Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1768921ybe; Sat, 14 Sep 2019 01:06:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNLHNZ58XIOwUxPwmbNnGVdQ/RGdowODWLDCb1i99oYOALx0nK9X4JXdbZ5U4ywbxF6Fgw X-Received: by 2002:a17:906:6810:: with SMTP id k16mr42541931ejr.193.1568448401951; Sat, 14 Sep 2019 01:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568448401; cv=none; d=google.com; s=arc-20160816; b=cjcq3SG5pFEtKFEjk0HRfibPb2cag9u+cysZwjnVjgpatOZhEbPUQJ2XeGtGbQFoVB U5pEwjzskB9eqfl2j3Vtf2lPelZYXUg1tckvnbpFsMnpz19F95NZQwZaiPT+tIzVLEgw vcMi+doo+R//9gIXOFK4s4/WWHIZXA/fxhvuAS/32n1xxq+J3cRD3PpU096QFnG3rXGM Onxb/RwiVVAZVySbGZVuwhYdNzem+lUI5t5NplnLM0qfqphUJtUOHtHQZjrL2+Kn184S IxQAO2dEsddCurqr4quBqn2ewhjN8qKo1/7YbFVckfsUepJyJ82MBL7kJkCdkko9yh3r uxnA== 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 f13si15661049ejf.174.2019.09.14.01.06.05; Sat, 14 Sep 2019 01:06:41 -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 S1730711AbfIMT2N (ORCPT + 99 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(+) 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; }; -- 2.17.1