Skip to contentSkip to conversation

HDA patch_via.c: Add second S/PDIF out control for VT1708S and VT1702.

PATCH In review Li Bo 2 participants 6 messages Oct 5, 2009 – Oct 8, 2009 Sound

lore
Share & tools
lore

Li Bo

author
#0 lore raw

PATCH 17/31 HDA patch_via.c: Add second S/PDIF out control for VT1708S and VT1702.

[ALSA] HDA VIA: Add second S/PDIF out control for VT1708S and VT1702.

sound/pci/hda/patch_via.c +8 -1
Index: sound-2.6/sound/pci/hda/patch_via.c
===================================================================
@@ -1265,6 +1265,13 @@
 		if (err < 0)
 			return err;
 		spec->multiout.share_spdif = 1;
+		/* lydia add for second spdif out */
+		if (spec->slave_dig_outs[0]) {
+			err = snd_hda_create_spdif_out_ctls(codec,
+						    spec->slave_dig_outs[0]);
+			if (err < 0)
+				return err;
+		}
 	}
 	if (spec->dig_in_nid) {
 		err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -3127,7 +3134,7 @@
 };
 
 static struct hda_pcm_stream vt1708S_pcm_digital_playback = {
-	.substreams = 1,
+	.substreams = 2,
 	.channels_min = 2,
 	.channels_max = 2,
 	/* NID is set in via_build_pcms */
#1 lore raw

At Mon, 5 Oct 2009 22:27:35 +0800,

Quoted 4 lines · Li Bo

[ALSA] HDA VIA: Add second S/PDIF out control for VT1708S and VT1702.

The slave SPDIFs are really slaves. They are supposed to have identical SPDIF status bits as the master. So, creating the individual SPDIF status controls is wrong.

If they have to be handled separately, we shouldn't use slave SPDIF but create different streams, etc.

Takashi

Quoted 29 lines

Index: sound-2.6/sound/pci/hda/patch_via.c
===================================================================

sound/pci/hda/patch_via.c +8 -1
@@ -1265,6 +1265,13 @@
 		if (err < 0)
 			return err;
 		spec->multiout.share_spdif = 1;
+		/* lydia add for second spdif out */
+		if (spec->slave_dig_outs[0]) {
+			err = snd_hda_create_spdif_out_ctls(codec,
+						    spec->slave_dig_outs[0]);
+			if (err < 0)
+				return err;
+		}
 	}
 	if (spec->dig_in_nid) {
 		err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -3127,7 +3134,7 @@
 };
 
 static struct hda_pcm_stream vt1708S_pcm_digital_playback = {
-	.substreams = 1,
+	.substreams = 2,
 	.channels_min = 2,
 	.channels_max = 2,
 	/* NID is set in via_build_pcms */
author
#2 lore raw

They are separate S/PDIFs, and in our test, slave SPDIF seems can work
independently with master SPDIF. I'll do some test later.

Quoted 48 lines · Takashi Iwai

At Mon, 5 Oct 2009 22:27:35 +0800,

Quoted 4 lines · Li Bo

[ALSA] HDA VIA: Add second S/PDIF out control for VT1708S and VT1702.

The slave SPDIFs are really slaves.  They are supposed to have identical SPDIF status bits as the master.  So, creating the individual SPDIF status controls is wrong.

If they have to be handled separately, we shouldn't use slave SPDIF but create different streams, etc.

Takashi

Quoted 29 lines

Index: sound-2.6/sound/pci/hda/patch_via.c
===================================================================

sound/pci/hda/patch_via.c       2009-10-05 15:11:02.000000000 +0800 renamed from sound/pci/hda/patch_via.c  2009-10-05 15:10:59.000000000 +0800 +8 -1
@@ -1265,6 +1265,13 @@
               if (err < 0)
                       return err;
               spec->multiout.share_spdif = 1;
+             /* lydia add for second spdif out */
+             if (spec->slave_dig_outs[0]) {
+                     err = snd_hda_create_spdif_out_ctls(codec,
+                                                 spec->slave_dig_outs[0]);
+                     if (err < 0)
+                             return err;
+             }
       }
       if (spec->dig_in_nid) {
               err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -3127,7 +3134,7 @@
  };
 
  static struct hda_pcm_stream vt1708S_pcm_digital_playback = {
-     .substreams = 1,
+     .substreams = 2,
       .channels_min = 2,
       .channels_max = 2,
       /* NID is set in via_build_pcms */
#3 lore raw

At Tue, 6 Oct 2009 13:01:42 +0800,

Quoted 3 lines · Li Bo

They are separate S/PDIFs, and in our test, slave SPDIF seems can work
independently with master SPDIF. I'll do some test later.

The problem is that master SPDIF will change both master and slaves. In your implementation, the slave can be used freely only while the master isn't used. Or, it'll conflict later once when the master is used.

Takashi

Quoted 41 lines · Takashi Iwai
Quoted 40 lines

At Mon, 5 Oct 2009 22:27:35 +0800,

Quoted 4 lines · Li Bo

[ALSA] HDA VIA: Add second S/PDIF out control for VT1708S and VT1702.

The slave SPDIFs are really slaves.  They are supposed to have identical SPDIF status bits as the master.  So, creating the individual SPDIF status controls is wrong.

If they have to be handled separately, we shouldn't use slave SPDIF but create different streams, etc.

Takashi

Quoted 22 lines

Index: sound-2.6/sound/pci/hda/patch_via.c
===================================================================

sound/pci/hda/patch_via.c       2009-10-05 15:11:02.000000000 +0800 renamed from sound/pci/hda/patch_via.c  2009-10-05 15:10:59.000000000 +0800 +7 -0
@@ -1265,6 +1265,13 @@
               if (err < 0)
                       return err;
               spec->multiout.share_spdif = 1;
+             /* lydia add for second spdif out */
+             if (spec->slave_dig_outs[0]) {
+                     err = snd_hda_create_spdif_out_ctls(codec,
+                                                 spec->slave_dig_outs[0]);
+                     if (err < 0)
+                             return err;
+             }
       }
       if (spec->dig_in_nid) {
               err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -3127,7 +3134,7 @@
  };
 
