Skip to contentSkip to conversation

Fix softcursor issues

PATCH In review Benjamin Herrenschmidt 2 participants 2 messages Feb 9, 2004 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix softcursor issues

Hi James !

I'm having troubles with softcursor in the new tree. It can tap outside of the ioremap'ed region of the framebuffer because it doesn't properly crop the saved area at the bottom of the screen.

Here's a quick fix that works for me with offb (offb ioremap's just the exact size of the framebuffer and so would trigger it).

I also added calls to fb_sync since we are touching the framebuffer, we must make sure pending accel operations are properly completed.

Ben.

drivers/video/softcursor.c +20 -8
diff -urN fbdev-2.5/drivers/video/softcursor.c linuxppc-2.5-benh/drivers/video/softcursor.c
@@ -29,9 +29,10 @@
 {
 	unsigned int scan_align = info->sprite.scan_align - 1;
 	u8 *addr = info->sprite.addr, *dst;
-	unsigned int size, i, j;
+	unsigned int size, i, j, ysize;
 	unsigned long *save;
-	
+	int needsync = 1;
+
 	if (cursor->image.height > 32 || cursor->image.width > 32)
 		return -ENXIO;
 
@@ -63,14 +64,20 @@
 		fb_load_cursor_image(info);
 		
 	if (!cursor->enable || (info->cursor.enable && (cursor->set & FB_CUR_SETPOS))) {
+		if (needsync && info->fbops->fb_sync) {
+			info->fbops->fb_sync(info);
+			needsync = 0;
+		}
 		// Draw saved area
 		i = (info->cursor.image.width * info->var.bits_per_pixel + 7) >> 3;
 		size = (i + scan_align) & ~scan_align;
 		i = (info->cursor.image.dx * info->var.bits_per_pixel >> 3);
 		dst = info->screen_base + info->cursor.image.dy * info->fix.line_length + i;
-		
+		ysize = 32;
+		if ((info->cursor.image.dy + ysize) > info->var.yres_virtual)
+			ysize = info->var.yres_virtual - info->cursor.image.dy;
 		save = (unsigned long *) (addr + info->sprite.size/2);
-		for (i = 0; i < 32; i++) {
+		for (i = 0; i < ysize; i++) {
 			unsigned long *dst0 = (unsigned long *) dst;
 			for (j = 0; j < size; j++) {
 				FB_WRITEL(FB_READL(save++), dst0++);
@@ -80,14 +87,21 @@
 	}
 	
 	if (!info->cursor.enable || (cursor->set & FB_CUR_SETPOS)) {
+		if (needsync && info->fbops->fb_sync) {
+			info->fbops->fb_sync(info);
+			needsync = 0;
+		}
 		// Save the area under the cursor
 		i = (info->cursor.image.width * info->var.bits_per_pixel + 7) >> 3;
 		size = (i + scan_align) & ~scan_align;
 		i = (info->cursor.image.dx * info->var.bits_per_pixel >> 3);
 		dst = info->screen_base + info->cursor.image.dy * info->fix.line_length + i;
 		
+		ysize = 32;
+		if ((info->cursor.image.dy + ysize) > info->var.yres_virtual)
+			ysize = info->var.yres_virtual - info->cursor.image.dy;
 		save = (unsigned long *) (addr + info->sprite.size/2);
-		for (i = 0; i < 32; i++) {
+		for (i = 0; i < ysize; i++) {
 			unsigned long *dst0 = (unsigned long *) dst;
 			for (j = 0; j < size; j++) {
 				FB_WRITEL(FB_READL(dst0++), save++);
@@ -96,10 +110,8 @@
 		}
 	}
 
-	if (cursor->enable) {
-		//info->cursor.image.data = addr;
+	if (cursor->enable)
 		info->fbops->fb_imageblit(info, &info->cursor.image);
-	}
 	return 0;
 }
 

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn

#1 lore raw

Thanks. Applied.

Quoted 81 lines · Benjamin Herrenschmidt

Hi James !

I'm having troubles with softcursor in the new tree. It can tap outside of the ioremap'ed region of the framebuffer because it doesn't properly crop the saved area at the bottom of the screen.

Here's a quick fix that works for me with offb (offb ioremap's just the exact size of the framebuffer and so would trigger it).

I also added calls to fb_sync since we are touching the framebuffer, we must make sure pending accel operations are properly completed.

Ben.

diff -urN fbdev-2.5/drivers/video/softcursor.c linuxppc-2.5-benh/drivers/video/softcursor.c

drivers/video/softcursor.c +19 -5
@@ -29,9 +29,10 @@
 {
 	unsigned int scan_align = info->sprite.scan_align - 1;
 	u8 *addr = info->sprite.addr, *dst;
-	unsigned int size, i, j;
+	unsigned int size, i, j, ysize;
 	unsigned long *save;
-	
+	int needsync = 1;
+
 	if (cursor->image.height > 32 || cursor->image.width > 32)
 		return -ENXIO;
 
@@ -63,14 +64,20 @@
 		fb_load_cursor_image(info);
 
 	if (!cursor->enable || (info->cursor.enable && (cursor->set & FB_CUR_SETPOS))) {
+		if (needsync && info->fbops->fb_sync) {
+			info->fbops->fb_sync(info);
+			needsync = 0;
+		}
 		// Draw saved area
 		i = (info->cursor.image.width * info->var.bits_per_pixel + 7) >> 3;
 		size = (i + scan_align) & ~scan_align;
 		i = (info->cursor.image.dx * info->var.bits_per_pixel >> 3);
 		dst = info->screen_base + info->cursor.image.dy * info->fix.line_length + i;
-		
+		ysize = 32;
+		if ((info->cursor.image.dy + ysize) > info->var.yres_virtual)
+			ysize = info->var.yres_virtual - info->cursor.image.dy;
 		save = (unsigned long *) (addr + info->sprite.size/2);
-		for (i = 0; i < 32; i++) {
+		for (i = 0; i < ysize; i++) {
 			unsigned long *dst0 = (unsigned long *) dst;
 			for (j = 0; j < size; j++) {
 				FB_WRITEL(FB_READL(save++), dst0++);
@@ -80,14 +87,21 @@
 	}
 
 	if (!info->cursor.enable || (cursor->set & FB_CUR_SETPOS)) {
+		if (needsync && info->fbops->fb_sync) {
+			info->fbops->fb_sync(info);
+			needsync = 0;
+		}
 		// Save the area under the cursor
 		i = (info->cursor.image.width * info->var.bits_per_pixel + 7) >> 3;
 		size = (i + scan_align) & ~scan_align;
 		i = (info->cursor.image.dx * info->var.bits_per_pixel >> 3);
 		dst = info->screen_base + info->cursor.image.dy * info->fix.line_length + i;
 
+		ysize = 32;
+		if ((info->cursor.image.dy + ysize) > info->var.yres_virtual)
+			ysize = info->var.yres_virtual - info->cursor.image.dy;
 		save = (unsigned long *) (addr + info->sprite.size/2);
-		for (i = 0; i < 32; i++) {
+		for (i = 0; i < ysize; i++) {
 			unsigned long *dst0 = (unsigned long *) dst;
 			for (j = 0; j < size; j++) {
 				FB_WRITEL(FB_READL(dst0++), save++);
@@ -96,10 +110,8 @@
 		}

drivers/video/softcursor.c line 117

Quoted 10 lines
drivers/video/softcursor.c +1 -3
 	}
 
-	if (cursor->enable) {
-		//info->cursor.image.data = addr;
+	if (cursor->enable)
 		info->fbops->fb_imageblit(info, &info->cursor.image);
-	}
 	return 0;
 }
 

-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn