Skip to content

Commit f501f43

Browse files
author
Sugar Zhang
committed
ASoC: rockchip: i2s-tdm: Optimize TRCM-resume for QUIRKS_ALWAYS_ON
On the QUIRKS_ALWAYS_ON path, we bring up the clk path on probe to achieve the clk always on function. for this situation, the refcount always true, so, we should save the stream dma state on pause and then do restore on resume. Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com> Change-Id: I8e45b78a475a468880ef2fb0b358dbdd1169ff08
1 parent 83dd3ad commit f501f43

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

sound/soc/rockchip/rockchip_i2s_tdm.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ struct rk_i2s_tdm_dev {
101101
bool mclk_calibrate;
102102
bool tdm_mode;
103103
bool tdm_fsync_half_frame;
104+
bool is_dma_active[SNDRV_PCM_STREAM_LAST + 1];
104105
unsigned int mclk_rx_freq;
105106
unsigned int mclk_tx_freq;
106107
unsigned int mclk_root0_freq;
@@ -239,6 +240,18 @@ static inline bool is_stream_active(struct rk_i2s_tdm_dev *i2s_tdm, int stream)
239240
return (val & I2S_XFER_RXS_START);
240241
}
241242

243+
static inline bool is_dma_active(struct rk_i2s_tdm_dev *i2s_tdm, int stream)
244+
{
245+
unsigned int val;
246+
247+
regmap_read(i2s_tdm->regmap, I2S_DMACR, &val);
248+
249+
if (stream == SNDRV_PCM_STREAM_PLAYBACK)
250+
return (val & I2S_DMACR_TDE_MASK);
251+
else
252+
return (val & I2S_DMACR_RDE_MASK);
253+
}
254+
242255
#ifdef HAVE_SYNC_RESET
243256
#if defined(CONFIG_ARM) && !defined(writeq)
244257
static inline void __raw_writeq(u64 val, volatile void __iomem *addr)
@@ -623,6 +636,9 @@ static void rockchip_i2s_tdm_trcm_pause(struct snd_pcm_substream *substream,
623636
int stream = substream->stream;
624637
int bstream = SNDRV_PCM_STREAM_LAST - stream;
625638

639+
/* store the current state, prepare for resume if necessary */
640+
i2s_tdm->is_dma_active[bstream] = is_dma_active(i2s_tdm, bstream);
641+
626642
/* disable dma for both tx and rx */
627643
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, stream, 0);
628644
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, bstream, 0);
@@ -638,7 +654,8 @@ static void rockchip_i2s_tdm_trcm_resume(struct snd_pcm_substream *substream,
638654
* just resume bstream, because current stream will be
639655
* startup in the trigger-cmd-START
640656
*/
641-
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, bstream, 1);
657+
if (i2s_tdm->is_dma_active[bstream])
658+
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, bstream, 1);
642659
rockchip_i2s_tdm_xfer_start(i2s_tdm, bstream);
643660
}
644661

0 commit comments

Comments
 (0)