From patchwork Fri Oct 3 16:55:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 499 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=1759510617; bh=9T1P4ItSj53IqF2damTqviFx9E7WU1/BCqI6y/pr8qg=; 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=w8rYoyqwtGi3BcGuKjLjy0WrUFOCXtLgtkX3JdeFDm2flW1tfvL+Zr1VfJXONsrpn +hv1CjO3MqEPWOPz0W3Nx/uwB8WO2wOR9zWCo0B2rhJvupfV2ZTrBjsGASgtrI9pnQ +mcjdDcqqV0rIkB4eHFzlTz2Xk6n18ScwpHeGrXlNaTIuHsij7ZrRvz27sYBHQDlb+ JVLxE8n/Hf699rEZkuCB56ThNiQajLe7bYL+e6SZCcTCLCjkZUooe4cad8guNHrU9K BPW5WB0MBpJDTJBUydsmn0xFlbRyCQyXHnVsZcyMfLIMJE1/XngtdaSkuV78YQx94b 1GBt30z5qFzfQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A9CD67EC5 for ; Fri, 3 Oct 2025 10:56:57 -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 uYr4ES269wqJ for ; Fri, 3 Oct 2025 10:56:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510617; bh=9T1P4ItSj53IqF2damTqviFx9E7WU1/BCqI6y/pr8qg=; 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=w8rYoyqwtGi3BcGuKjLjy0WrUFOCXtLgtkX3JdeFDm2flW1tfvL+Zr1VfJXONsrpn +hv1CjO3MqEPWOPz0W3Nx/uwB8WO2wOR9zWCo0B2rhJvupfV2ZTrBjsGASgtrI9pnQ +mcjdDcqqV0rIkB4eHFzlTz2Xk6n18ScwpHeGrXlNaTIuHsij7ZrRvz27sYBHQDlb+ JVLxE8n/Hf699rEZkuCB56ThNiQajLe7bYL+e6SZCcTCLCjkZUooe4cad8guNHrU9K BPW5WB0MBpJDTJBUydsmn0xFlbRyCQyXHnVsZcyMfLIMJE1/XngtdaSkuV78YQx94b 1GBt30z5qFzfQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5391367E86 for ; Fri, 3 Oct 2025 10:56:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510615; bh=tVTZSylEIp6g7CrnFj/GynyURuIT6UEHgM4gSHB01RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4dnO9XnWcz3JGcp8MV8awZoep0PuYlok81+jtDgdXbDwa+Aug+YnVG4zIhKCdm54 WgnNoInrP0xw6aHFZOtOWO2rd6g1kUgbm/1IpSfmnrFNd+/SEdPMqfpsBFpljer8CV 8Murtz0c7bF0YmtHMsb0/uvFummw3JXGE9oRdTQn5PEQ8nToyiZhrQBwQ1ZeGXoi6M +tHHO7r6V+5YZPPi/3t0G27cDdH1AtCyoMbCJMjBYyRi3xTY0eRDDwSTHBova37rcp Fk17GvH/ryFt6/CRlssr6yxDavlwmz6PmLKu03MtAvd9+3KjMgFwax5K05RD6V3BA+ 49iAxFWpWqNDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BC77167E12; Fri, 3 Oct 2025 10:56:55 -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 H1PBp9tVwF74; Fri, 3 Oct 2025 10:56:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510611; bh=qlKBXeTJshejRTrnNeMTnB/Kt+iNNOzswcxb/eKBwpo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KQB/JigiNUfUHoTrtfsuCpnlq+5PmccJBPNjAmIALwYJnmYMYlNaeZNVyAZ/wYGjN 9l5cwQ0Qq33D8/mPhjH5sqBVgW4bLQU7DOySyjtRc3z+/dmKNla9I9LVAZzZTblchu 95/y1h8uV7jGESYbwCG/HgV0zKCDuO5gsX5CUXgYs5NdqMKrB8OTlL/tq0uFDN/6ON 4exgqR7Dys+K15Ddn+sjntD1kWnH+XFLc7NLWpxt3YKScrsWyYPxuotsoNezHNfbKm XhiP6ImyaDZx+vb560qQzCOcfBLLGXkEDjsyCWNa6a9tZSflTnNH5agU5zBKd/kQDg JXKqh38VOKyWw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EE59567ECA; Fri, 3 Oct 2025 10:56:50 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 3 Oct 2025 10:55:11 -0600 Message-ID: <20251003165525.440173-19-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: QX7HOD3BCLVY62AG5INT7CPVNV35H37T X-Message-ID-Hash: QX7HOD3BCLVY62AG5INT7CPVNV35H37T 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 18/22] video: Add flags parameter to sync() operation 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 Add an enum video_sync_flags with VIDSYNC_FORCE, VIDSYNC_FLUSH, and VIDSYNC_COPY flags and update the sync() operation in struct video_ops to accept a flags parameter. This allows for more flexible control of video sync behavior. The VIDSYNC_FLUSH flag is set when a full flush should be performed, and the VIDSYNC_COPY flag indicates whether the framebuffer should be flushed to the copy buffer. The logic is now calculated before calling sync() so drivers can observe these states. Co-developed-by: Claude Signed-off-by: Simon Glass --- drivers/video/efi.c | 2 +- drivers/video/mcde_simple.c | 2 +- drivers/video/seps525.c | 2 +- drivers/video/video-uclass.c | 14 +++++++++++--- include/video.h | 15 ++++++++++++++- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/video/efi.c b/drivers/video/efi.c index 578392c3908..b5e472395e9 100644 --- a/drivers/video/efi.c +++ b/drivers/video/efi.c @@ -43,7 +43,7 @@ struct efi_video_priv { bool use_blit; }; -static int efi_video_sync(struct udevice *dev) +static int efi_video_sync(struct udevice *dev, uint flags) { struct video_priv *vid_priv = dev_get_uclass_priv(dev); struct efi_video_priv *priv = dev_get_priv(dev); diff --git a/drivers/video/mcde_simple.c b/drivers/video/mcde_simple.c index 7591e088e38..9dd9c382644 100644 --- a/drivers/video/mcde_simple.c +++ b/drivers/video/mcde_simple.c @@ -94,7 +94,7 @@ static int mcde_simple_probe(struct udevice *dev) return 0; } -static int mcde_simple_video_sync(struct udevice *dev) +static int mcde_simple_video_sync(struct udevice *dev, uint flags) { struct mcde_simple_priv *priv = dev_get_priv(dev); unsigned int val; diff --git a/drivers/video/seps525.c b/drivers/video/seps525.c index 11293872a5c..aaf716cb65d 100644 --- a/drivers/video/seps525.c +++ b/drivers/video/seps525.c @@ -221,7 +221,7 @@ static int seps525_spi_startup(struct udevice *dev) return 0; } -static int seps525_sync(struct udevice *vid) +static int seps525_sync(struct udevice *vid, uint flags) { struct video_priv *uc_priv = dev_get_uclass_priv(vid); struct seps525_priv *priv = dev_get_priv(vid); diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index f8ba3abc5f4..8f5689a8a51 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -505,23 +505,31 @@ int video_sync(struct udevice *vid, bool force) struct video_priv *priv = dev_get_uclass_priv(vid); struct video_uc_priv *uc_priv = uclass_get_priv(vid->uclass); struct video_ops *ops = video_get_ops(vid); + uint flags = 0; int ret; /* Skip sync if manual-sync mode is active */ if (uc_priv->manual_sync) return 0; + if (force) + flags |= VIDSYNC_FORCE; + + /* Check if sync should do full flush */ + if (!CONFIG_IS_ENABLED(CYCLIC) || force || + get_timer(priv->last_sync) >= CONFIG_VIDEO_SYNC_MS) + flags |= VIDSYNC_FLUSH; + if (IS_ENABLED(CONFIG_VIDEO_COPY)) video_flush_copy(vid); if (ops && ops->sync) { - ret = ops->sync(vid); + ret = ops->sync(vid, flags); if (ret) return ret; } - if (CONFIG_IS_ENABLED(CYCLIC) && !force && - get_timer(priv->last_sync) < CONFIG_VIDEO_SYNC_MS) + if (!(flags & VIDSYNC_FLUSH)) return 0; video_flush_dcache(vid, false); diff --git a/include/video.h b/include/video.h index 3f5c8cbd45a..d08781d3a78 100644 --- a/include/video.h +++ b/include/video.h @@ -10,6 +10,7 @@ #include #include #include +#include #ifdef CONFIG_SANDBOX #include #endif @@ -74,6 +75,17 @@ enum video_format { VIDEO_X2R10G10B10, }; +/** + * enum video_sync_flags - Flags for video_sync() operations + * + * @VIDSYNC_FORCE: Force sync even if recently synced or in manual-sync mode + * @VIDSYNC_FLUSH: Flush dcache and perform full sync operations + */ +enum video_sync_flags { + VIDSYNC_FORCE = BIT(0), + VIDSYNC_FLUSH = BIT(1), +}; + /** * struct video_priv - Device information used by the video uclass * @@ -146,9 +158,10 @@ struct video_ops { * to optimise the region to redraw. * * @dev: Video device + * @flags: Flags for the sync operation (enum video_sync_flags) * Return 0 on success, or -ve error code */ - int (*sync)(struct udevice *dev); + int (*sync)(struct udevice *dev, uint flags); }; #define video_get_ops(dev) ((struct video_ops *)(dev)->driver->ops)