]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ASoC: rt5514-spi: check irq status to schedule data copy
authorHsin-Yu Chao <hychao@chromium.org>
Wed, 13 Sep 2017 09:54:28 +0000 (17:54 +0800)
committerMark Brown <broonie@kernel.org>
Wed, 13 Sep 2017 16:40:30 +0000 (09:40 -0700)
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>
sound/soc/codecs/rt5514-spi.c
sound/soc/codecs/rt5514-spi.h

index ed6e5373916c390fb15dfc9efd943c9c55f7d819..12f2ecf3a4feeb3a6133012b33b5b10cad33999f 100644 (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;
index a6434ee6ff037c11c945a3358a90070de316b09c..c1a36647c1197f925985a623ffe52336fd167c68 100644 (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 {