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 F27DBC4332F for ; Fri, 30 Dec 2022 20:50:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D83A38553E; Fri, 30 Dec 2022 21:50:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=@gmx.de header.b="kiKWSOmL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D29698554C; Fri, 30 Dec 2022 21:50:03 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 610D38553E for ; Fri, 30 Dec 2022 21:50:00 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1672433398; bh=ZixROZRaClPDc9lIFBr2YXg8aK43T+tajqTXxG9Sgtk=; h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:In-Reply-To; b=kiKWSOmL8nAKjYNznxMkWJPW0QbfqmT+Gj24iSDmnTvNjjAmCPkPcIehkeE0LVNJo c2KGpHuXrikVSgYYSZ+qu4/0FeWUq3OG6IyGrSL9+PVSUnWUEiQ/Myp976RPUrmqgW rhzRIaJBRGtbhHzX0fv5ebaXGxhOnxLZuKF4YZJrkMqCFJ4nPHGodFqm0JyzpJtBv/ /KWKyx5yjUZhkdGw83fl/XVVz+l9gunChXJ02AWI9toBqUnGxHno1h+m1hOKWvOsmX ZAAzM+ydTc78OO3DaZCVEg+wow888azdFVB2O0xDANnnLp/4NNW6Orj07CQNbkf6l0 TcenxmVHpgqzg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.123.94] ([88.152.145.137]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MS3mz-1pH5bB1R4F-00TUIk; Fri, 30 Dec 2022 21:49:58 +0100 Message-ID: <878ced9f-d4e5-fb11-6274-385e34cc314b@gmx.de> Date: Fri, 30 Dec 2022 21:49:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH v3 1/7] dm: video: Add damage tracking API Content-Language: en-US To: Alexander Graf , u-boot@lists.denx.de Cc: Matthias Brugger , Anatolij Gustschin , Simon Glass , Da Xue References: <20221230195828.88134-1-agraf@csgraf.de> <20221230195828.88134-2-agraf@csgraf.de> From: Heinrich Schuchardt In-Reply-To: <20221230195828.88134-2-agraf@csgraf.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:HSywdFnRLS5vqqyEC4E6RtdBAoMF/0U6Rz/QRN5xqPZztLXD0hZ ggH8zjwgkxTrkskPtCKC0DHE6t6LorFAD9DCsNkHfxx35chGVF6Jxt7lWcGnUqHgbSNWl6e 6XpXVcCA7UGq+9w22N3DPn7neNVlCr7gkvzsM96kpkq8spILMMVz9TCdZYqMutOYw2PBHry 1JTTIpro7AIJEtCbcmn7Q== UI-OutboundReport: notjunk:1;M01:P0:gxoD8EIE+qM=;0Xui4BxryqXb3tt1gzB0EigQUgx bJG7O6a/T2vGH4eCoAAWlNLpv0cQpVCvW64XsBKK0QjQoYbrkjrFkusZKvMq54gGi5QI8qvki rn1r6FBh1aiaGu/ElFFlwaQtLOYGeXZUnvBcswoNQGnQDd2VLthOAUi1pPCz68Gq0cQ1Jwp9M hCusDvpxsqGKpGTxWcTUvpo/YV1oVIP3lLPHbVZSEtPlIY+RL1UVhzqQRuj7vc1tLkusBj7lb 3VCmcOK1oCPHzb+pGo2YkEmlUTcx9XhPGC9hk43MvquP9Blapofeuwt4YFD5uMP1jHcDz0a+R L40hPNN2xysFLTz8rxDtlxbl5MDT6m8sTulLIIq5jo5ZaPR+iQ7Jz9vRCbxkIiVw4a3inT0UZ XC/i/zjj94whGmB4DzxLdVr6ekZ8ih3g3Ps9/E7UYkAe32OvFAQm98hfXvC0WVS2STooFJGBB icprr3EIiUTvPAlHB5CG3LDFifIwsBhZ0EA9AEh7cCf9OEp8GV/OP545vLm2Ny1eDPz778Htr aVr0xlcfbGg/SmMmePMOFNuqTnRNM3PmenufNTthbfINpppi4usKM6VXX8if0Lf8SsabuW5oq 1Uk0Z7MSBMlGKgw39IWhlStEQv4ZZjsgx4vvxggJ/A7ZaHLohCQSSgls7oCyURBmPnkteNXMl TXEUmcoXhCZv/aLSOQXSvRB4XOOz4aNM5LtnKbAoJVaOmGcpVgvczaMGhHSIuJdT7beFb4gkm VVtHwcWXjNP41VxnI4+9l75y+5ammWJSZpis9HyrggvN+U2TXUcD3uBas1/Eh8rXyBmypF5pO o1yMCdDO67rwSM6dj3Qs0327eatAWu7c+UyWi0mTNWbQ+jhMh12zZZQ9Z+Tn1q/CXsWnAk5Gg MO+/i0o3b4ypKfFBtfLwsn1UpADkRtpGmbcIrIr3XJCiuRcGkxFh2m0HlRTEt8M9M+DXF8+K6 i5x1WELBKISqqg4a5rWUKtRh3cw= 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 On 12/30/22 20:58, Alexander Graf wrote: > 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 > > v2 -> v3: > > - Adapt Kconfig to DM always > --- > drivers/video/Kconfig | 14 ++++++++++++ > drivers/video/video-uclass.c | 41 ++++++++++++++++++++++++++++++++++++ > include/video.h | 29 +++++++++++++++++++++++-- > 3 files changed, 82 insertions(+), 2 deletions(-) > > diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig > index f539977d9b..e12457c654 100644 > --- a/drivers/video/Kconfig > +++ b/drivers/video/Kconfig > @@ -62,6 +62,20 @@ 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" > + 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 feature adds damage tracking to collect information about regio= ns > + 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 0ce376ca3f..48a053841e 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 > @@ -254,6 +256,45 @@ void video_set_default_colors(struct udevice *dev, = bool invert) > priv->colour_bg =3D video_index_to_colour(priv, back); > } > > +/* Notify about changes in the frame buffer */ > +int video_damage(struct udevice *vid, int x, int y, int width, int heig= ht) > +{ > + struct video_priv *priv =3D dev_get_uclass_priv(vid); > + int endx =3D x + width; > + int endy =3D 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 =3D priv->xsize; > + > + if (endy > priv->ysize) > + endy =3D priv->ysize; > + > + if (priv->damage.endx && priv->damage.endy) { This if is superfluous if you initialize x =3D priv->xsize, y =3D priv->ysize in video_flush_dcache(). Please, simplify the code. Best regards Heinrich > + /* Span a rectangle across all old and new damage */ > + priv->damage.x =3D min(x, priv->damage.x); > + priv->damage.y =3D min(y, priv->damage.y); > + priv->damage.endx =3D max(endx, priv->damage.endx); > + priv->damage.endy =3D max(endy, priv->damage.endy); > + } else { > + /* First damage, setting the rectangle to span it */ > + priv->damage.x =3D x; > + priv->damage.y =3D y; > + priv->damage.endx =3D endx; > + priv->damage.endy =3D 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 43f2e2c02f..4b35e97f79 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; > @@ -211,8 +217,9 @@ int video_fill(struct udevice *dev, u32 colour); > * @return: 0 on success, error code otherwise > * > * Some frame buffers are cached or have a secondary frame buffer. Thi= s > - * function syncs these up so that the current contents of the U-Boot f= rame > - * buffer are displayed to the user. > + * function syncs the damaged parts of them up so that the current cont= ents > + * of the U-Boot frame buffer are displayed to the user. It clears the = damage > + * buffer. > */ > int video_sync(struct udevice *vid, bool force); > > @@ -332,6 +339,24 @@ static inline int video_sync_copy_all(struct udevic= e *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 upd= ated > + * 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 heig= ht); > + > /** > * video_is_active() - Test if one video device it active > *