Skip to contentSkip to conversation

drm/mediatek: dp: Add sdp path reset

PATCH Superseded Liankun Yang 3 participants 3 messages Sep 25, 2024 – Oct 23, 2024

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/mediatek: dp: Add sdp path reset

When using type-c to type-c to connect to the monitor,
the sound plays normally. If you unplug the type-c and connect the type-c to hdmi dongle to the monitor, there will be noise.

By capturing the audio data, it is found that
the data position is messy, and there is no error in the data.

Through experiments, it can be restored by resetting the SDP path when unplugging it.

---
Changes in V3:
- No change.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Changes in V2:
- Fix build error.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

---
 drivers/gpu/drm/mediatek/mtk_dp.c     | 15 +++++++++++++++
 drivers/gpu/drm/mediatek/mtk_dp_reg.h |  1 +
 2 files changed, 16 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +15 -0
index d8796a904eca..4003bd83f64e 100644
@@ -1052,6 +1052,18 @@ static void mtk_dp_digital_sw_reset(struct mtk_dp *mtk_dp)
 			   0, DP_TX_TRANSMITTER_4P_RESET_SW_DP_TRANS_P0);
 }
 
+static void mtk_dp_sdp_path_reset(struct mtk_dp *mtk_dp)
+{
+	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004,
+				SDP_RESET_SW_DP_ENC0_P0,
+				SDP_RESET_SW_DP_ENC0_P0);
+
+	/* Wait for sdp path reset to complete */
+	usleep_range(1000, 5000);
+	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004,
+				0, SDP_RESET_SW_DP_ENC0_P0);
+}
+
 static void mtk_dp_set_lanes(struct mtk_dp *mtk_dp, int lanes)
 {
 	mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_35F0,
@@ -2314,6 +2326,9 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge,
 			   DP_PWR_STATE_BANDGAP_TPLL,
 			   DP_PWR_STATE_MASK);
 
+	/* SDP path reset sw*/
+	mtk_dp_sdp_path_reset(mtk_dp);
+
 	/* Ensure the sink is muted */
 	msleep(20);
 }
drivers/gpu/drm/mediatek/mtk_dp_reg.h +1 -0
index 709b79480693..8ad7a9cc259e 100644
@@ -86,6 +86,7 @@
 #define MTK_DP_ENC0_P0_3004			0x3004
 #define VIDEO_M_CODE_SEL_DP_ENC0_P0_MASK		BIT(8)
 #define DP_TX_ENCODER_4P_RESET_SW_DP_ENC0_P0		BIT(9)
+#define SDP_RESET_SW_DP_ENC0_P0				BIT(13)
 #define MTK_DP_ENC0_P0_3010			0x3010
 #define HTOTAL_SW_DP_ENC0_P0_MASK			GENMASK(15, 0)
 #define MTK_DP_ENC0_P0_3014			0x3014
Signature · 1 line
2.45.2
#1 lore raw
Quoted 7 lines · Liankun Yang

When using type-c to type-c to connect to the monitor,
the sound plays normally. If you unplug the type-c and connect the type-c to hdmi dongle to the monitor, there will be noise.

By capturing the audio data, it is found that
the data position is messy, and there is no error in the data.

Quoted 8 lines

Through experiments, it can be restored by resetting the SDP path when unplugging it.

---
Changes in V3:
- No change.

If there are no changes, why did you increase the revision?

Quoted 2 lines

Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

The link points to some other patch. Please consider using b4 tool, it will manage changelogs and links for you.

Quoted 10 lines

Changes in V2:
- Fix build error.
Per suggestion from the previous thread:
https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

---
 drivers/gpu/drm/mediatek/mtk_dp.c     | 15 +++++++++++++++
 drivers/gpu/drm/mediatek/mtk_dp_reg.h |  1 +
 2 files changed, 16 insertions(+)
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
In reply to Liankun Yang

Hi, Liankun:

Quoted 32 lines · Liankun Yang

When using type-c to type-c to connect to the monitor,
the sound plays normally. If you unplug the type-c and connect the type-c to hdmi dongle to the monitor, there will be noise.

