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.
v4:
- disable if CUR_DEF maps to CUR_NONE
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..2dcb1e38bd6b 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 = vc_cursor_valid_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