Skip to contentSkip to conversation

cs46xx: SPDIF channel status more volume fixes

PATCH In review Benny Sjostrand 2 participants 2 messages Nov 14, 2002 – Nov 15, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cs46xx: SPDIF channel status more volume fixes

Hi!

Here's my final aproach for related to volume fixes. I hope that this possibly can solve the bass-problem. I've discovered that the volume was a little bit unbalanced in left vs. right channel, however a human ear may not hear the difference maybe some audio equipment can react very weird on this, I've tested to change between Stereo 3Stereo or Dolbly Pro Logic modes on my receiver the sound is distributed very different. Well, this problem should be fixed with this patch, the level should be equal in left and right channel (depending on what you playing and your mixer settings).

About AC3, I've implemented the channel status as it's based on how it's done in ens1370.c. From what I can understand from the spec. it's only possible to set channel status byte 0, 1 and 3, the worst thing is that all bits are wrapped: byte0,bit0 -> csuv register, bit(32) byte 1 bit (8) -> csuv register bit(16) I hope all weird byte and bits swappings are correct. I've done some quick test with xine, AC3 still dont work forme, dont know exactly what's wrong. I would to have some stuff that could display the stream raw data the comes out from SPDIF interface .... :(

Summary:
- SPDIF channel status implementation (based on how it's done in ens1370.c)
- Removed the "AC3 Mode" control in mixer
- Final aproach for rewrite on the DAC and SPDIF input volume mechanism
- Change mixer control name on some mixer items "IEC 958" -> "IEC958", to heave it in the same way like it's done in the rest of the ALSA code.

/Benny

cvs/alsa-kernel/include/cs46xx_dsp_spos.h renamed from include/cs46xx_dsp_spos.h +4 -1
diff --exclude=CVS -Naur alsa-kernel/include/cs46xx_dsp_spos.h ../cvs/alsa-kernel/include/cs46xx_dsp_spos.h
@@ -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       8
 
 struct _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 +142 -54

259 lines not on this page · raw message

cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.h renamed from pci/cs46xx/cs46xx_lib.h +2 -2
diff --exclude=CVS -Naur alsa-kernel/pci/cs46xx/cs46xx_lib.h ../cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.h
@@ -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
diff --exclude=CVS -Naur alsa-kernel/pci/cs46xx/dsp_spos.h ../cvs/alsa-kernel/pci/cs46xx/dsp_spos.h
@@ -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
diff --exclude=CVS -Naur alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c ../cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c
@@ -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);
#1 lore raw

Sorry to report, but still having same problems w/ the bass.

Weijia Yang

Quoted 30 lines · Benny Sjostrand

Hi!

Here's my final aproach for related to volume fixes. I hope that this possibly can solve the bass-problem. I've discovered that the volume was a little bit unbalanced in left vs. right channel, however a human ear may not hear the difference maybe some audio equipment can react very weird on this, I've tested to change between Stereo 3Stereo or Dolbly Pro Logic modes on my receiver the sound is distributed very different. Well, this problem should be fixed with this patch, the level should be equal in left and right channel (depending on what you playing and your mixer settings).

About AC3, I've implemented the channel status as it's based on how it's done in ens1370.c. From what I can understand from the spec. it's only possible to set channel status byte 0, 1 and 3, the worst thing is that all bits are wrapped: byte0,bit0 -> csuv register, bit(32) byte 1 bit
(8) -> csuv register bit(16) I hope all weird byte and bits swappings are correct.
I've done some quick test with xine, AC3 still dont work forme, dont know exactly what's wrong. I would to have some stuff that could display the stream raw data the comes out from SPDIF interface .... :(

Summary:
- SPDIF channel status implementation (based on how it's done in ens1370.c)
- Removed the "AC3 Mode" control in mixer
- Final aproach for rewrite on the DAC and SPDIF input volume mechanism
- Change mixer control name on some mixer items "IEC 958" -> "IEC958", to heave it in the
same way like it's done in the rest of the ALSA code.

Quoted 1 line

/Benny

-------------------------------------------------------
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