From patchwork Fri Sep 13 19:28:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 173788 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp558680ilq; Fri, 13 Sep 2019 12:28:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaGxj8m6E/CuGzUgWCTIeH7/cb7PQICtEj695pLRJ+7YLsiNJxbVzEMuLIX/VKNHCjAatJ X-Received: by 2002:aa7:c586:: with SMTP id g6mr28588434edq.38.1568402897167; Fri, 13 Sep 2019 12:28:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568402897; cv=none; d=google.com; s=arc-20160816; b=pYrOGa94dUhjBMwXCKQ6dLxl0+pn0xnw7wh1m2QQpVP1esRiFILiHJHkyQC7tpivlo v8dzNvrRJK2uYopzRavvO/Ox5z9JFIRXlkMWWXwdEzX4mhiFEUJDrChqFfhIcp4JNEN+ mKtLKvFmMFEKEZVEprwtS062/31i1wxWuBuVa++bM3lJJgz4c2FLqI6qDec9i0dNYaaJ 8B6dlm0NvYFV2DPKduDVLnDzDmf8chwXcsYUbfrbRfK83FXNWxNH3Hzni2sZ83GqRjR0 aKPI2gPZWZbTwkpFM46VwMTc9lzsUJHQm//tmQjPWNTzVa/UVvJgJa9vrtn88eILLyJC qfGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Iqy9+9G+1JGHkI2VRVONnMUrdqgcLEHWXzZWxUZMFf4=; b=GYqzqlG54AWhaq/ANltR3lev6PyCpe65E/OSb3iZvuYYTU23ekEDpDvXb/0+2Pvvbr 32XlyrsTlPClCpejvVlmGjTw1u3ci3z8seJbyzhGbAgCKxrWFb6Sj0UwQsx/O/+NT+Fe 1fv9apKCZyZ+5MRHvMKR7qIXGHdkOOFlssGhW0XrMLDStKHYIvCR2Wf9+ube6zvoE/W9 UOy/OtRF+D6Y5pEKTF8o9jAPcH0kfMP8mVPhXjeWFDOHDrrEaeZe+uwQscBGF1RM4ySI 8HRoRHJTmyTFLws/U0dLsMTM1Sh54VjPZwQ/Xp0q+5AUAjO5Q+BXL9lJ38pLkKyND7RX LwtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si7812474edj.0.2019.09.13.12.28.17; Fri, 13 Sep 2019 12:28:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730735AbfIMT2N (ORCPT + 27 others); Fri, 13 Sep 2019 15:28:13 -0400 Received: from inva020.nxp.com ([92.121.34.13]:41854 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729471AbfIMT2M (ORCPT ); Fri, 13 Sep 2019 15:28:12 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2D3CB1A0189; Fri, 13 Sep 2019 21:28:11 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 204D41A00D0; Fri, 13 Sep 2019 21:28:11 +0200 (CEST) Received: from fsr-ub1864-103.ea.freescale.net (fsr-ub1864-103.ea.freescale.net [10.171.82.17]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 93EEE205DB; Fri, 13 Sep 2019 21:28:10 +0200 (CEST) From: Daniel Baluta To: broonie@kernel.org Cc: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Mihai Serban , Daniel Baluta Subject: [PATCH v2 1/3] ASoC: fsl_sai: Fix noise when using EDMA Date: Fri, 13 Sep 2019 22:28:05 +0300 Message-Id: <20190913192807.8423-2-daniel.baluta@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190913192807.8423-1-daniel.baluta@nxp.com> References: <20190913192807.8423-1-daniel.baluta@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mihai Serban EDMA requires the period size to be multiple of maxburst. Otherwise the remaining bytes are not transferred and thus noise is produced. We can handle this issue by adding a constraint on SNDRV_PCM_HW_PARAM_PERIOD_SIZE to be multiple of tx/rx maxburst value. Signed-off-by: Mihai Serban Signed-off-by: Daniel Baluta --- Changes since v1: * rename variable to use_edma as per Nicolin's suggestion. sound/soc/fsl/fsl_sai.c | 15 +++++++++++++++ sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 16 insertions(+) -- 2.17.1 Acked-by: Nicolin Chen diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index ef0b74693093..b517e4bc1b87 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -628,6 +628,16 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, FSL_SAI_CR3_TRCE_MASK, FSL_SAI_CR3_TRCE); + /* + * EDMA controller needs period size to be a multiple of + * tx/rx maxburst + */ + if (sai->soc_data->use_edma) + snd_pcm_hw_constraint_step(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_PERIOD_SIZE, + tx ? sai->dma_params_tx.maxburst : + sai->dma_params_rx.maxburst); + ret = snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &fsl_sai_rate_constraints); @@ -1026,30 +1036,35 @@ static int fsl_sai_remove(struct platform_device *pdev) static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false, + .use_edma = false, .fifo_depth = 32, .reg_offset = 0, }; static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true, + .use_edma = false, .fifo_depth = 32, .reg_offset = 0, }; static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { .use_imx_pcm = true, + .use_edma = false, .fifo_depth = 16, .reg_offset = 8, }; static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { .use_imx_pcm = true, + .use_edma = false, .fifo_depth = 128, .reg_offset = 8, }; static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { .use_imx_pcm = true, + .use_edma = true, .fifo_depth = 64, .reg_offset = 0, }; diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index b12cb578f6d0..76b15deea80c 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -157,6 +157,7 @@ struct fsl_sai_soc_data { bool use_imx_pcm; + bool use_edma; unsigned int fifo_depth; unsigned int reg_offset; };