diff options
author | Jyri Sarha <jsarha@ti.com> | 2015-04-23 09:16:06 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-04-30 15:47:16 -0400 |
commit | 518f6bab13842a5f25bd8f89b1cae32aa8adf91f (patch) | |
tree | e3e637b885e9a425760e9e6963079399ecde69be | |
parent | 5935a05626bc84810175e5f7b03b355a90769368 (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>
-rw-r--r-- | sound/soc/davinci/davinci-mcasp.c | 28 |
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, | |||
1023 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); | 1023 | hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); |
1024 | int sbits = params_width(params); | 1024 | int sbits = params_width(params); |
1025 | int slots = rd->mcasp->tdm_slots; | 1025 | int slots = rd->mcasp->tdm_slots; |
1026 | unsigned int list[ARRAY_SIZE(davinci_mcasp_dai_rates)]; | 1026 | struct snd_interval range; |
1027 | int i, count = 0; | 1027 | int i; |
1028 | |||
1029 | snd_interval_any(&range); | ||
1030 | range.empty = 1; | ||
1028 | 1031 | ||
1029 | for (i = 0; i < ARRAY_SIZE(davinci_mcasp_dai_rates); i++) { | 1032 | for (i = 0; i < ARRAY_SIZE(davinci_mcasp_dai_rates); i++) { |
1030 | if (ri->min <= davinci_mcasp_dai_rates[i] && | 1033 | if (snd_interval_test(ri, davinci_mcasp_dai_rates[i])) { |
1031 | ri->max >= davinci_mcasp_dai_rates[i]) { | ||
1032 | uint bclk_freq = sbits*slots* | 1034 | uint bclk_freq = sbits*slots* |
1033 | davinci_mcasp_dai_rates[i]; | 1035 | davinci_mcasp_dai_rates[i]; |
1034 | int ppm; | 1036 | int ppm; |
1035 | 1037 | ||
1036 | davinci_mcasp_calc_clk_div(rd->mcasp, bclk_freq, &ppm); | 1038 | davinci_mcasp_calc_clk_div(rd->mcasp, bclk_freq, &ppm); |
1037 | if (abs(ppm) < DAVINCI_MAX_RATE_ERROR_PPM) | 1039 | if (abs(ppm) < DAVINCI_MAX_RATE_ERROR_PPM) { |
1038 | list[count++] = davinci_mcasp_dai_rates[i]; | 1040 | if (range.empty) { |
1041 | range.min = davinci_mcasp_dai_rates[i]; | ||
1042 | range.empty = 0; | ||
1043 | } | ||
1044 | range.max = davinci_mcasp_dai_rates[i]; | ||
1045 | } | ||
1039 | } | 1046 | } |
1040 | } | 1047 | } |
1048 | |||
1041 | dev_dbg(rd->mcasp->dev, | 1049 | dev_dbg(rd->mcasp->dev, |
1042 | "%d frequencies (%d-%d) for %d sbits and %d tdm slots\n", | 1050 | "Frequencies %d-%d -> %d-%d for %d sbits and %d tdm slots\n", |
1043 | count, ri->min, ri->max, sbits, slots); | 1051 | ri->min, ri->max, range.min, range.max, sbits, slots); |
1044 | 1052 | ||
1045 | return snd_interval_list(hw_param_interval(params, rule->var), | 1053 | return snd_interval_refine(hw_param_interval(params, rule->var), |
1046 | count, list, 0); | 1054 | &range); |
1047 | } | 1055 | } |
1048 | 1056 | ||
1049 | static int davinci_mcasp_hw_rule_format(struct snd_pcm_hw_params *params, | 1057 | static int davinci_mcasp_hw_rule_format(struct snd_pcm_hw_params *params, |