2 * linux/drivers/video/fb_sys_read.c - Generic file operations where
3 * framebuffer is in system RAM
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, c;
25 if (!(info->flags & FBINFO_VIRTFB))
26 fb_warn_once(info, "Framebuffer is not in virtual address space.");
28 if (!info->screen_buffer)
31 total_size = info->screen_size;
34 total_size = info->fix.smem_len;
39 if (count >= total_size)
42 if (count + p > total_size)
43 count = total_size - p;
45 src = info->screen_buffer + p;
47 if (info->fbops->fb_sync)
48 info->fbops->fb_sync(info);
50 c = copy_to_user(buf, src, count);
57 return ret ? ret : err;
59 EXPORT_SYMBOL_GPL(fb_sys_read);
61 ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
62 size_t count, loff_t *ppos)
64 unsigned long p = *ppos;
67 unsigned long total_size, c;
70 if (!(info->flags & FBINFO_VIRTFB))
71 fb_warn_once(info, "Framebuffer is not in virtual address space.");
73 if (!info->screen_buffer)
76 total_size = info->screen_size;
79 total_size = info->fix.smem_len;
84 if (count > total_size) {
89 if (count + p > total_size) {
93 count = total_size - p;
96 dst = info->screen_buffer + p;
98 if (info->fbops->fb_sync)
99 info->fbops->fb_sync(info);
101 c = copy_from_user(dst, buf, count);
108 return ret ? ret : err;
110 EXPORT_SYMBOL_GPL(fb_sys_write);
113 MODULE_DESCRIPTION("Generic file read (fb in system RAM)");
114 MODULE_LICENSE("GPL");