Skip to content

Commit 76d3a9a

Browse files
Sugar Zhangrkhuangtao
authored andcommitted
ASoC: rockchip: pcm: add vad preprocess
Change-Id: I6b5e2f36e30c033e68019bde8c94a3c2c569a60d Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
1 parent 4365303 commit 76d3a9a

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

sound/core/pcm_dmaengine.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ static void dmaengine_pcm_dma_complete(void *arg)
135135
struct snd_pcm_substream *substream = arg;
136136
struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
137137

138+
#ifdef CONFIG_SND_SOC_ROCKCHIP_VAD
139+
if (snd_pcm_vad_attached(substream)) {
140+
void *buf = substream->runtime->dma_area + prtd->pos;
141+
142+
snd_pcm_vad_preprocess(substream, buf,
143+
substream->runtime->period_size);
144+
}
145+
#endif
138146
prtd->pos += snd_pcm_lib_period_bytes(substream);
139147
if (prtd->pos >= snd_pcm_lib_buffer_bytes(substream))
140148
prtd->pos = 0;

sound/soc/rockchip/rockchip_multi_dais_pcm.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct dmaengine_mpcm_runtime_data {
2929
dma_cookie_t cookies[MAX_DAIS];
3030
unsigned int *channel_maps;
3131
int num_chans;
32+
unsigned int pos;
3233
};
3334

3435
static inline struct dmaengine_mpcm_runtime_data *substream_to_prtd(
@@ -90,7 +91,21 @@ static void snd_dmaengine_mpcm_set_config_from_dai_data(
9091
static void dmaengine_mpcm_dma_complete(void *arg)
9192
{
9293
struct snd_pcm_substream *substream = arg;
94+
#ifdef CONFIG_SND_SOC_ROCKCHIP_VAD
95+
struct dmaengine_mpcm_runtime_data *prtd = substream_to_prtd(substream);
96+
97+
if (snd_pcm_vad_attached(substream)) {
98+
void *buf = substream->runtime->dma_area + prtd->pos;
99+
100+
snd_pcm_vad_preprocess(substream, buf,
101+
substream->runtime->period_size);
102+
}
103+
104+
prtd->pos += snd_pcm_lib_period_bytes(substream);
105+
if (prtd->pos >= snd_pcm_lib_buffer_bytes(substream))
106+
prtd->pos = 0;
93107

108+
#endif
94109
snd_pcm_period_elapsed(substream);
95110
}
96111

@@ -111,6 +126,7 @@ static int dmaengine_mpcm_prepare_and_submit(struct snd_pcm_substream *substream
111126
if (!substream->runtime->no_period_wakeup)
112127
flags |= DMA_PREP_INTERRUPT;
113128

129+
prtd->pos = 0;
114130
offset = 0;
115131
period_bytes = snd_pcm_lib_period_bytes(substream);
116132
buffer_bytes = snd_pcm_lib_buffer_bytes(substream);

0 commit comments

Comments
 (0)