@@ -1095,33 +1095,30 @@ static int davinci_mcasp_hw_rule_channels(struct snd_pcm_hw_params *params,
int rate = params_rate(params);
int max_chan_per_wire = rd->mcasp->tdm_slots < ci->max ?
rd->mcasp->tdm_slots : ci->max;
- unsigned int list[ci->max - ci->min + 1];
- int c1, c, count = 0;
+ struct snd_interval range;
+ int c1;
+ snd_interval_any(&range);
+ range.min = range.max = 0;
for (c1 = ci->min; c1 <= max_chan_per_wire; c1++) {
uint bclk_freq = c1*sbits*rate;
int ppm;
davinci_mcasp_calc_clk_div(rd->mcasp, bclk_freq, &ppm);
if (abs(ppm) < DAVINCI_MAX_RATE_ERROR_PPM) {
+ if (!range.min)
+ range.min = c1;
+ range.max = c1;
/* If we can use all tdm_slots, we can put any
amount of channels to remaining wires as
long as they fit in. */
- if (c1 == rd->mcasp->tdm_slots) {
- for (c = c1; c <= rd->serializers*c1 &&
- c <= ci->max; c++)
- list[count++] = c;
- } else {
- list[count++] = c1;
- }
+ if (c1 == rd->mcasp->tdm_slots)
+ range.max = rd->serializers * c1;
}
}
- dev_dbg(rd->mcasp->dev,
- "%d possible channel counts (%d-%d) for %d Hz and %d sbits\n",
- count, ci->min, ci->max, rate, sbits);
- 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_startup(struct snd_pcm_substream *substream,