Skip to content

Instantly share code, notes, and snippets.

@vext01
Last active January 24, 2021 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vext01/958756d0fd515cc321f99a3ee1e3351a to your computer and use it in GitHub Desktop.
Save vext01/958756d0fd515cc321f99a3ee1e3351a to your computer and use it in GitHub Desktop.
DAC Audio

Trying to use this use DAC on OpenBSD-6.8 and -current fails.

uaudio2 at uhub0 port 1 configuration 1 interface 3 "E+ Corp. DAC Audio" rev 1.10/0.01 addr 2
uaudio2: class v1, full-speed, async, channels: 2 play, 0 rec, 3 ctls
audio3 at uaudio2

The problem is that one of the checks fails when trying to get a usb interface handle:

usbd_status
usbd_device2interface_handle(struct usbd_device *dev, u_int8_t ifaceno,
    struct usbd_interface **iface)
{
	if (dev->cdesc == NULL)
		return (USBD_NOT_CONFIGURED);
	if (ifaceno >= dev->cdesc->bNumInterface)
		return (USBD_INVAL);  // <---------- We return here because 3 >= 3 in the above line.
	*iface = &dev->ifaces[ifaceno];
	return (USBD_NORMAL_COMPLETION);
}

EDIT: The device exposes three USB interfaces with interface numbers 0, 1 and 3. This is not in compliance with the USB spec, which would require interfaces numbers 0, 1 and 2.

Bus 000 Device 002: ID 262a:9023
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 8
idVendor 0x262a
idProduct 0x9023
bcdDevice 0.01
iManufacturer 1 E+ Corp.
iProduct 2 DAC Audio
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 220
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 3 Human Interface Device
bInterfaceSubClass 0 No Subclass
bInterfaceProtocol 0 None
iInterface 0
HID Device Descriptor:
bLength 9
bDescriptorType 33
bcdHID 1.00
bCountryCode 0 Not supported
bNumDescriptors 1
bDescriptorType 34 Report
wDescriptorLength 92
Report Descriptor: (length is 92)
Item(Global): Usage Page, data= [ 0x0c ] 12
Consumer
Item(Local ): Usage, data= [ 0x01 ] 1
Consumer Control
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Global): Logical Minimum, data= [ 0x00 ] 0
Item(Global): Logical Maximum, data= [ 0x01 ] 1
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x01 ] 1
Item(Global): Report Count, data= [ 0x01 ] 1
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Size, data= [ 0x08 ] 8
Item(Global): Report Count, data= [ 0x12 ] 18
Item(Main ): Input, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Local ): Usage, data= [ 0x00 ] 0
Unassigned
Item(Global): Report Count, data= [ 0x1c ] 28
Item(Main ): Output, data= [ 0x02 ] 2
Data Variable Absolute No_Wrap Linear
Preferred_State No_Null_Position Non_Volatile Bitfield
Item(Main ): End Collection, data=none
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0013 1x 19 bytes
bInterval 32
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 1 Control Device
bInterfaceProtocol 0
iInterface 3 DAC Audio
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdADC 1.00
wTotalLength 40
bInCollection 1
baInterfaceNr( 0) 3
AudioControl Interface Descriptor:
bLength 12
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 6
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bNrChannels 2
wChannelConfig 0x0003
Left Front (L)
Right Front (R)
iChannelNames 0
iTerminal 0
AudioControl Interface Descriptor:
bLength 10
bDescriptorType 36
bDescriptorSubtype 6 (FEATURE_UNIT)
bUnitID 9
bSourceID 6
bControlSize 1
bmaControls( 0) 0x01
Mute Control
bmaControls( 1) 0x02
Volume Control
bmaControls( 2) 0x02
Volume Control
iFeature 0
AudioControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0301 Speaker
bAssocTerminal 0
bSourceID 9
iTerminal 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 1
bNumEndpoints 2
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 6
bDelay 1 frames
wFormatTag 1 PCM
AudioStreaming Interface Descriptor:
bLength 23
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 2
bBitResolution 16
bSamFreqType 5 Discrete
tSamFreq[ 0] 96000
tSamFreq[ 1] 88200
tSamFreq[ 2] 48000
tSamFreq[ 3] 44100
tSamFreq[ 4] 32000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0190 1x 400 bytes
bInterval 1
bRefresh 0
bSynchAddress 131
AudioControl Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0 Undefined
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0003 1x 3 bytes
bInterval 1
bRefresh 3
bSynchAddress 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 2
bNumEndpoints 2
bInterfaceClass 1 Audio
bInterfaceSubClass 2 Streaming
bInterfaceProtocol 0
iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 6
bDelay 1 frames
wFormatTag 1 PCM
AudioStreaming Interface Descriptor:
bLength 23
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 2
bSubframeSize 3
bBitResolution 24
bSamFreqType 5 Discrete
tSamFreq[ 0] 96000
tSamFreq[ 1] 88200
tSamFreq[ 2] 48000
tSamFreq[ 3] 44100
tSamFreq[ 4] 32000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0258 1x 600 bytes
bInterval 1
bRefresh 0
bSynchAddress 131
AudioControl Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0 Undefined
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0003 1x 3 bytes
bInterval 1
bRefresh 3
bSynchAddress 0
Device Status: 0x0000
(Bus Powered)
usbd_reset_port: port 2 reset done
usbd_new_device: bus=0xffff800000257000 port=2 depth=1 speed=2
usbd_setup_pipe: dev=0xffff800000cf7b00 iface=0x0 ep=0xffff800000cf7b38 pipe=0xffff800000cf7b08
usbd_new_device: adding unit addr=4, rev=110, class=0, subclass=0, protocol=0, maxpacket=8, len=18, speed=2
usbd_new_device: new dev (addr 4), dev=0xffff800000cf7b00, parent=0xffff80000024e900
usbd_probe_and_attach trying device specific drivers
usbd_probe_and_attach: no device specific driver found
usbd_probe_and_attach: looping over 1 configurations
usbd_probe_and_attach: trying config idx=0
usb_allocmem: large alloc 220
usb_freemem: large free
usbd_set_config_index: (addr 4) cno=1 attr=0x80, selfpowered=0, power=100
usbd_set_config_index: set config 1
uhidev0 at uhub0 port 2 configuration 1 interface 0 "E+ Corp. DAC Audio" rev 1.10/0.01 addr 4
usb_allocmem: large alloc 92
usb_freemem: large free
uhidev0: iclass 3/0
uhid0 at uhidev0: input=19, output=28, feature=0
uaudio0 at uhub0 port 2 configuration 1 interface 3 "E+ Corp. DAC Audio" rev 1.10/0.01 addr 4
uaudio_process_conf: skipped iface
uaudio_process_ac: ifnum = 1, 177 bytes to processs
uaudio_process_header: version 0x100
06: in, nch = 2, term = 0x101, assoc = 0
09: feature id = 6, nch = 2, size = 1
mute[-1]
uaudio_req: type = 0xa1, req = 0x82, val = 0x201, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x83, val = 0x201, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x84, val = 0x201, index = 0x901, size = 2
[-14080:0]/128 (14081 vals)
level[0]
uaudio_req: type = 0xa1, req = 0x82, val = 0x202, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x83, val = 0x202, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x84, val = 0x202, index = 0x901, size = 2
[-14080:0]/128 (14081 vals)
level[1]
02: out, id = 9, nch = 2, term = 0x301, assoc = 0
uaudio0: units list:
06: input <dac>, dest = 09 <dac>
09: feature <dac>, src = 06 <dac>, dst = 02 <output>, cls = 0
02: output <output>, source = 09 <dac>
uaudio0: mixer controls:
09: dac.level[0]
09: dac.level[1]
09: dac.mute
uaudio_process_conf: stop altnum 0
uaudio_process_as_ep: addr = 0x3, async/data, maxpktsz = 400, ival = 1
uaudio_process_as_ep: addr = 0x83, unk/data, maxpktsz = 3, ival = 1
uaudio_process_as_ep: addr = 0x3, async/data, maxpktsz = 600, ival = 1
uaudio_process_as_ep: addr = 0x83, unk/data, maxpktsz = 3, ival = 1
00: <outputs>, next = -1, prev = -1, class = -1
01: <inputs>, next = -1, prev = -1, class = -1
uaudio_req: type = 0xa1, req = 0x81, val = 0x201, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x81, val = 0x202, index = 0x901, size = 2
02: <dac>, next = -1, prev = -1, class = 0, nch = 2, delta = 1, val = 255 255
uaudio_req: type = 0xa1, req = 0x81, val = 0x100, index = 0x901, size = 1
03: <dac_mute>, next = -1, prev = -1, class = 0, members: off(=0) on(=1), val = 0
4 controls
alts:
mode = play, ifnum = 3, altnum = 2, addr = 0x3, maxpkt = 600, sync = 0x83, nch = 2, fmt = s24le3, rates: 32000 44100 48000 88200 96000
mode = play, ifnum = 3, altnum = 1, addr = 0x3, maxpkt = 400, sync = 0x83, nch = 2, fmt = s16le2, rates: 32000 44100 48000 88200 96000
parameters:
pchan = 2, s24le3, rchan = 0, s0le0, rates: 32000 44100 48000 88200 96000
pchan = 2, s16le2, rchan = 0, s0le0, rates: 32000 44100 48000 88200 96000
uaudio0: class v1, full-speed, async, channels: 2 play, 0 rec, 3 ctls
audio1 at uaudio0
uaudio_set_params: rate 48000 -> 48000 (index 8)
uaudio_set_params: rate = 48000
uaudio_set_params: rate 48000 -> 48000 (index 8)
uaudio_set_params: rate = 48000
uaudio_req: type = 0xa1, req = 0x81, val = 0x201, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x81, val = 0x202, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x81, val = 0x100, index = 0x901, size = 1
uaudio_set_params: rate 48000 -> 48000 (index 8)
uaudio_set_params: rate = 48000
uaudio_set_params: rate 48000 -> 48000 (index 8)
uaudio_set_params: rate = 48000
uaudio_req: type = 0xa1, req = 0x81, val = 0x201, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x81, val = 0x202, index = 0x901, size = 2
uaudio_req: type = 0xa1, req = 0x81, val = 0x100, index = 0x901, size = 1
uaudio_stream_open: play: blksz = 1920, rate = 48000, fps = 1000
uaudio_stream_open: spf = 0xf00000 in [0xef1000:0xf0f000]
uaudio_stream_open: nframes_max = 11, nframes_mask = 0, maxpkt = 196
uaudio_stream_open: safe_blksz = 2048, nxfers = 4
usb_allocmem: large alloc 2156
usb_allocmem: large alloc 2156
usb_allocmem: large alloc 2156
usb_allocmem: large alloc 2156
uaudio0: can't get iface handle
uaudio0: can't get iface handle
usb_freemem: large free
usb_freemem: large free
usb_freemem: large free
usb_freemem: large free
audio1: failed to start playback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment