From: Abhinav Kumar <quic_abhin...@quicinc.com>

dp_display_disable() handles special case of when monitor is
disconnected from the dongle while the dongle stays connected
thereby needing a separate function dp_ctrl_off_link_stream()
for this. However with a slight rework this can still be handled
by keeping common paths same for regular and special case.

Signed-off-by: Abhinav Kumar <quic_abhin...@quicinc.com>
Signed-off-by: Yongxing Mou <yongxing....@oss.qualcomm.com>
---
 drivers/gpu/drm/msm/dp/dp_ctrl.c    | 19 +------------------
 drivers/gpu/drm/msm/dp/dp_ctrl.h    |  3 ++-
 drivers/gpu/drm/msm/dp/dp_display.c | 10 +++++++++-
 3 files changed, 12 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 
6bfd8faa1e212c3a25964677a4462e7a3a162fa4..e1ff4c6bb4f0eed2e1ff931f12ba891cf81feffb
 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -2549,7 +2549,7 @@ int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl)
        return ret;
 }
 
-void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl)
+void msm_dp_ctrl_reinit_phy(struct msm_dp_ctrl *msm_dp_ctrl)
 {
        struct msm_dp_ctrl_private *ctrl;
        struct phy *phy;
@@ -2557,23 +2557,6 @@ void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl 
*msm_dp_ctrl)
        ctrl = container_of(msm_dp_ctrl, struct msm_dp_ctrl_private, 
msm_dp_ctrl);
        phy = ctrl->phy;
 
-       msm_dp_panel_disable_vsc_sdp(ctrl->panel);
-
-       /* set dongle to D3 (power off) mode */
-       msm_dp_link_psm_config(ctrl->link, &ctrl->panel->link_info, true);
-
-       msm_dp_ctrl_mainlink_disable(ctrl);
-
-       if (ctrl->stream_clks_on) {
-               clk_disable_unprepare(ctrl->pixel_clk);
-               ctrl->stream_clks_on = false;
-       }
-
-       dev_pm_opp_set_rate(ctrl->dev, 0);
-       msm_dp_ctrl_link_clk_disable(&ctrl->msm_dp_ctrl);
-
-       phy_power_off(phy);
-
        /* aux channel down, reinit phy */
        phy_exit(phy);
        phy_init(phy);
diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h
index 
1497f1a8fc2f00991356663c19c87eb9fad48a73..93747c0a9b3f049bc877f347f05d42b66ad0dddf
 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.h
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h
@@ -19,7 +19,6 @@ struct phy;
 int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl);
 int msm_dp_ctrl_on_stream(struct msm_dp_ctrl *msm_dp_ctrl);
 int msm_dp_ctrl_prepare_stream_on(struct msm_dp_ctrl *msm_dp_ctrl, bool 
force_link_train);
-void msm_dp_ctrl_off_link_stream(struct msm_dp_ctrl *msm_dp_ctrl);
 void msm_dp_ctrl_off(struct msm_dp_ctrl *msm_dp_ctrl);
 void msm_dp_ctrl_push_idle(struct msm_dp_ctrl *msm_dp_ctrl);
 irqreturn_t msm_dp_ctrl_isr(struct msm_dp_ctrl *msm_dp_ctrl);
@@ -46,4 +45,6 @@ void msm_dp_ctrl_core_clk_disable(struct msm_dp_ctrl 
*msm_dp_ctrl);
 void msm_dp_ctrl_enable_irq(struct msm_dp_ctrl *msm_dp_ctrl);
 void msm_dp_ctrl_disable_irq(struct msm_dp_ctrl *msm_dp_ctrl);
 
+void msm_dp_ctrl_reinit_phy(struct msm_dp_ctrl *msm_dp_ctrl);
+
 #endif /* _DP_CTRL_H_ */
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c 
b/drivers/gpu/drm/msm/dp/dp_display.c
index 
36a12150925246b168acbabf77d1206a1ef8eff5..4c74eb2915fd620868f658ccafc32030b1c208c6
 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -773,12 +773,20 @@ static int msm_dp_display_disable(struct 
msm_dp_display_private *dp)
        if (!msm_dp_display->power_on)
                return 0;
 
+       msm_dp_panel_disable_vsc_sdp(dp->panel);
+
+       /* dongle is still connected but sinks are disconnected */
        if (dp->link->sink_count == 0) {
                /*
                 * irq_hpd with sink_count = 0
                 * hdmi unplugged out of dongle
                 */
-               msm_dp_ctrl_off_link_stream(dp->ctrl);
+
+               /* set dongle to D3 (power off) mode */
+               msm_dp_link_psm_config(dp->link, &dp->panel->link_info, true);
+               msm_dp_ctrl_off(dp->ctrl);
+               /* re-init the PHY so that we can listen to Dongle disconnect */
+               msm_dp_ctrl_reinit_phy(dp->ctrl);
        } else {
                /*
                 * unplugged interrupt

-- 
2.34.1

Reply via email to