Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <p.zabel@pengutronix.de>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://lore.kernel.org/r/20240626-drm-panel-ili9881c-rotation-v1-1-e0ff54173e32@pengutronix.de
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240626-drm-panel-ili9881c-rotation-v1-1-e0ff54173e32@pengutronix.de

authored by

Philipp Zabel and committed by
Neil Armstrong
b64e7d59 15bda06b

+17 -2
+17 -2
drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
··· 42 42 const size_t init_length; 43 43 const struct drm_display_mode *mode; 44 44 const unsigned long mode_flags; 45 + u8 default_address_mode; 45 46 }; 46 47 47 48 struct ili9881c { ··· 54 53 struct gpio_desc *reset; 55 54 56 55 enum drm_panel_orientation orientation; 56 + u8 address_mode; 57 57 }; 58 58 59 59 #define ILI9881C_SWITCH_PAGE_INSTR(_page) \ ··· 817 815 ILI9881C_COMMAND_INSTR(0xd1, 0x4b), 818 816 ILI9881C_COMMAND_INSTR(0xd2, 0x60), 819 817 ILI9881C_COMMAND_INSTR(0xd3, 0x39), 820 - ILI9881C_SWITCH_PAGE_INSTR(0), 821 - ILI9881C_COMMAND_INSTR(0x36, 0x03), 822 818 }; 823 819 824 820 static const struct ili9881c_instr w552946ab_init[] = { ··· 1299 1299 if (ret) 1300 1300 return ret; 1301 1301 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 + 1302 1310 ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK); 1303 1311 if (ret) 1304 1312 return ret; ··· 1529 1521 return ret; 1530 1522 } 1531 1523 1524 + ctx->address_mode = ctx->desc->default_address_mode; 1525 + if (ctx->orientation == DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP) { 1526 + ctx->address_mode ^= 0x03; 1527 + ctx->orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; 1528 + } 1529 + 1532 1530 ctx->panel.prepare_prev_first = true; 1533 1531 1534 1532 ret = drm_panel_of_backlight(&ctx->panel); ··· 1586 1572 .mode = &tl050hdv35_default_mode, 1587 1573 .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | 1588 1574 MIPI_DSI_MODE_LPM, 1575 + .default_address_mode = 0x03, 1589 1576 }; 1590 1577 1591 1578 static const struct ili9881c_desc w552946aba_desc = {