From patchwork Wed Sep 13 09:54:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yu Chao X-Patchwork-Id: 9950863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A49096038F for ; Wed, 13 Sep 2017 09:55:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9513528EDA for ; Wed, 13 Sep 2017 09:55:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A0AB28F6C; Wed, 13 Sep 2017 09:55:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9439A28F48 for ; Wed, 13 Sep 2017 09:55:30 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 62ACB266AF8; Wed, 13 Sep 2017 11:54:43 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id C60002668BF; Wed, 13 Sep 2017 11:54:41 +0200 (CEST) Received: from mail-pg0-f47.google.com (mail-pg0-f47.google.com [74.125.83.47]) by alsa0.perex.cz (Postfix) with ESMTP id 312692668BF for ; Wed, 13 Sep 2017 11:54:38 +0200 (CEST) Received: by mail-pg0-f47.google.com with SMTP id j16so16128778pga.1 for ; Wed, 13 Sep 2017 02:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=lpwidH+jflTA0aCEMMSv+RzaLSONtxMPm3OhbRJ/8LE=; b=lSn5uyReSvHwWU5eUPcu61NlhWqbHIUUM1dxJJZtt84rcgEuQQ9XAn+KtypRW9IXTn 7AczFO4t48UHzjAV3HJCiv+ZZpDEvGQy+7A/h3W/E3o8MPgmw3iWo6bkGneU+B/NI66F MHWv6kkcquFc/FEwftrl0CdRUkp0qRh48bBUo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lpwidH+jflTA0aCEMMSv+RzaLSONtxMPm3OhbRJ/8LE=; b=YUkBMqkga/GLhG9EnHZTvlIOdK4lYIy8GUoqz8FTcNjAsn6hIb8N3/iaVR+3K6PCVy L0JEHbkR0L+Il+kDIsAfEr/isvvw30/hkTTYvok4jlEDCVHNoagIY9eU4SaMA2vRqzRb rvVsb5DO29bakDvqDsaFU4Oj4OrGz40dliqP3u1Lrx6I6dYXKozBVN0aPvSX8CRk3QIT vXK9zZxnvS21wNeXWB3F1nD92dKCQsSwjWb5e6UhGGUnIxod/ETutQBvKhFNDjYLBhrF pR1IVlvRnAUmHDhoMVW2tm923yMWWR9/v707TU0MkugQQR3/xK1gKcWwxCVzxEFQxRmq D6Dg== X-Gm-Message-State: AHPjjUjW3qjXH29c0r8nqoQOSJ0VAqS+QGGjZMZPzbThhqk+YZFlF9SJ WOcvLXmmDaWPwFoj X-Google-Smtp-Source: ADKCNb7nJi3wZxIrhPZ4/Xo4if1cK+bj39vofdPCm2PGHW4me4WCAwjuEYkBmUKLU8SFamZ1GLMSQw== X-Received: by 10.99.117.91 with SMTP id f27mr17112278pgn.376.1505296477182; Wed, 13 Sep 2017 02:54:37 -0700 (PDT) Received: from hychaoz840.tpe.corp.google.com ([2401:fa00:1:b:6819:4871:27e2:edb1]) by smtp.gmail.com with ESMTPSA id s27sm19558108pgo.59.2017.09.13.02.54.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 02:54:35 -0700 (PDT) From: Hsin-Yu Chao To: broonie@kernel.org, lgirdwood@gmail.com Date: Wed, 13 Sep 2017 17:54:28 +0800 Message-Id: <20170913095428.27036-1-hychao@chromium.org> X-Mailer: git-send-email 2.12.2 Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, Hsin-Yu Chao Subject: [alsa-devel] [PATCH] ASoC: rt5514-spi: check irq status to schedule data copy X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- sound/soc/codecs/rt5514-spi.c | 17 +++++++++++++++-- sound/soc/codecs/rt5514-spi.h | 3 +++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 60f61af9ced3..f932d866056d 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -145,9 +145,8 @@ done: 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; diff --git a/sound/soc/codecs/rt5514-spi.h b/sound/soc/codecs/rt5514-spi.h index a6434ee6ff03..c1a36647c119 100644 --- a/sound/soc/codecs/rt5514-spi.h +++ b/sound/soc/codecs/rt5514-spi.h @@ -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 {