Quoted 9 lines
Quoted 8 lines

sound/pci/hda/patch_via.c       2009-10-05 15:11:02.000000000 +0800 line 3140

Quoted 7 lines
sound/pci/hda/patch_via.c       2009-10-05 15:11:02.000000000 +0800 renamed from sound/pci/hda/patch_via.c  2009-10-05 15:10:59.000000000 +0800 +1 -1
  static struct hda_pcm_stream vt1708S_pcm_digital_playback = {
-     .substreams = 1,
+     .substreams = 2,
       .channels_min = 2,
       .channels_max = 2,
       /* NID is set in via_build_pcms */

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

author
#4 lore raw
Quoted 6 lines · Takashi Iwai

At Tue, 6 Oct 2009 13:01:42 +0800,

Quoted 3 lines · Li Bo

They are separate S/PDIFs, and in our test, slave SPDIF  seems can work independently with master SPDIF. I'll do some test later.

Quoted 8 lines

The problem is that master SPDIF will change both master and slaves. In your implementation, the slave can be used freely only while the master isn't used.  Or, it'll conflict later once when the master is used.

Takashi

Oh I understand, thank you. We'll update this patch to build independent control & substreams for 2nd SPDIF.

Quoted 51 lines
Quoted 50 lines · Takashi Iwai
Quoted 48 lines

At Mon, 5 Oct 2009 22:27:35 +0800,

Quoted 4 lines · Li Bo

[ALSA] HDA VIA: Add second S/PDIF out control for VT1708S and VT1702.

The slave SPDIFs are really slaves.  They are supposed to have identical SPDIF status bits as the master.  So, creating the individual SPDIF status controls is wrong.

If they have to be handled separately, we shouldn't use slave SPDIF but create different streams, etc.

Takashi

Quoted 29 lines

Index: sound-2.6/sound/pci/hda/patch_via.c
===================================================================

sound/pci/hda/patch_via.c       2009-10-05 15:11:02.000000000 +0800 renamed from sound/pci/hda/patch_via.c  2009-10-05 15:10:59.000000000 +0800 +8 -1
@@ -1265,6 +1265,13 @@
               if (err < 0)
                       return err;
               spec->multiout.share_spdif = 1;
+             /* lydia add for second spdif out */
+             if (spec->slave_dig_outs[0]) {
+                     err = snd_hda_create_spdif_out_ctls(codec,
+                                                 spec->slave_dig_outs[0]);
+                     if (err < 0)
+                             return err;
+             }
       }
       if (spec->dig_in_nid) {
               err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -3127,7 +3134,7 @@
  };
 
  static struct hda_pcm_stream vt1708S_pcm_digital_playback = {
-     .substreams = 1,
+     .substreams = 2,
       .channels_min = 2,
       .channels_max = 2,
       /* NID is set in via_build_pcms */
author
#5 lore raw

[ALSA] HDA VIA: Add second S/PDIF out control for VT1708S and VT1702.

---
 sound/pci/hda/patch_via.c |   37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)
