From patchwork Fri Aug 30 21:59:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Baluta X-Patchwork-Id: 172702 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1182836ily; Fri, 30 Aug 2019 14:59:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCnMUzdCiepFRS2/1OU3hEBCJzDtpg1ktW1K0MOX04qJq5HV9WVL2HRCvuT/BIAJvJ5uVE X-Received: by 2002:a63:4823:: with SMTP id v35mr14718256pga.138.1567202356716; Fri, 30 Aug 2019 14:59:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567202356; cv=none; d=google.com; s=arc-20160816; b=ADKQy3JQrsp9o+aIrMbo6RsarWEZGRx4rEg9yG0JM9EF5USeFMqGLqZSpBoA3eCfqa mBeIQLj8tKIxOc+233Ieqjebs7tfB+IRLlubGuDCHOBspCkYoZWsPQwYEM9MkL8D5FV9 8jJWYvlWf7H0MLtf9xE/kK4udcRZ9jpV5SkOotbzmH16gjUc5VuPhMEEbQAsUYUytKWY 1d1iCY5nR3hb1DV40XY5Mpby6aEGl+JaELAsewN0KvItTwX4i2/F0a101RX0ody/Nl56 aFvxQRnweRez+DFgY/QF+Q6C3c3C/EIQVDUUc2ScFOZyL/aru5pntbbUC7/4vG69uO+V frrQ== 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=sFVfK6t5vOF9AVhfTuXoAIzNxmPAEYRYLsPHewuxn18=; b=K7yVqIY6RMDF2Rkbcek/q/L4U+/KzDlFfZg6gn3unR9rfjdXnEy5qm1c0RqL/NFOL9 zZtGxY1IXcRrwC2YEswyJLFIRyU+fjNIXxwGcs2YFTQqyyY+Xh5CZK78GV13YkcHmt4z 6vLPt8JGGdn8qrxgHq63PgtPYIAyTuE1DLTCGse01yTeNTfUufMEDkAZ4IBfh1d/Rdvc 6B5Pgoz5F5QCLgaU9WFGN+2bapVIKt9vRZr04I8v8lb7g1DpjbGuGKyITDPjaCnMuH46 CYtUJtjLuF5gEOF0iOuKIMWkKxRFrnUTtQil9LE10qRffjKmW/WcCRTrXzbbGG0ZDgmO 7FWg== 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 ds20si5676595pjb.9.2019.08.30.14.59.16; Fri, 30 Aug 2019 14:59:16 -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 S1728289AbfH3V7P (ORCPT + 28 others); Fri, 30 Aug 2019 17:59:15 -0400 Received: from inva021.nxp.com ([92.121.34.21]:52664 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728166AbfH3V7P (ORCPT ); Fri, 30 Aug 2019 17:59:15 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id F0D4420079F; Fri, 30 Aug 2019 23:59:12 +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 E48EC20043B; Fri, 30 Aug 2019 23:59:12 +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 3FC0F2061E; Fri, 30 Aug 2019 23:59:12 +0200 (CEST) From: Daniel Baluta To: broonie@kernel.org Cc: festevam@gmail.com, shengjiu.wang@nxp.com, Xiubo.Lee@gmail.com, nicoleotsuka@gmail.com, timur@kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Viorel Suman , NXP Linux Team , Daniel Baluta Subject: [PATCH] ASoC: fsl_sai: Implement set_bclk_ratio Date: Sat, 31 Aug 2019 00:59:10 +0300 Message-Id: <20190830215910.31590-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: Viorel Suman This is to allow machine drivers to set a certain bitclk rate which might not be exactly rate * frame size. Cc: NXP Linux Team Signed-off-by: Viorel Suman Signed-off-by: Daniel Baluta --- sound/soc/fsl/fsl_sai.c | 21 +++++++++++++++++++-- sound/soc/fsl/fsl_sai.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) -- 2.17.1 Acked-by: Nicolin Chen diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index fe126029f4e3..e896b577b1f7 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -137,6 +137,16 @@ static int fsl_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, return 0; } +static int fsl_sai_set_dai_bclk_ratio(struct snd_soc_dai *dai, + unsigned int ratio) +{ + struct fsl_sai *sai = snd_soc_dai_get_drvdata(dai); + + sai->bclk_ratio = ratio; + + return 0; +} + static int fsl_sai_set_dai_sysclk_tr(struct snd_soc_dai *cpu_dai, int clk_id, unsigned int freq, int fsl_dir) { @@ -423,8 +433,14 @@ static int fsl_sai_hw_params(struct snd_pcm_substream *substream, slot_width = sai->slot_width; if (!sai->is_slave_mode) { - ret = fsl_sai_set_bclk(cpu_dai, tx, - slots * slot_width * params_rate(params)); + if (sai->bclk_ratio) + ret = fsl_sai_set_bclk(cpu_dai, tx, + sai->bclk_ratio * + params_rate(params)); + else + ret = fsl_sai_set_bclk(cpu_dai, tx, + slots * slot_width * + params_rate(params)); if (ret) return ret; @@ -640,6 +656,7 @@ static void fsl_sai_shutdown(struct snd_pcm_substream *substream, } static const struct snd_soc_dai_ops fsl_sai_pcm_dai_ops = { + .set_bclk_ratio = fsl_sai_set_dai_bclk_ratio, .set_sysclk = fsl_sai_set_dai_sysclk, .set_fmt = fsl_sai_set_dai_fmt, .set_tdm_slot = fsl_sai_set_dai_tdm_slot, diff --git a/sound/soc/fsl/fsl_sai.h b/sound/soc/fsl/fsl_sai.h index 3a3f6f8e5595..f96f8d97489d 100644 --- a/sound/soc/fsl/fsl_sai.h +++ b/sound/soc/fsl/fsl_sai.h @@ -177,6 +177,7 @@ struct fsl_sai { unsigned int mclk_streams; unsigned int slots; unsigned int slot_width; + unsigned int bclk_ratio; const struct fsl_sai_soc_data *soc_data; struct snd_dmaengine_dai_dma_data dma_params_rx;