Skip to content

Commit ce558c9

Browse files
committed
ASoC: rt722: wait codec init in hw_params
Move regmap sync to rt722_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 ace46fb commit ce558c9

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ static int rt722_sdca_update_status(struct sdw_slave *slave,
209209
enum sdw_slave_status status)
210210
{
211211
struct rt722_sdca_priv *rt722 = dev_get_drvdata(&slave->dev);
212+
int ret;
212213

213214
if (status == SDW_SLAVE_UNATTACHED)
214215
rt722->hw_init = false;
@@ -236,7 +237,12 @@ static int rt722_sdca_update_status(struct sdw_slave *slave,
236237
return 0;
237238

238239
/* perform I/O transfers required for Slave initialization */
239-
return rt722_sdca_io_init(&slave->dev, slave);
240+
ret = rt722_sdca_io_init(&slave->dev, slave);
241+
if (slave->unattach_request) {
242+
regcache_cache_only(rt722->regmap, false);
243+
regcache_sync(rt722->regmap);
244+
}
245+
return ret;
240246
}
241247

242248
static int rt722_sdca_read_prop(struct sdw_slave *slave)
@@ -495,13 +501,10 @@ static int rt722_sdca_dev_system_suspend(struct device *dev)
495501
return rt722_sdca_dev_suspend(dev);
496502
}
497503

498-
#define RT722_PROBE_TIMEOUT 5000
499-
500504
static int rt722_sdca_dev_resume(struct device *dev)
501505
{
502506
struct sdw_slave *slave = dev_to_sdw_dev(dev);
503507
struct rt722_sdca_priv *rt722 = dev_get_drvdata(dev);
504-
unsigned long time;
505508

506509
if (!rt722->first_hw_init)
507510
return 0;
@@ -516,15 +519,7 @@ static int rt722_sdca_dev_resume(struct device *dev)
516519
mutex_unlock(&rt722->disable_irq_lock);
517520
goto regmap_sync;
518521
}
519-
520-
time = wait_for_completion_timeout(&slave->initialization_complete,
521-
msecs_to_jiffies(RT722_PROBE_TIMEOUT));
522-
if (!time) {
523-
dev_err(&slave->dev, "Initialization not complete, timed out\n");
524-
sdw_show_ping_status(slave->bus, true);
525-
526-
return -ETIMEDOUT;
527-
}
522+
return 0;
528523

529524
regmap_sync:
530525
slave->unattach_request = 0;

sound/soc/codecs/rt722-sdca.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,8 @@ static void rt722_sdca_shutdown(struct snd_pcm_substream *substream,
11141114
snd_soc_dai_set_dma_data(dai, substream, NULL);
11151115
}
11161116

1117+
#define RT722_PROBE_TIMEOUT 5000
1118+
11171119
static int rt722_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
11181120
struct snd_pcm_hw_params *params,
11191121
struct snd_soc_dai *dai)
@@ -1168,6 +1170,10 @@ static int rt722_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
11681170
port_config.ch_mask = GENMASK(num_channels - 1, 0);
11691171
port_config.num = port;
11701172

1173+
retval = sdw_slave_wait_for_initialization(rt722->slave, RT722_PROBE_TIMEOUT);
1174+
if (retval < 0)
1175+
return retval;
1176+
11711177
retval = sdw_stream_add_slave(rt722->slave, &stream_config,
11721178
&port_config, 1, sdw_stream);
11731179
if (retval) {

0 commit comments

Comments
 (0)