diff mbox series

[1/2] ASoC: rt711-sdca: fix key tone missing

Message ID 20230721082645.114050-1-shumingf@realtek.com
State New
Headers show
Series [1/2] ASoC: rt711-sdca: fix key tone missing | expand

Commit Message

Shuming [θŒƒζ›ΈιŠ˜] July 21, 2023, 8:26 a.m. UTC
From: Shuming Fan <shumingf@realtek.com>

This patch uses a bit to check whether the system was hibernated or not.
It could avoid repeating the recalibration and CBJ detection.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
---
 sound/soc/codecs/rt711-sdca-sdw.c |  1 +
 sound/soc/codecs/rt711-sdca.c     | 17 ++++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt711-sdca-sdw.c b/sound/soc/codecs/rt711-sdca-sdw.c
index 119e1f9605d7..cb27b4a98fb6 100644
--- a/sound/soc/codecs/rt711-sdca-sdw.c
+++ b/sound/soc/codecs/rt711-sdca-sdw.c
@@ -101,6 +101,7 @@  static bool rt711_sdca_mbq_volatile_register(struct device *dev, unsigned int re
 	case 0x2000080:
 	case 0x2000081:
 	case 0x2000083:
+	case 0x200009f:
 	case 0x5800000:
 	case 0x5800001:
 	case 0x5f00001:
diff --git a/sound/soc/codecs/rt711-sdca.c b/sound/soc/codecs/rt711-sdca.c
index 07640d2f6e56..f1a93e3ffa1c 100644
--- a/sound/soc/codecs/rt711-sdca.c
+++ b/sound/soc/codecs/rt711-sdca.c
@@ -488,6 +488,12 @@  static void rt711_sdca_jack_init(struct rt711_sdca_priv *rt711)
 		/* set SCP_SDCA_IntMask2[0]=1 */
 		sdw_write_no_pm(rt711->slave, SDW_SCP_SDCA_INTMASK2, SDW_SCP_SDCA_INTMASK_SDCA_8);
 		dev_dbg(&rt711->slave->dev, "in %s enable\n", __func__);
+
+		/* trigger GE interrupt */
+		rt711_sdca_index_update_bits(rt711, RT711_VENDOR_HDA_CTL,
+			RT711_GE_MODE_RELATED_CTL, 0x0080, 0x0080);
+		rt711_sdca_index_update_bits(rt711, RT711_VENDOR_HDA_CTL,
+			RT711_GE_MODE_RELATED_CTL, 0x0080, 0x0000);
 	} else {
 		/* disable HID 1/2 event */
 		rt711_sdca_index_update_bits(rt711, RT711_VENDOR_HDA_CTL,
@@ -1493,7 +1499,7 @@  int rt711_sdca_io_init(struct device *dev, struct sdw_slave *slave)
 {
 	struct rt711_sdca_priv *rt711 = dev_get_drvdata(dev);
 	int ret = 0;
-	unsigned int val;
+	unsigned int val, hibernation_flag;
 
 	rt711->disable_irq = false;
 
@@ -1525,6 +1531,11 @@  int rt711_sdca_io_init(struct device *dev, struct sdw_slave *slave)
 
 	pm_runtime_get_noresume(&slave->dev);
 
+	rt711_sdca_index_read(rt711, RT711_VENDOR_REG, 0x9f, &val);
+	hibernation_flag = (val >> 8);
+	if (hibernation_flag)
+		goto _preset_ready_;
+
 	rt711_sdca_reset(rt711);
 
 	rt711_sdca_index_read(rt711, RT711_VENDOR_REG, RT711_JD_PRODUCT_NUM, &val);
@@ -1559,6 +1570,10 @@  int rt711_sdca_io_init(struct device *dev, struct sdw_slave *slave)
 	if (rt711->hs_jack)
 		rt711_sdca_jack_init(rt711);
 
+	if (!hibernation_flag)
+		rt711_sdca_index_update_bits(rt711, RT711_VENDOR_REG, 0x9f, 0x0100, 0x0100);
+
+_preset_ready_:
 	if (rt711->first_hw_init) {
 		regcache_cache_bypass(rt711->regmap, false);
 		regcache_mark_dirty(rt711->regmap);