From patchwork Thu Jun 9 22:59:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 1641494 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LK00x5hfdz9s09 for ; Fri, 10 Jun 2022 09:00:01 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7ADE7843D0; Fri, 10 Jun 2022 00:59:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=csgraf.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 60C57843F2; Fri, 10 Jun 2022 00:59:29 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from zulu616.server4you.de (mail.csgraf.de [85.25.223.15]) by phobos.denx.de (Postfix) with ESMTP id BC7A6843D1 for ; Fri, 10 Jun 2022 00:59:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=csgraf.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=agraf@csgraf.de Received: from localhost.localdomain (dynamic-077-004-116-159.77.4.pool.telefonica.de [77.4.116.159]) by csgraf.de (Postfix) with ESMTPSA id 0DAB06080305; Fri, 10 Jun 2022 00:59:23 +0200 (CEST) From: Alexander Graf To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Anatolij Gustschin , Simon Glass , Matthias Brugger , Da Xue Subject: [PATCH v2 1/7] dm: video: Add damage tracking API Date: Fri, 10 Jun 2022 00:59:15 +0200 Message-Id: <20220609225921.62462-2-agraf@csgraf.de> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220609225921.62462-1-agraf@csgraf.de> References: <20220609225921.62462-1-agraf@csgraf.de> MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean We are going to introduce image damage tracking to fasten up screen refresh on large displays. This patch adds damage tracking for up to one rectangle of the screen which is typically enough to hold blt or text print updates. Callers into this API and a reduced dcache flush code path will follow in later patches. Signed-off-by: Alexander Graf Reported-by: Da Xue --- v1 -> v2: - Remove ifdefs --- drivers/video/Kconfig | 15 +++++++++++++ drivers/video/video-uclass.c | 41 ++++++++++++++++++++++++++++++++++++ include/video.h | 29 +++++++++++++++++++++++-- 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 965b587927..9e1c409b37 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -64,6 +64,21 @@ config VIDEO_COPY To use this, your video driver must set @copy_base in struct video_uc_plat. +config VIDEO_DAMAGE + bool "Enable damage tracking of frame buffer regions" + depends on DM_VIDEO + default y if ARM && !SYS_DCACHE_OFF + help + On some machines (most ARM), the display frame buffer resides in + RAM. To make the display controller pick up screen updates, we + have to flush frame buffer contents from CPU caches into RAM which + can be a slow operation. + + This patch adds damage tracking to collect information about regions + that received updates. When we want to sync, we then only flush + regions of the frame buffer that were modified before, speeding up + screen refreshes significantly. + config BACKLIGHT_PWM bool "Generic PWM based Backlight Driver" depends on BACKLIGHT && DM_PWM diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 01e8af5ac6..17793490d1 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #ifdef CONFIG_SANDBOX #include #endif @@ -180,6 +182,45 @@ void video_set_default_colors(struct udevice *dev, bool invert) priv->colour_bg = vid_console_color(priv, back); } +/* Notify about changes in the frame buffer */ +int video_damage(struct udevice *vid, int x, int y, int width, int height) +{ + struct video_priv *priv = dev_get_uclass_priv(vid); + int endx = x + width; + int endy = y + height; + + if (!CONFIG_IS_ENABLED(VIDEO_DAMAGE)) + return 0; + + if (x > priv->xsize) + return 0; + + if (y > priv->ysize) + return 0; + + if (endx > priv->xsize) + endx = priv->xsize; + + if (endy > priv->ysize) + endy = priv->ysize; + + if (priv->damage.endx && priv->damage.endy) { + /* Span a rectangle across all old and new damage */ + priv->damage.x = min(x, priv->damage.x); + priv->damage.y = min(y, priv->damage.y); + priv->damage.endx = max(endx, priv->damage.endx); + priv->damage.endy = max(endy, priv->damage.endy); + } else { + /* First damage, setting the rectangle to span it */ + priv->damage.x = x; + priv->damage.y = y; + priv->damage.endx = endx; + priv->damage.endy = endy; + } + + return 0; +} + /* Flush video activity to the caches */ int video_sync(struct udevice *vid, bool force) { diff --git a/include/video.h b/include/video.h index 43e2c89977..acb65d70a2 100644 --- a/include/video.h +++ b/include/video.h @@ -109,6 +109,12 @@ struct video_priv { void *fb; int fb_size; void *copy_fb; + struct { + int x; + int y; + int endx; + int endy; + } damage; int line_length; u32 colour_fg; u32 colour_bg; @@ -167,8 +173,9 @@ int video_clear(struct udevice *dev); * @return: 0 on success, error code otherwise * * Some frame buffers are cached or have a secondary frame buffer. This - * function syncs these up so that the current contents of the U-Boot frame - * buffer are displayed to the user. + * function syncs the damaged parts of them up so that the current contents + * of the U-Boot frame buffer are displayed to the user. It clears the damage + * buffer. */ int video_sync(struct udevice *vid, bool force); @@ -268,6 +275,24 @@ static inline int video_sync_copy_all(struct udevice *dev) #endif +/** + * video_damage() - Notify the video subsystem about screen updates. + * + * @vid: Device to sync + * @x: Upper left X coordinate of the damaged rectangle + * @y: Upper left Y coordinate of the damaged rectangle + * @width: Width of the damaged rectangle + * @height: Height of the damaged rectangle + * + * @return: 0 + * + * Some frame buffers are cached or have a secondary frame buffer. This + * function notifies the video subsystem about rectangles that were updated + * within the frame buffer. They may only get written to the screen on the + * next call to video_sync(). + */ +int video_damage(struct udevice *vid, int x, int y, int width, int height); + /** * video_is_active() - Test if one video device it active *