video: truetype: Use common cursor-drawing code
Update truetype_set_cursor_visible() to use the existing shared draw_cursor_vertically() function instead of duplicating cursor-drawing itself. This corrects a problem where met is accessed for fixed-width fonts, for which it doesn't exist. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -1000,10 +1000,8 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible,
|
||||
struct udevice *vid = dev->parent;
|
||||
struct video_priv *vid_priv = dev_get_uclass_priv(vid);
|
||||
struct console_tt_priv *priv = dev_get_priv(dev);
|
||||
struct console_tt_metrics *met = priv->cur_met;
|
||||
uint row, width, height, xoff;
|
||||
void *start, *line;
|
||||
uint out, val;
|
||||
void *line;
|
||||
uint height;
|
||||
|
||||
if (xpl_phase() <= PHASE_SPL)
|
||||
return -ENOSYS;
|
||||
@@ -1022,79 +1020,21 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible,
|
||||
x = VID_TO_PIXEL(vc_priv->xcur_frac);
|
||||
|
||||
y = vc_priv->ycur;
|
||||
height = met->font_size;
|
||||
xoff = 0;
|
||||
|
||||
val = vid_priv->colour_bg ? 0 : 255;
|
||||
width = VIDCONSOLE_CURSOR_WIDTH;
|
||||
/* Get font height from current font type */
|
||||
if (priv->cur_fontdata)
|
||||
height = priv->cur_fontdata->height;
|
||||
else
|
||||
height = priv->cur_met->font_size;
|
||||
|
||||
/* Figure out where to write the cursor in the frame buffer */
|
||||
start = vid_priv->fb + y * vid_priv->line_length +
|
||||
line = vid_priv->fb + y * vid_priv->line_length +
|
||||
x * VNBYTES(vid_priv->bpix);
|
||||
line = start;
|
||||
|
||||
/* draw a vertical bar in the correct position */
|
||||
for (row = 0; row < height; row++) {
|
||||
switch (vid_priv->bpix) {
|
||||
case VIDEO_BPP8:
|
||||
if (IS_ENABLED(CONFIG_VIDEO_BPP8)) {
|
||||
u8 *dst = line + xoff;
|
||||
int i;
|
||||
/* Use the shared cursor drawing function */
|
||||
draw_cursor_vertically(&line, vid_priv, height, NORMAL_DIRECTION);
|
||||
|
||||
out = val;
|
||||
for (i = 0; i < width; i++) {
|
||||
if (vid_priv->colour_fg)
|
||||
*dst++ |= out;
|
||||
else
|
||||
*dst++ &= out;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VIDEO_BPP16: {
|
||||
u16 *dst = (u16 *)line + xoff;
|
||||
int i;
|
||||
|
||||
if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
|
||||
for (i = 0; i < width; i++) {
|
||||
out = val >> 3 |
|
||||
(val >> 2) << 5 |
|
||||
(val >> 3) << 11;
|
||||
if (vid_priv->colour_fg)
|
||||
*dst++ |= out;
|
||||
else
|
||||
*dst++ &= out;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VIDEO_BPP32: {
|
||||
u32 *dst = (u32 *)line + xoff;
|
||||
int i;
|
||||
|
||||
if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
|
||||
for (i = 0; i < width; i++) {
|
||||
int out;
|
||||
|
||||
if (vid_priv->format == VIDEO_X2R10G10B10)
|
||||
out = val << 2 | val << 12 | val << 22;
|
||||
else
|
||||
out = val | val << 8 | val << 16;
|
||||
if (vid_priv->colour_fg)
|
||||
*dst++ |= out;
|
||||
else
|
||||
*dst++ &= out;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
line += vid_priv->line_length;
|
||||
}
|
||||
|
||||
video_damage(dev->parent, x, y, width, height);
|
||||
video_damage(dev->parent, x, y, VIDCONSOLE_CURSOR_WIDTH, height);
|
||||
|
||||
return video_sync(vid, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user