Skip to content

Commit 1e17dab

Browse files
committed
ASoC: rt712: wait codec init in hw_params
Move regmap sync to rt712_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 ce558c9 commit 1e17dab

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

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

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ static int rt712_sdca_update_status(struct sdw_slave *slave,
157157
enum sdw_slave_status status)
158158
{
159159
struct rt712_sdca_priv *rt712 = dev_get_drvdata(&slave->dev);
160+
int ret;
160161

161162
if (status == SDW_SLAVE_UNATTACHED)
162163
rt712->hw_init = false;
@@ -184,7 +185,15 @@ static int rt712_sdca_update_status(struct sdw_slave *slave,
184185
return 0;
185186

186187
/* perform I/O transfers required for Slave initialization */
187-
return rt712_sdca_io_init(&slave->dev, slave);
188+
ret = rt712_sdca_io_init(&slave->dev, slave);
189+
190+
if (slave->unattach_request) {
191+
regcache_cache_only(rt712->regmap, false);
192+
regcache_sync(rt712->regmap);
193+
regcache_cache_only(rt712->mbq_regmap, false);
194+
regcache_sync(rt712->mbq_regmap);
195+
}
196+
return ret;
188197
}
189198

190199
static int rt712_sdca_read_prop(struct sdw_slave *slave)
@@ -446,13 +455,10 @@ static int rt712_sdca_dev_system_suspend(struct device *dev)
446455
return rt712_sdca_dev_suspend(dev);
447456
}
448457

449-
#define RT712_PROBE_TIMEOUT 5000
450-
451458
static int rt712_sdca_dev_resume(struct device *dev)
452459
{
453460
struct sdw_slave *slave = dev_to_sdw_dev(dev);
454461
struct rt712_sdca_priv *rt712 = dev_get_drvdata(dev);
455-
unsigned long time;
456462

457463
if (!rt712->first_hw_init)
458464
return 0;
@@ -468,15 +474,7 @@ static int rt712_sdca_dev_resume(struct device *dev)
468474
mutex_unlock(&rt712->disable_irq_lock);
469475
goto regmap_sync;
470476
}
471-
472-
time = wait_for_completion_timeout(&slave->initialization_complete,
473-
msecs_to_jiffies(RT712_PROBE_TIMEOUT));
474-
if (!time) {
475-
dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__);
476-
sdw_show_ping_status(slave->bus, true);
477-
478-
return -ETIMEDOUT;
479-
}
477+
return 0;
480478

481479
regmap_sync:
482480
slave->unattach_request = 0;

sound/soc/codecs/rt712-sdca.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,8 @@ static void rt712_sdca_shutdown(struct snd_pcm_substream *substream,
14511451
snd_soc_dai_set_dma_data(dai, substream, NULL);
14521452
}
14531453

1454+
#define RT712_PROBE_TIMEOUT 5000
1455+
14541456
static int rt712_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
14551457
struct snd_pcm_hw_params *params,
14561458
struct snd_soc_dai *dai)
@@ -1505,6 +1507,10 @@ static int rt712_sdca_pcm_hw_params(struct snd_pcm_substream *substream,
15051507
port_config.ch_mask = GENMASK(num_channels - 1, 0);
15061508
port_config.num = port;
15071509

1510+
retval = sdw_slave_wait_for_initialization(rt712->slave, RT712_PROBE_TIMEOUT);
1511+
if (retval < 0)
1512+
return retval;
1513+
15081514
retval = sdw_stream_add_slave(rt712->slave, &stream_config,
15091515
&port_config, 1, sdw_stream);
15101516
if (retval) {

0 commit comments

Comments
 (0)