@@ -160,6 +160,8 @@ static int sdl_display_init(const struct device *dev)
160
160
PIXEL_FORMAT_BGR_565
161
161
#elif defined(CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_L_8 )
162
162
PIXEL_FORMAT_L_8
163
+ #elif defined(CONFIG_SDL_DISPLAY_DEFAULT_PIXEL_FORMAT_AL_88 )
164
+ PIXEL_FORMAT_AL_88
163
165
#else /* SDL_DISPLAY_DEFAULT_PIXEL_FORMAT */
164
166
PIXEL_FORMAT_ARGB_8888
165
167
#endif /* SDL_DISPLAY_DEFAULT_PIXEL_FORMAT */
@@ -210,6 +212,31 @@ static void sdl_display_write_rgb888(uint8_t *disp_buf,
210
212
}
211
213
}
212
214
215
+ static void sdl_display_write_al88 (uint8_t * disp_buf ,
216
+ const struct display_buffer_descriptor * desc , const void * buf )
217
+ {
218
+ uint32_t w_idx ;
219
+ uint32_t h_idx ;
220
+ uint32_t pixel ;
221
+ const uint8_t * byte_ptr ;
222
+
223
+ __ASSERT ((desc -> pitch * 2U * desc -> height ) <= desc -> buf_size ,
224
+ "Input buffer too small" );
225
+
226
+ for (h_idx = 0U ; h_idx < desc -> height ; ++ h_idx ) {
227
+ for (w_idx = 0U ; w_idx < desc -> width ; ++ w_idx ) {
228
+ byte_ptr = (const uint8_t * )buf +
229
+ ((h_idx * desc -> pitch ) + w_idx ) * 2U ;
230
+ pixel = * (byte_ptr + 1 ) << 24 ;
231
+ pixel |= * (byte_ptr ) << 16 ;
232
+ pixel |= * (byte_ptr ) << 8 ;
233
+ pixel |= * (byte_ptr );
234
+ * ((uint32_t * )disp_buf ) = pixel ;
235
+ disp_buf += 4 ;
236
+ }
237
+ }
238
+ }
239
+
213
240
static void sdl_display_write_rgb565 (uint8_t * disp_buf ,
214
241
const struct display_buffer_descriptor * desc , const void * buf )
215
242
{
@@ -392,6 +419,8 @@ static int sdl_display_write(const struct device *dev, const uint16_t x,
392
419
sdl_display_write_bgr565 (disp_data -> buf , desc , buf );
393
420
} else if (disp_data -> current_pixel_format == PIXEL_FORMAT_L_8 ) {
394
421
sdl_display_write_l8 (disp_data -> buf , desc , buf );
422
+ } else if (disp_data -> current_pixel_format == PIXEL_FORMAT_AL_88 ) {
423
+ sdl_display_write_al88 (disp_data -> buf , desc , buf );
395
424
}
396
425
397
426
if (k_current_get () == & disp_data -> sdl_thread ) {
@@ -543,6 +572,29 @@ static void sdl_display_read_l8(const uint8_t *read_buf,
543
572
}
544
573
}
545
574
575
+ static void sdl_display_read_al88 (const uint8_t * read_buf ,
576
+ const struct display_buffer_descriptor * desc , void * buf )
577
+ {
578
+ uint32_t w_idx ;
579
+ uint32_t h_idx ;
580
+ uint8_t * buf8 ;
581
+ const uint32_t * pix_ptr ;
582
+
583
+ __ASSERT ((desc -> pitch * 2U * desc -> height ) <= desc -> buf_size , "Read buffer is too small" );
584
+
585
+ for (h_idx = 0U ; h_idx < desc -> height ; ++ h_idx ) {
586
+ buf8 = ((uint8_t * )buf ) + desc -> pitch * 2U * h_idx ;
587
+
588
+ for (w_idx = 0U ; w_idx < desc -> width ; ++ w_idx ) {
589
+ pix_ptr = (const uint32_t * )read_buf + ((h_idx * desc -> pitch ) + w_idx );
590
+ * buf8 = (* pix_ptr & 0xFF );
591
+ buf8 += 1 ;
592
+ * buf8 = (* pix_ptr & 0xFF000000 ) >> 24 ;
593
+ buf8 += 1 ;
594
+ }
595
+ }
596
+ }
597
+
546
598
static int sdl_display_read (const struct device * dev , const uint16_t x , const uint16_t y ,
547
599
const struct display_buffer_descriptor * desc , void * buf )
548
600
{
@@ -580,6 +632,8 @@ static int sdl_display_read(const struct device *dev, const uint16_t x, const ui
580
632
sdl_display_read_bgr565 (disp_data -> read_buf , desc , buf );
581
633
} else if (disp_data -> current_pixel_format == PIXEL_FORMAT_L_8 ) {
582
634
sdl_display_read_l8 (disp_data -> read_buf , desc , buf );
635
+ } else if (disp_data -> current_pixel_format == PIXEL_FORMAT_AL_88 ) {
636
+ sdl_display_read_al88 (disp_data -> read_buf , desc , buf );
583
637
}
584
638
k_mutex_unlock (& disp_data -> task_mutex );
585
639
@@ -615,6 +669,9 @@ static int sdl_display_clear(const struct device *dev)
615
669
case PIXEL_FORMAT_BGR_565 :
616
670
size = config -> width * config -> height * 2U ;
617
671
break ;
672
+ case PIXEL_FORMAT_AL_88 :
673
+ size = config -> width * config -> height * 2U ;
674
+ break ;
618
675
default :
619
676
__ASSERT_MSG_INFO ("Pixel format not supported" );
620
677
return - EINVAL ;
@@ -688,7 +745,8 @@ static void sdl_display_get_capabilities(
688
745
PIXEL_FORMAT_MONO10 |
689
746
PIXEL_FORMAT_RGB_565 |
690
747
PIXEL_FORMAT_BGR_565 |
691
- PIXEL_FORMAT_L_8 ;
748
+ PIXEL_FORMAT_L_8 |
749
+ PIXEL_FORMAT_AL_88 ;
692
750
capabilities -> current_pixel_format = disp_data -> current_pixel_format ;
693
751
capabilities -> screen_info =
694
752
(IS_ENABLED (CONFIG_SDL_DISPLAY_MONO_VTILED ) ? SCREEN_INFO_MONO_VTILED : 0 ) |
@@ -708,6 +766,7 @@ static int sdl_display_set_pixel_format(const struct device *dev,
708
766
case PIXEL_FORMAT_RGB_565 :
709
767
case PIXEL_FORMAT_BGR_565 :
710
768
case PIXEL_FORMAT_L_8 :
769
+ case PIXEL_FORMAT_AL_88 :
711
770
disp_data -> current_pixel_format = pixel_format ;
712
771
return 0 ;
713
772
default :
0 commit comments