4

I'm trying to write a simple driver for my USB Sound Card (just for fun) on Xubuntu 14.04 -- for example, I want to have an opportunity to control volume on my laptop via this device.

The problem is -- I have nothing on output with sudo cat /dev/hidraw0. I tested my USB Mouse in this way -- I was getting some output on clicks and moves. I think, the device is exactly /dev/hidraw0, because it's the only thing which appears in /dev/ directory when I plug it in and disappears when I plug it out.

Also this example http://lxr.free-electrons.com/source/samples/hidraw/hid-example.c shows me

Report Descriptor Size: 50
Report Descriptor:
5 c 9 1 a1 1 15 0 25 1 9 e9 9 ea 75 1 95 2 81 2 9 e2 9 0 81 6 9 0 95 4 81 2 26 ff 0 9 0 75 8 95 f 81 2 9 0 95 10 91 2 c0 

Raw Name: C-Media Electronics Inc. USB Advanced Audio Device
Raw Phys: usb-0000:00:1a.0-1.2/input3
Raw Info:
        bustype: 3 (USB)
        vendor: 0x0b05
        product: 0x1743
HIDIOCSFEATURE: Broken pipe
HIDIOCGFEATURE: Broken pipe
Error: 32
write: Broken pipe
read: Resource temporarily unavailable

How can I read some intput from this device? What's wrong?

[EDIT 1]

Command sudo lsusb -v -d 0b05:1743 shows

Bus 001 Device 005: ID 0b05:1743 ASUSTek Computer, Inc. Xonar U1 Audio Station
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x0b05 ASUSTek Computer, Inc.
  idProduct          0x1743 Xonar U1 Audio Station
  bcdDevice            1.00
  iManufacturer           3 C-Media Electronics Inc.
  iProduct                1 USB Advanced Audio Device
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          293
    bNumInterfaces          4
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      1 Control Device
      bInterfaceProtocol      0 
      iInterface              0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      1 (HEADER)
        bcdADC               1.00
        wTotalLength          128
        bInCollection           2
        baInterfaceNr( 0)       1
        baInterfaceNr( 1)       2
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             2
        wTerminalType      0x0201 Microphone
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             3
        wTerminalType      0x0603 Line Connector
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                12
        bDescriptorType        36
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             4
        wTerminalType      0x0605 SPDIF interface
        bAssocTerminal          0
        bNrChannels             2
        wChannelConfig     0x0003
          Left Front (L)
          Right Front (R)
        iChannelNames           0 
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             6
        wTerminalType      0x0301 Speaker
        bAssocTerminal          0
        bSourceID               9
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID             7
        wTerminalType      0x0101 USB Streaming
        bAssocTerminal          0
        bSourceID               8
        iTerminal               0 
      AudioControl Interface Descriptor:
        bLength                 9
        bDescriptorType        36
        bDescriptorSubtype      5 (SELECTOR_UNIT)
        bUnitID                 8
        bNrInPins               3
        baSource( 0)           10
        baSource( 1)           11
        baSource( 2)           12
        iSelector               0 
      AudioControl Interface Descriptor:
        bLength                13
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                 9
        bSourceID               1
        bControlSize            2
        bmaControls( 0)      0x01
        bmaControls( 0)      0x02
          Mute Control
          Loudness Control
        bmaControls( 1)      0x02
        bmaControls( 1)      0x00
          Volume Control
        bmaControls( 2)      0x02
        bmaControls( 2)      0x00
          Volume Control
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                10
        bSourceID               2
        bControlSize            1
        bmaControls( 0)      0x01
          Mute Control
        bmaControls( 1)      0x02
          Volume Control
        bmaControls( 2)      0x02
          Volume Control
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                11
        bSourceID               3
        bControlSize            1
        bmaControls( 0)      0x01
          Mute Control
        bmaControls( 1)      0x02
          Volume Control
        bmaControls( 2)      0x02
          Volume Control
        iFeature                0 
      AudioControl Interface Descriptor:
        bLength                10
        bDescriptorType        36
        bDescriptorSubtype      6 (FEATURE_UNIT)
        bUnitID                12
        bSourceID               4
        bControlSize            1
        bmaControls( 0)      0x01
          Mute Control
        bmaControls( 1)      0x00
        bmaControls( 2)      0x00
        iFeature                0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           1
        bDelay                  1 frames
        wFormatTag              1 PCM
      AudioStreaming Interface Descriptor:
        bLength                20
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            4 Discrete
        tSamFreq[ 0]         8000
        tSamFreq[ 1]        16000
        tSamFreq[ 2]        44100
        tSamFreq[ 3]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            9
          Transfer Type            Isochronous
          Synch Type               Adaptive
          Usage Type               Data
        wMaxPacketSize     0x00c8  1x 200 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioControl Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x01
            Sampling Frequency
          bLockDelayUnits         1 Milliseconds
          wLockDelay              1 Milliseconds
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        2
      bAlternateSetting       1
      bNumEndpoints           1
      bInterfaceClass         1 Audio
      bInterfaceSubClass      2 Streaming
      bInterfaceProtocol      0 
      iInterface              0 
      AudioStreaming Interface Descriptor:
        bLength                 7
        bDescriptorType        36
        bDescriptorSubtype      1 (AS_GENERAL)
        bTerminalLink           7
        bDelay                  1 frames
        wFormatTag              1 PCM
      AudioStreaming Interface Descriptor:
        bLength                20
        bDescriptorType        36
        bDescriptorSubtype      2 (FORMAT_TYPE)
        bFormatType             1 (FORMAT_TYPE_I)
        bNrChannels             2
        bSubframeSize           2
        bBitResolution         16
        bSamFreqType            4 Discrete
        tSamFreq[ 0]         8000
        tSamFreq[ 1]        16000
        tSamFreq[ 2]        44100
        tSamFreq[ 3]        48000
      Endpoint Descriptor:
        bLength                 9
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            5
          Transfer Type            Isochronous
          Synch Type               Asynchronous
          Usage Type               Data
        wMaxPacketSize     0x00c8  1x 200 bytes
        bInterval               1
        bRefresh                0
        bSynchAddress           0
        AudioControl Endpoint Descriptor:
          bLength                 7
          bDescriptorType        37
          bDescriptorSubtype      1 (EP_GENERAL)
          bmAttributes         0x01
            Sampling Frequency
          bLockDelayUnits         0 Undefined
          wLockDelay              0 Undefined
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        3
      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      50
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x87  EP 7 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)

