Skip to content

Commit 7d86ddc

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 1e17dab commit 7d86ddc

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

sound/soc/codecs/rt1320-sdw.c

Lines changed: 18 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,16 @@ 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+
777+
if (slave->unattach_request) {
778+
regcache_cache_only(rt1320->regmap, false);
779+
regcache_sync(rt1320->regmap);
780+
regcache_cache_only(rt1320->mbq_regmap, false);
781+
regcache_sync(rt1320->mbq_regmap);
782+
}
783+
784+
return ret;
775785
}
776786

777787
static int rt1320_pde11_event(struct snd_soc_dapm_widget *w,
@@ -1168,6 +1178,8 @@ static void rt1320_sdw_shutdown(struct snd_pcm_substream *substream,
11681178
snd_soc_dai_set_dma_data(dai, substream, NULL);
11691179
}
11701180

1181+
#define RT1320_PROBE_TIMEOUT 5000
1182+
11711183
static int rt1320_sdw_hw_params(struct snd_pcm_substream *substream,
11721184
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
11731185
{
@@ -1210,6 +1222,10 @@ static int rt1320_sdw_hw_params(struct snd_pcm_substream *substream,
12101222
return -EINVAL;
12111223
}
12121224

1225+
retval = sdw_slave_wait_for_initialization(rt1320->sdw_slave, RT1320_PROBE_TIMEOUT);
1226+
if (retval < 0)
1227+
return retval;
1228+
12131229
if (dai->id == RT1320_AIF1)
12141230
retval = sdw_stream_add_slave(rt1320->sdw_slave, &stream_config,
12151231
&port_config, 1, sdw_stream);
@@ -1470,26 +1486,18 @@ static int rt1320_dev_suspend(struct device *dev)
14701486
return 0;
14711487
}
14721488

1473-
#define RT1320_PROBE_TIMEOUT 5000
1474-
14751489
static int rt1320_dev_resume(struct device *dev)
14761490
{
14771491
struct sdw_slave *slave = dev_to_sdw_dev(dev);
14781492
struct rt1320_sdw_priv *rt1320 = dev_get_drvdata(dev);
1479-
unsigned long time;
14801493

14811494
if (!rt1320->first_hw_init)
14821495
return 0;
14831496

14841497
if (!slave->unattach_request)
14851498
goto regmap_sync;
14861499

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-
}
1500+
return 0;
14931501

14941502
regmap_sync:
14951503
slave->unattach_request = 0;

0 commit comments

Comments
 (0)