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

drm: bridge: ti-sn65dsi83: Retrieve the display mode from the state

Instead of storing a copy of the display mode in the sn65dsi83
structure, retrieve it from the atomic state in
sn65dsi83_atomic_enable(). This allows the removal of the .mode_set()
operation, and completes the transition to the atomic API.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Robert Foss <robert.foss@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20210621125518.13715-6-laurent.pinchart@ideasonboard.com

authored by

Laurent Pinchart and committed by
Robert Foss
1451d0e9 03ea01c0

+26 -23
+26 -23
drivers/gpu/drm/bridge/ti-sn65dsi83.c
··· 137 137 138 138 struct sn65dsi83 { 139 139 struct drm_bridge bridge; 140 - struct drm_display_mode mode; 141 140 struct device *dev; 142 141 struct regmap *regmap; 143 142 struct device_node *host_node; ··· 370 371 struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge); 371 372 struct drm_atomic_state *state = old_bridge_state->base.state; 372 373 const struct drm_bridge_state *bridge_state; 374 + const struct drm_crtc_state *crtc_state; 375 + const struct drm_display_mode *mode; 376 + struct drm_connector *connector; 377 + struct drm_crtc *crtc; 373 378 bool lvds_format_24bpp; 374 379 bool lvds_format_jeida; 375 380 unsigned int pval; ··· 411 408 break; 412 409 } 413 410 411 + /* 412 + * Retrieve the CRTC adjusted mode. This requires a little dance to go 413 + * from the bridge to the encoder, to the connector and to the CRTC. 414 + */ 415 + connector = drm_atomic_get_new_connector_for_encoder(state, 416 + bridge->encoder); 417 + crtc = drm_atomic_get_new_connector_state(state, connector)->crtc; 418 + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); 419 + mode = &crtc_state->adjusted_mode; 420 + 414 421 /* Clear reset, disable PLL */ 415 422 regmap_write(ctx->regmap, REG_RC_RESET, 0x00); 416 423 regmap_write(ctx->regmap, REG_RC_PLL_EN, 0x00); 417 424 418 425 /* Reference clock derived from DSI link clock. */ 419 426 regmap_write(ctx->regmap, REG_RC_LVDS_PLL, 420 - REG_RC_LVDS_PLL_LVDS_CLK_RANGE(sn65dsi83_get_lvds_range(ctx, &ctx->mode)) | 427 + REG_RC_LVDS_PLL_LVDS_CLK_RANGE(sn65dsi83_get_lvds_range(ctx, mode)) | 421 428 REG_RC_LVDS_PLL_HS_CLK_SRC_DPHY); 422 429 regmap_write(ctx->regmap, REG_DSI_CLK, 423 - REG_DSI_CLK_CHA_DSI_CLK_RANGE(sn65dsi83_get_dsi_range(ctx, &ctx->mode))); 430 + REG_DSI_CLK_CHA_DSI_CLK_RANGE(sn65dsi83_get_dsi_range(ctx, mode))); 424 431 regmap_write(ctx->regmap, REG_RC_DSI_CLK, 425 432 REG_RC_DSI_CLK_DSI_CLK_DIVIDER(sn65dsi83_get_dsi_div(ctx))); 426 433 ··· 444 431 regmap_write(ctx->regmap, REG_DSI_EQ, 0x00); 445 432 446 433 /* Set up sync signal polarity. */ 447 - val = (ctx->mode.flags & DRM_MODE_FLAG_NHSYNC ? 434 + val = (mode->flags & DRM_MODE_FLAG_NHSYNC ? 448 435 REG_LVDS_FMT_HS_NEG_POLARITY : 0) | 449 - (ctx->mode.flags & DRM_MODE_FLAG_NVSYNC ? 436 + (mode->flags & DRM_MODE_FLAG_NVSYNC ? 450 437 REG_LVDS_FMT_VS_NEG_POLARITY : 0); 451 438 452 439 /* Set up bits-per-pixel, 18bpp or 24bpp. */ ··· 476 463 REG_LVDS_LANE_CHB_LVDS_TERM); 477 464 regmap_write(ctx->regmap, REG_LVDS_CM, 0x00); 478 465 479 - le16val = cpu_to_le16(ctx->mode.hdisplay); 466 + le16val = cpu_to_le16(mode->hdisplay); 480 467 regmap_bulk_write(ctx->regmap, REG_VID_CHA_ACTIVE_LINE_LENGTH_LOW, 481 468 &le16val, 2); 482 - le16val = cpu_to_le16(ctx->mode.vdisplay); 469 + le16val = cpu_to_le16(mode->vdisplay); 483 470 regmap_bulk_write(ctx->regmap, REG_VID_CHA_VERTICAL_DISPLAY_SIZE_LOW, 484 471 &le16val, 2); 485 472 /* 32 + 1 pixel clock to ensure proper operation */ 486 473 le16val = cpu_to_le16(32 + 1); 487 474 regmap_bulk_write(ctx->regmap, REG_VID_CHA_SYNC_DELAY_LOW, &le16val, 2); 488 - le16val = cpu_to_le16(ctx->mode.hsync_end - ctx->mode.hsync_start); 475 + le16val = cpu_to_le16(mode->hsync_end - mode->hsync_start); 489 476 regmap_bulk_write(ctx->regmap, REG_VID_CHA_HSYNC_PULSE_WIDTH_LOW, 490 477 &le16val, 2); 491 - le16val = cpu_to_le16(ctx->mode.vsync_end - ctx->mode.vsync_start); 478 + le16val = cpu_to_le16(mode->vsync_end - mode->vsync_start); 492 479 regmap_bulk_write(ctx->regmap, REG_VID_CHA_VSYNC_PULSE_WIDTH_LOW, 493 480 &le16val, 2); 494 481 regmap_write(ctx->regmap, REG_VID_CHA_HORIZONTAL_BACK_PORCH, 495 - ctx->mode.htotal - ctx->mode.hsync_end); 482 + mode->htotal - mode->hsync_end); 496 483 regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_BACK_PORCH, 497 - ctx->mode.vtotal - ctx->mode.vsync_end); 484 + mode->vtotal - mode->vsync_end); 498 485 regmap_write(ctx->regmap, REG_VID_CHA_HORIZONTAL_FRONT_PORCH, 499 - ctx->mode.hsync_start - ctx->mode.hdisplay); 486 + mode->hsync_start - mode->hdisplay); 500 487 regmap_write(ctx->regmap, REG_VID_CHA_VERTICAL_FRONT_PORCH, 501 - ctx->mode.vsync_start - ctx->mode.vdisplay); 488 + mode->vsync_start - mode->vdisplay); 502 489 regmap_write(ctx->regmap, REG_VID_CHA_TEST_PATTERN, 0x00); 503 490 504 491 /* Enable PLL */ ··· 555 542 return MODE_OK; 556 543 } 557 544 558 - static void sn65dsi83_mode_set(struct drm_bridge *bridge, 559 - const struct drm_display_mode *mode, 560 - const struct drm_display_mode *adj) 561 - { 562 - struct sn65dsi83 *ctx = bridge_to_sn65dsi83(bridge); 563 - 564 - ctx->mode = *adj; 565 - } 566 - 567 545 #define MAX_INPUT_SEL_FORMATS 1 568 546 569 547 static u32 * ··· 588 584 .atomic_disable = sn65dsi83_atomic_disable, 589 585 .atomic_post_disable = sn65dsi83_atomic_post_disable, 590 586 .mode_valid = sn65dsi83_mode_valid, 591 - .mode_set = sn65dsi83_mode_set, 592 587 593 588 .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, 594 589 .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,