
From: Simon Glass <sjg@chromium.org> The video cursor is always enabled at present, but it is only used for expo. Put it behind an option, to reduce code size for platforms which do use video but don't want a cursor. Move the existing set_cursor_visible() method behind this option, for the normal console. For the truetype console, the fonts and extra rendering dwarf the code-size saving, so include the cursor there always. Once the cursor is enabled for the CLI, this will produce code-size savings. Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/video/Kconfig | 8 ++++++++ drivers/video/console_normal.c | 7 +++++-- drivers/video/vidconsole-uclass.c | 2 ++ include/video_console.h | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 6e1577ae687..446ce51fe27 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -68,6 +68,14 @@ config BACKLIGHT This provides backlight uclass driver that enables basic panel backlight support. +config CURSOR + bool "Show a cursor on the console" + default y + help + Show a cursor on the video console when entering commands. This is + a simple vertical bar drawn before the character at the current + position. The cursor makes it easy to see the current input position. + config VIDEO_PCI_DEFAULT_FB_SIZE hex "Default framebuffer size to use if no drivers request it" default 0x1000000 if X86 diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 07db613ac53..a39b04bd73c 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -105,8 +105,9 @@ static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) return VID_TO_POS(fontdata->width); } -static int console_set_cursor_visible(struct udevice *dev, bool visible, - uint x, uint y, uint index) +static int __maybe_unused console_set_cursor_visible(struct udevice *dev, + bool visible, uint x, + uint y, uint index) { struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); struct udevice *vid = dev->parent; @@ -140,7 +141,9 @@ struct vidconsole_ops console_ops = { .get_font_size = console_simple_get_font_size, .get_font = console_simple_get_font, .select_font = console_simple_select_font, +#ifdef CONFIG_CURSOR .set_cursor_visible = console_set_cursor_visible, +#endif }; U_BOOT_DRIVER(vidconsole_normal) = { diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 6c5338936e5..f53d55e81b7 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -701,6 +701,7 @@ int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf) return 0; } +#ifdef CONFIG_CURSOR int vidconsole_set_cursor_visible(struct udevice *dev, bool visible, uint x, uint y, uint index) { @@ -715,6 +716,7 @@ int vidconsole_set_cursor_visible(struct udevice *dev, bool visible, return 0; } +#endif void vidconsole_push_colour(struct udevice *dev, enum colour_idx fg, enum colour_idx bg, struct vidconsole_colour *old) diff --git a/include/video_console.h b/include/video_console.h index 8f3f58f3aa9..d3c65a08331 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -404,6 +404,7 @@ int vidconsole_entry_save(struct udevice *dev, struct abuf *buf); */ int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf); +#ifdef CONFIG_CURSOR /** * vidconsole_set_cursor_visible() - Show or hide the cursor * @@ -418,6 +419,14 @@ int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf); */ int vidconsole_set_cursor_visible(struct udevice *dev, bool visible, uint x, uint y, uint index); +#else +static inline int vidconsole_set_cursor_visible(struct udevice *dev, + bool visible, uint x, uint y, + uint index) +{ + return 0; +} +#endif /* CONFIG_CURSOR */ /** * vidconsole_push_colour() - Temporarily change the font colour -- 2.43.0