Skip to content

Commit e335027

Browse files
committed
ASoC: rt1017: wait codec init in hw_params
Move regmap sync to rt1017_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 de6e2c6 commit e335027

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ static int rt1017_sdca_update_status(struct sdw_slave *slave,
373373
enum sdw_slave_status status)
374374
{
375375
struct rt1017_sdca_priv *rt1017 = dev_get_drvdata(&slave->dev);
376+
int ret;
376377

377378
if (status == SDW_SLAVE_UNATTACHED)
378379
rt1017->hw_init = false;
@@ -385,7 +386,18 @@ static int rt1017_sdca_update_status(struct sdw_slave *slave,
385386
return 0;
386387

387388
/* perform I/O transfers required for Slave initialization */
388-
return rt1017_sdca_io_init(&slave->dev, slave);
389+
ret = rt1017_sdca_io_init(&slave->dev, slave);
390+
if (ret < 0) {
391+
dev_err(&slave->dev, "IO init failed: %d\n", ret);
392+
return ret;
393+
}
394+
395+
if (slave->unattach_request) {
396+
regcache_cache_only(rt1017->regmap, false);
397+
regcache_sync(rt1017->regmap);
398+
}
399+
400+
return ret;
389401
}
390402

391403
static const char * const rt1017_rx_data_ch_select[] = {
@@ -569,6 +581,8 @@ static void rt1017_sdca_shutdown(struct snd_pcm_substream *substream,
569581
snd_soc_dai_set_dma_data(dai, substream, NULL);
570582
}
571583

584+
#define RT1017_PROBE_TIMEOUT 5000
585+
572586
static int rt1017_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
573587
struct snd_pcm_hw_params *params,
574588
struct snd_soc_dai *dai)
@@ -616,6 +630,10 @@ static int rt1017_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
616630
params_rate(params), num_channels, snd_pcm_format_width(params_format(params)),
617631
direction, ch_mask, port);
618632

633+
retval = sdw_slave_wait_for_initialization(rt1017->sdw_slave, RT1017_PROBE_TIMEOUT);
634+
if (retval < 0)
635+
return retval;
636+
619637
retval = sdw_stream_add_slave(rt1017->sdw_slave, &stream_config,
620638
&port_config, 1, sdw_stream);
621639
if (retval) {
@@ -770,28 +788,18 @@ static int rt1017_sdca_dev_suspend(struct device *dev)
770788
return 0;
771789
}
772790

773-
#define RT1017_PROBE_TIMEOUT 5000
774-
775791
static int rt1017_sdca_dev_resume(struct device *dev)
776792
{
777793
struct sdw_slave *slave = dev_to_sdw_dev(dev);
778794
struct rt1017_sdca_priv *rt1017 = dev_get_drvdata(dev);
779-
unsigned long time;
780795

781796
if (!rt1017->first_hw_init)
782797
return 0;
783798

784799
if (!slave->unattach_request)
785800
goto regmap_sync;
786801

787-
time = wait_for_completion_timeout(&slave->initialization_complete,
788-
msecs_to_jiffies(RT1017_PROBE_TIMEOUT));
789-
if (!time) {
790-
dev_err(&slave->dev, "Initialization not complete, timed out\n");
791-
sdw_show_ping_status(slave->bus, true);
792-
793-
return -ETIMEDOUT;
794-
}
802+
return 0;
795803

796804
regmap_sync:
797805
slave->unattach_request = 0;

0 commit comments

Comments
 (0)