
From: James Simmons <jsimmons@infradead.org>

This patch forbids the cursor use from userland.  The reason is that the
cursor area could be altered by a another process and the current system
doesn't handle syncing those updates.


Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 drivers/video/aty/mach64_cursor.c  |    2 +-
 drivers/video/fbsysfs.c            |   10 ++++++++--
 drivers/video/i810/i810.h          |    1 -
 drivers/video/i810/i810_main.c     |    7 +++----
 drivers/video/intelfb/intelfb.h    |    1 -
 drivers/video/intelfb/intelfbdrv.c |   21 ++++-----------------
 drivers/video/intelfb/intelfbhw.c  |    4 ----
 drivers/video/nvidia/nvidia.c      |    1 +
 drivers/video/riva/fbdev.c         |    3 ++-
 include/linux/fb.h                 |    1 +
 10 files changed, 20 insertions(+), 31 deletions(-)

diff -puN drivers/video/aty/mach64_cursor.c~fbdev-dont-allow-softcursor-use-from-userland drivers/video/aty/mach64_cursor.c
--- devel/drivers/video/aty/mach64_cursor.c~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/aty/mach64_cursor.c	2005-08-06 21:28:28.000000000 -0700
@@ -219,8 +219,8 @@ int __init aty_init_cursor(struct fb_inf
 	info->sprite.buf_align = 16; 	/* and 64 lines tall. */
 	info->sprite.flags = FB_PIXMAP_IO;
 
+	info->flags |= FBINFO_HWACCEL_CURSOR;
 	info->fbops->fb_cursor = atyfb_cursor;
-
 	return 0;
 }
 
diff -puN drivers/video/fbsysfs.c~fbdev-dont-allow-softcursor-use-from-userland drivers/video/fbsysfs.c
--- devel/drivers/video/fbsysfs.c~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/fbsysfs.c	2005-08-06 21:28:28.000000000 -0700
@@ -371,13 +371,19 @@ static ssize_t show_console(struct class
 static ssize_t store_cursor(struct class_device *class_device,
 			    const char * buf, size_t count)
 {
-//	struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device);
+	struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device);
+
+	if (!(fb_info->flags & FBINFO_HWACCEL_CURSOR))
+		return -ENXIO;
 	return 0;
 }
 
 static ssize_t show_cursor(struct class_device *class_device, char *buf)
 {
-//	struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device);
+	struct fb_info *fb_info = (struct fb_info *)class_get_devdata(class_device);
+
+	if (!(fb_info->flags & FBINFO_HWACCEL_CURSOR))
+		return -ENXIO;
 	return 0;
 }
 
diff -puN drivers/video/i810/i810.h~fbdev-dont-allow-softcursor-use-from-userland drivers/video/i810/i810.h
--- devel/drivers/video/i810/i810.h~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/i810/i810.h	2005-08-06 21:28:28.000000000 -0700
@@ -201,7 +201,6 @@
 #define HAS_ACCELERATION            2
 #define ALWAYS_SYNC                 4
 #define LOCKUP                      8
