Skip to content

Commit 65155d1

Browse files
yangliankun1Chun-Kuang Hu
authored andcommitted
drm/mediatek: Move DP training to hotplug thread
By adjusting the order of link training and relocating it to HPD, link training can identify the usability of each lane in the current link. It also supports handling signal instability and weakness due to environmental issues, enabling the acquisition of a stable bandwidth for the current link. Subsequently, DP work can proceed based on the actual maximum bandwidth. It should training in the hpd event thread. Check the mode with lane count and link rate of training. If we're eDP and capabilities were already parsed we can skip reading again because eDP panels aren't hotpluggable hence the caps and training information won't ever change in a boot life Therefore, bridge typec judgment is required for edp training in atomic_enable function. `mtk_dp_parse_capabilities` is related to DP training, it is used in `mtk_dp_hpd_event_thread` before DP training, and then only used by eDP when read edid. -Modify part of in `mtk_dp_bridge_atomic_disable` if (mtk_dp->train_info.cable_plugged_in) { drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); usleep_range(2000, 3000); } /* power off aux */ mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, DP_PWR_STATE_BANDGAP_TPLL, DP_PWR_STATE_MASK); -Modify part of in `mtk_dp_aux_panel_poweron(mtk_dp, false);` if (pwron) { .... } else { /* power off panel */ drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3); usleep_range(2000, 3000); /* power off aux */ mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE, DP_PWR_STATE_BANDGAP_TPLL, DP_PWR_STATE_MASK); } The `mtk_dp_aux_panel_poweron` function fails to align. Within the `mtk_dp_hpd_event_thread`, if DP is disconnected, the `mtk_dp_aux_panel_poweron` function will write from `aux` to `DPRX`, causing a failure and thus preventing symmetry. This shows the current timings after the DP cable is plugged in, as well as the modified timings. current timings: Fix timings: mtk_dp_hpd_event_thread() mtk_dp_hpd_event_thread() (including DP link training) | | ... ... mtk_dp_bridge_mode_valid() mtk_dp_bridge_mode_valid() | ... ... mtk_dp_bridge_atomic_check() mtk_dp_bridge_atomic_check() | ... ... mtk_dp_bridge_atomic_enable() mtk_dp_bridge_atomic_enable() (including DP link training) PS: 1. "..." represents ommited steps; 2. `mtk_dp_bridge_mode_valid()` calculates the bandwidth using the current lane count and link rate, and then filters each mode to determine if it supports returning a status. 3. In the `drm_display_mode_to_videomode(&crtc_state->adjusted_mode, &mtk_dp->info.vm);` function, within the `mtk_dp_bridge_atomic_check()` function, `adjusted_mode` sets the currently selected display mode for the DRM. 4. DP link training tests the signal conditions of the link between DPTX and DPRX, and selects the lane count and link rate that meet the signal conditions. 5. For example, the platform support DP 4lane 5.4G, but panel A support DP 2lane 5.4G. This is a time sequence: a).Plug in panel A. According to the platform, it can output 4K60Hz. b).Timing mode set 4K 60Hz(Including in mtk_dp_bridge_atomic_check function). c).Atomic enable(Based on panel A ability, training pass 2lane 5.4G). d).Finally, due to 2lane 5.4G bandwidth limitation, the platform cannot output 4K 60Hz, resulting in a black sreen. If apply this patch. a).Plug in panel A. b).Training pass 2lane 5.4G c).Timing mode set 2K 60Hz(Based on the 2lane 5.4G bandwidth limit and including in mtk_dp_bridge_atomic_che Signed-off-by: Liankun Yang <liankun.yang@mediatek.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/20251223061755.7717-1-liankun.yang@mediatek.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent f9c68b1 commit 65155d1

1 file changed

Lines changed: 38 additions & 19 deletions

File tree

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,7 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)
19761976
struct mtk_dp *mtk_dp = dev;
19771977
unsigned long flags;
19781978
u32 status;
1979+
int ret;
19791980

19801981
if (mtk_dp->need_debounce && mtk_dp->train_info.cable_plugged_in)
19811982
msleep(100);
@@ -1994,9 +1995,28 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)
19941995
memset(&mtk_dp->info.audio_cur_cfg, 0,
19951996
sizeof(mtk_dp->info.audio_cur_cfg));
19961997

1998+
mtk_dp->enabled = false;
1999+
/* power off aux */
2000+
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
2001+
DP_PWR_STATE_BANDGAP_TPLL,
2002+
DP_PWR_STATE_MASK);
2003+
19972004
mtk_dp->need_debounce = false;
19982005
mod_timer(&mtk_dp->debounce_timer,
19992006
jiffies + msecs_to_jiffies(100) - 1);
2007+
} else {
2008+
mtk_dp_aux_panel_poweron(mtk_dp, true);
2009+
2010+
ret = mtk_dp_parse_capabilities(mtk_dp);
2011+
if (ret)
2012+
drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
2013+
2014+
/* Training */
2015+
ret = mtk_dp_training(mtk_dp);
2016+
if (ret)
2017+
drm_err(mtk_dp->drm_dev, "Training failed, %d\n", ret);
2018+
2019+
mtk_dp->enabled = true;
20002020
}
20012021
}
20022022

@@ -2168,7 +2188,8 @@ static const struct drm_edid *mtk_dp_edid_read(struct drm_bridge *bridge,
21682188
* Parse capability here to let atomic_get_input_bus_fmts and
21692189
* mode_valid use the capability to calculate sink bitrates.
21702190
*/
2171-
if (mtk_dp_parse_capabilities(mtk_dp)) {
2191+
if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP &&
2192+
mtk_dp_parse_capabilities(mtk_dp)) {
21722193
drm_err(mtk_dp->drm_dev, "Can't parse capabilities\n");
21732194
drm_edid_free(drm_edid);
21742195
drm_edid = NULL;
@@ -2366,13 +2387,15 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,
23662387
return;
23672388
}
23682389

2369-
mtk_dp_aux_panel_poweron(mtk_dp, true);
2390+
if (mtk_dp->data->bridge_type == DRM_MODE_CONNECTOR_eDP) {
2391+
mtk_dp_aux_panel_poweron(mtk_dp, true);
23702392

2371-
/* Training */
2372-
ret = mtk_dp_training(mtk_dp);
2373-
if (ret) {
2374-
drm_err(mtk_dp->drm_dev, "Training failed, %d\n", ret);
2375-
goto power_off_aux;
2393+
/* Training */
2394+
ret = mtk_dp_training(mtk_dp);
2395+
if (ret) {
2396+
drm_err(mtk_dp->drm_dev, "Training failed, %d\n", ret);
2397+
goto power_off_aux;
2398+
}
23762399
}
23772400

23782401
ret = mtk_dp_video_config(mtk_dp);
@@ -2392,7 +2415,9 @@ static void mtk_dp_bridge_atomic_enable(struct drm_bridge *bridge,
23922415
sizeof(mtk_dp->info.audio_cur_cfg));
23932416
}
23942417

2395-
mtk_dp->enabled = true;
2418+
if (mtk_dp->data->bridge_type == DRM_MODE_CONNECTOR_eDP)
2419+
mtk_dp->enabled = true;
2420+
23962421
mtk_dp_update_plugged_status(mtk_dp);
23972422

23982423
return;
@@ -2407,21 +2432,15 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge,
24072432
{
24082433
struct mtk_dp *mtk_dp = mtk_dp_from_bridge(bridge);
24092434

2410-
mtk_dp->enabled = false;
2435+
if (mtk_dp->data->bridge_type == DRM_MODE_CONNECTOR_eDP) {
2436+
mtk_dp->enabled = false;
2437+
mtk_dp_aux_panel_poweron(mtk_dp, false);
2438+
}
2439+
24112440
mtk_dp_update_plugged_status(mtk_dp);
24122441
mtk_dp_video_enable(mtk_dp, false);
24132442
mtk_dp_audio_mute(mtk_dp, true);
24142443

2415-
if (mtk_dp->train_info.cable_plugged_in) {
2416-
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_SET_POWER, DP_SET_POWER_D3);
2417-
usleep_range(2000, 3000);
2418-
}
2419-
2420-
/* power off aux */
2421-
mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
2422-
DP_PWR_STATE_BANDGAP_TPLL,
2423-
DP_PWR_STATE_MASK);
2424-
24252444
/* SDP path reset sw*/
24262445
mtk_dp_sdp_path_reset(mtk_dp);
24272446

0 commit comments

Comments
 (0)