From patchwork Fri Sep 8 05:23:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 9943179 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3350600CB for ; Fri, 8 Sep 2017 05:25:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCB5228433 for ; Fri, 8 Sep 2017 05:25:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C186528455; Fri, 8 Sep 2017 05:25:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24C5528433 for ; Fri, 8 Sep 2017 05:25:04 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 814A126753F; Fri, 8 Sep 2017 07:25:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 35815267541; Fri, 8 Sep 2017 07:25:01 +0200 (CEST) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by alsa0.perex.cz (Postfix) with ESMTP id D19B9267400 for ; Fri, 8 Sep 2017 07:24:56 +0200 (CEST) Received: by mail-pf0-f194.google.com with SMTP id g65so707730pfe.1 for ; Thu, 07 Sep 2017 22:24:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9nwj8t35sTRfZBy4W/qH00ECayOdTNn3a9nb6TOjuWA=; b=CmigN/e7hmFviWBzS5fFyKUct/btZ+tXA515cKyqP7kgOVUcs7vGucH/rsFaax+SNa AcF5LZpxeFuqJQRw5JIhbLFFBPF2NmHIMtmzEDOlbqbQXXD/o6BFO2S0zK0XaZhxFT+m 2EwEcr4eL7tswvNA/2xnG0oRpK9zLoI1q0BiOaw3jQYYUEBvoP8dELT0iJtFMYeD2nxb 6P/s60eWu+swuhsOG08L2qKEgCUcJT0QPtsaMy+XuAJoM9UCu9HROR5ShNlI9rmrzKFe 9H8IaBXMXeX1JHDPasEj0LZ+MRs0SqThFIfs9dGuwIQGrmYD94LnKGTQyASUqQ1dsXBe KvEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9nwj8t35sTRfZBy4W/qH00ECayOdTNn3a9nb6TOjuWA=; b=diN6u0CEbciCliLLOcbW40UUqA1BJIBVu5c0z8iVrk2jWlTPlrGGBgxNzgawLOjnnP T1+i6DFD8HkHOpCRcf2VIsH2Nsfl2sWzfnQqmKZxIS9qH1mda7n3kqlwXWrrU1w+EiGT KKSs1lsDnQLDnCqGo2oZ06LhtX92l3hzdWsp2sh3Ru/9A36UluIhA25P7wHF+Y1cOB4H fzPaMb+ljIdTuUkple66EyYZnN3ybK87FJVAREguckxbLcu7CjPzhyrrYGqZxoSV6o3O YsfpoWDofeOgPBtwt4PXLQWQiY7vBxHQoobksr5juLCPGBvIj8qUqxX6PXPBOBgFpZnB gMFg== X-Gm-Message-State: AHPjjUjQLWbapnZgEUTTf0hcCy7Ivg5dxzZTj6ju6zDdZ8rGIf0j7bWZ GAMpUBNRvdfl9g== X-Google-Smtp-Source: ADKCNb5E3DaeH4gviRp5TqaytQOiMMB7gLXLtyRBSiJwH4i/7rGQ5HEAG46N8n/foipIKMiGY91VRw== X-Received: by 10.99.110.142 with SMTP id j136mr1840757pgc.390.1504848295459; Thu, 07 Sep 2017 22:24:55 -0700 (PDT) Received: from Asurada-CZ80.localdomain (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id q12sm1404799pgs.47.2017.09.07.22.24.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Sep 2017 22:24:54 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org Date: Thu, 7 Sep 2017 22:23:43 -0700 Message-Id: <1504848223-3376-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: alsa-devel@alsa-project.org, timur@tabi.org, arnaud.mouiche@invoxia.com, linux-kernel@vger.kernel.org, tiwai@suse.com, lgirdwood@gmail.com, caleb@crome.org, mpa@pengutronix.de, max.krummenacher@toradex.com, lukma@denx.de, fabio.estevam@nxp.com, mail@maciej.szmigiero.name, linuxppc-dev@lists.ozlabs.org Subject: [alsa-devel] [PATCH] ASoC: fsl_ssi: Override bit clock rate based on slot number X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The set_sysclk() now is used to override the output bit clock rate. But this is not a common way to implement a set_dai_sysclk(). And this creates a problem when a general machine driver (simple-card for example) tries to do set_dai_sysclk() by passing an input clock rate for the baud clock instead of setting the bit clock rate as fsl_ssi driver expected. So this patch solves this problem by firstly removing set_sysclk() since the hw_params() can calculate the bit clock rate. Secondly, in order not to break those TDM use cases which previously might have been using set_sysclk() to override the bit clock rate, this patch changes the driver to override it based on the slot number. The patch also removes an obsolete comment of the dir parameter. Signed-off-by: Nicolin Chen Tested-by: Ɓukasz Majewski Tested-by: Lukasz Majewski --- sound/soc/fsl/fsl_ssi.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 64598d1..3657c88 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -197,12 +197,12 @@ struct fsl_ssi_soc_data { * @use_dma: DMA is used or FIQ with stream filter * @use_dual_fifo: DMA with support for both FIFOs used * @fifo_deph: Depth of the SSI FIFOs + * @slots: number of slots * @rxtx_reg_val: Specific register settings for receive/transmit configuration * * @clk: SSI clock * @baudclk: SSI baud clock for master mode * @baudclk_streams: Active streams that are using baudclk - * @bitclk_freq: bitclock frequency set by .set_dai_sysclk * * @dma_params_tx: DMA transmit parameters * @dma_params_rx: DMA receive parameters @@ -233,12 +233,12 @@ struct fsl_ssi_private { bool use_dual_fifo; bool has_ipg_clk_name; unsigned int fifo_depth; + unsigned int slots; struct fsl_ssi_rxtx_reg_val rxtx_reg_val; struct clk *clk; struct clk *baudclk; unsigned int baudclk_streams; - unsigned int bitclk_freq; /* regcache for volatile regs */ u32 regcache_sfcsr; @@ -700,8 +700,7 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream, * Note: This function can be only called when using SSI as DAI master * * Quick instruction for parameters: - * freq: Output BCLK frequency = samplerate * 32 (fixed) * channels - * dir: SND_SOC_CLOCK_OUT -> TxBCLK, SND_SOC_CLOCK_IN -> RxBCLK. + * freq: Output BCLK frequency = samplerate * 32 (fixed) * slots (or channels) */ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, struct snd_soc_dai *cpu_dai, @@ -716,9 +715,9 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, unsigned int freq; bool baudclk_is_used; - /* Prefer the explicitly set bitclock frequency */ - if (ssi_private->bitclk_freq) - freq = ssi_private->bitclk_freq; + /* Generate bit clock based on the slot or channel number */ + if (ssi_private->slots) + freq = ssi_private->slots * 32 * params_rate(hw_params); else freq = params_channels(hw_params) * 32 * params_rate(hw_params); @@ -805,16 +804,6 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, return 0; } -static int fsl_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, - int clk_id, unsigned int freq, int dir) -{ - struct fsl_ssi_private *ssi_private = snd_soc_dai_get_drvdata(cpu_dai); - - ssi_private->bitclk_freq = freq; - - return 0; -} - /** * fsl_ssi_hw_params - program the sample size * @@ -1121,6 +1110,8 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, regmap_update_bits(regs, CCSR_SSI_SCR, CCSR_SSI_SCR_SSIEN, val); + ssi_private->slots = slots; + return 0; } @@ -1191,7 +1182,6 @@ static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { .hw_params = fsl_ssi_hw_params, .hw_free = fsl_ssi_hw_free, .set_fmt = fsl_ssi_set_dai_fmt, - .set_sysclk = fsl_ssi_set_dai_sysclk, .set_tdm_slot = fsl_ssi_set_dai_tdm_slot, .trigger = fsl_ssi_trigger, };