Skip to content

Commit

Permalink
ASoC: rt5514-spi: check irq status to schedule data copy
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hsin-Yu Chao authored and Mark Brown committed Sep 13, 2017
1 parent f5fd4a6 commit 659178f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sound/soc/codecs/rt5514-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions sound/soc/codecs/rt5514-spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 659178f

Please sign in to comment.