From patchwork Sat Jan 3 01:18:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1202 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=1767403200; bh=3oxFxAhJa1vz2huChI3xNGHZMlcIyJvrsb3xQKR3kCQ=; 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=DboCO3444fpEkVGVUETMScDaz0b5N1aVjvdJOxoqO1gNjv4HmLuK7QWw1g88MLcfZ txEa5DSQm7DEuR7OpLXHrm7jQINBlzRABOfsnCq/D+6N06FFWOixkk10RvJEclC9V2 szEejWE1HYo5vlQIwgyDcAfjuMZHN+C/YwYZe/8M9D04zt+u2gGg9YYem+dAt/oof/ 3NtR8L6qhpsuQAsk96koA8eLwJnWHfAsi1m859GBzIhGuPMMqZm2fGZoW1o+SrXM+G 7gkcFBrlFjg24JVmb9v681BO/Aq/praRwmSISUmDJWGjiRAol3Bu09sRr14NbQ5wnP Kc5hCat9gp9rA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DB9F46904E for ; Fri, 2 Jan 2026 18:20:00 -0700 (MST) 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 eSd0d72BmYzO for ; Fri, 2 Jan 2026 18:20:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403200; bh=3oxFxAhJa1vz2huChI3xNGHZMlcIyJvrsb3xQKR3kCQ=; 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=DboCO3444fpEkVGVUETMScDaz0b5N1aVjvdJOxoqO1gNjv4HmLuK7QWw1g88MLcfZ txEa5DSQm7DEuR7OpLXHrm7jQINBlzRABOfsnCq/D+6N06FFWOixkk10RvJEclC9V2 szEejWE1HYo5vlQIwgyDcAfjuMZHN+C/YwYZe/8M9D04zt+u2gGg9YYem+dAt/oof/ 3NtR8L6qhpsuQAsk96koA8eLwJnWHfAsi1m859GBzIhGuPMMqZm2fGZoW1o+SrXM+G 7gkcFBrlFjg24JVmb9v681BO/Aq/praRwmSISUmDJWGjiRAol3Bu09sRr14NbQ5wnP Kc5hCat9gp9rA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CA2BF68FAF for ; Fri, 2 Jan 2026 18:20:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403198; bh=26Qvl0orD0W+/13QhRdrfP2DfFZdIMmQk5Y0i5ePPMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eCquTY/srx4VZDTkzux/V/BzJgtaSMj4hhIRFTbjHg8cOCIIEn7fL25nkrjOyeb9u 5/MqRnKoM6+uKqdZV4T9VxEJEUUZwUyeeOlcEezUBmlqoHE4zMIIUkufX26m2tEcnY FlISaz5Av05OoiskKuA/1R7KIaxjxiSCp6RC3keUG7VcypihkLHASAgN2D5YsiIiQZ ytvgQA4MRMNDtAl26dgirXBQ+qMEn0siUtJYD0/7PjMla1b2xq1PGxDvNVgvaxq33b Nh4Rktu9dDIhm8qAaPHgJPcCM+yN4G0jvrwiY9A2Qd2vS7kOjZtv413Kh+2QLudqR+ xhqZ5sl02LO4g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C943E68F5F; Fri, 2 Jan 2026 18:19:58 -0700 (MST) 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 VhmjV5Fm1EmH; Fri, 2 Jan 2026 18:19:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767403194; bh=eiDSr9isc/174j06kfWMFPK4XAO9P11wq/DFiNf+AsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBbmbumsb+r17d1Yn8lMAZ5xP4iBMU7xqXvbz5i9CKLCEO2br1DMQqezXJQWcFTgu NWyDRxi7Ag1tft19ljVBqP9mtlk+A4MMkFe3/Er5iSKcKQ9JfMH8wy55NQ4eYDsiY2 oWLaZV+5RlUCVX1wevMpXwe0TX2kXDWbyXAwJpLE5KaGX1gXfx8EEL7GNgu35A0CYb 1UnrjCrGeihSlN+6IEPgXAXQCXLDBKz5C20ntFx4yQ4OslSMre60vTDy9bn4si7N11 U/iIrxRUh0XpjkeemUqqp0NeW8odhhbbcwJOWvfn49ueXy+3N7ouMWCW8jj5uqCiGP 1um2vXvKRsF0A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E8B1F68FAF; Fri, 2 Jan 2026 18:19:53 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 2 Jan 2026 18:18:44 -0700 Message-ID: <20260103011908.149445-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260103011908.149445-1-sjg@u-boot.org> References: <20260103011908.149445-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JLOFB5DBOJWFCWIWNIXB5XFWXE2XYWPM X-Message-ID-Hash: JLOFB5DBOJWFCWIWNIXB5XFWXE2XYWPM 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 08/24] video: Optimise video_flush_copy() for full-line damage 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 When copying partial framebuffer regions line by line, there is overhead from multiple memcpy() calls. Optimise video_flush_copy() to detect when entire lines are being copied (damage spans full width) and perform a single memcpy() for the whole region instead of looping line by line. Also invert the early-exit check to reduce nesting. Co-developed-by: Claude Signed-off-by: Simon Glass --- drivers/video/video-uclass.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 3e02c48d399..698fe0e4caf 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -507,16 +507,25 @@ static void video_flush_copy(struct udevice *vid) if (!priv->copy_fb) return; - if (damage->x1 && damage->y1) { - int lstart = damage->x0 * VNBYTES(priv->bpix); - int lend = damage->x1 * VNBYTES(priv->bpix); + if (!damage->x1 || !damage->y1) + return; + + int lstart = damage->x0 * VNBYTES(priv->bpix); + int llen = damage->x1 * VNBYTES(priv->bpix) - lstart; + + /* Copy entire region at once if full lines are damaged */ + if (!lstart && llen == priv->line_length) { + ulong offset = damage->y0 * priv->line_length; + ulong len = (damage->y1 - damage->y0) * priv->line_length; + + memcpy(priv->copy_fb + offset, priv->fb + offset, len); + } else { int y; for (y = damage->y0; y < damage->y1; y++) { - ulong offset = (y * priv->line_length) + lstart; - ulong len = lend - lstart; + ulong offset = y * priv->line_length + lstart; - memcpy(priv->copy_fb + offset, priv->fb + offset, len); + memcpy(priv->copy_fb + offset, priv->fb + offset, llen); } } }