Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Logan Li <loganli@viatech.com.cn>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, HaraldWelte@viatech.com, LydiaWang@viatech.com.cn
Subject: [PATCH 17/30] ALSA: HDA VIA: Add 2nd S/PDIF out for VT1708S and VT1702.
Date: Sat, 10 Oct 2009 19:08:25 +0800	[thread overview]
Message-ID: <4AD06B29.8020803@viatech.com.cn> (raw)

From: Lydia Wang <lydiawang@viatech.com.cn>
Subject: ALSA: HDA VIA: Add 2nd S/PDIF out for VT1708S and VT1702.

Signed-off-by: Lydia Wang <lydiawang@viatech.com.cn>
Signed-off-by: Logan Li <loganli@viatech.com.cn>

---
 sound/pci/hda/patch_via.c |   37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -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;
@@ -1179,8 +1179,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,
@@ -1298,6 +1313,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);
@@ -1472,11 +1494,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;
 }
 
@@ -3164,7 +3181,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 */
@@ -3400,7 +3417,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 */
 		}
 	}

             reply	other threads:[~2009-10-10 11:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-10 11:08 Logan Li [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-09 10:40 [PATCH 17/30] ALSA: HDA VIA: Add 2nd S/PDIF out for VT1708S and VT1702 LoganLi

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=4AD06B29.8020803@viatech.com.cn \
    --to=loganli@viatech.com.cn \
    --cc=HaraldWelte@viatech.com \
    --cc=LydiaWang@viatech.com.cn \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox