Skip to content

Commit f985d68

Browse files
committed
ASoC: rt5682: wait codec init in hw_params
Move regmap sync to rt5682_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>
1 parent f990347 commit f985d68

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

sound/soc/codecs/rt5682-sdw.c

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ static int rt5682_sdw_hw_params(struct snd_pcm_substream *substream,
129129
else
130130
port_config.num = 2;
131131

132+
retval = sdw_slave_wait_for_initialization(rt5682->slave, RT5682_PROBE_TIMEOUT);
133+
if (retval < 0)
134+
return retval;
135+
132136
retval = sdw_stream_add_slave(rt5682->slave, &stream_config,
133137
&port_config, 1, sdw_stream);
134138
if (retval) {
@@ -513,6 +517,7 @@ static int rt5682_update_status(struct sdw_slave *slave,
513517
enum sdw_slave_status status)
514518
{
515519
struct rt5682_priv *rt5682 = dev_get_drvdata(&slave->dev);
520+
int ret;
516521

517522
if (status == SDW_SLAVE_UNATTACHED)
518523
rt5682->hw_init = false;
@@ -525,7 +530,19 @@ static int rt5682_update_status(struct sdw_slave *slave,
525530
return 0;
526531

527532
/* perform I/O transfers required for Slave initialization */
528-
return rt5682_io_init(&slave->dev, slave);
533+
ret = rt5682_io_init(&slave->dev, slave);
534+
if (ret < 0) {
535+
dev_err(&slave->dev, "IO init Failed: %d\n", ret);
536+
return ret;
537+
}
538+
539+
if (slave->unattach_request) {
540+
regcache_cache_only(rt5682->sdw_regmap, false);
541+
regcache_cache_only(rt5682->regmap, false);
542+
regcache_sync(rt5682->regmap);
543+
}
544+
545+
return ret;
529546
}
530547

531548
static int rt5682_read_prop(struct sdw_slave *slave)
@@ -757,7 +774,6 @@ static int rt5682_dev_resume(struct device *dev)
757774
{
758775
struct sdw_slave *slave = dev_to_sdw_dev(dev);
759776
struct rt5682_priv *rt5682 = dev_get_drvdata(dev);
760-
unsigned long time;
761777

762778
if (!rt5682->first_hw_init)
763779
return 0;
@@ -772,14 +788,7 @@ static int rt5682_dev_resume(struct device *dev)
772788
goto regmap_sync;
773789
}
774790

775-
time = wait_for_completion_timeout(&slave->initialization_complete,
776-
msecs_to_jiffies(RT5682_PROBE_TIMEOUT));
777-
if (!time) {
778-
dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
779-
sdw_show_ping_status(slave->bus, true);
780-
781-
return -ETIMEDOUT;
782-
}
791+
return 0;
783792

784793
regmap_sync:
785794
slave->unattach_request = 0;

0 commit comments

Comments
 (0)