sound/pci/hda/patch_via.c +27 -10
@@ -107,7 +107,7 @@
 
 	/* playback */
 	struct hda_multi_out multiout;
-	hda_nid_t slave_dig_outs[2];
+	hda_nid_t second_dig_out;
 
 	/* capture */
 	unsigned int num_adc_nids;
@@ -1177,8 +1177,23 @@
 					struct snd_pcm_substream *substream)
 {
 	struct via_spec *spec = codec->spec;
-	return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
-					     stream_tag, format, substream);
+	hda_nid_t nid = substream->number == 0
+		? spec->multiout.dig_out_nid : spec->second_dig_out;
+	mutex_lock(&codec->spdif_mutex);
+	/* copy from hda_codec.c: setup_dig_out_stream */
+	/* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
+	if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))
+		snd_hda_codec_write_cache(
+			codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
+			codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
+	snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
+	/* turn on again (if needed) */
+	if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))
+		snd_hda_codec_write_cache(
+			codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
+			codec->spdif_ctls & 0xff);
+	mutex_unlock(&codec->spdif_mutex);
+	return 0;
 }
 
 static int via_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
@@ -1296,6 +1311,13 @@
 		if (err < 0)
 			return err;
 		spec->multiout.share_spdif = 1;
+		/* add second spdif out */
+		if (spec->second_dig_out) {
+			err = snd_hda_create_spdif_out_ctls(
+				codec, spec->second_dig_out);
+			if (err < 0)
+				return err;
+		}
 	}
 	if (spec->dig_in_nid) {
 		err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
@@ -1470,11 +1492,6 @@
 	} else /* enable SPDIF-input pin */
 		snd_hda_codec_write(codec, spec->autocfg.dig_in_pin, 0,
 				    AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN);
-
-	/* assign slave outs */
-	if (spec->slave_dig_outs[0])
-		codec->slave_dig_outs = spec->slave_dig_outs;
-
  	return 0;
 }
 
@@ -3162,7 +3179,7 @@
 };
 
 static struct hda_pcm_stream vt1708S_pcm_digital_playback = {
-	.substreams = 1,
+	.substreams = 2,
 	.channels_min = 2,
 	.channels_max = 2,
 	/* NID is set in via_build_pcms */
@@ -3398,7 +3415,7 @@
 		if (!spec->multiout.dig_out_nid)
 			spec->multiout.dig_out_nid = nid;
 		else {
-			spec->slave_dig_outs[0] = nid;
+			spec->second_dig_out = nid;
 			break; /* at most two dig outs */
 		}
 	}