Skip to content

Commit e9d7221

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

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

sound/soc/codecs/rt711-sdw.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ static int rt711_update_status(struct sdw_slave *slave,
320320
enum sdw_slave_status status)
321321
{
322322
struct rt711_priv *rt711 = dev_get_drvdata(&slave->dev);
323+
int ret;
323324

324325
if (status == SDW_SLAVE_UNATTACHED)
325326
rt711->hw_init = false;
@@ -332,7 +333,20 @@ static int rt711_update_status(struct sdw_slave *slave,
332333
return 0;
333334

334335
/* perform I/O transfers required for Slave initialization */
335-
return rt711_io_init(&slave->dev, slave);
336+
ret = rt711_io_init(&slave->dev, slave);
337+
if (ret < 0) {
338+
dev_err(&slave->dev, "%s: I/O init failed: %d\n",
339+
__func__, ret);
340+
return ret;
341+
}
342+
343+
if (slave->unattach_request) {
344+
regcache_cache_only(rt711->regmap, false);
345+
regcache_sync_region(rt711->regmap, 0x3000, 0x8fff);
346+
regcache_sync_region(rt711->regmap, 0x752009, 0x752091);
347+
}
348+
349+
return ret;
336350
}
337351

338352
static int rt711_read_prop(struct sdw_slave *slave)
@@ -526,13 +540,10 @@ static int rt711_dev_system_suspend(struct device *dev)
526540
return rt711_dev_suspend(dev);
527541
}
528542

529-
#define RT711_PROBE_TIMEOUT 5000
530-
531543
static int rt711_dev_resume(struct device *dev)
532544
{
533545
struct sdw_slave *slave = dev_to_sdw_dev(dev);
534546
struct rt711_priv *rt711 = dev_get_drvdata(dev);
535-
unsigned long time;
536547

537548
if (!rt711->first_hw_init)
538549
return 0;
@@ -547,12 +558,7 @@ static int rt711_dev_resume(struct device *dev)
547558
goto regmap_sync;
548559
}
549560

550-
time = wait_for_completion_timeout(&slave->initialization_complete,
551-
msecs_to_jiffies(RT711_PROBE_TIMEOUT));
552-
if (!time) {
553-
dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
554-
return -ETIMEDOUT;
555-
}
561+
return 0;
556562

557563
regmap_sync:
558564
slave->unattach_request = 0;

sound/soc/codecs/rt711.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,8 @@ static void rt711_shutdown(struct snd_pcm_substream *substream,
982982
snd_soc_dai_set_dma_data(dai, substream, NULL);
983983
}
984984

985+
#define RT711_PROBE_TIMEOUT 5000
986+
985987
static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
986988
struct snd_pcm_hw_params *params,
987989
struct snd_soc_dai *dai)
@@ -1017,6 +1019,10 @@ static int rt711_pcm_hw_params(struct snd_pcm_substream *substream,
10171019
return -EINVAL;
10181020
}
10191021

1022+
retval = sdw_slave_wait_for_initialization(rt711->slave, RT711_PROBE_TIMEOUT);
1023+
if (retval < 0)
1024+
return retval;
1025+
10201026
retval = sdw_stream_add_slave(rt711->slave, &stream_config,
10211027
&port_config, 1, sdw_stream);
10221028
if (retval) {

0 commit comments

Comments
 (0)