Skip to contentSkip to conversation

cs46xx Phase reversal fixes and some AC3 pass through progress

PATCH In review Benny Sjostrand 3 participants 5 messages Dec 9, 2002 – Dec 10, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cs46xx Phase reversal fixes and some AC3 pass through progress

Hi!

In this patch the phase problems should be gone, if still think that you got "phase reversal" problem please sendme a dump of the /proc/asound/card0/dsp/sample content while you are playbacking whatever giving you "phase reversal" problem.

On the AC3 front I've managed to get my receiver to switch on to "Digital Surround" mode (instead of PCM), which must mean that it finally detected the AC3 stream. But still no sound, got no idea why, but please if you have time give it a test.

Consider this patch as "experimental", just in the mean, dont be surprised if something that worked OK before is now broken.

Summar of changes:
- Phase reversal fixes.
- Some rewrites on playback code, related to the sample rate setup.
- AC3 stuff ....

/Benny

cvs/alsa-kernel/include/cs46xx.h renamed from include/cs46xx.h +2 -0
diff --exclude=CVS -Naur alsa-kernel/include/cs46xx.h ../cvs/alsa-kernel/include/cs46xx.h
@@ -1663,6 +1663,8 @@
 	snd_pcm_substream_t *substream;
 
 	pcm_channel_descriptor_t * pcm_channel;
+
+	int pcm_channel_id;    /* Fron Rear, Center Lfe  ... */
 } cs46xx_pcm_t;
 
 typedef struct {
cvs/alsa-kernel/include/cs46xx_dsp_spos.h renamed from include/cs46xx_dsp_spos.h +0 -1
diff --exclude=CVS -Naur alsa-kernel/include/cs46xx_dsp_spos.h ../cvs/alsa-kernel/include/cs46xx_dsp_spos.h
@@ -140,7 +140,6 @@
 	dsp_scb_descriptor_t * pcm_reader_scb;
 	dsp_scb_descriptor_t * src_scb;
 	dsp_scb_descriptor_t * mixer_scb;
-	int pcm_channel_id;
 
 	void * private_data;
 } pcm_channel_descriptor_t;
cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.c renamed from pci/cs46xx/cs46xx_lib.c +42 -41

161 lines not on this page · raw message

cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.h renamed from pci/cs46xx/cs46xx_lib.h +1 -2
diff --exclude=CVS -Naur alsa-kernel/pci/cs46xx/cs46xx_lib.h ../cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.h
@@ -152,6 +152,7 @@
                                                         dsp_scb_descriptor_t * parent_scb,
                                                         int scb_child_type);
 dsp_scb_descriptor_t *  cs46xx_dsp_create_src_task_scb(cs46xx_t * chip,char * scb_name,
+						       int sample_rate,
                                                        u16 src_buffer_addr,
                                                        u16 src_delay_buffer_addr,u32 dest,
                                                        dsp_scb_descriptor_t * parent_scb,
@@ -202,8 +203,6 @@
                                                           int pcm_channel_id);
 void                       cs46xx_dsp_destroy_pcm_channel (cs46xx_t * chip,
                                                            pcm_channel_descriptor_t * pcm_channel);
