Skip to content

Commit 61cc2d7

Browse files
committed
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 <[email protected]> Tested-by: Dylan Robinson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 75c16b5 commit 61cc2d7

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

sound/usb/pcm.c

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -695,41 +695,30 @@ static int match_endpoint_audioformats(struct snd_usb_substream *subs,
695695
struct audioformat *match, int rate,
696696
snd_pcm_format_t pcm_format)
697697
{
698-
int i;
699-
int score = 0;
698+
int i, score;
700699

701-
if (fp->channels < 1) {
702-
dev_dbg(&subs->dev->dev,
703-
"%s: (fmt @%p) no channels\n", __func__, fp);
700+
if (fp->channels < 1)
704701
return 0;
705-
}
706702

707-
if (!(fp->formats & pcm_format_to_bits(pcm_format))) {
708-
dev_dbg(&subs->dev->dev,
709-
"%s: (fmt @%p) no match for format %d\n", __func__,
710-
fp, pcm_format);
703+
if (!(fp->formats & pcm_format_to_bits(pcm_format)))
711704
return 0;
712-
}
713705

714-
for (i = 0; i < fp->nr_rates; i++) {
715-
if (fp->rate_table[i] == rate) {
716-
score++;
717-
break;
706+
if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) {
707+
if (rate < fp->rate_min || rate > fp->rate_max)
708+
return 0;
709+
} else {
710+
for (i = 0; i < fp->nr_rates; i++) {
711+
if (fp->rate_table[i] == rate)
712+
break;
718713
}
719-
}
720-
if (!score) {
721-
dev_dbg(&subs->dev->dev,
722-
"%s: (fmt @%p) no match for rate %d\n", __func__,
723-
fp, rate);
724-
return 0;
714+
if (i >= fp->nr_rates)
715+
return 0;
725716
}
726717

718+
score = 1;
727719
if (fp->channels == match->channels)
728720
score++;
729721

730-
dev_dbg(&subs->dev->dev,
731-
"%s: (fmt @%p) score %d\n", __func__, fp, score);
732-
733722
return score;
734723
}
735724

0 commit comments

Comments
 (0)