From patchwork Fri Oct 3 16:55:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 502 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510627; bh=vkoEVIvwAhCfSDCnaLgeNg4SPoZDF46Cb6VyauFsJHg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=W1k8LsS/XTMg1fyGbkeFUzPT1uk+nJZqtSaF6v3J1SP4q+0QgAyejIGI04fWnNjrT XoCQiZ4saOO2gCNUXe+uvdwjPjPudHTRDy7iN+LPC10dN+Bz3bHEMRFRfWrsy5WAWi cTIInULyTmtinajb3/4Ai20WenG07DRZu+rSo93XOLT/QuY3Pp7r3fIsLyjw8lttg+ +blmB2QtYLOVi4kB9knqSRmkwkObKgi/kxwCTRzVC/LoYfsJamokBw8pxObDN7yx+D HG102s0bs7yshYIV91oHH34rpyatqsNB2CKpbY7OLKel1O58HAGATqhLhwLAKvvy0T MwqmofqY8wvpg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3E79867DC0 for ; Fri, 3 Oct 2025 10:57:07 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id QJQRJ3xXsErH for ; Fri, 3 Oct 2025 10:57:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510626; bh=vkoEVIvwAhCfSDCnaLgeNg4SPoZDF46Cb6VyauFsJHg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=th494r2yGw8ASKKi8OmZAMY/k1867cfjznbKRSFrVq71UADUUMIf+tWHm0ZlZR8Wm c6RHAN+PHwUdqLeLrwhWTAt80xf+4Mstgn2wwabkEEr03EQfbJWOLpKUNXeBZrCaIz VXUI++g9CqBnxfbtSaORT8FL0JvFE2pMNJZoTZnnmnWWYml5qg2NnJyJ4JxcULPClJ Km8KWyyptrk8Oy2l6EFAHJ8tZvgxoKQkghdDkarLJsT1U1HIRgqbT367YbPKnIZF18 PrxqR5NVxoBw/uY0+UQ1YJlxs5956hktQAuhteRj7n8lgForIdQHvrVoLrY7GQmF1W EHJiV+TYiPnUg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 37DD667E85 for ; Fri, 3 Oct 2025 10:57:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510624; bh=C+r1GNy/8T+u1l2hfrXSG/HqBHIeWB78Ls+yHD8Os1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fRcZncv9J5knRZlFK+rq3Oqd7okUNlDZqnbw3sIYTUfDW1hOJFIkdfgl9gRFMPER2 wnbBVHGpzpaSMda4HFG1ulLkWkGbHfLfibo5dNx7/gb0JNWJ39m92zra4efH4Xgw1a w9enXS0SjE/nYkwLr8rIqcOocfpIWTb1ADRaye6aHxdBNUJ+1HHxvNy6ZR0rL4hg5a 77Tnz3cG36v8voyFcM75swHcmF+WmyVrUhFya6xCvy5+rxYr1Mw2+Z6S+jRl8JHOhT uqabYDHqKnNlQ1zX5CbrC6twdEPbj9I1WG9+u2ZLatMGbmDgx8bDtX2CG2Ej8E15uy cBuytBPzdh/6g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2800F67DC0; Fri, 3 Oct 2025 10:57:04 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Baghn0IDfgST; Fri, 3 Oct 2025 10:57:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510622; bh=hg6pjU2AWH6IiznyEJX01wbKoW2o3dD7LHWxsB1BC4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v4TKNSmE7TOwELl141mTRvIL8mb0rbqhcAccm07e5tBgGC5ZXNrDgl3nxOzZ+gYLE +hoaxbmhr5c9d1oUSJzEILMLgxjt+yBJk7YOMjcVQBZm//edn5jZ7amihzMWSIgv1t k1ua5XtyJIdw/L3gb6d34gjK7aYeKG6BLsgu+nxOR6hocR7IwUja3nRhMkLCyrHT/j u5Joxi5X5P23HyuYmAKihlghyCW8OsZzUtDDwt8BabM6fxzNOG1BOCJeSRrU45LaTO jRT+qgJ46b9S9JIo6KCrRMmXH7AjRLIcqnhCsx5N3eBhXW/Cyf8r2W8+vOiBPsyCxg zpFna0nnJlTdQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 51CE567E12; Fri, 3 Oct 2025 10:57:02 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 3 Oct 2025 10:55:14 -0600 Message-ID: <20251003165525.440173-22-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251003165525.440173-1-sjg@u-boot.org> References: <20251003165525.440173-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: GNUDMWGBTC4INUWEB6UCNOQPB4WKBBNO X-Message-ID-Hash: GNUDMWGBTC4INUWEB6UCNOQPB4WKBBNO X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 21/22] video: sandbox: Add sync() method for video List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass At present, video_sync() has a special case for sandbox. Remove this and add a sync() method in the sandbox_sdl driver instead. The sync() method checks the VIDSYNC_FLUSH flag and skips sync operation if it's not set, avoiding unnecessary SDL updates. If CONFIG_VIDEO_DAMAGE is enabled, the SDL portion accepts an optional damage rectangle parameter to support only updating the damaged region. Use the struct video_bbox definition from the video_defs.h header as this avoids trying to include too many U-Boot headers in code that is build with system headers. Co-developed-by: Claude Signed-off-by: Simon Glass --- arch/sandbox/cpu/sdl.c | 5 +++-- arch/sandbox/include/asm/sdl.h | 7 +++++-- drivers/video/sandbox_sdl.c | 19 +++++++++++++++++++ drivers/video/video-uclass.c | 4 ---- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c index f4038c2431a..246fa37d457 100644 --- a/arch/sandbox/cpu/sdl.c +++ b/arch/sandbox/cpu/sdl.c @@ -12,6 +12,7 @@ #include #include #include +#include /** * struct buf_info - a data buffer holding audio data @@ -311,7 +312,7 @@ static int copy_to_texture(void *lcd_base, const struct video_bbox *damage) return 0; } -int sandbox_sdl_sync(void *lcd_base) +int sandbox_sdl_sync(void *lcd_base, const struct video_bbox *damage) { struct SDL_Rect rect; int ret; @@ -319,7 +320,7 @@ int sandbox_sdl_sync(void *lcd_base) if (!sdl.texture) return 0; SDL_RenderClear(sdl.renderer); - ret = copy_to_texture(lcd_base, NULL); + ret = copy_to_texture(lcd_base, damage); if (ret) { printf("copy_to_texture: %d: %s\n", ret, SDL_GetError()); return -EIO; diff --git a/arch/sandbox/include/asm/sdl.h b/arch/sandbox/include/asm/sdl.h index 735652de6bd..93d934f9c54 100644 --- a/arch/sandbox/include/asm/sdl.h +++ b/arch/sandbox/include/asm/sdl.h @@ -10,6 +10,7 @@ #include struct mouse_event; +struct video_bbox; #ifdef CONFIG_SANDBOX_SDL @@ -42,9 +43,10 @@ int sandbox_sdl_remove_display(void); * user can see it. * * @lcd_base: Base of frame buffer + * @damage: Optional damage rectangle to limit the update region (may be NULL) * Return: 0 if screen was updated, -ENODEV is there is no screen. */ -int sandbox_sdl_sync(void *lcd_base); +int sandbox_sdl_sync(void *lcd_base, const struct video_bbox *damage); /** * sandbox_sdl_scan_keys() - scan for pressed keys @@ -129,7 +131,8 @@ static inline int sandbox_sdl_remove_display(void) return -ENODEV; } -static inline int sandbox_sdl_sync(void *lcd_base) +static inline int sandbox_sdl_sync(void *lcd_base, + const struct video_bbox *damage) { return -ENODEV; } diff --git a/drivers/video/sandbox_sdl.c b/drivers/video/sandbox_sdl.c index 69dfa930273..67b4b6c7911 100644 --- a/drivers/video/sandbox_sdl.c +++ b/drivers/video/sandbox_sdl.c @@ -127,6 +127,24 @@ static int sandbox_sdl_bind(struct udevice *dev) return ret; } +static int sandbox_sdl_video_sync(struct udevice *vid, uint flags) +{ + struct video_priv *priv = dev_get_uclass_priv(vid); + const struct video_bbox *damage = NULL; + + if (!(flags & VIDSYNC_FLUSH)) + return 0; + + if (IS_ENABLED(CONFIG_VIDEO_DAMAGE)) + damage = &priv->damage; + + return sandbox_sdl_sync(priv->fb, damage); +} + +static const struct video_ops sandbox_sdl_ops = { + .sync = sandbox_sdl_video_sync, +}; + static const struct udevice_id sandbox_sdl_ids[] = { { .compatible = "sandbox,lcd-sdl" }, { } @@ -139,5 +157,6 @@ U_BOOT_DRIVER(sandbox_lcd_sdl) = { .bind = sandbox_sdl_bind, .probe = sandbox_sdl_probe, .remove = sandbox_sdl_remove, + .ops = &sandbox_sdl_ops, .plat_auto = sizeof(struct sandbox_sdl_plat), }; diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index a8849cf6289..491dd23bff0 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -522,10 +522,6 @@ int video_manual_sync(struct udevice *vid, uint flags) if (IS_ENABLED(CONFIG_VIDEO_COPY) && (flags & VIDSYNC_COPY)) video_flush_dcache(vid, true); -#if defined(CONFIG_VIDEO_SANDBOX_SDL) - /* to see the copy framebuffer, use priv->copy_fb */ - sandbox_sdl_sync(priv->fb); -#endif priv->last_sync = get_timer(0); if (IS_ENABLED(CONFIG_VIDEO_DAMAGE)) {