Questions on usb audio development
Hi.
I know there is quite some documentation how to develop a pci driver for alsa - but since I'll try to get a usb device working I was wondering how to write a usb driver? Is it just the same? How to interface the various aspects of the device with regards to descriptor reading, ...
Quoted 5 lines · LCID Fire
Hi.
I know there is quite some documentation how to develop a pci driver for alsa - but since I'll try to get a usb device working I was wondering how to write a usb driver? Is it just the same? How to interface the various aspects of the device with regards to descriptor reading, ...
Look at the snd-usb-audio and usx2y sources.
Lee
At Sun, 20 May 2007 15:25:31 -0400,
Quoted 9 lines · Lee Revell
Quoted 5 lines · LCID Fire
Hi.
I know there is quite some documentation how to develop a pci driver for alsa - but since I'll try to get a usb device working I was wondering how to write a usb driver? Is it just the same? How to interface the various aspects of the device with regards to descriptor reading, ...Look at the snd-usb-audio and usx2y sources.
Also the new caiaq driver.
The major difference between the normal PCI and USB audio drivers is that USB audio has no traditional DMA like most PCI devices have. Thus the driver has to sets up URB pakets. usb-audio driver creates an intermediate ring-buffer that is used for the communication from/to user-space, and URBs are made from this buffer.
Takashi
Quoted 5 lines · Takashi Iwai
The major difference between the normal PCI and USB audio drivers is that USB audio has no traditional DMA like most PCI devices have. Thus the driver has to sets up URB pakets. usb-audio driver creates an intermediate ring-buffer that is used for the communication from/to user-space, and URBs are made from this buffer.
Basicly the reoccuring interface pattern I'm facing is:
bLength 9 bDescriptorType 4 bInterfaceNumber 5 bAlternateSetting 1 bNumEndpoints 1 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 2 bInterfaceProtocol 0 iInterface 6 LineIn2
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0x00b8 1x 184 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
Which is - if you ask me a normal audio token - hidden as a vendor specific interface. So what do you think, are these 2 descriptors just the audio format info or have they really embedded some specific info for the class? Question is whether to wire that with FIXED_ENDPOINT or STANDARD_INTERFACE?
The others are:
bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 1
bInterfaceProtocol 0
iInterface 15 Line 1
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported
Which again does not seem to be more than the sync node of an audio device (especially as it seems like they did not even change the subclass).
Well and I just for a start tried to write a quirks sections for these nodes like:
{
USB_DEVICE(0x13e5, 0x0001),
.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk)
{
.ifnum = QUIRK_ANY_INTERFACE,
.type = QUIRK_COMPOSITE,
.data = & (const struct snd_usb_audio_quirk[])
{
{
.ifnum = 0,
.altsetting = 0,
.type = QUIRK_AUDIO_STANDARD_INTERFACE
},
{
.ifnum = 0,
.type = QUIRK_AUDIO_FIXED_ENDPOINT,
.data = & (const struct audioformat)
{
.format = SNDRV_PCM_FORMAT_S16_LE,
.channels = 2,
.iface = 0,
.altsetting = 1,
.altset_idx = 1,
.attributes = 0,
.endpoint = 0x01,
.ep_attr = 0x09,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 44100,
.rate_max = 44100,
}
},
{
.ifnum = 2,
.type = QUIRK_AUDIO_FIXED_ENDPOINT,
.data = & (const struct audioformat)
{
.format = SNDRV_PCM_FORMAT_S16_LE,
.channels = 2,
.iface = 2,
.altsetting = 1,
.altset_idx = 1,
.attributes = 0,
.endpoint = 0x82,
.ep_attr = 0x09,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 44100,
.rate_max = 44100,
}
},
{
.ifnum = 3,
.altsetting = 0,
.type = QUIRK_AUDIO_STANDARD_INTERFACE
},
{
.ifnum = 4,
.type = QUIRK_AUDIO_FIXED_ENDPOINT,
.data = & (const struct audioformat)
{
.format = SNDRV_PCM_FORMAT_S16_LE,
.channels = 2,
.iface = 4,
.altsetting = 1,
.altset_idx = 1,
.attributes = 0,
.endpoint = 0x04,
.ep_attr = 0x09,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 44100,
.rate_max = 44100,
}
},
{
.ifnum = 5,
.type = QUIRK_AUDIO_FIXED_ENDPOINT,
.data = & (const struct audioformat)
{
.format = SNDRV_PCM_FORMAT_S16_LE,
.channels = 2,
.iface = 5,
.altsetting = 1,
.altset_idx = 1,
.attributes = 0,
.endpoint = 0x84,
.ep_attr = 0x09,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 44100,
.rate_max = 44100,
}
},
{
.ifnum = 6,
.altsetting = 0,
.type = QUIRK_AUDIO_STANDARD_INTERFACE
},
{
.ifnum = 7,
.type = QUIRK_AUDIO_FIXED_ENDPOINT,
.data = & (const struct audioformat)
{
.format = SNDRV_PCM_FORMAT_S16_LE,
.channels = 2,
.iface = 7,
.altsetting = 1,
.altset_idx = 1,
.attributes = 0,
.endpoint = 0x85,
.ep_attr = 0x09,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.rate_min = 44100,
.rate_max = 44100,
}
},
{
.ifnum = -1
}
}
}
},So could anyone please tell me whether I'm totally lost on a wrong track?
Quirks device not showing up
Well I defined a quirks for my usb device. I mined the probe code with output and it creates a new driver instance for my device as well as it finds the channels. Nevertheless I don't get my device listed in userspace. Is there anything special to be done besides defining a quirks?
Re: Quirks device not showing up
Quoted 5 lines · LCID Fire
Well I defined a quirks for my usb device. I mined the probe code with output and it creates a new driver instance for my device as well as it finds the channels. Nevertheless I don't get my device listed in userspace. Is there anything special to be done besides defining a quirks?
All quirks have been written as specific workarounds for certain devices. It is possible that you device behaves in some different way.
I'd tell you what the actual problem with your quirk is, but my crystal ball is under repair just now. Please show your code and the output of "lsusb -v" for your device.
Regards,
Clemens
Re: Quirks device not showing up
Quoted 3 lines · Clemens Ladisch
I'd tell you what the actual problem with your quirk is, but my crystal ball is under repair just now. Please show your code and the output of "lsusb -v" for your device.
It's the following:
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.00
bDeviceClass 255 Vendor Specific Class bDeviceSubClass 255 Vendor Specific Subclass bDeviceProtocol 255 Vendor Specific Protocol bMaxPacketSize0 32 idVendor 0x13e5 idProduct 0x0001 bcdDevice 1.00 iManufacturer 1 iProduct 2 iSerial 0 bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 497
bNumInterfaces 9
bConfigurationValue 1
iConfiguration 13
bmAttributes 0x80
(Bus Powered)
MaxPower 300mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 1
bInterfaceProtocol 0
iInterface 15
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 7
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 9
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0x00b8 1x 184 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 3
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 5
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0x00b8 1x 184 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 1
bInterfaceProtocol 0
iInterface 16
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 4
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 8
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 4
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 10
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0x00b8 1x 184 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 5
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 4
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 5
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 6
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0x00b8 1x 184 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 6
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 1
bInterfaceProtocol 0
iInterface 17
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 7
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 11
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 7
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 2
bInterfaceProtocol 0
iInterface 12
Class specific interface descriptor for class 255 is unsupported Class specific interface descriptor for class 255 is unsupported Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 9
Transfer Type Isochronous
Synch Type Adaptive
Usage Type Data
wMaxPacketSize 0x0090 1x 144 bytes
bInterval 1
bRefresh 0
bSynchAddress 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 8
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 4
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 4
cannot read device status, Operation not permitted (1)
Seems pretty default to me. As I said the probing and analyses of the channel seems to work fine.
Re: Quirks device not showing up
Quoted 5 lines · LCID Fire
Quoted 3 lines · Clemens Ladisch
I'd tell you what the actual problem with your quirk is, but my crystal ball is under repair just now. Please show your code and the output of "lsusb -v" for your device.
It's the following:
Where's the code?
Lee
Re: Quirks device not showing up
Quoted 8 lines · Lee Revell
Quoted 5 lines · LCID Fire
Quoted 3 lines · Clemens Ladisch
I'd tell you what the actual problem with your quirk is, but my crystal ball is under repair just now. Please show your code and the output of "lsusb -v" for your device.
It's the following:
Where's the code?
Oh, it's
{
USB_DEVICE(0x13e5, 0x0001),
.driver_info = (unsigned long) & (const struct snd_usb_audio_quirk)
{
.ifnum = QUIRK_ANY_INTERFACE,
.type = QUIRK_AUDIO_STANDARD_INTERFACE
}
}added to usbquirks.h
Re: Quirks device not showing up
In reply to LCID FireQuoted 4 lines · LCID Fire
Well I defined a quirks for my usb device. I mined the probe code with output and it creates a new driver instance for my device as well as it finds the channels. Nevertheless I don't get my device listed in userspace. Is there anything special to be done besides defining a quirks?
I have to correct myself a bit. The patch is actually working - and my card and it's channels are detected just fine - problem is there seems to be no mixer available for my channels.
When I try to access my card using alsamixer I get a message "No mixer elems found". Is there a special .conf file necessary and what's the format for it?
Re: Quirks device not showing up
Quoted 11 lines · LCID Fire
Quoted 4 lines · LCID Fire
Well I defined a quirks for my usb device. I mined the probe code with output and it creates a new driver instance for my device as well as it finds the channels. Nevertheless I don't get my device listed in userspace. Is there anything special to be done besides defining a quirks?
I have to correct myself a bit. The patch is actually working - and my card and it's channels are detected just fine - problem is there seems to be no mixer available for my channels.
When I try to access my card using alsamixer I get a message "No mixer elems found". Is there a special .conf file necessary and what's the format for it?
This is normal, many USB devices don't have any mixer elements.
Lee
Re: Quirks device not showing up
Quoted 9 lines · Lee Revell
Quoted 6 lines · LCID Fire
I have to correct myself a bit. The patch is actually working - and my card and it's channels are detected just fine - problem is there seems to be no mixer available for my channels.
When I try to access my card using alsamixer I get a message "No mixer elems found". Is there a special .conf file necessary and what's the format for it?This is normal, many USB devices don't have any mixer elements.
Ok, but isn't there a software way to emulate the mixer?