From patchwork Fri Oct 3 16:55:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 490 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=1759510589; bh=MO1Ijw8DkZ4fbKkYJ5LL9pNR1NGwyLeo4RWQmiQacvk=; 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=R4HT+YxFQFMjiiXjQtH1OKCgt5Y51Y4NLQerto3ccUTME2/AoSQG/YRVo91lg/vpL kIaGl1uETalS3xP8EAT9EkRVJUyFcbDIyTW6SbVQWJ1LhEfcn2KgYtoK5i3byRbcWC PYIdLP6UlDJftjN2NHUUwSr8EOVbR+F3JBkifdsLXLKThKAl/o8LOpfZcji9Sj4Rve 5jKCO/awBa1MHZMS/fNBcXzGI/S1H+lOY+YmFBm70aE05TRnhV5EB+/amgb+/w/qpI V/e+VwRKK6b6foadPqfBpChvXhLjTDvmu8MDN8b6jJIWVCvXmfuIAVLD2B67kj3IwX Id86+/JNbz4yA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9D0B567ECA for ; Fri, 3 Oct 2025 10:56:29 -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 LEHf3-tLlQ1Z for ; Fri, 3 Oct 2025 10:56:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510587; bh=MO1Ijw8DkZ4fbKkYJ5LL9pNR1NGwyLeo4RWQmiQacvk=; 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=eSx3ZqHr96FeN6i+96SbUWYUdcg6wuvbCEAIPFEhj4mDJqTlc43raLVMHXT/dTDw1 0ZmuQHwIOlbHuEPQMOvujBiyP0APRWKgCdDPrnq0fG+F8FIrJxEXUKgQhFKVazlL6J HVy6MzznoSzKlALaBKJVyHtShTV0CXQ7HZ8KYrxauFPIGvwJBtcj5T58cSTE4ahZPN sbA27Vew2rEprfnRLhw/s7eQZMUVi80uvg8om0tTDp//JDIvCXoCGG3vx8gWIavhDm stjqdjaiK4ZHOhgQLVLTwJDZhtx0f+/Mpz6lLFDORjir5g6FoWxGLnf9IZl0b80Mn5 pi4sXQlwpRBxQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DE90E67EBD for ; Fri, 3 Oct 2025 10:56:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510584; bh=MZ5hJPx9pKqFg7uT2y0+9vXvBpvehAJ6twmO3gaXc5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HPStRUtEsoKW6XeIMKlZqkKs33hxYTpa2i8pKkwBzIRowIxWMBnNuKWOSe2VhtqkT 5bam6gjvyB8JeuIU/6uo4tRVyg+NpIeaseFdHP5Br28hCD8PbLkoyvQFVByq6go1Sn P5QepUO+fiBnXvPWSqFJ22bpILqBiSd1PtZSs83DmGaF9iebT2ATTWszlTJaKEmpZ7 AueCCkj4ZYAxekM0z+6rIQD2fhTETlEccMgMOMdBCsShBtnpSDcsV1+I6ASR7P0O/B ohCp1SI3IyNaS42xyoNw7oRT3nSaHovJYxDUXsO1KHdxX39krz0s3WsXL8g8O+udx0 /WxP25o6E7ZZw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E756067E82; Fri, 3 Oct 2025 10:56: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 10026) with ESMTP id qz4TBfmPJ4Gr; Fri, 3 Oct 2025 10:56:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759510582; bh=ziOrz40g0tu3JXCwy9iGNPcXvpHMLxCCJSRt5ubdXZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YlsIEttR4phehF46jSq4gYL+K9iPj4G0oaY+vpE2utWfjXlm2HSOWlQvhOwUqqRiU tx+xuPAxNoNO47CnZ9kVW1scJxOG6xnmkVpVnQUUxufb6xUh3V+9W5yIUSMztFs8c6 v7Z6xtMsEbeKg6i+wMVnP/sJgQX+x8Pc0AMxDirPWQGf4fWIrOa9Ercd0OJ5iEMjoM gI5ufYlQuw8RpkOV653fNXMoG8NPzHx5Pm912H67BQhLtqJPUcwKBwdG+LzYJYa38N a4lmGkdwHErPGp9u2kXjZTiRfAx1d3yaTbfE/FlI4eB8pw9zxfU6VcHVoxL54wcJlP ePUoEm5vyePNg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 19DD067EC7; Fri, 3 Oct 2025 10:56:22 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 3 Oct 2025 10:55:02 -0600 Message-ID: <20251003165525.440173-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251003165525.440173-1-sjg@u-boot.org> References: <20251003165525.440173-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: FDX43HLJ7LMXDSX6OXUDSU5MQ6ZUNGME X-Message-ID-Hash: FDX43HLJ7LMXDSX6OXUDSU5MQ6ZUNGME 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 09/22] video: Support transparency in the inner bmp functions 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 Provide an alpha and acol parameter to control whether transparency is used. For now alpha is always false so this does nothing. Make the current video_bmp_display() an internal static function and add a new video_bmp_display() to call it. Signed-off-by: Simon Glass --- drivers/video/video_bmp.c | 43 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index 390996dbaf1..4c9157486cb 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -64,9 +64,12 @@ static u32 get_bmp_col_rgba8888(struct bmp_color_table_entry *cte) * @bmap: Pointer to BMP bitmap position to write. This contains a single byte * which is either written directly (bpix == 8) or used to look up the * palette to get a colour to write + * @alpha: Enable alpha transparency + * @acol: Alpha color (RGB888 format) */ static void write_pix8(u8 *fb, uint bpix, enum video_format eformat, - struct bmp_color_table_entry *palette, u8 *bmap) + struct bmp_color_table_entry *palette, u8 *bmap, + bool alpha, u32 acol) { struct bmp_color_table_entry *cte = &palette[*bmap]; @@ -96,12 +99,12 @@ static void write_pix8(u8 *fb, uint bpix, enum video_format eformat, static void draw_unencoded_bitmap(u8 **fbp, uint bpix, enum video_format eformat, uchar *bmap, struct bmp_color_table_entry *palette, - int cnt) + int cnt, bool alpha, u32 acolour) { u8 *fb = *fbp; while (cnt > 0) { - write_pix8(fb, bpix, eformat, palette, bmap++); + write_pix8(fb, bpix, eformat, palette, bmap++, alpha, acolour); fb += bpix / 8; cnt--; } @@ -110,12 +113,12 @@ static void draw_unencoded_bitmap(u8 **fbp, uint bpix, static void draw_encoded_bitmap(u8 **fbp, uint bpix, enum video_format eformat, struct bmp_color_table_entry *palette, u8 *bmap, - int cnt) + int cnt, bool alpha, u32 acolour) { u8 *fb = *fbp; while (cnt > 0) { - write_pix8(fb, bpix, eformat, palette, bmap); + write_pix8(fb, bpix, eformat, palette, bmap, alpha, acolour); fb += bpix / 8; cnt--; } @@ -126,7 +129,8 @@ static void video_display_rle8_bitmap(struct udevice *dev, struct bmp_image *bmp, uint bpix, struct bmp_color_table_entry *palette, uchar *fb, int x_off, int y_off, - ulong width, ulong height) + ulong width, ulong height, bool alpha, + u32 acolour) { struct video_priv *priv = dev_get_uclass_priv(dev); uchar *bmap; @@ -178,7 +182,8 @@ static void video_display_rle8_bitmap(struct udevice *dev, cnt = runlen; draw_unencoded_bitmap( &fb, bpix, eformat, - bmap, palette, cnt); + bmap, palette, cnt, + alpha, acolour); } x += runlen; } @@ -204,7 +209,8 @@ static void video_display_rle8_bitmap(struct udevice *dev, cnt = runlen; draw_encoded_bitmap(&fb, bpix, eformat, palette, &bmap[1], - cnt); + cnt, alpha, + acolour); } x += runlen; } @@ -252,8 +258,8 @@ void video_bmp_get_info(const void *bmp_image, ulong *widthp, ulong *heightp, *bpixp = get_unaligned_le16(&bmp->header.bit_count); } -int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, - bool align) +static int draw_bmp(struct udevice *dev, ulong bmp_image, int x, int y, + bool align, bool alpha, u32 acolour) { struct video_priv *priv = dev_get_uclass_priv(dev); int i, j; @@ -337,8 +343,10 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, &bmp->header.compression); debug("compressed %d %d\n", compression, BMP_BI_RLE8); if (compression == BMP_BI_RLE8) { - video_display_rle8_bitmap(dev, bmp, bpix, palette, fb, - x, y, width, height); + video_display_rle8_bitmap(dev, bmp, bpix, + palette, fb, x, y, + width, height, alpha, + acolour); break; } } @@ -351,9 +359,10 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, for (i = 0; i < height; ++i) { schedule(); for (j = 0; j < width; j++) { - write_pix8(fb, bpix, eformat, palette, bmap); - bmap++; + write_pix8(fb, bpix, eformat, palette, bmap, + alpha, acolour); fb += bpix / 8; + bmap++; } bmap += (padded_width - width); fb -= byte_width + priv->line_length; @@ -462,3 +471,9 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, return video_sync(dev, false); } + +int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y, + bool align) +{ + return draw_bmp(dev, bmp_image, x, y, align, false, 0); +}