aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/sbuslib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/sbuslib.c')
-rw-r--r--drivers/video/sbuslib.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c
index 34f72edba820..3a74a63dd4f2 100644
--- a/drivers/video/sbuslib.c
+++ b/drivers/video/sbuslib.c
@@ -3,6 +3,7 @@
3 * Copyright (C) 2003 David S. Miller (davem@redhat.com) 3 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#include <linux/compat.h>
6#include <linux/kernel.h> 7#include <linux/kernel.h>
7#include <linux/module.h> 8#include <linux/module.h>
8#include <linux/string.h> 9#include <linux/string.h>
@@ -45,6 +46,9 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,
45 unsigned long off; 46 unsigned long off;
46 int i; 47 int i;
47 48
49 if (!(vma->vm_flags & (VM_SHARED | VM_MAYSHARE)))
50 return -EINVAL;
51
48 size = vma->vm_end - vma->vm_start; 52 size = vma->vm_end - vma->vm_start;
49 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 53 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
50 return -EINVAL; 54 return -EINVAL;
@@ -182,3 +186,109 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
182 }; 186 };
183} 187}
184EXPORT_SYMBOL(sbusfb_ioctl_helper); 188EXPORT_SYMBOL(sbusfb_ioctl_helper);
189
190#ifdef CONFIG_COMPAT
191struct fbcmap32 {
192 int index; /* first element (0 origin) */
193 int count;
194 u32 red;
195 u32 green;
196 u32 blue;
197};
198
199#define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
200#define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
201
202static int fbiogetputcmap(struct file *file, struct fb_info *info,
203 unsigned int cmd, unsigned long arg)
204{
205 struct fbcmap32 __user *argp = (void __user *)arg;
206 struct fbcmap __user *p = compat_alloc_user_space(sizeof(*p));
207 u32 addr;
208 int ret;
209
210 ret = copy_in_user(p, argp, 2 * sizeof(int));
211 ret |= get_user(addr, &argp->red);
212 ret |= put_user(compat_ptr(addr), &p->red);
213 ret |= get_user(addr, &argp->green);
214 ret |= put_user(compat_ptr(addr), &p->green);
215 ret |= get_user(addr, &argp->blue);
216 ret |= put_user(compat_ptr(addr), &p->blue);
217 if (ret)
218 return -EFAULT;
219 return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
220 (cmd == FBIOPUTCMAP32) ?
221 FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC,
222 (unsigned long)p, info);
223}
224
225struct fbcursor32 {
226 short set; /* what to set, choose from the list above */
227 short enable; /* cursor on/off */
228 struct fbcurpos pos; /* cursor position */
229 struct fbcurpos hot; /* cursor hot spot */
230 struct fbcmap32 cmap; /* color map info */
231 struct fbcurpos size; /* cursor bit map size */
232 u32 image; /* cursor image bits */
233 u32 mask; /* cursor mask bits */
234};
235
236#define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
237#define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
238
239static int fbiogscursor(struct file *file, struct fb_info *info,
240 unsigned long arg)
241{
242 struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p));
243 struct fbcursor32 __user *argp = (void __user *)arg;
244 compat_uptr_t addr;
245 int ret;
246
247 ret = copy_in_user(p, argp,
248 2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
249 ret |= copy_in_user(&p->size, &argp->size, sizeof(struct fbcurpos));
250 ret |= copy_in_user(&p->cmap, &argp->cmap, 2 * sizeof(int));
251 ret |= get_user(addr, &argp->cmap.red);
252 ret |= put_user(compat_ptr(addr), &p->cmap.red);
253 ret |= get_user(addr, &argp->cmap.green);
254 ret |= put_user(compat_ptr(addr), &p->cmap.green);
255 ret |= get_user(addr, &argp->cmap.blue);
256 ret |= put_user(compat_ptr(addr), &p->cmap.blue);
257 ret |= get_user(addr, &argp->mask);
258 ret |= put_user(compat_ptr(addr), &p->mask);
259 ret |= get_user(addr, &argp->image);
260 ret |= put_user(compat_ptr(addr), &p->image);
261 if (ret)
262 return -EFAULT;
263 return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
264 FBIOSCURSOR, (unsigned long)p, info);
265}
266
267long sbusfb_compat_ioctl(struct file *file, unsigned int cmd,
268 unsigned long arg, struct fb_info *info)
269{
270 switch (cmd) {
271 case FBIOGTYPE:
272 case FBIOSATTR:
273 case FBIOGATTR:
274 case FBIOSVIDEO:
275 case FBIOGVIDEO:
276 case FBIOGCURSOR32: /* This is not implemented yet.
277 Later it should be converted... */
278 case FBIOSCURPOS:
279 case FBIOGCURPOS:
280 case FBIOGCURMAX:
281 return info->fbops->fb_ioctl(file->f_dentry->d_inode,
282 file, cmd, arg, info);
283 case FBIOPUTCMAP32:
284 return fbiogetputcmap(file, info, cmd, arg);
285 case FBIOGETCMAP32:
286 return fbiogetputcmap(file, info, cmd, arg);
287 case FBIOSCURSOR32:
288 return fbiogscursor(file, info, arg);
289 default:
290 return -ENOIOCTLCMD;
291 }
292}
293EXPORT_SYMBOL(sbusfb_compat_ioctl);
294#endif