From patchwork Fri Sep 19 20:14:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 378 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=1758313048; bh=SBTr9oQnoJsUODG/31DtSESWwrj6jaJpagF4q5wZUQY=; 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=fXMitbEORIcVzfFy/d2fFkhauQT8oTywoNK/VSFuSWUv57owKr4OnLmGG4czjUvvn x6lEe7DiU7hGCqij9STN9IgUZOGxF8HE8YTqO3RUnXv+s6PdYe/vAbtBnmGeBXlRjM RYL+BVEnul+Tqfz9s0ziGrl42LQ5KtW3SXiN8Hx+3w53B7BgR4uFa+3oukIwHQNFpc vjCoKC1d2fqDnu7li/KZBq2hBnGlmMPgGlnDxfPX2/4QtjdQEvUPsZF99Khcfnz7pd sAe0334wpNXn88+NShIHY17pD1E3Tz75GUe70F4WKTKae6gfxbQy9xZxmh3MEis9yo V+Oi4B0XfjiYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F8CC67BFC for ; Fri, 19 Sep 2025 14:17:28 -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 vf8Nwgijf970 for ; Fri, 19 Sep 2025 14:17:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313048; bh=SBTr9oQnoJsUODG/31DtSESWwrj6jaJpagF4q5wZUQY=; 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=fXMitbEORIcVzfFy/d2fFkhauQT8oTywoNK/VSFuSWUv57owKr4OnLmGG4czjUvvn x6lEe7DiU7hGCqij9STN9IgUZOGxF8HE8YTqO3RUnXv+s6PdYe/vAbtBnmGeBXlRjM RYL+BVEnul+Tqfz9s0ziGrl42LQ5KtW3SXiN8Hx+3w53B7BgR4uFa+3oukIwHQNFpc vjCoKC1d2fqDnu7li/KZBq2hBnGlmMPgGlnDxfPX2/4QtjdQEvUPsZF99Khcfnz7pd sAe0334wpNXn88+NShIHY17pD1E3Tz75GUe70F4WKTKae6gfxbQy9xZxmh3MEis9yo V+Oi4B0XfjiYg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8F64867C06 for ; Fri, 19 Sep 2025 14:17:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313046; bh=ALT+PR3q55DIRU329bhhQjZUjLN6qV9vHP7K3+87zWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cmyl0vNCTgQPxZaqXowFaJI7KZ3RFoOUcGs2ZdwMIGB+oDdKoPczck5vvbzRvLpau Nf75ft5OizP60rLxg8uOtB7N/DVK0Pxa2lodJcXvZcehy3eN/rQONWf5gEUMes/kWK iTCFaD0hcOcV+1m+G8jY5eOlryZb38Vlu67YzjekufC6M/TgHppiDm81Sn0G3ggxqS rmk/SoEOWwli/3pw2y0iO4m3zlEoGhuwE2+CFTleN1HfnhxR+Id6tC6cQwLSMtHiig GpjVn/ltDs+S/gtGBu/bk/WU4yGwosn+OPYuYq8cRXIkjS33PXlcHDTtvkUv9J8LAC Tnx8xs82uuSCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8022B67C06; Fri, 19 Sep 2025 14:17:26 -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 b50dme6iCQoE; Fri, 19 Sep 2025 14:17:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313039; bh=rtLA4nuX+Qmtpo2iXWC9841R6wYQO3QAkKFnVtDB+4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ijjl5dLR+tSSMIjBsZqzrz+Jg6cuJ6fevulD79FJ5vboDfUrWPFVibIzkAQIr3nNJ sD78lV5uTiN1xSkylJWcJzrnnKja2QlPfTS1TsEj3PKCfh0u1r44uQl0y76dTzsAcE O/r9i3+U9/vxnPskJtTD45dofrRdPlY9P1hUbfV7c8PcYr7E+tYDRYaP7RMgswGsqO PiaZyAnJPysF65vesQJfBZI2aRnwV4Ckyx1YM9BmND0qZ4LltoOjz7AZAPVJSqmnoT odH1BfFgOclpFQGLrDzaUqPepCgoXzIlaZq5CkQF8JIqYORSZGRBwzCBiail2AbDgq ClXMRkbFHAs9w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1176967A99; Fri, 19 Sep 2025 14:17:19 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:43 -0600 Message-ID: <20250919201507.4024144-37-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250919201507.4024144-1-sjg@u-boot.org> References: <20250919201507.4024144-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6AGQINEQR7HDBGZEWAAKO7X2RSAAHIVS X-Message-ID-Hash: 6AGQINEQR7HDBGZEWAAKO7X2RSAAHIVS 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 36/42] video: Support reading the framebuffer when writing 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 Create a variant of fill_pixel_and_goto_next() function which returns the old pixel value. This will make it easy to save the framebuffer pixels as they are overwritten by drawing the cursor. Leave the current function alone, since it increases code size about 16 bytes and may slow down blitting. Signed-off-by: Simon Glass --- drivers/video/console_core.c | 25 +++++++++++++++++++++++++ drivers/video/vidconsole_internal.h | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index b1688e717c9..4fab5a2605e 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -61,6 +61,31 @@ inline void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int ste *dstp = dst_byte + step; } +inline u32 swap_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step) +{ + u8 *dst_byte = *dstp; + u32 old_value = 0; + + if (pbytes == 4) { + u32 *dst = *dstp; + old_value = *dst; + *dst = value; + } + if (pbytes == 2) { + u16 *dst = *dstp; + old_value = *dst; + *dst = value; + } + if (pbytes == 1) { + u8 *dst = *dstp; + old_value = *dst; + *dst = value; + } + *dstp = dst_byte + step; + + return old_value; +} + int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vid_priv, struct video_fontdata *fontdata, bool direction) { diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 4cb6ba4e15f..93f9c7b4e56 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -45,6 +45,18 @@ int check_bpix_support(int bpix); */ void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step); +/** + * swap_pixel_and_goto_next() - Swap 1 pixel in framebuffer, and go to next one + * + * @param dstp a pointer to pointer to framebuffer. + * @param value value to write to framebuffer. + * @param pbytes framebuffer bytes per pixel. + * @param step framebuffer pointer increment. Usually is equal to pbytes, + * and may be negative to control filling direction. + * Return: old value of the pixel + */ +u32 swap_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step); + /** * Fills 1 character in framebuffer vertically. Vertically means we're filling char font data rows * across the lines.