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>
This commit is contained in:
Hsin-Yu Chao 2017-09-13 17:54:28 +08:00 committed by Mark Brown
parent f5fd4a67be
commit 659178f5d1
2 changed files with 18 additions and 2 deletions

View File

@ -145,9 +145,8 @@ static void rt5514_spi_copy_work(struct work_struct *work)
mutex_unlock(&rt5514_dsp->dma_lock);
}
static irqreturn_t rt5514_spi_irq(int irq, void *data)
static void rt5514_schedule_copy(struct rt5514_dsp *rt5514_dsp)
{
struct rt5514_dsp *rt5514_dsp = data;
u8 buf[8];
rt5514_dsp->get_size = 0;
@ -180,6 +179,13 @@ static irqreturn_t rt5514_spi_irq(int irq, void *data)
if (rt5514_dsp->buf_base && rt5514_dsp->buf_limit &&
rt5514_dsp->buf_rp && rt5514_dsp->buf_size)
schedule_delayed_work(&rt5514_dsp->copy_work, 0);
}
static irqreturn_t rt5514_spi_irq(int irq, void *data)
{
struct rt5514_dsp *rt5514_dsp = data;
rt5514_schedule_copy(rt5514_dsp);
return IRQ_HANDLED;
}
@ -199,12 +205,19 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream,
struct rt5514_dsp *rt5514_dsp =
snd_soc_platform_get_drvdata(rtd->platform);
int ret;
u8 buf[8];
mutex_lock(&rt5514_dsp->dma_lock);
ret = snd_pcm_lib_alloc_vmalloc_buffer(substream,
params_buffer_bytes(hw_params));
rt5514_dsp->substream = substream;
rt5514_dsp->dma_offset = 0;
/* Read IRQ status and schedule copy accordingly. */
rt5514_spi_burst_read(RT5514_IRQ_CTRL, (u8 *)&buf, sizeof(buf));
if (buf[0] & RT5514_IRQ_STATUS_BIT)
rt5514_schedule_copy(rt5514_dsp);
mutex_unlock(&rt5514_dsp->dma_lock);
return ret;

View File

@ -20,6 +20,9 @@
#define RT5514_BUFFER_VOICE_BASE 0x18000200
#define RT5514_BUFFER_VOICE_LIMIT 0x18000204
#define RT5514_BUFFER_VOICE_WP 0x1800020c
#define RT5514_IRQ_CTRL 0x18002094
#define RT5514_IRQ_STATUS_BIT (0x1 << 5)
/* SPI Command */
enum {