From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F012CC4CEC7 for ; Thu, 12 Sep 2019 23:23:29 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33E5B20830 for ; Thu, 12 Sep 2019 23:23:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ONE2qNZw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33E5B20830 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46Tvvy3th1zF50t for ; Fri, 13 Sep 2019 09:23:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::544; helo=mail-pg1-x544.google.com; envelope-from=nicoleotsuka@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ONE2qNZw"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46Tvt21HzlzF4yx for ; Fri, 13 Sep 2019 09:21:45 +1000 (AEST) Received: by mail-pg1-x544.google.com with SMTP id i18so14235983pgl.11 for ; Thu, 12 Sep 2019 16:21:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=cfuHGRLy8MAHGaooaO76at7ZU9RjLSy1/AcY20LrGz4=; b=ONE2qNZwg1741FDo5uEQ6I8c64u77O4PBT6nDWoToKFs6XNpmkauOrIGsen+NFNWKV jnR3QuBhnGS5ogeZOBXO3uWj3PKtpde7DFGXDS/gy45S0MkhYg2ZuZ9tv47GxHKEI7Lm QLla4db4MBry4fMHaZZMlkvF0xn1ZZuwm6y9BBwMsE9lUfdgzhnKGA2vsvmMM6NkIgf4 +ShG8+gSO1V0hQ05HgVVq8DvxRSgxHt/4hovXdKNTn/jlkN68suNPxf1HU5OqtaQp7Lu Eb9d59lkxDWy37PUJEsfFg3NJ9jo02AgM95Uf+Vlm0ycnPx9idp4tkBe/+ceowtOg3tn URIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cfuHGRLy8MAHGaooaO76at7ZU9RjLSy1/AcY20LrGz4=; b=HYKUMfoHcZY3EeJAaPgRiylTPGToDvTLeqrr3e5oP8APTLnnDk8EIeIMM60MSAYxEh VPztEzr/JTOrVkSPfGHMpezCGvCr1/oCh6qcNVPVHZlrz/Ny2KNN2BTbwxqMxy9c/CmX 33t4CEfBSgUi9FkvpajJJE8mbYTClzxt5svPZvCUjhehQzX9I4s0gNlT0Jc8bk2a8XsI v7W3HIdLXil/ySxx5c7gfArC/gwI/xhOVgAJkfJ6cZlYshi2juLoxSN75bF4u9YDd9Ar oc+kwWG3BdlxS++TCjIG70AsN4Cjufh74VnVsF0h2OOG4rqvzba3VkGKMlw/EDbdrwKP VnRA== X-Gm-Message-State: APjAAAXupGTVDpkL8mCpGzOx0VLOjTegTmryM95V2CZs7gSHtU3o1Dcg ymG+poJnVj3jC4b+1s6Leto= X-Google-Smtp-Source: APXvYqzZIQm+h/0QNu9dg8DnY8zWPNl00lnNgKtEEAubibhAR2pxRqBWHKTo9/jS0PgzYsyCyzRRkQ== X-Received: by 2002:a63:4824:: with SMTP id v36mr13497605pga.385.1568330502215; Thu, 12 Sep 2019 16:21:42 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id l62sm42479694pfl.167.2019.09.12.16.21.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Sep 2019 16:21:41 -0700 (PDT) Date: Thu, 12 Sep 2019 16:21:20 -0700 From: Nicolin Chen To: Shengjiu Wang Subject: Re: [PATCH 1/3] ASoC: fsl_asrc: Use in(out)put_format instead of in(out)put_word_width Message-ID: <20190912232119.GB24937@Asurada-Nvidia.nvidia.com> References: <65e96ca15afd4a282b122f3ea8b13642cf4614c7.1568025083.git.shengjiu.wang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <65e96ca15afd4a282b122f3ea8b13642cf4614c7.1568025083.git.shengjiu.wang@nxp.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, timur@kernel.org, Xiubo.Lee@gmail.com, linuxppc-dev@lists.ozlabs.org, tiwai@suse.com, lgirdwood@gmail.com, perex@perex.cz, broonie@kernel.org, festevam@gmail.com, linux-kernel@vger.kernel.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Sep 09, 2019 at 06:33:19PM -0400, Shengjiu Wang wrote: > snd_pcm_format_t is more formal than enum asrc_word_width, which has > two property, width and physical width, which is more accurate than > enum asrc_word_width. So it is better to use in(out)put_format > instead of in(out)put_word_width. > > Signed-off-by: Shengjiu Wang Acked-by: Nicolin Chen > --- > sound/soc/fsl/fsl_asrc.c | 56 +++++++++++++++++++++++++++------------- > sound/soc/fsl/fsl_asrc.h | 4 +-- > 2 files changed, 40 insertions(+), 20 deletions(-) > > diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c > index cfa40ef6b1ca..4d3804a1ea55 100644 > --- a/sound/soc/fsl/fsl_asrc.c > +++ b/sound/soc/fsl/fsl_asrc.c > @@ -265,6 +265,8 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) > struct asrc_config *config = pair->config; > struct fsl_asrc *asrc_priv = pair->asrc_priv; > enum asrc_pair_index index = pair->index; > + enum asrc_word_width input_word_width; > + enum asrc_word_width output_word_width; > u32 inrate, outrate, indiv, outdiv; > u32 clk_index[2], div[2]; > int in, out, channels; > @@ -283,9 +285,32 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) > return -EINVAL; > } > > - /* Validate output width */ > - if (config->output_word_width == ASRC_WIDTH_8_BIT) { > - pair_err("does not support 8bit width output\n"); > + switch (snd_pcm_format_width(config->input_format)) { > + case 8: > + input_word_width = ASRC_WIDTH_8_BIT; > + break; > + case 16: > + input_word_width = ASRC_WIDTH_16_BIT; > + break; > + case 24: > + input_word_width = ASRC_WIDTH_24_BIT; > + break; > + default: > + pair_err("does not support this input format, %d\n", > + config->input_format); > + return -EINVAL; > + } > + > + switch (snd_pcm_format_width(config->output_format)) { > + case 16: > + output_word_width = ASRC_WIDTH_16_BIT; > + break; > + case 24: > + output_word_width = ASRC_WIDTH_24_BIT; > + break; > + default: > + pair_err("does not support this output format, %d\n", > + config->output_format); > return -EINVAL; > } > > @@ -383,8 +408,8 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) > /* Implement word_width configurations */ > regmap_update_bits(asrc_priv->regmap, REG_ASRMCR1(index), > ASRMCR1i_OW16_MASK | ASRMCR1i_IWD_MASK, > - ASRMCR1i_OW16(config->output_word_width) | > - ASRMCR1i_IWD(config->input_word_width)); > + ASRMCR1i_OW16(output_word_width) | > + ASRMCR1i_IWD(input_word_width)); > > /* Enable BUFFER STALL */ > regmap_update_bits(asrc_priv->regmap, REG_ASRMCR(index), > @@ -497,13 +522,13 @@ static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream, > struct snd_soc_dai *dai) > { > struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai); > - int width = params_width(params); > struct snd_pcm_runtime *runtime = substream->runtime; > struct fsl_asrc_pair *pair = runtime->private_data; > unsigned int channels = params_channels(params); > unsigned int rate = params_rate(params); > struct asrc_config config; > - int word_width, ret; > + snd_pcm_format_t format; > + int ret; > > ret = fsl_asrc_request_pair(channels, pair); > if (ret) { > @@ -513,15 +538,10 @@ static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream, > > pair->config = &config; > > - if (width == 16) > - width = ASRC_WIDTH_16_BIT; > - else > - width = ASRC_WIDTH_24_BIT; > - > if (asrc_priv->asrc_width == 16) > - word_width = ASRC_WIDTH_16_BIT; > + format = SNDRV_PCM_FORMAT_S16_LE; > else > - word_width = ASRC_WIDTH_24_BIT; > + format = SNDRV_PCM_FORMAT_S24_LE; > > config.pair = pair->index; > config.channel_num = channels; > @@ -529,13 +549,13 @@ static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream, > config.outclk = OUTCLK_ASRCK1_CLK; > > if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { > - config.input_word_width = width; > - config.output_word_width = word_width; > + config.input_format = params_format(params); > + config.output_format = format; > config.input_sample_rate = rate; > config.output_sample_rate = asrc_priv->asrc_rate; > } else { > - config.input_word_width = word_width; > - config.output_word_width = width; > + config.input_format = format; > + config.output_format = params_format(params); > config.input_sample_rate = asrc_priv->asrc_rate; > config.output_sample_rate = rate; > } > diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h > index c60075112570..38af485bdd22 100644 > --- a/sound/soc/fsl/fsl_asrc.h > +++ b/sound/soc/fsl/fsl_asrc.h > @@ -342,8 +342,8 @@ struct asrc_config { > unsigned int dma_buffer_size; > unsigned int input_sample_rate; > unsigned int output_sample_rate; > - enum asrc_word_width input_word_width; > - enum asrc_word_width output_word_width; > + snd_pcm_format_t input_format; > + snd_pcm_format_t output_format; > enum asrc_inclk inclk; > enum asrc_outclk outclk; > }; > -- > 2.21.0 >