By capturing the audio data, it is found that
the data position is messy, and there is no error in the data.

Through experiments, it can be restored by resetting the SDP path when unplugging it.

---
Changes in V3:
- No change.
Per suggestion from the previous thread:
https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/__;!!CTRNKA9wMg0ARbw!mhcYHA4m2S6EpGvYUubMl7eBLyt7SADiPTyQhOa7f0UFswazF0-Y8-lftFpGssdap12777TirJM-pRD_8EvyLSs$

Changes in V2:
- Fix build error.
Per suggestion from the previous thread:
https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/__;!!CTRNKA9wMg0ARbw!mhcYHA4m2S6EpGvYUubMl7eBLyt7SADiPTyQhOa7f0UFswazF0-Y8-lftFpGssdap12777TirJM-pRD_DlpQdlI$

---
 drivers/gpu/drm/mediatek/mtk_dp.c     | 15 +++++++++++++++
 drivers/gpu/drm/mediatek/mtk_dp_reg.h |  1 +
 2 files changed, 16 insertions(+)
drivers/gpu/drm/mediatek/mtk_dp.c +0 -0
index d8796a904eca..4003bd83f64e 100644

drivers/gpu/drm/mediatek/mtk_dp.c static void mtk_dp_digital_sw_reset(struct mtk_dp *mtk_dp) · line 1059

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dp.c +5 -0
@@ -1052,6 +1052,18 @@ static void mtk_dp_digital_sw_reset(struct mtk_dp *mtk_dp)
 			   0, DP_TX_TRANSMITTER_4P_RESET_SW_DP_TRANS_P0);
 }
 
+static void mtk_dp_sdp_path_reset(struct mtk_dp *mtk_dp)
+{
+	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004,
+				SDP_RESET_SW_DP_ENC0_P0,
+				SDP_RESET_SW_DP_ENC0_P0);

Align to the right of '('.

drivers/gpu/drm/mediatek/mtk_dp.c static void mtk_dp_digital_sw_reset(struct mtk_dp *mtk_dp) · line 1064

Quoted 5 lines
drivers/gpu/drm/mediatek/mtk_dp.c +5 -0
+
+	/* Wait for sdp path reset to complete */
+	usleep_range(1000, 5000);
+	mtk_dp_update_bits(mtk_dp, MTK_DP_ENC0_P0_3004,
+				0, SDP_RESET_SW_DP_ENC0_P0);

Ditto.

Regards,
CK

Quoted 27 lines
drivers/gpu/drm/mediatek/mtk_dp.c +5 -0
+}
+
 static void mtk_dp_set_lanes(struct mtk_dp *mtk_dp, int lanes)
 {
 	mtk_dp_update_bits(mtk_dp, MTK_DP_TRANS_P0_35F0,
@@ -2314,6 +2326,9 @@ static void mtk_dp_bridge_atomic_disable(struct drm_bridge *bridge,
 			   DP_PWR_STATE_BANDGAP_TPLL,
 			   DP_PWR_STATE_MASK);
 
+	/* SDP path reset sw*/
+	mtk_dp_sdp_path_reset(mtk_dp);
+
 	/* Ensure the sink is muted */
 	msleep(20);
 }
drivers/gpu/drm/mediatek/mtk_dp_reg.h +1 -0
index 709b79480693..8ad7a9cc259e 100644
@@ -86,6 +86,7 @@
 #define MTK_DP_ENC0_P0_3004			0x3004
 #define VIDEO_M_CODE_SEL_DP_ENC0_P0_MASK		BIT(8)
 #define DP_TX_ENCODER_4P_RESET_SW_DP_ENC0_P0		BIT(9)
+#define SDP_RESET_SW_DP_ENC0_P0				BIT(13)
 #define MTK_DP_ENC0_P0_3010			0x3010
 #define HTOTAL_SW_DP_ENC0_P0_MASK			GENMASK(15, 0)
 #define MTK_DP_ENC0_P0_3014			0x3014