]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: bmp: Support rgba8888 pixel format
authorMichal Simek <michal.simek@amd.com>
Wed, 17 May 2023 08:42:08 +0000 (10:42 +0200)
committerMichal Simek <michal.simek@amd.com>
Mon, 12 Jun 2023 11:25:01 +0000 (13:25 +0200)
Adding the support for RGBA8888 format for BMP decoding.

Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/322910eb24692f6140a001796501270eb1c53d9a.1684312924.git.michal.simek@amd.com
drivers/video/video_bmp.c

index 47e52c4f69c98b91f059961db212068da163efce..45f003c8251ae01861ecb812f83cc94774d110bf 100644 (file)
@@ -42,6 +42,18 @@ static u32 get_bmp_col_x2r10g10b10(struct bmp_color_table_entry *cte)
                (cte->blue << 2U));
 }
 
+/**
+ * get_bmp_col_rgba8888() - Convert a colour-table entry into a rgba8888 pixel value
+ *
+ * Return: value to write to the rgba8888 frame buffer for this palette entry
+ */
+static u32 get_bmp_col_rgba8888(struct bmp_color_table_entry *cte)
+{
+       return ((cte->red) |
+               (cte->green << 8U) |
+               (cte->blue << 16U) | 0xff << 24U);
+}
+
 /**
  * write_pix8() - Write a pixel from a BMP image into the framebuffer
  *
@@ -71,6 +83,8 @@ static void write_pix8(u8 *fb, uint bpix, enum video_format eformat,
                        *fb++ = cte->blue;
                } else if (eformat == VIDEO_X2R10G10B10) {
                        *(u32 *)fb = get_bmp_col_x2r10g10b10(cte);
+               } else if (eformat == VIDEO_RGBA8888) {
+                       *(u32 *)fb = get_bmp_col_rgba8888(cte);
                } else {
                        *fb++ = cte->blue;
                        *fb++ = cte->green;
@@ -382,6 +396,17 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                                                *fb++ = (pix >> 8) & 0xff;
                                                *fb++ = (pix >> 16) & 0xff;
                                                *fb++ = pix >> 24;
+                                       } else if (eformat == VIDEO_RGBA8888) {
+                                               u32 pix;
+
+                                               pix = *bmap++ << 8U; /* blue */
+                                               pix |= *bmap++ << 16U; /* green */
+                                               pix |= *bmap++ << 24U; /* red */
+
+                                               *fb++ = (pix >> 24) & 0xff;
+                                               *fb++ = (pix >> 16) & 0xff;
+                                               *fb++ = (pix >> 8) & 0xff;
+                                               *fb++ = 0xff;
                                        } else {
                                                *fb++ = *bmap++;
                                                *fb++ = *bmap++;
@@ -409,6 +434,17 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                                                *fb++ = (pix >> 8) & 0xff;
                                                *fb++ = (pix >> 16) & 0xff;
                                                *fb++ = pix >> 24;
+                                       } else if (eformat == VIDEO_RGBA8888) {
+                                               u32 pix;
+
+                                               pix = *bmap++ << 8U; /* blue */
+                                               pix |= *bmap++ << 16U; /* green */
+                                               pix |= *bmap++ << 24U; /* red */
+                                               bmap++;
+                                               *fb++ = (pix >> 24) & 0xff;
+                                               *fb++ = (pix >> 16) & 0xff;
+                                               *fb++ = (pix >> 8) & 0xff;
+                                               *fb++ = 0xff; /* opacity */
                                        } else {
                                                *fb++ = *bmap++;
                                                *fb++ = *bmap++;