From 4ea15482101bd2ef6d2086b1a8afb255de2e65e5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 19 Nov 2021 13:23:59 -0700 Subject: [PATCH] video: theadorable: Use RGB565 for BMP blitting 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 --- configs/sandbox_defconfig | 1 + configs/sandbox_flattree_defconfig | 1 + drivers/video/video_bmp.c | 6 ++-- test/dm/video.c | 46 +++++++++++++++++++++++++++++ tools/logos/denx-24bpp.bmp.gz | Bin 0 -> 7137 bytes 5 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tools/logos/denx-24bpp.bmp.gz diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 5dffc704bd..4f413582fb 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -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 diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index f16d890048..4d5a73fce0 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -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 diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c index ba36589eff..1c61356765 100644 --- a/drivers/video/video_bmp.c +++ b/drivers/video/video_bmp.c @@ -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; diff --git a/test/dm/video.c b/test/dm/video.c index c496b05df7..4e76574a91 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -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 index 0000000000000000000000000000000000000000..95b44d31950994a4dc6a5148a4a754d9979e2dc6 GIT binary patch literal 7137 zcmV<78y@5ziwFn{aFt;I17u}xcr7wCVsLOSVr_5$>|F;~8)up(o1ScP$?jc}+uiIX zcbm;+FL!&}Zf~>CKIb^bxP-(urh@ zUmE_^I{w`i^pyR65PtvUks$lOfop8YG((WU>j!TC|9+%g+KEBQDaR2| zjC1_K4*FwwT{%7oNl9Is(d&B$9pi#j{CE_DU`G~G*Y!@h62}m29w;_hp&HP1soP)# zUa*-`(aL~Vh%P|=@+i^1UdpjjQ^|+uQH>UO!Mzzm+R6he(gz3~C7R<(9Un+%X;6?n zW|U=yOA$QmnRQ|Ll~I-*m*QpV=?D-~?(D7^&dEs9S!Td41>bQjr;d@j*$16v<(;9+ zK|y?n4M!eO@sTtj?0F%cRlO4MW*q7mKLRN(k#1aZXd*m(^w-msV>FTf!udK1lWoa1Em?uWn3mP%%q-QZURDL)&GL#S{MoERP5z># zMER>4a_7$0YhP1Me2C?hboom;v&)e_YHch|SHJ%E^k30X@?mAGQ@p5cTKum|n)X$^ z^F1Sq8(Y(2|4k^r29wfTfC9{yV+r%-zv1>U1jF+&)i4>-^cLRg)WNoc*IBp#YzO)?QbPpsn^RHD zo+gp(zN^UHh1{u6m9_P;z0&=yJ|oPf{X_0EH|=N7D92XhuDQxFo{yQE4>Hz8G2|&$ zdC^?;lqalRU(xGWzUO@L+MPwK-Y#oB>T-YYrPS#^7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