Skip to content

Commit b64e7d5

Browse files
pH5superna9999
authored andcommitted
drm/panel: ilitek-ili9881c: Explicitly set address mode, allow 180° rotation
We can use horizontal and vertical flipping via the MIPI DCS address mode to rotate the display by 180° using the device tree "rotation" property. Since the tl050hdv35 panel has been defined as rotated, we have to invert the bits there. Signed-off-by: Philipp Zabel <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Link: https://lore.kernel.org/r/20240626-drm-panel-ili9881c-rotation-v1-1-e0ff54173e32@pengutronix.de Signed-off-by: Neil Armstrong <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20240626-drm-panel-ili9881c-rotation-v1-1-e0ff54173e32@pengutronix.de
1 parent 15bda06 commit b64e7d5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/gpu/drm/panel/panel-ilitek-ili9881c.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct ili9881c_desc {
4242
const size_t init_length;
4343
const struct drm_display_mode *mode;
4444
const unsigned long mode_flags;
45+
u8 default_address_mode;
4546
};
4647

4748
struct ili9881c {
@@ -53,6 +54,7 @@ struct ili9881c {
5354
struct gpio_desc *reset;
5455

5556
enum drm_panel_orientation orientation;
57+
u8 address_mode;
5658
};
5759

5860
#define ILI9881C_SWITCH_PAGE_INSTR(_page) \
@@ -815,8 +817,6 @@ static const struct ili9881c_instr tl050hdv35_init[] = {
815817
ILI9881C_COMMAND_INSTR(0xd1, 0x4b),
816818
ILI9881C_COMMAND_INSTR(0xd2, 0x60),
817819
ILI9881C_COMMAND_INSTR(0xd3, 0x39),
818-
ILI9881C_SWITCH_PAGE_INSTR(0),
819-
ILI9881C_COMMAND_INSTR(0x36, 0x03),
820820
};
821821

822822
static const struct ili9881c_instr w552946ab_init[] = {
@@ -1299,6 +1299,14 @@ static int ili9881c_prepare(struct drm_panel *panel)
12991299
if (ret)
13001300
return ret;
13011301

1302+
if (ctx->address_mode) {
1303+
ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_ADDRESS_MODE,
1304+
&ctx->address_mode,
1305+
sizeof(ctx->address_mode));
1306+
if (ret < 0)
1307+
return ret;
1308+
}
1309+
13021310
ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
13031311
if (ret)
13041312
return ret;
@@ -1521,6 +1529,12 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
15211529
return ret;
15221530
}
15231531

1532+
ctx->address_mode = ctx->desc->default_address_mode;
1533+
if (ctx->orientation == DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP) {
1534+
ctx->address_mode ^= 0x03;
1535+
ctx->orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
1536+
}
1537+
15241538
ctx->panel.prepare_prev_first = true;
15251539

15261540
ret = drm_panel_of_backlight(&ctx->panel);
@@ -1572,6 +1586,7 @@ static const struct ili9881c_desc tl050hdv35_desc = {
15721586
.mode = &tl050hdv35_default_mode,
15731587
.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
15741588
MIPI_DSI_MODE_LPM,
1589+
.default_address_mode = 0x03,
15751590
};
15761591

15771592
static const struct ili9881c_desc w552946aba_desc = {

0 commit comments

Comments
 (0)