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

drm/panel: sitronix-st7789v: add support for partial mode

The ST7789V controller features support for the partial mode. Here,
the area to be displayed can be restricted in one direction (by default,
in vertical direction). This is useful for panels that are partially
occluded by design. Add support for the partial mode.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230718-feature-lcd-panel-v2-3-2485ca07b49d@wolfvision.net

authored by

Michael Riesch and committed by
Neil Armstrong
a82db604 a5382e35

+41 -2
+41 -2
drivers/gpu/drm/panel/panel-sitronix-st7789v.c
··· 118 118 u32 bus_format; 119 119 u32 bus_flags; 120 120 bool invert_mode; 121 + bool partial_mode; 122 + u16 partial_start; 123 + u16 partial_end; 121 124 }; 122 125 123 126 struct st7789v { ··· 348 345 static int st7789v_prepare(struct drm_panel *panel) 349 346 { 350 347 struct st7789v *ctx = panel_to_st7789v(panel); 351 - u8 pixel_fmt, polarity; 348 + u8 mode, pixel_fmt, polarity; 352 349 int ret; 350 + 351 + if (!ctx->info->partial_mode) 352 + mode = ST7789V_RGBCTRL_WO; 353 + else 354 + mode = 0; 353 355 354 356 switch (ctx->info->bus_format) { 355 357 case MEDIA_BUS_FMT_RGB666_1X18: ··· 495 487 MIPI_DCS_EXIT_INVERT_MODE)); 496 488 } 497 489 490 + if (ctx->info->partial_mode) { 491 + u8 area_data[4] = { 492 + (ctx->info->partial_start >> 8) & 0xff, 493 + (ctx->info->partial_start >> 0) & 0xff, 494 + ((ctx->info->partial_end - 1) >> 8) & 0xff, 495 + ((ctx->info->partial_end - 1) >> 0) & 0xff, 496 + }; 497 + 498 + /* Caution: if userspace ever pushes a mode different from the 499 + * expected one (i.e., the one advertised by get_modes), we'll 500 + * add margins. 501 + */ 502 + 503 + ST7789V_TEST(ret, st7789v_write_command( 504 + ctx, MIPI_DCS_ENTER_PARTIAL_MODE)); 505 + 506 + ST7789V_TEST(ret, st7789v_write_command( 507 + ctx, MIPI_DCS_SET_PAGE_ADDRESS)); 508 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[0])); 509 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[1])); 510 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[2])); 511 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[3])); 512 + 513 + ST7789V_TEST(ret, st7789v_write_command( 514 + ctx, MIPI_DCS_SET_PARTIAL_ROWS)); 515 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[0])); 516 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[1])); 517 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[2])); 518 + ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[3])); 519 + } 520 + 498 521 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_RAMCTRL_CMD)); 499 522 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RAMCTRL_DM_RGB | 500 523 ST7789V_RAMCTRL_RM_RGB)); ··· 533 494 ST7789V_RAMCTRL_MAGIC)); 534 495 535 496 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_RGBCTRL_CMD)); 536 - ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_WO | 497 + ST7789V_TEST(ret, st7789v_write_data(ctx, mode | 537 498 ST7789V_RGBCTRL_RCM(2) | 538 499 polarity)); 539 500 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_VBP(8)));