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 E6BD0C433F5 for ; Thu, 6 Oct 2022 14:37:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7863284DC0; Thu, 6 Oct 2022 16:37:01 +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="B+Uw/Xre"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7490184C17; Thu, 6 Oct 2022 16:36:57 +0200 (CEST) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (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 6DE1B84E37 for ; Thu, 6 Oct 2022 16:36:49 +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-xd34.google.com with SMTP id s16so1407482ioa.6 for ; Thu, 06 Oct 2022 07:36:49 -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=RVAbppLmYLngPwlekJyKUfVFBPes46vKjQDD4m1G7sA=; b=B+Uw/XreJ2WOHKo54PccIOU4mN4q//UEytcU6W1k3M6dewKvT1ZkZ3HNVkuryq9rUN CxrqvLZDu8WS1onZXTpW+JDIod2dLF4moMfRPmeWuyeA8Zo2qbXUVJZa9ynstDONYTfq xFTIM2k7GwCr4fPk2VwMnAgRVEietFYfGz0Dg= 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=RVAbppLmYLngPwlekJyKUfVFBPes46vKjQDD4m1G7sA=; b=Nmj7bPF9iUGaeFP6Xljp5LXUNR/2wJQ5Ymj+xpMxTP9Lqn6jvRagbxe0izh1DAXG4l 6H3gPleOmbVfZ9kujfrn0/juKKxv7rQqoBgVfzLaiVOTB30OUPIWR4RDrbrv5aM8lrL/ DMGyfxqw/Fxf7hMQWXoNZjc01yswl38g8ylt2uKrSYi9tVwCEUWlWv43Zm3YYkr5EYzy 3onuiDPdcQiJRxnQZaV9vkQgbvd/lMnR+NYL53VQohfng01OEP/W0e0Zt/Xz0EdrgaIf WxPM/gCfoZM9ZOSLTOjr+kiEcACAtuIQsblFSkA6E0dOsHw5HBn4TVZCZW1mm9C7eLBS SNSA== X-Gm-Message-State: ACrzQf0EJLDd0Q+4SKWUEF/f29hST3w5y+C6iAu0fF4r+1t8nvKXAckw ntJHRoKkCH/k4/B6Ih75DwCXpLsOmTBtqA== X-Google-Smtp-Source: AMsMyM488/o2Lf7chbwED1aMLbTfhnLteEtNvdKLC8kwKyKe5li2IeVMPAoub7ZJ8kZIM7nuP1E9XQ== X-Received: by 2002:a5d:8052:0:b0:6a5:4b18:ac03 with SMTP id b18-20020a5d8052000000b006a54b18ac03mr53013ior.153.1665067007436; Thu, 06 Oct 2022 07:36:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 07:36:46 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Anatolij Gustschin , Simon Glass Subject: [PATCH 02/16] video: Provide a function to set the cursor position Date: Thu, 6 Oct 2022 08:36:04 -0600 Message-Id: <20221006143619.354301-3-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 Add an exported function which allows the cursor position to be set to pixel granularity. Make use of this in the existing code. Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 18 +++++++++++++----- include/video_console.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index f67027c67be..53263580e3b 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -122,6 +122,15 @@ static char *parsenum(char *s, int *num) return end; } +void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y) +{ + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + + priv->xcur_frac = VID_TO_POS(x); + priv->xstart_frac = priv->xcur_frac; + priv->ycur = y; +} + /** * set_cursor_position() - set cursor position * @@ -614,12 +623,11 @@ 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; - col *= priv->x_charsize; - row *= priv->y_charsize; - priv->xcur_frac = VID_TO_POS(min_t(short, col, vid_priv->xsize - 1)); - priv->xstart_frac = priv->xcur_frac; - priv->ycur = min_t(short, row, vid_priv->ysize - 1); + 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, diff --git a/include/video_console.h b/include/video_console.h index 72edd419191..76c4b10acf6 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -219,6 +219,18 @@ int vidconsole_put_string(struct udevice *dev, const char *str); void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row); +/** + * vidconsole_set_cursor_pos() - set cursor position + * + * The cursor is set to the new position and the start-of-line information is + * updated to the same position, so that a newline will return to @x + * + * @dev: video console device to update + * @x: x position from left in pixels + * @y: y position from top in pixels + */ +void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y); + #ifdef CONFIG_VIDEO_COPY /** * vidconsole_sync_copy() - Sync back to the copy framebuffer -- 2.38.0.rc1.362.ged0d419d3c-goog