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.

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.

Signed-off-by: Liankun Yang <[email protected]>
---
Change in V7:
- Separate the edp part:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Change in V6:
- Fixed power on in atomic enable.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Change in V5:
- Fixed the issue that the 4th version of the patch caused DP to have no screen.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Change in V4:
- Tested the internal eDP display on MT8195 Tomato and it is fine.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Change in V3:
- Remove 'mtk_dp->enabled = false" in atomic disable.
- Remove 'mtk_dp->enabled = true" in atomic enable.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Change in V2:
- Adjust DP training timing.
- Adjust parse capabilities timing.
- Add power on/off for connect/disconnect.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
---
 drivers/gpu/drm/mediatek/mtk_dp.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c 
b/drivers/gpu/drm/mediatek/mtk_dp.c
index bef6eeb30d3e..0ba2c208811c 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -1976,6 +1976,7 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void 
*dev)
        struct mtk_dp *mtk_dp = dev;
        unsigned long flags;
        u32 status;
+       int ret;
 
        if (mtk_dp->need_debounce && mtk_dp->train_info.cable_plugged_in)
                msleep(100);
@@ -1994,9 +1995,28 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void 
*dev)
                        memset(&mtk_dp->info.audio_cur_cfg, 0,
                               sizeof(mtk_dp->info.audio_cur_cfg));
 
+                       mtk_dp->enabled = false;
+                       /* power off aux */
+                       mtk_dp_update_bits(mtk_dp, MTK_DP_TOP_PWR_STATE,
+                                          DP_PWR_STATE_BANDGAP_TPLL,
+                                          DP_PWR_STATE_MASK);
+
                        mtk_dp->need_debounce = false;
                        mod_timer(&mtk_dp->debounce_timer,
                                  jiffies + msecs_to_jiffies(100) - 1);
+               } else {
+                       mtk_dp_aux_panel_poweron(mtk_dp, true);
+
+                       ret = mtk_dp_parse_capabilities(mtk_dp);
+                       if (ret)
+                               drm_err(mtk_dp->drm_dev, "Can't parse 
capabilities\n");
+
+                       /* Training */
+                       ret = mtk_dp_training(mtk_dp);
+                       if (ret)
+                               drm_err(mtk_dp->drm_dev, "Training failed, 
%d\n", ret);
+
+                       mtk_dp->enabled = true;
                }
        }
 
-- 
2.45.2

Reply via email to