drivers: display: st7789v: add support for BGR565
Add support for BGR565 pixel format in the st7789v driver. Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
This commit is contained in:
parent
8d74553053
commit
c8c526313a
2 changed files with 13 additions and 3 deletions
|
|
@ -24,4 +24,7 @@ config ST7789V_RGB888
|
|||
config ST7789V_RGB565
|
||||
bool "RGB565"
|
||||
|
||||
config ST7789V_BGR565
|
||||
bool "BGR565"
|
||||
|
||||
endchoice
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ struct st7789v_data {
|
|||
uint16_t y_offset;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ST7789V_RGB565
|
||||
#define ST7789V_PIXEL_SIZE 2u
|
||||
#else
|
||||
#ifdef CONFIG_ST7789V_RGB888
|
||||
#define ST7789V_PIXEL_SIZE 3u
|
||||
#else
|
||||
#define ST7789V_PIXEL_SIZE 2u
|
||||
#endif
|
||||
|
||||
static void st7789v_set_lcd_margins(const struct device *dev,
|
||||
|
|
@ -164,6 +164,8 @@ static int st7789v_write(const struct device *dev,
|
|||
}
|
||||
if (IS_ENABLED(CONFIG_ST7789V_RGB565)) {
|
||||
pixfmt = PIXEL_FORMAT_RGB_565;
|
||||
} else if (IS_ENABLED(CONFIG_ST7789V_BGR565)) {
|
||||
pixfmt = PIXEL_FORMAT_BGR_565;
|
||||
} else {
|
||||
pixfmt = PIXEL_FORMAT_RGB_888;
|
||||
}
|
||||
|
|
@ -197,6 +199,9 @@ static void st7789v_get_capabilities(const struct device *dev,
|
|||
#ifdef CONFIG_ST7789V_RGB565
|
||||
capabilities->supported_pixel_formats = PIXEL_FORMAT_RGB_565;
|
||||
capabilities->current_pixel_format = PIXEL_FORMAT_RGB_565;
|
||||
#elif CONFIG_ST7789V_BGR565
|
||||
capabilities->supported_pixel_formats = PIXEL_FORMAT_BGR_565;
|
||||
capabilities->current_pixel_format = PIXEL_FORMAT_BGR_565;
|
||||
#else
|
||||
capabilities->supported_pixel_formats = PIXEL_FORMAT_RGB_888;
|
||||
capabilities->current_pixel_format = PIXEL_FORMAT_RGB_888;
|
||||
|
|
@ -209,6 +214,8 @@ static int st7789v_set_pixel_format(const struct device *dev,
|
|||
{
|
||||
#ifdef CONFIG_ST7789V_RGB565
|
||||
if (pixel_format == PIXEL_FORMAT_RGB_565) {
|
||||
#elif CONFIG_ST7789V_BGR565
|
||||
if (pixel_format == PIXEL_FORMAT_BGR_565) {
|
||||
#else
|
||||
if (pixel_format == PIXEL_FORMAT_RGB_888) {
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue