brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
[openwrt/svn-archive/archive.git] / target / linux / brcm2708 / patches-3.10 / 0069-fbdev-add-FBIOCOPYAREA-ioctl.patch
1 From 422d5162d6b4e5cd8f7a9470b128577d1b826bdd 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 069/196] fbdev: add FBIOCOPYAREA ioctl
5
6 Based on the patch authored by Ali Gholami Rudi at
7 https://lkml.org/lkml/2009/7/13/153
8
9 Provide an ioctl for userspace applications, but only if this operation
10 is hardware accelerated (otherwide it does not make any sense).
11
12 Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
13 ---
14 drivers/video/fbmem.c | 30 ++++++++++++++++++++++++++++++
15 include/uapi/linux/fb.h | 5 +++++
16 2 files changed, 35 insertions(+)
17
18 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
19 index 098bfc6..da8e53b 100644
20 --- a/drivers/video/fbmem.c
21 +++ b/drivers/video/fbmem.c
22 @@ -1074,6 +1074,25 @@ fb_blank(struct fb_info *info, int blank)
23 return ret;
24 }
25
26 +static int fb_copyarea_user(struct fb_info *info,
27 + struct fb_copyarea *copy)
28 +{
29 + int ret = 0;
30 + if (!lock_fb_info(info))
31 + return -ENODEV;
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) {
36 + ret = -EINVAL;
37 + goto out;
38 + }
39 + info->fbops->fb_copyarea(info, copy);
40 +out:
41 + unlock_fb_info(info);
42 + return ret;
43 +}
44 +
45 static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
46 unsigned long arg)
47 {
48 @@ -1084,6 +1103,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;
54 long ret = 0;
55
56 @@ -1193,6 +1213,15 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
57 console_unlock();
58 unlock_fb_info(info);
59 break;
60 + case FBIOCOPYAREA:
61 + if (info->flags & FBINFO_HWACCEL_COPYAREA) {
62 + /* only provide this ioctl if it is accelerated */
63 + if (copy_from_user(&copy, argp, sizeof(copy)))
64 + return -EFAULT;
65 + ret = fb_copyarea_user(info, &copy);
66 + break;
67 + }
68 + /* fall through */
69 default:
70 if (!lock_fb_info(info))
71 return -ENODEV;
72 @@ -1345,6 +1374,7 @@ static long fb_compat_ioctl(struct file *file, unsigned int cmd,
73 case FBIOPAN_DISPLAY:
74 case FBIOGET_CON2FBMAP:
75 case FBIOPUT_CON2FBMAP:
76 + case FBIOCOPYAREA:
77 arg = (unsigned long) compat_ptr(arg);
78 case FBIOBLANK:
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
84 @@ -34,6 +34,11 @@
85 #define FBIOPUT_MODEINFO 0x4617
86 #define FBIOGET_DISPINFO 0x4618
87 #define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
88 +/*
89 + * HACK: use 'z' in order not to clash with any other ioctl numbers which might
90 + * be concurrently added to the mainline kernel
91 + */
92 +#define FBIOCOPYAREA _IOW('z', 0x21, struct fb_copyarea)
93
94 #define FB_TYPE_PACKED_PIXELS 0 /* Packed Pixels */
95 #define FB_TYPE_PLANES 1 /* Non interleaved planes */
96 --
97 1.9.1
98