snd-via82xx: Support all sample rate conversion capabilities of DXS channels
PATCH 1/1 snd-via82xx: Support all sample rate conversion capabilities of DXS channels
Hello!
The current snd-via82xx driver does not use all capabilities of the DXS channels present in VIA VT8233/5/7 chips. In particular:
- The driver only accepts sample rates which are supported by the AC'97 codec; however, the controller is able to perform sample rate conversion itself, therefore the codec limits do not apply (and even non-standard rates can be used).
- The driver forces sample rates for all 4 DXS subdevices to be the same; however, the controller has separate sample rate converters for each channel.
This patch adds support for these capabilities of the VT823x controller to the snd-via82xx driver. I have tested it with the ASUS A8V Deluxe board (VT8237 southbridge, Realtek ALC850 codec), with simultaneous output with different sample rates (48000, 44100, 8000, and some non-standard values like 44444, 12345, etc...). The SPDIF output also seems to work (tested with the Sony MZ-N1 portable minidisc recorder).
To avoid breaking support of some other hardware which may not like this mode, the full DXS support is enabled only for known devices (the patch adds an entry for ASUS A8V Deluxe), or when the dxs_support=5 option is used.
When using dxs_support=5, the AC'97 sample rate is locked at 48000 Hz, and the controller performs sample rate conversion for each DXS channel. Therefore output with any sample rate between 8000 and 48000 Hz is possible even if the codec supports only 48000 Hz (like ALC850, which does not support VRA). SPDIF rate is also locked to 48000 Hz.
The patch was made for ALSA CVS version from yesterday.
Best regards,
Sergey Vlasov
=======================================================================
Add support for full sample rate conversion capabilities of DXS channels present in VIA VT8233/5/7 controllers:
- any sample rate in the 8000 ... 48000 Hz range is supported even if the AC'97 codec supports only 48000 Hz output;
- different DXS channels can use different sample rates at the same time (the controller performs required sample rate conversion and mixing in hardware).
alsa-kernel/pci/via82xx.c renamed from alsa-kernel/pci/via82xx.c.dxs-src +17 -3
@@ -101,7 +101,7 @@ MODULE_PARM_DESC(ac97_clock, "AC'97 codemodule_param_array (ac97_quirk, charp,NULL ,0444 );MODULE_PARM_DESC (ac97_quirk,"AC'97 workaround for strange hardware." );module_param_array (dxs_support, int,NULL ,0444 ); -MODULE_PARM_DESC (dxs_support,"Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA)" ); +MODULE_PARM_DESC (dxs_support,"Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)" );/* pci ids */
@@ -302,6 +302,7 @@ DEFINE_VIA_REGSET(CAPTURE_8233, 0x60);#define VIA_DXS_DISABLE 2#define VIA_DXS_48K 3#define VIA_DXS_NO_VRA 4 +#define VIA_DXS_SRC 5/*
@@ -380,6 +381,7 @@ struct _snd_via82xx {struct via_rate_lock rates[2 ];/* playback and capture */ unsigned int dxs_fixed: 1; /* DXS channel accepts only 48kHz */ unsigned int no_vra: 1; /* no need to set VRA on DXS channels */ + unsigned int dxs_src: 1; /* use full SRC capabilities of DXS */ unsigned int spdif_on: 1; /* only spdif rates work to external DACs */snd_pcm_t *pcms[2 ];
@@ -924,15 +926,16 @@ static int snd_via8233_playback_prepare(via82xx_t *chip =snd_pcm_substream_chip (substream);viadev_t *viadev = (viadev_t *)substream->runtime->private_data;snd_pcm_runtime_t *runtime = substream->runtime; +int ac97_rate = chip->dxs_src ?48000 : runtime->rate;int rate_changed;u32 rbits; -if ((rate_changed =via_lock_rate (&chip->rates[0 ], runtime->rate)) <0 ) +if ((rate_changed =via_lock_rate (&chip->rates[0 ], ac97_rate)) <0 )return rate_changed;if (rate_changed) {snd_ac97_set_rate (chip->ac97,AC97_PCM_FRONT_DAC_RATE , chip->no_vra ?48000 : runtime->rate); -snd_ac97_set_rate (chip->ac97,AC97_SPDIF , runtime->rate); +snd_ac97_set_rate (chip->ac97,AC97_SPDIF , ac97_rate); }if (runtime->rate ==48000 ) rbits =0xfffff ;
@@ -1074,6 +1077,12 @@ static int snd_via82xx_pcm_open(via82xx_/* fixed DXS playback rate */ runtime->hw.rates =SNDRV_PCM_RATE_48000 ; runtime->hw.rate_min = runtime->hw.rate_max =48000 ; + }else if (chip->dxs_src && viadev->reg_offset <0x40 ) { +/* use full SRC capabilities of DXS */ + runtime->hw.rates = (SNDRV_PCM_RATE_CONTINUOUS | +SNDRV_PCM_RATE_8000_48000 ); + runtime->hw.rate_min =8000 ; + runtime->hw.rate_max =48000 ; }else if (! ratep->rate) {int idx = viadev->direction ?AC97_RATES_ADC :AC97_RATES_FRONT_DAC ; runtime->hw.rates = chip->ac97->rates[idx];
@@ -2149,6 +2158,7 @@ static int __devinit check_dxs_list(stru { .vendor = 0x1043, .device = 0x8095, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8X (FIXME: possibly VIA_DXS_ENABLE?)*/ { .vendor = 0x1043, .device = 0x80a1, .action = VIA_DXS_NO_VRA }, /* ASUS A7V8-X */ { .vendor = 0x1043, .device = 0x80b0, .action = VIA_DXS_NO_VRA }, /* ASUS A7V600 & K8V*/ + { .vendor = 0x1043, .device = 0x812a, .action = VIA_DXS_SRC }, /* ASUS A8V Deluxe */ { .vendor = 0x1071, .device = 0x8375, .action = VIA_DXS_NO_VRA }, /* Vobis/Yakumo/Mitac notebook */ { .vendor = 0x10cf, .device = 0x118e, .action = VIA_DXS_ENABLE }, /* FSC laptop */ { .vendor = 0x1106, .device = 0x4161, .action = VIA_DXS_NO_VRA }, /* ASRock K7VT2 */
@@ -2288,6 +2298,10 @@ static int __devinit snd_via82xx_probe(s chip->dxs_fixed =1 ; else if (dxs_support[dev] == VIA_DXS_NO_VRA) chip->no_vra = 1; + else if (dxs_support[dev] == VIA_DXS_SRC) { + chip->no_vra =1 ; + chip->dxs_src =1 ; + } }if ((err =snd_via8233_init_misc (chip, dev)) <0 ) goto __error;
alsa-kernel/Documentation/ALSA-Configuration.txt renamed from alsa-kernel/Documentation/ALSA-Configuration.txt.dxs-src +13 -8
@@ -1211,16 +1211,18 @@ Prior to version 0.9.0rc4 options had a ------------------ Module for AC'97 motherboards based on VIA 82C686A/686B, 8233, - 8233A, 8233C, 8235 (south) bridge. + 8233A, 8233C, 8235, 8237 (south) bridge. mpu_port - 0x300,0x310,0x320,0x330, otherwise obtain BIOS setup [VIA686A/686B only] joystick - Enable joystick (default off) [VIA686A/686B only] ac97_clock - AC'97 codec clock base (default 48000Hz) dxs_support - support DXS channels, - 0 = auto (defalut), 1 = enable, 2 = disable, - 3 = 48k only, 4 = no VRA - [VIA8233/C,8235 only] + 0 = auto (default), 1 = enable, 2 = disable, + 3 = 48k only, 4 = no VRA, 5 = enable any sample + rate and different sample rates on different + channels + [VIA8233/C, 8235, 8237 only] ac97_quirk - AC'97 workaround for strange hardware See the description of intel8x0 module for details.
@@ -1232,18 +1234,21 @@ Prior to version 0.9.0rc4 options had a default value 1.4. Then the interrupt number will be assigned under 15. You might also upgrade your BIOS. - Note: VIA8233/5 (not VIA8233A) can support DXS (direct sound) + Note: VIA8233/5/7 (not VIA8233A) can support DXS (direct sound) channels as the first PCM. On these channels, up to 4 - streams can be played at the same time. + streams can be played at the same time, and the controller + can perform sample rate conversion with separate rates for + each channel. As default (dxs_support = 0), 48k fixed rate is chosen except for the known devices since the output is often noisy except for 48k on some mother boards due to the bug of BIOS. - Please try once dxs_support=1 and if it works on other + Please try once dxs_support=5 and if it works on other sample rates (e.g. 44.1kHz of mp3 playback), please let us know the PCI subsystem vendor/device id's (output of "lspci -nv"). - If it doesn't work, try dxs_support=4. If it still doesn't + If dxs_support=5 does not work, try dxs_support=1; if it + doesn't work too, try dxs_support=4. If it still doesn't work and the default setting is ok, dxs_support=3 is the right choice. If the default setting doesn't work at all, try dxs_support=2 to disable the DXS channels.
At Sun, 10 Apr 2005 19:53:20 +0400,
Quoted 45 lines · Sergey Vlasov
Hello!
The current snd-via82xx driver does not use all capabilities of the DXS channels present in VIA VT8233/5/7 chips. In particular:
- The driver only accepts sample rates which are supported by the AC'97 codec; however, the controller is able to perform sample rate conversion itself, therefore the codec limits do not apply (and even non-standard rates can be used).
- The driver forces sample rates for all 4 DXS subdevices to be the same; however, the controller has separate sample rate converters for each channel.
This patch adds support for these capabilities of the VT823x controller to the snd-via82xx driver. I have tested it with the ASUS A8V Deluxe board (VT8237 southbridge, Realtek ALC850 codec), with simultaneous output with different sample rates (48000, 44100, 8000, and some non-standard values like 44444, 12345, etc...). The SPDIF output also seems to work (tested with the Sony MZ-N1 portable minidisc recorder).
To avoid breaking support of some other hardware which may not like this mode, the full DXS support is enabled only for known devices (the patch adds an entry for ASUS A8V Deluxe), or when the dxs_support=5 option is used.
When using dxs_support=5, the AC'97 sample rate is locked at 48000 Hz, and the controller performs sample rate conversion for each DXS channel. Therefore output with any sample rate between 8000 and 48000 Hz is possible even if the codec supports only 48000 Hz (like ALC850, which does not support VRA). SPDIF rate is also locked to 48000 Hz.
The patch was made for ALSA CVS version from yesterday.
Best regards,
Sergey Vlasov=======================================================================
Add support for full sample rate conversion capabilities of DXS channels present in VIA VT8233/5/7 controllers:
Quoted 8 lines
- any sample rate in the 8000 ... 48000 Hz range is supported even if the AC'97 codec supports only 48000 Hz output;
- different DXS channels can use different sample rates at the same time (the controller performs required sample rate conversion and mixing in hardware).
Signed-off-by Sergey Vlasov <[email protected]>
Thanks. I applied it to CVS.
If I understand correctly, this feature should be available on all machines with dxs_support=4, but you added a new dxs_support entry just to be sure not to break, right?
BTW, the SPDIF rate should be also 48k in dxs_support=4, too. I'll fix this now...
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Quoted 12 lines · Takashi Iwai
At Sun, 10 Apr 2005 19:53:20 +0400,
Quoted 9 lines · Sergey Vlasov
Add support for full sample rate conversion capabilities of DXS channels present in VIA VT8233/5/7 controllers:
- any sample rate in the 8000 ... 48000 Hz range is supported even if the AC'97 codec supports only 48000 Hz output;
- different DXS channels can use different sample rates at the same time (the controller performs required sample rate conversion and mixing in hardware).
Quoted 5 lines
Thanks. I applied it to CVS.
If I understand correctly, this feature should be available on all machines with dxs_support=4, but you added a new
dxs_supportentry just to be sure not to break, right?
Yes, it should work, but this driver was broken too many times in the past (and some Linux distributions still select via82cxxx_audio instead of snd-via82xx by default because of this). On the other hand, this means that many existing entries with VIA_DXS_NO_VRA will just stay that way, because the driver will not give any messages to try dxs_support=5.
In fact, I wonder how dxs_support=1 could work at all, if the controller resamples everything to 48000, but the codec is configured to use some other rate. Some hardware must be broken to make this work :)
At Mon, 11 Apr 2005 18:40:09 +0400,
Quoted 27 lines · Sergey Vlasov
[1 <text/plain; us-ascii (quoted-printable)>]
Quoted 12 lines · Takashi Iwai
At Sun, 10 Apr 2005 19:53:20 +0400,
Quoted 9 lines · Sergey Vlasov
Add support for full sample rate conversion capabilities of DXS channels present in VIA VT8233/5/7 controllers:
- any sample rate in the 8000 ... 48000 Hz range is supported even if the AC'97 codec supports only 48000 Hz output;
- different DXS channels can use different sample rates at the same time (the controller performs required sample rate conversion and mixing in hardware).
Quoted 5 lines
Thanks. I applied it to CVS.
If I understand correctly, this feature should be available on all machines with dxs_support=4, but you added a new
dxs_supportentry just to be sure not to break, right?Yes, it should work, but this driver was broken too many times in the past (and some Linux distributions still select
via82cxxx_audioinstead of snd-via82xx by default because of this). On the other hand, this means that many existing entries withVIA_DXS_NO_VRAwill just stay that way, because the driver will not give any messages to try dxs_support=5.
Quoted 3 lines
In fact, I wonder how dxs_support=1 could work at all, if the controller resamples everything to 48000, but the codec is configured to use some other rate. Some hardware must be broken to make this work :)
Yes, it's a really wonder :)
Sometimes we had to use dx_support=1 indeed...
Takashi
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click