1 From f67ad61f5999035fad1610d00a966989f34e3ce5 Mon Sep 17 00:00:00 2001
2 From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
3 Date: Mon, 17 Jun 2013 13:32:11 +0300
4 Subject: [PATCH 008/114] fbdev: add FBIOCOPYAREA ioctl
6 Based on the patch authored by Ali Gholami Rudi at
7 https://lkml.org/lkml/2009/7/13/153
9 Provide an ioctl for userspace applications, but only if this operation
10 is hardware accelerated (otherwide it does not make any sense).
12 Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
14 drivers/video/fbdev/core/fbmem.c | 30 ++++++++++++++++++++++++++++++
15 include/uapi/linux/fb.h | 5 +++++
16 2 files changed, 35 insertions(+)
18 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
19 index 0705d88..771992a 100644
20 --- a/drivers/video/fbdev/core/fbmem.c
21 +++ b/drivers/video/fbdev/core/fbmem.c
22 @@ -1084,6 +1084,25 @@ fb_blank(struct fb_info *info, int blank)
24 EXPORT_SYMBOL(fb_blank);
26 +static int fb_copyarea_user(struct fb_info *info,
27 + struct fb_copyarea *copy)
30 + if (!lock_fb_info(info))
32 + if (copy->dx + copy->width > info->var.xres ||
33 + copy->sx + copy->width > info->var.xres ||
34 + copy->dy + copy->height > info->var.yres ||
35 + copy->sy + copy->height > info->var.yres) {
39 + info->fbops->fb_copyarea(info, copy);
41 + unlock_fb_info(info);
45 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
48 @@ -1094,6 +1113,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49 struct fb_cmap cmap_from;
50 struct fb_cmap_user cmap;
51 struct fb_event event;
52 + struct fb_copyarea copy;
53 void __user *argp = (void __user *)arg;
56 @@ -1211,6 +1231,15 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
61 + if (info->flags & FBINFO_HWACCEL_COPYAREA) {
62 + /* only provide this ioctl if it is accelerated */
63 + if (copy_from_user(©, argp, sizeof(copy)))
65 + ret = fb_copyarea_user(info, ©);
70 if (!lock_fb_info(info))
72 @@ -1365,6 +1394,7 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,
74 case FBIOGET_CON2FBMAP:
75 case FBIOPUT_CON2FBMAP:
77 arg = (unsigned long) compat_ptr(arg);
79 ret = do_fb_ioctl(info, cmd, arg);
80 diff --git a/include/uapi/linux/fb.h b/include/uapi/linux/fb.h
81 index fb795c3..fa72af0 100644
82 --- a/include/uapi/linux/fb.h
83 +++ b/include/uapi/linux/fb.h
85 #define FBIOPUT_MODEINFO 0x4617
86 #define FBIOGET_DISPINFO 0x4618
87 #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
89 + * HACK: use 'z' in order not to clash with any other ioctl numbers which might
90 + * be concurrently added to the mainline kernel
92 +#define FBIOCOPYAREA _IOW('z', 0x21, struct fb_copyarea)
94 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
95 #define FB_TYPE_PLANES 1 /* Non interleaved planes */