All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Zielinski <grim@undead.cc>
To: linux-fbdev-devel@lists.sourceforge.net
Subject: Framebuffer text mode style cursor
Date: Sat, 15 Nov 2003 23:35:07 -0500	[thread overview]
Message-ID: <3FB6FE7B.8070507@undead.cc> (raw)

[-- Attachment #1: Type: text/plain, Size: 5634 bytes --]

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.


diff -urN -X dontdiff fbdev-2.6/drivers/video/console/Kconfig fbdev/drivers/video/console/Kconfig
--- fbdev-2.6/drivers/video/console/Kconfig	2003-10-25 14:43:11.000000000 -0400
+++ fbdev/drivers/video/console/Kconfig	2003-11-15 23:13:02.000000000 -0500
@@ -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
diff -urN -X dontdiff fbdev-2.6/drivers/video/console/fbcon.c fbdev/drivers/video/console/fbcon.c
--- fbdev-2.6/drivers/video/console/fbcon.c	2003-11-15 03:31:27.000000000 -0500
+++ fbdev/drivers/video/console/fbcon.c	2003-11-15 23:10:14.000000000 -0500
@@ -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




[-- Attachment #2: Type: text/html, Size: 6325 bytes --]

                 reply	other threads:[~2003-11-16  4:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3FB6FE7B.8070507@undead.cc \
    --to=grim@undead.cc \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.