summaryrefslogtreecommitdiff
path: root/sound/soc/davinci
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2015-04-23 16:16:06 +0300
committerMark Brown <broonie@kernel.org>2015-04-30 20:47:16 +0100
commit518f6bab13842a5f25bd8f89b1cae32aa8adf91f (patch)
treee3e637b885e9a425760e9e6963079399ecde69be /sound/soc/davinci
parent5935a05626bc84810175e5f7b03b355a90769368 (diff)
ASoC: davinci-macsp: Optimize implicit BLCK sample-rate rule
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 <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/davinci')
-rw-r--r--sound/soc/davinci/davinci-mcasp.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index f8417072c66b..56da8ce1faf3 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -1023,27 +1023,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,