diff options
author | Gregor Jasny <gjasny@web.de> | 2007-01-31 06:27:39 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-02-09 03:03:26 -0500 |
commit | beb60119bcc9cbd80bc5b4f7feec419e067d3e46 (patch) | |
tree | 06761bca06fb9e8166a002ef3e5bddd79e448d3f /sound | |
parent | 4147dab62d1b4387c304888488e1f67a83ad53c8 (diff) |
[ALSA] usbaudio - Fix Oops with broken usb descriptors
This is a patch for ALSA Bug #2724. Some webcams provide bogus
settings with no valid rates. With this patch those are skipped.
Signed-off-by: Gregor Jasny <gjasny@web.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/usb/usbaudio.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index de680d095e94..56e42b88addf 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c | |||
@@ -2463,6 +2463,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2463 | * build the rate table and bitmap flags | 2463 | * build the rate table and bitmap flags |
2464 | */ | 2464 | */ |
2465 | int r, idx, c; | 2465 | int r, idx, c; |
2466 | unsigned int nonzero_rates = 0; | ||
2466 | /* this table corresponds to the SNDRV_PCM_RATE_XXX bit */ | 2467 | /* this table corresponds to the SNDRV_PCM_RATE_XXX bit */ |
2467 | static unsigned int conv_rates[] = { | 2468 | static unsigned int conv_rates[] = { |
2468 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, | 2469 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, |
@@ -2485,6 +2486,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2485 | fp->altsetting == 5 && fp->maxpacksize == 392) | 2486 | fp->altsetting == 5 && fp->maxpacksize == 392) |
2486 | rate = 96000; | 2487 | rate = 96000; |
2487 | fp->rate_table[r] = rate; | 2488 | fp->rate_table[r] = rate; |
2489 | nonzero_rates |= rate; | ||
2488 | if (rate < fp->rate_min) | 2490 | if (rate < fp->rate_min) |
2489 | fp->rate_min = rate; | 2491 | fp->rate_min = rate; |
2490 | else if (rate > fp->rate_max) | 2492 | else if (rate > fp->rate_max) |
@@ -2500,6 +2502,10 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform | |||
2500 | if (!found) | 2502 | if (!found) |
2501 | fp->needs_knot = 1; | 2503 | fp->needs_knot = 1; |
2502 | } | 2504 | } |
2505 | if (!nonzero_rates) { | ||
2506 | hwc_debug("All rates were zero. Skipping format!\n"); | ||
2507 | return -1; | ||
2508 | } | ||
2503 | if (fp->needs_knot) | 2509 | if (fp->needs_knot) |
2504 | fp->rates |= SNDRV_PCM_RATE_KNOT; | 2510 | fp->rates |= SNDRV_PCM_RATE_KNOT; |
2505 | } else { | 2511 | } else { |