Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 921B7C433EF for ; Mon, 10 Jan 2022 00:57:45 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 55C9081DCA; Mon, 10 Jan 2022 01:57:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 331F1811DF; Mon, 10 Jan 2022 01:57:17 +0100 (CET) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id DFBCE80F78 for ; Mon, 10 Jan 2022 01:57:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 258F1113E; Sun, 9 Jan 2022 16:57:13 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C95CF3F774; Sun, 9 Jan 2022 16:57:11 -0800 (PST) From: Andre Przywara To: Anatolij Gustschin Cc: Simon Glass , Tom Rini , Heinrich Schuchardt , Alexander Graf , Mark Kettenis , u-boot@lists.denx.de Subject: [PATCH 2/8] video: vidconsole: Support wider bitmap fonts Date: Mon, 10 Jan 2022 00:56:32 +0000 Message-Id: <20220110005638.21599-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20220110005638.21599-1-andre.przywara@arm.com> References: <20220110005638.21599-1-andre.przywara@arm.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Currently the DM_VIDEO console only supports bitmap fonts with up to 8 pixels wide glyphs. Add support for fonts with glyphs up to 32 pixels wide, as those might prove useful on high resolution screens. This is done by expanding the glyph bits buffer to 32bits, and aligning the font data to the high bits, counting down from there. The compiler should optimise away any unneeded accesses for narrower fonts. Signed-off-by: Andre Przywara --- drivers/video/console_normal.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index bfd3aab8d24..9f552d02b30 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -13,6 +13,9 @@ #include #include /* Get font data, width and height */ +#define VIDEO_FONT_STRIDE ((VIDEO_FONT_WIDTH + 7) / 8) +#define VIDEO_FONT_GLYPH_BYTES (VIDEO_FONT_STRIDE * VIDEO_FONT_HEIGHT) + static int console_normal_set_row(struct udevice *dev, uint row, int clr) { struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); @@ -98,8 +101,20 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, return -EAGAIN; for (row = 0; row < VIDEO_FONT_HEIGHT; row++) { - unsigned int idx = (u8)ch * VIDEO_FONT_HEIGHT + row; - uchar bits = video_fontdata[idx]; + uint32_t bits = video_fontdata[(u8)ch * VIDEO_FONT_GLYPH_BYTES + + row * VIDEO_FONT_STRIDE] << 24; + + if (VIDEO_FONT_WIDTH > 8) + bits |= video_fontdata[ch * VIDEO_FONT_GLYPH_BYTES + + row * VIDEO_FONT_STRIDE + 1] << 16; + + if (VIDEO_FONT_WIDTH > 16) + bits |= video_fontdata[ch * VIDEO_FONT_GLYPH_BYTES + + row * VIDEO_FONT_STRIDE + 2] << 8; + + if (VIDEO_FONT_WIDTH > 24) + bits |= video_fontdata[ch * VIDEO_FONT_GLYPH_BYTES + + row * VIDEO_FONT_STRIDE + 3]; switch (vid_priv->bpix) { case VIDEO_BPP8: @@ -107,7 +122,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, uint8_t *dst = line; for (i = 0; i < VIDEO_FONT_WIDTH; i++) { - *dst++ = (bits & 0x80) ? + *dst++ = (bits & BIT(31)) ? vid_priv->colour_fg : vid_priv->colour_bg; bits <<= 1; @@ -119,7 +134,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, uint16_t *dst = line; for (i = 0; i < VIDEO_FONT_WIDTH; i++) { - *dst++ = (bits & 0x80) ? + *dst++ = (bits & BIT(31)) ? vid_priv->colour_fg : vid_priv->colour_bg; bits <<= 1; @@ -131,7 +146,7 @@ static int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, uint32_t *dst = line; for (i = 0; i < VIDEO_FONT_WIDTH; i++) { - *dst++ = (bits & 0x80) ? + *dst++ = (bits & BIT(31)) ? vid_priv->colour_fg : vid_priv->colour_bg; bits <<= 1; -- 2.17.6