[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250626115625.536423-9-yung-chuan.liao@linux.intel.com>
Date: Thu, 26 Jun 2025 19:56:18 +0800
From: Bard Liao <yung-chuan.liao@...ux.intel.com>
To: broonie@...nel.org,
tiwai@...e.de,
linux-sound@...r.kernel.org,
vkoul@...nel.org
Cc: vinod.koul@...aro.org,
linux-kernel@...r.kernel.org,
pierre-louis.bossart@...ux.dev,
bard.liao@...el.com
Subject: [PATCH 08/15] ASoC: rt711: wait codec init in hw_params
Move regmap sync to rt711_update_status() when unattach_request
is set, and only do regmap sync in resume when no reattach needed.
And move waiting codec init to hw_params when the codec really need to
be initialized. The change can shorten the resume time.
Signed-off-by: Bard Liao <yung-chuan.liao@...ux.intel.com>
Reviewed-by: Shuming Fan <shumingf@...ltek.com>
Reviewed-by: Charles Keepax <ckeepax@...nsource.cirrus.com>
---
sound/soc/codecs/rt711-sdw.c | 26 ++++++++++++++++----------
sound/soc/codecs/rt711.c | 6 ++++++
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/rt711-sdw.c b/sound/soc/codecs/rt711-sdw.c
index 93a5a89a96b1..884206850b46 100644
--- a/sound/soc/codecs/rt711-sdw.c
+++ b/sound/soc/codecs/rt711-sdw.c
@@ -320,6 +320,7 @@ static int rt711_update_status(struct sdw_slave *slave,
enum sdw_slave_status status)
{
struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev);
+ int ret;
if (status == SDW_SLAVE_UNATTACHED)
rt711->hw_init = false;
@@ -332,7 +333,20 @@ static int rt711_update_status(struct sdw_slave *slave,
return 0;
/* perform I/O transfers required for Slave initialization */
- return rt711_io_init(&slave->dev, slave);
+ ret = rt711_io_init(&slave->dev, slave);
+ if (ret < 0) {
+ dev_err(&slave->dev, "%s: I/O init failed: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ if (slave->unattach_request) {
+ regcache_cache_only(rt711->regmap, false);
+ regcache_sync_region(rt711->regmap, 0x3000, 0x8fff);
+ regcache_sync_region(rt711->regmap, 0x752009, 0x752091);
+ }
+
+ return ret;
}
static int rt711_read_prop(struct sdw_slave *slave)
@@ -526,13 +540,10 @@ static int rt711_dev_system_suspend(struct device *dev)
return rt711_dev_suspend(dev);
}
-#define RT711_PROBE_TIMEOUT 5000
-
static int rt711_dev_resume(struct device *dev)
{
struct sdw_slave *slave = dev_to_sdw_dev(dev);
struct rt711_priv *rt711 = dev_get_drvdata(dev);
- unsigned long time;
if (!rt711->first_hw_init)
return 0;
@@ -547,12 +558,7 @@ static int rt711_dev_resume(struct device *dev)
goto regmap_sync;
}
- time = wait_for_completion_timeout(&slave->initialization_complete,
- msecs_to_jiffies(RT711_PROBE_TIMEOUT));
- if (!time) {
- dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
- return -ETIMEDOUT;
- }
+ return 0;
regmap_sync:
slave->unattach_request = 0;
diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c
index 5446f9506a16..2fbd7c0227ff 100644
--- a/sound/soc/codecs/rt711.c
+++ b/sound/soc/codecs/rt711.c
@@ -982,6 +982,8 @@ static void rt711_shutdown(struct snd_pcm_substream *substream,
snd_soc_dai_set_dma_data(dai, substream, NULL);
}
+#define RT711_PROBE_TIMEOUT 5000
+
static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
@@ -1017,6 +1019,10 @@ static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}
+ retval = sdw_slave_wait_for_initialization(rt711->slave, RT711_PROBE_TIMEOUT);
+ if (retval < 0)
+ return retval;
+
retval = sdw_stream_add_slave(rt711->slave, &stream_config,
&port_config, 1, sdw_stream);
if (retval) {
--
2.43.0
Powered by blists - more mailing lists