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 6AD9CC6FD1D for ; Wed, 15 Mar 2023 16:12:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E3C2C85CA2; Wed, 15 Mar 2023 17:12:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com 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=konsulko.com header.i=@konsulko.com header.b="XUW7YofX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EEF4785F0A; Wed, 15 Mar 2023 17:12:22 +0100 (CET) Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) (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 DF96185F0A for ; Wed, 15 Mar 2023 17:01:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-qt1-x82e.google.com with SMTP id s12so16666004qtq.11 for ; Wed, 15 Mar 2023 09:01:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1678896097; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vGx3X5p11aHUk7YEruX/ppL8HvDSuzGgg23tMjw/ULQ=; b=XUW7YofXD3Z3fOg5enVuqPg7XsJZRJNDVuG8vE/s/4e9lMUX5yLMyUgrs2XR42yRx0 hnzrFOvqpoBHvd+C4/sO2YZNmndPGT2zuF4t0YtJLw9bzwyADn9p2k5lOoInJCY1VT8A 82aryBN4gFu4i7DqmjY7RXqTWQafZtrSspc/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678896097; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vGx3X5p11aHUk7YEruX/ppL8HvDSuzGgg23tMjw/ULQ=; b=UhXAMHC6CvlAkLymTBLDDbVBZYWCg7GbI7LCtrHpaFF9DhhRELNkTiEjTphJCVA2Pv gazAhjIJt9OdLoy0D1uRH85HuA/5FD4FUzwOeGmuruX0qBTbmq2cIGG4PE7WSp0Fs0iz SijbCoiU9AQdlJNywYgKevoftU5f9+FTV4MHVqRQ4cOKrP3gZ35djryIGTwciBoH7AHn 68fN49kCwgr9egH+VRfzPuP93MVoNnab9CQLwZp73LMDelAgMI2wqgK1EYe0Hj1F4qP7 9kz4khG7V5HYhDtB58XfpUKsC40iDqBUU+dSgbQyrD69x8DoEP4JYc6Ndy7/EgAUORRR +Zxg== X-Gm-Message-State: AO0yUKWWSNyNQ87x8GXPfskNnxNWoKRvaDV4dx8F1/evyNcHhv5MHLFQ MyHHA5iJioYvoL67WjtdYESfSb0zbiF57o2NA23C2A== X-Google-Smtp-Source: AK7set8W7BBVgNTuPqAaV0x+2aMtFkl+ALGKiWtKFPfHj0S5Y2YkRT7TlpqVousIVUmj17slR4ebXA== X-Received: by 2002:a05:622a:154:b0:3bf:d8b6:4cc7 with SMTP id v20-20020a05622a015400b003bfd8b64cc7mr533095qtw.58.1678896097182; Wed, 15 Mar 2023 09:01:37 -0700 (PDT) Received: from bill-the-cat.lan (2603-6081-7b00-6400-c150-991a-730f-2661.res6.spectrum.com. [2603:6081:7b00:6400:c150:991a:730f:2661]) by smtp.gmail.com with ESMTPSA id x7-20020ac87307000000b003b63b8df24asm3961942qto.36.2023.03.15.09.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 09:01:36 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH] Revert 9f62a472dfb2 ("video: Remove duplicate cursor-positioning function") Date: Wed, 15 Mar 2023 12:01:36 -0400 Message-Id: <20230315160136.2087793-1-trini@konsulko.com> X-Mailer: git-send-email 2.34.1 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.8 at phobos.denx.de X-Virus-Status: Clean This reverts commit 9f62a472dfb26ec14408a27938ddd2a25700009d. The changes here aren't quite right, and on platforms such as Raspberry Pi where we can have both serial and video output, the change above causes output to change. This can be seen as the hush tests we have now fail. Signed-off-by: Tom Rini --- Cc: Simon Glass Some other issues in my lab meant I thought I had tested this platform when I took the PR in originally, but hadn't. So I'd like to grab this ASAP. --- drivers/video/vidconsole-uclass.c | 44 ++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 61f4216750f2..1225de233325 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -126,14 +126,26 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y) priv->ycur = y; } -void vidconsole_position_cursor(struct udevice *dev, uint col, uint row) +/** + * set_cursor_position() - set cursor position + * + * @priv: private data of the video console + * @row: new row + * @col: new column + */ +static void set_cursor_position(struct vidconsole_priv *priv, int row, int col) { - struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - short x, y; - - x = min_t(short, col, priv->cols - 1) * priv->x_charsize; - y = min_t(short, row, priv->rows - 1) * priv->y_charsize; - vidconsole_set_cursor_pos(dev, x, y); + /* + * Ensure we stay in the bounds of the screen. + */ + if (row >= priv->rows) + row = priv->rows - 1; + if (col >= priv->cols) + col = priv->cols - 1; + + priv->ycur = row * priv->y_charsize; + priv->xcur_frac = priv->xstart_frac + + VID_TO_POS(col * priv->x_charsize); } /** @@ -180,7 +192,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) int row = priv->row_saved; int col = priv->col_saved; - vidconsole_position_cursor(dev, col, row); + set_cursor_position(priv, row, col); priv->escape = 0; return; } @@ -242,7 +254,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) if (row < 0) row = 0; /* Right and bottom overflows are handled in the callee. */ - vidconsole_position_cursor(dev, col, row); + set_cursor_position(priv, row, col); break; } case 'H': @@ -266,7 +278,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) if (col) --col; - vidconsole_position_cursor(dev, col, row); + set_cursor_position(priv, row, col); break; } @@ -655,3 +667,15 @@ int vidconsole_clear_and_reset(struct udevice *dev) return 0; } + +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); +} -- 2.34.1