summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-10-06 08:36:17 -0600
committerAnatolij Gustschin <agust@denx.de>2022-10-30 20:01:40 +0100
commite90322f87c97a4829c44fe77435c9faca87cbfc8 (patch)
tree818962ae3039336c7e0f65db8272cb3c6c2765b7 /drivers
parent430e1676a76bf8b7112c64e19cf64b988c281ee0 (diff)
downloadu-boot-e90322f87c97a4829c44fe77435c9faca87cbfc8.tar.gz
u-boot-e90322f87c97a4829c44fe77435c9faca87cbfc8.tar.bz2
u-boot-e90322f87c97a4829c44fe77435c9faca87cbfc8.zip
video: Add a function to get the dimensions of a BMP image
This is useful for some other users, so break this out into a function. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/video_bmp.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index 082895a50e..6188a13e44 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -229,6 +229,16 @@ static void video_splash_align_axis(int *axis, unsigned long panel_size,
*axis = max(0, (int)axis_alignment);
}
+void video_bmp_get_info(void *bmp_image, ulong *widthp, ulong *heightp,
+ uint *bpixp)
+{
+ struct bmp_image *bmp = bmp_image;
+
+ *widthp = get_unaligned_le32(&bmp->header.width);
+ *heightp = get_unaligned_le32(&bmp->header.height);
+ *bpixp = get_unaligned_le16(&bmp->header.bit_count);
+}
+
int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
bool align)
{
@@ -253,9 +263,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
return -EINVAL;
}
- width = get_unaligned_le32(&bmp->header.width);
- height = get_unaligned_le32(&bmp->header.height);
- bmp_bpix = get_unaligned_le16(&bmp->header.bit_count);
+ video_bmp_get_info(bmp, &width, &height, &bmp_bpix);
hdr_size = get_unaligned_le16(&bmp->header.size);
debug("hdr_size=%d, bmp_bpix=%d\n", hdr_size, bmp_bpix);
palette = (void *)bmp + 14 + hdr_size;
@@ -283,7 +291,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
!(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));
+ bpix, colours);
return -EPERM;
}