PATCH: C-Media 6206 USB Audio
I've been posting on the alsa-users list and I think I finally have a working patch now that I'd like to submit.
The C-Media 6206 device is based off of CM106 and just needed a boot quirk added to set the registers properly for output.
At least one other user can confirm that this patch works and that the SPDIF-out is also functioning now with this change.
This is diff'd against today's snapshot so it should be good to go. Let me know if there's anything else that I need to do or change with this.
Thanks,
---Dan
--- alsa-driver/alsa-kernel/usb/usbaudio.c 2009-06-07 06:20:32.000000000
-0400
+++ alsa-driver/alsa-kernel/usb/usbaudio.c 2009-06-07 22:24:44.000000000
-0400
@@ -3291,6 +3291,21 @@
return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
}
+static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) +{
+ /*
+ * C-Media CM6206 is based on CM106 with two additional + * registers that are not documented in the data sheet. + * Values here are chosen based on sniffing USB traffic + * under Windows. + */ + return snd_usb_cm106_write_int_reg(dev, 0, 0x200c) + + snd_usb_cm106_write_int_reg(dev, 1, 0x3000) + + snd_usb_cm106_write_int_reg(dev, 2, 0xf800) + + snd_usb_cm106_write_int_reg(dev, 3, 0x143f) + + snd_usb_cm106_write_int_reg(dev, 4, 0x0000) + + snd_usb_cm106_write_int_reg(dev, 5, 0x3000);
+}
/*
* Setup quirks
@@ -3577,6 +3592,12 @@
goto __err_val;
}+ /* C-Media CM6206 / CM106-Like Sound Device */
+ if (id == USB_ID(0x0d8c, 0x0102)) {
+ if (snd_usb_cm6206_boot_quirk(dev) < 0)
+ goto __err_val;
+ }
+
/*
* found a config. now register to ALSA
*/At Sun, 7 Jun 2009 22:46:51 -0400,
Quoted 9 lines · Dan Allongo
I've been posting on the alsa-users list and I think I finally have a working patch now that I'd like to submit.
The C-Media 6206 device is based off of CM106 and just needed a boot quirk added to set the registers properly for output.
At least one other user can confirm that this patch works and that the SPDIF-out is also functioning now with this change.
This is diff'd against today's snapshot so it should be good to go. Let me know if there's anything else that I need to do or change with this.
Thanks for the patch! I'd like certainly to apply it, however...
Review
Quoted 6 lines
(quoted diff) +6
-0+ return snd_usb_cm106_write_int_reg(dev, 0, 0x200c) + + snd_usb_cm106_write_int_reg(dev, 1, 0x3000) + + snd_usb_cm106_write_int_reg(dev, 2, 0xf800) + + snd_usb_cm106_write_int_reg(dev, 3, 0x143f) + + snd_usb_cm106_write_int_reg(dev, 4, 0x0000) + + snd_usb_cm106_write_int_reg(dev, 5, 0x3000);
Summing the return values here look weird.
You want to return an error code, right? Then use a simple if sequence, or write a loop there.
Also, run $LINUX/scripts/checkpatch.pl to your patch and fix errors / warnings suggested there. Then please repost the patch with your sign-off.
thanks,
Takashi
Quoted 1 line
From
888c94e4f714bdec2f0959a540721dd700fc8c88Mon Sep 17 00:00:00 2001
From: Dan Allongo <[email protected]>
Date: Mon, 8 Jun 2009 11:21:52 -0400
Subject: [PATCH - CM6206 1/1] modified: sound/usb/usbaudio.c
Added boot quirk for C-Media CM6206 device in snd_usb_audio_probe. The function snd_usb_cm6206_boot_quirk sets up six internal 16-bit registers in order to initialize the device. Values for the registers came from sniffing USB traffic under Windows since only four of the six are documented in the datasheet for CM106 and some reserved bits were also being set.
sound/usb/usbaudio.c +0 -0
@@ -3291,6 +3291,24 @@ static int snd_usb_cm106_boot_quirk(struct usb_device
*dev)
return snd_usb_cm106_write_int_reg(dev, 2, 0x8004);
}
+/*
+ * C-Media CM6206 is based on CM106 with two additional
+ * registers that are not documented in the data sheet.
+ * Values here are chosen based on sniffing USB traffic
+ * under Windows.
+ */
+static int snd_usb_cm6206_boot_quirk(struct usb_device *dev) +{
+ int err, reg;
+ int val[] = {0x200c,0x3000,0xf800,0x143f,0x0000,0x3000};
+
+ for (reg = 0; reg < 6; reg++) {
+ if ((err = snd_usb_cm106_write_int_reg(dev, reg, val[reg])) < 0)
+ return err;
+ }
+
+ return err;
+}
/*
* Setup quirks
@@ -3577,6 +3595,12 @@ static void *snd_usb_audio_probe(struct usb_device *dev,
goto __err_val;
}+ /* C-Media CM6206 / CM106-Like Sound Device */
+ if (id == USB_ID(0x0d8c, 0x0102)) {
+ if (snd_usb_cm6206_boot_quirk(dev) < 0)
+ goto __err_val;
+ }
+
/*
* found a config. now register to ALSA
*/Signature · 1 line
1.5.6.5
Quoted 36 lines · Takashi Iwai
At Sun, 7 Jun 2009 22:46:51 -0400,
Quoted 4 lines · Dan Allongo
I've been posting on the alsa-users list and I think I finally have a working patch now that I'd like to submit.
The C-Media 6206 device is based off of CM106 and just needed a bootquirk
Quoted 5 lines
added to set the registers properly for output.
At least one other user can confirm that this patch works and that the SPDIF-out is also functioning now with this change.
This is diff'd against today's snapshot so it should be good to go. Let me know if there's anything else that I need to do or change withthis.
Thanks for the patch! I'd like certainly to apply it, however...
Review
Quoted 6 lines
(quoted diff) +6
-0+ return snd_usb_cm106_write_int_reg(dev, 0, 0x200c) + + snd_usb_cm106_write_int_reg(dev, 1, 0x3000) + + snd_usb_cm106_write_int_reg(dev, 2, 0xf800) + + snd_usb_cm106_write_int_reg(dev, 3, 0x143f) + + snd_usb_cm106_write_int_reg(dev, 4, 0x0000) + + snd_usb_cm106_write_int_reg(dev, 5, 0x3000);Summing the return values here look weird.
You want to return an error code, right? Then use a simple if sequence, or write a loop there.Also, run
$LINUX/scripts/checkpatch.plto your patch and fix errors / warnings suggested there. Then please repost the patch with your sign-off.thanks,
Takashi