From patchwork Fri Aug 30 20:09:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 172700 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1090946ily; Fri, 30 Aug 2019 13:09:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9UoFx+RgllAmK68vwy3wqssH9aGqGC5O2AfSMZD8DKNjGc5z/w9FO8ciNXJrGEwpGPIUI X-Received: by 2002:a17:902:8d8c:: with SMTP id v12mr17813603plo.198.1567195746084; Fri, 30 Aug 2019 13:09:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567195746; cv=none; d=google.com; s=arc-20160816; b=qZlH4V17VifYoIa/k76NvRA+dHpMWntLhOStxEsTgDr4FHzTCHidibGWUKrwSYawoo aOz1JqHG/TPy0zoGPCYteGVr4SBC/F3YoDU3b7p+RMFa21uG0Ec1U/HQDowXM5sxW1dN l5RcqUODTHpqVrui965hQg8CC4HtQRQvz7H/TnuDhg1S7vh/1uvXINF2mgFwiPP2SNA2 /zkDSAIDAQtozlmnbfPKrVSYNUaIE6BHaxdeo2upvgo69bIhFTJwtfwEi6/7pmmgTXps glfPGVqQkIOkEykWWzm+p+O/8CBHCZwIkaZ+l3KLz09hMtVu1CvSDTJ+3m3UGmkSezn2 rpag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=4rL30b7ME2NxwKvJeInnOeA9f5HOekXkXCd/WviV7TI=; b=yNVY0zqfdBuo9+uFggNv3QrSZZmlZtg47Z1vnCXbv4F/CfTu/StZxnvhO8SRdWUTFY rcXj91uD3v/Y/x9/PcJ1w7skIaIPmDg/+uskHZnZt/1Tvhb6URCrtKlK9ERgch8HBjCq I0hskels3/+xai0yNL3KYCv+PC1DVF8pi7uWm2uhfDANzvwBs6YdsTKwp9HyZKp3F0/M c//8iypVQxs1in0IsYkiAPDvVogKm+dyBTlfdd8B6mPfeM+pmpvNHVjdNiyX8Xj6yXEm qpBJigViGQ1RYcnpNsKXLyMxuNuyZ+LdIWgmnyNAAPtRnJKZp8WDtI3+TN5vasPVl6Pa I03A== 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 q9si5485808pjv.72.2019.08.30.13.09.05; Fri, 30 Aug 2019 13:09:06 -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 S1728129AbfH3UJE (ORCPT + 28 others); Fri, 30 Aug 2019 16:09:04 -0400 Received: from inva021.nxp.com ([92.121.34.21]:44694 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727963AbfH3UJE (ORCPT ); Fri, 30 Aug 2019 16:09:04 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 52F54200033; Fri, 30 Aug 2019 22:09:02 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 450E0200423; Fri, 30 Aug 2019 22:09:02 +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 AF43C2061E; Fri, 30 Aug 2019 22:09:01 +0200 (CEST) From: Daniel Baluta To: broonie@kernel.org Cc: festevam@gmail.com, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, shengjiu.wang@nxp.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, timur@kernel.org, mihai.serban@gmail.com, Mihai Serban , NXP Linux Team , Daniel Baluta Subject: [PATCH] ASoC: fsl_sai: Fix noise when using EDMA Date: Fri, 30 Aug 2019 23:09:00 +0300 Message-Id: <20190830200900.19668-1-daniel.baluta@nxp.com> X-Mailer: git-send-email 2.17.1 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. Cc: NXP Linux Team Signed-off-by: Mihai Serban Signed-off-by: Daniel Baluta --- sound/soc/fsl/fsl_sai.c | 15 +++++++++++++++ sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 16 insertions(+) -- 2.17.1 diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 728307acab90..fe126029f4e3 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -612,6 +612,16 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, FSL_SAI_CR3_TRCE_MASK, FSL_SAI_CR3_TRCE); + /* + * some DMA controllers need period size to be a multiple of + * tx/rx maxburst + */ + if (sai->soc_data->use_constraint_period_size) + 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); @@ -1011,30 +1021,35 @@ static const struct fsl_sai_soc_data fsl_sai_vf610_data = { .use_imx_pcm = false, .fifo_depth = 32, .reg_offset = 0, + .use_constraint_period_size = false, }; static const struct fsl_sai_soc_data fsl_sai_imx6sx_data = { .use_imx_pcm = true, .fifo_depth = 32, .reg_offset = 0, + .use_constraint_period_size = false, }; static const struct fsl_sai_soc_data fsl_sai_imx7ulp_data = { .use_imx_pcm = true, .fifo_depth = 16, .reg_offset = 8, + .use_constraint_period_size = false, }; static const struct fsl_sai_soc_data fsl_sai_imx8mq_data = { .use_imx_pcm = true, .fifo_depth = 128, .reg_offset = 8, + .use_constraint_period_size = false, }; static const struct fsl_sai_soc_data fsl_sai_imx8qm_data = { .use_imx_pcm = true, .fifo_depth = 64, .reg_offset = 0, + .use_constraint_period_size = true, }; static const struct of_device_id fsl_sai_ids[] = { diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index b89b0ca26053..3a3f6f8e5595 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_constraint_period_size; unsigned int fifo_depth; unsigned int reg_offset; };