mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-04 16:15:11 +00:00
ALSA: usb-audio: Fix EP matching for continuous rates
The function to evaluate the match of the parameters with an EP assumes only the discrete rate tables and doesn't handle the continuous rates properly. This patch fixes match_endpoint_audioformats() to handle the continuous rates. Also the almost useless debug prints there are dropped. Tested-by: Keith Milner <kamilner@superlative.org> Tested-by: Dylan Robinson <dylan_robinson@motu.com> Link: https://lore.kernel.org/r/20201123085347.19667-25-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
75c16b5147
commit
61cc2d775e
1 changed files with 13 additions and 24 deletions
|
@ -695,41 +695,30 @@ static int match_endpoint_audioformats(struct snd_usb_substream *subs,
|
||||||
struct audioformat *match, int rate,
|
struct audioformat *match, int rate,
|
||||||
snd_pcm_format_t pcm_format)
|
snd_pcm_format_t pcm_format)
|
||||||
{
|
{
|
||||||
int i;
|
int i, score;
|
||||||
int score = 0;
|
|
||||||
|
|
||||||
if (fp->channels < 1) {
|
if (fp->channels < 1)
|
||||||
dev_dbg(&subs->dev->dev,
|
|
||||||
"%s: (fmt @%p) no channels\n", __func__, fp);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(fp->formats & pcm_format_to_bits(pcm_format))) {
|
if (!(fp->formats & pcm_format_to_bits(pcm_format)))
|
||||||
dev_dbg(&subs->dev->dev,
|
|
||||||
"%s: (fmt @%p) no match for format %d\n", __func__,
|
|
||||||
fp, pcm_format);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < fp->nr_rates; i++) {
|
if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) {
|
||||||
if (fp->rate_table[i] == rate) {
|
if (rate < fp->rate_min || rate > fp->rate_max)
|
||||||
score++;
|
return 0;
|
||||||
break;
|
} else {
|
||||||
|
for (i = 0; i < fp->nr_rates; i++) {
|
||||||
|
if (fp->rate_table[i] == rate)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
if (i >= fp->nr_rates)
|
||||||
if (!score) {
|
return 0;
|
||||||
dev_dbg(&subs->dev->dev,
|
|
||||||
"%s: (fmt @%p) no match for rate %d\n", __func__,
|
|
||||||
fp, rate);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
score = 1;
|
||||||
if (fp->channels == match->channels)
|
if (fp->channels == match->channels)
|
||||||
score++;
|
score++;
|
||||||
|
|
||||||
dev_dbg(&subs->dev->dev,
|
|
||||||
"%s: (fmt @%p) score %d\n", __func__, fp, score);
|
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue