Skip to content

Commit 2334b9b

Browse files
committed
ASoC: rt1320: wait codec init in hw_params
Move regmap sync to rt1320_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 78bcf2c commit 2334b9b

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

sound/soc/codecs/rt1320-sdw.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,7 @@ static int rt1320_update_status(struct sdw_slave *slave,
759759
enum sdw_slave_status status)
760760
{
761761
struct rt1320_sdw_priv *rt1320 = dev_get_drvdata(&slave->dev);
762+
int ret;
762763

763764
if (status == SDW_SLAVE_UNATTACHED)
764765
rt1320->hw_init = false;
@@ -771,7 +772,20 @@ static int rt1320_update_status(struct sdw_slave *slave,
771772
return 0;
772773

773774
/* perform I/O transfers required for Slave initialization */
774-
return rt1320_io_init(&slave->dev, slave);
775+
ret = rt1320_io_init(&slave->dev, slave);
776+
if (ret < 0) {
777+
dev_err(&slave->dev, "IO init failed: %d\n", ret);
778+
return ret;
779+
}
780+
781+
if (slave->unattach_request) {
782+
regcache_cache_only(rt1320->regmap, false);
783+
regcache_sync(rt1320->regmap);
784+
regcache_cache_only(rt1320->mbq_regmap, false);
785+
regcache_sync(rt1320->mbq_regmap);
786+
}
787+
788+
return ret;
775789
}
776790

777791
static int rt1320_pde11_event(struct snd_soc_dapm_widget *w,
@@ -1168,6 +1182,8 @@ static void rt1320_sdw_shutdown(struct snd_pcm_substream *substream,
11681182
snd_soc_dai_set_dma_data(dai, substream, NULL);
11691183
}
11701184

1185+
#define RT1320_PROBE_TIMEOUT 5000
1186+
11711187
static int rt1320_sdw_hw_params(struct snd_pcm_substream *substream,
11721188
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
11731189
{
@@ -1210,6 +1226,10 @@ static int rt1320_sdw_hw_params(struct snd_pcm_substream *substream,
12101226
return -EINVAL;
12111227
}
12121228

1229+
retval = sdw_slave_wait_for_initialization(rt1320->sdw_slave, RT1320_PROBE_TIMEOUT);
1230+
if (retval < 0)
1231+
return retval;
1232+
12131233
if (dai->id == RT1320_AIF1)
12141234
retval = sdw_stream_add_slave(rt1320->sdw_slave, &stream_config,
12151235
&port_config, 1, sdw_stream);
@@ -1470,26 +1490,18 @@ static int rt1320_dev_suspend(struct device *dev)
14701490
return 0;
14711491
}
14721492

1473-
#define RT1320_PROBE_TIMEOUT 5000
1474-
14751493
static int rt1320_dev_resume(struct device *dev)
14761494
{
14771495
struct sdw_slave *slave = dev_to_sdw_dev(dev);
14781496
struct rt1320_sdw_priv *rt1320 = dev_get_drvdata(dev);
1479-
unsigned long time;
14801497

14811498
if (!rt1320->first_hw_init)
14821499
return 0;
14831500

14841501
if (!slave->unattach_request)
14851502
goto regmap_sync;
14861503

1487-
time = wait_for_completion_timeout(&slave->initialization_complete,
1488-
msecs_to_jiffies(RT1320_PROBE_TIMEOUT));
1489-
if (!time) {
1490-
dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
1491-
return -ETIMEDOUT;
1492-
}
1504+
return 0;
14931505

14941506
regmap_sync:
14951507
slave->unattach_request = 0;

0 commit comments

Comments
 (0)