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.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c
index 34f72edba820..646c43f921c5 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>
@@ -182,3 +183,109 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
182 }; 183 };
183} 184}
184EXPORT_SYMBOL(sbusfb_ioctl_helper); 185EXPORT_SYMBOL(sbusfb_ioctl_helper);
186
187#ifdef CONFIG_COMPAT
188struct fbcmap32 {
189 int index; /* first element (0 origin) */
190 int count;
191 u32 red;
192 u32 green;
193 u32 blue;
194};
195
196#define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
197#define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
198
199static int fbiogetputcmap(struct file *file, struct fb_info *info,
200 unsigned int cmd, unsigned long arg)
201{
202 struct fbcmap32 __user *argp = (void __user *)arg;
203 struct fbcmap __user *p = compat_alloc_user_space(sizeof(*p));
204 u32 addr;
205 int ret;
206
207 ret = copy_in_user(p, argp, 2 * sizeof(int));
208 ret |= get_user(addr, &argp->red);
209 ret |= put_user(compat_ptr(addr), &p->red);
210 ret |= get_user(addr, &argp->green);
211 ret |= put_user(compat_ptr(addr), &p->green);
212 ret |= get_user(addr, &argp->blue);
213 ret |= put_user(compat_ptr(addr), &p->blue);
214 if (ret)
215 return -EFAULT;
216 return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
217 (cmd == FBIOPUTCMAP32) ?
218 FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC,
219 (unsigned long)p, info);
220}
221
222struct fbcursor32 {
223 short set; /* what to set, choose from the list above */
224 short enable; /* cursor on/off */
225 struct fbcurpos pos; /* cursor position */
226 struct fbcurpos hot; /* cursor hot spot */
227 struct fbcmap32 cmap; /* color map info */
228 struct fbcurpos size; /* cursor bit map size */
229 u32 image; /* cursor image bits */
230 u32 mask; /* cursor mask bits */
231};
232
233#define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
234#define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
235
236static int fbiogscursor(struct file *file, struct fb_info *info,
237 unsigned long arg)
238{
239 struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p));
240 struct fbcursor32 __user *argp = (void __user *)arg;
241 compat_uptr_t addr;
242 int ret;
243
244 ret = copy_in_user(p, argp,
245 2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
246 ret |= copy_in_user(&p->size, &argp->size, sizeof(struct fbcurpos));
247 ret |= copy_in_user(&p->cmap, &argp->cmap, 2 * sizeof(int));
248 ret |= get_user(addr, &argp->cmap.red);
249 ret |= put_user(compat_ptr(addr), &p->cmap.red);
250 ret |= get_user(addr, &argp->cmap.green);
251 ret |= put_user(compat_ptr(addr), &p->cmap.green);
252 ret |= get_user(addr, &argp->cmap.blue);
253 ret |= put_user(compat_ptr(addr), &p->cmap.blue);
254 ret |= get_user(addr, &argp->mask);
255 ret |= put_user(compat_ptr(addr), &p->mask);
256 ret |= get_user(addr, &argp->image);
257 ret |= put_user(compat_ptr(addr), &p->image);
258 if (ret)
259 return -EFAULT;
260 return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
261 FBIOSCURSOR, (unsigned long)p, info);
262}
263
264long sbusfb_compat_ioctl(struct file *file, unsigned int cmd,
265 unsigned long arg, struct fb_info *info)
266{
267 switch (cmd) {
268 case FBIOGTYPE:
269 case FBIOSATTR:
270 case FBIOGATTR:
271 case FBIOSVIDEO:
272 case FBIOGVIDEO:
273 case FBIOGCURSOR32: /* This is not implemented yet.
274 Later it should be converted... */
275 case FBIOSCURPOS:
276 case FBIOGCURPOS:
277 case FBIOGCURMAX:
278 return info->fbops->fb_ioctl(file->f_dentry->d_inode,
279 file, cmd, arg, info);
280 case FBIOPUTCMAP32:
281 return fbiogetputcmap(file, info, cmd, arg);
282 case FBIOGETCMAP32:
283 return fbiogetputcmap(file, info, cmd, arg);
284 case FBIOSCURSOR32:
285 return fbiogscursor(file, info, arg);
286 default:
287 return -ENOIOCTLCMD;
288 }
289}
290EXPORT_SYMBOL(sbusfb_compat_ioctl);
291#endif