From patchwork Sat Jun 4 23:47:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 9155017 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 05B5360751 for ; Sat, 4 Jun 2016 23:53:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE2BC27B13 for ; Sat, 4 Jun 2016 23:53:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D29D227C8F; Sat, 4 Jun 2016 23:53:50 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5008727B13 for ; Sat, 4 Jun 2016 23:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750904AbcFDXxs (ORCPT ); Sat, 4 Jun 2016 19:53:48 -0400 Received: from mail-qt0-f172.google.com ([209.85.216.172]:34927 "EHLO mail-qt0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbcFDXxs (ORCPT ); Sat, 4 Jun 2016 19:53:48 -0400 X-Greylist: delayed 369 seconds by postgrey-1.27 at vger.kernel.org; Sat, 04 Jun 2016 19:53:48 EDT Received: by mail-qt0-f172.google.com with SMTP id 9so997877qtg.2 for ; Sat, 04 Jun 2016 16:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Mo4RgDa6tzpiA86BQiqRyQ7xkrdMqjVnwzirFr2jtE=; b=oLExOSNOXu1rnwLK0c1Ou4rLlNtEfb2wge6zUHg1Lpyz8AoLOe3NxBPi6+2C+A+q5Y PXee7Jm2cMO9T3OIdZCX55HtiPCdpFuJ5sM4ddZJALuVJIs2UMnUmMXqTw5B/HqyRzem AZF4hP2iBq4vnkpS9Bg9fPKngSy+uJXlpSkhHC47+Hh7wZSr91HixQxOdXVUD1Zt72BA b9ZDomQd5NvvW5yXs1bN4Ewdvr2gUqXKAbbcu3kiNbW/cAHDjo0NUSFLviByr9O6FIYK yrsab2j6bcojl/DfJs8+W6eWW5f8MfYG2AXVYOqQ9o3+lll8ED2W4QiF3AXNPxDZeDtr RMeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1Mo4RgDa6tzpiA86BQiqRyQ7xkrdMqjVnwzirFr2jtE=; b=DwxIgx2PG9I3EakPh2F7RHmpmgzKp9JLZSsm4LwSpVRcyKBzBS6X875NfJphSe5Zc2 3T6z8MiML9ABN7Dlx6/bKyu3ewRW/6KkFRBQ8ln0Ei8mQlvE23CyC/7xr+EXjdRqwdnX 19Gr50uRGz/YSSHIAMMO/lCNc1UxmDGijTm3dDBKzkw0luTLLZuSA9HVOV1nfdZRRYae ZWHAuIKyeScVhBNMg/bt4HlZzeUUTFcIij8RQEmfIkhZuQ4vhhfNJSuddCEKRjm6jAqq e6zSC28x+PUoFQ/xFyqT4dD8IqTkwovo+AYNvbT672a5XiTxwr/emT7Mecz+plzvdckE WqaA== X-Gm-Message-State: ALyK8tKq6YGEnBHY5ZYLlDKtbZf9mt+jDPQQlaz4gEAoMFGNnTBo8hxacyN95uASvzQAVg== X-Received: by 10.237.47.67 with SMTP id l61mr9742117qtd.89.1465084061319; Sat, 04 Jun 2016 16:47:41 -0700 (PDT) Received: from localhost.localdomain ([190.2.108.156]) by smtp.gmail.com with ESMTPSA id i34sm3022786qgd.2.2016.06.04.16.47.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 04 Jun 2016 16:47:40 -0700 (PDT) From: Ezequiel Garcia To: Cc: Hans Verkuil , Ezequiel Garcia Subject: [RESEND/PATCH 4/6] tw686x: audio: Implement non-memcpy capture Date: Sat, 4 Jun 2016 20:47:18 -0300 Message-Id: <1465084040-6112-5-git-send-email-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1465084040-6112-1-git-send-email-ezequiel@vanguardiasur.com.ar> References: <1465084040-6112-1-git-send-email-ezequiel@vanguardiasur.com.ar> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we've introduced the dma_mode parameter to pick the DMA operation, let's use it to also select the audio DMA operation. When dma_mode != memcpy, the driver will avoid using memcpy in the audio capture path, and the DMA hardware operation will act directly on the ALSA buffers. Signed-off-by: Ezequiel Garcia --- drivers/media/pci/tw686x/tw686x-audio.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/media/pci/tw686x/tw686x-audio.c b/drivers/media/pci/tw686x/tw686x-audio.c index 91459ab715b2..a14d1b07edec 100644 --- a/drivers/media/pci/tw686x/tw686x-audio.c +++ b/drivers/media/pci/tw686x/tw686x-audio.c @@ -62,12 +62,22 @@ void tw686x_audio_irq(struct tw686x_dev *dev, unsigned long requests, } spin_unlock_irqrestore(&ac->lock, flags); + if (!done || !next) + continue; + /* + * Checking for a non-nil dma_desc[pb]->virt buffer is + * the same as checking for memcpy DMA mode. + */ desc = &ac->dma_descs[pb]; - if (done && next && desc->virt) { - memcpy(done->virt, desc->virt, desc->size); - ac->ptr = done->dma - ac->buf[0].dma; - snd_pcm_period_elapsed(ac->ss); + if (desc->virt) { + memcpy(done->virt, desc->virt, + desc->size); + } else { + u32 reg = pb ? ADMA_B_ADDR[ch] : ADMA_P_ADDR[ch]; + reg_write(dev, reg, next->dma); } + ac->ptr = done->dma - ac->buf[0].dma; + snd_pcm_period_elapsed(ac->ss); } } @@ -181,6 +191,12 @@ static int tw686x_pcm_prepare(struct snd_pcm_substream *ss) ac->curr_bufs[0] = p_buf; ac->curr_bufs[1] = b_buf; ac->ptr = 0; + + if (dev->dma_mode != TW686X_DMA_MODE_MEMCPY) { + reg_write(dev, ADMA_P_ADDR[ac->ch], p_buf->dma); + reg_write(dev, ADMA_B_ADDR[ac->ch], b_buf->dma); + } + spin_unlock_irqrestore(&ac->lock, flags); return 0; @@ -290,6 +306,14 @@ static int tw686x_audio_dma_alloc(struct tw686x_dev *dev, { int pb; + /* + * In the memcpy DMA mode we allocate a consistent buffer + * and use it for the DMA capture. Otherwise, DMA + * acts on the ALSA buffers as received in pcm_prepare. + */ + if (dev->dma_mode != TW686X_DMA_MODE_MEMCPY) + return 0; + for (pb = 0; pb < 2; pb++) { u32 reg = pb ? ADMA_B_ADDR[ac->ch] : ADMA_P_ADDR[ac->ch]; void *virt;