Thread (8 messages) flat view 8 messages, 2 authors, 1d ago
WARM1d

[PATCH 3/5] vgacon: Use vt_font_cursor_{start,end}()

From: Thomas Zimmermann <tzimmermann@suse.de>
Date: 2026-09-11 09:45:43
Also in: dri-devel, linux-serial, sashiko-reviews
Subsystem: console subsystem, framebuffer layer, the rest · Maintainers: Greg Kroah-Hartman, Helge Deller, Linus Torvalds

Replace vgacon's custom cursor metrics with the shared helpers
vc_font_cursor_start() and vc_font_cursor_end(). Note that the
_end() function returns the index of the scanline below the cursor,
while VGA hardware expects the cursor's final scanline. Hence vgacon
subtracts 1 from the end value.

The cursor shapes remain mostly unchanged, except that non-underline
cursors now also use the glyph's top-most and bottom-most scanline.
This follows the style used by fbcon.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/video/console/vgacon.c | 36 ++++++----------------------------
 1 file changed, 6 insertions(+), 30 deletions(-)
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 536e7fe4d142..b16ddb1b09a7 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -36,6 +36,7 @@
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/fs.h>
+#include <linux/font.h>
 #include <linux/kernel.h>
 #include <linux/console.h>
 #include <linux/string.h>
@@ -505,18 +506,18 @@ static void vgacon_set_cursor_size(int from, int to)
 
 static void vgacon_cursor(struct vc_data *c, bool enable)
 {
-	unsigned int c_height;
+	unsigned int c_type;
 
 	if (c->vc_mode != KD_TEXT)
 		return;
 
 	vgacon_restore_screen(c);
 
-	c_height = c->vc_cell_height;
+	c_type = c->vc_cursor_type;
 
 	write_vga(14, (c->vc_pos - vga_vram_base) / 2);
 
-	if (!enable) {
+	if (!enable || CUR_SIZE(c_type) == CUR_NONE) {
 	        if (vga_video_type >= VIDEO_TYPE_VGAC)
 			vgacon_set_cursor_size(31, 30);
 		else
@@ -524,33 +525,8 @@ static void vgacon_cursor(struct vc_data *c, bool enable)
 		return;
 	}
 
-	switch (CUR_SIZE(c->vc_cursor_type)) {
-	case CUR_UNDERLINE:
-		vgacon_set_cursor_size(c_height - (c_height < 10 ? 2 : 3),
-				       c_height - (c_height < 10 ? 1 : 2));
-		break;
-	case CUR_TWO_THIRDS:
-		vgacon_set_cursor_size(c_height / 3,
-				       c_height - (c_height < 10 ? 1 : 2));
-		break;
-	case CUR_LOWER_THIRD:
-		vgacon_set_cursor_size(c_height * 2 / 3,
-				       c_height - (c_height < 10 ? 1 : 2));
-		break;
-	case CUR_LOWER_HALF:
-		vgacon_set_cursor_size(c_height / 2,
-				       c_height - (c_height < 10 ? 1 : 2));
-		break;
-	case CUR_NONE:
-		if (vga_video_type >= VIDEO_TYPE_VGAC)
-			vgacon_set_cursor_size(31, 30);
-		else
-			vgacon_set_cursor_size(31, 31);
-		break;
-	default:
-		vgacon_set_cursor_size(1, c_height);
-		break;
-	}
+	vgacon_set_cursor_size(vc_font_cursor_start(&c->vc_font, c_type),
+			       vc_font_cursor_end(&c->vc_font, c_type) - 1);
 }
 
 static void vgacon_doresize(struct vc_data *c,
-- 
2.55.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help