Skip to content

Commit c73f512

Browse files
committed
drivers: display: issue with configuration on ILI9341
ILI9341 is not deploying correctly the display sample. The screen looks mirrored vertically and the color doesn't match with the sequence expected. To fix it, change the Memory Access Control configuration data. Signed-off-by: Nicolas Moreno <[email protected]>
1 parent 9c1fbc8 commit c73f512

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

drivers/display/display_ili9xxx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ ili9xxx_set_pixel_format(const struct device *dev,
295295
uint8_t tx_data;
296296
uint8_t bytes_per_pixel;
297297

298-
if (pixel_format == PIXEL_FORMAT_RGB_565) {
298+
if (pixel_format == PIXEL_FORMAT_RGB_565 || pixel_format == PIXEL_FORMAT_BGR_565) {
299299
bytes_per_pixel = 2U;
300300
tx_data = ILI9XXX_PIXSET_MCU_16_BIT | ILI9XXX_PIXSET_RGB_16_BIT;
301301
} else if (pixel_format == PIXEL_FORMAT_RGB_888) {
@@ -324,7 +324,8 @@ static int ili9xxx_set_orientation(const struct device *dev,
324324
struct ili9xxx_data *data = dev->data;
325325

326326
int r;
327-
uint8_t tx_data = ILI9XXX_MADCTL_BGR;
327+
uint8_t tx_data = config->pixel_format == PIXEL_FORMAT_BGR_565
328+
? ILI9XXX_MADCTL_BGR : 0;
328329
if (config->quirks->cmd_set == CMD_SET_1) {
329330
if (orientation == DISPLAY_ORIENTATION_NORMAL) {
330331
tx_data |= ILI9XXX_MADCTL_MX;
@@ -368,7 +369,7 @@ static void ili9xxx_get_capabilities(const struct device *dev,
368369
memset(capabilities, 0, sizeof(struct display_capabilities));
369370

370371
capabilities->supported_pixel_formats =
371-
PIXEL_FORMAT_RGB_565 | PIXEL_FORMAT_RGB_888;
372+
PIXEL_FORMAT_RGB_565 | PIXEL_FORMAT_RGB_888 | PIXEL_FORMAT_BGR_565;
372373
capabilities->current_pixel_format = data->pixel_format;
373374

374375
if (data->orientation == DISPLAY_ORIENTATION_NORMAL ||
@@ -394,6 +395,8 @@ static int ili9xxx_configure(const struct device *dev)
394395
/* pixel format */
395396
if (config->pixel_format == ILI9XXX_PIXEL_FORMAT_RGB565) {
396397
pixel_format = PIXEL_FORMAT_RGB_565;
398+
} else if (config->pixel_format == ILI9XXX_PIXEL_FORMAT_BGR565) {
399+
pixel_format = PIXEL_FORMAT_BGR_565;
397400
} else {
398401
pixel_format = PIXEL_FORMAT_RGB_888;
399402
}
@@ -511,7 +514,7 @@ static const struct ili9xxx_quirks ili9340_quirks = {
511514

512515
#ifdef CONFIG_ILI9341
513516
static const struct ili9xxx_quirks ili9341_quirks = {
514-
.cmd_set = CMD_SET_1,
517+
.cmd_set = CMD_SET_2,
515518
};
516519
#endif
517520

drivers/display/display_ili9xxx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
enum madctl_cmd_set {
6161
CMD_SET_1, /* Default for most of ILI9xxx display controllers */
62-
CMD_SET_2, /* Used by ILI9342c */
62+
CMD_SET_2, /* Used by ILI9342c & ILI9341 */
6363
};
6464

6565
struct ili9xxx_quirks {

dts/bindings/display/ilitek,ili9xxx-common.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ properties:
2020
enum:
2121
- 0 # RGB565
2222
- 1 # RGB888
23+
- 2 # BGR565
2324
description:
2425
Display pixel format. Note that when RGB888 pixel format is selected
2526
only 6 color bits are actually used being in practice equivalent to

include/zephyr/dt-bindings/display/ili9xxx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
/* Pixel formats */
1010
#define ILI9XXX_PIXEL_FORMAT_RGB565 0U
1111
#define ILI9XXX_PIXEL_FORMAT_RGB888 1U
12+
#define ILI9XXX_PIXEL_FORMAT_BGR565 2U
1213

1314
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_DISPLAY_ILI9XXX_H_ */

0 commit comments

Comments
 (0)