Skip to content

Commit 04726a2

Browse files
danieldegrassefabiobaltieri
authored andcommitted
drivers: display: st7796s: respect rgb_is_inverted in 8080 8 bit mode
Update ST7796s display driver to respect the setting of rgb_is_inverted in 8080 8 bit mode, as it was previously not applied for this mode. Also, simplify the logic check for 16 bit mode- the new check is functionally equivalent, but no longer inverts both boolean values. Signed-off-by: Daniel DeGrasse <[email protected]>
1 parent 3604aba commit 04726a2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

drivers/display/display_st7796s.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ static int st7796s_get_pixelfmt(const struct device *dev)
118118
* and vice versa.
119119
*/
120120
if (config->dbi_config.mode == MIPI_DBI_MODE_8080_BUS_8_BIT) {
121-
if (config->madctl & ST7796S_MADCTL_BGR) {
121+
/*
122+
* Similar to the handling for other interface modes,
123+
* invert the reported pixel format if "rgb_is_inverted"
124+
* is enabled
125+
*/
126+
if (((bool)(config->madctl & ST7796S_MADCTL_BGR)) !=
127+
config->rgb_is_inverted) {
122128
return PIXEL_FORMAT_RGB_565;
123129
} else {
124130
return PIXEL_FORMAT_BGR_565;
@@ -133,7 +139,8 @@ static int st7796s_get_pixelfmt(const struct device *dev)
133139
* if rgb_is_inverted is enabled.
134140
* It is a workaround for supporting buggy modules that display RGB as BGR.
135141
*/
136-
if (!(config->madctl & ST7796S_MADCTL_BGR) != !config->rgb_is_inverted) {
142+
if (((bool)(config->madctl & ST7796S_MADCTL_BGR)) !=
143+
config->rgb_is_inverted) {
137144
return PIXEL_FORMAT_BGR_565;
138145
} else {
139146
return PIXEL_FORMAT_RGB_565;

0 commit comments

Comments
 (0)