-#define USE_HWCUR                  16
 
 struct gtt_data {
 	struct agp_memory *i810_fb_memory;
diff -puN drivers/video/i810/i810_main.c~fbdev-dont-allow-softcursor-use-from-userland drivers/video/i810/i810_main.c
--- devel/drivers/video/i810/i810_main.c~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/i810/i810_main.c	2005-08-06 21:28:28.000000000 -0700
@@ -1375,7 +1375,6 @@ static int i810fb_set_par(struct fb_info
 	decode_var(&info->var, par);
 	i810_load_regs(par);
 	i810_init_cursor(par);
-
 	encode_fix(&info->fix, info);
 
 	if (info->var.accel_flags && !(par->dev_flags & LOCKUP)) {
@@ -1387,6 +1386,7 @@ static int i810fb_set_par(struct fb_info
 		info->pixmap.scan_align = 1;
 		info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
 	}
+	info->flags |= FBINFO_HWACCEL_CURSOR;
 	return 0;
 }
 
@@ -1418,9 +1418,8 @@ static int i810fb_cursor(struct fb_info 
 	struct i810fb_par *par = (struct i810fb_par *)info->par;
 	u8 __iomem *mmio = par->mmio_start_virtual;
 
-	if (!(par->dev_flags & USE_HWCUR) || !info->var.accel_flags ||
-	    par->dev_flags & LOCKUP)
-		return soft_cursor(info, cursor);
+	if (!par->dev_flags & LOCKUP)
+		return -ENXIO;
 
 	if (cursor->image.width > 64 || cursor->image.height > 64)
 		return -ENXIO;
diff -puN drivers/video/intelfb/intelfbdrv.c~fbdev-dont-allow-softcursor-use-from-userland drivers/video/intelfb/intelfbdrv.c
--- devel/drivers/video/intelfb/intelfbdrv.c~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/intelfb/intelfbdrv.c	2005-08-06 21:28:28.000000000 -0700
@@ -117,14 +117,10 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
-#include <linux/console.h>
-#include <linux/selection.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
-#include <linux/kd.h>
-#include <linux/vt_kern.h>
 #include <linux/pagemap.h>
 #include <linux/version.h>
 
@@ -242,7 +238,7 @@ static int voffset	= 48;
 static char *mode       = NULL;
 
 module_param(accel, bool, S_IRUGO);
-MODULE_PARM_DESC(accel, "Enable console acceleration");
+MODULE_PARM_DESC(accel, "Enable hardware acceleration");
 module_param(vram, int, S_IRUGO);
 MODULE_PARM_DESC(vram, "System RAM to allocate to framebuffer in MiB");
 module_param(voffset, int, S_IRUGO);
@@ -498,7 +494,7 @@ intelfb_pci_register(struct pci_dev *pde
 {
 	struct fb_info *info;
 	struct intelfb_info *dinfo;
-	int i, j, err, dvo;
+	int i, err, dvo;
 	int aperture_size, stolen_size;
 	struct agp_kern_info gtt_info;
 	int agp_memtype;
@@ -841,13 +837,6 @@ intelfb_pci_register(struct pci_dev *pde
 	if (bailearly == 5)
 		bailout(dinfo);
 
-	for (i = 0; i < 16; i++) {
-		j = color_table[i];
-		dinfo->palette[i].red = default_red[j];
-		dinfo->palette[i].green = default_grn[j];
-		dinfo->palette[i].blue = default_blu[j];
-	}
-
 	if (bailearly == 6)
 		bailout(dinfo);
 
@@ -1332,6 +1321,8 @@ intelfb_set_par(struct fb_info *info)
 	} else {
 		info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN;
 	}
+	if (dinfo->hwcursor)
+		info->flags |= FBINFO_HWACCEL_CURSOR;
 	kfree(hw);
 	return 0;
 invalid_mode:
@@ -1359,10 +1350,6 @@ intelfb_setcolreg(unsigned regno, unsign
 			green >>= 8;
 			blue >>= 8;
 
-			dinfo->palette[regno].red = red;
-			dinfo->palette[regno].green = green;
-			dinfo->palette[regno].blue = blue;
-
 			intelfbhw_setcolreg(dinfo, regno, red, green, blue,
 					    transp);
 		}
diff -puN drivers/video/intelfb/intelfb.h~fbdev-dont-allow-softcursor-use-from-userland drivers/video/intelfb/intelfb.h
--- devel/drivers/video/intelfb/intelfb.h~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/intelfb/intelfb.h	2005-08-06 21:28:28.000000000 -0700
@@ -234,7 +234,6 @@ struct intelfb_info {
 
 	/* palette */
 	u32 pseudo_palette[17];
-	struct { u8 red, green, blue, pad; } palette[256];
 
 	/* chip info */
 	int pci_chipset;
diff -puN drivers/video/intelfb/intelfbhw.c~fbdev-dont-allow-softcursor-use-from-userland drivers/video/intelfb/intelfbhw.c
--- devel/drivers/video/intelfb/intelfbhw.c~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/intelfb/intelfbhw.c	2005-08-06 21:28:28.000000000 -0700
@@ -29,14 +29,10 @@
 #include <linux/slab.h>
 #include <linux/delay.h>
 #include <linux/fb.h>
-#include <linux/console.h>
-#include <linux/selection.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/vmalloc.h>
-#include <linux/kd.h>
-#include <linux/vt_kern.h>
 #include <linux/pagemap.h>
 #include <linux/version.h>
 
diff -puN drivers/video/nvidia/nvidia.c~fbdev-dont-allow-softcursor-use-from-userland drivers/video/nvidia/nvidia.c
--- devel/drivers/video/nvidia/nvidia.c~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/nvidia/nvidia.c	2005-08-06 21:28:28.000000000 -0700
@@ -1300,6 +1300,7 @@ static int __devinit nvidia_set_fbinfo(s
 	    | FBINFO_HWACCEL_IMAGEBLIT
 	    | FBINFO_HWACCEL_FILLRECT
 	    | FBINFO_HWACCEL_COPYAREA
+	    | FBINFO_HWACCEL_CURSOR
 	    | FBINFO_HWACCEL_YPAN;
 
 	fb_videomode_to_modelist(info->monspecs.modedb,
diff -puN drivers/video/riva/fbdev.c~fbdev-dont-allow-softcursor-use-from-userland drivers/video/riva/fbdev.c
--- devel/drivers/video/riva/fbdev.c~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/drivers/video/riva/fbdev.c	2005-08-06 21:28:28.000000000 -0700
@@ -1704,7 +1704,8 @@ static int __devinit riva_set_fbinfo(str
 		    | FBINFO_HWACCEL_YPAN
 		    | FBINFO_HWACCEL_COPYAREA
 		    | FBINFO_HWACCEL_FILLRECT
-	            | FBINFO_HWACCEL_IMAGEBLIT;
+	            | FBINFO_HWACCEL_IMAGEBLIT
+		    | FBINFO_HWACCEL_CURSOR;
 
 	/* Accel seems to not work properly on NV30 yet...*/
 	if ((par->riva.Architecture == NV_ARCH_30) || noaccel) {
diff -puN include/linux/fb.h~fbdev-dont-allow-softcursor-use-from-userland include/linux/fb.h
--- devel/include/linux/fb.h~fbdev-dont-allow-softcursor-use-from-userland	2005-08-06 21:28:28.000000000 -0700
+++ devel-akpm/include/linux/fb.h	2005-08-06 21:28:28.000000000 -0700
@@ -705,6 +705,7 @@ struct fb_tile_ops {
 #define FBINFO_HWACCEL_XPAN		0x1000 /* optional */
 #define FBINFO_HWACCEL_YPAN		0x2000 /* optional */
 #define FBINFO_HWACCEL_YWRAP		0x4000 /* optional */
+#define FBINFO_HWACCEL_CURSOR		0x8000 /* required */
 
 #define FBINFO_MISC_USEREVENT          0x10000 /* event request
 						  from userspace */
_