Command printf '01%030d' | xxd -ps -r | sudo tee /dev/hidraw0 shows me an error tee: /dev/hidraw0: Broken pipe.

[EDIT 2]

Command sudo evtest /dev/input/event14 does not react on my interaction with device

Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0xb05 product 0x1743 version 0x100
Input device name: "C-Media Electronics Inc. USB Advanced Audio Device"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 113 (KEY_MUTE)
    Event code 114 (KEY_VOLUMEDOWN)
    Event code 115 (KEY_VOLUMEUP)
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
Properties:
Testing ... (interrupt to exit)

[EDIT 3]

Here is my sudo dumpcap -i usbmon1 -w - > usb.pcapng result: http://www.wikiupload.com/Q3QZA5LCTAUS5P2

1 Answer 1

1

You do not "see" any audio in /dev/hidraw0 because that control messages are handled over a different endpoint than audio messages. Control messages need reliable transmission while audio can get lost and typically uses isochronous transfers.

Your test program results in errors because it tried to write a report of length 2.

Here is the decoded HID report descriptor (converted using hidrd-convert):

Usage Page (Consumer),          ; 05 0C     - Consumer (0Ch)
Usage (Consumer Control),       ; 09 01     - Consumer control (01h, application collection)
Collection (Application),       ; A1 01
    Logical Minimum (0),        ; 15 00
    Logical Maximum (1),        ; 25 01
    Usage (Volume Inc),         ; 09 E9     - Volume increment (E9h, re-trigger control)
    Usage (Volume Dec),         ; 09 EA     - Volume decrement (EAh, re-trigger control)
    Report Size (1),            ; 75 01
    Report Count (2),           ; 95 02
    Input (Variable),           ; 81 02
    Usage (Mute),               ; 09 E2     - Mute (E2h, on/off control)
    Usage (00h),                ; 09 00
    Input (Variable, Relative), ; 81 06
    Usage (00h),                ; 09 00
    Report Count (4),           ; 95 04
    Input (Variable),           ; 81 02
    Logical Maximum (255),      ; 26 FF 00
    Usage (00h),                ; 09 00
    Report Size (8),            ; 75 08
    Report Count (15),          ; 95 0F
    Input (Variable),           ; 81 02
    Usage (00h),                ; 09 00
    Report Count (16),          ; 95 10
    Output (Variable),          ; 91 02
End Collection                  ; C0

This descriptor describes the binary format of the data that can be send using the Set_Report Request (over the control pipe). (See this Device Class Definition for Human Interface Devices (HID) document for details, especially 8.5 Report Example).

Interpretation of descriptor for the bit layout for Input reports (device-to-host, you receive them over an interrupt endpoint, see sec. 4.4 of HID 1.1):

0.0: Volume Increment
0.1: Volume Decrement
0.2: Mute
0.3: (null)
0.4-7: (null)
15 times 8 bits (1 byte): (null)

If you need to send HID reports, note that the report count of the Output report is 16 (and the bit size is 8). So an Output report (one which is sent over an Interrupt Out endpoint) is 16 bytes.

As far as I can see, your device is only able to send key events which have to be processed by the OS. It provides no functionality to adjust the audio levels in hardware via software.

As for the inability to read, the device does not have meaningful data to report over the control pipe so it is possible that the manufacturer did not bother implementing a Get_Report method. By the way, how does sudo lsusb -v -d 0b05:1743 look like?

4
  • I have added result of lsusb to my question, but I can't send signals with printf because of broken pipe (you can see that in the end of EDIT 1)
    – Charlie
    Nov 28, 2014 at 16:24
  • Also, my device (ASUS Xonar U1) has some controls for volume regulation, mute/unmute button and led indicator: blue means normal work of device, red means mute, purple means that device is plugged, but something's gone wrong (as in my case without drivers)
    – Charlie
    Nov 28, 2014 at 16:31
  • @Charlie Can you obtain a packet capture as described in this post? Remove the USB device, start the capture, insert the device, wait for 3 seconds (such that is clear in the capture), press some keys, stop the capture and upload it.
    – Lekensteyn
    Nov 28, 2014 at 22:02
  • Done it -- you can see it in EDIT 3 section
    – Charlie
    Nov 29, 2014 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .