[RFC PATCH continued] PA2.0 UCM integration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Feng Wei <feng.wei@xxxxxxxxxx>

UCM: make jack and port single direction.

remove possibilities of dual direction jack and port

Signed-off-by: Feng Wei <feng.wei at linaro.org>
---
 src/modules/alsa/alsa-ucm.c |   29 ++++++++++++++++++++---------
 src/modules/alsa/alsa-ucm.h |    3 ++-
 2 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
index 7341bc9..ddfff2a 100644
--- a/src/modules/alsa/alsa-ucm.c
+++ b/src/modules/alsa/alsa-ucm.c
@@ -53,6 +53,8 @@
 #include "alsa-util.h"
 #include "alsa-ucm.h"
 
+#define PA_UCM_PRE_TAG_OUTPUT                       "[Out] "
+#define PA_UCM_PRE_TAG_INPUT                        "[In] "
 #define PA_UCM_PLAYBACK_PRIORITY_UNSET(device)      ((device)->playback_channels && !(device)->playback_priority)
 #define PA_UCM_CAPTURE_PRIORITY_UNSET(device)       ((device)->capture_channels && !(device)->capture_priority)
 #define PA_UCM_DEVICE_PRIORITY_SET(device, priority) \
@@ -558,7 +560,7 @@ static void ucm_add_port_combination(pa_hashmap *hash, pa_alsa_ucm_mapping_conte
 
     dev = context->ucm_devices[dev_indices[0]];
     dev_name = pa_proplist_gets(dev->proplist, PA_PROP_UCM_NAME);
-    name = pa_xstrdup(dev_name);
+    name = pa_sprintf_malloc("%s%s", is_sink ? PA_UCM_PRE_TAG_OUTPUT : PA_UCM_PRE_TAG_INPUT, dev_name);
     desc = num == 1 ? pa_xstrdup(pa_proplist_gets(dev->proplist, PA_PROP_UCM_DESCRIPTION))
             : pa_sprintf_malloc("Combination port for %s", dev_name);
     priority = is_sink ? dev->playback_priority : dev->capture_priority;
@@ -953,21 +955,25 @@ static int ucm_create_mapping(pa_alsa_ucm_config *ucm,
     return ret;
 }
 
-static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm, const char *dev_name) {
+static pa_alsa_jack* ucm_get_jack(pa_alsa_ucm_config *ucm,
+        const char *dev_name, const char *pre_tag) {
     pa_alsa_jack *j;
+    char *name = pa_sprintf_malloc("%s%s", pre_tag, dev_name);
 
     PA_LLIST_FOREACH(j, ucm->jacks)
-        if (pa_streq(j->name, dev_name))
-            return j;
+        if (pa_streq(j->name, name))
+            goto out;
 
     j = pa_xnew0(pa_alsa_jack, 1);
     j->state_unplugged = PA_PORT_AVAILABLE_NO;
     j->state_plugged = PA_PORT_AVAILABLE_YES;
-    j->name = pa_xstrdup(dev_name);
+    j->name = pa_xstrdup(name);
     j->alsa_name = pa_sprintf_malloc("%s Jack", dev_name);
 
     PA_LLIST_PREPEND(pa_alsa_jack, ucm->jacks, j);
 
+out:
+    pa_xfree(name);
     return j;
 }
 
@@ -1026,7 +1032,10 @@ static int ucm_create_profile(pa_alsa_ucm_config *ucm, pa_alsa_profile_set *ps,
         source = pa_proplist_gets(dev->proplist, PA_PROP_UCM_SOURCE);
 
         ucm_create_mapping(ucm, ps, p, dev, verb_name, dev_name, sink, source);
-        dev->jack = ucm_get_jack(ucm, dev_name);
+        if (sink)
+            dev->output_jack = ucm_get_jack(ucm, dev_name, PA_UCM_PRE_TAG_OUTPUT);
+        if (source)
+            dev->input_jack = ucm_get_jack(ucm, dev_name, PA_UCM_PRE_TAG_INPUT);
     }
     pa_alsa_profile_dump(p);
 
@@ -1102,10 +1111,12 @@ static void ucm_mapping_jack_probe(pa_alsa_mapping *m) {
         return;
 
     for (i=0; i<context->ucm_devices_num; i++) {
+        pa_alsa_jack *jack;
         dev = context->ucm_devices[i];
-        pa_assert (dev->jack);
-        dev->jack->has_control = pa_alsa_find_jack(hctl_handle, dev->jack->alsa_name) != NULL;
-        pa_log_info("ucm_mapping_jack_probe: %s has_control=%d", dev->jack->name, dev->jack->has_control);
+        jack = m->direction == PA_ALSA_DIRECTION_OUTPUT ? dev->output_jack : dev->input_jack;
+        pa_assert (jack);
+        jack->has_control = pa_alsa_find_jack(hctl_handle, jack->alsa_name) != NULL;
+        pa_log_info("ucm_mapping_jack_probe: %s has_control=%d", jack->name, jack->has_control);
     }
 
     snd_mixer_close(mixer_handle);
diff --git a/src/modules/alsa/alsa-ucm.h b/src/modules/alsa/alsa-ucm.h
index 24f9eec..379f3c9 100644
--- a/src/modules/alsa/alsa-ucm.h
+++ b/src/modules/alsa/alsa-ucm.h
@@ -78,7 +78,8 @@ struct pa_alsa_ucm_device {
     int n_suppdev;
     char **conflicting_devices;
     char **supported_devices;
-    pa_alsa_jack *jack;
+    pa_alsa_jack *input_jack;
+    pa_alsa_jack *output_jack;
 };
 
 struct pa_alsa_ucm_modifier {
-- 
1.7.9.5




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux