Module Name:    src
Committed By:   riz
Date:           Sat Apr 21 15:57:28 UTC 2012

Modified Files:
        src/sys/dev/usb [netbsd-5]: uaudio.c

Log Message:
Pull up following revision(s) (requested by jakllsch in ticket #1746):
        sys/dev/usb/uaudio.c: revision 1.120
Address PR#44279.
- Be more lenient to device descriptor inconsistencies.
- Apply Roland SD-90 quirk only to the SD-90.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.114.6.1 src/sys/dev/usb/uaudio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.114 src/sys/dev/usb/uaudio.c:1.114.6.1
--- src/sys/dev/usb/uaudio.c:1.114	Sat Jun 28 09:14:56 2008
+++ src/sys/dev/usb/uaudio.c	Sat Apr 21 15:57:27 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.114 2008/06/28 09:14:56 kent Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.114.6.1 2012/04/21 15:57:27 riz Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.114 2008/06/28 09:14:56 kent Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.114.6.1 2012/04/21 15:57:27 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -65,6 +65,8 @@ __KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1
 #include <dev/usb/usbdi_util.h>
 #include <dev/usb/usb_quirks.h>
 
+#include <dev/usb/usbdevs.h>
+
 #include <dev/usb/uaudioreg.h>
 
 /* #define UAUDIO_DEBUG */
@@ -1847,7 +1849,7 @@ uaudio_identify_ac(struct uaudio_softc *
 	const struct usb_audio_output_terminal *pot;
 	struct terminal_list *tml;
 	const char *tbuf, *ibuf, *ibufend;
-	int size, offs, aclen, ndps, i, j;
+	int size, offs, ndps, i, j;
 
 	size = UGETW(cdesc->wTotalLength);
 	tbuf = (const char *)cdesc;
@@ -1864,26 +1866,23 @@ uaudio_identify_ac(struct uaudio_softc *
 
 	/* A class-specific AC interface header should follow. */
 	ibuf = tbuf + offs;
+	ibufend = tbuf + size;
 	acdp = (const struct usb_audio_control_descriptor *)ibuf;
 	if (acdp->bDescriptorType != UDESC_CS_INTERFACE ||
 	    acdp->bDescriptorSubtype != UDESCSUB_AC_HEADER)
 		return USBD_INVAL;
-	aclen = UGETW(acdp->wTotalLength);
-	if (offs + aclen > size)
-		return USBD_INVAL;
 
 	if (!(usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_BAD_ADC) &&
 	     UGETW(acdp->bcdADC) != UAUDIO_VERSION)
 		return USBD_INVAL;
 
 	sc->sc_audio_rev = UGETW(acdp->bcdADC);
-	DPRINTFN(2,("uaudio_identify_ac: found AC header, vers=%03x, len=%d\n",
-		 sc->sc_audio_rev, aclen));
+	DPRINTFN(2,("uaudio_identify_ac: found AC header, vers=%03x\n",
+		 sc->sc_audio_rev));
 
 	sc->sc_nullalt = -1;
 
 	/* Scan through all the AC specific descriptors */
-	ibufend = ibuf + aclen;
 	dp = (const uaudio_cs_descriptor_t *)ibuf;
 	ndps = 0;
 	iot = malloc(sizeof(struct io_terminal) * 256, M_TEMP, M_NOWAIT | M_ZERO);
@@ -1900,12 +1899,8 @@ uaudio_identify_ac(struct uaudio_softc *
 			free(iot, M_TEMP);
 			return USBD_INVAL;
 		}
-		if (dp->bDescriptorType != UDESC_CS_INTERFACE) {
-			aprint_error(
-			    "uaudio_identify_ac: skip desc type=0x%02x\n",
-			    dp->bDescriptorType);
-			continue;
-		}
+		if (dp->bDescriptorType != UDESC_CS_INTERFACE)
+			break;
 		i = ((const struct usb_audio_input_terminal *)dp)->bTerminalId;
 		iot[i].d.desc = dp;
 		if (i > ndps)
@@ -2625,11 +2620,10 @@ uaudio_chan_open(struct uaudio_softc *sc
 		return err;
 
 	/*
-	 * If just one sampling rate is supported,
-	 * no need to call uaudio_set_speed().
 	 * Roland SD-90 freezes by a SAMPLING_FREQ_CONTROL request.
 	 */
-	if (as->asf1desc->bSamFreqType != 1) {
+	if ((UGETW(sc->sc_udev->ddesc.idVendor) != USB_VENDOR_ROLAND) &&
+	    (UGETW(sc->sc_udev->ddesc.idProduct) != USB_PRODUCT_ROLAND_SD90)) {
 		err = uaudio_set_speed(sc, endpt, ch->sample_rate);
 		if (err) {
 			DPRINTF(("uaudio_chan_open: set_speed failed err=%s\n",

Reply via email to