From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: broonie@kernel.org, tiwai@suse.de, linux-sound@vger.kernel.org,
vkoul@kernel.org
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
pierre-louis.bossart@linux.dev, bard.liao@intel.com
Subject: [PATCH 06/15] ASoC: rt715-sdca: wait codec init in hw_params
Date: Thu, 26 Jun 2025 19:56:16 +0800 [thread overview]
Message-ID: <20250626115625.536423-7-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20250626115625.536423-1-yung-chuan.liao@linux.intel.com>
Move regmap sync to rt715_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@linux.intel.com>
Reviewed-by: Shuming Fan <shumingf@realtek.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
sound/soc/codecs/rt715-sdca-sdw.c | 37 +++++++++++++++++++++----------
sound/soc/codecs/rt715-sdca.c | 6 +++++
2 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/sound/soc/codecs/rt715-sdca-sdw.c b/sound/soc/codecs/rt715-sdca-sdw.c
index ce7d8955efc3..ed0e230fc009 100644
--- a/sound/soc/codecs/rt715-sdca-sdw.c
+++ b/sound/soc/codecs/rt715-sdca-sdw.c
@@ -120,6 +120,7 @@ static int rt715_sdca_update_status(struct sdw_slave *slave,
enum sdw_slave_status status)
{
struct rt715_sdca_priv *rt715 = dev_get_drvdata(&slave->dev);
+ int ret;
/*
* Perform initialization only if slave status is present and
@@ -129,7 +130,29 @@ static int rt715_sdca_update_status(struct sdw_slave *slave,
return 0;
/* perform I/O transfers required for Slave initialization */
- return rt715_sdca_io_init(&slave->dev, slave);
+ ret = rt715_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(rt715->regmap, false);
+ regcache_sync_region(rt715->regmap,
+ SDW_SDCA_CTL(FUN_JACK_CODEC, RT715_SDCA_ST_EN,
+ RT715_SDCA_ST_CTRL, CH_00),
+ SDW_SDCA_CTL(FUN_MIC_ARRAY, RT715_SDCA_SMPU_TRIG_ST_EN,
+ RT715_SDCA_SMPU_TRIG_ST_CTRL, CH_00));
+ regcache_cache_only(rt715->mbq_regmap, false);
+ regcache_sync_region(rt715->mbq_regmap, 0x2000000, 0x61020ff);
+ regcache_sync_region(rt715->mbq_regmap,
+ SDW_SDCA_CTL(FUN_JACK_CODEC, RT715_SDCA_ST_EN,
+ RT715_SDCA_ST_CTRL, CH_00),
+ SDW_SDCA_CTL(FUN_MIC_ARRAY, RT715_SDCA_SMPU_TRIG_ST_EN,
+ RT715_SDCA_SMPU_TRIG_ST_CTRL, CH_00));
+ }
+
+ return ret;
}
static int rt715_sdca_read_prop(struct sdw_slave *slave)
@@ -220,13 +243,10 @@ static int rt715_dev_suspend(struct device *dev)
return 0;
}
-#define RT715_PROBE_TIMEOUT 5000
-
static int rt715_dev_resume(struct device *dev)
{
struct sdw_slave *slave = dev_to_sdw_dev(dev);
struct rt715_sdca_priv *rt715 = dev_get_drvdata(dev);
- unsigned long time;
if (!rt715->first_hw_init)
return 0;
@@ -234,14 +254,7 @@ static int rt715_dev_resume(struct device *dev)
if (!slave->unattach_request)
goto regmap_sync;
- time = wait_for_completion_timeout(&slave->initialization_complete,
- msecs_to_jiffies(RT715_PROBE_TIMEOUT));
- if (!time) {
- dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
- sdw_show_ping_status(slave->bus, true);
-
- return -ETIMEDOUT;
- }
+ return 0;
regmap_sync:
slave->unattach_request = 0;
diff --git a/sound/soc/codecs/rt715-sdca.c b/sound/soc/codecs/rt715-sdca.c
index 7fb02654c16b..c2a08ae8df95 100644
--- a/sound/soc/codecs/rt715-sdca.c
+++ b/sound/soc/codecs/rt715-sdca.c
@@ -792,6 +792,8 @@ static void rt715_sdca_shutdown(struct snd_pcm_substream *substream,
snd_soc_dai_set_dma_data(dai, substream, NULL);
}
+#define RT715_PROBE_TIMEOUT 5000
+
static int rt715_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
@@ -830,6 +832,10 @@ static int rt715_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
return -EINVAL;
}
+ retval = sdw_slave_wait_for_initialization(rt715->slave, RT715_PROBE_TIMEOUT);
+ if (retval < 0)
+ return retval;
+
retval = sdw_stream_add_slave(rt715->slave, &stream_config,
&port_config, 1, sdw_stream);
if (retval) {
--
2.43.0
next prev parent reply other threads:[~2025-06-26 11:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 11:56 [PATCH 00/15] ASoC/soundwire: Realtek codecs: " Bard Liao
2025-06-26 11:56 ` [PATCH 01/15] soundwire: add sdw_slave_wait_for_initialization helper Bard Liao
2025-06-26 11:56 ` [PATCH 02/15] ASoC: rt722: wait codec init in hw_params Bard Liao
2025-06-26 11:56 ` [PATCH 03/15] ASoC: rt712: " Bard Liao
2025-06-26 11:56 ` [PATCH 04/15] ASoC: rt1320: " Bard Liao
2025-06-26 11:56 ` [PATCH 05/15] ASoC: rt721: " Bard Liao
2025-06-26 11:56 ` Bard Liao [this message]
2025-06-26 11:56 ` [PATCH 07/15] ASoC: rt711-sdca: " Bard Liao
2025-06-26 11:56 ` [PATCH 08/15] ASoC: rt711: " Bard Liao
2025-06-26 11:56 ` [PATCH 09/15] ASoC: rt715: " Bard Liao
2025-06-26 11:56 ` [PATCH 10/15] ASoC: rt700: " Bard Liao
2025-06-26 11:56 ` [PATCH 11/15] ASoC: rt1316: " Bard Liao
2025-06-26 11:56 ` [PATCH 12/15] ASoC: rt1318: " Bard Liao
2025-06-26 11:56 ` [PATCH 13/15] ASoC: rt1308: " Bard Liao
2025-06-26 11:56 ` [PATCH 14/15] ASoC: rt5682: " Bard Liao
2025-06-26 11:56 ` [PATCH 15/15] ASoC: rt1017: " Bard Liao
2025-06-26 12:19 ` [PATCH 00/15] ASoC/soundwire: Realtek codecs: " Pierre-Louis Bossart
2025-06-27 6:53 ` Liao, Bard
2025-07-01 10:13 ` Pierre-Louis Bossart
2025-07-01 10:33 ` Pierre-Louis Bossart
2025-07-01 11:42 ` Liao, Bard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250626115625.536423-7-yung-chuan.liao@linux.intel.com \
--to=yung-chuan.liao@linux.intel.com \
--cc=bard.liao@intel.com \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=pierre-louis.bossart@linux.dev \
--cc=tiwai@suse.de \
--cc=vinod.koul@linaro.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®