2 * linux/drivers/video/fb_sys_read.c - Generic file operations where
3 * framebuffer is in system RAM
5 * Copyright (C) 2007 Antonino Daplas <adaplas@pol.net>
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file COPYING in the main directory of this archive
13 #include <linux/module.h>
14 #include <linux/uaccess.h>
16 ssize_t
fb_sys_read(struct fb_info
*info
, char __user
*buf
, size_t count
,
19 unsigned long p
= *ppos
;
22 unsigned long total_size
;
24 if (info
->state
!= FBINFO_STATE_RUNNING
)
27 total_size
= info
->screen_size
;
30 total_size
= info
->fix
.smem_len
;
35 if (count
>= total_size
)
38 if (count
+ p
> total_size
)
39 count
= total_size
- p
;
41 src
= (void __force
*)(info
->screen_base
+ p
);
43 if (info
->fbops
->fb_sync
)
44 info
->fbops
->fb_sync(info
);
46 if (copy_to_user(buf
, src
, count
))
52 return (err
) ? err
: count
;
54 EXPORT_SYMBOL_GPL(fb_sys_read
);
56 ssize_t
fb_sys_write(struct fb_info
*info
, const char __user
*buf
,
57 size_t count
, loff_t
*ppos
)
59 unsigned long p
= *ppos
;
62 unsigned long total_size
;
64 if (info
->state
!= FBINFO_STATE_RUNNING
)
67 total_size
= info
->screen_size
;
70 total_size
= info
->fix
.smem_len
;
75 if (count
> total_size
) {
80 if (count
+ p
> total_size
) {
84 count
= total_size
- p
;
87 dst
= (void __force
*) (info
->screen_base
+ p
);
89 if (info
->fbops
->fb_sync
)
90 info
->fbops
->fb_sync(info
);
92 if (copy_from_user(dst
, buf
, count
))
98 return (err
) ? err
: count
;
100 EXPORT_SYMBOL_GPL(fb_sys_write
);
102 MODULE_AUTHOR("Antonino Daplas <adaplas@pol.net>");
103 MODULE_DESCRIPTION("Generic file read (fb in system RAM)");
104 MODULE_LICENSE("GPL");