public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] video: bmp: Add support for 24bpp BMP files on 16bpp displays
Date: Tue, 29 Jan 2019 11:44:44 +0100	[thread overview]
Message-ID: <20190129104445.10865-2-sr@denx.de> (raw)
In-Reply-To: <20190129104445.10865-1-sr@denx.de>

This patch adds support to load 24bpp BMP files on 16bpp displays. This
will be used by the theadorable board. The "old" bmp command did support
this operartion mode and to not break compatibility with the move to
DM_VIDEO, we need to add this support to the "new" bmp code.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Anatolij Gustschin <agust@denx.de>
---
 drivers/video/video_bmp.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index 2898b0b55d..193f37d275 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -229,11 +229,12 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
 	}
 
 	/*
-	 * We support displaying 8bpp BMPs on 16bpp LCDs
+	 * We support displaying 8bpp and 24bpp BMPs on 16bpp LCDs
 	 * and displaying 24bpp BMPs on 32bpp LCDs
-	 * */
+	 */
 	if (bpix != bmp_bpix &&
 	    !(bmp_bpix == 8 && bpix == 16) &&
+	    !(bmp_bpix == 24 && bpix == 16) &&
 	    !(bmp_bpix == 24 && bpix == 32)) {
 		printf("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
 		       bpix, get_unaligned_le16(&bmp->header.bit_count));
@@ -318,12 +319,22 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
 	case 24:
 		for (i = 0; i < height; ++i) {
 			for (j = 0; j < width; j++) {
-				*(fb++) = *(bmap++);
-				*(fb++) = *(bmap++);
-				*(fb++) = *(bmap++);
-				*(fb++) = 0;
+				if (bpix == 16) {
+					/* 16bit 555RGB format */
+					*(u16 *)fb = ((bmap[2] >> 3) << 10) |
+						((bmap[1] >> 3) << 5) |
+						(bmap[0] >> 3);
+					bmap += 3;
+					fb += 2;
+				} else {
+					*(fb++) = *(bmap++);
+					*(fb++) = *(bmap++);
+					*(fb++) = *(bmap++);
+					*(fb++) = 0;
+				}
 			}
 			fb -= priv->line_length + width * (bpix / 8);
+			bmap += (padded_width - width) * 3;
 		}
 		break;
 #endif /* CONFIG_BMP_24BPP */
-- 
2.20.1

  reply	other threads:[~2019-01-29 10:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 10:44 [U-Boot] [PATCH] video: Armada XP: Move driver to DM_VIDEO Stefan Roese
2019-01-29 10:44 ` Stefan Roese [this message]
2019-01-29 13:16   ` [U-Boot] [PATCH] video: bmp: Add support for 24bpp BMP files on 16bpp displays Anatolij Gustschin
2019-01-29 10:44 ` [U-Boot] [PATCH] arm: mvebu: theadorable: Enable DM_VIDEO support Stefan Roese
2019-01-29 13:25   ` Anatolij Gustschin
2019-01-29 13:13 ` [U-Boot] [PATCH] video: Armada XP: Move driver to DM_VIDEO Anatolij Gustschin
2019-01-30  6:32   ` Stefan Roese
2019-01-30  7:34     ` Anatolij Gustschin
2019-01-30  7:39       ` Stefan Roese
2019-01-30  7:46         ` Anatolij Gustschin
2019-01-30  7:49           ` Stefan Roese
2019-01-30  8:11             ` 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=20190129104445.10865-2-sr@denx.de \
    --to=sr@denx.de \
    --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