Skip to content

Commit 71bbe52

Browse files
yishai1999kartben
authored andcommitted
tests: drivers: display: add support for htiled mode
Added test support for htiled displays Signed-off-by: Yishai Jaffe <[email protected]>
1 parent b65f0b0 commit 71bbe52

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed

tests/drivers/display/display_read_write/src/main.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ static uint8_t disp_buffer[DT_PROP(DT_CHOSEN(zephyr_display), width) *
2222
__aligned(CONFIG_DISPLAY_BUFFER_ALIGNMENT);
2323
static struct display_capabilities cfg;
2424
static uint8_t bpp;
25-
static bool is_tiled;
25+
static bool is_vtiled;
26+
static bool is_htiled;
2627

2728
static inline uint8_t bytes_per_pixel(enum display_pixel_format pixel_format)
2829
{
@@ -57,7 +58,7 @@ static void verify_bytes_of_area(uint8_t *data, int cmp_x, int cmp_y, size_t wid
5758

5859
zassert_ok(err, "display_read failed");
5960

60-
if (is_tiled) {
61+
if (is_vtiled || is_htiled) {
6162
zassert_mem_equal(data, disp_buffer, width * height / 8, NULL);
6263
} else {
6364
zassert_mem_equal(data, disp_buffer, width * height * bpp, NULL);
@@ -66,7 +67,7 @@ static void verify_bytes_of_area(uint8_t *data, int cmp_x, int cmp_y, size_t wid
6667

6768
static void verify_background_color(int x, int y, size_t width, size_t height, uint32_t color)
6869
{
69-
size_t buf_size = is_tiled ? (height * width / 8) : (height * width * bpp);
70+
size_t buf_size = height * width * bpp / ((is_vtiled || is_htiled) ? 8 : 1);
7071
struct display_buffer_descriptor desc = {
7172
.height = height,
7273
.pitch = width,
@@ -90,7 +91,7 @@ static void verify_background_color(int x, int y, size_t width, size_t height, u
9091
zassert_equal(buf16[i], (uint16_t)color, "@%d", i);
9192
break;
9293
case 1:
93-
if (is_tiled) {
94+
if (is_vtiled) {
9495
uint16_t x = i % (width);
9596
uint16_t line = (i - x) / width;
9697
uint16_t tile = line / 8;
@@ -99,6 +100,10 @@ static void verify_background_color(int x, int y, size_t width, size_t height, u
99100
uint8_t *tptr = disp_buffer + (tile * width + x);
100101

101102
zassert_equal(!!(*tptr & BIT(y)), !!(color), "@%d", i);
103+
} else if (is_htiled) {
104+
uint8_t *tptr = disp_buffer + i / 8;
105+
106+
zassert_equal(!!(*tptr & BIT(i % 8)), !!(color), "@%d", i);
102107
} else {
103108
zassert_equal(buf8[i], (uint8_t)color, "@%d", i);
104109
}
@@ -114,7 +119,8 @@ static void display_before(void *text_fixture)
114119
{
115120
display_get_capabilities(dev, &cfg);
116121
bpp = bytes_per_pixel(cfg.current_pixel_format);
117-
is_tiled = ((bpp == 1) && (cfg.screen_info & SCREEN_INFO_MONO_VTILED));
122+
is_vtiled = (bpp == 1 && (cfg.screen_info & SCREEN_INFO_MONO_VTILED));
123+
is_htiled = (bpp == 1 && !(cfg.screen_info & SCREEN_INFO_MONO_VTILED));
118124

119125
struct display_buffer_descriptor desc = {
120126
.height = display_height,
@@ -143,8 +149,8 @@ ZTEST(display_read_write, test_clear)
143149
ZTEST(display_read_write, test_write_to_buffer_head)
144150
{
145151
uint8_t data[4] = {0xFA, 0xAF, 0x9F, 0xFA};
146-
uint8_t height = (is_tiled ? 8 : 1);
147-
uint16_t width = sizeof(data) / bpp;
152+
uint8_t height = (is_vtiled ? 8 : 1);
153+
uint16_t width = sizeof(data) / bpp * (is_htiled ? 8 : 1);
148154
uint16_t buf_size = width * bpp;
149155
struct display_buffer_descriptor desc = {
150156
.height = height,
@@ -171,8 +177,8 @@ ZTEST(display_read_write, test_write_to_buffer_head)
171177
ZTEST(display_read_write, test_write_to_buffer_tail)
172178
{
173179
uint8_t data[4] = {0xFA, 0xAF, 0x9F, 0xFA};
174-
uint16_t height = (is_tiled ? 8 : 1);
175-
uint16_t width = sizeof(data) / bpp;
180+
uint16_t height = (is_vtiled ? 8 : 1);
181+
uint16_t width = sizeof(data) / bpp * (is_htiled ? 8 : 1);
176182
uint16_t buf_size = width * bpp;
177183
struct display_buffer_descriptor desc = {
178184
.height = height,
@@ -196,7 +202,7 @@ ZTEST(display_read_write, test_write_to_buffer_tail)
196202
zassert_ok(err, "display_read failed");
197203

198204
/* check write data and read data are same */
199-
if (is_tiled) {
205+
if (is_vtiled || is_htiled) {
200206
zassert_mem_equal(data,
201207
disp_buffer + (display_width * display_height / 8 - buf_size),
202208
buf_size, NULL);
@@ -217,8 +223,8 @@ ZTEST(display_read_write, test_write_to_buffer_tail)
217223
ZTEST(display_read_write, test_read_does_not_clear_existing_buffer)
218224
{
219225
uint8_t data[4] = {0xFA, 0xAF, 0x9F, 0xFA};
220-
uint8_t height = (is_tiled ? 8 : 1);
221-
uint16_t width = sizeof(data) / bpp;
226+
uint8_t height = (is_vtiled ? 8 : 1);
227+
uint16_t width = sizeof(data) / bpp * (is_htiled ? 8 : 1);
222228
uint16_t buf_size = width * bpp;
223229
struct display_buffer_descriptor desc = {
224230
.height = height,
@@ -252,7 +258,7 @@ ZTEST(display_read_write, test_read_does_not_clear_existing_buffer)
252258
zassert_ok(err, "display_read failed");
253259

254260
/* checking correctly write to the tail of buffer */
255-
if (is_tiled) {
261+
if (is_vtiled || is_htiled) {
256262
zassert_mem_equal(data,
257263
disp_buffer + (display_width * display_height / 8 - buf_size),
258264
buf_size, NULL);

tests/drivers/display/display_read_write/testcase.yaml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,61 @@ tests:
1919
extra_configs:
2020
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_RGB_888=y
2121
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
22-
drivers.display.read_write.sdl.mono01:
22+
drivers.display.read_write.sdl.mono01.vtiled.msbfirst:
2323
platform_allow:
2424
- native_sim
2525
extra_configs:
2626
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO01=y
2727
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
28-
drivers.display.read_write.sdl.mono10:
28+
drivers.display.read_write.sdl.mono10.vtiled.msbfirst:
2929
platform_allow:
3030
- native_sim
3131
extra_configs:
3232
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO10=y
3333
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
34-
drivers.display.read_write.sdl.mono01.lsbfirst:
34+
drivers.display.read_write.sdl.mono01.htiled.msbfirst:
3535
platform_allow:
3636
- native_sim
3737
extra_configs:
3838
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO01=y
3939
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
40+
- CONFIG_SDL_DISPLAY_MONO_VTILED=n
41+
drivers.display.read_write.sdl.mono10.htiled.msbfirst:
42+
platform_allow:
43+
- native_sim
44+
extra_configs:
45+
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO10=y
46+
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
47+
- CONFIG_SDL_DISPLAY_MONO_VTILED=n
48+
drivers.display.read_write.sdl.mono01.vtiled.lsbfirst:
49+
platform_allow:
50+
- native_sim
51+
extra_configs:
52+
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO01=y
53+
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
54+
- CONFIG_SDL_DISPLAY_MONO_MSB_FIRST=n
55+
drivers.display.read_write.sdl.mono10.vtiled.lsbfirst:
56+
platform_allow:
57+
- native_sim
58+
extra_configs:
59+
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO10=y
60+
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
61+
- CONFIG_SDL_DISPLAY_MONO_MSB_FIRST=n
62+
drivers.display.read_write.sdl.mono01.htiled.lsbfirst:
63+
platform_allow:
64+
- native_sim
65+
extra_configs:
66+
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO01=y
67+
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
68+
- CONFIG_SDL_DISPLAY_MONO_VTILED=n
4069
- CONFIG_SDL_DISPLAY_MONO_MSB_FIRST=n
41-
drivers.display.read_write.sdl.mono10.lsbfirst:
70+
drivers.display.read_write.sdl.mono10.htiled.lsbfirst:
4271
platform_allow:
4372
- native_sim
4473
extra_configs:
4574
- CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_MONO10=y
4675
- CONFIG_SDL_DISPLAY_USE_HARDWARE_ACCELERATOR=n
76+
- CONFIG_SDL_DISPLAY_MONO_VTILED=n
4777
- CONFIG_SDL_DISPLAY_MONO_MSB_FIRST=n
4878
drivers.display.read_write.sdl.rgb565:
4979
platform_allow:

0 commit comments

Comments
 (0)