1 From b28366cb5b514e5c59586f9a5509d3afff5337d5 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 053/232] 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 --- a/drivers/video/fbdev/core/fbmem.c
19 +++ b/drivers/video/fbdev/core/fbmem.c
20 @@ -1084,6 +1084,25 @@ fb_blank(struct fb_info *info, int blank
22 EXPORT_SYMBOL(fb_blank);
24 +static int fb_copyarea_user(struct fb_info *info,
25 + struct fb_copyarea *copy)
28 + if (!lock_fb_info(info))
30 + if (copy->dx + copy->width > info->var.xres ||
31 + copy->sx + copy->width > info->var.xres ||
32 + copy->dy + copy->height > info->var.yres ||
33 + copy->sy + copy->height > info->var.yres) {
37 + info->fbops->fb_copyarea(info, copy);
39 + unlock_fb_info(info);
43 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
46 @@ -1094,6 +1113,7 @@ static long do_fb_ioctl(struct fb_info *
47 struct fb_cmap cmap_from;
48 struct fb_cmap_user cmap;
49 struct fb_event event;
50 + struct fb_copyarea copy;
51 void __user *argp = (void __user *)arg;
54 @@ -1211,6 +1231,15 @@ static long do_fb_ioctl(struct fb_info *
59 + if (info->flags & FBINFO_HWACCEL_COPYAREA) {
60 + /* only provide this ioctl if it is accelerated */
61 + if (copy_from_user(©, argp, sizeof(copy)))
63 + ret = fb_copyarea_user(info, ©);
68 if (!lock_fb_info(info))
70 @@ -1365,6 +1394,7 @@ static long fb_compat_ioctl(struct file
72 case FBIOGET_CON2FBMAP:
73 case FBIOPUT_CON2FBMAP:
75 arg = (unsigned long) compat_ptr(arg);
77 ret = do_fb_ioctl(info, cmd, arg);
78 --- a/include/uapi/linux/fb.h
79 +++ b/include/uapi/linux/fb.h
81 #define FBIOPUT_MODEINFO 0x4617
82 #define FBIOGET_DISPINFO 0x4618
83 #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
85 + * HACK: use 'z' in order not to clash with any other ioctl numbers which might
86 + * be concurrently added to the mainline kernel
88 +#define FBIOCOPYAREA _IOW('z', 0x21, struct fb_copyarea)
90 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
91 #define FB_TYPE_PLANES 1 /* Non interleaved planes */