Skip to content

Commit f97e7f4

Browse files
committed
ASoC: rt711-sdca: wait codec init in hw_params
Move regmap sync to rt711_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 47f6c5d commit f97e7f4

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static int rt711_sdca_update_status(struct sdw_slave *slave,
142142
enum sdw_slave_status status)
143143
{
144144
struct rt711_sdca_priv *rt711 = dev_get_drvdata(&slave->dev);
145+
int ret;
145146

146147
if (status == SDW_SLAVE_UNATTACHED)
147148
rt711->hw_init = false;
@@ -169,7 +170,20 @@ static int rt711_sdca_update_status(struct sdw_slave *slave,
169170
return 0;
170171

171172
/* perform I/O transfers required for Slave initialization */
172-
return rt711_sdca_io_init(&slave->dev, slave);
173+
ret = rt711_sdca_io_init(&slave->dev, slave);
174+
if (ret < 0) {
175+
dev_err(&slave->dev, "IO init failed: %d\n", ret);
176+
return ret;
177+
}
178+
179+
if (slave->unattach_request) {
180+
regcache_cache_only(rt711->regmap, false);
181+
regcache_sync(rt711->regmap);
182+
regcache_cache_only(rt711->mbq_regmap, false);
183+
regcache_sync(rt711->mbq_regmap);
184+
}
185+
186+
return ret;
173187
}
174188

175189
static int rt711_sdca_read_prop(struct sdw_slave *slave)
@@ -434,13 +448,10 @@ static int rt711_sdca_dev_system_suspend(struct device *dev)
434448
return rt711_sdca_dev_suspend(dev);
435449
}
436450

437-
#define RT711_PROBE_TIMEOUT 5000
438-
439451
static int rt711_sdca_dev_resume(struct device *dev)
440452
{
441453
struct sdw_slave *slave = dev_to_sdw_dev(dev);
442454
struct rt711_sdca_priv *rt711 = dev_get_drvdata(dev);
443-
unsigned long time;
444455

445456
if (!rt711->first_hw_init)
446457
return 0;
@@ -456,14 +467,7 @@ static int rt711_sdca_dev_resume(struct device *dev)
456467
goto regmap_sync;
457468
}
458469

459-
time = wait_for_completion_timeout(&slave->initialization_complete,
460-
msecs_to_jiffies(RT711_PROBE_TIMEOUT));
461-
if (!time) {
462-
dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
463-
sdw_show_ping_status(slave->bus, true);
464-
465-
return -ETIMEDOUT;
466-
}
470+
return 0;
467471

468472
regmap_sync:
469473
slave->unattach_request = 0;

sound/soc/codecs/rt711-sdca.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,8 @@ static void rt711_sdca_shutdown(struct snd_pcm_substream *substream,
13271327
snd_soc_dai_set_dma_data(dai, substream, NULL);
13281328
}
13291329

1330+
#define RT711_PROBE_TIMEOUT 5000
1331+
13301332
static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
13311333
struct snd_pcm_hw_params *params,
13321334
struct snd_soc_dai *dai)
@@ -1362,6 +1364,10 @@ static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
13621364
return -EINVAL;
13631365
}
13641366

1367+
retval = sdw_slave_wait_for_initialization(rt711->slave, RT711_PROBE_TIMEOUT);
1368+
if (retval < 0)
1369+
return retval;
1370+
13651371
retval = sdw_stream_add_slave(rt711->slave, &stream_config,
13661372
&port_config, 1, sdw_stream);
13671373
if (retval) {

0 commit comments

Comments
 (0)