All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benny Sjostrand <gorm@cucumelo.org>
To: Gregoire Favre <greg@ulima.unil.ch>
Cc: alsa-devel@lists.sourceforge.net, James@superbug.demon.co.uk
Subject: Re: How to put 16bit none audio PCM data stream into a 32bit none audio S/P-DIF transport stream?
Date: Tue, 15 Apr 2003 01:00:43 +0200	[thread overview]
Message-ID: <3E9B3D9B.2060901@cucumelo.org> (raw)
In-Reply-To: 20030414212708.GB22184@ulima.unil.ch

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

>
>
>It's a value I could find, is that good?
>  
>
It's what I expected ...

>I have tried xine with the same iec958:AES0=0x2,AES1=0x0,AES2=0x82,AES3=0x2
>value:
>  
>
Let me guess, I did not work ? Well, guess what, I got new "this time 
hopefully working" patch,
so if you like to apply it to CVS and test again -;)

Could you also test with:
AES0=0x40,AES1=0x0,AES2=0x41,AES3=0x40 (all bits wrapped)

Then I got a question about the IEC958 protocoll that hopefulle someone 
on this list
knows something about. The Left and Right validity bits, and Left, Right 
user
bits, what are suposed to do ?? are they suposed to be 1 or 0 when outputing
AC3/DTS ???

That could be a posible source of the problem, in this patch they are
all turned off.

/Benny

[-- Attachment #2: cs46xx.patch --]
[-- Type: text/plain, Size: 7598 bytes --]

diff --exclude=CVS --exclude=Makefile -Nau alsa-kernel/pci/cs46xx/cs46xx_lib.c ../cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.c
--- alsa-kernel/pci/cs46xx/cs46xx_lib.c	Sat Apr  5 21:09:20 2003
+++ ../cvs/alsa-kernel/pci/cs46xx/cs46xx_lib.c	Tue Apr 15 00:51:31 2003
@@ -2091,10 +2091,10 @@
 	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);
+	ucontrol->value.iec958.status[0] =  ins->spdif_csuv_default        & 0xff;
+	ucontrol->value.iec958.status[1] = 0;
+	ucontrol->value.iec958.status[2] = (ins->spdif_csuv_default >> 16) & 0xff;
+	ucontrol->value.iec958.status[3] = (ins->spdif_csuv_default >> 24) & 0xff;
 	up (&chip->spos_mutex);
 
 	return 0;
@@ -2109,9 +2109,9 @@
 	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])  |
+	val =  (u32)ucontrol->value.iec958.status[0]        |
+	      ((u32)ucontrol->value.iec958.status[1] << 16) |
+	      ((u32)ucontrol->value.iec958.status[2] << 24) |
 		/* left and right validity bit */
 		(1 << 13) | (1 << 12);
 
@@ -2119,8 +2119,11 @@
 	change = (unsigned int)ins->spdif_csuv_default != val;
 	ins->spdif_csuv_default = val;
 
-	if ( !(ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) )
+	
+	if ( !(ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN) ) {
+		snd_printdd ("setting SP_SPDOUT_CSUV register (%08x)\n",val);
 		cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val);
+	}
 
 	up (&chip->spos_mutex);
 
@@ -2131,8 +2134,8 @@
 				     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[1] = 0x00;
+	ucontrol->value.iec958.status[2] = 0xff;
 	ucontrol->value.iec958.status[3] = 0xff;
 	return 0;
 }
@@ -2144,10 +2147,10 @@
 	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);
+	ucontrol->value.iec958.status[0] =  ins->spdif_csuv_stream        & 0xff;
+	ucontrol->value.iec958.status[1] = 0;
+	ucontrol->value.iec958.status[2] = (ins->spdif_csuv_stream >> 16) & 0xff;
+	ucontrol->value.iec958.status[3] = (ins->spdif_csuv_stream >> 24) & 0xff;
 	up (&chip->spos_mutex);
 
 	return 0;
@@ -2162,18 +2165,20 @@
 	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]) |
+	val =  (u32)ucontrol->value.iec958.status[0]        |
+	      ((u32)ucontrol->value.iec958.status[2] << 16) |
+	      ((u32)ucontrol->value.iec958.status[3] << 24);
 		/* left and right validity bit */
-		(1 << 13) | (1 << 12);
+	        /* (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 )
+	if ( ins->spdif_status_out & DSP_SPDIF_STATUS_PLAYBACK_OPEN ) {
+		snd_printdd ("setting SP_SPDOUT_CSUV register (%08x)\n",val);
 		cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV,val);
+	}
 
 	up (&chip->spos_mutex);
 
@@ -2543,13 +2548,21 @@
 	chip->eapd_switch = snd_ctl_find_id(chip->card, &id);
     
 #ifdef CONFIG_SND_CS46XX_NEW_DSP
+	if (chip->nr_ac97_codecs == 1 && 
+	   snd_cs46xx_codec_read(chip,AC97_VENDOR_ID2,
+				 CS46XX_PRIMARY_CODEC_INDEX) == 0x5d2d) {
+		/* set primary cs4294 codec into Extended Audio Mode */
+		snd_printdd("setting EAM bit on cs4294 CODEC\n");
+		snd_cs46xx_codec_write(chip,AC97_CSR_ACMODE,0x200,
+				       CS46XX_PRIMARY_CODEC_INDEX);
+	}
 	/* do soundcard specific mixer setup */
 	if (chip->mixer_init) {
 		snd_printdd ("calling chip->mixer_init(chip);\n");
 		chip->mixer_init(chip);
 	}
 #endif
-
+	
  	/* turn on amplifier */
 	chip->amplifier_ctrl(chip, 1);
     
diff --exclude=CVS --exclude=Makefile -Nau alsa-kernel/pci/cs46xx/dsp_spos.c ../cvs/alsa-kernel/pci/cs46xx/dsp_spos.c
--- alsa-kernel/pci/cs46xx/dsp_spos.c	Sat Apr  5 21:09:20 2003
+++ ../cvs/alsa-kernel/pci/cs46xx/dsp_spos.c	Tue Apr 15 00:14:36 2003
@@ -265,13 +265,10 @@
 
 	/* 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);
-
+	ins->spdif_csuv_default = (SNDRV_PCM_DEFAULT_CON_SPDIF & 0xffff00ff) | 
+		/* left and right validity bits */ (1 << 13) | (1 << 12);
+	ins->spdif_csuv_stream =  (SNDRV_PCM_DEFAULT_CON_SPDIF & 0xffff00ff) | 
+		/* left and right validity bits */ (1 << 13) | (1 << 12);
 	return ins;
 }
 
@@ -1655,6 +1652,7 @@
 	cs46xx_poke_via_dsp (chip,SP_SPDOUT_CONTROL, 0x80000000);
 
 	/* right and left validate bit */
+	snd_printdd ("setting SP_SPDOUT_CSUV register to default (%08x)\n",ins->spdif_csuv_default);
 	cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV, ins->spdif_csuv_default);
 
 	/* monitor state */
diff --exclude=CVS --exclude=Makefile -Nau alsa-kernel/pci/cs46xx/dsp_spos.h ../cvs/alsa-kernel/pci/cs46xx/dsp_spos.h
--- alsa-kernel/pci/cs46xx/dsp_spos.h	Sat Apr  5 21:09:20 2003
+++ ../cvs/alsa-kernel/pci/cs46xx/dsp_spos.h	Sun Apr 13 12:43:20 2003
@@ -186,25 +186,6 @@
 #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) >> 7);
-
-	return wrapped;
-
-}
-
-
 static inline void cs46xx_dsp_spos_update_scb (cs46xx_t * chip,dsp_scb_descriptor_t * scb) 
 {
 	/* update nextSCB and subListPtr in SCB */
diff --exclude=CVS --exclude=Makefile -Nau alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c ../cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c
--- alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c	Sat Apr  5 21:09:20 2003
+++ ../cvs/alsa-kernel/pci/cs46xx/dsp_spos_scb_lib.c	Mon Apr 14 01:01:30 2003
@@ -1701,6 +1701,7 @@
 
 
 	/* set spdif channel status value for streaming */
+	snd_printdd ("setting SP_SPDOUT_CSUV register to stream (%08x)\n",ins->spdif_csuv_stream);
 	cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV, ins->spdif_csuv_stream);
 
 	ins->spdif_status_out  |= DSP_SPDIF_STATUS_PLAYBACK_OPEN;
@@ -1717,6 +1718,7 @@
 	ins->spdif_status_out  &= ~DSP_SPDIF_STATUS_PLAYBACK_OPEN;
 
 	/* restore settings */
+	snd_printdd ("setting SP_SPDOUT_CSUV register to default (%08x)\n",ins->spdif_csuv_default);
 	cs46xx_poke_via_dsp (chip,SP_SPDOUT_CSUV, ins->spdif_csuv_default);
 	
 	/* deallocate stuff */


  reply	other threads:[~2003-04-14 23:00 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-08 14:02 How to put 16bit none audio PCM data stream into a 32bit none audio S/P-DIF transport stream? Gregoire Favre
2003-04-08 14:28 ` Paul Davis
2003-04-08 15:50   ` Takashi Iwai
2003-04-08 16:42     ` Gregoire Favre
2003-04-08 20:30       ` James Courtier-Dutton
2003-04-08 20:44         ` Gregoire Favre
2003-04-09 10:34         ` James Courtier-Dutton
2003-04-09 11:06           ` Gregoire Favre
2003-04-09 16:50             ` James Courtier-Dutton
2003-04-09 17:58               ` Gregoire Favre
2003-04-10 17:43               ` James Courtier-Dutton
2003-04-08 21:39     ` Benny Sjostrand
2003-04-08 20:55       ` Gregoire Favre
2003-04-08 21:28         ` James Courtier-Dutton
2003-04-08 21:55           ` Gregoire Favre
2003-04-09  6:59           ` Benny Sjostrand
2003-04-09  8:28             ` Gregoire Favre
2003-04-09 11:09               ` Takashi Iwai
2003-04-09 11:43                 ` Gregoire Favre
2003-04-09 13:11                   ` Takashi Iwai
2003-04-09 17:58                     ` Gregoire Favre
2003-04-10 11:21                     ` James Courtier-Dutton
2003-04-10 11:26                       ` Gregoire Favre
2003-04-13 11:41                         ` Benny Sjostrand
2003-04-13 17:05                           ` Gregoire Favre
2003-04-13 18:21                             ` Benny Sjostrand
2003-04-13 18:30                               ` Gregoire Favre
2003-04-13 23:23                                 ` Benny Sjostrand
2003-04-14 19:06                                   ` Gregoire Favre
2003-04-14 22:20                                     ` Benny Sjostrand
2003-04-14 21:27                                       ` Gregoire Favre
2003-04-14 23:00                                         ` Benny Sjostrand [this message]
2003-04-14 22:14                                           ` Gregoire Favre
2003-04-09 21:17               ` Benny Sjostrand
2003-04-09 20:38                 ` Gregoire Favre
  -- strict thread matches above, loose matches on Subject: below --
2003-04-08 23:33 Peter Heatwole

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3E9B3D9B.2060901@cucumelo.org \
    --to=gorm@cucumelo.org \
    --cc=James@superbug.demon.co.uk \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=greg@ulima.unil.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.