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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DC6FC433F5 for ; Thu, 7 Apr 2022 07:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233537AbiDGHHA (ORCPT ); Thu, 7 Apr 2022 03:07:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240330AbiDGHG7 (ORCPT ); Thu, 7 Apr 2022 03:06:59 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8896524B5CF for ; Thu, 7 Apr 2022 00:05:00 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncMCK-0002PS-Os; Thu, 07 Apr 2022 09:04:52 +0200 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1ncMCK-00043z-0E; Thu, 07 Apr 2022 09:04:52 +0200 Date: Thu, 7 Apr 2022 09:04:51 +0200 From: Sascha Hauer To: Shengjiu Wang Cc: alsa-devel@alsa-project.org, Xiubo Li , Fabio Estevam , Sascha Hauer , Vinod Koul , NXP Linux Team , dmaengine@vger.kernel.org Subject: Re: [PATCH v3 14/20] ASoC: fsl_micfil: Drop get_pdm_clk() Message-ID: <20220407070451.GY4012@pengutronix.de> References: <20220405075959.2744803-1-s.hauer@pengutronix.de> <20220405075959.2744803-15-s.hauer@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:04:04 up 7 days, 19:33, 61 users, load average: 0.26, 0.73, 0.52 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dmaengine@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org On Thu, Apr 07, 2022 at 11:41:52AM +0800, Shengjiu Wang wrote: > On Tue, Apr 5, 2022 at 4:00 PM Sascha Hauer <[1]s.hauer@pengutronix.de> > wrote: > > get_pdm_clk() calculates the PDM clock based on the quality setting, > but really the PDM clock is independent of the quality, it's always > rate * 4 * micfil->osr. Just drop the function and do the calculation > in the caller. > > Signed-off-by: Sascha Hauer <[2]s.hauer@pengutronix.de> > --- >  sound/soc/fsl/fsl_micfil.c | 38 +------------------------------------- >  1 file changed, 1 insertion(+), 37 deletions(-) > > diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c > index 4b4b7fbbf5c4f..8335646a84d17 100644 > --- a/sound/soc/fsl/fsl_micfil.c > +++ b/sound/soc/fsl/fsl_micfil.c > @@ -111,42 +111,6 @@ static const struct snd_kcontrol_new > fsl_micfil_snd_controls[] = { >                      snd_soc_get_enum_double, snd_soc_put_enum_double), >  }; > > -static inline int get_pdm_clk(struct fsl_micfil *micfil, > -                             unsigned int rate) > -{ > -       u32 ctrl2_reg; > -       int qsel; > -       int bclk; > -       int osr = MICFIL_OSR_DEFAULT; > - > -       regmap_read(micfil->regmap, REG_MICFIL_CTRL2, &ctrl2_reg); > -       qsel = FIELD_GET(MICFIL_CTRL2_QSEL, ctrl2_reg); > - > -       switch (qsel) { > -       case MICFIL_QSEL_HIGH_QUALITY: > -               bclk = rate * 8 * osr / 2; /* kfactor = 0.5 */ > -               break; > -       case MICFIL_QSEL_MEDIUM_QUALITY: > -       case MICFIL_QSEL_VLOW0_QUALITY: > -               bclk = rate * 4 * osr * 1; /* kfactor = 1 */ > -               break; > -       case MICFIL_QSEL_LOW_QUALITY: > -       case MICFIL_QSEL_VLOW1_QUALITY: > -               bclk = rate * 2 * osr * 2; /* kfactor = 2 */ > -               break; > -       case MICFIL_QSEL_VLOW2_QUALITY: > -               bclk = rate * osr * 4; /* kfactor = 4 */ > -               break; > -       default: > -               dev_err(&micfil->pdev->dev, > -                       "Please make sure you select a valid > quality.\n"); > -               bclk = -1; > -               break; > -       } > - > -       return bclk; > -} > - >  static inline int get_clk_div(struct fsl_micfil *micfil, >                               unsigned int rate) >  { > @@ -155,7 +119,7 @@ static inline int get_clk_div(struct fsl_micfil > *micfil, > >         mclk_rate = clk_get_rate(micfil->mclk); > > -       clk_div = mclk_rate / (get_pdm_clk(micfil, rate) * 2); > +       clk_div = mclk_rate / (rate * micfil->osr * 8); > > Where is micfil->osr assigned a value? Should be MICFIL_OSR_DEFAULT instead. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | 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 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80B29C433F5 for ; Thu, 7 Apr 2022 07:05:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CBFA5173F; Thu, 7 Apr 2022 09:05:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CBFA5173F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1649315154; bh=Yi5ywt6yEIomD3NlhRqxwQdS7ErGkhZq72f4qhtQQz0=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fdebzIl7+BcqdyR4+3Vp8K1S4N+WHRMybW5zFmmmCrv2qTJ2cHOpBmru8tLZQgl9k c2Kgv8N6Us83oky2XTXRFg0TXB4GG7L8i3YOC/jy8KPH0x/oFKE6h9vhpARcB7Vslc HB92KshtIN+9YqArxreVm6gxHj6isNiQ85CRZHeI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 51727F8012A; Thu, 7 Apr 2022 09:05:04 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6CFA5F8012A; Thu, 7 Apr 2022 09:05:01 +0200 (CEST) Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6A6B0F80085 for ; Thu, 7 Apr 2022 09:04:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6A6B0F80085 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncMCK-0002PS-Os; Thu, 07 Apr 2022 09:04:52 +0200 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1ncMCK-00043z-0E; Thu, 07 Apr 2022 09:04:52 +0200 Date: Thu, 7 Apr 2022 09:04:51 +0200 From: Sascha Hauer To: Shengjiu Wang Subject: Re: [PATCH v3 14/20] ASoC: fsl_micfil: Drop get_pdm_clk() Message-ID: <20220407070451.GY4012@pengutronix.de> References: <20220405075959.2744803-1-s.hauer@pengutronix.de> <20220405075959.2744803-15-s.hauer@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:04:04 up 7 days, 19:33, 61 users, load average: 0.26, 0.73, 0.52 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: alsa-devel@alsa-project.org Cc: alsa-devel@alsa-project.org, Xiubo Li , Vinod Koul , NXP Linux Team , Sascha Hauer , dmaengine@vger.kernel.org, Fabio Estevam X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Thu, Apr 07, 2022 at 11:41:52AM +0800, Shengjiu Wang wrote: > On Tue, Apr 5, 2022 at 4:00 PM Sascha Hauer <[1]s.hauer@pengutronix.de> > wrote: > > get_pdm_clk() calculates the PDM clock based on the quality setting, > but really the PDM clock is independent of the quality, it's always > rate * 4 * micfil->osr. Just drop the function and do the calculation > in the caller. > > Signed-off-by: Sascha Hauer <[2]s.hauer@pengutronix.de> > --- >  sound/soc/fsl/fsl_micfil.c | 38 +------------------------------------- >  1 file changed, 1 insertion(+), 37 deletions(-) > > diff --git a/sound/soc/fsl/fsl_micfil.c b/sound/soc/fsl/fsl_micfil.c > index 4b4b7fbbf5c4f..8335646a84d17 100644 > --- a/sound/soc/fsl/fsl_micfil.c > +++ b/sound/soc/fsl/fsl_micfil.c > @@ -111,42 +111,6 @@ static const struct snd_kcontrol_new > fsl_micfil_snd_controls[] = { >                      snd_soc_get_enum_double, snd_soc_put_enum_double), >  }; > > -static inline int get_pdm_clk(struct fsl_micfil *micfil, > -                             unsigned int rate) > -{ > -       u32 ctrl2_reg; > -       int qsel; > -       int bclk; > -       int osr = MICFIL_OSR_DEFAULT; > - > -       regmap_read(micfil->regmap, REG_MICFIL_CTRL2, &ctrl2_reg); > -       qsel = FIELD_GET(MICFIL_CTRL2_QSEL, ctrl2_reg); > - > -       switch (qsel) { > -       case MICFIL_QSEL_HIGH_QUALITY: > -               bclk = rate * 8 * osr / 2; /* kfactor = 0.5 */ > -               break; > -       case MICFIL_QSEL_MEDIUM_QUALITY: > -       case MICFIL_QSEL_VLOW0_QUALITY: > -               bclk = rate * 4 * osr * 1; /* kfactor = 1 */ > -               break; > -       case MICFIL_QSEL_LOW_QUALITY: > -       case MICFIL_QSEL_VLOW1_QUALITY: > -               bclk = rate * 2 * osr * 2; /* kfactor = 2 */ > -               break; > -       case MICFIL_QSEL_VLOW2_QUALITY: > -               bclk = rate * osr * 4; /* kfactor = 4 */ > -               break; > -       default: > -               dev_err(&micfil->pdev->dev, > -                       "Please make sure you select a valid > quality.\n"); > -               bclk = -1; > -               break; > -       } > - > -       return bclk; > -} > - >  static inline int get_clk_div(struct fsl_micfil *micfil, >                               unsigned int rate) >  { > @@ -155,7 +119,7 @@ static inline int get_clk_div(struct fsl_micfil > *micfil, > >         mclk_rate = clk_get_rate(micfil->mclk); > > -       clk_div = mclk_rate / (get_pdm_clk(micfil, rate) * 2); > +       clk_div = mclk_rate / (rate * micfil->osr * 8); > > Where is micfil->osr assigned a value? Should be MICFIL_OSR_DEFAULT instead. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |