From 747440d0fa95f2205a8fcef49b6c7845700b6246 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 18 Jan 2016 19:52:28 -0700 Subject: [PATCH] dm: video: test: Test that bitmap display works correctly Add a test for the 'bmp' command. Test both the uncompressed and compressed versions of the file, since they use different code paths. Signed-off-by: Simon Glass Acked-by: Anatolij Gustschin --- include/configs/sandbox.h | 2 ++ test/dm/video.c | 54 ++++++++++++++++++++++++++++++++++++++ tools/logos/denx-comp.bmp | Bin 0 -> 4148 bytes 3 files changed, 56 insertions(+) create mode 100644 tools/logos/denx-comp.bmp diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 23ae44c8a0..6498981cef 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -163,6 +163,8 @@ #define CONFIG_SYS_CONSOLE_IS_IN_ENV #define LCD_BPP LCD_COLOR16 #define CONFIG_LCD_BMP_RLE8 +#define CONFIG_VIDEO_BMP_RLE8 +#define CONFIG_SPLASH_SCREEN_ALIGN #define CONFIG_KEYBOARD diff --git a/test/dm/video.c b/test/dm/video.c index 65db216b31..9f5e7fce37 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -215,3 +215,57 @@ static int dm_test_video_rotation3(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_video_rotation3, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Read a file into memory and return a pointer to it */ +static int read_file(struct unit_test_state *uts, const char *fname, + ulong *addrp) +{ + int buf_size = 100000; + ulong addr = 0; + int size, fd; + char *buf; + + buf = map_sysmem(addr, 0); + ut_assert(buf != NULL); + fd = os_open(fname, OS_O_RDONLY); + ut_assert(fd >= 0); + size = os_read(fd, buf, buf_size); + ut_assert(size >= 0); + ut_assert(size < buf_size); + os_close(fd); + *addrp = addr; + + return 0; +} + +/* Test drawing a bitmap file */ +static int dm_test_video_bmp(struct unit_test_state *uts) +{ + struct udevice *dev; + ulong addr; + + ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev)); + ut_assertok(read_file(uts, "tools/logos/denx.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(1368, compress_frame_buffer(dev)); + + return 0; +} +DM_TEST(dm_test_video_bmp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); + +/* Test drawing a compressed bitmap file */ +static int dm_test_video_bmp_comp(struct unit_test_state *uts) +{ + struct udevice *dev; + ulong addr; + + ut_assertok(uclass_get_device(UCLASS_VIDEO, 0, &dev)); + ut_assertok(read_file(uts, "tools/logos/denx-comp.bmp", &addr)); + + ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); + ut_asserteq(1368, compress_frame_buffer(dev)); + + return 0; +} +DM_TEST(dm_test_video_bmp_comp, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); diff --git a/tools/logos/denx-comp.bmp b/tools/logos/denx-comp.bmp new file mode 100644 index 0000000000000000000000000000000000000000..89d0f471c85cf734b5f0e2bb2508d39f5b9e72b8 GIT binary patch literal 4148 zcmeH}JBVCW7{|ZwzF%|i?CfTD_HOoU9!9h=1``B36GbeO{DjKjbg$6`yOp(GSK^vPDZ4|D*@7%dFJBwIaNQOOg&pqGkfBxTN_VhC+$KpTl zMjrIN8kJ}yPxm@R)`htdsy{^j&j&%I?E`#k@-`>WrHoIihlzQ6JN0~jqn zgj@QYdis={dEtzlefg}Md-I%Jc;|v#ymV16eQ-%Ge{@-{esWc=eRfT*e|=qUet%PL z-M%Gvf4(cbzwOE+Uv%>LSDie2qmviE>E!kAI(hqtPTu>mlMioqa^BEe!{g)#(V#agEl14zzi`$D5%s zxvl-43?GQ2u=fRGtroue`*EhW8*bbC<23pwk6<$|S%ii0Z3uJEc#jXcv7GY;|I2=J zI80oxtto8I8H88-S>z!r#$nX^3R3cI@dkvwSE2+I!R#E}O7UP(dtagDZ5DxiRH0|p zvZsmZ_psiY%J!PM>Cvgg|EaU=*9hM2-d+rSlF99rv%HBrE8$qkSAG84r2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