[PATCH 1/2] fbdev: add FBIOFILLRECT ioctl

From: Ali Gholami Rudi
Date: Mon Jul 13 2009 - 11:19:23 EST


Signed-off-by: Ali Gholami Rudi <ali@xxxxxxx>
---
drivers/video/fbmem.c | 25 +++++++++++++++++++++++++
include/linux/fb.h | 1 +
2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index a85c818..a90cd0f 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1016,6 +1016,25 @@ fb_blank(struct fb_info *info, int blank)
return ret;
}

+static int fb_fillrect_user(struct fb_info *info,
+ struct fb_fillrect *fill)
+{
+ int ret = 0;
+ if (fill->rop != ROP_COPY && fill->rop != ROP_XOR)
+ return -EINVAL;
+ if (!lock_fb_info(info))
+ return -ENODEV;
+ if (fill->dx + fill->width > info->var.xres ||
+ fill->dy + fill->height > info->var.yres) {
+ ret = -EINVAL;
+ goto out;
+ }
+ info->fbops->fb_fillrect(info, fill);
+out:
+ unlock_fb_info(info);
+ return ret;
+}
+
static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
unsigned long arg)
{
@@ -1026,6 +1045,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
struct fb_cmap cmap_from;
struct fb_cmap_user cmap;
struct fb_event event;
+ struct fb_fillrect fill;
void __user *argp = (void __user *)arg;
long ret = 0;

@@ -1133,6 +1153,11 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
release_console_sem();
unlock_fb_info(info);
break;
+ case FBIOFILLRECT:
+ if (copy_from_user(&fill, argp, sizeof(fill)))
+ return -EFAULT;
+ ret = fb_fillrect_user(info, &fill);
+ break;
default:
if (!lock_fb_info(info))
return -ENODEV;
diff --git a/include/linux/fb.h b/include/linux/fb.h
index f847df9..40cc99a 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -37,6 +37,7 @@ struct dentry;
#define FBIOGET_HWCINFO 0x4616
#define FBIOPUT_MODEINFO 0x4617
#define FBIOGET_DISPINFO 0x4618
+#define FBIOFILLRECT 0x4619


#define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/