-void                       cs46xx_dsp_set_src_sample_rate(cs46xx_t * chip,dsp_scb_descriptor_t * src, 
-                                                          u32 rate);
 int                        cs46xx_dsp_pcm_unlink (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel);
 int                        cs46xx_dsp_pcm_link (cs46xx_t * chip,pcm_channel_descriptor_t * pcm_channel);
 dsp_scb_descriptor_t *     cs46xx_add_record_source (cs46xx_t *chip,dsp_scb_descriptor_t * source,
cvs/alsa-kernel/pci/cs46xx/dsp_spos.c renamed from pci/cs46xx/dsp_spos.c +7 -6
diff --exclude=CVS -Naur alsa-kernel/pci/cs46xx/dsp_spos.c ../cvs/alsa-kernel/pci/cs46xx/dsp_spos.c
@@ -615,7 +615,7 @@
 	snd_iprintf(buffer,"\nMIX_SAMPLE_BUF1:\n");
 
 	col = 0;
-	for (i = MIX_SAMPLE_BUF1;i < MIX_SAMPLE_BUF1 + 0x30; i += sizeof(u32),col ++) {
+	for (i = MIX_SAMPLE_BUF1;i < MIX_SAMPLE_BUF1 + 0x40; i += sizeof(u32),col ++) {
 		if (col == 4) {
 			snd_iprintf(buffer,"\n");
 			col = 0;
@@ -628,14 +628,14 @@
 		snd_iprintf(buffer,"%08X ",readl(dst + i));
 	}
 
-	snd_iprintf(buffer,"\n\n");
+	snd_iprintf(buffer,"\nSRC_TASK_SCB1:\n");
 	col = 0;
-	for (i = SPDIFI_IP_OUTPUT_BUFFER1;i < SPDIFI_IP_OUTPUT_BUFFER1 + 0x40; i += sizeof(u32),col ++) {
+	for (i = 0x2580 ; i < 0x2580 + 0x40 ; i += sizeof(u32),col ++) {
 		if (col == 4) {
 			snd_iprintf(buffer,"\n");
 			col = 0;
 		}
-
+		
 		if (col == 0) {
 			snd_iprintf(buffer, "%04X ",i);
 		}
@@ -646,7 +646,7 @@
 
 	snd_iprintf(buffer,"\nSPDIFO_BUFFER:\n");
 	col = 0;
-	for (i = SPDIFO_IP_OUTPUT_BUFFER1;i < SPDIFO_IP_OUTPUT_BUFFER1 + 0x40; i += sizeof(u32),col ++) {
+	for (i = SPDIFO_IP_OUTPUT_BUFFER1;i < SPDIFO_IP_OUTPUT_BUFFER1 + 0x30; i += sizeof(u32),col ++) {
 		if (col == 4) {
 			snd_iprintf(buffer,"\n");
 			col = 0;
@@ -1356,6 +1356,7 @@
 
 	/* SPDIF input sampel rate converter */
 	src_task_scb = cs46xx_dsp_create_src_task_scb(chip,"SrcTaskSCB_SPDIFI",
+						      48000,
 						      SRC_OUTPUT_BUF1,
 						      SRC_DELAY_BUF1,SRCTASK_SCB_ADDR,
 						      master_mix_scb,
@@ -1601,7 +1602,7 @@
 
 	/* set SPDIF input sample rate and unmute
 	   NOTE: only 48khz support for SPDIF input this time */
-	cs46xx_dsp_set_src_sample_rate(chip,ins->spdif_in_src,48000);
+	/* cs46xx_dsp_set_src_sample_rate(chip,ins->spdif_in_src,48000); */
 
 	/* monitor state */
 	ins->spdif_status_in = 1;
cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c renamed from pci/cs46xx/dsp_spos_scb_lib.c +116 -108

317 lines not on this page · raw message

#1 lore raw

Hi Benny,

At Mon, 09 Dec 2002 01:12:09 +0100,

Quoted 15 lines · Benny Sjostrand

Hi!

In this patch the phase problems should be gone, if still think that you got "phase reversal" problem
please sendme a dump of the /proc/asound/card0/dsp/sample content while you are playbacking
whatever giving you "phase reversal" problem.

On the AC3 front I've managed to get my receiver to switch on to "Digital Surround" mode (instead of PCM), which
must mean that it finally detected the AC3 stream. But still no sound,
got no idea why, but please if you
have time give it a test.

Quoted 8 lines

Consider this patch as "experimental", just in the mean, dont be surprised if something that worked
OK before is now broken.

Summar of changes:
- Phase reversal fixes.
- Some rewrites on playback code, related to the sample rate setup.
- AC3 stuff ....

thanks! now committed on cvs.

the spdif output on my terratec x-fire seems working fine now, at least for the normal playback. however, if i stop the playback in the middle, it results in a constant beep. does happen on another card?

also, ac3dec seems not working yet on the card.
this could be due to another reason, though.

Takashi

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#2 lore raw
Quoted 8 lines

the spdif output on my terratec x-fire seems working fine now, at least for the normal playback. however, if i stop the playback in the

middle, it results in a constant beep. does happen on another card?

It has not happen for me (yet)

Sounds like there some garbage left in some sample buffer. Did you use the IEC958 PCM device (aplay -Dhw:0,2) or just turn on the SPDIF output switch in mixer ???

/Benny

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#3 lore raw

At Mon, 09 Dec 2002 22:06:21 +0100,

Quoted 7 lines · Benny Sjostrand
Quoted 7 lines

the spdif output on my terratec x-fire seems working fine now, at least for the normal playback. however, if i stop the playback in the

Quoted 8 lines
Quoted 2 lines

middle, it results in a constant beep. does happen on another card?

It has not happen for me (yet)

Sounds like there some garbage left in some sample buffer. Did you use the IEC958 PCM device (aplay -Dhw:0,2) or just turn on the SPDIF output switch in mixer ???

i've used -Dhw:0,2. well, it seems fixed on the latest version.

thanks!

Takashi

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

#4 lore raw
In reply to Benny Sjostrand

Hi Benny,

I tested your patch and phase reversals are gone now. That's fine so far. But to apply your patch I had to install a version newer than rc6. I downloaded the cvs snapshot 2002-12-09.tar.bz2 and installed it successfully. After that the SPDIF ac3 mode switch is gone (like with rc6 + your previous patch). That seems to be ok.(?) But now I have the following problems with my terratec xfire card that I didn't have with the unpatched rc6 version:

* SPDIF input doesn't work anymore: no sound. Even reinstalling unpatched rc6 only helps if I do a cold reboot afterwards. (restarting alsa after installing rc6 doesn't help)

* (probably related) SPDIF volume control can't be changed individually for left and right channel. If you change the volume of one channel, the other channel follows more or less. I get a max. volume difference betw. right and left channel of 4 (on the scale 0..100).

* full duplex operation causes much more xruns compared to unpatched rc6:
My application sets input and output buffer size to 1024 frames, chunk size to 512 and the avail_min (for the poll/wait function) to 512. Then I link playback and capture device and basically do the following:

// using buffer size = 2 * chunk size
// therefore, fill output buffer with 2*chunkSize frames before starting err = snd_pcm_wait(pHandle, 1000);
if(err < 0){fprintf(stderr, "output wait error(init0.5): %s\n",
snd_strerror(err));return -1;}
err = snd_pcm_writei(pHandle, outbuf, chunkSize);
if(err < 0){fprintf(stderr, "audio output error(init1): %s\n",
snd_strerror(err));return -1;}
err = snd_pcm_wait(pHandle, 1000);
if(err < 0){fprintf(stderr, "output wait error(init1.5): %s\n",
snd_strerror(err));return -1;}
err = snd_pcm_writei(pHandle, outbuf, chunkSize);
if(err < 0){fprintf(stderr, "audio output error(init2): %s\n",
snd_strerror(err));return -1;}
// start audio device
err = snd_pcm_start(cHandle);
if(err < 0){fprintf(stderr, "error starting streams: %s\n",
snd_strerror(err));return -1;}

Then a loop of waits for the capture device, readi, wait for playback device, writei, ... follows.
This code worked with (almost) no xruns with rc6 driver. With cvs from 2002-12-09 (patched for phase reversal or not does no difference), this code doesn't work anymore, the first writei fails with 'broken pipe' error. This shouldn't be the case since the snd_pcm_wait returned without error and there must be space left in the buffer. If I change the buffer size to 2048 frames (still chunkSize = 512), the program works in about 2 of 3 cases and fails after various chunks played/recorded otherwise with xruns. I don't know if I could have programmed something wrong, but it worked with rc6 without problems and stable. I don't see a reason why the first writei could fail if the buffer is empty and snd_pcm_wait has returned without error before. Do you have an idea if the changes of the driver code could cause these problems?
fe

PS. regarding the phase reversal problems: switching the 'pcm out path&mute' control from pre3d to post3d (or back) also reverses the phase of the pcm output. That's no problem for stereo sound because left and rigth channel always have same phase but it might cause problems with > 2 channels/surround sound.

Quoted 13 lines · Benny Sjostrand

Hi!

In this patch the phase problems should be gone, if still think that you got "phase reversal" problem please sendme a dump of the /proc/asound/card0/dsp/sample content while you are playbacking whatever giving you "phase reversal" problem.

On the AC3 front I've managed to get my receiver to switch on to "Digital Surround" mode (instead of PCM), which must mean that it finally detected the AC3 stream. But still no sound, got no idea why, but please if you have time give it a test.

Consider this patch as "experimental", just in the mean, dont be surprised if something that worked OK before is now broken.

Quoted 9 lines

Summar of changes:
- Phase reversal fixes.
- Some rewrites on playback code, related to the sample rate setup.
- AC3 stuff ....

/Benny

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf