Skip to content

Commit b65f0b0

Browse files
yishai1999kartben
authored andcommitted
drivers: display: sdl: support non-vtiled mono mode
Added support for writing in non-vtiled mono mode to SDL display emulator driver. Signed-off-by: Yishai Jaffe <[email protected]>
1 parent 4385aa4 commit b65f0b0

File tree

2 files changed

+43
-16
lines changed

2 files changed

+43
-16
lines changed

drivers/display/Kconfig.sdl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ config SDL_DISPLAY_MONO_MSB_FIRST
6262
If selected, set the MSB to represent the first pixel.
6363
This applies when the pixel format is MONO01/MONO10.
6464

65+
config SDL_DISPLAY_MONO_VTILED
66+
bool "Configure data octet representation"
67+
default y
68+
help
69+
If selected, set the data octet to represent 8 pixels ordered vertically.
70+
Otherwise, horizontally.
71+
This applies when the pixel format is MONO01/MONO10.
72+
6573
config SDL_DISPLAY_TRANSPARENCY_GRID_CELL_SIZE
6674
int "Transparency grid cell size"
6775
default 8

drivers/display/display_sdl.c

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -279,24 +279,42 @@ static void sdl_display_write_mono(uint8_t *disp_buf,
279279
one_color = 0x00FFFFFF;
280280
}
281281

282-
for (tile_idx = 0U; tile_idx < desc->height/8U; ++tile_idx) {
283-
for (w_idx = 0U; w_idx < desc->width; ++w_idx) {
284-
byte_ptr = (const uint8_t *)buf +
285-
((tile_idx * desc->pitch) + w_idx);
286-
disp_buf_start = disp_buf;
287-
for (h_idx = 0U; h_idx < 8; ++h_idx) {
288-
if ((*byte_ptr & mono_pixel_order(h_idx)) != 0U) {
289-
pixel = one_color;
290-
} else {
291-
pixel = ~one_color;
282+
if (IS_ENABLED(CONFIG_SDL_DISPLAY_MONO_VTILED)) {
283+
for (tile_idx = 0U; tile_idx < desc->height / 8U; ++tile_idx) {
284+
for (w_idx = 0U; w_idx < desc->width; ++w_idx) {
285+
byte_ptr =
286+
(const uint8_t *)buf + ((tile_idx * desc->pitch) + w_idx);
287+
disp_buf_start = disp_buf;
288+
for (h_idx = 0U; h_idx < 8; ++h_idx) {
289+
if ((*byte_ptr & mono_pixel_order(h_idx)) != 0U) {
290+
pixel = one_color;
291+
} else {
292+
pixel = ~one_color;
293+
}
294+
*((uint32_t *)disp_buf) = pixel | 0xFF000000;
295+
disp_buf += (desc->width * 4U);
292296
}
293-
*((uint32_t *)disp_buf) = pixel | 0xFF000000;
294-
disp_buf += (desc->width * 4U);
297+
disp_buf = disp_buf_start;
298+
disp_buf += 4;
299+
}
300+
disp_buf += 7 * (desc->width * 4U);
301+
}
302+
} else {
303+
for (h_idx = 0; h_idx < desc->height; h_idx++) {
304+
for (tile_idx = 0; tile_idx < desc->width / 8; tile_idx++) {
305+
byte_ptr = (const uint8_t *)buf +
306+
((h_idx * desc->width / 8) + tile_idx);
307+
for (w_idx = 0; w_idx < 8; w_idx++) {
308+
if ((*byte_ptr & mono_pixel_order(w_idx)) != 0U) {
309+
pixel = one_color;
310+
} else {
311+
pixel = ~one_color;
312+
}
313+
*((uint32_t *)disp_buf + w_idx) = pixel | 0xFF000000;
314+
}
315+
disp_buf += 8 * sizeof(uint32_t);
295316
}
296-
disp_buf = disp_buf_start;
297-
disp_buf += 4;
298317
}
299-
disp_buf += 7 * (desc->width * 4U);
300318
}
301319
}
302320

@@ -669,7 +687,8 @@ static void sdl_display_get_capabilities(
669687
PIXEL_FORMAT_BGR_565 |
670688
PIXEL_FORMAT_L_8;
671689
capabilities->current_pixel_format = disp_data->current_pixel_format;
672-
capabilities->screen_info = SCREEN_INFO_MONO_VTILED |
690+
capabilities->screen_info =
691+
(IS_ENABLED(CONFIG_SDL_DISPLAY_MONO_VTILED) ? SCREEN_INFO_MONO_VTILED : 0) |
673692
(IS_ENABLED(CONFIG_SDL_DISPLAY_MONO_MSB_FIRST) ? SCREEN_INFO_MONO_MSB_FIRST : 0);
674693
}
675694

0 commit comments

Comments
 (0)