Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2009 09:15:34 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 171834 for review
Message-ID:  <200912160915.nBG9FYtU063526@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/chv.cgi?CH=171834

Change 171834 by hselasky@hselasky_laptop001 on 2009/12/16 09:14:53

	USB audio:
		- add support for more than 2 audio channels.
		- patch by: Ariff Abdullah and HPS

Affected files ...

.. //depot/projects/usb/src/sys/dev/sound/usb/uaudio.c#64 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/sound/usb/uaudio.c#64 (text+ko) ====

@@ -89,7 +89,7 @@
 
 static int uaudio_default_rate = 96000;
 static int uaudio_default_bits = 32;
-static int uaudio_default_channels = 2;
+static int uaudio_default_channels = 16;
 
 #if USB_DEBUG
 static int uaudio_debug = 0;
@@ -1088,9 +1088,9 @@
 		/* set a valid value */
 		rate = 192000 - (192000 % fps);
 	}
-	if ((channels == 0) || (channels > 2)) {
+	if ((channels == 0) || (channels > 16)) {
 		/* set a valid value */
-		channels = 2;
+		channels = 16;
 	}
 	if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND)) {
 		sc->sc_sndstat_valid = 1;
@@ -1295,6 +1295,7 @@
 	    &sc->sc_play_chan : &sc->sc_rec_chan);
 	uint32_t buf_size;
 	uint32_t frames;
+	uint32_t format;
 	uint8_t endpoint;
 	uint8_t blocks;
 	uint8_t iface_index;
@@ -1329,15 +1330,34 @@
 	ch->pcm_ch = c;
 	ch->pcm_mtx = c->lock;
 
-	if (ch->p_asf1d->bNrChannels >= 2)
-		ch->pcm_cap.fmtlist[0] =
-		    SND_FORMAT(ch->p_fmt->freebsd_fmt, 2, 0);
-	else
-		ch->pcm_cap.fmtlist[0] =
-		    SND_FORMAT(ch->p_fmt->freebsd_fmt, 1, 0);
+	format = ch->p_fmt->freebsd_fmt;
+
+	switch (ch->p_asf1d->bNrChannels) {
+	case 2:
+		/* stereo */
+		format = SND_FORMAT(format, 2, 0);
+		break;
+	case 1:
+		/* mono */
+		format = SND_FORMAT(format, 1, 0);
+		break;
+	default:
+		/* surround and more */
+		format = feeder_matrix_default_format(
+		    SND_FORMAT(format, ch->p_asf1d->bNrChannels, 0));
+		break;
+	}
 
+	ch->pcm_cap.fmtlist[0] = format;
 	ch->pcm_cap.fmtlist[1] = 0;
 
+	/* check if format is not supported */
+
+	if (format == 0) {
+		DPRINTF("The selected audio format is not supported\n");
+		goto error;
+	}
+
 	/* set alternate interface corresponding to the mode */
 
 	endpoint = ch->p_ed1->bEndpointAddress;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912160915.nBG9FYtU063526>