Skip to content

Commit 26d3e48

Browse files
committed
ASoC: rt700: wait codec init in hw_params
Move regmap sync to rt700_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 63e9bd4 commit 26d3e48

2 files changed

Lines changed: 21 additions & 12 deletions

File tree

sound/soc/codecs/rt700-sdw.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ static int rt700_update_status(struct sdw_slave *slave,
314314
enum sdw_slave_status status)
315315
{
316316
struct rt700_priv *rt700 = dev_get_drvdata(&slave->dev);
317+
int ret;
317318

318319
if (status == SDW_SLAVE_UNATTACHED)
319320
rt700->hw_init = false;
@@ -326,7 +327,19 @@ static int rt700_update_status(struct sdw_slave *slave,
326327
return 0;
327328

328329
/* perform I/O transfers required for Slave initialization */
329-
return rt700_io_init(&slave->dev, slave);
330+
ret = rt700_io_init(&slave->dev, slave);
331+
if (ret < 0) {
332+
dev_err(&slave->dev, "I/O init failed: %d\n", ret);
333+
return ret;
334+
}
335+
336+
if (slave->unattach_request) {
337+
regcache_cache_only(rt700->regmap, false);
338+
regcache_sync_region(rt700->regmap, 0x3000, 0x8fff);
339+
regcache_sync_region(rt700->regmap, 0x752010, 0x75206b);
340+
}
341+
342+
return ret;
330343
}
331344

332345
static int rt700_read_prop(struct sdw_slave *slave)
@@ -518,28 +531,18 @@ static int rt700_dev_system_suspend(struct device *dev)
518531
return rt700_dev_suspend(dev);
519532
}
520533

521-
#define RT700_PROBE_TIMEOUT 5000
522-
523534
static int rt700_dev_resume(struct device *dev)
524535
{
525536
struct sdw_slave *slave = dev_to_sdw_dev(dev);
526537
struct rt700_priv *rt700 = dev_get_drvdata(dev);
527-
unsigned long time;
528538

529539
if (!rt700->first_hw_init)
530540
return 0;
531541

532542
if (!slave->unattach_request)
533543
goto regmap_sync;
534544

535-
time = wait_for_completion_timeout(&slave->initialization_complete,
536-
msecs_to_jiffies(RT700_PROBE_TIMEOUT));
537-
if (!time) {
538-
dev_err(&slave->dev, "Initialization not complete, timed out\n");
539-
sdw_show_ping_status(slave->bus, true);
540-
541-
return -ETIMEDOUT;
542-
}
545+
return 0;
543546

544547
regmap_sync:
545548
slave->unattach_request = 0;

sound/soc/codecs/rt700.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,8 @@ static void rt700_shutdown(struct snd_pcm_substream *substream,
893893
snd_soc_dai_set_dma_data(dai, substream, NULL);
894894
}
895895

896+
#define RT700_PROBE_TIMEOUT 5000
897+
896898
static int rt700_pcm_hw_params(struct snd_pcm_substream *substream,
897899
struct snd_pcm_hw_params *params,
898900
struct snd_soc_dai *dai)
@@ -934,6 +936,10 @@ static int rt700_pcm_hw_params(struct snd_pcm_substream *substream,
934936
return -EINVAL;
935937
}
936938

939+
retval = sdw_slave_wait_for_initialization(rt700->slave, RT700_PROBE_TIMEOUT);
940+
if (retval < 0)
941+
return retval;
942+
937943
retval = sdw_stream_add_slave(rt700->slave, &stream_config,
938944
&port_config, 1, sdw_stream);
939945
if (retval) {

0 commit comments

Comments
 (0)