Skip to content

Commit 62b2f02

Browse files
committed
drm/bridge: adv7533: Change number of DSI lanes dynamically
Lower modes on ADV7533 require lower number of DSI lanes for correct operation. If ADV7533 is being used with 4 DSI lanes, then switch the lanes to 3 when the target mode's pixel clock is less than 80 Mhz. Based on patch by Andy Green <[email protected]> Signed-off-by: Archit Taneja <[email protected]>
1 parent 78fa479 commit 62b2f02

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

drivers/gpu/drm/bridge/adv7511/adv7511.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ struct adv7511 {
339339
#ifdef CONFIG_DRM_I2C_ADV7533
340340
void adv7533_dsi_power_on(struct adv7511 *adv);
341341
void adv7533_dsi_power_off(struct adv7511 *adv);
342+
void adv7533_mode_set(struct adv7511 *adv, struct drm_display_mode *mode);
342343
int adv7533_patch_registers(struct adv7511 *adv);
343344
void adv7533_uninit_cec(struct adv7511 *adv);
344345
int adv7533_init_cec(struct adv7511 *adv);
@@ -354,6 +355,11 @@ static inline void adv7533_dsi_power_off(struct adv7511 *adv)
354355
{
355356
}
356357

358+
static inline void adv7533_mode_set(struct adv7511 *adv,
359+
struct drm_display_mode *mode)
360+
{
361+
}
362+
357363
static inline int adv7533_patch_registers(struct adv7511 *adv)
358364
{
359365
return -ENODEV;

drivers/gpu/drm/bridge/adv7511/adv7511_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ static void adv7511_mode_set(struct adv7511 *adv7511,
712712
regmap_update_bits(adv7511->regmap, 0x17,
713713
0x60, (vsync_polarity << 6) | (hsync_polarity << 5));
714714

715+
if (adv7511->type == ADV7533)
716+
adv7533_mode_set(adv7511, adj_mode);
717+
715718
drm_mode_copy(&adv7511->curr_mode, adj_mode);
716719

717720
/*

drivers/gpu/drm/bridge/adv7511/adv7533.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ void adv7533_dsi_power_off(struct adv7511 *adv)
115115
regmap_write(adv->regmap_cec, 0x27, 0x0b);
116116
}
117117

118+
void adv7533_mode_set(struct adv7511 *adv, struct drm_display_mode *mode)
119+
{
120+
struct mipi_dsi_device *dsi = adv->dsi;
121+
int lanes, ret;
122+
123+
if (adv->num_dsi_lanes != 4)
124+
return;
125+
126+
if (mode->clock > 80000)
127+
lanes = 4;
128+
else
129+
lanes = 3;
130+
131+
if (lanes != dsi->lanes) {
132+
mipi_dsi_detach(dsi);
133+
dsi->lanes = lanes;
134+
ret = mipi_dsi_attach(dsi);
135+
if (ret)
136+
dev_err(&dsi->dev, "failed to change host lanes\n");
137+
}
138+
}
139+
118140
int adv7533_patch_registers(struct adv7511 *adv)
119141
{
120142
return regmap_register_patch(adv->regmap,

0 commit comments

Comments
 (0)