From patchwork Fri Sep 19 20:14:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 377 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=1758313044; bh=unMY5ueFIzxdPAHvJyZv7KSOmOs+WqV1En9meDQQR20=; 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=vEASm8lvXJgUo7UteaV40Czg/6y1LsUxpeLVpmkAc6d16IInuoKHLH2ZrfPKd0Cor 3KKyQUfJYxe8J4WDD7xybOpIr2Ma832WCK/dAuevsrpHhnh6JoUBt/dhd87Z52/Axw eCmodjr0L+Y23SzHZ4TGMfVwdGkGu7GWjgZI8H+gtp645tqgVW9TzQXe7CFAVlLCbI L/fOXG8Q0BOVPR/HFieJBnb+MLX5a4NZq0nqc/weiJe3N8InLMqu6iPdAE5PSRwOcP PDAT9fn1Q5/+pKJQOTapxyRvL0sfXQltIDf8l/9JiqeAXGvqphbdQkHSmWRWc8nCXY yiDK5z6exu1fg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 425A367C6C for ; Fri, 19 Sep 2025 14:17:24 -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 Cbhbm_M8W_BP for ; Fri, 19 Sep 2025 14:17:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313042; bh=unMY5ueFIzxdPAHvJyZv7KSOmOs+WqV1En9meDQQR20=; 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=JB7iCShd5hKFEoxPSofXByN7Cw+00WFWVfB3s884RysoxCAEpi55E7/UhvGABm7TX zRTGC2gMk+9DvnGD+RQemiYS4aXrjGXk+98AG1SAETixen77IKFThWSZncD/opRJrC tz93ZwISlc80hguv10hzjkJhbUL+h3CJ0M3iRSGCkqmpZ+Pk5DEixQP6SWMAPGYS7u VwA6YjSq1ds9FOz2FBu4gk3JlXgPixIDe2JCgShl1dS2yMSNtYuGOeAFkNUEUUonG1 d9Sm1WKj8zwBbsSjP5LVn4vcLZaY10YbeAY9vCa5sxRx/J2AOgh65mqiMoZouNjdD9 yqrYFExXidR1w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3B19067C0E for ; Fri, 19 Sep 2025 14:17:22 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313039; bh=qX/3ZzWMi1fFCxfcBPwy8fgfpDzFCh73G39sD1eB7Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bR3Ptv0b0eG5akyD4TugnbdykJyIPme8I0fE/OzaKl+Nm2HM1P2boflLSq1lItlA8 7HC/OwL9q1i4CiX+ohjecFvsUBvZDysROst2SHjPqvHqFkWfyNvfpahZxtGT7hK5sF 2JjIg1gXvuUehp9ig/tO7sfoW1M7OawOHUA845VmdXKx5N2z1e6dnIPO0qBhY2cCsk XIrmjKQQvXqJysZ9phFllNqTTIzI3CLFF20ZM8zQxn4CoZGFw+JW8M01in28l/3Eko IhnV+mAyh7vTgZqBFvmY4fOaK7Bc/bxMNRivij12UyuP+XWNxyuWP/Uj5S6d1e/5tp wREs10YXROk2w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 275EA67B3B; Fri, 19 Sep 2025 14:17:19 -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 6zH8gKJw62A7; Fri, 19 Sep 2025 14:17:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758313037; bh=4nq7TZJ71bMceY2rUChXnWgHhM6nsI2Bw1avKY6ViU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mOVbX2aIhPGTsIYxW+CS/KiQ5e0jlSmg7DD/uBU2zXPld9mX/jP/C8ARbFgkIj5bc a1K1YOq0Lg1YNTqnNRs6ggJblCw2BmbH6pBL1CKv5yea+K00g5ewWecwEv484qJDwQ g9KVTl2KxBQsbYNfY/fnzm5I1YElkZCzmza06EnH/PDcP26mUPTgjZGzXRM+rg2Mx1 fe9EtHfJgxBks6Io8nm954sF5quBLyOFoK0DcYP+v9gaN8xBrwuHvtjIBWk2FTNg7R 3rwoqOT5Pi3ZnJdFr8qAf1lmyeavT5AV8ELeEl97J1ACoQdzAnUfG005bMct+/JemV +9xmUfT21H/sg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0A44567C8F; Fri, 19 Sep 2025 14:17:16 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:42 -0600 Message-ID: <20250919201507.4024144-36-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: EKWDJ4E5R25W7LFPCH6GTZXCH26Q6OWU X-Message-ID-Hash: EKWDJ4E5R25W7LFPCH6GTZXCH26Q6OWU 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 35/42] video: Provide a buffer to hold pixels behind the cursor 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 Drawing the cursor is a destructive operation, so we must save the previous contents of the affected part of the framebuffer, so it can be restored afterwards. Add this to the cursor info and set it up when probing the console device. Signed-off-by: Simon Glass --- drivers/video/console_core.c | 41 ++++++++++++++++++++++++++++- drivers/video/console_truetype.c | 4 +++ drivers/video/vidconsole_internal.h | 10 +++++++ include/video_console.h | 4 +++ 4 files changed, 58 insertions(+), 1 deletion(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 6db42e63ea9..b1688e717c9 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -9,6 +9,8 @@ #include #include #include +#include +#include #include #include "vidconsole_internal.h" @@ -198,9 +200,46 @@ int cursor_show(struct vidconsole_cursor *curs, struct video_priv *vid_priv, return 0; } +int console_alloc_cursor(struct udevice *dev) +{ + struct vidconsole_priv *vc_priv; + struct vidconsole_cursor *curs; + struct video_priv *vid_priv; + struct udevice *vid; + int save_count; + + if (!CONFIG_IS_ENABLED(CURSOR) || xpl_phase() < PHASE_BOARD_R) + return 0; + + vc_priv = dev_get_uclass_priv(dev); + vid = dev_get_parent(dev); + vid_priv = dev_get_uclass_priv(vid); + curs = &vc_priv->curs; + + /* Allocate cursor save buffer for maximum possible cursor height */ + save_count = vid_priv->ysize * VIDCONSOLE_CURSOR_WIDTH; + curs->save_data = malloc(save_count * sizeof(u32)); + if (!curs->save_data) + return -ENOMEM; + + return 0; +} + int console_probe(struct udevice *dev) { - return console_set_font(dev, fonts); + int ret; + + ret = console_set_font(dev, fonts); + if (ret) + return ret; + + if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { + ret = console_alloc_cursor(dev); + if (ret) + return ret; + } + + return 0; } const char *console_simple_get_font_size(struct udevice *dev, uint *sizep) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index e215a3e0e54..fc2985ed92f 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1111,6 +1111,10 @@ static int console_truetype_probe(struct udevice *dev) debug("%s: ready\n", __func__); + ret = console_alloc_cursor(dev); + if (ret) + return ret; + return 0; } diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index c008b9cf7d3..4cb6ba4e15f 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -123,6 +123,16 @@ int fill_char_horizontally(uchar *pfont, void **line, struct video_priv *vid_pri int cursor_show(struct vidconsole_cursor *curs, struct video_priv *vid_priv, bool direction); +/** + * console_alloc_cursor() - Allocate cursor save buffer + * + * Allocates memory for saving pixels under the cursor + * + * @dev: vidconsole device + * Return: 0 if success, -ENOMEM if allocation fails + */ +int console_alloc_cursor(struct udevice *dev); + /** * console probe function. * diff --git a/include/video_console.h b/include/video_console.h index b40253b218d..ffe331c5803 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -32,6 +32,8 @@ enum { * @enabled: cursor is active (e.g. during readline) * @visible: cursor is currently visible * @indent: indent subsequent lines to the same position as the first line + * @saved: true if save_data contains valid data + * @save_data: saved pixels under cursor * @x: cursor left X position in pixels * @y: cursor top Y position in pixels * @height: height of cursor in pixels @@ -41,6 +43,8 @@ struct vidconsole_cursor { bool enabled; bool visible; bool indent; + bool saved; + u32 *save_data; /* filled in by get_cursor_info(): */ uint x;