From: Takashi Iwai Subject: Re: [PATCH] Workaround for misdetected sample rate with CM6207 Date: Mon, 16 Feb 2009 12:06:17 +0100 Message-ID: References: <20090214212205.GA4898@xs4all.nl> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mail.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id E2A4624497 for ; Mon, 16 Feb 2009 12:06:17 +0100 (CET) In-Reply-To: <20090214212205.GA4898@xs4all.nl> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Joris van Rantwijk Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org 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 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; }