Skip to contentSkip to conversation

questions about usbmidi

DISCUSSION Thomas Rabe 2 participants 6 messages Apr 9, 2003 – Apr 10, 2003

lore
Share & tools
lore
#0 lore raw

hello,

I try to hack a little bit on Karstens tascam-us428 alsa patch and have some problems to integrate usbmidi (usbaudio works). in the patch (written for alsa rc3?) this was done with:

8<----------------------------------------------------------- static int snd_us428_create_usbmidi( snd_card_t* card ) {

#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
        static snd_usb_audio_quirk_t quirk = {
                .vendor_name =  "TASCAM",
                .product_name = "US-428",
                .ifnum =        0,
                .endpoints = {{
                        .epnum =        6,
                        .out_cables =   3,
                        .in_cables =    3
                        }}
        };
        snd_seq_device_t *seq_device;
        snd_usb_midi_t *umidi;
        int err;

        err = snd_seq_device_new( card, us428( card)->chip.next_seq_device,
                                 SNDRV_SEQ_DEV_ID_USBMIDI,
                                 sizeof(snd_usb_midi_t), &seq_device);
        if (err < 0)
                return err;
        us428( card)->chip.next_seq_device++;
        strcpy(seq_device->name, card->shortname);
        umidi = (snd_usb_midi_t *)SNDRV_SEQ_DEVICE_ARGPTR(seq_device);
        umidi->chip = &us428( card)->chip;
        umidi->ifnum = 0;
        umidi->quirk = &quirk;
        umidi->seq_client = -1;
#endif
        return 0;
}

8<------------------------------------------------------------------

i changed this to:
8<---------------------------------------------------------------- static int snd_us428_create_usbmidi( snd_card_t* card ) {

#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
	static snd_usb_audio_quirk_t quirk = {
		.vendor_name =	"TASCAM",
		.product_name =	"US-428",
		.ifnum = 	0,
       		.type = QUIRK_MIDI_FIXED_ENDPOINT,
		.data = & (const snd_usb_midi_endpoint_info_t) {
       		  .out_ep =0x06,
		  .in_ep = 0x86,
			.out_cables =	0x003,
			.in_cables =	0x003
			}
	};

	int err;

	err = snd_usb_create_midi_interface(&us428( card)->chip, us428( 
card)->chip.dev->actconfig->interface , &quirk);
        if (err < 0)
          return err;
#endif
	return 0;
}

8<--------------------------------------------------------------------

but if i insert the module with modprobe i get segfault + kernel oops. what should be wrong? is it a good idea to link against usbmidi.o? (the us428 is non standard audio/midi device).
btw: karstens original code is available at
http://hal9000.drehmoment.org/tascam

Greetings,

Thomas Rabe.

-- mail: raven at drehmoment dot org
-- home: http://hal9000.drehmoment.org
-- more: http://drehmoment.org

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#1 lore raw
Quoted 7 lines · Thomas Rabe

I try to hack a little bit on Karstens tascam-us428 alsa patch and have some problems to integrate usbmidi (usbaudio works). in the patch (written for alsa rc3?) this was done with:
[...]
i changed this to:
...
#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)

You don't need this #if; the new code doesn't use the sequencer.

Quoted 1 line
	.in_ep = 0x86,

This endpoint number must not include the USB_DIR_IN flag. Make this:

	.in_ep = 0x06,

If this is the only endpoint in the interface, you can omit the endpoint number and let the driver autodetect it.

Quoted 2 lines

is it a good idea to link against usbmidi.o? (the us428 is non standard audio/midi device).

Yes, the MIDI interface part of the US428 is mostly standard compliant.

HTH
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com

#2 lore raw
Quoted 7 lines · Clemens Ladisch
Quoted 4 lines · Thomas Rabe

I try to hack a little bit on Karstens tascam-us428 alsa patch and have some problems to integrate usbmidi (usbaudio works). in the patch (written for alsa rc3?) this was done with:
[...]

Quoted 8 lines
Quoted 1 line
	.in_ep = 0x86,

This endpoint number must not include the USB_DIR_IN flag. Make this:

	.in_ep = 0x06,

If this is the only endpoint in the interface, you can omit the endpoint number and let the driver autodetect it.

i don't really know if autodetection will work (for the lsusb see below). the real problem are the kernel-oopses, the last message i get: ports are created.

8<------------------------------------------------------

Apr  9 17:57:05 konstruktor kernel: ALSA ../alsa-kernel/usb/usbmidi.c:782: created 2 output and 2 input ports
Apr  9 17:57:05 konstruktor kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000004
Apr  9 17:57:05 konstruktor kernel:  printing eip:
Apr  9 17:57:05 konstruktor kernel: d0861541
Apr  9 17:57:05 konstruktor kernel: *pde = 00000000
Apr  9 17:57:05 konstruktor kernel: Oops: 0002
Apr  9 17:57:05 konstruktor kernel: CPU:    0
Apr  9 17:57:05 konstruktor kernel: EIP: 0010:[ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-555711/96] 
   Not tainted
Apr  9 17:57:05 konstruktor kernel: EFLAGS: 00010246
Apr  9 17:57:05 konstruktor kernel: eax: cfc635c8   ebx: 00000001   ecx: 00000000   edx: c2b13de4
Apr  9 17:57:05 konstruktor kernel: esi: cfc635b8   edi: c2b13e04   ebp: 00000002   esp: c2951e48
Apr  9 17:57:05 konstruktor kernel: ds: 0018   es: 0018   ss: 0018
Apr  9 17:57:05 konstruktor kernel: Process modprobe (pid: 3506, stackpage=c2951000)
Apr  9 17:57:05 konstruktor kernel: Stack: c8e6bbc0 c2b13c14 cff60400 c2b13c14 c2951e6c c2951e6a c2951e68 00000002
Apr  9 17:57:05 konstruktor kernel:        00030606 00000003 00000000 d0861caa c2b13de4 c8e6bbc0 d086a6b8 d0861cc4
Apr  9 17:57:05 konstruktor kernel:        c2b13c14 c8e6bbc0 00000000 d0862019 c2b13c14 d086a650 d086a680 c8e6bbc0
Apr  9 17:57:05 konstruktor kernel: Call Trace: [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-553814/96] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-518472/96] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-553788/96] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-552935/96] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-518576/96]
Apr  9 17:57:05 konstruktor kernel: [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-518528/96] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-518500/96] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-541312/96] [usb_find_interface_driver+305/472] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-518576/96] [usb_check_support+92/120]
Apr  9 17:57:05 konstruktor kernel:    [usb_check_support+53/120] [usb_scan_devices+50/80] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-518528/96] [usb_register+150/156] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-552462/96] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-518528/96]
Apr  9 17:57:05 konstruktor kernel:    [sys_init_module+1285/1448] [ide-cd:__insmod_ide-cd_O/lib/modules/2.4.18/kernel/drivers/ide/ide+-561056/96] [system_call+51/56]
Apr  9 17:57:05 konstruktor kernel:
Apr  9 17:57:05 konstruktor kernel: Code: 89 41 04 89 4e 10 89 78 04 89 42 20 83 c6 1c 31 ff 83 3c 3e

8<---------------------------------------------------------------------------

usb desc:
8<---------------------------------------------------------------------------

usb.c: USB device 3 (vend/prod 0x1604/0x8001) is not claimed by any active driver.

  Length              = 18
  DescriptorType      = 01
  USB version         = 1.00
  Vendor:Product      = 1604:8001
  MaxPacketSize0      = 64
  NumConfigurations   = 1
  Device version      = 0.01
  Device Class:SubClass:Protocol = 00:00:00
    Per-interface classes
Configuration:
  bLength             =    9
  bDescriptorType     =   02
  wTotalLength        = 00b7
  bNumInterfaces      =   01
  bConfigurationValue =   01
  iConfiguration      =   00
  bmAttributes        =   40

MaxPower = 0mA

Interface: 0
Alternate Setting: 0

    bLength             =    9
    bDescriptorType     =   04
    bInterfaceNumber    =   00
    bAlternateSetting   =   00
    bNumEndpoints       =   05
    bInterface Class:SubClass:Protocol =   ff:00:00
    iInterface          =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   04 (out)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   84 (in)
      bmAttributes        =   03 (Interrupt)
      wMaxPacketSize      = 0015
      bInterval           =   0a
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   06 (out)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   86 (in)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   02 (out)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
  Alternate Setting:  1
    bLength             =    9
    bDescriptorType     =   04
    bInterfaceNumber    =   00
    bAlternateSetting   =   01
    bNumEndpoints       =   08
    bInterface Class:SubClass:Protocol =   ff:00:00
    iInterface          =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   04 (out)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   84 (in)
      bmAttributes        =   03 (Interrupt)
      wMaxPacketSize      = 0015
      bInterval           =   0a
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   06 (out)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   86 (in)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   02 (out)
      bmAttributes        =   02 (Bulk)
      wMaxPacketSize      = 0040
      bInterval           =   00
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   88 (in)
      bmAttributes        =   01 (Isochronous)
      wMaxPacketSize      = 00c8
      bInterval           =   01
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   8a (in)
      bmAttributes        =   01 (Isochronous)
      wMaxPacketSize      = 00c8
      bInterval           =   01
    Endpoint:
      bLength             =    7
      bDescriptorType     =   05
      bEndpointAddress    =   0a (out)
      bmAttributes        =   01 (Isochronous)
      wMaxPacketSize      = 00c8
      bInterval           =   01
  Alternate Setting:  2
    bLength             =    9
    bDescriptorType     =   04
    bInterfaceNumber    =   00
    bAlternateSetting   =   02
    bNumEndpoints       =   08

bInterface Class:SubClass:Protocol = ff:00:00
iInterface = 00
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 04 (out)
bmAttributes = 02 (Bulk)
wMaxPacketSize = 0040
bInterval = 00
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 84 (in)
bmAttributes = 03 (Interrupt)
wMaxPacketSize = 0015
bInterval = 0a
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 06 (out)
bmAttributes = 02 (Bulk)
wMaxPacketSize = 0040
bInterval = 00
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 86 (in)
bmAttributes = 02 (Bulk)
wMaxPacketSize = 0040
bInterval = 00
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 02 (out)
bmAttributes = 02 (Bulk)
wMaxPacketSize = 0040
bInterval = 00
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 88 (in)
bmAttributes = 01 (Isochronous)
wMaxPacketSize = 012c
bInterval = 01
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 8a (in)
bmAttributes = 01 (Isochronous)
wMaxPacketSize = 012c
bInterval = 01
Endpoint:
bLength = 7
bDescriptorType = 05
bEndpointAddress = 0a (out)
bmAttributes = 01 (Isochronous)
wMaxPacketSize = 012c
bInterval = 01
8<-----------------------------------------------------------

Greetings,

Thomas Rabe.

-- mail: raven at drehmoment dot org
-- home: http://hal9000.drehmoment.org
-- more: http://drehmoment.org

-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com

#3 lore raw
Quoted 6 lines · Thomas Rabe
Quoted 2 lines · Clemens Ladisch

If this is the only endpoint in the interface, you can omit the endpoint number and let the driver autodetect it.

i don't really know if autodetection will work (for the lsusb see below).

All endpoints are in one interface, so it wouldn't work.

Quoted 6 lines

the real problem are the kernel-oopses, the last message i get:
ports are created.

8<------------------------------------------------------

Apr  9 17:57:05 konstruktor kernel: ALSA ../alsa-kernel/usb/usbmidi.c:782: created 2 output and 2 input ports
Apr  9 17:57:05 konstruktor kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000004

Well, this may indicate that the MIDI part works and that the error is in some other part of the driver. Does the oops still happen when you don't call snd_usb_create_midi_interface?

HTH
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com

#4 lore raw
Quoted 4 lines · Clemens Ladisch
Quoted 2 lines · Thomas Rabe

Clemens Ladisch wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

If this is the only endpoint in the interface, you can omit the endpoint number and let the driver autodetect it.

i don't really know if autodetection will work (for the lsusb see below).

All endpoints are in one interface, so it wouldn't work.

will i have more luck with snd_usbmidi_create_rawmidi? if yes, should i declare the relevant functions/structs needed for rawmidi in usbaudio.h or cut'n paste the stuff from usbmidi.c in my driver file?

Quoted 11 lines
Quoted 6 lines

the real problem are the kernel-oopses, the last message i get:
ports are created.

8<------------------------------------------------------

Apr  9 17:57:05 konstruktor kernel: ALSA ../alsa-kernel/usb/usbmidi.c:782: created 2 output and 2 input ports
Apr  9 17:57:05 konstruktor kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000004

Well, this may indicate that the MIDI part works and that the error is in some other part of the driver. Does the oops still happen when you don't call snd_usb_create_midi_interface?

the driver works fine without calling snd_usb_create_midi_interface (no errors, all audiochannels are available). i just wondering why there is no error return but the oops. it's very hard to try out hacks, because i have to reboot after the oops (can't rmmod the driver and other alsa modules).

Quoted 2 lines

HTH
Clemens

Greetings,

Thomas Rabe.

-- mail: raven at drehmoment dot org
-- home: http://hal9000.drehmoment.org
-- more: http://drehmoment.org

-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com

#5 lore raw
Quoted 8 lines · Thomas Rabe
Quoted 5 lines · Clemens Ladisch
Quoted 2 lines · Thomas Rabe

i don't really know if autodetection will work (for the lsusb see below).

All endpoints are in one interface, so it wouldn't work.

will i have more luck with snd_usbmidi_create_rawmidi?

It's only the autodetection that wouldn't work. Using snd_usb_create_midi_interface with endpoint 0x06 should work just fine.

Quoted 6 lines
Quoted 3 lines

Well, this may indicate that the MIDI part works and that the error is in some other part of the driver. Does the oops still happen when you don't call snd_usb_create_midi_interface?

the driver works fine without calling snd_usb_create_midi_interface (no errors, all audiochannels are available).

The initialization code does nothing USB-related except allocing some URBs and submitting the input URBs. Please try to remove the call to snd_usbmidi_submit_urb at the end of _create_midi_interface.

HTH
Clemens

-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com