Skip to content

Commit bd1d8a5

Browse files
committed
ASoC: rt1316: wait codec init in hw_params
Move regmap sync to rt1316_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 26d3e48 commit bd1d8a5

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

sound/soc/codecs/rt1316-sdw.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ static int rt1316_update_status(struct sdw_slave *slave,
313313
enum sdw_slave_status status)
314314
{
315315
struct rt1316_sdw_priv *rt1316 = dev_get_drvdata(&slave->dev);
316+
int ret;
316317

317318
if (status == SDW_SLAVE_UNATTACHED)
318319
rt1316->hw_init = false;
@@ -325,7 +326,18 @@ static int rt1316_update_status(struct sdw_slave *slave,
325326
return 0;
326327

327328
/* perform I/O transfers required for Slave initialization */
328-
return rt1316_io_init(&slave->dev, slave);
329+
ret = rt1316_io_init(&slave->dev, slave);
330+
if (ret < 0) {
331+
dev_err(&slave->dev, "%s: I/O init failed: %d\n", __func__, ret);
332+
return ret;
333+
}
334+
335+
if (slave->unattach_request) {
336+
regcache_cache_only(rt1316->regmap, false);
337+
regcache_sync(rt1316->regmap);
338+
}
339+
340+
return ret;
329341
}
330342

331343
static int rt1316_classd_event(struct snd_soc_dapm_widget *w,
@@ -505,6 +517,8 @@ static void rt1316_sdw_shutdown(struct snd_pcm_substream *substream,
505517
snd_soc_dai_set_dma_data(dai, substream, NULL);
506518
}
507519

520+
#define RT1316_PROBE_TIMEOUT 5000
521+
508522
static int rt1316_sdw_hw_params(struct snd_pcm_substream *substream,
509523
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
510524
{
@@ -534,6 +548,10 @@ static int rt1316_sdw_hw_params(struct snd_pcm_substream *substream,
534548
else
535549
port_config.num = 2;
536550

551+
retval = sdw_slave_wait_for_initialization(rt1316->sdw_slave, RT1316_PROBE_TIMEOUT);
552+
if (retval < 0)
553+
return retval;
554+
537555
retval = sdw_stream_add_slave(rt1316->sdw_slave, &stream_config,
538556
&port_config, 1, sdw_stream);
539557
if (retval) {
@@ -742,28 +760,18 @@ static int rt1316_dev_suspend(struct device *dev)
742760
return 0;
743761
}
744762

745-
#define RT1316_PROBE_TIMEOUT 5000
746-
747763
static int rt1316_dev_resume(struct device *dev)
748764
{
749765
struct sdw_slave *slave = dev_to_sdw_dev(dev);
750766
struct rt1316_sdw_priv *rt1316 = dev_get_drvdata(dev);
751-
unsigned long time;
752767

753768
if (!rt1316->first_hw_init)
754769
return 0;
755770

756771
if (!slave->unattach_request)
757772
goto regmap_sync;
758773

759-
time = wait_for_completion_timeout(&slave->initialization_complete,
760-
msecs_to_jiffies(RT1316_PROBE_TIMEOUT));
761-
if (!time) {
762-
dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
763-
sdw_show_ping_status(slave->bus, true);
764-
765-
return -ETIMEDOUT;
766-
}
774+
return 0;
767775

768776
regmap_sync:
769777
slave->unattach_request = 0;

0 commit comments

Comments
 (0)