dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: deller@gmx.de, gregkh@linuxfoundation.org, jirislaby@kernel.org,
	simona@ffwll.ch
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-serial@vger.kernel.org, sashiko-reviews@lists.linux.dev,
	Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH 3/5] vgacon: Use vt_font_cursor_{start,end}()
Date: Fri, 11 Sep 2026 11:25:21 +0200	[thread overview]
Message-ID: <20260911094518.78093-4-tzimmermann@suse.de> (raw)
In-Reply-To: <20260911094518.78093-1-tzimmermann@suse.de>

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


  parent reply	other threads:[~2026-09-11  9:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  9:25 [PATCH 0/5] fbcon,vgacon,vt: Share helpers for text cursors Thomas Zimmermann
2026-09-11  9:25 ` [PATCH 1/5] vt: Add cursor-size helpers Thomas Zimmermann
2026-09-11  9:55   ` sashiko-bot
2026-09-12 19:01   ` Helge Deller
2026-09-11  9:25 ` [PATCH 2/5] vgacon: Remove trailing whitespaces Thomas Zimmermann
2026-09-11  9:46   ` sashiko-bot
2026-09-11  9:25 ` Thomas Zimmermann [this message]
2026-09-11  9:58   ` [PATCH 3/5] vgacon: Use vt_font_cursor_{start,end}() sashiko-bot
2026-09-11  9:25 ` [PATCH 4/5] lib/fonts: Add font_glyph_cursor() helper Thomas Zimmermann
2026-09-11  9:52   ` sashiko-bot
2026-09-11  9:25 ` [PATCH 5/5] fbcon: Replace fbcon_fill_cursor_mask() with fbcon_cursor_glyph() Thomas Zimmermann
2026-09-11  9:50   ` sashiko-bot

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=20260911094518.78093-4-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=simona@ffwll.ch \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox