Sound UsbPre : minimal patch for support
diff mbox

Message ID 1805025243.580922365.1448569737961.JavaMail.root@spooler2-g27.priv.proxad.net
State New
Headers show

Commit Message

shal@free.fr Nov. 26, 2015, 8:28 p.m. UTC
Hello,

I have a Sound UsbPre (the first not the UsbPRe2) sound card.
There is no support for this card in alsa.
I do a usb packet sniffing on Windows for detect problem.
Some control quirk should be added at boot in order to use the card.

It works to play and record in 44100 khz.
It works only with 44100khz (for example, if you play a 88200 file, it will be played too slow).
This patch is not well tested, work on my desktop : Linux Ubuntu with 4.2.19-lowlatency kernel.

The button emulation is not done (by a control packet, you can change the card configuration, like phantom power activation).
If somebody is interested, I can provide needed information.

If Alsa's developer is interested, I can provide support for test patches or develop a second version of this patch in order to integrate the support for this card in the linux kernel 

Regards,
Olivier


linux-source-4.2.0/sound/usb$ diff -rub quirks.c.ORIG quirks.c

Comments

Takashi Iwai Dec. 7, 2015, 4:50 p.m. UTC | #1
On Thu, 26 Nov 2015 21:28:57 +0100,
shal@free.fr wrote:
> 
> Hello,
> 
> I have a Sound UsbPre (the first not the UsbPRe2) sound card.
> There is no support for this card in alsa.
> I do a usb packet sniffing on Windows for detect problem.
> Some control quirk should be added at boot in order to use the card.
> 
> It works to play and record in 44100 khz.
> It works only with 44100khz (for example, if you play a 88200 file, it will be played too slow).
> This patch is not well tested, work on my desktop : Linux Ubuntu with 4.2.19-lowlatency kernel.
> 
> The button emulation is not done (by a control packet, you can change the card configuration, like phantom power activation).
> If somebody is interested, I can provide needed information.
> 
> If Alsa's developer is interested, I can provide support for test patches or develop a second version of this patch in order to integrate the support for this card in the linux kernel 

Yeah, sure it'd be great if you can polish and submit the patch.  Even
with a limited support, it's much better than nothing.


thanks,

Takashi

> 
> Regards,
> Olivier
> 
> 
> linux-source-4.2.0/sound/usb$ diff -rub quirks.c.ORIG quirks.c 
> --- quirks.c.ORIG	2015-11-24 22:43:16.878635155 +0100
> +++ quirks.c	2015-11-26 20:56:09.492126460 +0100
> @@ -601,6 +601,40 @@
>  	return 0;
>  }
>  
> +/* Add some control messages needed by Sound Devices UsbPre. 
> + * Values here are chosen based on sniffing USB traffic
> + * under Windows.*/
> +static int snd_usb_usbpre_boot_quirk(struct usb_device *dev)
> +{
> +    u8 buf = 1;
> +    u8 data1[1] = {0x81};
> +    u8 data2[1] = {0xc1};
> +    u8 data3[3] = {0x44,0xac,0x00};
> +
> +	snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 1,
> +				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> +				0x00f0, 496, data1, 1);
> +	snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x81 ,
> +			    USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> +			    0x00f0, 0, &buf, 1);		
> +	if (buf == 0) {
> +		return -ENODEV;
> +	}
> +	snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 1,
> +				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> +				0x00f0, 496, data2, 1);
> +	snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x81 ,
> +			    USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> +			    0x00f0, 0, &buf, 1);		
> +	if (buf == 0) {
> +		return -ENODEV;
> +	}
> +	snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 1,
> +				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT,
> +				0x0100, 133, data3, 3);
> +	return 0;
> +}
> +
>  static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
>  {
>  	int err;
> @@ -985,6 +1019,10 @@
>  		/* SB Audigy 2 NX needs its own boot-up magic, too */
>  		return snd_usb_audigy2nx_boot_quirk(dev);
>  
> +	case USB_ID(0x0926, 0x0100):
> +		/* Sound Devices UsbPre needs its own boot-up magic, too */
> +		return snd_usb_usbpre_boot_quirk(dev);
> +
>  	case USB_ID(0x10f5, 0x0200):
>  		/* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
>  		return snd_usb_cm106_boot_quirk(dev);
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

Patch
diff mbox

--- quirks.c.ORIG	2015-11-24 22:43:16.878635155 +0100
+++ quirks.c	2015-11-26 20:56:09.492126460 +0100
@@ -601,6 +601,40 @@ 
 	return 0;
 }
 
+/* Add some control messages needed by Sound Devices UsbPre. 
+ * Values here are chosen based on sniffing USB traffic
+ * under Windows.*/
+static int snd_usb_usbpre_boot_quirk(struct usb_device *dev)
+{
+    u8 buf = 1;
+    u8 data1[1] = {0x81};
+    u8 data2[1] = {0xc1};
+    u8 data3[3] = {0x44,0xac,0x00};
+
+	snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 1,
+				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+				0x00f0, 496, data1, 1);
+	snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x81 ,
+			    USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+			    0x00f0, 0, &buf, 1);		
+	if (buf == 0) {
+		return -ENODEV;
+	}
+	snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 1,
+				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+				0x00f0, 496, data2, 1);
+	snd_usb_ctl_msg(dev, usb_rcvctrlpipe(dev, 0), 0x81 ,
+			    USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+			    0x00f0, 0, &buf, 1);		
+	if (buf == 0) {
+		return -ENODEV;
+	}
+	snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0), 1,
+				USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_ENDPOINT,
+				0x0100, 133, data3, 3);
+	return 0;
+}
+
 static int snd_usb_fasttrackpro_boot_quirk(struct usb_device *dev)
 {
 	int err;
@@ -985,6 +1019,10 @@ 
 		/* SB Audigy 2 NX needs its own boot-up magic, too */
 		return snd_usb_audigy2nx_boot_quirk(dev);
 
+	case USB_ID(0x0926, 0x0100):
+		/* Sound Devices UsbPre needs its own boot-up magic, too */
+		return snd_usb_usbpre_boot_quirk(dev);
+
 	case USB_ID(0x10f5, 0x0200):
 		/* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
 		return snd_usb_cm106_boot_quirk(dev);