aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/usb/usbaudio.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 2ab83129d9b0..80863093d2c8 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2524,7 +2524,6 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
2524 * build the rate table and bitmap flags 2524 * build the rate table and bitmap flags
2525 */ 2525 */
2526 int r, idx; 2526 int r, idx;
2527 unsigned int nonzero_rates = 0;
2528 2527
2529 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); 2528 fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
2530 if (fp->rate_table == NULL) { 2529 if (fp->rate_table == NULL) {
@@ -2532,24 +2531,26 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
2532 return -1; 2531 return -1;
2533 } 2532 }
2534 2533
2535 fp->nr_rates = nr_rates; 2534 fp->nr_rates = 0;
2536 fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); 2535 fp->rate_min = fp->rate_max = 0;
2537 for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { 2536 for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) {
2538 unsigned int rate = combine_triple(&fmt[idx]); 2537 unsigned int rate = combine_triple(&fmt[idx]);
2538 if (!rate)
2539 continue;
2539 /* C-Media CM6501 mislabels its 96 kHz altsetting */ 2540 /* C-Media CM6501 mislabels its 96 kHz altsetting */
2540 if (rate == 48000 && nr_rates == 1 && 2541 if (rate == 48000 && nr_rates == 1 &&
2541 chip->usb_id == USB_ID(0x0d8c, 0x0201) && 2542 chip->usb_id == USB_ID(0x0d8c, 0x0201) &&
2542 fp->altsetting == 5 && fp->maxpacksize == 392) 2543 fp->altsetting == 5 && fp->maxpacksize == 392)
2543 rate = 96000; 2544 rate = 96000;
2544 fp->rate_table[r] = rate; 2545 fp->rate_table[fp->nr_rates] = rate;
2545 nonzero_rates |= rate; 2546 if (!fp->rate_min || rate < fp->rate_min)
2546 if (rate < fp->rate_min)
2547 fp->rate_min = rate; 2547 fp->rate_min = rate;
2548 else if (rate > fp->rate_max) 2548 if (!fp->rate_max || rate > fp->rate_max)
2549 fp->rate_max = rate; 2549 fp->rate_max = rate;
2550 fp->rates |= snd_pcm_rate_to_rate_bit(rate); 2550 fp->rates |= snd_pcm_rate_to_rate_bit(rate);
2551 fp->nr_rates++;
2551 } 2552 }
2552 if (!nonzero_rates) { 2553 if (!fp->nr_rates) {
2553 hwc_debug("All rates were zero. Skipping format!\n"); 2554 hwc_debug("All rates were zero. Skipping format!\n");
2554 return -1; 2555 return -1;
2555 } 2556 }