From patchwork Fri Sep 19 20:14:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 356 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=1758312974; bh=XhthwO5S9iOujYeWYlTpZ0R8XLtdpQh9vs4nK96IwZk=; 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=FR1KdnITEN4gsbeFBKo5F15nHDTUrmPjoCa/YmKWvDZH4I0PvzR5yJkD8tDD90yme 8kEXA9N9RQg15paiDTyoof/KfVfoPt3Jzjs8zIhn9tmNquyTHVWPOdtl8zNVwQL4W5 w6nTInxUZVpJfrWKGI1NxU0JXggqSiAOBV9xtYDk7jYl6G1OQAu4v3cwoIffFzgvX2 cq0Mzue1SZAc5c49fGPT1oq3QfPuK85Rfx/QBoCuM5b7kSjtDpWhNaURnczJADvgeR /xQ0T25/ABnIpIExz/5Zyy7A5HbtJKGan9Qe2unyA8wLO+WqI6egDiKTnisXOeJd5d x1U9NMDfJcQRA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 800AF67C6C for ; Fri, 19 Sep 2025 14:16:14 -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 q28uhLOgdG6T for ; Fri, 19 Sep 2025 14:16:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312974; bh=XhthwO5S9iOujYeWYlTpZ0R8XLtdpQh9vs4nK96IwZk=; 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=FR1KdnITEN4gsbeFBKo5F15nHDTUrmPjoCa/YmKWvDZH4I0PvzR5yJkD8tDD90yme 8kEXA9N9RQg15paiDTyoof/KfVfoPt3Jzjs8zIhn9tmNquyTHVWPOdtl8zNVwQL4W5 w6nTInxUZVpJfrWKGI1NxU0JXggqSiAOBV9xtYDk7jYl6G1OQAu4v3cwoIffFzgvX2 cq0Mzue1SZAc5c49fGPT1oq3QfPuK85Rfx/QBoCuM5b7kSjtDpWhNaURnczJADvgeR /xQ0T25/ABnIpIExz/5Zyy7A5HbtJKGan9Qe2unyA8wLO+WqI6egDiKTnisXOeJd5d x1U9NMDfJcQRA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6FD0D67C5A for ; Fri, 19 Sep 2025 14:16:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312972; bh=Mg/QJUlhMkuXrMo1tgJuK4/HA5uYc0NKiTPUuXz0ESU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPAgD4W3cFVsOAwyUzMRRwYA8xTDRvO+A+QSgyN1+1nVYorMeEcc9TzHyxgo4Tu/U HnFwbkfqbnUcF5jPWhNQvO3IVxQ6W1Kb0IjnTce2yEKjdnqltBQsGT1fkJYfjAckqC ng2q1pvKVd0LRVdBDhec4z+qBCGMvDXvXFg/8/O1l4MzKcsZPF5jmQL6izlMQxZ3pS tftoOZRCZgHcp5mRfSEJ7qFGyx7Nvt1zJbYFmKCw3uopU5K5bnVAglxNORvRmfBUKN zhEGnR8GHQ5+Q1ABhf4f3xevqEOqnHY4pkw8C365W73PKIItEe3s6nxDGRvibpqMNN YVmeUvkqxogmw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2E4A267B3B; Fri, 19 Sep 2025 14:16:12 -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 hW3x08uOcD4c; Fri, 19 Sep 2025 14:16:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1758312968; bh=ou+6j8srHawFFHNvqZMgduxOHa4X5R4L8iV5ye9gnPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iijX82+vpHnuV+AuRm5lRXuLkl7Ap+hwvA4BOwMVz+On/lo4cHwhCcWYuqAdcdkDg EQdMa0DZ4lOlnbgGgbhQ0GwS+e1VZDESGfPFMnr3eMEwafymYmS8VSGYjmGtIvboRj nWP/ujlc+9f5IFowysbSGz+mTn6c69cUePjMLPQ7e5JY3p3Q3WJ7GXJn3EHt2DJs8+ lXtCXiHQJbvg07czpevnWN3+3/cnNjuxm3qWdfyY9U8SagKWYUwIhBFxjbWtsgwDPQ 9qVBd4im1vM66yq1msh8zsBqOkYnxnTHbLYHzNNpfRdtkre4DWSbMjjcS6otBabtMA InkLXWwPlymnw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BE2DD67C5B; Fri, 19 Sep 2025 14:16:07 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 19 Sep 2025 14:14:21 -0600 Message-ID: <20250919201507.4024144-15-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: X66LSSKBOWGNGDRU5GN6WYDV4UG3BYSS X-Message-ID-Hash: X66LSSKBOWGNGDRU5GN6WYDV4UG3BYSS 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 14/42] video: truetype: Use common cursor-drawing code 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 Update truetype_set_cursor_visible() to use the existing shared draw_cursor_vertically() function instead of duplicating cursor-drawing itself. This corrects a problem where met is accessed for fixed-width fonts, for which it doesn't exist. Co-developed-by: Claude Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 82 +++++--------------------------- 1 file changed, 11 insertions(+), 71 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 43274bb8f66..fb7f70a4b2a 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1000,10 +1000,8 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible, struct udevice *vid = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid); struct console_tt_priv *priv = dev_get_priv(dev); - struct console_tt_metrics *met = priv->cur_met; - uint row, width, height, xoff; - void *start, *line; - uint out, val; + void *line; + uint height; if (xpl_phase() <= PHASE_SPL) return -ENOSYS; @@ -1022,79 +1020,21 @@ static int truetype_set_cursor_visible(struct udevice *dev, bool visible, x = VID_TO_PIXEL(vc_priv->xcur_frac); y = vc_priv->ycur; - height = met->font_size; - xoff = 0; - val = vid_priv->colour_bg ? 0 : 255; - width = VIDCONSOLE_CURSOR_WIDTH; + /* Get font height from current font type */ + if (priv->cur_fontdata) + height = priv->cur_fontdata->height; + else + height = priv->cur_met->font_size; /* Figure out where to write the cursor in the frame buffer */ - start = vid_priv->fb + y * vid_priv->line_length + + line = vid_priv->fb + y * vid_priv->line_length + x * VNBYTES(vid_priv->bpix); - line = start; - - /* draw a vertical bar in the correct position */ - for (row = 0; row < height; row++) { - switch (vid_priv->bpix) { - case VIDEO_BPP8: - if (IS_ENABLED(CONFIG_VIDEO_BPP8)) { - u8 *dst = line + xoff; - int i; - - out = val; - for (i = 0; i < width; i++) { - if (vid_priv->colour_fg) - *dst++ |= out; - else - *dst++ &= out; - } - } - break; - case VIDEO_BPP16: { - u16 *dst = (u16 *)line + xoff; - int i; - if (IS_ENABLED(CONFIG_VIDEO_BPP16)) { - for (i = 0; i < width; i++) { - out = val >> 3 | - (val >> 2) << 5 | - (val >> 3) << 11; - if (vid_priv->colour_fg) - *dst++ |= out; - else - *dst++ &= out; - } - } - break; - } - case VIDEO_BPP32: { - u32 *dst = (u32 *)line + xoff; - int i; - - if (IS_ENABLED(CONFIG_VIDEO_BPP32)) { - for (i = 0; i < width; i++) { - int out; - - if (vid_priv->format == VIDEO_X2R10G10B10) - out = val << 2 | val << 12 | val << 22; - else - out = val | val << 8 | val << 16; - if (vid_priv->colour_fg) - *dst++ |= out; - else - *dst++ &= out; - } - } - break; - } - default: - return -ENOSYS; - } - - line += vid_priv->line_length; - } + /* Use the shared cursor drawing function */ + draw_cursor_vertically(&line, vid_priv, height, NORMAL_DIRECTION); - video_damage(dev->parent, x, y, width, height); + video_damage(dev->parent, x, y, VIDCONSOLE_CURSOR_WIDTH, height); return video_sync(vid, true); }