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 EE6C1C7EE23 for ; Thu, 1 Jun 2023 16:26:44 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB59C86346; Thu, 1 Jun 2023 18:24:57 +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="KmIyXqLa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2DFB68636C; Thu, 1 Jun 2023 18:24:41 +0200 (CEST) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) (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 CEF4886345 for ; Thu, 1 Jun 2023 18:24:34 +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-il1-x136.google.com with SMTP id e9e14a558f8ab-33b9a56e261so4026545ab.0 for ; Thu, 01 Jun 2023 09:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636673; x=1688228673; 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=U8ZQ64Z7qENNEWUTvYkW05Z6192xhB6jo4sGkKR4twA=; b=KmIyXqLaOYDGvg3j1SeFwIsC1Vk02fLFPYOqhq56/ddGbpCbDUQYJIQuM+KlTNtU7/ Jz+dOMUFC7koqXeMB1Ix4yH3S4CELUSGpKBKTApSIXIf60deNrENtIEdMlGZjRGE1BhE K4OO2w3MAnPjTrF29ZNMgIKsofnq4+69Wn3qA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636673; x=1688228673; 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=U8ZQ64Z7qENNEWUTvYkW05Z6192xhB6jo4sGkKR4twA=; b=cqstvDbmeooZUbNU8H5w87WNusP5oiaOddbzhUtvUm+FhEA6mNqSx2lUgJYW1i+6Vr I9pPVBWR/8VqPZ17nOdBSMZ6wJP76zbwdqIOMDHdOs5UVBrmDMJQdL/YM0I54TxWY4wS HulWAk5hv87ncCR/bhyvyRaQ4jU07KCzKLBYAKD8B0+FYGu3oXZRD5Gu2ZmhNSAVsTD0 7UkWCXQca55Ha5xYILu9KoSF/OEdeRdWNWqW2vf4B4z/ZkCsh+mfy7EqN7XsbfJlzPxS q46XQpps14Wx7AYA9cGzDcf9k72IYO2tssYA7DEAEI8melcMQue3nV+1ggyfMuVCKVai wYsg== X-Gm-Message-State: AC+VfDwtupw0JqVr/IHJ3QY5C5eK+MKTVPmwd0dh0BaJSeLe36D8lpnQ aPX5U11xMF1K8kFpePSiyjv2+CAAo6SfAywH/bw= X-Google-Smtp-Source: ACHHUZ6XHPxJx4J1fuEHHUNUtlYpZNWlwpaZYUrEXJ8SRUR8sqe7RVadSQs16aYaIixU8afDDJR09g== X-Received: by 2002:a05:6e02:6d0:b0:33a:56d6:d9a9 with SMTP id p16-20020a056e0206d000b0033a56d6d9a9mr6559292ils.19.1685636673403; Thu, 01 Jun 2023 09:24:33 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id l1-20020a922901000000b0033a6e7ee4e3sm3862098ilg.1.2023.06.01.09.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:24:33 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass , Anatolij Gustschin Subject: [PATCH 09/40] video: Provide a way to clear part of the console Date: Thu, 1 Jun 2023 10:22:33 -0600 Message-ID: <20230601162404.220488-8-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog In-Reply-To: <20230601162404.220488-1-sjg@chromium.org> References: <20230601162404.220488-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.8 at phobos.denx.de X-Virus-Status: Clean This is useful when the background colour must be written before text is updated, to avoid strange display artifacts. Add a function for this, using the existing code from the truetype console. Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 72 ++------------------------------ drivers/video/video-uclass.c | 52 +++++++++++++++++++++++ include/video.h | 16 +++++++ 3 files changed, 71 insertions(+), 69 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 0ea8a9f6215e..63d7557c71a0 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -378,72 +378,6 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, return width_frac; } -/** - * console_truetype_erase() - Erase a character - * - * This is used for backspace. We erase a square of the display within the - * given bounds. - * - * @dev: Device to update - * @xstart: X start position in pixels from the left - * @ystart: Y start position in pixels from the top - * @xend: X end position in pixels from the left - * @yend: Y end position in pixels from the top - * @clr: Value to write - * Return: 0 if OK, -ENOSYS if the display depth is not supported - */ -static int console_truetype_erase(struct udevice *dev, int xstart, int ystart, - int xend, int yend, int clr) -{ - struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); - void *start, *line; - int pixels = xend - xstart; - int row, i, ret; - - start = vid_priv->fb + ystart * vid_priv->line_length; - start += xstart * VNBYTES(vid_priv->bpix); - line = start; - for (row = ystart; row < yend; row++) { - switch (vid_priv->bpix) { - case VIDEO_BPP8: { - uint8_t *dst = line; - - if (IS_ENABLED(CONFIG_VIDEO_BPP8)) { - for (i = 0; i < pixels; i++) - *dst++ = clr; - } - break; - } - case VIDEO_BPP16: { - uint16_t *dst = line; - - if (IS_ENABLED(CONFIG_VIDEO_BPP16)) { - for (i = 0; i < pixels; i++) - *dst++ = clr; - } - break; - } - case VIDEO_BPP32: { - uint32_t *dst = line; - - if (IS_ENABLED(CONFIG_VIDEO_BPP32)) { - for (i = 0; i < pixels; i++) - *dst++ = clr; - } - break; - } - default: - return -ENOSYS; - } - line += vid_priv->line_length; - } - ret = vidconsole_sync_copy(dev, start, line); - if (ret) - return ret; - - return 0; -} - /** * console_truetype_backspace() - Handle a backspace operation * @@ -482,9 +416,9 @@ static int console_truetype_backspace(struct udevice *dev) else xend = vid_priv->xsize; - console_truetype_erase(dev, VID_TO_PIXEL(pos->xpos_frac), pos->ypos, - xend, pos->ypos + vc_priv->y_charsize, - vid_priv->colour_bg); + video_fill_part(vid_dev, VID_TO_PIXEL(pos->xpos_frac), pos->ypos, + xend, pos->ypos + vc_priv->y_charsize, + vid_priv->colour_bg); /* Move the cursor back to where it was when we pushed this record */ vc_priv->xcur_frac = pos->xpos_frac; diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 8396bdfb11e1..1db049bec004 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -142,6 +142,58 @@ int video_reserve(ulong *addrp) return 0; } +int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, + int yend, u32 colour) +{ + struct video_priv *priv = dev_get_uclass_priv(dev); + void *start, *line; + int pixels = xend - xstart; + int row, i, ret; + + start = priv->fb + ystart * priv->line_length; + start += xstart * VNBYTES(priv->bpix); + line = start; + for (row = ystart; row < yend; row++) { + switch (priv->bpix) { + case VIDEO_BPP8: { + u8 *dst = line; + + if (IS_ENABLED(CONFIG_VIDEO_BPP8)) { + for (i = 0; i < pixels; i++) + *dst++ = colour; + } + break; + } + case VIDEO_BPP16: { + u16 *dst = line; + + if (IS_ENABLED(CONFIG_VIDEO_BPP16)) { + for (i = 0; i < pixels; i++) + *dst++ = colour; + } + break; + } + case VIDEO_BPP32: { + u32 *dst = line; + + if (IS_ENABLED(CONFIG_VIDEO_BPP32)) { + for (i = 0; i < pixels; i++) + *dst++ = colour; + } + break; + } + default: + return -ENOSYS; + } + line += priv->line_length; + } + ret = video_sync_copy(dev, start, line); + if (ret) + return ret; + + return 0; +} + int video_fill(struct udevice *dev, u32 colour) { struct video_priv *priv = dev_get_uclass_priv(dev); diff --git a/include/video.h b/include/video.h index 29c4f51efb08..e5b0db294734 100644 --- a/include/video.h +++ b/include/video.h @@ -203,6 +203,22 @@ int video_clear(struct udevice *dev); */ int video_fill(struct udevice *dev, u32 colour); +/** + * video_fill_part() - Erase a region + * + * Erase a rectangle of the display within the given bounds. + * + * @dev: Device to update + * @xstart: X start position in pixels from the left + * @ystart: Y start position in pixels from the top + * @xend: X end position in pixels from the left + * @yend: Y end position in pixels from the top + * @colour: Value to write + * Return: 0 if OK, -ENOSYS if the display depth is not supported + */ +int video_fill_part(struct udevice *dev, int xstart, int ystart, int xend, + int yend, u32 colour); + /** * video_sync() - Sync a device's frame buffer with its hardware * -- 2.41.0.rc0.172.g3f132b7071-goog