[Android Q&A, Help & Troubleshooting] DACcer:
I've been looking at getting external USB audio (using an external USB DAC for sound) working on my HTC One XL for a bit now, and I'm starting to hit a wall...

I've built a new custom kernel based of the base CyanogenMod one for the MSM8960. This works :)

I've turned on a ton of debugging + added more debugging, and compiled in the USB Audio drivers, my kernel logs now look something like:

<6>[ 192.232076] usb 1-1: new full speed USB device number 2 using msm_hsusb_host

<6>[ 192.387639] usb 1-1: New USB shizzle found, idVendor=045e, idProduct=070f

<6>[ 192.387730] usb 1-1: New USB device strings: Mfr=0, Product=1, SerialNumber=0

<6>[ 192.387852] usb 1-1: Product: Microsoft LifeChat LX-3000

<7>[ 192.387913] device: '1-1': device_add

<7>[ 192.388280] bus: 'usb': add device 1-1

<7>[ 192.388402] PM: Adding info for usb:1-1

<7>[ 192.388890] bus: 'usb': driver_probe_device: matched device 1-1 with driver usb

<7>[ 192.389012] bus: 'usb': really_probe: probing driver usb with device 1-1

<7>[ 192.389073] usb 1-1: usb_probe_device

<7>[ 192.389195] usb 1-1: configuration #1 chosen from 1 choice

<7>[ 192.389256] usb 1-1: rpm_resume flags 0x4

<7>[ 192.389317] usb 1-1: rpm_resume returns 1

<7>[ 192.390599] usb 1-1: adding 1-1:1.0 (config #1, interface 0)

<7>[ 192.390660] device: '1-1:1.0': device_add

<7>[ 192.390782] bus: 'usb': add device 1-1:1.0

<7>[ 192.390874] PM: Adding info for usb:1-1:1.0

<7>[ 192.391118] bus: 'usb': driver_probe_device: matched device 1-1:1.0 with driver snd-usb-audio

<7>[ 192.391240] bus: 'usb': really_probe: probing driver snd-usb-audio with device 1-1:1.0

<7>[ 192.391362] snd-usb-audio 1-1:1.0: usb_probe_interface

<7>[ 192.391423] snd-usb-audio 1-1:1.0: usb_probe_interface - got id

<7>[ 192.391545] usb 1-1: rpm_resume flags 0x4

<7>[ 192.391606] usb 1-1: rpm_resume returns 1

<6>[ 192.392583] 2:1:0: add audio endpoint Interface Class = 1

<6>[ 192.392644] 2:1:0: add audio endpoint Interface SubClass = 2

<6>[ 192.392736] 2:1:0: add audio endpoint Interface Class = 1

<6>[ 192.392797] 2:1:0: add audio endpoint Interface SubClass = 2

<6>[ 192.392919] 2:1:1: UAC Version 1

<6>[ 192.392980] 2:1:1: add audio endpoint 0x1

<6>[ 192.396581] 2:2:0: add audio endpoint Interface Class = 1

<6>[ 192.396673] 2:2:0: add audio endpoint Interface SubClass = 2

<6>[ 192.396734] 2:2:0: add audio endpoint Interface Class = 1

<6>[ 192.396856] 2:2:0: add audio endpoint Interface SubClass = 2

<6>[ 192.396917] 2:2:1: UAC Version 1

<6>[ 192.396978] 2:2:1: add audio endpoint 0x82

<6>[ 192.400579] [13] FU [Mic Playback Switch] ch = 1, val = 0/1/1

<3>[ 192.400640] Unable to resume device, either shutdown or probing (0,1)

<3>[ 192.400762] cannot get ctl value: req = 0x83, wValue = 0x200, wIndex = 0xd00, type = 4, error = -19

<3>[ 192.400885] 13:0: cannot get min/max values for control 2 (id 13)

<3>[ 192.400976] Unable to resume device, either shutdown or probing (0,1)

<3>[ 192.401098] cannot get ctl value: req = 0x84, wValue = 0x200, wIndex = 0xd00, type = 4, error = -19

<6>[ 192.401220] [13] FU [Mic Playback Volume] ch = 1, val = 0/1/1

<6>[ 192.401281] [9] FU [Speaker Playback Switch] ch = 1, val = 0/1/1

<3>[ 192.401403] Unable to resume device, either shutdown or probing (0,1)

<3>[ 192.401464] cannot get ctl value: req = 0x83, wValue = 0x201, wIndex = 0x900, type = 4, error = -19

<3>[ 192.401587] 9:0: cannot get min/max values for control 2 (id 9)

<3>[ 192.401648] Unable to resume device, either shutdown or probing (0,1)

<3>[ 192.401739] cannot get ctl value: req = 0x84, wValue = 0x201, wIndex = 0x900, type = 4, error = -19

<6>[ 192.401861] [9] FU [Speaker Playback Volume] ch = 2, val = 0/1/1

<6>[ 192.401922] [10] FU [Mic Capture Switch] ch = 1, val = 0/1/1

<3>[ 192.402044] Unable to resume device, either shutdown or probing (0,1)

<3>[ 192.402136] cannot get ctl value: req = 0x83, wValue = 0x200, wIndex = 0xa00, type = 4, error = -19

<3>[ 192.402258] 10:0: cannot get min/max values for control 2 (id 10)

<3>[ 192.402350] Unable to resume device, either shutdown or probing (0,1)

<3>[ 192.402441] cannot get ctl value: req = 0x84, wValue = 0x200, wIndex = 0xa00, type = 4, error = -19

<6>[ 192.402533] [10] FU [Mic Capture Volume] ch = 1, val = 0/1/1

<6>[ 192.402655] [10] FU [Auto Gain Control] ch = 1, val = 0/1/1

<7>[ 192.402746] device: 'card1': device_add

<7>[ 192.402868] PM: Adding info for No Bus:card1

<7>[ 192.403174] device: 'pcmC1D0p': device_add

<7>[ 192.403418] PM: Adding info for No Bus:pcmC1D0p

<7>[ 192.403906] device: 'pcmC1D0c': device_add

<7>[ 192.404059] PM: Adding info for No Bus:pcmC1D0c

<7>[ 192.404455] device: 'controlC1': device_add

<7>[ 192.404669] PM: Adding info for No Bus:controlC1

<7>[ 192.405035] driver: '1-1:1.0': driver_bound: bound to device 'snd-usb-audio'

<7>[ 192.405157] bus: 'usb': really_probe: bound device 1-1:1.0 to driver snd-usb-audio

<7>[ 192.405218] snd-usb-audio 1-1:1.0: rpm_suspend flags 0x4

<7>[ 192.405310] snd-usb-audio 1-1:1.0: rpm_suspend returns 0

<7>[ 192.405402] usb 1-1: adding 1-1:1.1 (config #1, interface 1)

<7>[ 192.405493] device: '1-1:1.1': device_add

<7>[ 192.405585] bus: 'usb': add device 1-1:1.1

<7>[ 192.405707] PM: Adding info for usb:1-1:1.1

<7>[ 192.405981] driver: '1-1:1.1': driver_bound: bound to device 'snd-usb-audio'

<7>[ 192.406104] usb 1-1: adding 1-1:1.2 (config #1, interface 2)

<7>[ 192.406165] device: '1-1:1.2': device_add

<7>[ 192.406256] bus: 'usb': add device 1-1:1.2

<7>[ 192.406378] PM: Adding info for usb:1-1:1.2

<7>[ 192.406622] driver: '1-1:1.2': driver_bound: bound to device 'snd-usb-audio'

<7>[ 192.406744] usb 1-1: adding 1-1:1.3 (config #1, interface 3)

<7>[ 192.406806] device: '1-1:1.3': device_add

<7>[ 192.406958] bus: 'usb': add device 1-1:1.3

<7>[ 192.407019] PM: Adding info for usb:1-1:1.3

<7>[ 192.408240] bus: 'usb': driver_probe_device: matched device 1-1:1.3 with driver usbhid

<7>[ 192.408362] bus: 'usb': really_probe: probing driver usbhid with device 1-1:1.3

<7>[ 192.408484] usbhid 1-1:1.3: usb_probe_interface

<7>[ 192.408545] usbhid 1-1:1.3: usb_probe_interface - got id

<7>[ 192.408667] usb 1-1: rpm_resume flags 0x4

<7>[ 192.408728] usb 1-1: rpm_resume returns 1

<7>[ 192.408850] device: '0003:045E:070F.0001': device_add

<7>[ 192.408972] bus: 'hid': add device 0003:045E:070F.0001

<7>[ 192.409034] PM: Adding info for hid:0003:045E:070F.0001

<7>[ 192.409400] bus: 'hid': driver_probe_device: matched device 0003:045E:070F.0001 with driver generic-usb

<7>[ 192.409461] bus: 'hid': really_probe: probing driver generic-usb with device 0003:045E:070F.0001

<7>[ 192.411841] usbhid 1-1:1.3: rpm_resume flags 0x5

<7>[ 192.411963] usbhid 1-1:1.3: rpm_resume returns 1

<7>[ 192.413825] device: 'input7': device_add

<7>[ 192.413978] PM: Adding info for No Bus:input7

<6>[ 192.414344] input: Microsoft LifeChat LX-3000 as /devices/platform/msm_hsusb_host/usb1/1-1/1-1:1.3/input/input7

<7>[ 192.414466] device: 'event7': device_add

<7>[ 192.414771] PM: Adding info for No Bus:event7

<6>[ 192.415077] generic-usb 0003:045E:070F.0001: input: USB HID v1.00 Device [Microsoft LifeChat LX-3000 ] on usb-msm_hsusb_host-1/input3

<7>[ 192.415229] driver: '0003:045E:070F.0001': driver_bound: bound to device 'generic-usb'

<7>[ 192.415290] bus: 'hid': really_probe: bound device 0003:045E:070F.0001 to driver generic-usb

<7>[ 192.415412] driver: '1-1:1.3': driver_bound: bound to device 'usbhid'

<7>[ 192.415534] bus: 'usb': really_probe: bound device 1-1:1.3 to driver usbhid

....

Now the errors printed above, really don't matter (after much debugging, it appears to be a bug in ALSA, will look at fixing that later, but it isn't going to cause any issues from what I can tell).

So in conclusion, it looks like it successfully loaded USB_AUDIO drivers and the HID driver (the HID driver is for the volume control on the headset).

Now my logcat looks like:

E/WiredAccessoryObserver( 359): unsetting h2w flag

I/DockObserver( 359): Dock state changed: 16

V/WiredAccessoryObserver( 359): Headset UEVENT: {SUBSYSTEM=switch, SWITCH_STATE=16, DEVPATH=/devices/virtual/switch/dock, SEQNUM=3298, ACTION=change, SWITCH_NAME=dock}

V/WiredAccessoryObserver( 359): updateState name: dock state 16

V/WiredAccessoryObserver( 359): updateState switchState: 0

V/WiredAccessoryObserver( 359): newState = 0, headsetState = 0,mHeadsetState = 0

V/BluetoothService( 359): Received ACTION_DOCK_EVENT with State:16

E/SharedPreferencesImpl( 359): Couldn't create directory for SharedPreferences file shared_prefs/bluetooth_service_settings.xml

I/ActivityManager( 359): Start proc net.muteheadlight.dockredir for broadcast net.muteheadlight.dockredir/net.muteheadlight.docksoundredir.dockSoundRedirect: pid=3397 uid=10133 gids={1028}

D/ActivityThread( 3397): setTargetHeapUtilization:0.25

D/ActivityThread( 3397): setTargetHeapIdealFree:8388608

D/ActivityThread( 3397): setTargetHeapConcurrentStart:2097152

I/ActivityManager( 359): No longer want com.google.android.talk (pid 2959): hidden #16

D/EventHub( 359): No input device configuration file found for device 'Microsoft LifeChat LX-3000 '.

I/EventHub( 359): New device: id=8, fd=287, path='/dev/input/event7', name='Microsoft LifeChat LX-3000 ', classes=0x80000001, configuration='', keyLayout='/system/usr/keylayout/Generic.kl', keyCharacterMap='/system/usr/keychars/Generic.kcm', builtinKeyboard=false, usingSuspendBlockIoctl=false, usingClockIoctl=false

I/InputReader( 359): Device added: id=8, name='Microsoft LifeChat LX-3000 ', sources=0x00000101

To get this far, I had to manually trigger an Intent with Action of 'com.cyanogenmod.settings.SamsungDock'. Before sending that intent, the WiredAccessoryObserver would print 'Ignoring dock event as Audio routing disabled'.

After all this, no sound is routed to the external USb headset :crying:

I have a feeling the kernel is working as expected, but the Cyanogenmod rom is not correctly handling the dock event.The DockObserver class in cyanogenmod watches for events:

DOCK_UEVENT_MATCH = "DEVPATH=/devices/virtual/switch/dock";

And this is being sent by the kernel and received by the DockObserver, but from here it seems to try and load the deive as a smsung USB audio dock, instead of usb_audio.

My really big question is, how does this work on the Galaxy Nexus with only a kernel change to load the correct drivers....:eek:

Any input or pointing in the right direction would be great!!!! (if you've listened to my rant this far you've done well).