[alsa-devel] [PATCH] Workaround for misdetected sample rate with CM6207
Takashi Iwai
tiwai at suse.de
Mon Feb 16 12:06:17 CET 2009
At Sat, 14 Feb 2009 22:22:05 +0100,
Joris van Rantwijk wrote:
>
> Summary: Workaround for misdetected sample rate with CM6207
>
> The CM6207 incorrectly advertises its 96 kHz playback setting as 48 kHz
> in its USB device descriptor. This patch extends an existing workaround
> in usbaudio.c to also cover the CM6207.
>
> This resolves issue 0004249 in the ALSA bug tracker.
>
> Signed-off by: Joris van Rantwijk <jorispubl at xs4all.nl>
Thanks for the patch.
Basically your patch tries to fix multiple thing at once.
It should be better split.
For example, try the patch, and add 0d8c:0102 on that.
Does it work?
Takashi
---
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index be47d89..5a09621 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2514,7 +2514,6 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
* build the rate table and bitmap flags
*/
int r, idx;
- unsigned int nonzero_rates = 0;
fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
if (fp->rate_table == NULL) {
@@ -2522,24 +2521,26 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
return -1;
}
- fp->nr_rates = nr_rates;
- fp->rate_min = fp->rate_max = combine_triple(&fmt[8]);
+ fp->nr_rates = 0;
+ fp->rate_min = fp->rate_max = 0;
for (r = 0, idx = offset + 1; r < nr_rates; r++, idx += 3) {
unsigned int rate = combine_triple(&fmt[idx]);
+ if (!rate)
+ continue;
/* C-Media CM6501 mislabels its 96 kHz altsetting */
if (rate == 48000 && nr_rates == 1 &&
chip->usb_id == USB_ID(0x0d8c, 0x0201) &&
fp->altsetting == 5 && fp->maxpacksize == 392)
rate = 96000;
- fp->rate_table[r] = rate;
- nonzero_rates |= rate;
- if (rate < fp->rate_min)
+ fp->rate_table[fp->nr_rates] = rate;
+ if (!fp->rate_min || rate < fp->rate_min)
fp->rate_min = rate;
- else if (rate > fp->rate_max)
+ if (!fp->rate_max || rate > fp->rate_max)
fp->rate_max = rate;
fp->rates |= snd_pcm_rate_to_rate_bit(rate);
+ fp->nr_rates++;
}
- if (!nonzero_rates) {
+ if (!fp->nr_rates) {
hwc_debug("All rates were zero. Skipping format!\n");
return -1;
}
More information about the Alsa-devel
mailing list