Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1267104ybl; Fri, 30 Aug 2019 15:00:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNj99aewH8SW8E8Bi9ef/sSEiBP/i/aH1prNU/Ju831dlBFtVUkd8DH1Gem8654B0cbZs6 X-Received: by 2002:a17:90a:2069:: with SMTP id n96mr729372pjc.4.1567202448394; Fri, 30 Aug 2019 15:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567202448; cv=none; d=google.com; s=arc-20160816; b=tp8YfPOSbXUh6h5Z/+1lhfBzefV9X0NomeS9zSUafBZmWeF+68kfO3b2Ch4ce3kpMv mCFNJirGETYk6bLZfYR8bKbuG5Pj89ZEf70PNehosrfcgEq7+gbYGnFgU/V8mXUrE0kk HqappqHnIWGfi6j68Ho55UdnA9B+xFdti+g0q9S6f9YS7yxWQfpsPR7hZS/a73TCUXvj Hz+hS/7R/uBCdkqsPynUS+YeMy5uAxn1MEitzAeMKyTWxX2RUjiT7l0SIgHz5iv2/U/r 7sy4r7xqmGHQOW6ZVP6StLLfpRgVI7YOugp+oGCd6DaMaC7q0rCzqmt0J0M9Mip+RRyA 4cpA== 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 z24si5912597pjt.22.2019.08.30.15.00.33; Fri, 30 Aug 2019 15:00:48 -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 S1728267AbfH3V7P (ORCPT + 99 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(-) 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; -- 2.17.1