From patchwork Fri Jan 9 01:52:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jianqun Xu X-Patchwork-Id: 5596391 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8260BC058D for ; Fri, 9 Jan 2015 01:55:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A353420561 for ; Fri, 9 Jan 2015 01:55:17 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6D32A2051C for ; Fri, 9 Jan 2015 01:55:16 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D7BEB260639; Fri, 9 Jan 2015 02:55:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00, SUBJ_OBFU_PUNCT_MANY, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 0959426059C; Fri, 9 Jan 2015 02:55:08 +0100 (CET) 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 6264626059D; Fri, 9 Jan 2015 02:55:07 +0100 (CET) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.99.137]) by alsa0.perex.cz (Postfix) with ESMTP id D2811260599 for ; Fri, 9 Jan 2015 02:54:57 +0100 (CET) Received: from jay.xu?rock-chips.com (unknown [192.168.167.131]) by regular1.263xmail.com (Postfix) with SMTP id 76EEE6504; Fri, 9 Jan 2015 09:54:54 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 7D78F457; Fri, 9 Jan 2015 09:54:51 +0800 (CST) X-RL-SENDER: jay.xu@rock-chips.com X-FST-TO: lgirdwood@gmail.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: jay.xu@rock-chips.com X-UNIQUE-TAG: <3b8634f1e7b144c623b17c8c1f2d0ded> X-ATTACHMENT-NUM: 0 X-SENDER: xjq@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 4006IDR3VE; Fri, 09 Jan 2015 09:54:53 +0800 (CST) From: Jianqun Xu To: lgirdwood@gmail.com, heiko@sntech.de, broonie@kernel.org, perex@perex.cz, tiwai@suse.de, sonnyrao@chromium.org Date: Fri, 9 Jan 2015 09:52:49 +0800 Message-Id: <1420768369-6681-1-git-send-email-jay.xu@rock-chips.com> X-Mailer: git-send-email 1.9.1 Cc: linux-rockchip@lists.infradead.org, alsa-devel@alsa-project.org, Jianqun Xu , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH] ASoC: rockchip: i2s: add rockchip_dmaengine_pcm_config 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 This patch makes snd_dmaengine_pcm_register with rockchip_dmaengine_pcm_config, which configure the parameters of period and buffer match to rockchip DMAC. ======================= without rockchip_dmaengine_pcm_config, and test with command - aplay -D hw:0,0 /tmp/a, there are the error dump: [ 134.899396] dma-pl330 ffb20000.dma-controller: fill_queue:2251 Bad Desc(7) [ 134.906270] dma-pl330 ffb20000.dma-controller: fill_queue:2251 Bad Desc(8) [ 134.913141] dma-pl330 ffb20000.dma-controller: fill_queue:2251 Bad Desc(9) And bellow sound from DMA debugger: "I debugged it a little and it looks like what is happening is that requests which aren't a multiple of burst size * burst length are coming in. Right now the i2s block is setting a burst size of 4 and burst length of 4, but the dmaengine code has no idea about this restriction. I was able to eliminate the messages by changing burst length to 1 in the i2s driver. This fix would always work as long as we're sending a multiple of 4 bytes (which so far seems to be the case)" This patch can make the length of dma buffer is aligned to a multiple of burst size and burst length. Signed-off-by: Jianqun Xu --- sound/soc/rockchip/rockchip_i2s.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index c74ba37..bdd1021 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -408,6 +408,24 @@ static const struct regmap_config rockchip_i2s_regmap_config = { .cache_type = REGCACHE_FLAT, }; +static const struct snd_pcm_hardware rockchip_pcm_hardware = { + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED, + .period_bytes_min = 1024, + .period_bytes_max = PAGE_SIZE, + .periods_min = 3, + .periods_max = 8, + .buffer_bytes_max = 8 * PAGE_SIZE, + .fifo_size = 16, +}; + +static const struct snd_dmaengine_pcm_config rockchip_dmaengine_pcm_config = { + .pcm_hardware = &rockchip_pcm_hardware, + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, + .prealloc_buffer_size = PAGE_SIZE * 8, +}; + static int rockchip_i2s_probe(struct platform_device *pdev) { struct rk_i2s_dev *i2s; @@ -478,7 +496,8 @@ static int rockchip_i2s_probe(struct platform_device *pdev) goto err_suspend; } - ret = snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); + ret = snd_dmaengine_pcm_register(&pdev->dev, + &rockchip_dmaengine_pcm_config, 0); if (ret) { dev_err(&pdev->dev, "Could not register PCM\n"); goto err_pcm_register;