Skip to content

Commit 63e9bd4

Browse files
committed
ASoC: rt715: wait codec init in hw_params
Move regmap sync to rt715_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 e9d7221 commit 63e9bd4

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

sound/soc/codecs/rt715-sdw.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ static int rt715_update_status(struct sdw_slave *slave,
376376
enum sdw_slave_status status)
377377
{
378378
struct rt715_priv *rt715 = dev_get_drvdata(&slave->dev);
379+
int ret;
379380

380381
/*
381382
* Perform initialization only if slave status is present and
@@ -385,7 +386,19 @@ static int rt715_update_status(struct sdw_slave *slave,
385386
return 0;
386387

387388
/* perform I/O transfers required for Slave initialization */
388-
return rt715_io_init(&slave->dev, slave);
389+
ret = rt715_io_init(&slave->dev, slave);
390+
if (ret < 0) {
391+
dev_err(&slave->dev, "%s: I/O init failed: %d\n", __func__, ret);
392+
return ret;
393+
}
394+
395+
if (slave->unattach_request) {
396+
regcache_cache_only(rt715->regmap, false);
397+
regcache_sync_region(rt715->regmap, 0x3000, 0x8fff);
398+
regcache_sync_region(rt715->regmap, 0x752039, 0x752039);
399+
}
400+
401+
return ret;
389402
}
390403

391404
static int rt715_read_prop(struct sdw_slave *slave)
@@ -497,28 +510,18 @@ static int rt715_dev_suspend(struct device *dev)
497510
return 0;
498511
}
499512

500-
#define RT715_PROBE_TIMEOUT 5000
501-
502513
static int rt715_dev_resume(struct device *dev)
503514
{
504515
struct sdw_slave *slave = dev_to_sdw_dev(dev);
505516
struct rt715_priv *rt715 = dev_get_drvdata(dev);
506-
unsigned long time;
507517

508518
if (!rt715->first_hw_init)
509519
return 0;
510520

511521
if (!slave->unattach_request)
512522
goto regmap_sync;
513523

514-
time = wait_for_completion_timeout(&slave->initialization_complete,
515-
msecs_to_jiffies(RT715_PROBE_TIMEOUT));
516-
if (!time) {
517-
dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
518-
sdw_show_ping_status(slave->bus, true);
519-
520-
return -ETIMEDOUT;
521-
}
524+
return 0;
522525

523526
regmap_sync:
524527
slave->unattach_request = 0;

sound/soc/codecs/rt715.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ static void rt715_shutdown(struct snd_pcm_substream *substream,
822822
snd_soc_dai_set_dma_data(dai, substream, NULL);
823823
}
824824

825+
#define RT715_PROBE_TIMEOUT 5000
826+
825827
static int rt715_pcm_hw_params(struct snd_pcm_substream *substream,
826828
struct snd_pcm_hw_params *params,
827829
struct snd_soc_dai *dai)
@@ -858,6 +860,10 @@ static int rt715_pcm_hw_params(struct snd_pcm_substream *substream,
858860
return -EINVAL;
859861
}
860862

863+
retval = sdw_slave_wait_for_initialization(rt715->slave, RT715_PROBE_TIMEOUT);
864+
if (retval < 0)
865+
return retval;
866+
861867
retval = sdw_stream_add_slave(rt715->slave, &stream_config,
862868
&port_config, 1, sdw_stream);
863869
if (retval) {

0 commit comments

Comments
 (0)