Skip to contentSkip to conversation

Framebuffer text mode style cursor

PATCH John Zielinski 1 participant 1 message Nov 16, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

As I mentioned before, I found the default framebuffer cursor to be extremely distracting as it made the character it's on blink. Here's a patch to make it act just the way it does in text mode. I made it a configurable option. So if the default cursor drives you nuts as well, give it a try.

drivers/video/console/Kconfig +0 -0
diff -urN -X dontdiff fbdev-2.6/drivers/video/console/Kconfig fbdev/drivers/video/console/Kconfig
@@ -104,6 +104,13 @@

config FRAMEBUFFER_CONSOLE
tristate "Framebuffer Console support"
depends on FB
+
+config FBCON_TEXT_CURSOR
+ bool "Framebuffer text mode style cursor"
+ depends on FRAMEBUFFER_CONSOLE
+ help
+ Say Y here if you want the framebuffer cursor to behave like it
+ does in text mode.

config PCI_CONSOLE
bool

drivers/video/console/fbcon.c +0 -0
diff -urN -X dontdiff fbdev-2.6/drivers/video/console/fbcon.c fbdev/drivers/video/console/fbcon.c
@@ -139,6 +139,11 @@
 

static int vbl_cursor_cnt;

+#ifdef CONFIG_FBCON_TEXT_CURSOR
+static u8 *cursor_data = NULL;
+static int cursor_data_size = 0;
+#endif
+
#define divides(a, b) ((!(a) || (b)%(a)) ? 0 : 1)

/*
@@ -966,18 +971,38 @@

	}

	if (mode != CM_ERASE) {
-		unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
		int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
		int fgshift = (vc->vc_hi_font_mask) ? 9 : 8;
		int s_pitch = (vc->vc_font.width + 7) >> 3;
		int size = s_pitch * vc->vc_font.height;
		struct fb_cursor cursor;
-		int cur_height = 0, c, i;
-		u8 *dst;
+		int cur_height, c;
		
		memset(&cursor, 0, sizeof(struct fb_cursor));
		cursor.enable = 1;

+ switch (vc->vc_cursor_type & 0x0f) {
+ case CUR_NONE:
+ cur_height = 0;
+ break;
+ case CUR_UNDERLINE:
+ cur_height = (vc->vc_font.height < 10) ? 1 : 2;
+ break;
+ case CUR_LOWER_THIRD:
+ cur_height = vc->vc_font.height/3;
+ break;
+ case CUR_LOWER_HALF:
+ cur_height = vc->vc_font.height >> 1;
+ break;
+ case CUR_TWO_THIRDS:
+ cur_height = (vc->vc_font.height << 1)/3;
+ break;
+ case CUR_BLOCK:
+ default:
+ cur_height = vc->vc_font.height;
+ break;
+ }
+
c = scr_readw((u16 *) vc->vc_pos);

		if (info->cursor.image.bg_color != attr_bgcol(bgshift, c) ||
@@ -988,6 +1013,12 @@
			cursor.set |= FB_CUR_SETCMAP;
		}

+ if (info->cursor.hot.x || info->cursor.hot.y) {
+ cursor.hot.x = cursor.hot.y = 0;
+ cursor.set |= FB_CUR_SETHOT;
+ }
+
+#ifndef CONFIG_FBCON_TEXT_CURSOR

		if ((info->cursor.image.dx != (vc->vc_font.width * vc->vc_x)) ||
		    (info->cursor.image.dy != (vc->vc_font.height * y))) {
			cursor.image.dx = vc->vc_font.width * vc->vc_x;
@@ -1002,15 +1033,13 @@
			cursor.set |= FB_CUR_SETSIZE;
		}

- if (info->cursor.hot.x || info->cursor.hot.y) {
- cursor.hot.x = cursor.hot.y = 0;
- cursor.set |= FB_CUR_SETHOT;
- }
-

		if ((cursor.set & FB_CUR_SETSIZE) || (cursor.set & FB_CUR_SETPOS)) {
+			unsigned short charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
			int width = vc->vc_font.width >> 3;
			u8 delta = vc->vc_font.width & 7;

-
+ u8 *dst;
+ int i;
+

			dst = kmalloc(size, GFP_ATOMIC);
			if (!dst)
				return;
@@ -1019,28 +1048,7 @@
			if (info->cursor.image.data)
				kfree(info->cursor.image.data);
			info->cursor.image.data = dst;

-
- switch (vc->vc_cursor_type & 0x0f) {
- case CUR_NONE:
- cur_height = 0;
- break;
- case CUR_UNDERLINE:
- cur_height = (vc->vc_font.height < 10) ? 1 : 2;
- break;
- case CUR_LOWER_THIRD:
- cur_height = vc->vc_font.height/3;
- break;
- case CUR_LOWER_HALF:
- cur_height = vc->vc_font.height >> 1;
- break;
- case CUR_TWO_THIRDS:
- cur_height = (vc->vc_font.height << 1)/3;
- break;
- case CUR_BLOCK:
- default:
- cur_height = vc->vc_font.height;
- break;
- }
+

			dst += (vc->vc_font.height - cur_height) * s_pitch;
			for (i = 0; i < cur_height; i++) {
				memset(dst, 0xff, width);
@@ -1048,9 +1056,7 @@
					*(dst+width) = 0xf << delta;
				dst += s_pitch;
			}	

- }

-		if ((cursor.set & FB_CUR_SETSIZE) || (cursor.set & FB_CUR_SETPOS)) {
			char *src = vc->vc_font.data + ((c & charmask) * size);
			
			dst = kmalloc(size, GFP_ATOMIC);
@@ -1067,6 +1073,39 @@
					*dst++ = 0xff ^ *src++;
			}	
		}

+#else
+ if ((info->cursor.image.dx != (vc->vc_font.width * vc->vc_x)) ||
+ (info->cursor.image.dy != (vc->vc_font.height * y + vc->vc_font.height - cur_height))) {
+ cursor.image.dx = vc->vc_font.width * vc->vc_x;
+ cursor.image.dy = vc->vc_font.height * y + vc->vc_font.height - cur_height;
+ cursor.set |= FB_CUR_SETPOS;
+ }
+
+ if (info->cursor.image.height != cur_height ||
+ info->cursor.image.width != vc->vc_font.width) {
+ cursor.image.height = cur_height;
+ cursor.image.width = vc->vc_font.width;
+ cursor.set |= FB_CUR_SETSIZE;
+ }
+
+ if (cursor.set & FB_CUR_SETSIZE) {
+ if (size > cursor_data_size) {
+ if (cursor_data) {
+ kfree(cursor_data);
+ cursor_data_size = 0;
+ }
+ cursor_data = kmalloc(size, GFP_ATOMIC); + if (!cursor_data)
+ return;
+ memset(cursor_data, 0xff, size);
+ cursor_data_size = size;
+ }
+
+ cursor.set |= FB_CUR_SETSHAPE;
+ info->cursor.image.data = cursor_data;
+ info->cursor.mask = cursor_data;
+ }
+#endif

		info->fbops->fb_cursor(info, &cursor);
		info->cursor.enable = 1;
		atomic_dec(&info->sprite.count);

John