Skip to content

Commit 659178f

Browse files
Hsin-Yu Chaobroonie
authored andcommitted
ASoC: rt5514-spi: check irq status to schedule data copy
For wake on voice use case, we need to copy data from DSP buffer to PCM stream when system wakes up by voice. However the edge triggered IRQ could be missed when system wakes up, in that case the irq function will not be called. Fix that by checking the irq status bit and schedule data copy accordingly. Signed-off-by: Hsin-Yu Chao <hychao@chromium.org> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f5fd4a6 commit 659178f

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

sound/soc/codecs/rt5514-spi.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,8 @@ static void rt5514_spi_copy_work(struct work_struct *work)
145145
mutex_unlock(&rt5514_dsp->dma_lock);
146146
}
147147

148-
static irqreturn_t rt5514_spi_irq(int irq, void *data)
148+
static void rt5514_schedule_copy(struct rt5514_dsp *rt5514_dsp)
149149
{
150-
struct rt5514_dsp *rt5514_dsp = data;
151150
u8 buf[8];
152151

153152
rt5514_dsp->get_size = 0;
@@ -180,6 +179,13 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data)
180179
if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit &&
181180
rt5514_dsp->buf_rp && rt5514_dsp->buf_size)
182181
schedule_delayed_work(&rt5514_dsp->copy_work, 0);
182+
}
183+
184+
static irqreturn_t rt5514_spi_irq(int irq, void *data)
185+
{
186+
struct rt5514_dsp *rt5514_dsp = data;
187+
188+
rt5514_schedule_copy(rt5514_dsp);
183189

184190
return IRQ_HANDLED;
185191
}
@@ -199,12 +205,19 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream,
199205
struct rt5514_dsp *rt5514_dsp =
200206
snd_soc_platform_get_drvdata(rtd->platform);
201207
int ret;
208+
u8 buf[8];
202209

203210
mutex_lock(&rt5514_dsp->dma_lock);
204211
ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
205212
params_buffer_bytes(hw_params));
206213
rt5514_dsp->substream = substream;
207214
rt5514_dsp->dma_offset = 0;
215+
216+
/* Read IRQ status and schedule copy accordingly. */
217+
rt5514_spi_burst_read(RT5514_IRQ_CTRL, (u8 *)&buf, sizeof(buf));
218+
if (buf[0] & RT5514_IRQ_STATUS_BIT)
219+
rt5514_schedule_copy(rt5514_dsp);
220+
208221
mutex_unlock(&rt5514_dsp->dma_lock);
209222

210223
return ret;

sound/soc/codecs/rt5514-spi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#define RT5514_BUFFER_VOICE_BASE 0x18000200
2121
#define RT5514_BUFFER_VOICE_LIMIT 0x18000204
2222
#define RT5514_BUFFER_VOICE_WP 0x1800020c
23+
#define RT5514_IRQ_CTRL 0x18002094
24+
25+
#define RT5514_IRQ_STATUS_BIT (0x1 << 5)
2326

2427
/* SPI Command */
2528
enum {

0 commit comments

Comments
 (0)