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 v2 3/5] vgacon: Use vt_cursor_{start,end}()
Date: Tue, 15 Sep 2026 14:29:14 +0200 [thread overview]
Message-ID: <20260915123304.1027277-4-tzimmermann@suse.de> (raw)
In-Reply-To: <20260915123304.1027277-1-tzimmermann@suse.de>
Replace vgacon's custom cursor metrics with the shared helpers
vc_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.
v2:
- restore use of vc_cell_height (Sashiko)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Helge Deller <deller@gmx.de>
---
drivers/video/console/vgacon.c | 33 +++++----------------------------
1 file changed, 5 insertions(+), 28 deletions(-)
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 536e7fe4d142..b1408bb5e265 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -506,6 +506,7 @@ 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_size;
if (c->vc_mode != KD_TEXT)
return;
@@ -513,10 +514,11 @@ static void vgacon_cursor(struct vc_data *c, bool enable)
vgacon_restore_screen(c);
c_height = c->vc_cell_height;
+ c_size = CUR_SIZE(c->vc_cursor_type);
write_vga(14, (c->vc_pos - vga_vram_base) / 2);
- if (!enable) {
+ if (!enable || c_size == CUR_NONE) {
if (vga_video_type >= VIDEO_TYPE_VGAC)
vgacon_set_cursor_size(31, 30);
else
@@ -524,33 +526,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_cursor_start(c_height, c_size),
+ vc_cursor_end(c_height, c_size) - 1);
}
static void vgacon_doresize(struct vc_data *c,
--
2.55.0
next prev parent reply other threads:[~2026-09-15 12:33 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 12:29 [PATCH v2 0/5] fbcon,vgacon,vt: Share helpers for text cursors Thomas Zimmermann
2026-09-15 12:29 ` [PATCH v2 1/5] vt: Add cursor-size helpers Thomas Zimmermann
2026-09-15 12:40 ` sashiko-bot
2026-09-23 12:57 ` Greg KH
2026-09-23 13:30 ` Thomas Zimmermann
2026-09-15 12:29 ` [PATCH v2 2/5] vgacon: Remove trailing whitespaces Thomas Zimmermann
2026-09-15 12:35 ` sashiko-bot
2026-09-15 12:29 ` Thomas Zimmermann [this message]
2026-09-15 12:39 ` [PATCH v2 3/5] vgacon: Use vt_cursor_{start,end}() sashiko-bot
2026-09-15 12:29 ` [PATCH v2 4/5] lib/fonts: Add font_glyph_cursor() helper Thomas Zimmermann
2026-09-15 12:40 ` sashiko-bot
2026-09-15 12:29 ` [PATCH v2 5/5] fbcon: Replace fbcon_fill_cursor_mask() with fbcon_cursor_glyph() Thomas Zimmermann
2026-09-15 12:41 ` 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=20260915123304.1027277-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