[PATCH 04/16] video: Move the console commands to cmd/

Ilias Apalodimas ilias.apalodimas at linaro.org
Thu Oct 13 14:03:36 CEST 2022


Hi Simon,

On Thu, 6 Oct 2022 at 17:36, Simon Glass <sjg at chromium.org> wrote:
>
> Move these commands and the implementation to the cmd/ directory, which is
> where most commands are kept.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
>  cmd/Kconfig                       | 12 +++++
>  cmd/Makefile                      |  2 +
>  cmd/video.c                       | 73 +++++++++++++++++++++++++++++++
>  drivers/video/Kconfig             |  8 ----
>  drivers/video/vidconsole-uclass.c | 62 --------------------------
>  5 files changed, 87 insertions(+), 70 deletions(-)
>  create mode 100644 cmd/video.c
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index bfa12ce12a7..a512a55c031 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -2137,6 +2137,18 @@ config CMD_UUID
>           The two commands are very similar except for the endianness of the
>           output.
>
> +config CMD_VIDCONSOLE
> +       bool "lcdputs and setcurs"
> +       depends on DM_VIDEO
> +       default y
> +       help
> +         Enabling this will provide 'setcurs' and 'lcdputs' commands which
> +         support cursor positioning and drawing strings on the video
> +         console (framebuffer).
> +
> +         The name 'lcdputs' is a bit of a misnomer, but so named because the
> +         video device is often an LCD.
> +
>  endmenu
>
>  source "cmd/ti/Kconfig"
> diff --git a/cmd/Makefile b/cmd/Makefile
> index cf6ce1bd6fd..86a77805f88 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -176,6 +176,8 @@ obj-$(CONFIG_CMD_WDT) += wdt.o
>  obj-$(CONFIG_CMD_LZMADEC) += lzmadec.o
>  obj-$(CONFIG_CMD_UFS) += ufs.o
>  obj-$(CONFIG_CMD_USB) += usb.o disk.o
> +obj-$(CONFIG_CMD_VIDCONSOLE) += video.o
> +
>  obj-$(CONFIG_CMD_FASTBOOT) += fastboot.o
>  obj-$(CONFIG_CMD_FS_UUID) += fs_uuid.o
>
> diff --git a/cmd/video.c b/cmd/video.c
> new file mode 100644
> index 00000000000..e6b0b553136
> --- /dev/null
> +++ b/cmd/video.c
> @@ -0,0 +1,73 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * video commands
> + *
> + * Copyright 2022 Google LLC
> + * Written by Simon Glass <sjg at chromium.org>
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +#include <dm.h>
> +#include <video.h>
> +#include <video_console.h>
> +
> +void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
> +{
> +       struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
> +       struct udevice *vid_dev = dev->parent;
> +       struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
> +       short x, y;
> +
> +       x = min_t(short, col * priv->x_charsize, vid_priv->xsize - 1);
> +       y = min_t(short, row * priv->y_charsize, vid_priv->ysize - 1);
> +       vidconsole_set_cursor_pos(dev, x, y);
> +}
> +
> +static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
> +                             char *const argv[])
> +{
> +       unsigned int col, row;
> +       struct udevice *dev;
> +
> +       if (argc != 3)
> +               return CMD_RET_USAGE;
> +
> +       if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
> +               return CMD_RET_FAILURE;
> +       col = dectoul(argv[1], NULL);
> +       row = dectoul(argv[2], NULL);
> +       vidconsole_position_cursor(dev, col, row);
> +
> +       return 0;
> +}
> +
> +static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc,
> +                        char *const argv[])
> +{
> +       struct udevice *dev;
> +       int ret;
> +
> +       if (argc != 2)
> +               return CMD_RET_USAGE;
> +
> +       if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
> +               return CMD_RET_FAILURE;
> +       ret = vidconsole_put_string(dev, argv[1]);
> +       if (!ret)
> +               ret = video_sync(dev->parent, false);
> +
> +       return ret ? CMD_RET_FAILURE : 0;
> +}
> +
> +U_BOOT_CMD(
> +       setcurs, 3,     1,      do_video_setcursor,
> +       "set cursor position within screen",
> +       "    <col> <row> in character"
> +);
> +
> +U_BOOT_CMD(
> +       lcdputs, 2,     1,      do_video_puts,
> +       "print string on video framebuffer",
> +       "    <string>"
> +);
> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 4ecc158c460..c9fc4a3a583 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -85,14 +85,6 @@ config BACKLIGHT_GPIO
>           it understands the standard device tree
>           (leds/backlight/gpio-backlight.txt)
>
> -config CMD_VIDCONSOLE
> -       bool "Enable vidconsole commands lcdputs and setcurs"
> -       depends on DM_VIDEO
> -       default y
> -       help
> -         Enabling this will provide 'setcurs' and 'lcdputs' commands which
> -         support cursor positioning and drawing strings on video framebuffer.
> -
>  config VIDEO_BPP8
>         bool "Support 8-bit-per-pixel displays"
>         depends on DM_VIDEO
> diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
> index d5667191e0a..17d4f2f6d08 100644
> --- a/drivers/video/vidconsole-uclass.c
> +++ b/drivers/video/vidconsole-uclass.c
> @@ -616,65 +616,3 @@ int vidconsole_memmove(struct udevice *dev, void *dst, const void *src,
>         return vidconsole_sync_copy(dev, dst, dst + size);
>  }
>  #endif
> -
> -#if CONFIG_IS_ENABLED(CMD_VIDCONSOLE)
> -void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
> -{
> -       struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
> -       struct udevice *vid_dev = dev->parent;
> -       struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
> -       short x, y;
> -
> -       x = min_t(short, col * priv->x_charsize, vid_priv->xsize - 1);
> -       y = min_t(short, row * priv->y_charsize, vid_priv->ysize - 1);
> -       vidconsole_set_cursor_pos(dev, x, y);
> -}
> -
> -static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,
> -                             char *const argv[])
> -{
> -       unsigned int col, row;
> -       struct udevice *dev;
> -
> -       if (argc != 3)
> -               return CMD_RET_USAGE;
> -
> -       if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
> -               return CMD_RET_FAILURE;
> -       col = dectoul(argv[1], NULL);
> -       row = dectoul(argv[2], NULL);
> -       vidconsole_position_cursor(dev, col, row);
> -
> -       return 0;
> -}
> -
> -static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc,
> -                        char *const argv[])
> -{
> -       struct udevice *dev;
> -       int ret;
> -
> -       if (argc != 2)
> -               return CMD_RET_USAGE;
> -
> -       if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev))
> -               return CMD_RET_FAILURE;
> -       ret = vidconsole_put_string(dev, argv[1]);
> -       if (!ret)
> -               ret = video_sync(dev->parent, false);
> -
> -       return ret ? CMD_RET_FAILURE : 0;
> -}
> -
> -U_BOOT_CMD(
> -       setcurs, 3,     1,      do_video_setcursor,
> -       "set cursor position within screen",
> -       "    <col> <row> in character"
> -);
> -
> -U_BOOT_CMD(
> -       lcdputs, 2,     1,      do_video_puts,
> -       "print string on video framebuffer",
> -       "    <string>"
> -);
> -#endif /* CONFIG_IS_ENABLED(CMD_VIDCONSOLE) */
> --
> 2.38.0.rc1.362.ged0d419d3c-goog
>
Acked-by: Ilias Apalodimas <ilias.apalodimas at linaro.org>


More information about the U-Boot mailing list