Skip to content

Commit fa86218

Browse files
Sugar Zhangrkhuangtao
authored andcommitted
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 <[email protected]> Change-Id: I8e45b78a475a468880ef2fb0b358dbdd1169ff08
1 parent 3324809 commit fa86218

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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;
@@ -299,6 +300,18 @@ static inline bool is_stream_active(struct rk_i2s_tdm_dev *i2s_tdm, int stream)
299300
return (val & I2S_XFER_RXS_START);
300301
}
301302

303+
static inline bool is_dma_active(struct rk_i2s_tdm_dev *i2s_tdm, int stream)
304+
{
305+
unsigned int val;
306+
307+
regmap_read(i2s_tdm->regmap, I2S_DMACR, &val);
308+
309+
if (stream == SNDRV_PCM_STREAM_PLAYBACK)
310+
return (val & I2S_DMACR_TDE_MASK);
311+
else
312+
return (val & I2S_DMACR_RDE_MASK);
313+
}
314+
302315
#ifdef HAVE_SYNC_RESET
303316
#if defined(CONFIG_ARM) && !defined(writeq)
304317
static inline void __raw_writeq(u64 val, volatile void __iomem *addr)
@@ -683,6 +696,9 @@ static void rockchip_i2s_tdm_trcm_pause(struct snd_pcm_substream *substream,
683696
int stream = substream->stream;
684697
int bstream = SNDRV_PCM_STREAM_LAST - stream;
685698

699+
/* store the current state, prepare for resume if necessary */
700+
i2s_tdm->is_dma_active[bstream] = is_dma_active(i2s_tdm, bstream);
701+
686702
/* disable dma for both tx and rx */
687703
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, stream, 0);
688704
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, bstream, 0);
@@ -698,7 +714,8 @@ static void rockchip_i2s_tdm_trcm_resume(struct snd_pcm_substream *substream,
698714
* just resume bstream, because current stream will be
699715
* startup in the trigger-cmd-START
700716
*/
701-
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, bstream, 1);
717+
if (i2s_tdm->is_dma_active[bstream])
718+
rockchip_i2s_tdm_dma_ctrl(i2s_tdm, bstream, 1);
702719
rockchip_i2s_tdm_xfer_start(i2s_tdm, bstream);
703720
}
704721

0 commit comments

Comments
 (0)