]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: theadorable: Use RGB565 for BMP blitting
authorSimon Glass <sjg@chromium.org>
Fri, 19 Nov 2021 20:23:59 +0000 (13:23 -0700)
committerAnatolij Gustschin <agust@denx.de>
Sun, 26 Dec 2021 22:23:52 +0000 (23:23 +0100)
At present this uses RGB555 format for blitting to a display. Sandbox uses
565 and that seems to be more normal for BMP as well. Update the code
accordingly and add a test.

Note that this likely breaks the theadorable board so we may need to
discuss supporting both formats.

Signed-off-by: Simon Glass <sjg@chromium.org>
configs/sandbox_defconfig
configs/sandbox_flattree_defconfig
drivers/video/video_bmp.c
test/dm/video.c
tools/logos/denx-24bpp.bmp.gz [new file with mode: 0644]

index 5dffc704bd6b3afeec7681c15c16e24792f9a71b..4f413582fb2d32ca455b68a5e324901927eec4db 100644 (file)
@@ -286,6 +286,7 @@ CONFIG_SANDBOX_OSD=y
 CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_VIDEO_BMP_RLE8=y
 CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
 CONFIG_W1=y
 CONFIG_W1_GPIO=y
 CONFIG_W1_EEPROM=y
index f16d890048f0911e8477ca9c8d74b97ed625297b..4d5a73fce0932a8acdb81ed6972a35b8734a7a73 100644 (file)
@@ -199,6 +199,7 @@ CONFIG_OSD=y
 CONFIG_SANDBOX_OSD=y
 CONFIG_VIDEO_BMP_RLE8=y
 CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
 CONFIG_CMD_DHRYSTONE=y
 CONFIG_RSA_VERIFY_WITH_PKEY=y
 CONFIG_TPM=y
index ba36589effb1f6b92e55d2b9026f89bd5f915eb1..1c613567657d105f189d774192fa70f97160f02b 100644 (file)
@@ -338,9 +338,9 @@ int video_bmp_display(struct udevice *dev, ulong bmp_image, int x, int y,
                for (i = 0; i < height; ++i) {
                        for (j = 0; j < width; j++) {
                                if (bpix == 16) {
-                                       /* 16bit 555RGB format */
-                                       *(u16 *)fb = ((bmap[2] >> 3) << 10) |
-                                               ((bmap[1] >> 3) << 5) |
+                                       /* 16bit 565RGB format */
+                                       *(u16 *)fb = ((bmap[2] >> 3) << 11) |
+                                               ((bmap[1] >> 2) << 5) |
                                                (bmap[0] >> 3);
                                        bmap += 3;
                                        fb += 2;
index c496b05df76f3e7eb80f5ff0da1894deeb9370ba..4e76574a9138eed217a2dbaa77b59bfa265dc592 100644 (file)
@@ -363,6 +363,52 @@ static int dm_test_video_bmp16(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_video_bmp16, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
 
+/* Test drawing a 24bpp bitmap file on a 16bpp display */
+static int dm_test_video_bmp24(struct unit_test_state *uts)
+{
+       ulong src, src_len = ~0UL;
+       uint dst_len = ~0U;
+       struct udevice *dev;
+       ulong dst = 0x10000;
+
+       ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev));
+       ut_assertnonnull(dev);
+       ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP16));
+
+       ut_assertok(read_file(uts, "tools/logos/denx-24bpp.bmp.gz", &src));
+       ut_assertok(gunzip(map_sysmem(dst, 0), dst_len, map_sysmem(src, 0),
+                          &src_len));
+
+       ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
+       ut_asserteq(3656, compress_frame_buffer(uts, dev));
+
+       return 0;
+}
+DM_TEST(dm_test_video_bmp24, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+/* Test drawing a 24bpp bitmap file on a 32bpp display */
+static int dm_test_video_bmp24_32(struct unit_test_state *uts)
+{
+       ulong src, src_len = ~0UL;
+       uint dst_len = ~0U;
+       struct udevice *dev;
+       ulong dst = 0x10000;
+
+       ut_assertok(uclass_find_first_device(UCLASS_VIDEO, &dev));
+       ut_assertnonnull(dev);
+       ut_assertok(sandbox_sdl_set_bpp(dev, VIDEO_BPP32));
+
+       ut_assertok(read_file(uts, "tools/logos/denx-24bpp.bmp.gz", &src));
+       ut_assertok(gunzip(map_sysmem(dst, 0), dst_len, map_sysmem(src, 0),
+                          &src_len));
+
+       ut_assertok(video_bmp_display(dev, dst, 0, 0, false));
+       ut_asserteq(6827, compress_frame_buffer(uts, dev));
+
+       return 0;
+}
+DM_TEST(dm_test_video_bmp24_32, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
 /* Test drawing a bitmap file on a 32bpp display */
 static int dm_test_video_bmp32(struct unit_test_state *uts)
 {
diff --git a/tools/logos/denx-24bpp.bmp.gz b/tools/logos/denx-24bpp.bmp.gz
new file mode 100644 (file)
index 0000000..95b44d3
Binary files /dev/null and b/tools/logos/denx-24bpp.bmp.gz differ