ALSA: usb: Work around CM6631 sample rate change bug
PATCH 1/1 ALSA: usb: Work around CM6631 sample rate change bug
The C-Media CM6631 USB-to-S/PDIF receiver doesn't respond to changes in sampling frequency while the interface is active.
Reset the interface after setting the sampling frequency, to ensure that the sample rate set by snd_usb_init_sample_rate() is used. Otherwise, the device will try to use the sample rate of the previous file, causing distorted sound on sample rate changes.
--- sound/usb/pcm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/usb/pcm.c +10 -0
@@ -710,6 +710,16 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) subs->need_setup_ep = false; } +/* Some devices doesn't respond to sample rate changes while the +* interface is active. */ +switch (subs->stream->chip->usb_id) { +case USB_ID (0x0d8c ,0x0304 ):/* C-Media - Schiit USB Interface */ +case USB_ID (0x0d8c ,0x0309 ):/* C-Media CM6631 */ +usb_set_interface (subs->dev, subs->cur_audiofmt->iface, + subs->cur_audiofmt->altset_idx); +break ; + } +/* some unit conversions in runtime */ subs->data_endpoint->maxframesize =bytes_to_frames (runtime, subs->data_endpoint->maxpacksize);
Signature · 1 line
1.7.10.4
Quoted 9 lines · Torstein Hegge
The C-Media CM6631 USB-to-S/PDIF receiver doesn't respond to changes in sampling frequency while the interface is active.
Reset the interface after setting the sampling frequency, to ensure that the sample rate set by
snd_usb_init_sample_rate()is used. Otherwise, the device will try to use the sample rate of the previous file, causing distorted sound on sample rate changes.Signed-off-by Torstein Hegge <[email protected]>
Thanks!
Daniel
Quoted 26 lines
--- sound/usb/pcm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)sound/usb/pcm.c +10
-0@@ -710,6 +710,16 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) subs->need_setup_ep = false; } +/* Some devices doesn't respond to sample rate changes while the +* interface is active. */ +switch (subs->stream->chip->usb_id) { +case USB_ID (0x0d8c ,0x0304 ):/* C-Media - Schiit USB Interface */ +case USB_ID (0x0d8c ,0x0309 ):/* C-Media CM6631 */ +usb_set_interface (subs->dev, subs->cur_audiofmt->iface, + subs->cur_audiofmt->altset_idx); +break ; + } +/* some unit conversions in runtime */ subs->data_endpoint->maxframesize =bytes_to_frames (runtime, subs->data_endpoint->maxpacksize);
Quoted 4 lines · Daniel Mack
Quoted 3 lines · Torstein Hegge
The C-Media CM6631 USB-to-S/PDIF receiver doesn't respond to changes in sampling frequency while the interface is active.
Quoted 8 lines
Quoted 6 lines
Reset the interface after setting the sampling frequency, to ensure that the sample rate set by
snd_usb_init_sample_rate()is used. Otherwise, the device will try to use the sample rate of the previous file, causing distorted sound on sample rate changes.Signed-off-by Torstein Hegge <[email protected]>Acked-by Daniel Mack <[email protected]>
While this does fix the sample rate change problem, it introduces a new problem. With at least one media player application (xbmc) this patch causes the usb sound card to not output sound when starting a video file. Skipping forward or backward in the video stream restores audio output.
I haven't yet been able to look into why this happens, or why xbmc behaves different from mplayer and vlc.
Torstein
Quoted 26 lines
Quoted 26 lines
--- sound/usb/pcm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)sound/usb/pcm.c +10
-0@@ -710,6 +710,16 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) subs->need_setup_ep = false; } +/* Some devices doesn't respond to sample rate changes while the +* interface is active. */ +switch (subs->stream->chip->usb_id) { +case USB_ID (0x0d8c ,0x0304 ):/* C-Media - Schiit USB Interface */ +case USB_ID (0x0d8c ,0x0309 ):/* C-Media CM6631 */ +usb_set_interface (subs->dev, subs->cur_audiofmt->iface, + subs->cur_audiofmt->altset_idx); +break ; + } +/* some unit conversions in runtime */ subs->data_endpoint->maxframesize =bytes_to_frames (runtime, subs->data_endpoint->maxpacksize);
At Sun, 3 Mar 2013 20:29:22 +0100,
Quoted 15 lines · Torstein Hegge
Quoted 4 lines · Daniel Mack
Quoted 3 lines · Torstein Hegge
The C-Media CM6631 USB-to-S/PDIF receiver doesn't respond to changes in sampling frequency while the interface is active.
Quoted 8 lines
Quoted 6 lines
Reset the interface after setting the sampling frequency, to ensure that the sample rate set by
snd_usb_init_sample_rate()is used. Otherwise, the device will try to use the sample rate of the previous file, causing distorted sound on sample rate changes.Signed-off-by Torstein Hegge <[email protected]>Acked-by Daniel Mack <[email protected]>
Quoted 8 lines
While this does fix the sample rate change problem, it introduces a new problem. With at least one media player application (xbmc) this patch causes the usb sound card to not output sound when starting a video file. Skipping forward or backward in the video stream restores audio output.
I haven't yet been able to look into why this happens, or why xbmc behaves different from mplayer and vlc.
If the reset of interface is needed only when *changing* SRC, we can check the current rate against the previous rate and skip the reset?
The difference of xbmc and mplayer/vlc may come from the different initialization procedure. Apps can call hw_params or prepare multiple times, for example, before actually starting the stream.
Takashi
Quoted 34 lines
Torstein
Quoted 12 lines
Quoted 12 lines
--- sound/usb/pcm.c | 10 ++++++++++ 1 file changed, 10 insertions(+)sound/usb/pcm.c +0
-0@@ -710,6 +710,16 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) subs->need_setup_ep = false; }Quoted 14 lines
Quoted 4 lines
sound/usb/pcm.c +3
-0+/* Some devices doesn't respond to sample rate changes while the +* interface is active. */ +switch (subs->stream->chip->usb_id) {sound/usb/pcm.c static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) · line 725
Quoted 10 lines
sound/usb/pcm.c +7
-0+case USB_ID (0x0d8c ,0x0304 ):/* C-Media - Schiit USB Interface */ +case USB_ID (0x0d8c ,0x0309 ):/* C-Media CM6631 */ +usb_set_interface (subs->dev, subs->cur_audiofmt->iface, + subs->cur_audiofmt->altset_idx); +break ; + } +/* some unit conversions in runtime */ subs->data_endpoint->maxframesize =bytes_to_frames (runtime, subs->data_endpoint->maxpacksize);_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 8 lines · Takashi Iwai
Quoted 7 lines · Torstein Hegge
Quoted 6 lines · Daniel Mack
sound/usb/pcm.c static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) · line 717
Quoted 5 lines · Torstein Hegge
The C-Media CM6631 USB-to-S/PDIF receiver doesn't respond to changes in sampling frequency while the interface is active.
sound/usb/pcm.c +2
-0+case USB_ID (0x0d8c ,0x0304 ):/* C-Media - Schiit USB Interface */ +case USB_ID (0x0d8c ,0x0309 ):/* C-Media CM6631 */
There are other CM6631-based devices.
Quoted 2 lines
If the reset of interface is needed only when *changing* SRC, we can check the current rate against the previous rate and skip the reset?
Or, if we want to be more similar to what many Windows drivers do, reset the interface to altsetting zero before setting it again.
Regards,
Clemens
Quoted 11 lines · Clemens Ladisch
Quoted 8 lines · Takashi Iwai
Quoted 7 lines · Torstein Hegge
Quoted 6 lines · Daniel Mack
sound/usb/pcm.c static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) · line 717
Quoted 5 lines · Torstein Hegge
The C-Media CM6631 USB-to-S/PDIF receiver doesn't respond to changes in sampling frequency while the interface is active.
sound/usb/pcm.c +2
-0+case USB_ID (0x0d8c ,0x0304 ):/* C-Media - Schiit USB Interface */ +case USB_ID (0x0d8c ,0x0309 ):/* C-Media CM6631 */ There are other CM6631-based devices.
Most CM6631 devices with sample rate change problems reported has one of those two ids, as far as I can see. The Asus Xonar Essence One uses the CM6631, but it is listed in the wiki as supported, without any comments about any such issue. I don't know what vendor/product id the Emotiva XDA-2 reports. Did you think of any device in particular?
Quoted 5 lines
Quoted 2 lines
If the reset of interface is needed only when *changing* SRC, we can check the current rate against the previous rate and skip the reset?
Or, if we want to be more similar to what many Windows drivers do, reset the interface to altsetting zero before setting it again.
I see that is done other places in the usb module where the intention is to reset the device. It doesn't seem to make any difference one way or the other in this case. I'll do a reset to altsetting zero first in the next version of this patch.
Thanks.
Torstein
Quoted 11 lines · Torstein Hegge
Quoted 5 lines · Clemens Ladisch
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Torstein Hegge
sound/usb/pcm.c static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream) · line 717
Quoted 2 lines
sound/usb/pcm.c +2
-0+case USB_ID (0x0d8c ,0x0304 ):/* C-Media - Schiit USB Interface */ +case USB_ID (0x0d8c ,0x0309 ):/* C-Media CM6631 */ There are other CM6631-based devices.
Most CM6631 devices with sample rate change problems reported has one of those two ids, as far as I can see. The Asus Xonar Essence One uses the CM6631, but it is listed in the wiki as supported, without any comments about any such issue.
I vaguely remember some such report. Better add this (0b05:17a8).
Quoted 3 lines
I don't know what vendor/product id the Emotiva XDA-2 reports.
From that driver's .inf file:
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0301&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0302&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0304&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0305&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0306&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0309&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0310&MI_00
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0311&MI_00 ;CM6610A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0312&MI_00 ;CM6620A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0313&MI_00 ;CM6630A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0314&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0319&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0315&MI_00 ;CM6632A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_200C&PID_1030&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_054C&PID_06CF&MI_00
(200c = Reloop, 054c = Sony)
Regards,
Clemens
Quoted 8 lines · Clemens Ladisch
Quoted 7 lines · Torstein Hegge
Quoted 5 lines · Clemens Ladisch
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines · Torstein Hegge
Review
Quoted 2 lines
(quoted diff) +2
-0+ case USB_ID(0x0d8c, 0x0304): /* C-Media - Schiit USB Interface */ + case USB_ID(0x0d8c, 0x0309): /* C-Media CM6631 */There are other CM6631-based devices.
Quoted 6 lines
Quoted 4 lines
Most CM6631 devices with sample rate change problems reported has one of those two ids, as far as I can see. The Asus Xonar Essence One uses the CM6631, but it is listed in the wiki as supported, without any comments about any such issue.
I vaguely remember some such report. Better add this (0b05:17a8).
I got an email from a Xonar user experiencing the problem. I'll add it.
Quoted 20 lines
Quoted 1 line
I don't know what vendor/product id the Emotiva XDA-2 reports.
From that driver's .inf file:
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0301&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0302&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0304&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0305&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0306&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0309&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0310&MI_00
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0311&MI_00 ;CM6610A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0312&MI_00 ;CM6620A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0313&MI_00 ;CM6630A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0314&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0319&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0315&MI_00 ;CM6632A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_200C&PID_1030&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_054C&PID_06CF&MI_00
Quoted 1 line
(200c = Reloop, 054c = Sony)
I'm not quite sure how to interpret that. I guess most of those are similar devices that doesn't necessarily need this workaround?
Torstein
Quoted 19 lines · Torstein Hegge
Quoted 17 lines · Clemens Ladisch
From that driver's .inf file:
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0301&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0302&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0304&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0305&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0306&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0309&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0310&MI_00
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0311&MI_00 ;CM6610A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0312&MI_00 ;CM6620A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0313&MI_00 ;CM6630A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0314&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0319&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0315&MI_00 ;CM6632A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_200C&PID_1030&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_054C&PID_06CF&MI_00
Quoted 2 lines
I'm not quite sure how to interpret that. I guess most of those are similar devices that doesn't necessarily need this workaround?
Those are all the IDs that the C-Media driver attaches to. The hardware is always the same; I would be surprised if the firmware did not have the same bug.
Regards,
Clemens
Quoted 20 lines · Clemens Ladisch
Quoted 19 lines · Torstein Hegge
Quoted 17 lines · Clemens Ladisch
From that driver's .inf file:
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0301&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0302&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0304&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0305&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0306&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0309&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0310&MI_00
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0311&MI_00 ;CM6610A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0312&MI_00 ;CM6620A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0313&MI_00 ;CM6630A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0314&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0319&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0315&MI_00 ;CM6632A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_200C&PID_1030&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_054C&PID_06CF&MI_00
Quoted 6 lines
Quoted 2 lines
I'm not quite sure how to interpret that. I guess most of those are similar devices that doesn't necessarily need this workaround?
Those are all the IDs that the C-Media driver attaches to. The hardware is always the same; I would be surprised if the firmware did not have the same bug.
The ids listed covers CM6610, CM6620 and CM6631, which are distinct pieces of hardware, or at least they are sold as if they were. It might be a fair assumption that all current C-Media UAC V2.0 devices have this issue. However, I'm not able to test with anything other than CM6631.
The complete list then looks like:
switch (chip->usb_id) {
/* C-Media CM6610/CM6620/CM6631 */
case USB_ID(0x054c, 0x06cf): /* Sony */
case USB_ID(0x0b05, 0x17a8): /* Asus Xonar Essence One */ case USB_ID(0x0d8c, 0x0301):
case USB_ID(0x0d8c, 0x0302):
case USB_ID(0x0d8c, 0x0304): /* CM6631 (Schiit) */ case USB_ID(0x0d8c, 0x0305):
case USB_ID(0x0d8c, 0x0306):
case USB_ID(0x0d8c, 0x0309): /* CM6631 */
case USB_ID(0x0d8c, 0x0310):
case USB_ID(0x0d8c, 0x0311): /* CM6610A */
case USB_ID(0x0d8c, 0x0312): /* CM6620A */
case USB_ID(0x0d8c, 0x0313): /* CM6630A */
case USB_ID(0x0d8c, 0x0314): /* CM6631A */
case USB_ID(0x0d8c, 0x0315): /* CM6632A */
case USB_ID(0x0d8c, 0x0319): /* CM6631A */
case USB_ID(0x200c, 0x1030): /* Reloop */
[...] }
Torstein
Quoted 24 lines · Torstein Hegge
Quoted 23 lines · Clemens Ladisch
Quoted 21 lines · Torstein Hegge
Quoted 17 lines · Clemens Ladisch
From that driver's .inf file:
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0301&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0302&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0304&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0305&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0306&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0309&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0310&MI_00
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0311&MI_00 ;CM6610A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0312&MI_00 ;CM6620A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0313&MI_00 ;CM6630A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0314&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0319&MI_00 ;CM6631A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_0D8C&PID_0315&MI_00 ;CM6632A
%CMUACWO.DeviceDesc%=CMUACWO,USB\VID_200C&PID_1030&MI_00 %CMUACWO.DeviceDesc%=CMUACWO,USB\VID_054C&PID_06CF&MI_00I'm not quite sure how to interpret that. I guess most of those are similar devices that doesn't necessarily need this workaround?
Quoted 6 lines
Quoted 3 lines
Those are all the IDs that the C-Media driver attaches to. The hardware is always the same; I would be surprised if the firmware did not have the same bug.
The ids listed covers CM6610, CM6620 and CM6631, which are distinct pieces of hardware, or at least they are sold as if they were.
All the same chip with different labels. I don't know if C-Media even bothers to fuse off the unused features in the lower models.
Quoted 2 lines
It might be a fair assumption that all current C-Media UAC V2.0 devices have this issue.
Indeed. In any case, re-setting the interface should not hurt *any* compliant device.
Regards,
Clemens
Quoted 8 lines · Takashi Iwai
At Sun, 3 Mar 2013 20:29:22 +0100,
Quoted 6 lines · Torstein Hegge
While this does fix the sample rate change problem, it introduces a new problem. With at least one media player application (xbmc) this patch causes the usb sound card to not output sound when starting a video file. Skipping forward or backward in the video stream restores audio output.
Quoted 5 lines
Quoted 2 lines
I haven't yet been able to look into why this happens, or why xbmc behaves different from mplayer and vlc.
If the reset of interface is needed only when *changing* SRC, we can check the current rate against the previous rate and skip the reset?
That's right. I tried that, and it appears to have solved the issue with xbmc. I'll clean up that code and send an updated patch.
Thanks.
Torstein