diff options
Diffstat (limited to 'sound/usb')
-rw-r--r-- | sound/usb/usbaudio.c | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index ac5666f4c6d5..cbe8b335147c 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -123,7 +123,6 @@ struct audioformat { | |||
123 | unsigned int rate_min, rate_max; /* min/max rates */ | 123 | unsigned int rate_min, rate_max; /* min/max rates */ |
124 | unsigned int nr_rates; /* number of rate table entries */ | 124 | unsigned int nr_rates; /* number of rate table entries */ |
125 | unsigned int *rate_table; /* rate table */ | 125 | unsigned int *rate_table; /* rate table */ |
126 | unsigned int needs_knot; /* any unusual rates? */ | ||
127 | }; | 126 | }; |
128 | 127 | ||
129 | struct snd_usb_substream; | 128 | struct snd_usb_substream; |
@@ -1761,7 +1760,7 @@ static int check_hw_params_convention(struct snd_usb_substream *subs) | |||
1761 | channels[f->format] |= (1 << f->channels); | 1760 | channels[f->format] |= (1 << f->channels); |
1762 | rates[f->format] |= f->rates; | 1761 | rates[f->format] |= f->rates; |
1763 | /* needs knot? */ | 1762 | /* needs knot? */ |
1764 | if (f->needs_knot) | 1763 | if (f->rates & SNDRV_PCM_RATE_KNOT) |
1765 | goto __out; | 1764 | goto __out; |
1766 | } | 1765 | } |
1767 | /* check whether channels and rates match for all formats */ | 1766 | /* check whether channels and rates match for all formats */ |
@@ -1817,7 +1816,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, | |||
1817 | if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) | 1816 | if (fp->rates & SNDRV_PCM_RATE_CONTINUOUS) |
1818 | return 0; | 1817 | return 0; |
1819 | count += fp->nr_rates; | 1818 | count += fp->nr_rates; |
1820 | if (fp->needs_knot) | 1819 | if (fp->rates & SNDRV_PCM_RATE_KNOT) |
1821 | needs_knot = 1; | 1820 | needs_knot = 1; |
1822 | } | 1821 | } |
1823 | if (!needs_knot) | 1822 | if (!needs_knot) |
@@ -2453,7 +2452,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2453 | unsigned char *fmt, int offset) | 2452 | unsigned char *fmt, int offset) |
2454 | { | 2453 | { |
2455 | int nr_rates = fmt[offset]; | 2454 | int nr_rates = fmt[offset]; |
2456 | int found; | 2455 | |
2457 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { | 2456 | if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { |
2458 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", | 2457 | snd_printk(KERN_ERR "%d:%u:%d : invalid FORMAT_TYPE desc\n", |
2459 | chip->dev->devnum, fp->iface, fp->altsetting); | 2458 | chip->dev->devnum, fp->iface, fp->altsetting); |
@@ -2464,20 +2463,15 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2464 | /* | 2463 | /* |
2465 | * build the rate table and bitmap flags | 2464 | * build the rate table and bitmap flags |
2466 | */ | 2465 | */ |
2467 | int r, idx, c; | 2466 | int r, idx; |
2468 | unsigned int nonzero_rates = 0; | 2467 | unsigned int nonzero_rates = 0; |
2469 | /* this table corresponds to the SNDRV_PCM_RATE_XXX bit */ | 2468 | |
2470 | static unsigned int conv_rates[] = { | ||
2471 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, | ||
2472 | 64000, 88200, 96000, 176400, 192000 | ||
2473 | }; | ||
2474 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); | 2469 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); |
2475 | if (fp->rate_table == NULL) { | 2470 | if (fp->rate_table == NULL) { |
2476 | snd_printk(KERN_ERR "cannot malloc\n"); | 2471 | snd_printk(KERN_ERR "cannot malloc\n"); |
2477 | return -1; | 2472 | return -1; |
2478 | } | 2473 | } |
2479 | 2474 | ||
2480 | fp->needs_knot = 0; | ||
2481 | fp->nr_rates = nr_rates; | 2475 | fp->nr_rates = nr_rates; |
2482 | fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); | 2476 | fp->rate_min = fp->rate_max = combine_triple(&fmt[8]); |
2483 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { | 2477 | for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) { |
@@ -2493,23 +2487,12 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2493 | fp->rate_min = rate; | 2487 | fp->rate_min = rate; |
2494 | else if (rate > fp->rate_max) | 2488 | else if (rate > fp->rate_max) |
2495 | fp->rate_max = rate; | 2489 | fp->rate_max = rate; |
2496 | found = 0; | 2490 | fp->rates |= snd_pcm_rate_to_rate_bit(rate); |
2497 | for (c = 0; c < (int)ARRAY_SIZE(conv_rates); c++) { | ||
2498 | if (rate == conv_rates[c]) { | ||
2499 | found = 1; | ||
2500 | fp->rates |= (1 << c); | ||
2501 | break; | ||
2502 | } | ||
2503 | } | ||
2504 | if (!found) | ||
2505 | fp->needs_knot = 1; | ||
2506 | } | 2491 | } |
2507 | if (!nonzero_rates) { | 2492 | if (!nonzero_rates) { |
2508 | hwc_debug("All rates were zero. Skipping format!\n"); | 2493 | hwc_debug("All rates were zero. Skipping format!\n"); |
2509 | return -1; | 2494 | return -1; |
2510 | } | 2495 | } |
2511 | if (fp->needs_knot) | ||
2512 | fp->rates |= SNDRV_PCM_RATE_KNOT; | ||
2513 | } else { | 2496 | } else { |
2514 | /* continuous rates */ | 2497 | /* continuous rates */ |
2515 | fp->rates = SNDRV_PCM_RATE_CONTINUOUS; | 2498 | fp->rates = SNDRV_PCM_RATE_CONTINUOUS; |