From patchwork Sat Jan 17 00:56:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1545 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=1768611451; bh=s6NaAmw4OF/4vyu+TCD1Y2hGnqUqA9+IPtGRAVfz5jc=; 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=fu4r0Ev/cUuw+AGl+MTU7QoJdbNd7gJgydUlUC5Ia/o96iiRA60w2LsUQb46fBp2G KgqZEOIGYaVmTuUyMCrroAiXgeRuvSYvdorTkB/D2bZp/cUy4eGakaCxnCUGRNzlmS 4wOUSZkJyrpc8e8+LjsCcHgCtTkqwTwTkPRHdr+YL24SJDi2qql/2vQNTmnuAihSo8 Lwyl8O2HcMOni7jjrouHKjYxjs5nyhmGZyY8yLF0uwfgM0MGYGFZCgUW1zbknmmSA4 BnpE402qfwjo9VfZzQM1X4TH7d6dWaRaSZ3yDfTLYLUT3/AEbfo1eLecjAdQMDICNr zpeVSUjEwNwsw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B2730693E7 for ; Fri, 16 Jan 2026 17:57:31 -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 0OT-lXGPEtdz for ; Fri, 16 Jan 2026 17:57:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611451; bh=s6NaAmw4OF/4vyu+TCD1Y2hGnqUqA9+IPtGRAVfz5jc=; 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=fu4r0Ev/cUuw+AGl+MTU7QoJdbNd7gJgydUlUC5Ia/o96iiRA60w2LsUQb46fBp2G KgqZEOIGYaVmTuUyMCrroAiXgeRuvSYvdorTkB/D2bZp/cUy4eGakaCxnCUGRNzlmS 4wOUSZkJyrpc8e8+LjsCcHgCtTkqwTwTkPRHdr+YL24SJDi2qql/2vQNTmnuAihSo8 Lwyl8O2HcMOni7jjrouHKjYxjs5nyhmGZyY8yLF0uwfgM0MGYGFZCgUW1zbknmmSA4 BnpE402qfwjo9VfZzQM1X4TH7d6dWaRaSZ3yDfTLYLUT3/AEbfo1eLecjAdQMDICNr zpeVSUjEwNwsw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0D57693E0 for ; Fri, 16 Jan 2026 17:57:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611450; bh=/YcrEjqX33D9j1YfSgLv5m5OoQwBVK5XcGVBIOS6rsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oC9UagIq9CgPhZM06w9SYim+CMqDjG+fHWc+PDQryoZMNGhTXWrOE7oAjfpDn+KE4 Ro4aQEwLwBF6gTD31bLwWpPCFC4sNW/o4G4H6/IxNMAQInMfpsF4xchbQPwC6AHp6M ZYXEDuRWU7lQQEqvA23OUrepEqNf/8c1qQusXu0RJY4JhlxDPPU6pc1CwxAwI9E3c2 n2nsoxgErvFlW07ajyBRh2SJILXegWhOMlRujd4sIq9bjVgwwlGWuGOtc3Tqd0+Shu Xkx9ix+q6Cdi4oqWu865brF3snKs8KGdhIR0/BD2idbInWFnsVs2o/EJXkF+tQ+qF3 kqryuASeFVDyA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A542C693E0; Fri, 16 Jan 2026 17:57:30 -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 Z1_IJF83H3di; Fri, 16 Jan 2026 17:57:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611445; bh=FGALoFXkQ6oFNyzohPF7pfVHCo/NReoabvrorsCCxFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXnTvjDc2XfyKZ2UvXb2rqYYi29869o1w/IUXaDdAQGymuoDiLSyvATDEWcwUjfjS C+Dy65cqLdskgcly4unATn5tSJt0t2ewVqOPNk465ZHM1uwi0RtnKo8Ew+6iSxxj9f 0rQhXQPj0TVLIsKHe/ytscFDorqD2YDAO/donhSxNriEra1NKNuq2ub6ABC2QVfCxd UvS0pK5rRDrEm6VP2Uv/fk7U4ebUmzLdJ3jDY68EAhryaaJ84+6DiLk/9Vc9Hxl+GV UOh9QH1vmMtew7SdhHLYNQnTn4CjLXtCw2eiQWacnC1B53eL6MJsNTANBk+z4XhXDu Y0bO7/wmoOKEA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A2DD3693D7; Fri, 16 Jan 2026 17:57:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 17:56:41 -0700 Message-ID: <20260117005702.1684841-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260117005702.1684841-1-sjg@u-boot.org> References: <20260117005702.1684841-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NV6HMKQC76AYUPZF67X2P4UYQUDASD42 X-Message-ID-Hash: NV6HMKQC76AYUPZF67X2P4UYQUDASD42 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/18] video: Move xstart_frac into vidconsole_ctx 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 The left margin should be per-context so that different clients can maintain their own margin settings. Move the xstart_frac field from vidconsole_priv into vidconsole_ctx. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 2 +- drivers/video/vidconsole-uclass.c | 14 +++++++------- include/video_console.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 978e81a9350..36a2c33eb70 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -944,7 +944,7 @@ static void select_metrics(struct udevice *dev, struct console_tt_metrics *met) priv->cur_met = met; com->x_charsize = met->font_size; com->y_charsize = met->font_size; - vc_priv->xstart_frac = VID_TO_POS(2); + com->xstart_frac = VID_TO_POS(2); com->cols = vid_priv->xsize / met->font_size; com->rows = vid_priv->ysize / met->font_size; vc_priv->tab_width_frac = VID_TO_POS(met->font_size) * 8 / 2; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 71bcb0d9c91..bc2b3943fc8 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -77,7 +77,7 @@ static int vidconsole_back(struct udevice *dev) vidconsole_hide_cursor(dev); ctx->xcur_frac -= VID_TO_POS(ctx->x_charsize); - if (ctx->xcur_frac < priv->xstart_frac) { + if (ctx->xcur_frac < ctx->xstart_frac) { ctx->xcur_frac = (ctx->cols - 1) * VID_TO_POS(ctx->x_charsize); ctx->ycur -= ctx->y_charsize; @@ -100,7 +100,7 @@ static void vidconsole_newline(struct udevice *dev) const int rows = CONFIG_VAL(CONSOLE_SCROLL_LINES); int i, ret; - ctx->xcur_frac = priv->xstart_frac; + ctx->xcur_frac = ctx->xstart_frac; ctx->ycur += ctx->y_charsize; /* Check if we need to scroll the terminal */ @@ -139,7 +139,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y) vidconsole_hide_cursor(dev); ctx->xcur_frac = VID_TO_POS(x); - priv->xstart_frac = ctx->xcur_frac; + ctx->xstart_frac = ctx->xcur_frac; ctx->ycur = y; /* make sure not to kern against the previous character */ @@ -182,7 +182,7 @@ static void get_cursor_position(struct vidconsole_priv *priv, struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); *row = ctx->ycur / ctx->y_charsize; - *col = VID_TO_PIXEL(ctx->xcur_frac - priv->xstart_frac) / + *col = VID_TO_PIXEL(ctx->xcur_frac - ctx->xstart_frac) / ctx->x_charsize; } @@ -333,7 +333,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) #endif } ctx->ycur = 0; - ctx->xcur_frac = priv->xstart_frac; + ctx->xcur_frac = ctx->xstart_frac; } else { debug("unsupported clear mode: %d\n", mode); } @@ -507,7 +507,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) /* beep */ break; case '\r': - ctx->xcur_frac = priv->xstart_frac; + ctx->xcur_frac = ctx->xstart_frac; break; case '\n': vidconsole_newline(dev); @@ -984,7 +984,7 @@ void vidconsole_set_bitmap_font(struct udevice *dev, ctx->rows = vid_priv->ysize / fontdata->height; /* xsize_frac is set in vidconsole_pre_probe() */ } - vc_priv->xstart_frac = 0; + ctx->xstart_frac = 0; } void vidconsole_idle(struct udevice *dev) diff --git a/include/video_console.h b/include/video_console.h index 5b90a5cf160..cedc94a83cf 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -113,6 +113,7 @@ struct vidconsole_ansi { * @ansi: ANSI escape-sequence state * @utf8_buf: Buffer to accumulate UTF-8 byte sequence * @curs: Cursor state and management + * @xstart_frac: Left margin for the text console in fractional units */ struct vidconsole_ctx { int rows; @@ -128,13 +129,14 @@ struct vidconsole_ctx { struct vidconsole_ansi ansi; char utf8_buf[5]; struct vidconsole_cursor curs; + int xstart_frac; }; /** * struct vidconsole_priv - uclass-private data about a console device * * Drivers must set up @ctx.rows, @ctx.cols, @ctx.x_charsize, @ctx.y_charsize - * in their probe() method. Drivers may set up @xstart_frac if desired. + * in their probe() method. Drivers may set up @ctx.xstart_frac if desired. * * Note that these values relate to the rotated console, so that an 80x25 * console which is rotated 90 degrees will have rows=80 and cols=25 @@ -148,7 +150,6 @@ struct vidconsole_ctx { * @ctx: Per-client context * @tab_width_frac: Tab width in fractional units * @xsize_frac: Width of the display in fractional units - * @xstart_frac: Left margin for the text console in fractional units * @quiet: Suppress all output from stdio */ struct vidconsole_priv { @@ -156,7 +157,6 @@ struct vidconsole_priv { struct vidconsole_ctx ctx; int tab_width_frac; int xsize_frac; - int xstart_frac; bool quiet; };