public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ye Li <ye.li@nxp.com>
To: u-boot@lists.denx.de
Subject: [PATCH] video: bmp: Support 8bits BMP to 24/32 bits display
Date: Wed, 10 Jun 2020 02:52:23 -0700	[thread overview]
Message-ID: <1591782743-22846-3-git-send-email-ye.li@nxp.com> (raw)
In-Reply-To: <1591782743-22846-1-git-send-email-ye.li@nxp.com>

Update video bmp codes to support 8 bits BMP to 32 bits conversion
so that we can display 8 bits logo on 24 bits or 32 bits display

Signed-off-by: Ye Li <ye.li@nxp.com>
---
 drivers/video/video_bmp.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index eb96365..283e699 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);
@@ -281,20 +284,39 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
 		}
 #endif
 
-		if (bpix != 16)
+		if (bpix == 8)
 			byte_width = width;
-		else
+		else if (bpix == 16)
 			byte_width = width * 2;
+		else if (bpix == 24)
+			byte_width = width * 3;
+		else /* 32 */
+			byte_width = width * 4;
 
 		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 if (bpix == 24) {
+					/* Only support big endian */
+					cte = &palette[*bmap];
+					bmap++;
+					*(fb++) = cte->red;
+					*(fb++) = cte->green;
+					*(fb++) = cte->blue;
+				} else if (bpix == 32) {
+					/* Only support big endian */
+					cte = &palette[*bmap];
+					bmap++;
+					*(fb++) = cte->blue;
+					*(fb++) = cte->green;
+					*(fb++) = cte->red;
+					*(fb++) = 0;
 				}
 			}
 			bmap += (padded_width - width);
-- 
2.7.4

  parent reply	other threads:[~2020-06-10  9:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-10  9:52 [PATCH] video: vidconsole: avoid multiple lines overwrite logo Ye Li
2020-06-10  9:52 ` [PATCH] splash: Fix build warning on 64 bits CPU Ye Li
2020-06-17  7:09   ` Jagan Teki
2020-06-29  7:05   ` Anatolij Gustschin
2020-06-10  9:52 ` Ye Li [this message]
2020-06-17  7:10   ` [PATCH] video: bmp: Support 8bits BMP to 24/32 bits display Jagan Teki
2020-06-18 21:04   ` Fabio Estevam
2020-06-23 11:51     ` Anatolij Gustschin
2020-06-27 22:59   ` [PATCH v2] video: bmp: support 8bits BMP drawing on 24/32 bpp framebuffer Anatolij Gustschin
2020-06-29  7:04     ` Anatolij Gustschin
2020-06-17  7:11 ` [PATCH] video: vidconsole: avoid multiple lines overwrite logo Jagan Teki
2020-06-29  7:04 ` Anatolij Gustschin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1591782743-22846-3-git-send-email-ye.li@nxp.com \
    --to=ye.li@nxp.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox