snd-usb-us122l: added support for US-144
PATCH 1/1 snd-usb-us122l: added support for US-144
Hi,
here is a patch that adds support for the Tascam US-144 to snd-usb-us122l when uhci-hcd is used (ehci-hcd has to be disabled). With ehci-hcd the US-144 behaves completely differently.
The difference between US-122L and US-144 on uhci-hcd is, that US-144 uses endpoints on two interfaces, while on US-122L all endpoints are on one interface. US-122L should still work, but I don't have a US-122L to test that.
Audio in and out and Midi in were tested with US-144 and work.
This is my first contribution to the linux kernel, so please have a critical look on it. ;)
Taken against snd-usb-us122l 0.5 / alsa 1.0.20.
Regards,
Tobias Hansen
sound/usb/usx2y/us122l.c +58 -8
@@ -66,6 +66,28 @@ iface, &quirk); } +static int us144_create_usbmidi (struct snd_card *card) +{ +static struct snd_usb_midi_endpoint_info quirk_data = { + .out_ep =4 , + .in_ep =3 , + .out_cables =0x001 , + .in_cables =0x001 + }; +static struct snd_usb_audio_quirk quirk = { + .vendor_name ="US144" , + .product_name =NAME_ALLCAPS , + .ifnum =0 , + .type =QUIRK_MIDI_US122L , + .data = &quirk_data + }; +struct usb_device *dev =US122L (card)->chip.dev; +struct usb_interface *iface =usb_ifnum_to_if (dev,0 ); + +return snd_usb_create_midi_interface (&US122L (card)->chip, + iface, &quirk); +} +/* * Wrapper for usb_control_msg(). * Allocates a temp buffer to prevent dmaing from/to the stack.
@@ -171,6 +193,11 @@if (!us122l->first) us122l->first = file; + +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + iface =usb_ifnum_to_if (us122l->chip.dev,0 ); +usb_autopm_get_interface (iface); + } iface =usb_ifnum_to_if (us122l->chip.dev,1 );usb_autopm_get_interface (iface);return 0 ;
@@ -179,8 +206,14 @@static int usb_stream_hwdep_release (struct snd_hwdep *hw,struct file *file) {struct us122l *us122l = hw->private_data; -struct usb_interface *iface =usb_ifnum_to_if (us122l->chip.dev,1 ); +struct usb_interface *iface;snd_printdd (KERN_DEBUG "%p %p\n" , hw, file); + +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + iface =usb_ifnum_to_if (us122l->chip.dev,0 ); +usb_autopm_put_interface (iface); + } + iface =usb_ifnum_to_if (us122l->chip.dev,1 );usb_autopm_put_interface (iface);if (us122l->first == file) us122l->first =NULL ;
@@ -443,6 +476,13 @@int err;struct us122l *us122l =US122L (card); +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); +return false; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );
@@ -455,7 +495,10 @@if (!us122l_start (us122l,44100 ,256 ))return false; - err =us122l_create_usbmidi (card); +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) + err =us144_create_usbmidi (card); +else + err =us122l_create_usbmidi (card);if (err <0 ) {snd_printk (KERN_ERR "us122l_create_usbmidi error %i \n" , err);us122l_stop (us122l);
@@ -530,7 +573,7 @@if (err <0 )return err; -snd_card_set_dev (card, &intf->dev); +snd_card_set_dev (card, &device->dev);if (!us122l_create_card (card)) {snd_card_free (card);return -EINVAL ;
@@ -642,6 +685,13 @@mutex_lock (&us122l->mutex);/* needed, doesn't restart without: */ +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); + goto unlock; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );
@@ -675,11 +725,11 @@ .idVendor = 0x0644, .idProduct = USB_ID_US122L }, -/* { */ /* US-144 maybe works when @USB1.1. Untested. */ -/* .match_flags = USB_DEVICE_ID_MATCH_DEVICE, */ -/* .idVendor = 0x0644, */ -/* .idProduct = USB_ID_US144 */ -/* }, */ + {/* US-144 only works at USB1.1! Disable module ehci-hcd. */ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x0644, + .idProduct = USB_ID_US144 + }, {/* terminator */ } };
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Tue, 22 Sep 2009 03:49:11 +0200,
Quoted 5 lines · Tobias Hansen
sound/usb/usx2y/us122l.c +0
-0@@ -443,6 +476,13 @@int err;struct us122l *us122l =US122L (card);
sound/usb/usx2y/us122l.c line 488
Quoted 10 lines
sound/usb/usx2y/us122l.c +7
-0+if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); +return false; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );
Strictly speaking, the first interface should be reset in the error path...
sound/usb/usx2y/us122l.c line 579
Quoted 9 lines
sound/usb/usx2y/us122l.c +1
-1@@ -530,7 +573,7 @@if (err <0 )return err; -snd_card_set_dev (card, &intf->dev); +snd_card_set_dev (card, &device->dev);if (!us122l_create_card (card)) {snd_card_free (card);return -EINVAL ;
Any reason to change this again?
This actually reverts the fix in the upstream:
3f5d3465be8f6e04f43d9b6d543fe28d4be07d78 ALSA: usx2y - reparent sound device
Also, please give your sign-off. See $LINUX/Documentation/SubmittingPatches for details. Could you repost with it?
thanks,
Takashi
Quoted 7 lines · Takashi Iwai
At Tue, 22 Sep 2009 03:49:11 +0200,
Quoted 4 lines · Tobias Hansen
sound/usb/usx2y/us122l.c +0
-0@@ -443,6 +476,13 @@int err;struct us122l *us122l =US122L (card);
Quoted 15 lines
sound/usb/usx2y/us122l.c line 488
Quoted 11 lines
sound/usb/usx2y/us122l.c +7
-0+if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); +return false; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );Strictly speaking, the first interface should be reset in the error path...
You mean setting it to alt_setting 0 in every error path? I can do that, although alt_setting 0 is never used.
Quoted 14 lines
sound/usb/usx2y/us122l.c line 579
Quoted 11 lines
sound/usb/usx2y/us122l.c +1
-1@@ -530,7 +573,7 @@if (err <0 )return err; -snd_card_set_dev (card, &intf->dev); +snd_card_set_dev (card, &device->dev);if (!us122l_create_card (card)) {snd_card_free (card);return -EINVAL ;Any reason to change this again?
This actually reverts the fix in the upstream:
Quoted 3 lines
3f5d3465be8f6e04f43d9b6d543fe28d4be07d78 ALSA: usx2y - reparent sound device
I don't know why to take one interface when US-144 uses two interfaces at once. But I also don't know what this does anyhow.. Should I change it back?
Quoted 4 lines
Also, please give your sign-off. See $LINUX/Documentation/SubmittingPatches for details. Could you repost with it?
Ok. The driver now also checks if the US-144 is attached to USB 2 and refuses to probe then.
--- linux-2.6/sound/usb/usx2y/us122l.c.orig 2009-09-10
00:13:59.000000000 +0200
+++ linux-2.6/sound/usb/usx2y/us122l.c 2009-09-22 15:08:34.666293000
+0200
@@ -66,6 +66,28 @@ static int us122l_create_usbmidi(struct
iface, &quirk);
}
+static int us144_create_usbmidi(struct snd_card *card) +{
+ static struct snd_usb_midi_endpoint_info quirk_data = {
+ .out_ep = 4,
+ .in_ep = 3,
+ .out_cables = 0x001,
+ .in_cables = 0x001
+ };
+ static struct snd_usb_audio_quirk quirk = {
+ .vendor_name = "US144",
+ .product_name = NAME_ALLCAPS,
+ .ifnum = 0,
+ .type = QUIRK_MIDI_US122L,
+ .data = &quirk_data
+ };
+ struct usb_device *dev = US122L(card)->chip.dev;
+ struct usb_interface *iface = usb_ifnum_to_if(dev, 0);+
+ return snd_usb_create_midi_interface(&US122L(card)->chip,
+ iface, &quirk);
+}
+
/*
* Wrapper for usb_control_msg().
* Allocates a temp buffer to prevent dmaing from/to the stack.
@@ -171,6 +193,11 @@ static int usb_stream_hwdep_open(struct
if (!us122l->first)
us122l->first = file;+
+ if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) {
+ iface = usb_ifnum_to_if(us122l->chip.dev, 0);
+ usb_autopm_get_interface(iface);
+ }
iface = usb_ifnum_to_if(us122l->chip.dev, 1);
usb_autopm_get_interface(iface);
return 0;
@@ -179,8 +206,14 @@ static int usb_stream_hwdep_open(struct
static int usb_stream_hwdep_release(struct snd_hwdep *hw, struct file
*file)
{
struct us122l *us122l = hw->private_data;
- struct usb_interface *iface = usb_ifnum_to_if(us122l->chip.dev, 1);
+ struct usb_interface *iface;
snd_printdd(KERN_DEBUG "%p %p\n", hw, file);+
+ if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) {
+ iface = usb_ifnum_to_if(us122l->chip.dev, 0);
+ usb_autopm_put_interface(iface);
+ }
+ iface = usb_ifnum_to_if(us122l->chip.dev, 1);
usb_autopm_put_interface(iface);
if (us122l->first == file)
us122l->first = NULL;
@@ -443,6 +476,13 @@ static bool us122l_create_card(struct sn
int err;
struct us122l *us122l = US122L(card);+ if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) {
+ err = usb_set_interface(us122l->chip.dev, 0, 1);
+ if (err) {
+ snd_printk(KERN_ERR "usb_set_interface error \n");
+ return false;
+ }
+ }
err = usb_set_interface(us122l->chip.dev, 1, 1);
if (err) {
snd_printk(KERN_ERR "usb_set_interface error \n");
@@ -455,7 +495,10 @@ static bool us122l_create_card(struct sn
if (!us122l_start(us122l, 44100, 256))
return false;- err = us122l_create_usbmidi(card);
+ if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144)
+ err = us144_create_usbmidi(card);
+ else
+ err = us122l_create_usbmidi(card);
if (err < 0) {
snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err);
us122l_stop(us122l);
@@ -518,11 +561,10 @@ static int usx2y_create_card(struct usb_
return 0;}
-static int us122l_usb_probe(struct usb_interface *intf, +static int us122l_usb_probe(struct usb_device *device,
const struct usb_device_id *device_id, struct snd_card **cardp)
{
- struct usb_device *device = interface_to_usbdev(intf);
struct snd_card *card;
int err;@@ -530,7 +572,7 @@ static int us122l_usb_probe(struct usb_i
if (err < 0)
return err;- snd_card_set_dev(card, &intf->dev);
+ snd_card_set_dev(card, &device->dev);
if (!us122l_create_card(card)) {
snd_card_free(card);
return -EINVAL;
@@ -542,7 +584,8 @@ static int us122l_usb_probe(struct usb_i
return err;
}- usb_get_dev(device);
+ usb_get_intf(usb_ifnum_to_if(device, 0));
+ usb_get_intf(usb_ifnum_to_if(device, 1));
*cardp = card;
return 0; }
@@ -550,17 +593,24 @@ static int us122l_usb_probe(struct usb_i
static int snd_us122l_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
+ struct usb_device *device = interface_to_usbdev(intf);
struct snd_card *card;
int err;
+
+ if (device->descriptor.idProduct == USB_ID_US144
+ && device->speed == USB_SPEED_HIGH) {
+ snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n");
+ return -ENOENT;+ }
snd_printdd(KERN_DEBUG"%p:%i\n",
intf, intf->cur_altsetting->desc.bInterfaceNumber);
if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
return 0;- err = us122l_usb_probe(usb_get_intf(intf), id, &card);
+ err = us122l_usb_probe(usb_get_dev(device), id, &card);
if (err < 0) {
- usb_put_intf(intf);
+ usb_put_dev(device);
return err;
}@@ -591,7 +641,8 @@ static void snd_us122l_disconnect(struct
snd_usbmidi_disconnect(p);
}- usb_put_intf(intf);
+ usb_put_intf(usb_ifnum_to_if(us122l->chip.dev, 0));
+ usb_put_intf(usb_ifnum_to_if(us122l->chip.dev, 1));
usb_put_dev(us122l->chip.dev);
while (atomic_read(&us122l->mmap_count))@@ -642,6 +693,13 @@ static int snd_us122l_resume(struct usb_
mutex_lock(&us122l->mutex);
/* needed, doesn't restart without: */+ if (us122l->chip.dev->descriptor.idProduct == USB_ID_US144) {
+ err = usb_set_interface(us122l->chip.dev, 0, 1);
+ if (err) {
+ snd_printk(KERN_ERR "usb_set_interface error \n");
+ goto unlock;
+ }
+ }
err = usb_set_interface(us122l->chip.dev, 1, 1);
if (err) {
snd_printk(KERN_ERR "usb_set_interface error \n");
@@ -675,11 +733,11 @@ static struct usb_device_id snd_us122l_u
.idVendor = 0x0644,
.idProduct = USB_ID_US122L
},
-/* { */ /* US-144 maybe works when @USB1.1. Untested. */
-/* .match_flags = USB_DEVICE_ID_MATCH_DEVICE, */
-/* .idVendor = 0x0644, */
-/* .idProduct = USB_ID_US144 */
-/* }, */
+ { /* US-144 only works at USB1.1! Disable module ehci-hcd. */
+ .match_flags = USB_DEVICE_ID_MATCH_DEVICE,
+ .idVendor = 0x0644,
+ .idProduct = USB_ID_US144
+ },
{ /* terminator */ }};
At Tue, 22 Sep 2009 15:56:03 +0200,
Quoted 43 lines · Tobias Hansen
Quoted 7 lines · Takashi Iwai
At Tue, 22 Sep 2009 03:49:11 +0200,
Quoted 4 lines · Tobias Hansen
sound/usb/usx2y/us122l.c +0
-0@@ -443,6 +476,13 @@int err;struct us122l *us122l =US122L (card);Quoted 15 lines
sound/usb/usx2y/us122l.c line 488
Quoted 11 lines
sound/usb/usx2y/us122l.c +7
-0+if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); +return false; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );Strictly speaking, the first interface should be reset in the error path...
You mean setting it to
alt_setting0 in every error path? I can do that, althoughalt_setting0 is never used.Quoted 14 lines
sound/usb/usx2y/us122l.c line 579
Quoted 11 lines
sound/usb/usx2y/us122l.c +1
-1@@ -530,7 +573,7 @@if (err <0 )return err; -snd_card_set_dev (card, &intf->dev); +snd_card_set_dev (card, &device->dev);if (!us122l_create_card (card)) {snd_card_free (card);return -EINVAL ;Any reason to change this again?
This actually reverts the fix in the upstream:Quoted 3 lines
3f5d3465be8f6e04f43d9b6d543fe28d4be07d78 ALSA: usx2y - reparent sound device
Quoted 3 lines
I don't know why to take one interface when US-144 uses two interfaces at once. But I also don't know what this does anyhow.. Should I change it back?
Yes. Udev requires that the card instance to be the child of usb interface.
Quoted 6 lines
Quoted 4 lines
Also, please give your sign-off. See $LINUX/Documentation/SubmittingPatches for details. Could you repost with it?
Ok. The driver now also checks if the US-144 is attached to USB 2 and refuses to probe then.
Read the document above again :)
The right patch format consists of a summary line, the change log texts, your sign-off, then the patch body.
thanks,
Takashi
Quoted 193 lines
--- linux-2.6/sound/usb/usx2y/us122l.c.orig 2009-09-10
00:13:59.000000000 +0200
+++linux-2.6/sound/usb/usx2y/us122l.c2009-09-22 15:08:34.666293000
+0200sound/usb/usx2y/us122l.c +34
-1@@ -66,6 +66,28 @@ static int us122l_create_usbmidi(struct iface, &quirk); } +static int us144_create_usbmidi (struct snd_card *card) +{ +static struct snd_usb_midi_endpoint_info quirk_data = { + .out_ep =4 , + .in_ep =3 , + .out_cables =0x001 , + .in_cables =0x001 + }; +static struct snd_usb_audio_quirk quirk = { + .vendor_name ="US144" , + .product_name =NAME_ALLCAPS , + .ifnum =0 , + .type =QUIRK_MIDI_US122L , + .data = &quirk_data + }; +struct usb_device *dev =US122L (card)->chip.dev; +struct usb_interface *iface =usb_ifnum_to_if (dev,0 ); + +return snd_usb_create_midi_interface (&US122L (card)->chip, + iface, &quirk); +} +/* * Wrapper for usb_control_msg(). * Allocates a temp buffer to prevent dmaing from/to the stack. @@ -171,6 +193,11 @@ static int usb_stream_hwdep_open(structif (!us122l->first) us122l->first = file; + +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + iface =usb_ifnum_to_if (us122l->chip.dev,0 ); +usb_autopm_get_interface (iface); + } iface =usb_ifnum_to_if (us122l->chip.dev,1 );usb_autopm_get_interface (iface);return 0 ;@@ -179,8 +206,14 @@ static int usb_stream_hwdep_open(structstatic int usb_stream_hwdep_release (struct snd_hwdep *hw,struct file *file) {struct us122l *us122l = hw->private_data; -struct usb_interface *iface =usb_ifnum_to_if (us122l->chip.dev,1 ); +struct usb_interface *iface;snd_printdd (KERN_DEBUG "%p %p\n" , hw, file); + +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + iface =usb_ifnum_to_if (us122l->chip.dev,0 ); +usb_autopm_put_interface (iface); + } + iface =usb_ifnum_to_if (us122l->chip.dev,1 );usb_autopm_put_interface (iface);if (us122l->first == file)us122l->first = NULL;sound/usb/usx2y/us122l.c +38
-13@@ -443,6 +476,13 @@ static bool us122l_create_card(struct snint err;struct us122l *us122l =US122L (card); +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); +return false; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );@@ -455,7 +495,10 @@ static bool us122l_create_card(struct snif (!us122l_start (us122l,44100 ,256 ))return false; - err =us122l_create_usbmidi (card); +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) + err =us144_create_usbmidi (card); +else + err =us122l_create_usbmidi (card);if (err <0 ) {snd_printk (KERN_ERR "us122l_create_usbmidi error %i \n" , err);us122l_stop (us122l);@@ -518,11 +561,10 @@ static int usx2y_create_card(struct usb_return 0 ; } -static int us122l_usb_probe (struct usb_interface *intf, +static int us122l_usb_probe (struct usb_device *device,const struct usb_device_id *device_id,struct snd_card **cardp) { -struct usb_device *device =interface_to_usbdev (intf);struct snd_card *card;int err;@@ -530,7 +572,7 @@ static int us122l_usb_probe(struct usb_iif (err <0 )return err; -snd_card_set_dev (card, &intf->dev); +snd_card_set_dev (card, &device->dev);if (!us122l_create_card (card)) {snd_card_free (card);return -EINVAL ;@@ -542,7 +584,8 @@ static int us122l_usb_probe(struct usb_ireturn err; } -usb_get_dev (device); +usb_get_intf (usb_ifnum_to_if (device,0 )); +usb_get_intf (usb_ifnum_to_if (device,1 )); *cardp = card;return 0 ; }@@ -550,17 +593,24 @@ static int us122l_usb_probe(struct usb_istatic int snd_us122l_probe (struct usb_interface *intf,const struct usb_device_id *id) { +struct usb_device *device =interface_to_usbdev (intf);struct snd_card *card;int err; + +if (device->descriptor.idProduct ==USB_ID_US144 + && device->speed ==USB_SPEED_HIGH ) { +snd_printk (KERN_ERR "disable ehci-hcd to run US-144 \n" ); +return -ENOENT ; + }snd_printdd (KERN_DEBUG "%p:%i\n" , intf, intf->cur_altsetting->desc.bInterfaceNumber);if (intf->cur_altsetting->desc.bInterfaceNumber !=1 )return 0 ; - err =us122l_usb_probe (usb_get_intf (intf), id, &card); + err =us122l_usb_probe (usb_get_dev (device), id, &card);if (err <0 ) { -usb_put_intf (intf); +usb_put_dev (device);return err; }@@ -591,7 +641,8 @@ static void snd_us122l_disconnect(structsnd_usbmidi_disconnect (p); } -usb_put_intf (intf); +usb_put_intf (usb_ifnum_to_if (us122l->chip.dev,0 )); +usb_put_intf (usb_ifnum_to_if (us122l->chip.dev,1 ));usb_put_dev (us122l->chip.dev);while (atomic_read (&us122l->mmap_count))@@ -642,6 +693,13 @@ static int snd_us122l_resume(struct usb_mutex_lock (&us122l->mutex);/* needed, doesn't restart without: */ +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); + goto unlock; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );@@ -675,11 +733,11 @@ static struct usb_device_id snd_us122l_u .idVendor = 0x0644, .idProduct = USB_ID_US122L }, -/* { */ /* US-144 maybe works when @USB1.1. Untested. */ -/* .match_flags = USB_DEVICE_ID_MATCH_DEVICE, */ -/* .idVendor = 0x0644, */ -/* .idProduct = USB_ID_US144 */ -/* }, */ + {/* US-144 only works at USB1.1! Disable module ehci-hcd. */ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x0644, + .idProduct = USB_ID_US144 + }, {/* terminator */ } };Signed-off-by Tobias Hansen <[email protected]>
Quoted 4 lines · Takashi Iwai
Yes. Udev requires that the card instance to be the child of usb interface.
Ok, done.
Quoted 5 lines
Read the document above again :)
The right patch format consists of a summary line, the change log texts, your sign-off, then the patch body.
Ok, here is the next try. ;) I didn't find very precise instructions on the patch format, so if it is still not good, please tell me what to change.
snd-usb-us122l: add support for US-144
Adds support for US-144 when attached on USB1.1. Unlike the US-122L it uses both USB interfaces 0 and 1.
---
sound/usb/usx2y/us122l.c renamed from sound/usb/usx2y/us122l.c.orig +67 -8
@@ -66,6 +66,28 @@ static int us122l_create_usbmidi(struct iface, &quirk); } +static int us144_create_usbmidi (struct snd_card *card) +{ +static struct snd_usb_midi_endpoint_info quirk_data = { + .out_ep =4 , + .in_ep =3 , + .out_cables =0x001 , + .in_cables =0x001 + }; +static struct snd_usb_audio_quirk quirk = { + .vendor_name ="US144" , + .product_name =NAME_ALLCAPS , + .ifnum =0 , + .type =QUIRK_MIDI_US122L , + .data = &quirk_data + }; +struct usb_device *dev =US122L (card)->chip.dev; +struct usb_interface *iface =usb_ifnum_to_if (dev,0 ); + +return snd_usb_create_midi_interface (&US122L (card)->chip, + iface, &quirk); +} +/* * Wrapper for usb_control_msg(). * Allocates a temp buffer to prevent dmaing from/to the stack.
@@ -171,6 +193,11 @@ static int usb_stream_hwdep_open(structif (!us122l->first) us122l->first = file; + +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + iface =usb_ifnum_to_if (us122l->chip.dev,0 ); +usb_autopm_get_interface (iface); + } iface =usb_ifnum_to_if (us122l->chip.dev,1 );usb_autopm_get_interface (iface);return 0 ;
@@ -179,8 +206,14 @@ static int usb_stream_hwdep_open(structstatic int usb_stream_hwdep_release (struct snd_hwdep *hw,struct file *file) {struct us122l *us122l = hw->private_data; -struct usb_interface *iface =usb_ifnum_to_if (us122l->chip.dev,1 ); +struct usb_interface *iface;snd_printdd (KERN_DEBUG "%p %p\n" , hw, file); + +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + iface =usb_ifnum_to_if (us122l->chip.dev,0 ); +usb_autopm_put_interface (iface); + } + iface =usb_ifnum_to_if (us122l->chip.dev,1 );usb_autopm_put_interface (iface);if (us122l->first == file) us122l->first =NULL ;
@@ -443,6 +476,13 @@ static bool us122l_create_card(struct snint err;struct us122l *us122l =US122L (card); +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); +return false; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );
@@ -455,7 +495,10 @@ static bool us122l_create_card(struct snif (!us122l_start (us122l,44100 ,256 ))return false; - err =us122l_create_usbmidi (card); +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) + err =us144_create_usbmidi (card); +else + err =us122l_create_usbmidi (card);if (err <0 ) {snd_printk (KERN_ERR "us122l_create_usbmidi error %i \n" , err);us122l_stop (us122l);
@@ -542,6 +585,7 @@ static int us122l_usb_probe(struct usb_ireturn err; } +usb_get_intf (usb_ifnum_to_if (device,0 ));usb_get_dev (device); *cardp = card;return 0 ;
@@ -550,8 +594,15 @@ static int us122l_usb_probe(struct usb_istatic int snd_us122l_probe (struct usb_interface *intf,const struct usb_device_id *id) { +struct usb_device *device =interface_to_usbdev (intf);struct snd_card *card;int err; + +if (device->descriptor.idProduct ==USB_ID_US144 + && device->speed ==USB_SPEED_HIGH ) { +snd_printk (KERN_ERR "disable ehci-hcd to run US-144 \n" ); +return -ENOENT ; + }snd_printdd (KERN_DEBUG "%p:%i\n" , intf, intf->cur_altsetting->desc.bInterfaceNumber);
@@ -591,7 +642,8 @@ static void snd_us122l_disconnect(structsnd_usbmidi_disconnect (p); } -usb_put_intf (intf); +usb_put_intf (usb_ifnum_to_if (us122l->chip.dev,0 )); +usb_put_intf (usb_ifnum_to_if (us122l->chip.dev,1 ));usb_put_dev (us122l->chip.dev);while (atomic_read (&us122l->mmap_count))
@@ -642,6 +694,13 @@ static int snd_us122l_resume(struct usb_mutex_lock (&us122l->mutex);/* needed, doesn't restart without: */ +if (us122l->chip.dev->descriptor.idProduct ==USB_ID_US144 ) { + err =usb_set_interface (us122l->chip.dev,0 ,1 ); +if (err) { +snd_printk (KERN_ERR "usb_set_interface error \n" ); + goto unlock; + } + } err =usb_set_interface (us122l->chip.dev,1 ,1 );if (err) {snd_printk (KERN_ERR "usb_set_interface error \n" );
@@ -675,11 +734,11 @@ static struct usb_device_id snd_us122l_u .idVendor = 0x0644, .idProduct = USB_ID_US122L }, -/* { */ /* US-144 maybe works when @USB1.1. Untested. */ -/* .match_flags = USB_DEVICE_ID_MATCH_DEVICE, */ -/* .idVendor = 0x0644, */ -/* .idProduct = USB_ID_US144 */ -/* }, */ + {/* US-144 only works at USB1.1! Disable module ehci-hcd. */ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE, + .idVendor = 0x0644, + .idProduct = USB_ID_US144 + }, {/* terminator */ } };
At Tue, 22 Sep 2009 16:52:08 +0200,
Quoted 17 lines · Tobias Hansen
Quoted 4 lines · Takashi Iwai
Yes. Udev requires that the card instance to be the child of usb interface.
Ok, done.
Quoted 5 lines
Read the document above again :)
The right patch format consists of a summary line, the change log texts, your sign-off, then the patch body.Ok, here is the next try. ;) I didn't find very precise instructions on the patch format, so if it is still not good, please tell me what to change.
Quoted 6 lines
snd-usb-us122l: add support for US-144
Adds support for US-144 when attached on USB1.1. Unlike the US-122L it uses both USB interfaces 0 and 1.
Signed-off-by Tobias Hansen <[email protected]>
Thanks, now applied.
Takashi
PATCH 1/1 snd-usb-us122l: corrent error number for not probing US-144 on ehci-hcd
In reply to Tobias Hansensnd-usb-us122l: corrent error number for not probing US-144 on ehci-hcd This is the correct error number for telling the USB system that this driver is not for the device.
---
us122l.c 2009-10-12 14:51:05.255040655 +0200 renamed from us122l.c.orig 2009-10-12 08:46:01.000000000 +0200 +1 -1
@@ -601,7 +601,7 @@ static int snd_us122l_probe(struct usb_i if (device->descriptor.idProduct == USB_ID_US144 && device->speed == USB_SPEED_HIGH) { snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n"); - return -ENOENT; + return -ENODEV; } snd_printdd(KERN_DEBUG"%p:%i\n",
Re: [PATCH] snd-usb-us122l: corrent error number for not probing US-144 on ehci-hcd
At Mon, 12 Oct 2009 16:24:15 +0200,
Quoted 6 lines · Tobias Hansen
snd-usb-us122l: corrent error number for not probing US-144 on ehci-hcd This is the correct error number for telling the USB system that this driver is not for the device.
Signed-off-by Tobias Hansen <[email protected]>
Applied now. Thanks.
Takashi
Quoted 14 lines
---
us122l.c 2009-10-12 14:51:05.255040655 +0200 renamed from us122l.c.orig 2009-10-12 08:46:01.000000000 +0200 +1
-1@@ -601,7 +601,7 @@ static int snd_us122l_probe(struct usb_i if (device->descriptor.idProduct == USB_ID_US144 && device->speed == USB_SPEED_HIGH) { snd_printk(KERN_ERR "disable ehci-hcd to run US-144 \n"); - return -ENOENT; + return -ENODEV; } snd_printdd(KERN_DEBUG"%p:%i\n",