Skip to content

Commit f990347

Browse files
committed
ASoC: rt1308: wait codec init in hw_params
Move regmap sync to rt1308_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 5400221 commit f990347

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

sound/soc/codecs/rt1308-sdw.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ static int rt1308_update_status(struct sdw_slave *slave,
303303
enum sdw_slave_status status)
304304
{
305305
struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev);
306+
int ret;
306307

307308
if (status == SDW_SLAVE_UNATTACHED)
308309
rt1308->hw_init = false;
@@ -315,7 +316,18 @@ static int rt1308_update_status(struct sdw_slave *slave,
315316
return 0;
316317

317318
/* perform I/O transfers required for Slave initialization */
318-
return rt1308_io_init(&slave->dev, slave);
319+
ret = rt1308_io_init(&slave->dev, slave);
320+
if (ret < 0) {
321+
dev_err(&slave->dev, "IO init failed %d\n", ret);
322+
return ret;
323+
}
324+
325+
if (slave->unattach_request) {
326+
regcache_cache_only(rt1308->regmap, false);
327+
regcache_sync_region(rt1308->regmap, 0xc000, 0xcfff);
328+
}
329+
330+
return ret;
319331
}
320332

321333
static int rt1308_bus_config(struct sdw_slave *slave,
@@ -526,6 +538,8 @@ static int rt1308_sdw_set_tdm_slot(struct snd_soc_dai *dai,
526538
return 0;
527539
}
528540

541+
#define RT1308_PROBE_TIMEOUT 5000
542+
529543
static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream,
530544
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
531545
{
@@ -560,6 +574,10 @@ static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream,
560574
port_config.ch_mask = rt1308->rx_mask;
561575
}
562576

577+
retval = sdw_slave_wait_for_initialization(rt1308->sdw_slave, RT1308_PROBE_TIMEOUT);
578+
if (retval < 0)
579+
return retval;
580+
563581
retval = sdw_stream_add_slave(rt1308->sdw_slave, &stream_config,
564582
&port_config, 1, sdw_stream);
565583
if (retval) {
@@ -765,28 +783,18 @@ static int rt1308_dev_suspend(struct device *dev)
765783
return 0;
766784
}
767785

768-
#define RT1308_PROBE_TIMEOUT 5000
769-
770786
static int rt1308_dev_resume(struct device *dev)
771787
{
772788
struct sdw_slave *slave = dev_to_sdw_dev(dev);
773789
struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
774-
unsigned long time;
775790

776791
if (!rt1308->first_hw_init)
777792
return 0;
778793

779794
if (!slave->unattach_request)
780795
goto regmap_sync;
781796

782-
time = wait_for_completion_timeout(&slave->initialization_complete,
783-
msecs_to_jiffies(RT1308_PROBE_TIMEOUT));
784-
if (!time) {
785-
dev_err(&slave->dev, "Initialization not complete, timed out\n");
786-
sdw_show_ping_status(slave->bus, true);
787-
788-
return -ETIMEDOUT;
789-
}
797+
return 0;
790798

791799
regmap_sync:
792800
slave->unattach_request = 0;

0 commit comments

Comments
 (0)