drivers: display: st7735r: Add rgb-is-inverted property
Set the inverted value of pixel format setting in MADCTL register to current_pixel_format in display capabilities structure if rgb-is-inverted enabled. This make enables support for a module that mismatches the RGB setting in the MADCTL register and the actual display color format. (Such as Longan Nano built-in LCD module.) Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
This commit is contained in:
parent
e579c19bb1
commit
9f12f2cd51
1 changed files with 12 additions and 1 deletions
|
@ -51,6 +51,7 @@ struct st7735r_config {
|
|||
uint8_t gamctrp1[16];
|
||||
uint8_t gamctrn1[16];
|
||||
bool inversion_on;
|
||||
bool rgb_is_inverted;
|
||||
};
|
||||
|
||||
struct st7735r_data {
|
||||
|
@ -269,7 +270,16 @@ static void st7735r_get_capabilities(const struct device *dev,
|
|||
memset(capabilities, 0, sizeof(struct display_capabilities));
|
||||
capabilities->x_resolution = config->width;
|
||||
capabilities->y_resolution = config->height;
|
||||
if (config->madctl & ST7735R_MADCTL_BGR) {
|
||||
|
||||
/*
|
||||
* Invert the pixel format if rgb_is_inverted is enabled.
|
||||
* Report pixel format as the same format set in the MADCTL
|
||||
* if disabling the rgb_is_inverted option.
|
||||
* Or not so, reporting pixel format as RGB if MADCTL setting
|
||||
* is BGR. And also vice versa.
|
||||
* It is a workaround for supporting buggy modules that display RGB as BGR.
|
||||
*/
|
||||
if (!(config->madctl & ST7735R_MADCTL_BGR) != !config->rgb_is_inverted) {
|
||||
capabilities->supported_pixel_formats = PIXEL_FORMAT_BGR_565;
|
||||
capabilities->current_pixel_format = PIXEL_FORMAT_BGR_565;
|
||||
} else {
|
||||
|
@ -551,6 +561,7 @@ static const struct display_driver_api st7735r_api = {
|
|||
.gamctrp1 = DT_INST_PROP(inst, gamctrp1), \
|
||||
.gamctrn1 = DT_INST_PROP(inst, gamctrn1), \
|
||||
.inversion_on = DT_INST_PROP(inst, inversion_on), \
|
||||
.rgb_is_inverted = DT_INST_PROP(inst, rgb_is_inverted), \
|
||||
}; \
|
||||
\
|
||||
static struct st7735r_data st7735r_data_ ## inst = { \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue