diff mbox series

[v2] video: bmp: support 8bits BMP drawing on 24/32 bpp framebuffer

Message ID 20200627225944.13269-1-agust@denx.de
State Accepted
Commit bab68b2d889e7d3783c4f31b67025b086b7278c3
Headers show
Series [v2] video: bmp: support 8bits BMP drawing on 24/32 bpp framebuffer | expand

Commit Message

Anatolij Gustschin June 27, 2020, 10:59 p.m. UTC
From: Ye Li <ye.li at nxp.com>

Update video bmp code so that we can display 8 bits logo on
24 or 32 bpp framebuffer.

Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Anatolij Gustschin <agust at denx.de>
Reviewed-by: Jagan Teki <jagan at amarulasolutions.com>
Tested-by: Jagan Teki <jagan at amarulasolutions.com> # bpi-m1+, bpi-m64
---
Changes in v2:
 - reduce code
 - update commit message

 drivers/video/video_bmp.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

Comments

Anatolij Gustschin June 29, 2020, 7:04 a.m. UTC | #1
On Sun, 28 Jun 2020 00:59:44 +0200
Anatolij Gustschin agust at denx.de wrote:
...
> Changes in v2:
>  - reduce code
>  - update commit message
> 
>  drivers/video/video_bmp.c | 27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)

Applied to u-boot-video/master, thanks!

--
Anatolij
diff mbox series

Patch

diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index eb9636541d..7d7f37b445 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -233,6 +233,8 @@  int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
 	 */
 	if (bpix != bmp_bpix &&
 	    !(bmp_bpix == 8 && bpix == 16) &&
+	    !(bmp_bpix == 8 && bpix == 24) &&
+	    !(bmp_bpix == 8 && bpix == 32) &&
 	    !(bmp_bpix == 24 && bpix == 16) &&
 	    !(bmp_bpix == 24 && bpix == 32)) {
 		printf("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
@@ -265,6 +267,7 @@  int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
 	switch (bmp_bpix) {
 	case 1:
 	case 8: {
+		struct bmp_color_table_entry *cte;
 		cmap_base = priv->cmap;
 #ifdef CONFIG_VIDEO_BMP_RLE8
 		u32 compression = get_unaligned_le32(&bmp->header.compression);
@@ -280,21 +283,33 @@  int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
 			break;
 		}
 #endif
-
-		if (bpix != 16)
+		byte_width = width * (bpix / 8);
+		if (!byte_width)
 			byte_width = width;
-		else
-			byte_width = width * 2;
 
 		for (i = 0; i < height; ++i) {
 			WATCHDOG_RESET();
 			for (j = 0; j < width; j++) {
-				if (bpix != 16) {
+				if (bpix == 8) {
 					fb_put_byte(&fb, &bmap);
-				} else {
+				} else if (bpix == 16) {
 					*(uint16_t *)fb = cmap_base[*bmap];
 					bmap++;
 					fb += sizeof(uint16_t) / sizeof(*fb);
+				} else {
+					/* Only support big endian */
+					cte = &palette[*bmap];
+					bmap++;
+					if (bpix == 24) {
+						*(fb++) = cte->red;
+						*(fb++) = cte->green;
+						*(fb++) = cte->blue;
+					} else {
+						*(fb++) = cte->blue;
+						*(fb++) = cte->green;
+						*(fb++) = cte->red;
+						*(fb++) = 0;
+					}
 				}
 			}
 			bmap += (padded_width - width);