]> Git Repo - J-u-boot.git/blobdiff - drivers/video/video_bmp.c
Merge tag 'efi-2020-07-rc6-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
[J-u-boot.git] / drivers / video / video_bmp.c
index aeff65648c1a54f390c95b3d7960fa3a4ca899b8..7d7f37b445c3fdf70afde04474fea477dbe8acbc 100644 (file)
@@ -6,7 +6,9 @@
 #include <common.h>
 #include <bmp_layout.h>
 #include <dm.h>
+#include <log.h>
 #include <mapmem.h>
+#include <splash.h>
 #include <video.h>
 #include <watchdog.h>
 #include <asm/unaligned.h>
@@ -39,18 +41,16 @@ static void draw_encoded_bitmap(ushort **fbp, ushort col, int cnt)
 
 static void video_display_rle8_bitmap(struct udevice *dev,
                                      struct bmp_image *bmp, ushort *cmap,
-                                     uchar *fb, int x_off, int y_off)
+                                     uchar *fb, int x_off, int y_off,
+                                     ulong width, ulong height)
 {
        struct video_priv *priv = dev_get_uclass_priv(dev);
        uchar *bmap;
-       ulong width, height;
        ulong cnt, runlen;
        int x, y;
        int decode = 1;
 
        debug("%s\n", __func__);
-       width = get_unaligned_le32(&bmp->header.width);
-       height = get_unaligned_le32(&bmp->header.height);
        bmap = (uchar *)bmp + get_unaligned_le32(&bmp->header.data_offset);
 
        x = 0;
@@ -140,8 +140,6 @@ __weak void fb_put_word(uchar **fb, uchar **from)
 }
 #endif /* CONFIG_BMP_16BPP */
 
-#define BMP_ALIGN_CENTER       0x7fff
-
 /**
  * video_splash_align_axis() - Align a single coordinate
  *
@@ -158,8 +156,8 @@ __weak void fb_put_word(uchar **fb, uchar **from)
 static void video_splash_align_axis(int *axis, unsigned long panel_size,
                                    unsigned long picture_size)
 {
-       unsigned long panel_picture_delta = panel_size - picture_size;
-       unsigned long axis_alignment;
+       long panel_picture_delta = panel_size - picture_size;
+       long axis_alignment;
 
        if (*axis == BMP_ALIGN_CENTER)
                axis_alignment = panel_picture_delta / 2;
@@ -230,11 +228,14 @@ 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 == 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",
                       bpix, get_unaligned_le16(&bmp->header.bit_count));
@@ -266,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);
@@ -277,25 +279,37 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                                return -EPROTONOSUPPORT;
                        }
                        video_display_rle8_bitmap(dev, bmp, cmap_base, fb, x,
-                                                 y);
+                                                 y, width, height);
                        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);
@@ -319,12 +333,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 */
@@ -345,7 +369,7 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                break;
        };
 
-       video_sync(dev);
+       video_sync(dev, false);
 
        return 0;
 }
This page took 0.040939 seconds and 4 git commands to generate.