From 48be052c5cc4c0079f100e7cbf7f08cf269d0604 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Date: Fri, 18 Jun 2010 20:20:19 -0500
Subject: [PATCH] alsa: fix profile configuration for IEC output

---
 src/Makefile.am                                    |    3 +-
 src/modules/alsa/alsa-mixer.c                      |    8 ++----
 .../alsa/mixer/paths/iec958-stereo-output.conf     |   23 ++++++++++++++++++++
 src/modules/alsa/mixer/profile-sets/default.conf   |   23 +++----------------
 4 files changed, 32 insertions(+), 25 deletions(-)
 create mode 100644 src/modules/alsa/mixer/paths/iec958-stereo-output.conf

diff --git a/src/Makefile.am b/src/Makefile.am
index ffe7558..1779b0a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -132,7 +132,8 @@ ALSA_PATHS = \
 		modules/alsa/mixer/paths/analog-output-headphones.conf \
 		modules/alsa/mixer/paths/analog-output-headphones-2.conf \
 		modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf \
-		modules/alsa/mixer/paths/analog-output-mono.conf
+		modules/alsa/mixer/paths/analog-output-mono.conf \
+		modules/alsa/mixer/paths/iec958-stereo-output.conf
 
 EXTRA_DIST = \
 		pulse/client.conf.in \
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 93f2ed0..e27ade8 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -1783,7 +1783,8 @@ static int path_verify(pa_alsa_path *p) {
         { "analog-output-headphones",   N_("Analog Headphones") },
         { "analog-output-lfe-on-mono",  N_("Analog Output (LFE)") },
         { "analog-output-mono",         N_("Analog Mono Output") },
-        { "analog-output-speaker",      N_("Analog Speakers") }
+        { "analog-output-speaker",      N_("Analog Speakers") },
+        { "iec958-stereo_output",       N_("Digital IEC958 Output") }
     };
 
     pa_alsa_element *e;
@@ -2806,9 +2807,6 @@ static int mapping_verify(pa_alsa_mapping *m, const pa_channel_map *bonus) {
         { "analog-surround-70",     N_("Analog Surround 7.0") },
         { "analog-surround-71",     N_("Analog Surround 7.1") },
         { "iec958-stereo",          N_("Digital Stereo (IEC958)") },
-        { "iec958-surround-40",     N_("Digital Surround 4.0 (IEC958)") },
-        { "iec958-ac3-surround-40", N_("Digital Surround 4.0 (IEC958/AC3)") },
-        { "iec958-ac3-surround-51", N_("Digital Surround 5.1 (IEC958/AC3)") },
         { "hdmi-stereo",            N_("Digital Stereo (HDMI)") }
     };
 
@@ -2932,7 +2930,7 @@ static int profile_verify(pa_alsa_profile *p) {
     static const struct description_map well_known_descriptions[] = {
         { "output:analog-mono+input:analog-mono",     N_("Analog Mono Duplex") },
         { "output:analog-stereo+input:analog-stereo", N_("Analog Stereo Duplex") },
-        { "output:iec958-stereo",                     N_("Digital Stereo Duplex (IEC958)") },
+        { "output:iec958-stereo+input:iec958-stereo", N_("Digital Stereo Duplex (IEC958)") },
         { "off",                                      N_("Off") }
     };
 
diff --git a/src/modules/alsa/mixer/paths/iec958-stereo-output.conf b/src/modules/alsa/mixer/paths/iec958-stereo-output.conf
new file mode 100644
index 0000000..46f56af
--- /dev/null
+++ b/src/modules/alsa/mixer/paths/iec958-stereo-output.conf
@@ -0,0 +1,23 @@
+# This file is part of PulseAudio.
+#
+# PulseAudio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# PulseAudio is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with PulseAudio; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+
+
+[Element IEC958]
+switch = mute
+
+# this is not really needed, one mute is enough
+#[Element IEC958 Default PCM]
+#switch = mute
diff --git a/src/modules/alsa/mixer/profile-sets/default.conf b/src/modules/alsa/mixer/profile-sets/default.conf
index 5d352f1..919aa3b 100644
--- a/src/modules/alsa/mixer/profile-sets/default.conf
+++ b/src/modules/alsa/mixer/profile-sets/default.conf
@@ -110,26 +110,11 @@ priority = 7
 direction = output
 
 [Mapping iec958-stereo]
-device-strings = iec958:%f
+device-strings = hw:%f,1
 channel-map = left,right
-priority = 5
-
-[Mapping iec958-surround-40]
-device-strings = iec958:%f
-channel-map = front-left,front-right,rear-left,rear-right
-priority = 1
-
-[Mapping iec958-ac3-surround-40]
-device-strings = a52:%f
-channel-map = front-left,front-right,rear-left,rear-right
-priority = 2
-direction = output
-
-[Mapping iec958-ac3-surround-51]
-device-strings = a52:%f
-channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe
-priority = 3
-direction = output
+paths-input = iec958-stereo-input
+paths-output = iec958-stereo-output
+priority = 8
 
 [Mapping hdmi-stereo]
 device-strings = hdmi:%f
-- 
1.7.0.1

