From patchwork Mon Apr 20 13:58:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 6242541 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BE319BF4A6 for ; Mon, 20 Apr 2015 13:59:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED36A20421 for ; Mon, 20 Apr 2015 13:59:50 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 9A8FF203F7 for ; Mon, 20 Apr 2015 13:59:49 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 96C67265D05; Mon, 20 Apr 2015 15:59:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 00B15265A2A; Mon, 20 Apr 2015 15:58:48 +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 8B1AD265A2E; Mon, 20 Apr 2015 15:58:46 +0200 (CEST) Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by alsa0.perex.cz (Postfix) with ESMTP id 4C50D2659B6 for ; Mon, 20 Apr 2015 15:58:35 +0200 (CEST) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t3KDwVMQ013755; Mon, 20 Apr 2015 08:58:31 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t3KDwUnW030415; Mon, 20 Apr 2015 08:58:30 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Mon, 20 Apr 2015 08:58:30 -0500 Received: from imryr.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t3KDwOdS024203; Mon, 20 Apr 2015 08:58:28 -0500 From: Jyri Sarha To: Date: Mon, 20 Apr 2015 16:58:19 +0300 Message-ID: <069c38ce1799233b61462885d827f7c0e28e8bf8.1429537509.git.jsarha@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 Cc: peter.ujfalusi@ti.com, Jyri Sarha , liam.r.girdwood@linux.intel.com, broonie@kernel.org, misael.lopez@ti.com, dan.carpenter@oracle.com Subject: [alsa-devel] [PATCH 2/2] ASoC: davinci-macsp: Optimize implicit BLCK sample-rate rule 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP There is no need to copy the list of all supported sample-rates. Finding the supported endpoints within the current range is enough (see snd_interval_list()). Signed-off-by: Jyri Sarha --- sound/soc/davinci/davinci-mcasp.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index a01c6db..71127fe 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1022,27 +1022,35 @@ static int davinci_mcasp_hw_rule_rate(struct snd_pcm_hw_params *params, hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); int sbits = params_width(params); int slots = rd->mcasp->tdm_slots; - unsigned int list[ARRAY_SIZE(davinci_mcasp_dai_rates)]; - int i, count = 0; + struct snd_interval range; + int i; + + snd_interval_any(&range); + range.empty = 1; for (i = 0; i < ARRAY_SIZE(davinci_mcasp_dai_rates); i++) { - if (ri->min <= davinci_mcasp_dai_rates[i] && - ri->max >= davinci_mcasp_dai_rates[i]) { + if (snd_interval_test(ri, davinci_mcasp_dai_rates[i])) { uint bclk_freq = sbits*slots* davinci_mcasp_dai_rates[i]; int ppm; davinci_mcasp_calc_clk_div(rd->mcasp, bclk_freq, &ppm); - if (abs(ppm) < DAVINCI_MAX_RATE_ERROR_PPM) - list[count++] = davinci_mcasp_dai_rates[i]; + if (abs(ppm) < DAVINCI_MAX_RATE_ERROR_PPM) { + if (range.empty) { + range.min = davinci_mcasp_dai_rates[i]; + range.empty = 0; + } + range.max = davinci_mcasp_dai_rates[i]; + } } } + dev_dbg(rd->mcasp->dev, - "%d frequencies (%d-%d) for %d sbits and %d tdm slots\n", - count, ri->min, ri->max, sbits, slots); + "Frequencies %d-%d -> %d-%d for %d sbits and %d tdm slots\n", + ri->min, ri->max, range.min, range.max, sbits, slots); - return snd_interval_list(hw_param_interval(params, rule->var), - count, list, 0); + return snd_interval_refine(hw_param_interval(params, rule->var), + &range); } static int davinci_mcasp_hw_rule_format(struct snd_pcm_hw_params *params,