Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3FE6C433FE for ; Thu, 6 Oct 2022 14:48:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DCA484DB2; Thu, 6 Oct 2022 16:47:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="c8HFXTws"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 456DA84DAA; Thu, 6 Oct 2022 16:37:07 +0200 (CEST) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A3B3C84E45 for ; Thu, 6 Oct 2022 16:36:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id p186so1409036iof.5 for ; Thu, 06 Oct 2022 07:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Th21d/HaX3WdAHYTLMHIlCe6BTXHxTLJuIleKfHrM1E=; b=c8HFXTws9ebuhxEhkLdEIeyV9cjpoQrbZECC+2YCcDLs1NR51Bt7nASg/nmrZE/5Vn tZy0y+sjyfaZ/UY5eIVfp9rHNK1zfRE1balB6zZ5gww2e/DRcJkc7bjXux7hgC1goRzV S9xwfKrRouHkNUXoTwCzzOillqKiNUulGEomM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Th21d/HaX3WdAHYTLMHIlCe6BTXHxTLJuIleKfHrM1E=; b=teht13hRiDaouX9DfWWgmadH+id1s+SPgYKsF/ot7qq72LtsPFnuNiyKBBa5TxBGSI Gok2kynhOMeB15tdC6oF29LthlFDBrwEdPzbL2hfm8IEinh1+Gnfght00klTDHeIjMT9 EebwttnQOMrWER3LOm5zuO1Hsk7RnWTMrZ9jXJNbjcUO2GmEFZuw7lUVj1uuSQREnzmx cs7MkrEHUz19CqXgg9GEyNsODCQ0rScYHjSQmwyrzJ4rAe7z1wHPZbk0Kv+xppRf2i/p rcHiEnQeJ26doFpdEh3IghMYNm7L3hGE5qpQfBeirLOEQmlxgSLtfHJwdXf4+7BtNjht 1hYg== X-Gm-Message-State: ACrzQf32dPNt85QnW9KdyLexyrpzPsS9PKslmWVlozavj3t7TX2hs5Hv qvmH1MlXGzx0dUGDkQZzOfGPjnTNhUgyrg== X-Google-Smtp-Source: AMsMyM6TEpyV5gIKfL43y1ILJ+wY0FJkb/eW5OwMvJjtol1miqbUFu8KHc07LiKXPkrkOLAaiQ+iIA== X-Received: by 2002:a5d:9f50:0:b0:6b6:2e7e:2b71 with SMTP id u16-20020a5d9f50000000b006b62e7e2b71mr77262iot.42.1665067009999; Thu, 06 Oct 2022 07:36:49 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id g22-20020a056602073600b006a102cb4900sm388573iox.39.2022.10.06.07.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 07:36:49 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Anatolij Gustschin , Simon Glass , Ashok Reddy Soma , Chris Morgan , Heinrich Schuchardt , Huang Jianan , Ilias Apalodimas , John Keeping , Kever Yang , Masahisa Kojima , Ovidiu Panait , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Samuel Dionne-Riel , Stefan Roese Subject: [PATCH 04/16] video: Move the console commands to cmd/ Date: Thu, 6 Oct 2022 08:36:06 -0600 Message-Id: <20221006143619.354301-5-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221006143619.354301-1-sjg@chromium.org> References: <20221006143619.354301-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Move these commands and the implementation to the cmd/ directory, which is where most commands are kept. Signed-off-by: Simon Glass --- 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 + */ + +#include +#include +#include +#include +#include + +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", + " in character" +); + +U_BOOT_CMD( + lcdputs, 2, 1, do_video_puts, + "print string on video framebuffer", + " " +); 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", - " in character" -); - -U_BOOT_CMD( - lcdputs, 2, 1, do_video_puts, - "print string on video framebuffer", - " " -); -#endif /* CONFIG_IS_ENABLED(CMD_VIDCONSOLE) */ -- 2.38.0.rc1.362.ged0d419d3c-goog