Re: CM6206 USB Audio is mute.

From: Hans Petter Selasky <hps_at_selasky.org>
Date: Wed, 22 Apr 2015 09:40:16 +0200
On 04/21/15 21:30, Ranjan1018 . wrote:
> Connecting the USB cable the item is recognized:
> ugen0.5: <vendor 0x0d8c> at usbus0
> uaudio0: <vendor 0x0d8c USB Sound Device, class 0/0, rev 1.10/0.10, addr 5>
> on usbus0
> uaudio0: Play: 48000 Hz, 4 ch, 16-bit S-LE PCM format, 2x8ms buffer.
> uaudio0: Play: 44100 Hz, 4 ch, 16-bit S-LE PCM format, 2x8ms buffer.
> uaudio0: Record: 48000 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
> uaudio0: Record: 44100 Hz, 2 ch, 16-bit S-LE PCM format, 2x8ms buffer.
> uaudio0: No MIDI sequencer.
> pcm1: <USB audio> on uaudio0
> uaudio0: HID volume keys found.
>

Hi,

Did you check:

mixer -f /dev/mixerX

that sound volume is OK?

> Setting it as default unit
> # sysctl  hw.snd.default_unit=1
> and playing a song the interrupts count increase:

Some volume knobs might be hidden. Try to get all:

sysctl -a | grep pcm

> But the output is mute.
>
> In Debian Linux it works:
> # lsusb
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 002 Device 014: ID 0d8c:0102 C-Media Electronics, Inc. CM106 Like Sound
> Device
> # aplay -l
> **** List of PLAYBACK Hardware Devices ****
> card 1: Device [USB Sound Device], device 0: USB Audio [USB Audio]
>   Subdevices: 0/1
>   Subdevice #0: subdevice #0
>
> Looking at http://lxr.free-electrons.com/source/sound/usb/quirks.c I have
> found this code:
> /*
> 632 * C-Media CM106/CM106+ have four 16-bit internal registers that are
> nicely
> 633 * documented in the device's data sheet.
> 634 */
> 635 static int snd_usb_cm106_write_int_reg(struct usb_device *dev, int reg,
> u16 value)
> 636 {
> 637         u8 buf[4];
> 638         buf[0] = 0x20;
> 639         buf[1] = value & 0xff;
> 640         buf[2] = (value >> 8) & 0xff;
> 641         buf[3] = reg;
> 642         return snd_usb_ctl_msg(dev, usb_sndctrlpipe(dev, 0),
> USB_REQ_SET_CONFIGURATION,
> 643                                USB_DIR_OUT | USB_TYPE_CLASS |
> USB_RECIP_ENDPOINT,
> 644                                0, 0, &buf, 4);
> 645 }

This USB control request can be issued from userspace like this (you 
need to convert all variables below into constants):

usbconfig -d X.Y do_request "USB_DIR_OUT | USB_TYPE_CLASS |
 > USB_RECIP_ENDPOINT" "USB_REQ_SET_CONFIGURATION" 0 0 4 0x20 "(value & 
0xff)" "(value >> 8) & 0xff" "reg"

Such a command can easily be added like a devd script to run 
automatically during device attach.

> 646
>   647 static int snd_usb_cm106_boot_quirk(struct usb_device *dev)
> 648 {
> 649         /*
> 650         * Enable line-out driver mode, set headphone source to front
> 651         * channels, enable stereo mic.
> 652         */
> 653         return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
> 654 }
> 655
>   656 /*
> 657 * C-Media CM6206 is based on CM106 with two additional
> 658 * registers that are not documented in the data sheet.
> 659 * Values here are chosen based on sniffing USB traffic
> 660 * under Windows.
> 661 */
> 662 static int snd_usb_cm6206_boot_quirk(struct usb_device *dev)
> 663 {
> 664         int err  = 0, reg;
> 665         int val[] = {0x2004, 0x3000, 0xf800, 0x143f, 0x0000, 0x3000};
> 666
>   667         for (reg = 0; reg < ARRAY_SIZE(val); reg++) {
> 668                 err = snd_usb_cm106_write_int_reg(dev, reg, val[reg]);
> 669                 if (err < 0)
> 670                         return err;
> 671         }
> 672
>   673         return err;
> 674 }
> 675
>
> How can I test this code in FreeBSD ?
>

See answer above.

Please also use -stable or -current when testing.

--HPS
Received on Wed Apr 22 2015 - 05:39:29 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:57 UTC