Commit c69d3a9c authored by David S. Miller's avatar David S. Miller

[SBUSFB]: Implement enough ioctls to get X working.

parent 8fe573f2
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
static int bw2_blank(int, struct fb_info *); static int bw2_blank(int, struct fb_info *);
static int bw2_mmap(struct fb_info *, struct file *, struct vm_area_struct *); static int bw2_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
static int bw2_ioctl(struct inode *, struct file *, unsigned int,
unsigned long, struct fb_info *);
/* /*
* Frame buffer operations * Frame buffer operations
...@@ -48,6 +50,7 @@ static struct fb_ops bw2_ops = { ...@@ -48,6 +50,7 @@ static struct fb_ops bw2_ops = {
.fb_copyarea = cfb_copyarea, .fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit, .fb_imageblit = cfb_imageblit,
.fb_mmap = bw2_mmap, .fb_mmap = bw2_mmap,
.fb_ioctl = bw2_ioctl,
.fb_cursor = soft_cursor, .fb_cursor = soft_cursor,
}; };
...@@ -175,6 +178,15 @@ static int bw2_mmap(struct fb_info *info, struct file *file, struct vm_area_stru ...@@ -175,6 +178,15 @@ static int bw2_mmap(struct fb_info *info, struct file *file, struct vm_area_stru
vma); vma);
} }
static int bw2_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg, struct fb_info *info)
{
struct bw2_par *par = (struct bw2_par *) info->par;
return sbusfb_ioctl_helper(cmd, info,
FBTYPE_SUN2BW, 1, par->fbsize);
}
/* /*
* Initialisation * Initialisation
*/ */
......
...@@ -321,7 +321,8 @@ static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -321,7 +321,8 @@ static int cg14_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
break; break;
default: default:
ret = -EINVAL; ret = sbusfb_ioctl_helper(cmd, info,
FBTYPE_MDICOLOR, 24, par->fbsize);
break; break;
}; };
......
...@@ -34,6 +34,8 @@ static int cg3_setcolreg(unsigned, unsigned, unsigned, unsigned, ...@@ -34,6 +34,8 @@ static int cg3_setcolreg(unsigned, unsigned, unsigned, unsigned,
static int cg3_blank(int, struct fb_info *); static int cg3_blank(int, struct fb_info *);
static int cg3_mmap(struct fb_info *, struct file *, struct vm_area_struct *); static int cg3_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
static int cg3_ioctl(struct inode *, struct file *, unsigned int,
unsigned long, struct fb_info *);
/* /*
* Frame buffer operations * Frame buffer operations
...@@ -47,6 +49,7 @@ static struct fb_ops cg3_ops = { ...@@ -47,6 +49,7 @@ static struct fb_ops cg3_ops = {
.fb_copyarea = cfb_copyarea, .fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit, .fb_imageblit = cfb_imageblit,
.fb_mmap = cg3_mmap, .fb_mmap = cg3_mmap,
.fb_ioctl = cg3_ioctl,
.fb_cursor = soft_cursor, .fb_cursor = soft_cursor,
}; };
...@@ -232,6 +235,15 @@ static int cg3_mmap(struct fb_info *info, struct file *file, struct vm_area_stru ...@@ -232,6 +235,15 @@ static int cg3_mmap(struct fb_info *info, struct file *file, struct vm_area_stru
vma); vma);
} }
static int cg3_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg, struct fb_info *info)
{
struct cg3_par *par = (struct cg3_par *) info->par;
return sbusfb_ioctl_helper(cmd, info,
FBTYPE_SUN3COLOR, 8, par->fbsize);
}
/* /*
* Initialisation * Initialisation
*/ */
......
...@@ -37,6 +37,8 @@ static void cg6_imageblit(struct fb_info *, struct fb_image *); ...@@ -37,6 +37,8 @@ static void cg6_imageblit(struct fb_info *, struct fb_image *);
static void cg6_fillrect(struct fb_info *, struct fb_fillrect *); static void cg6_fillrect(struct fb_info *, struct fb_fillrect *);
static int cg6_sync(struct fb_info *); static int cg6_sync(struct fb_info *);
static int cg6_mmap(struct fb_info *, struct file *, struct vm_area_struct *); static int cg6_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
static int cg6_ioctl(struct inode *, struct file *, unsigned int,
unsigned long, struct fb_info *);
/* /*
* Frame buffer operations * Frame buffer operations
...@@ -51,6 +53,7 @@ static struct fb_ops cg6_ops = { ...@@ -51,6 +53,7 @@ static struct fb_ops cg6_ops = {
.fb_imageblit = cg6_imageblit, .fb_imageblit = cg6_imageblit,
.fb_sync = cg6_sync, .fb_sync = cg6_sync,
.fb_mmap = cg6_mmap, .fb_mmap = cg6_mmap,
.fb_ioctl = cg6_ioctl,
.fb_cursor = soft_cursor, .fb_cursor = soft_cursor,
}; };
...@@ -498,6 +501,15 @@ static int cg6_mmap(struct fb_info *info, struct file *file, struct vm_area_stru ...@@ -498,6 +501,15 @@ static int cg6_mmap(struct fb_info *info, struct file *file, struct vm_area_stru
vma); vma);
} }
static int cg6_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg, struct fb_info *info)
{
struct cg6_par *par = (struct cg6_par *) info->par;
return sbusfb_ioctl_helper(cmd, info,
FBTYPE_SUNFAST_COLOR, 8, par->fbsize);
}
/* /*
* Initialisation * Initialisation
*/ */
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/upa.h> #include <asm/upa.h>
#include <asm/oplib.h> #include <asm/oplib.h>
#include <asm/fbio.h>
#include "sbuslib.h" #include "sbuslib.h"
...@@ -37,6 +38,8 @@ static void ffb_fillrect(struct fb_info *, struct fb_fillrect *); ...@@ -37,6 +38,8 @@ static void ffb_fillrect(struct fb_info *, struct fb_fillrect *);
static void ffb_copyarea(struct fb_info *, struct fb_copyarea *); static void ffb_copyarea(struct fb_info *, struct fb_copyarea *);
static int ffb_sync(struct fb_info *); static int ffb_sync(struct fb_info *);
static int ffb_mmap(struct fb_info *, struct file *, struct vm_area_struct *); static int ffb_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
static int ffb_ioctl(struct inode *, struct file *, unsigned int,
unsigned long, struct fb_info *);
/* /*
* Frame buffer operations * Frame buffer operations
...@@ -51,6 +54,7 @@ static struct fb_ops ffb_ops = { ...@@ -51,6 +54,7 @@ static struct fb_ops ffb_ops = {
.fb_imageblit = ffb_imageblit, .fb_imageblit = ffb_imageblit,
.fb_sync = ffb_sync, .fb_sync = ffb_sync,
.fb_mmap = ffb_mmap, .fb_mmap = ffb_mmap,
.fb_ioctl = ffb_ioctl,
/* XXX Use FFB hw cursor once fb cursor API is better understood... */ /* XXX Use FFB hw cursor once fb cursor API is better understood... */
.fb_cursor = soft_cursor, .fb_cursor = soft_cursor,
...@@ -779,6 +783,15 @@ static int ffb_mmap(struct fb_info *info, struct file *file, struct vm_area_stru ...@@ -779,6 +783,15 @@ static int ffb_mmap(struct fb_info *info, struct file *file, struct vm_area_stru
0, vma); 0, vma);
} }
static int ffb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg, struct fb_info *info)
{
struct ffb_par *par = (struct ffb_par *) info->par;
return sbusfb_ioctl_helper(cmd, info,
FBTYPE_CREATOR, 24, par->fbsize);
}
/* /*
* Initialisation * Initialisation
*/ */
......
...@@ -32,6 +32,8 @@ static int p9100_setcolreg(unsigned, unsigned, unsigned, unsigned, ...@@ -32,6 +32,8 @@ static int p9100_setcolreg(unsigned, unsigned, unsigned, unsigned,
static int p9100_blank(int, struct fb_info *); static int p9100_blank(int, struct fb_info *);
static int p9100_mmap(struct fb_info *, struct file *, struct vm_area_struct *); static int p9100_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
static int p9100_ioctl(struct inode *, struct file *, unsigned int,
unsigned long, struct fb_info *);
/* /*
* Frame buffer operations * Frame buffer operations
...@@ -45,6 +47,7 @@ static struct fb_ops p9100_ops = { ...@@ -45,6 +47,7 @@ static struct fb_ops p9100_ops = {
.fb_copyarea = cfb_copyarea, .fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit, .fb_imageblit = cfb_imageblit,
.fb_mmap = p9100_mmap, .fb_mmap = p9100_mmap,
.fb_ioctl = p9100_ioctl,
.fb_cursor = soft_cursor, .fb_cursor = soft_cursor,
}; };
...@@ -228,6 +231,16 @@ static int p9100_mmap(struct fb_info *info, struct file *file, struct vm_area_st ...@@ -228,6 +231,16 @@ static int p9100_mmap(struct fb_info *info, struct file *file, struct vm_area_st
vma); vma);
} }
static int p9100_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg, struct fb_info *info)
{
struct p9100_par *par = (struct p9100_par *) info->par;
/* Make it look like a cg3. */
return sbusfb_ioctl_helper(cmd, info,
FBTYPE_SUN3COLOR, 8, par->fbsize);
}
/* /*
* Initialisation * Initialisation
*/ */
......
...@@ -83,3 +83,81 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map, ...@@ -83,3 +83,81 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,
return 0; return 0;
} }
EXPORT_SYMBOL(sbusfb_mmap_helper);
int sbusfb_ioctl_helper(unsigned long cmd, struct fb_info *info,
int type, int fb_depth, unsigned long fb_size)
{
switch(cmd) {
case FBIOGTYPE: {
struct fbtype *f = (struct fbtype *) arg;
if (put_user(type, &f->fb_type) ||
__put_user(info->var.yres, &f->fb_height) ||
__put_user(info->var.xres, &f->fb_width) ||
__put_user(fb_depth, &f->fb_depth) ||
__put_user(0, &f->fb_cmsize) ||
__put_user(fb_size, &f->fb_cmsize))
return -EFAULT;
return 0;
}
case FBIOPUTCMAP_SPARC: {
struct fbcmap *c = (struct fbcmap *) arg;
struct fb_cmap cmap;
u16 red, green, blue;
unsigned char *ured, *ugreen, *ublue;
int index, count, i, err;
if (get_user(index, &c->index) ||
__get_user(count, &c->count) ||
__get_user(ured, &c->red) ||
__get_user(ugreen, &c->green) ||
__get_user(ublue, &c->blue))
return -EFAULT;
cmap.len = 1;
cmap.red = &red;
cmap.green = &green;
cmap.blue = &blue;
for (i = 0; i < count; i++) {
if (get_user(red, &ured[i]) ||
get_user(green, &ugreen[i]) ||
get_user(blue, &ublue[i]))
return -EFAULT;
cmap.start = index + i;
err = fb_set_cmap(&cmap, 0, info);
if (err)
break;
}
return err;
}
case FBIOGETCMAP_SPARC: {
struct fbcmap *c = (struct fbcmap *) arg;
unsigned char *ured, *ugreen, *ublue;
struct fb_cmap *cmap = &info->cmap;
int index, count, i, err;
if (get_user(index, &c->index) ||
__get_user(count, &c->count) ||
__get_user(ured, &c->red) ||
__get_user(ugreen, &c->green) ||
__get_user(ublue, &c->blue))
return -EFAULT;
if (index + count > cmap->len)
return -EINVAL;
for (i = 0; i < count; i++) {
if (put_user(cmap->red[index + i], &ured[i]) ||
put_user(cmap->green[index + i], &ugreen[i]) ||
put_user(cmap->blue[index + i], &ublue[i]))
return -EFAULT;
}
return err;
}
default:
return -EINVAL;
};
}
EXPORT_SYMBOL(sbusfb_ioctl_helper);
...@@ -17,5 +17,7 @@ extern int sbusfb_mmap_helper(struct sbus_mmap_map *map, ...@@ -17,5 +17,7 @@ extern int sbusfb_mmap_helper(struct sbus_mmap_map *map,
unsigned long physbase, unsigned long fbsize, unsigned long physbase, unsigned long fbsize,
unsigned long iospace, unsigned long iospace,
struct vm_area_struct *vma); struct vm_area_struct *vma);
int sbusfb_ioctl_helper(unsigned long cmd, struct fb_info *info,
int type, int fb_depth, unsigned long fb_size);
#endif /* _SBUSLIB_H */ #endif /* _SBUSLIB_H */
...@@ -34,6 +34,8 @@ static int tcx_setcolreg(unsigned, unsigned, unsigned, unsigned, ...@@ -34,6 +34,8 @@ static int tcx_setcolreg(unsigned, unsigned, unsigned, unsigned,
static int tcx_blank(int, struct fb_info *); static int tcx_blank(int, struct fb_info *);
static int tcx_mmap(struct fb_info *, struct file *, struct vm_area_struct *); static int tcx_mmap(struct fb_info *, struct file *, struct vm_area_struct *);
static int tcx_ioctl(struct inode *, struct file *, unsigned int,
unsigned long, struct fb_info *);
/* /*
* Frame buffer operations * Frame buffer operations
...@@ -47,6 +49,7 @@ static struct fb_ops tcx_ops = { ...@@ -47,6 +49,7 @@ static struct fb_ops tcx_ops = {
.fb_copyarea = cfb_copyarea, .fb_copyarea = cfb_copyarea,
.fb_imageblit = cfb_imageblit, .fb_imageblit = cfb_imageblit,
.fb_mmap = tcx_mmap, .fb_mmap = tcx_mmap,
.fb_ioctl = tcx_ioctl,
.fb_cursor = soft_cursor, .fb_cursor = soft_cursor,
}; };
...@@ -261,6 +264,17 @@ static int tcx_mmap(struct fb_info *info, struct file *file, struct vm_area_stru ...@@ -261,6 +264,17 @@ static int tcx_mmap(struct fb_info *info, struct file *file, struct vm_area_stru
vma); vma);
} }
static int tcx_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg, struct fb_info *info)
{
struct tcx_par *par = (struct tcx_par *) info->par;
return sbusfb_ioctl_helper(cmd, info,
FBTYPE_TCXCOLOR,
(par->lowdepth ? 8 : 24),
par->fbsize);
}
/* /*
* Initialisation * Initialisation
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment