Skip to content

Commit bf9d692

Browse files
committed
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@linux.intel.com>
1 parent 2334b9b commit bf9d692

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

sound/soc/codecs/rt721-sdca-sdw.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ static int rt721_sdca_update_status(struct sdw_slave *slave,
190190
enum sdw_slave_status status)
191191
{
192192
struct rt721_sdca_priv *rt721 = dev_get_drvdata(&slave->dev);
193+
int ret;
193194

194195
if (status == SDW_SLAVE_UNATTACHED)
195196
rt721->hw_init = false;
@@ -217,7 +218,20 @@ static int rt721_sdca_update_status(struct sdw_slave *slave,
217218
return 0;
218219

219220
/* perform I/O transfers required for Slave initialization */
220-
return rt721_sdca_io_init(&slave->dev, slave);
221+
ret = rt721_sdca_io_init(&slave->dev, slave);
222+
if (ret < 0) {
223+
dev_err(&slave->dev, "IO init failed: %d\n", ret);
224+
return ret;
225+
}
226+
227+
if (slave->unattach_request) {
228+
regcache_cache_only(rt721->regmap, false);
229+
regcache_sync(rt721->regmap);
230+
regcache_cache_only(rt721->mbq_regmap, false);
231+
regcache_sync(rt721->mbq_regmap);
232+
}
233+
234+
return ret;
221235
}
222236

223237
static int rt721_sdca_read_prop(struct sdw_slave *slave)
@@ -483,13 +497,10 @@ static int rt721_sdca_dev_system_suspend(struct device *dev)
483497
return rt721_sdca_dev_suspend(dev);
484498
}
485499

486-
#define RT721_PROBE_TIMEOUT 5000
487-
488500
static int rt721_sdca_dev_resume(struct device *dev)
489501
{
490502
struct sdw_slave *slave = dev_to_sdw_dev(dev);
491503
struct rt721_sdca_priv *rt721 = dev_get_drvdata(dev);
492-
unsigned long time;
493504

494505
if (!rt721->first_hw_init)
495506
return 0;
@@ -504,15 +515,7 @@ static int rt721_sdca_dev_resume(struct device *dev)
504515
mutex_unlock(&rt721->disable_irq_lock);
505516
goto regmap_sync;
506517
}
507-
508-
time = wait_for_completion_timeout(&slave->initialization_complete,
509-
msecs_to_jiffies(RT721_PROBE_TIMEOUT));
510-
if (!time) {
511-
dev_err(&slave->dev, "Initialization not complete, timed out\n");
512-
sdw_show_ping_status(slave->bus, true);
513-
514-
return -ETIMEDOUT;
515-
}
518+
return 0;
516519

517520
regmap_sync:
518521
slave->unattach_request = 0;

sound/soc/codecs/rt721-sdca.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,8 @@ static void rt721_sdca_shutdown(struct snd_pcm_substream *substream,
12461246
snd_soc_dai_set_dma_data(dai, substream, NULL);
12471247
}
12481248

1249+
#define RT721_PROBE_TIMEOUT 5000
1250+
12491251
static int rt721_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
12501252
struct snd_pcm_hw_params *params,
12511253
struct snd_soc_dai *dai)
@@ -1300,6 +1302,10 @@ static int rt721_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
13001302
port_config.ch_mask = GENMASK(num_channels - 1, 0);
13011303
port_config.num = port;
13021304

1305+
retval = sdw_slave_wait_for_initialization(rt721->slave, RT721_PROBE_TIMEOUT);
1306+
if (retval < 0)
1307+
return retval;
1308+
13031309
retval = sdw_stream_add_slave(rt721->slave, &stream_config,
13041310
&port_config, 1, sdw_stream);
13051311
if (retval) {

0 commit comments

Comments
 (0)