[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250626115625.536423-6-yung-chuan.liao@linux.intel.com>
Date: Thu, 26 Jun 2025 19:56:15 +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 05/15] ASoC: rt721: wait codec init in hw_params
Move regmap sync to rt721_sdca_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/rt721-sdca-sdw.c | 29 ++++++++++++++++-------------
sound/soc/codecs/rt721-sdca.c | 6 ++++++
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/sound/soc/codecs/rt721-sdca-sdw.c b/sound/soc/codecs/rt721-sdca-sdw.c
index 582b47d69278..342a55116771 100644
--- a/sound/soc/codecs/rt721-sdca-sdw.c
+++ b/sound/soc/codecs/rt721-sdca-sdw.c
@@ -190,6 +190,7 @@ static int rt721_sdca_update_status(struct sdw_slave *slave,
enum sdw_slave_status status)
{
struct rt721_sdca_priv *rt721 = dev_get_drvdata(&slave->dev);
+ int ret;
if (status == SDW_SLAVE_UNATTACHED)
rt721->hw_init = false;
@@ -217,7 +218,20 @@ static int rt721_sdca_update_status(struct sdw_slave *slave,
return 0;
/* perform I/O transfers required for Slave initialization */
- return rt721_sdca_io_init(&slave->dev, slave);
+ ret = rt721_sdca_io_init(&slave->dev, slave);
+ if (ret < 0) {
+ dev_err(&slave->dev, "IO init failed: %d\n", ret);
+ return ret;
+ }
+
+ if (slave->unattach_request) {
+ regcache_cache_only(rt721->regmap, false);
+ regcache_sync(rt721->regmap);
+ regcache_cache_only(rt721->mbq_regmap, false);
+ regcache_sync(rt721->mbq_regmap);
+ }
+
+ return ret;
}
static int rt721_sdca_read_prop(struct sdw_slave *slave)
@@ -483,13 +497,10 @@ static int rt721_sdca_dev_system_suspend(struct device *dev)
return rt721_sdca_dev_suspend(dev);
}
-#define RT721_PROBE_TIMEOUT 5000
-
static int rt721_sdca_dev_resume(struct device *dev)
{
struct sdw_slave *slave = dev_to_sdw_dev(dev);
struct rt721_sdca_priv *rt721 = dev_get_drvdata(dev);
- unsigned long time;
if (!rt721->first_hw_init)
return 0;
@@ -504,15 +515,7 @@ static int rt721_sdca_dev_resume(struct device *dev)
mutex_unlock(&rt721->disable_irq_lock);
goto regmap_sync;
}
-
- time = wait_for_completion_timeout(&slave->initialization_complete,
- msecs_to_jiffies(RT721_PROBE_TIMEOUT));
- if (!time) {
- dev_err(&slave->dev, "Initialization not complete, timed out\n");
- sdw_show_ping_status(slave->bus, true);
-
- return -ETIMEDOUT;
- }
+ return 0;
regmap_sync:
slave->unattach_request = 0;
diff --git a/sound/soc/codecs/rt721-sdca.c b/sound/soc/codecs/rt721-sdca.c
index ba080957e933..91a7b6f672c6 100644
--- a/sound/soc/codecs/rt721-sdca.c
+++ b/sound/soc/codecs/rt721-sdca.c
@@ -1261,6 +1261,8 @@ static void rt721_sdca_shutdown(struct snd_pcm_substream *substream,
snd_soc_dai_set_dma_data(dai, substream, NULL);
}
+#define RT721_PROBE_TIMEOUT 5000
+
static int rt721_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
@@ -1315,6 +1317,10 @@ static int rt721_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
port_config.ch_mask = GENMASK(num_channels - 1, 0);
port_config.num = port;
+ retval = sdw_slave_wait_for_initialization(rt721->slave, RT721_PROBE_TIMEOUT);
+ if (retval < 0)
+ return retval;
+
retval = sdw_stream_add_slave(rt721->slave, &stream_config,
&port_config, 1, sdw_stream);
if (retval) {
--
2.43.0
Powered by blists - more mailing lists