i.MX6 solo with Linux : Android phone as USB Sound card : no PCM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX6 solo with Linux : Android phone as USB Sound card : no PCM

1,315 Views
michael_th
Contributor I

Hello,

I'm trying to use an Android device as an external USB sound card. The goal is to be able to read audio coming from the android device.

I use a custom board with i.MX6 with Linux based on BSP 4.0.0.

Linux is in configured in USB host mode. I added the snd_usb_audio driver to the kernel.

My problem is that even if the device is properly recognized and the snd_usb_audio driver actually is starting, the pcmC0D0c device file in /dev/snd/  is missing.

The device appears in as a sound card in /proc/asound/cards :

0 [SAMSUNGAndroid ]: USB-Audio - SAMSUNG_Android                      

SAMSUNG SAMSUNG_Android at usb-fsl-ehci.0-1.3, high speed

In /dev/snd only a time and a control device file is created :

root@BUI270:/home/appdata# ls /dev/snd/

by-id      by-path    controlC0  timer

Same information in /proc/asound/devices :

root@BUI270:/home/appdata# cat /proc/asound/devices  

0: [ 0]   : control 33:        : timer

I monitored udev to know what is exactly happening when the device is connected.

I see the same, the device is recognized but no pcm device file is created, only control and mixer :

KERNEL[1711.766285] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3 (usb)

UDEV  [1711.786822] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3 (usb)

KERNEL[1711.793708] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0 (usb)

KERNEL[1711.797750] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1 (usb)

KERNEL[1711.802739] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0 (sound)

KERNEL[1711.806283] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0/controlC0 (sound)

KERNEL[1711.809842] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0/mixer (sound)

KERNEL[1711.820871] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.2 (usb)

KERNEL[1711.823867] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.3 (usb)

KERNEL[1711.827551] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/usb_device/usbdev1.7 (usb_device)

UDEV  [1711.898694] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.2 (usb)

UDEV  [1711.913276] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.0 (usb)

UDEV  [1711.918454] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.3 (usb)

UDEV  [1711.935963] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/usb_device/usbdev1.7 (usb_device)

UDEV  [1711.975344] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1 (usb)

UDEV  [1711.977019] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0 (sound)

KERNEL[1711.979869] change   /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0 (sound)

UDEV  [1712.041063] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0/mixer (sound)

UDEV  [1712.081646] add      /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0/controlC0 (sound)

UDEV  [1712.137611] change   /devices/platform/fsl-ehci.0/usb1/1-1/1-1.3/1-1.3:1.1/sound/card0 (sound)

There seems to be something wrong at the kernel level, but I have no idea what because the usb sound driver is there.

Any help would be greatly appreciated !

Labels (3)
Tags (1)
0 Kudos
3 Replies

931 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Michael,

We are internally reviewing your case. I will send you an update as soon as having news.

Best regards!

/Carlos

0 Kudos

931 Views
michael_th
Contributor I

Hello Carlos,

I found the solution : there is a bug in the alsa kernel driver.
After applying this patch, it works ([alsa-devel] Problem using alsa to implement an Android dock  ) :

Reported-by: Jeremy Rosen <jeremy.rosen at openwide.fr>

Not-yet-tested-by: Jeremy Rosen <jeremy.rosen at openwide.fr>

Cc: <stable at vger.kernel.org>

Signed-off-by: Clemens Ladisch <clemens at ladisch.de>

---

sound/usb/card.c | 22 ++++++++++++++++++++--

1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c

index 563854a..5a5153c 100644

--- a/sound/usb/card.c

+++ b/sound/usb/card.c

@@ -148,14 +148,32 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int

  return -EINVAL;

  }

+ alts = &iface->altsetting[0];

+ altsd = get_iface_desc(alts);

+

+ /*

+ * Android with both accessory and audio interfaces enabled gets the

+ * interface numbers wrong.

+ */

+ if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) ||

+ chip->usb_id == USB_ID(0x18d1, 0x2d05)) &&

+ interface == 0 &&

+ altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&

+ altsd->bInterfaceSubClass == USB_SUBCLASS_VENDOR_SPEC) {

+ interface = 2;

+ iface = usb_ifnum_to_if(dev, interface);

+ if (!iface)

+ return -EINVAL;

+ alts = &iface->altsetting[0];

+ altsd = get_iface_desc(alts);

+ }

+

  if (usb_interface_claimed(iface)) {

  snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n",

  dev->devnum, ctrlif, interface);

  return -EINVAL;

  }

- alts = &iface->altsetting[0];

- altsd = get_iface_desc(alts);

  if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||

  altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&

  altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) {

0 Kudos

931 Views
CarlosCasillas
NXP Employee
NXP Employee

Hi Michael,

I'm glad to know that you issue was solved! Thanks a lot for sharing your solution with the Community!!!

Best regards!

/Carlos

0 Kudos