summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2026-10-05 15:31:03 +0200
committerHelge Deller <deller@gmx.de>2026-10-19 13:56:01 +0200
commit54ddfe9a7eef0d207d72338ea009278998f87668 (patch)
tree677eec291f215b70539dc31b7de680f919ef6167 /drivers/video/fbdev
parenta88cef92063b16b42e6fa202ce199f0da3110e1f (diff)
fbcon: Replace fbcon_fill_cursor_mask() with fbcon_cursor_glyph()
The kernel's font library provides font_glyph_cursor() to create cursor glyphs. Replace fbcon's fbcon_fill_cursor_mask() with a new helper that uses font_glyph_cursor(). The cursor shapes remain mostly unchanged. The only exception is in underline cursors for fonts with a size larger than 10. The underlining dash is now one pixel closer to the font-glyph data, so that the cursor looks less detached. This follows the style used by vgacon. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Helge Deller <deller@gmx.de> Signed-off-by: Helge Deller <deller@gmx.de>
Diffstat (limited to 'drivers/video/fbdev')
-rw-r--r--drivers/video/fbdev/core/bitblit.c3
-rw-r--r--drivers/video/fbdev/core/fbcon.c45
-rw-r--r--drivers/video/fbdev/core/fbcon.h2
-rw-r--r--drivers/video/fbdev/core/fbcon_ccw.c3
-rw-r--r--drivers/video/fbdev/core/fbcon_cw.c3
-rw-r--r--drivers/video/fbdev/core/fbcon_ud.c3
6 files changed, 16 insertions, 43 deletions
diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c
index 39f44258d793..03b3b18e1fe9 100644
--- a/drivers/video/fbdev/core/bitblit.c
+++ b/drivers/video/fbdev/core/bitblit.c
@@ -334,11 +334,10 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
vc->vc_cursor_type != par->p->cursor_shape ||
par->cursor_state.mask == NULL ||
par->cursor_reset) {
- unsigned char *mask = kmalloc_array(vc->vc_font.height, w, GFP_ATOMIC);
+ unsigned char *mask = fbcon_cursor_glyph(&vc->vc_font, vc->vc_cursor_type);
if (!mask)
return;
- fbcon_fill_cursor_mask(par, vc, mask);
kfree(par->cursor_state.mask);
par->cursor_state.mask = (const char *)mask;
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 01715873ea49..ba689d42792d 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -445,44 +445,21 @@ static void fbcon_del_cursor_work(struct fb_info *info)
cancel_delayed_work_sync(&par->cursor_work);
}
-void fbcon_fill_cursor_mask(struct fbcon_par *par, struct vc_data *vc, unsigned char *mask)
+unsigned char *fbcon_cursor_glyph(const struct vc_font *font, unsigned int cursor_type)
{
- static const unsigned int pattern = 0xffffffff;
- unsigned int pitch = vc_font_pitch(&vc->vc_font);
- unsigned int cur_height, size;
+ unsigned int height = font->height;
+ unsigned int cursor_size = vc_cursor_valid_size(CUR_SIZE(cursor_type));
+ unsigned char *glyph;
- switch (CUR_SIZE(vc->vc_cursor_type)) {
- case CUR_NONE:
- cur_height = 0;
- break;
- case CUR_UNDERLINE:
- if (vc->vc_font.height < 10)
- cur_height = 1;
- else
- cur_height = 2;
- break;
- case CUR_LOWER_THIRD:
- cur_height = vc->vc_font.height / 3;
- break;
- case CUR_LOWER_HALF:
- cur_height = vc->vc_font.height / 2;
- break;
- case CUR_TWO_THIRDS:
- cur_height = (vc->vc_font.height * 2) / 3;
- break;
- case CUR_BLOCK:
- default:
- cur_height = vc->vc_font.height;
- break;
- }
+ glyph = kmalloc_array(height, vc_font_pitch(font), GFP_ATOMIC);
+ if (!glyph)
+ return NULL;
- size = (vc->vc_font.height - cur_height) * pitch;
- while (size--)
- *mask++ = (unsigned char)~pattern;
+ font_glyph_cursor(font->width, height,
+ vc_cursor_start(height, cursor_size),
+ vc_cursor_end(height, cursor_size), glyph);
- size = cur_height * pitch;
- while (size--)
- *mask++ = (unsigned char)pattern;
+ return glyph;
}
#ifndef MODULE
diff --git a/drivers/video/fbdev/core/fbcon.h b/drivers/video/fbdev/core/fbcon.h
index 407d207b14f1..054cf66b15fa 100644
--- a/drivers/video/fbdev/core/fbcon.h
+++ b/drivers/video/fbdev/core/fbcon.h
@@ -202,7 +202,7 @@ extern void fbcon_set_tileops(struct vc_data *vc, struct fb_info *info);
extern void fbcon_set_bitops_ur(struct fbcon_par *par);
extern int soft_cursor(struct fb_info *info, struct fb_cursor *cursor);
-void fbcon_fill_cursor_mask(struct fbcon_par *par, struct vc_data *vc, unsigned char *mask);
+unsigned char *fbcon_cursor_glyph(const struct vc_font *font, unsigned int cursor_type);
#define FBCON_ATTRIBUTE_UNDERLINE 1
#define FBCON_ATTRIBUTE_REVERSE 2
diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c
index 33f02d579e02..9a9839631cc5 100644
--- a/drivers/video/fbdev/core/fbcon_ccw.c
+++ b/drivers/video/fbdev/core/fbcon_ccw.c
@@ -298,10 +298,9 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
par->cursor_reset) {
unsigned char *tmp, *mask;
- tmp = kmalloc_array(vc->vc_font.height, vc_font_pitch(&vc->vc_font), GFP_ATOMIC);
+ tmp = fbcon_cursor_glyph(&vc->vc_font, vc->vc_cursor_type);
if (!tmp)
return;
- fbcon_fill_cursor_mask(par, vc, tmp);
mask = kmalloc_array(vc->vc_font.width, w, GFP_ATOMIC);
if (!mask) {
diff --git a/drivers/video/fbdev/core/fbcon_cw.c b/drivers/video/fbdev/core/fbcon_cw.c
index bde820967eb9..4cb20337cf79 100644
--- a/drivers/video/fbdev/core/fbcon_cw.c
+++ b/drivers/video/fbdev/core/fbcon_cw.c
@@ -281,10 +281,9 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
par->cursor_reset) {
unsigned char *tmp, *mask;
- tmp = kmalloc_array(vc->vc_font.height, vc_font_pitch(&vc->vc_font), GFP_ATOMIC);
+ tmp = fbcon_cursor_glyph(&vc->vc_font, vc->vc_cursor_type);
if (!tmp)
return;
- fbcon_fill_cursor_mask(par, vc, tmp);
mask = kmalloc_array(vc->vc_font.width, w, GFP_ATOMIC);
if (!mask) {
diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c
index eaf08999e249..ac22b9846b79 100644
--- a/drivers/video/fbdev/core/fbcon_ud.c
+++ b/drivers/video/fbdev/core/fbcon_ud.c
@@ -328,10 +328,9 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, bool enable,
par->cursor_reset) {
unsigned char *tmp, *mask;
- tmp = kmalloc_array(vc->vc_font.height, w, GFP_ATOMIC);
+ tmp = fbcon_cursor_glyph(&vc->vc_font, vc->vc_cursor_type);
if (!tmp)
return;
- fbcon_fill_cursor_mask(par, vc, tmp);
mask = kmalloc_array(vc->vc_font.height, w, GFP_ATOMIC);
if (!mask) {