Need help with patch for #2724 (usbaudio, core)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've tried to write a patch for bug #2724. The problem is that some
Logitech webcams have interface alternatives with a rate of 0:

  Interface 3
    Altset 1
    Format: 0x2
    Channels: 1
    Endpoint: 6 IN (ASYNC)
    Rates: 0
  Interface 3
    Altset 2
    Format: 0x2
    Channels: 1
    Endpoint: 6 IN (ASYNC)
    Rates: 0
  Interface 3
    Altset 3
    Format: 0x2
    Channels: 1
    Endpoint: 6 IN (ASYNC)
    Rates: 16000

The ALSA Kernel driver seems to be somewhat unhappy about this and
oopses in snd_interval_list which gets called with:

i: dc4f0928 count: 3635438588 list: ffffffff mask 4294967295

I've tried to track down the origin of -1 in constraint_list->list but got
lost in the depths of the hw param stuff.

The attached patch skips all alternatives with no valid rates. With this
patch my Quickcam 5000 works like a charm. But I'm unsure if this is the
right approach to fix this bug.

I think the right way to go is to fix also the cause of the oops, so
that the ALSA core doesn't oops when no valid rate is given.

Thanks for your comments,
Gregor
diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c
index 19bdcc7..661e557 100644
--- a/sound/usb/usbaudio.c
+++ b/sound/usb/usbaudio.c
@@ -2455,7 +2455,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
 		/*
 		 * build the rate table and bitmap flags
 		 */
-		int r, idx, c;
+		int r, idx, c, nonzero_rates = 0;
 		/* this table corresponds to the SNDRV_PCM_RATE_XXX bit */
 		static unsigned int conv_rates[] = {
 			5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000,
@@ -2478,6 +2478,7 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
 			    fp->altsetting == 5 && fp->maxpacksize == 392)
 				rate = 96000;
 			fp->rate_table[r] = rate;
+                        nonzero_rates |= rate;
 			if (rate < fp->rate_min)
 				fp->rate_min = rate;
 			else if (rate > fp->rate_max)
@@ -2493,6 +2494,10 @@ static int parse_audio_format_rates(struct snd_usb_audio *chip, struct audioform
 			if (!found)
 				fp->needs_knot = 1;
 		}
+                if (!nonzero_rates) {
+                        hwc_debug("No rate was nonzero. Skipping format!\n");
+                        return -1;
+                }
 		if (fp->needs_knot)
 			fp->rates |= SNDRV_PCM_RATE_KNOT;
 	} else {
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux