Phase Reversal on Santa Cruz (cs46xx)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · you
I am not currently a subscriber to this list, so pease CC me on any responses.
OK, I decided to subscribe, so I ignore this.
Quoted 10 lines
Frank, Benny, the guess of a phase reversal as responsible for the 'lack of bass' on this card is dead-on - a little tinkering with artsbuilder (had to remember how to do it) to place an inverter in one channel of the output path brings sound back to perfection. Great guess!
I can pretty much leave the sub (which has one cone and mixes the channels first) silent against a full-volume sine wave, or invert it and have it perfect. I can definitely hear sine waves at higher frequencies attenuated to some extent if I move the speakers directly adjacent to one another. I'd say that confirms it pretty well.
I have also got an aRts stereo effect to fix it for noatun now, so I can verify it fixing the sound for general music as well. Yippie :-)
Quoted 2 lines
So... anything that can be done to fix this (I assume so, since it's a new problem since older alsa), or do I have to cut my speaker wires apart? :-P
Still hopfully alsa gets fixed and I can throw away the effect plugin :-)
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
Quoted 6 lines
Quoted 6 lines
So... anything that can be done to fix this (I assume so, since it's a new problem since older alsa), or do I have to cut my speaker wires apart? :-P
I'm still a newbie to the audio world, but just wondering, why design a audio equipment that behaves like this ??
(When you run out of ideas howto fix something let's try to move it into a HW bug instead -;) )
Quoted 5 lines
Still hopfully alsa gets fixed and I can throw away the effect plugin :-)
One alternative solution would be program the DSP to do the job instead and you will save CPU time. (Yet another thing that I dont known howto do -:( )
/Benny
PS. being out for traveling some days (wont respond any mail for a while ...)
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
Quoted 9 lines · Benny Sjostrand
Quoted 3 lines
Quoted 3 lines
So... anything that can be done to fix this (I assume so, since it's a new problem since older alsa), or do I have to cut my speaker wires apart? :-P
I'm still a newbie to the audio world, but just wondering, why design a audio equipment
that behaves like this ??
(When you run out of ideas howto fix something let's try to move it into a HW bug instead -;) )
well, the basic premise is simple... the speaker wires have a positive and negative wire, current flows through the coil, and the cone moves one way or the other. If you swap the wires, the cone moves the other way. Inaudible, except that if the two speakers aren't moving the same way, they waves tend to cancel each other out. It affects bass more than treble because the waves are longer and slower, so a) they correleation between the stereo channels is stronger and b) inaccuracies in soundcard timing, etc have less impact. The fact that sound is sensitive to polarity is just basic physics :-)
Now, why in the world the santa cruz would be wired in such a way that software which is fine on other cards would get one channel backwards on it is an excellent question. Espescially when there is older software that worked on all (though not so well, I definitely like having multiple apps accessing it at once).
Quoted 5 lines
Quoted 1 line
Still hopfully alsa gets fixed and I can throw away the effect plugin :-)
One alternative solution would be program the DSP to do the job instead and you will
save CPU time. (Yet another thing that I dont known howto do -:( )
well, how did it work before (0.9.0rc1 worked for sure, I guess I should try to identify the specific version that developed this problem)? Were we using the DSP to invert it previosly, did we lose some Santa Cruz specific bittwiddling (the 'fix' consists of just negating all the levels for one stereo channel). Any guesses?
Quoted 4 lines
/Benny
PS. being out for traveling some days (wont respond any mail for a while ...)
Just as another question, do anyone know if it's possible to use the internal SPDIF connector to feed CD audio into the card instead of the analog input? I can't find anything in the mixer that seems to recieve that input.
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
Quoted 5 lines · Kevin Puetz
Now, why in the world the santa cruz would be wired in such a way that software which is fine on other cards would get one channel backwards on it is an excellent question. Espescially when there is older software that worked on all (though not so well, I definitely like having multiple apps accessing it at once).
It's not just the Santa Cruz, though---my IBM T22 laptop has the exact same problem.
Mike.
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
Quoted 9 lines · Michael Alan Dorman
Quoted 5 lines · Kevin Puetz
Now, why in the world the santa cruz would be wired in such a way that software which is fine on other cards would get one channel backwards on it is an excellent question. Espescially when there is older software that worked on all (though not so well, I definitely like having multiple apps accessing it at once).
It's not just the Santa Cruz, though---my IBM T22 laptop has the exact same problem.
bizzarre...
okay, well for any aRts/noatun users who'd like to a) test their card or b) get a temporary workaround, I'll upload my cheesy effect fikter, which will either make your sound much better or much worse :-).
http://ophelia.student.iastate.edu/~puetzk/arts_phaseinvert-0.5.tgz
standard autoconf/automake setup for kde3, no docs :-) After installing it into your KDE prefix noatun should show Synth_STEREO_PHASEINVERSION as a choice in it's effects config dialog.
Quoted 11 lines
Mike.
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
Alsa-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Weijia Yang
Quoted 10 lines
okay, well for any aRts/noatun users who'd like to a) test their card or
b) get a temporary workaround, I'll upload my cheesy effect fikter, which will either make your sound much better or much worse :-).http://ophelia.student.iastate.edu/~puetzk/arts_phaseinvert-0.5.tgz
standard autoconf/automake setup for kde3, no docs :-) After installing it into your KDE prefix noatun should show
Synth_STEREO_PHASEINVERSIONas a choice in it's effects config dialog.
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Mike.
I am not quite sure how to go about compiling this effects plugin. Could you give me a short rundown? Thanks
Weijia Yang
Alright, standard kde autoconf directions as follows :-P
you will need a recent version of autotools (automake, autoconf, autoheader, etc), arts and kdelibs development headers from kde 3 (or 3.1) (ie, you need the -dev pacakges). That should be all... then
make -f Makefile.cvs
./configure --prefix=kde-config --prefix
make
make install
that should be all, it built here... what problem are you having specifically?
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines · you
I get the following error during the 'make' step. I am running kde3.1 rc3 with gcc3.2
err, oops. It only built here because my standard artsmodules.h had stuff in it from when I'd originally just added it to kdemm. My bad.
grab http://ophelia.student.iastate.edu/~puetzk/arts_phaseinvert-0.6.tgz, I fixed it.
-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing your web site with SSL, click here to get a FREE TRIAL of a Thawte Server Certificate: http://www.gothawte.com/rd524.html
Quoted 5 lines
well, the basic premise is simple... the speaker wires have a positive and negative wire, current flows through the coil, and the cone moves one way or the other. If you swap the wires, the cone moves the other way. Inaudible, except that if the two speakers aren't moving the same way, they waves tend to cancel each other out. It affects bass more than treble because the waves are longer and slower, so a) they correleation between the stereo channels is stronger and b) inaccuracies in soundcard timing, etc have less impact. The fact that sound is sensitive to polarity is just basic physics :-)
Thanks, that explication makes sense.
Quoted 3 lines
Now, why in the world the santa cruz would be wired in such a way that software which is fine on other cards would get one channel backwards on it is an excellent question. Espescially when there is older software that worked on all (though not so well, I definitely like having multiple apps accessing it at once).
If it was that simple that Santa Cruz where the only card in the world with this problem, but there's the same problem is reported for other cs46xx based card's too.
Quoted 3 lines
well, how did it work before (0.9.0rc1 worked for sure, I guess I should try to identify the specific version that developed this problem)? Were we using the DSP to invert it previosly, did we lose some Santa Cruz specific bittwiddling (the 'fix' consists of just negating all the levels for one stereo channel). Any guesses?
I would like know why the problem does not apear with rc1, but the problem does not apear forme with any release, so I cant reproduce the problem with my equipment, which dont make things easy ...
The main diference between the old DSP code and the new is that the old DSP is based on a static parameter setup. The new DSP code is a attempt to manage tasks and resources in the DSP dynamically.
I dont find any reason to why the DSP would invert one of the channels, in theory the parameter setup made when playing one PCM channel is the same as it is in the old DSP code static loaded (discarding unknown bugs)
Finally, the "volume" could be possible, speculating: if the output sample is the product of volume * sample, and the volume is negative the sample would be negated. The "volume" in a DSP SCB for each channel is 16 bit value where 0x8000 is the maximum volume and 0xffff is cero, and lower then 0x8000 dont know. This part now actually differs a little bit from the old static DSP setup. Have you tested my latest patch ??
Quoted 3 lines
Just as another question, do anyone know if it's possible to use the internal SPDIF connector to feed CD audio into the card instead of the analog input? I can't find anything in the mixer that seems to recieve that input.
The cs4630 chip got only one SDPIF input interface, you should see it the mixer with the new DSP code. And if that interface is wired to the internal SPDIF conector without any GPIO story it should just work (however the sounds gets distorcionated (out-of-sync) sometimes with the SPDIF input) ...
/Benny
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Quoted 13 lines · Benny Sjostrand
Thanks, that explication makes sense.
If it was that simple that Santa Cruz where the only card in the world with this problem, but there's the same problem is reported for other cs46xx based card's
too.Quoted 5 lines
well, how did it work before (0.9.0rc1 worked for sure, I guess I should try to identify the specific version that developed this problem)? Were we using the DSP to invert it previosly, did we lose some Santa Cruz specific bittwiddling (the 'fix' consists of just negating all the levels for one stereo channel). Any guesses?
Quoted 5 lines
I would like know why the problem does not apear with rc1, but the problem does not
apear forme with any release, so I cant reproduce the problem with my equipment, which
dont make things easy ...
no, that would be annoying indeed :-)
Quoted 10 lines
The main diference between the old DSP code and the new is that the old DSP is based on a static parameter setup. The new DSP code is a attempt to manage
tasks and resources in the DSP dynamically.I dont find any reason to why the DSP would invert one of the channels, in theory
the parameter setup made when playing one PCM channel is the same as it is in the old DSP code static loaded (discarding unknown bugs)
Quoted 8 lines
Finally, the "volume" could be possible, speculating: if the output sample is the product of volume * sample, and the volume is negative the sample would
be negated. The "volume" in a DSP SCB for each channel is 16 bit value where0x8000is the maximum volume and0xffffis cero, and lower then0x8000dont know. This part now actually differs a little bit from the old static DSP setup.
Have you tested my latest patch ??
no, I haven't, since the patch is quite mangled in the www archive and I wasn't subscribed then, I didn't go through th trouble of fixing it up. Is it merged into cvs now, and if not, could you send it my way? I'd be happy to give it a shot.
Quoted 5 lines
Quoted 4 lines
Just as another question, do anyone know if it's possible to use the internal SPDIF connector to feed CD audio into the card instead of the analog input? I can't find anything in the mixer that seems to recieve that input.
Quoted 7 lines
The cs4630 chip got only one SDPIF input interface, you should see it the mixer with
the new DSP code. And if that interface is wired to the internal SPDIF conector without
any GPIO story it should just work (however the sounds gets distorcionated (out-of-sync)
sometimes with the SPDIF input) ...
Hmm, OK. Guess I'll reboot to windows and see if that connection even works there :-P Maybe I just screwed it up.
Quoted 1 line
/Benny
oh, for anybody using this
http://ophelia.student.iastate.edu/~puetzk/arts_phaseinvert-0.7.tgz
fixing yet another silly glitch Weijia found. (This is an aRts effect filter which introduces a phase inversion between the channels on purpose, which either fixes or introduces the problem, depending on whether you had it already).
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Quoted 5 lines
no, I haven't, since the patch is quite mangled in the www archive and I wasn't subscribed then, I didn't go through th trouble of fixing it up. Is it merged into cvs now, and if not, could you send it my way? I'd be happy to give it a shot.
Here is the patch again, it's not in current CVS.
/Benny
cvs/alsa-kernel/include/cs46xx_dsp_spos.h renamed from include/cs46xx_dsp_spos.h +4 -1
@@ -63,7 +63,6 @@#define DSP_SPDIF_STATUS_OUTPUT_ENABLED 1#define DSP_SPDIF_STATUS_PLAYBACK_OPEN 2#define DSP_SPDIF_STATUS_HW_ENABLED 4 -#define DSP_SPDIF_STATUS_AC3_MODE 8struct _dsp_module_desc_t ;
@@ -196,6 +195,10 @@int spdif_status_in;u16 spdif_input_volume_right;u16 spdif_input_volume_left; +/* spdif channel status, +left right and user validity bits */ +int spdif_csuv_default; +int spdif_csuv_stream;/* SPDIF input sample rate converter */ dsp_scb_descriptor_t * spdif_in_src;
cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.c renamed from pci/cs46xx/cs46xx_lib.c +144 -56
269 lines not on this page · raw message
cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.h renamed from pci/cs46xx/cs46xx_lib.h +2 -2
@@ -217,6 +217,6 @@ int period_size);int cs46xx_dsp_pcm_ostream_set_period (cs46xx_t * chip,int period_size); -int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 right,u16 left); -int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 right,u16 left); +int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 left,u16 right); +int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 left,u16 right);#endif /* __CS46XX_LIB_H__ */
cvs/alsa-kernel/pci/cs46xx/dsp_spos.c renamed from pci/cs46xx/dsp_spos.c +35 -22
104 lines not on this page · raw message
cvs/alsa-kernel/pci/cs46xx/dsp_spos.h renamed from pci/cs46xx/dsp_spos.h +21 -3
@@ -185,6 +185,25 @@#define SP_SPDOUT_CONTROL 0x804D#define SP_SPDOUT_CSUV 0x808E +static inline u8 _wrap_all_bits (u8 val) { +u8 wrapped; + +/* wrap all 8 bits */ + wrapped = + ((val &0x1 ) <<7 ) | + ((val &0x2 ) <<5 ) | + ((val &0x4 ) <<3 ) | + ((val &0x8 ) <<1 ) | + ((val &0x10 ) >>1 ) | + ((val &0x20 ) >>3 ) | + ((val &0x40 ) >>5 ) | + ((val &0x80 ) >>6 ); + +return wrapped; + +} + +static inline void cs46xx_dsp_spos_update_scb (cs46xx_t * chip,dsp_scb_descriptor_t * scb) {/* update nextSCB and subListPtr in SCB */
@@ -195,12 +214,11 @@ }static inline void cs46xx_dsp_scb_set_volume (cs46xx_t * chip,dsp_scb_descriptor_t * scb, -u16 right,u16 left) { -unsigned int val = ((0xffff - right) <<16 | (0xffff - left)); +u16 left,u16 right) { +unsigned int val = ((0xffff - left) <<16 | (0xffff - right));snd_cs46xx_poke (chip, (scb->address + SCBVolumeCtrl) <<2 , val);snd_cs46xx_poke (chip, (scb->address + SCBVolumeCtrl +1 ) <<2 , val); } -#endif /* __DSP_SPOS_H__ */ #endif /* CONFIG_SND_CS46XX_NEW_DSP */
cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c renamed from pci/cs46xx/dsp_spos_scb_lib.c +15 -22
@@ -603,8 +603,8 @@ src_buffer_addr <<0x10 ,0x04000000 , { -0x8000 ,0x8000 , - 0xffff,0xffff +0xffff - ins->dac_volume_right,0xffff - ins->dac_volume_left, + 0xffff - ins->dac_volume_right,0xffff - ins->dac_volume_left } };
@@ -658,7 +658,7 @@/* D */ 0 , {/* E */ 0x8000 ,0x8000 , - /* F */ 0xffff,0xffff + /* F */ 0x8000,0x8000 } };
@@ -830,7 +830,7 @@0 ,0x2aab ,/* Const 1/3 */ { -0 ,/* Define the unused elements */ +0 ,/* Define the unused elements */ 0 ,0 },
@@ -846,7 +846,7 @@rate etc */ 0x18000000 ,/* Phi increment for approx 32k operation */ 0x8000 ,0x8000 ,/* Volume controls are unused at this time */ -0xffff ,0xffff +0x8000 ,0x8000 }; scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&asynch_fg_tx_scb,
@@ -864,7 +864,7 @@ dsp_scb_descriptor_t * parent_scb, int scb_child_type) { - +dsp_spos_instance_t * ins = chip->dsp_spos_instance;dsp_scb_descriptor_t * scb;asynch_fg_rx_scb_t asynch_fg_rx_scb = {
@@ -893,9 +893,9 @@rate etc */ 0x18000000 , -/* Mute stream */ -0x8000 ,0x8000 , -0xffff ,0xffff +/* Set IEC958 input volume */ +0xffff - ins->spdif_input_volume_right,0xffff - ins->spdif_input_volume_left, +0xffff - ins->spdif_input_volume_right,0xffff - ins->spdif_input_volume_left, }; scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&asynch_fg_rx_scb,
@@ -1116,11 +1116,13 @@case DSP_IEC958_CHANNEL : snd_assert (ins->asynch_tx_scb != NULL, return NULL); mixer_scb = ins->asynch_tx_scb; +#if 0 if (ins->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE ) {snd_printdd ("IEC958 opened in AC3 mode\n" );/*src_scb = ins->asynch_tx_scb; ins->asynch_tx_scb->ref_count ++;*/ } +#endif break ;default :snd_assert (0 );
@@ -1198,9 +1200,7 @@return NULL ; } -if (pcm_channel_id !=DSP_IEC958_CHANNEL || - !(ins->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE )) -cs46xx_dsp_set_src_sample_rate (chip,src_scb,sample_rate); +cs46xx_dsp_set_src_sample_rate (chip,src_scb,sample_rate); ins->nsrc_scb ++; }
@@ -1461,17 +1461,11 @@*/ spin_lock_irqsave (&chip->reg_lock, flags); -/* mute SCB */ -/* cs46xx_dsp_scb_set_volume (chip,src,0,0); */ -snd_cs46xx_poke (chip, (src->address + SRCCorPerGof) <<2 , ((correctionPerSec <<16 ) &0xFFFF0000 ) | (correctionPerGOF &0xFFFF ));snd_cs46xx_poke (chip, (src->address + SRCPhiIncr6Int26Frac) <<2 , phiIncr); -/* raise volume */ -/* cs46xx_dsp_scb_set_volume (chip,src,0x7fff,0x7fff); */ -spin_unlock_irqrestore (&chip->reg_lock, flags); }
@@ -1641,9 +1635,8 @@ SCB_ON_PARENT_NEXT_SCB); -if (ins->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE ) -/* set left (13), right validity bit (12) , and non-audio(1) and profsional bit (0) */ -cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV ,0x00000000 | (1 <<13 ) | (1 <<12 ) | (1 <<1 ) |1 ); +/* set spdif channel status value for streaming */ +cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV , ins->spdif_csuv_stream); ins->spdif_status_out |=DSP_SPDIF_STATUS_PLAYBACK_OPEN ;
@@ -1659,7 +1652,7 @@ ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN ;/* restore settings */ -cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV ,0x00000000 | (1 <<13 ) | (1 <<12 )); +cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV , ins->spdif_csuv_default);/* deallocate stuff */ cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb);
Just as a general point to note. We are not putting the audio card into AC3 mode.
We might be doing "passthru mode" or "spdif non-audio", but never just AC3 mode.
I help with the "xine" (a free media player http://xine.sf.net) that can play DVDs.
DVDs have AC3 audio tracks and DTS audio tracks.
xine uses "spdif non-audio" and "passthru mode" when used with alsa.
It can therefore output AC3 and DTS tracks to an external decoder.
Summary: -
AC3 is the wrong term to use. "spdif passthru" is probably a better term to use, as the current "ac3_mode" seems to imply that DTS audio might not work. Cheers
James
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Re: Re: Phase Reversal on Santa Cruz (cs46xx) => XFire too
In reply to Benny SjostrandHi Benny,
I noticed the phase reversal problem with my Terratec XFire, too: I played a mono wav. Then I combined the left and rigth output electrically and the sound was gone, i.e. one channel outputs the sound with a sign change, so that left+right=signal+(-signal)=0. The sound went back when unbalancing the output level. (This would also explain why my impulse response measuring program measures a negative response when connecting line out to line in ;-). I use the left channel of the soundcard for it.) It applied your patch below, but it didn't solve the problem. Is it correct that the SDPIF AC3 mode switch is gone after applying the patch? I patched alsa version 0.9.0rc6.
fe
P.S. just tested my IR measuring program with right channel (and 0.9.0rc6) => positive responseP.S.S. now I really wanted to know which channel has wrong sign with rc6. With 0.9.0rc2 I get positive impulse responses for both left and right channel.
conclusion: the left pcm channel of the alsa 0.9.0rc6 driver for cs46xx has wrong sign. Perhaps this can help a bit location the error.
Quoted 603 lines · Benny Sjostrand
Quoted 4 lines
no, I haven't, since the patch is quite mangled in the www archive and I wasn't subscribed then, I didn't go through th trouble of fixing it up. Is it merged into cvs now, and if not, could you send it my way? I'd be happy to give it a shot.
Here is the patch again, it's not in current CVS.
/Benny
------------------------------------------------------------------------
diff --exclude=CVS -Naur
alsa-kernel/include/cs46xx_dsp_spos.h../cvs/alsa-kernel/include/cs46xx_dsp_spos.hcvs/alsa-kernel/include/cs46xx_dsp_spos.h renamed from include/cs46xx_dsp_spos.h +4
-1@@ -63,7 +63,6 @@#define DSP_SPDIF_STATUS_OUTPUT_ENABLED 1#define DSP_SPDIF_STATUS_PLAYBACK_OPEN 2#define DSP_SPDIF_STATUS_HW_ENABLED 4 -#define DSP_SPDIF_STATUS_AC3_MODE 8struct _dsp_module_desc_t ;@@ -196,6 +195,10 @@int spdif_status_in;u16 spdif_input_volume_right;u16 spdif_input_volume_left; +/* spdif channel status, +left right and user validity bits */ +int spdif_csuv_default; +int spdif_csuv_stream;/* SPDIF input sample rate converter */ dsp_scb_descriptor_t * spdif_in_src;diff --exclude=CVS -Naur
alsa-kernel/pci/cs46xx/cs46xx_lib.c../cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.ccvs/alsa-kernel/pci/cs46xx/cs46xx_lib.c renamed from pci/cs46xx/cs46xx_lib.c +144
-56@@ -946,15 +946,15 @@case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME :#ifdef CONFIG_SND_CS46XX_NEW_DSP +/* magic value to unmute PCM stream playback volume */ +snd_cs46xx_poke (chip, (cpcm->pcm_channel->pcm_reader_scb->address + + SCBVolumeCtrl) <<2 ,0x80007fff ); +if (cpcm->pcm_channel->unlinked)cs46xx_dsp_pcm_link (chip,cpcm->pcm_channel); +if (substream->runtime->periods !=CS46XX_FRAGS )snd_cs46xx_playback_transfer (substream,0 ); - -/* raise playback volume */ -cs46xx_dsp_scb_set_volume (chip,cpcm->pcm_channel->pcm_reader_scb, - chip->dsp_spos_instance->dac_volume_right, - chip->dsp_spos_instance->dac_volume_left);#else if (substream->runtime->periods !=CS46XX_FRAGS )snd_cs46xx_playback_transfer (substream,0 );@@ -968,8 +968,9 @@case SNDRV_PCM_TRIGGER_STOP :case SNDRV_PCM_TRIGGER_SUSPEND :#ifdef CONFIG_SND_CS46XX_NEW_DSP -/* mute channel */ -cs46xx_dsp_scb_set_volume (chip,cpcm->pcm_channel->pcm_reader_scb,0 ,0 ); +/* magic mute channel */ +snd_cs46xx_poke (chip, (cpcm->pcm_channel->pcm_reader_scb->address + + SCBVolumeCtrl) <<2 ,0xffffffff );if (!cpcm->pcm_channel->unlinked)cs46xx_dsp_pcm_unlink (chip,cpcm->pcm_channel);@@ -1063,6 +1064,7 @@ }#endif +static int snd_cs46xx_playback_hw_params (snd_pcm_substream_t * substream,snd_pcm_hw_params_t * hw_params) {@@ -1079,15 +1081,10 @@down (&chip->spos_mutex);snd_assert (cpcm->pcm_channel !=NULL ); - -/* if IEC958 is opened in AC3 mode dont adjust SRCTask is not -used so dont adjust sample rate */ -if (cpcm->pcm_channel->pcm_channel_id !=DSP_IEC958_CHANNEL || - !(chip->dsp_spos_instance->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE )) { -if (_cs46xx_adjust_sample_rate (chip,cpcm,sample_rate)) { -up (&chip->spos_mutex); -return -ENXIO ; - } + +if (_cs46xx_adjust_sample_rate (chip,cpcm,sample_rate)) { +up (&chip->spos_mutex); +return -ENXIO ; }if (cs46xx_dsp_pcm_channel_set_period (chip,cpcm->pcm_channel,period_size *4 )) {@@ -1886,8 +1883,8 @@ {cs46xx_t *chip =snd_kcontrol_chip (kcontrol); - ucontrol->value.integer.value[0 ] = chip->dsp_spos_instance->dac_volume_right; - ucontrol->value.integer.value[1 ] = chip->dsp_spos_instance->dac_volume_left; + ucontrol->value.integer.value[0 ] = chip->dsp_spos_instance->dac_volume_left; + ucontrol->value.integer.value[1 ] = chip->dsp_spos_instance->dac_volume_right;return 0 ; }@@ -2038,34 +2035,6 @@return 0 ; } -static int snd_cs46xx_iec958_ac3_mode_get (snd_kcontrol_t *kcontrol, -snd_ctl_elem_value_t *ucontrol) -{ -cs46xx_t *chip =snd_kcontrol_chip (kcontrol); -dsp_spos_instance_t * ins = chip->dsp_spos_instance; - -if (!ins->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE ) - ucontrol->value.integer.value[0 ] =1 ; -else - ucontrol->value.integer.value[0 ] =0 ; - -return 0 ; -} - -static int snd_cs46xx_iec958_ac3_mode_put (snd_kcontrol_t *kcontrol, -snd_ctl_elem_value_t *ucontrol) -{ -cs46xx_t *chip =snd_kcontrol_chip (kcontrol); -dsp_spos_instance_t * ins = chip->dsp_spos_instance; -int old = ins->spdif_status_out; - -if (ucontrol->value.integer.value[0 ]) - ins->spdif_status_out |=DSP_SPDIF_STATUS_AC3_MODE ; -else - ins->spdif_status_out &= ~DSP_SPDIF_STATUS_AC3_MODE ; - -return (old != ins->spdif_status_out); -}static int snd_cs46xx_pcm_capture_put (snd_kcontrol_t *kcontrol,snd_ctl_elem_value_t *ucontrol)@@ -2127,6 +2096,110 @@return (val1 !=snd_cs46xx_peekBA0 (chip,BA0_EGPIODR )); } + +static int snd_cs46xx_spdif_info (snd_kcontrol_t *kcontrol,snd_ctl_elem_info_t * uinfo) +{ + uinfo->type =SNDRV_CTL_ELEM_TYPE_IEC958 ; + uinfo->count =1 ; +return 0 ; +} + +static int snd_cs46xx_spdif_default_get (snd_kcontrol_t * kcontrol, +snd_ctl_elem_value_t * ucontrol) +{ +cs46xx_t *chip =snd_kcontrol_chip (kcontrol); +dsp_spos_instance_t * ins = chip->dsp_spos_instance; + +down (&chip->spos_mutex); + ucontrol->value.iec958.status[0 ] =_wrap_all_bits ((ins->spdif_csuv_default >>24 ) &0xff ); + ucontrol->value.iec958.status[1 ] =_wrap_all_bits ((ins->spdif_csuv_default >>16 ) &0xff ); + ucontrol->value.iec958.status[2 ] =0 ; + ucontrol->value.iec958.status[3 ] =_wrap_all_bits ((ins->spdif_csuv_default) &0xff ); +up (&chip->spos_mutex); + +return 0 ; +} + +static int snd_cs46xx_spdif_default_put (snd_kcontrol_t * kcontrol, +snd_ctl_elem_value_t * ucontrol) +{ +cs46xx_t * chip =snd_kcontrol_chip (kcontrol); +dsp_spos_instance_t * ins = chip->dsp_spos_instance; +unsigned int val; +int change; + +down (&chip->spos_mutex); + val =_wrap_all_bits (((u32 )ucontrol->value.iec958.status[0 ] <<24 )) | +_wrap_all_bits (((u32 )ucontrol->value.iec958.status[2 ] <<16 )) | +_wrap_all_bits ( (u32 )ucontrol->value.iec958.status[3 ]) | +/* left and right validity bit */ + (1 <<13 ) | (1 <<12 ); + + + change = ins->spdif_csuv_default != val; + ins->spdif_csuv_default = val; + +if ( !(ins->spdif_status_out &DSP_SPDIF_STATUS_PLAYBACK_OPEN ) ) +cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV ,val); + +up (&chip->spos_mutex); + +return change; +} + +static int snd_cs46xx_spdif_mask_get (snd_kcontrol_t * kcontrol, +snd_ctl_elem_value_t * ucontrol) +{ + ucontrol->value.iec958.status[0 ] =0xff ; + ucontrol->value.iec958.status[1 ] =0xff ; + ucontrol->value.iec958.status[2 ] =0x00 ; + ucontrol->value.iec958.status[3 ] =0xff ; +return 0 ; +} + +static int snd_cs46xx_spdif_stream_get (snd_kcontrol_t * kcontrol, +snd_ctl_elem_value_t * ucontrol) +{ +cs46xx_t *chip =snd_kcontrol_chip (kcontrol); +dsp_spos_instance_t * ins = chip->dsp_spos_instance; + +down (&chip->spos_mutex); + ucontrol->value.iec958.status[0 ] =_wrap_all_bits ((ins->spdif_csuv_stream >>24 ) &0xff ); + ucontrol->value.iec958.status[1 ] =_wrap_all_bits ((ins->spdif_csuv_stream >>16 ) &0xff ); + ucontrol->value.iec958.status[2 ] =0 ; + ucontrol->value.iec958.status[3 ] =_wrap_all_bits ((ins->spdif_csuv_stream) &0xff ); +up (&chip->spos_mutex); + +return 0 ; +} + +static int snd_cs46xx_spdif_stream_put (snd_kcontrol_t * kcontrol, +snd_ctl_elem_value_t * ucontrol) +{ +cs46xx_t * chip =snd_kcontrol_chip (kcontrol); +dsp_spos_instance_t * ins = chip->dsp_spos_instance; +unsigned int val; +int change; + +down (&chip->spos_mutex); + val =_wrap_all_bits (((u32 )ucontrol->value.iec958.status[0 ] <<24 )) | +_wrap_all_bits (((u32 )ucontrol->value.iec958.status[1 ] <<16 )) | +_wrap_all_bits ( (u32 )ucontrol->value.iec958.status[3 ]) | +/* left and right validity bit */ + (1 <<13 ) | (1 <<12 ); + + + change = ins->spdif_csuv_stream != val; + ins->spdif_csuv_stream = val; + +if ( ins->spdif_status_out &DSP_SPDIF_STATUS_PLAYBACK_OPEN ) +cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV ,val); + +up (&chip->spos_mutex); + +return change; +} +#endif /* CONFIG_SND_CS46XX_NEW_DSP */ #ifdef CONFIG_SND_CS46XX_DEBUG_GPIO @@ -2238,7 +2311,7 @@ }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "IEC 958 Output Switch", + .name = "IEC958 Output Switch", .info = snd_mixer_boolean_info, .get = snd_cs46xx_iec958_get, .put = snd_cs46xx_iec958_put,@@ -2246,14 +2319,7 @@ }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "IEC 958 AC3 Mode Switch", - .info = snd_mixer_boolean_info, - .get = snd_cs46xx_iec958_ac3_mode_get, - .put = snd_cs46xx_iec958_ac3_mode_put, -}, -{ - .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "IEC 958 Input Switch", + .name = "IEC958 Input Switch", .info = snd_mixer_boolean_info, .get = snd_cs46xx_iec958_get, .put = snd_cs46xx_iec958_put,@@ -2261,12 +2327,34 @@ }, { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, - .name = "IEC 958 Input Volume", + .name = "IEC958 Input Volume", .info = snd_cs46xx_vol_info, .get = snd_cs46xx_vol_iec958_get, .put = snd_cs46xx_vol_iec958_put, .private_value = (ASYNCRX_SCB_ADDR + 0xE) << 2, }, +{ + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), + .info = snd_cs46xx_spdif_info, + .get = snd_cs46xx_spdif_default_get, + .put = snd_cs46xx_spdif_default_put, +}, +{ + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), + .info = snd_cs46xx_spdif_info, + .get = snd_cs46xx_spdif_mask_get, + .access = SNDRV_CTL_ELEM_ACCESS_READ +}, +{ + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM), + .info = snd_cs46xx_spdif_info, + .get = snd_cs46xx_spdif_stream_get, + .put = snd_cs46xx_spdif_stream_put +}, + #endif #ifdef CONFIG_SND_CS46XX_DEBUG_GPIO {diff --exclude=CVS -Naur
alsa-kernel/pci/cs46xx/cs46xx_lib.h../cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.hcvs/alsa-kernel/pci/cs46xx/cs46xx_lib.h renamed from pci/cs46xx/cs46xx_lib.h +2
-2@@ -217,6 +217,6 @@ int period_size);int cs46xx_dsp_pcm_ostream_set_period (cs46xx_t * chip,int period_size); -int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 right,u16 left); -int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 right,u16 left); +int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 left,u16 right); +int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 left,u16 right);#endif /* __CS46XX_LIB_H__ */ diff --exclude=CVS -Naur
alsa-kernel/pci/cs46xx/dsp_spos.c../cvs/alsa-kernel/pci/cs46xx/dsp_spos.ccvs/alsa-kernel/pci/cs46xx/dsp_spos.c renamed from pci/cs46xx/dsp_spos.c +35
-22@@ -31,6 +31,7 @@#include <sound/core.h> #include <sound/control.h> #include <sound/info.h> +#include <sound/asoundef.h> #include <sound/cs46xx.h> #include "cs46xx_lib.h" @@ -262,6 +263,15 @@ ins->spdif_input_volume_right =0x8000 ; ins->spdif_input_volume_left =0x8000 ; +/* set left and right validity bits and +default channel status */ + ins->spdif_csuv_default = + ins->spdif_csuv_stream = +/* byte 0 */ (_wrap_all_bits ( (SNDRV_PCM_DEFAULT_CON_SPDIF &0xff )) <<24 ) | +/* byte 1 */ (_wrap_all_bits ( ((SNDRV_PCM_DEFAULT_CON_SPDIF >>16 ) &0xff )) <<16 ) | +/* byte 3 */ _wrap_all_bits ( (SNDRV_PCM_DEFAULT_CON_SPDIF >>24 ) &0xff ) | +/* left and right validity bits */ (1 <<13 ) | (1 <<12 ); +return ins; }@@ -1549,7 +1559,7 @@cs46xx_poke_via_dsp (chip,SP_SPDOUT_CONTROL ,0x80000000 );/* right and left validate bit */ -cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV ,0x00000000 | (1 <<13 ) | (1 <<12 )); +cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV , ins->spdif_csuv_default);/* monitor state */ ins->spdif_status_out |=DSP_SPDIF_STATUS_HW_ENABLED ;@@ -1587,11 +1597,6 @@cs46xx_poke_via_dsp (chip,SP_SPDIN_FIFOPTR ,0x0 );cs46xx_src_link (chip,ins->spdif_in_src); -/* restore SPDIF input volume */ -cs46xx_dsp_scb_set_volume (chip,ins->spdif_in_src, - ins->spdif_input_volume_right, - ins->spdif_input_volume_left); -spin_unlock_irq (&chip->reg_lock);/* set SPDIF input sample rate and unmute @@ -1725,39 +1730,47 @@return 0 ; } -int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 right,u16 left) +int cs46xx_dsp_set_dac_volume (cs46xx_t * chip,u16 left,u16 right) { -int i;dsp_spos_instance_t * ins = chip->dsp_spos_instance; +dsp_scb_descriptor_t * scb;down (&chip->spos_mutex); + +/* main output */ + scb = ins->master_mix_scb->sub_list_ptr; +while (scb != ins->the_null_scb) { +cs46xx_dsp_scb_set_volume (chip,scb,left,right); + scb = scb->next_scb_ptr; + } - ins->dac_volume_right = right; - ins->dac_volume_left = left; - -for (i =0 ; i <DSP_MAX_PCM_CHANNELS ; ++i) { -if (ins->pcm_channels[i].active && - !ins->pcm_channels[i].unlinked) { -cs46xx_dsp_scb_set_volume (chip,ins->pcm_channels[i].pcm_reader_scb, - right,left); - - } +/* rear output */ + scb = ins->rear_mix_scb->sub_list_ptr; +while (scb != ins->the_null_scb) { +cs46xx_dsp_scb_set_volume (chip,scb,left,right); + scb = scb->next_scb_ptr; } + ins->dac_volume_left = left; + ins->dac_volume_right = right; +up (&chip->spos_mutex);return 0 ; } -int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 right,u16 left) { +int cs46xx_dsp_set_iec958_volume (cs46xx_t * chip,u16 left,u16 right) {dsp_spos_instance_t * ins = chip->dsp_spos_instance;down (&chip->spos_mutex); -cs46xx_dsp_scb_set_volume (chip,ins->spdif_in_src, - right,left); - ins->spdif_input_volume_right = right; +if (ins->asynch_rx_scb !=NULL ) +cs46xx_dsp_scb_set_volume (chip,ins->asynch_rx_scb, + left,right); + ins->spdif_input_volume_left = left; + ins->spdif_input_volume_right = right; +up (&chip->spos_mutex);return 0 ;diff --exclude=CVS -Naur
alsa-kernel/pci/cs46xx/dsp_spos.h../cvs/alsa-kernel/pci/cs46xx/dsp_spos.hcvs/alsa-kernel/pci/cs46xx/dsp_spos.h renamed from pci/cs46xx/dsp_spos.h +21
-3@@ -185,6 +185,25 @@#define SP_SPDOUT_CONTROL 0x804D#define SP_SPDOUT_CSUV 0x808E +static inline u8 _wrap_all_bits (u8 val) { +u8 wrapped; + +/* wrap all 8 bits */ + wrapped = + ((val &0x1 ) <<7 ) | + ((val &0x2 ) <<5 ) | + ((val &0x4 ) <<3 ) | + ((val &0x8 ) <<1 ) | + ((val &0x10 ) >>1 ) | + ((val &0x20 ) >>3 ) | + ((val &0x40 ) >>5 ) | + ((val &0x80 ) >>6 ); + +return wrapped; + +} + +static inline void cs46xx_dsp_spos_update_scb (cs46xx_t * chip,dsp_scb_descriptor_t * scb) {/* update nextSCB and subListPtr in SCB */ @@ -195,12 +214,11 @@ }static inline void cs46xx_dsp_scb_set_volume (cs46xx_t * chip,dsp_scb_descriptor_t * scb, -u16 right,u16 left) { -unsigned int val = ((0xffff - right) <<16 | (0xffff - left)); +u16 left,u16 right) { +unsigned int val = ((0xffff - left) <<16 | (0xffff - right));snd_cs46xx_poke (chip, (scb->address + SCBVolumeCtrl) <<2 , val);snd_cs46xx_poke (chip, (scb->address + SCBVolumeCtrl +1 ) <<2 , val); } -#endif /* __DSP_SPOS_H__ */ #endif /* CONFIG_SND_CS46XX_NEW_DSP */ diff --exclude=CVS -Naur
alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c../cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.ccvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c renamed from pci/cs46xx/dsp_spos_scb_lib.c +14
-21@@ -603,8 +603,8 @@ src_buffer_addr <<0x10 ,0x04000000 , { -0x8000 ,0x8000 , - 0xffff,0xffff +0xffff - ins->dac_volume_right,0xffff - ins->dac_volume_left, + 0xffff - ins->dac_volume_right,0xffff - ins->dac_volume_left } };@@ -658,7 +658,7 @@/* D */ 0 , {/* E */ 0x8000 ,0x8000 , - /* F */ 0xffff,0xffff + /* F */ 0x8000,0x8000 } };@@ -830,7 +830,7 @@0 ,0x2aab ,/* Const 1/3 */ { -0 ,/* Define the unused elements */ +0 ,/* Define the unused elements */ 0 ,0 },@@ -846,7 +846,7 @@rate etc */ 0x18000000 ,/* Phi increment for approx 32k operation */ 0x8000 ,0x8000 ,/* Volume controls are unused at this time */ -0xffff ,0xffff +0x8000 ,0x8000 }; scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&asynch_fg_tx_scb,@@ -864,7 +864,7 @@ dsp_scb_descriptor_t * parent_scb, int scb_child_type) { - +dsp_spos_instance_t * ins = chip->dsp_spos_instance;dsp_scb_descriptor_t * scb;asynch_fg_rx_scb_t asynch_fg_rx_scb = {@@ -893,9 +893,9 @@rate etc */ 0x18000000 , -/* Mute stream */ -0x8000 ,0x8000 , -0xffff ,0xffff +/* Set IEC958 input volume */ +0xffff - ins->spdif_input_volume_right,0xffff - ins->spdif_input_volume_left, +0xffff - ins->spdif_input_volume_right,0xffff - ins->spdif_input_volume_left, }; scb = cs46xx_dsp_create_generic_scb(chip,scb_name,(u32 *)&asynch_fg_rx_scb,@@ -1116,11 +1116,13 @@case DSP_IEC958_CHANNEL : snd_assert (ins->asynch_tx_scb != NULL, return NULL); mixer_scb = ins->asynch_tx_scb; +#if 0 if (ins->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE ) {snd_printdd ("IEC958 opened in AC3 mode\n" );/*src_scb = ins->asynch_tx_scb; ins->asynch_tx_scb->ref_count ++;*/ } +#endif break ;default :snd_assert (0 );@@ -1198,9 +1200,7 @@return NULL ; } -if (pcm_channel_id !=DSP_IEC958_CHANNEL || - !(ins->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE )) -cs46xx_dsp_set_src_sample_rate (chip,src_scb,sample_rate); +cs46xx_dsp_set_src_sample_rate (chip,src_scb,sample_rate); ins->nsrc_scb ++; }@@ -1461,17 +1461,11 @@*/ spin_lock_irqsave (&chip->reg_lock, flags); -/* mute SCB */ -/* cs46xx_dsp_scb_set_volume (chip,src,0,0); */ -snd_cs46xx_poke (chip, (src->address + SRCCorPerGof) <<2 , ((correctionPerSec <<16 ) &0xFFFF0000 ) | (correctionPerGOF &0xFFFF ));snd_cs46xx_poke (chip, (src->address + SRCPhiIncr6Int26Frac) <<2 , phiIncr); -/* raise volume */ -/* cs46xx_dsp_scb_set_volume (chip,src,0x7fff,0x7fff); */ -spin_unlock_irqrestore (&chip->reg_lock, flags); }@@ -1641,9 +1635,8 @@ SCB_ON_PARENT_NEXT_SCB); -if (ins->spdif_status_out &DSP_SPDIF_STATUS_AC3_MODE ) -/* set left (13), right validity bit (12) , and non-audio(1) and profsional bit (0) */ -cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV ,0x00000000 | (1 <<13 ) | (1 <<12 ) | (1 <<1 ) |1 ); +/* set spdif channel status value for streaming */ +cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV , ins->spdif_csuv_stream); ins->spdif_status_out |=DSP_SPDIF_STATUS_PLAYBACK_OPEN ;
cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c line 1658
Quoted 8 lines
cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c renamed from pci/cs46xx/dsp_spos_scb_lib.c +1
-1@@ -1659,7 +1652,7 @@ ins->spdif_status_out &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN ;/* restore settings */ -cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV ,0x00000000 | (1 <<13 ) | (1 <<12 )); +cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV , ins->spdif_csuv_default);/* deallocate stuff */ cs46xx_dsp_remove_scb (chip,ins->asynch_tx_scb);
-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET comprehensive development tool, built to increase your productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
Re: Re: Phase Reversal on Santa Cruz (cs46xx) => XFire too
Quoted 1 line · Friedrich Ewaldt
Hi Benny,
w00t!
it seems that volumes 0-0x7fff ramp up volumes, then 8000-ffff go back down... but with opposite phases. So...
--- alsa-cvs/alsa-driver-0.9.0rc6cvs20021202/alsa-kernel/pci/cs46xx/dsp_spos.h
2002-11-24 19:52:17.000000000 -0600
+++ modules/alsa-driver/alsa-kernel/pci/cs46xx/dsp_spos.h 2002-12-03
17:27:10.000000000 -0600
@@ -215,7 +215,7 @@
static inline void cs46xx_dsp_scb_set_volume (cs46xx_t *
chip,dsp_scb_descriptor_t * scb,
u16 left,u16 right) {
- unsigned int val = ((0xffff - left) << 16 | (0xffff - right));
+ unsigned int val = (left << 16 | (0xffff - right));
snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl) << 2, val); snd_cs46xx_poke(chip, (scb->address + SCBVolumeCtrl + 1) << 2, val);
and it sounds correct (for CD analog passthru and PCM at least). (note - you'll need to open alsamixer and adjust the DAC volume before the 'fix' works, I haven't found where it gets programmed on driver load.
Now, I have no idea if this is correct, if I just broke SPDIF (no reciever), rear speakers (ditto, I don't have any) but it fixes my case anyway, so that's a start. If anyone can test more of these cases, that might be good.
Throwing it out before I head out here for a few hours, in the hope that it will cause some insight :-)
-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET comprehensive development tool, built to increase your productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
Re: Re: Phase Reversal on Santa Cruz (cs46xx) => XFire too
Quoted 6 lines
it seems that volumes 0-0x7fff ramp up volumes, then 8000-ffff go back down... but with opposite phases. So...
Great discovery!, probably the stream can be inverted several times when it processedthrough through the SCB tree. (PCMReader->SrcTaskSCB->MasterMixSCB->CodecOut)
Almost all SCB's got a volume field.
Quoted 4 lines
and it sounds correct (for CD analog passthru and PCM at least).
(note - you'll need to open alsamixer and adjust the DAC volume before the 'fix' works, I haven't found where it gets programmed on driver load.
I guess that the only thing left is to change the initial volume values set when driver is loaded in dsp_spos.c line 260:
/* maximize volume */
ins->dac_volume_right = 0x8000;
- ins->dac_volume_left = 0x8000;
+ ins->dac_volume_left = 0x7fff;
ins->spdif_input_volume_right = 0x8000;- ins->spdif_input_volume_left = 0x8000;
+ ins->spdif_input_volume_left = 0x7fff;
Quoted 4 lines
Now, I have no idea if this is correct, if I just broke SPDIF (no reciever), rear speakers (ditto, I don't have any) but it fixes my case anyway, so that's a start. If anyone can test more of these cases, that might be good.
If it works and solves a problem then it must correct -:)
/Benny
-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET comprehensive development tool, built to increase your productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
Re: Re: Phase Reversal on Santa Cruz (cs46xx) => XFire too
Hi Kevin, hi Benny,
with your changes applied, now both PCM channels have the same phase with my XFire. The stereo image makes much more sense that way :-). Thanks a lot!
What I've noticed: Switching the 'PCM Out' control from 'pre 3D' to 'post 3D' inverts the sign of both l&r channels. (behaviour is independent of '3D depth', '3D center' and '3D switch' controls). But that doesn't cause any problems, at least with stereo output (which is the only mode the XFire works for now). With >2 channel output on other cs46xx cards this could perhaps cause problems if the phase of the rear/LFE/center channels doesn't match the left/right channel phase any more. But I can't check this with my card.
@Benny:
Another problem: SPDIF input doesn't work anymore since I applied the patch attached in your mail on 11/23/02. There is no 'SPDIF ac3 mode' in alsamixer after patching. Is this correct? And I noticed that I can't change the SPDIF input volume for left and right channel independently anymore. If I move the slider for one channel, the other follows more or less. I get a maximum volume difference of 4 (on the range 0..100) between left and right SPDIF input channel. Changing the levels independently and SPDIF input worked before patching. I reinstalled the unpatched rc6 driver but even restarting alsa didn't make SPDIF input working again (I also deleted my /etc/asound.state because the mixer controls have changed). Finally, I found out that I had to switch off my PC for several seconds and restart with the unpatched rc6 driver. The patched driver changes the state of the soundcard in some way that even reinstalling the unpatched one doesn't help without cold booting. Does SPDIF input work for other cs46xx based cards after applying the mentioned patch? What errors does this patch fix? Do I need it?
Anyway, great to have pcm output without phase reversals. Thanks again! fe
Quoted 24 lines · Benny Sjostrand
Quoted 6 lines
it seems that volumes 0-0x7fff ramp up volumes, then 8000-ffff go back down... but with opposite phases. So...
Great discovery!, probably the stream can be inverted several times when it processedthrough through the SCB tree. (
PCMReader->SrcTaskSCB->MasterMixSCB->CodecOut)
Almost all SCB's got a volume field.Quoted 4 lines
and it sounds correct (for CD analog passthru and PCM at least).
(note - you'll need to open alsamixer and adjust the DAC volume before the 'fix' works, I haven't found where it gets programmed on driver load.I guess that the only thing left is to change the initial volume values set when driver is loaded in
dsp_spos.cline 260:/* maximize volume */ ins->dac_volume_right = 0x8000;(quoted diff) +2
-2- ins->dac_volume_left = 0x8000; + ins->dac_volume_left = 0x7fff; ins->spdif_input_volume_right = 0x8000; - ins->spdif_input_volume_left = 0x8000; + ins->spdif_input_volume_left = 0x7fff;
Quoted 8 lines
Quoted 4 lines
Now, I have no idea if this is correct, if I just broke SPDIF (no reciever), rear speakers (ditto, I don't have any) but it fixes my case anyway, so that's a start. If anyone can test more of these cases, that might be good.
If it works and solves a problem then it must correct -:)
/Benny
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf