Still can't work well on embedded devices without driver support. Index: pulseaudio-1.1/src/modules/alsa/alsa-jack-inputdev.h =================================================================== --- pulseaudio-1.1.orig/src/modules/alsa/alsa-jack-inputdev.h 2012-02-16 17:49:05.184505051 +0800 +++ pulseaudio-1.1/src/modules/alsa/alsa-jack-inputdev.h 2012-02-16 17:56:21.376505285 +0800 @@ -25,11 +25,13 @@ #include <pulsecore/idxset.h> #include <pulsecore/hashmap.h> #include "alsa-mixer.h" +#include "alsa-ucm.h" struct pa_alsa_jack_inputdev_link { pa_device_port *port; pa_alsa_path *path; pa_alsa_jack_inputdev *dev; + struct pa_alsa_ucm_device *ucm_dev; int64_t switches_enable; }; @@ -39,6 +41,7 @@ /* Match an alsa path against input devices. Returns NULL if no match. Returned link pointer is owned by input device and does not need to be freed. */ pa_alsa_jack_inputdev_link* pa_alsa_jack_inputdev_match(pa_hashmap* devs, pa_alsa_path* path); +pa_alsa_jack_inputdev_link* pa_alsa_jack_inputdev_match_ucm(pa_hashmap* devs, struct pa_alsa_ucm_device *ucm_dev); /* Start listening to input dev change events, and reports initial state */ void pa_alsa_jack_inputdev_start(pa_hashmap* devs, pa_core* core); Index: pulseaudio-1.1/src/modules/alsa/alsa-ucm.c =================================================================== --- pulseaudio-1.1.orig/src/modules/alsa/alsa-ucm.c 2012-02-16 17:49:05.356505051 +0800 +++ pulseaudio-1.1/src/modules/alsa/alsa-ucm.c 2012-02-16 18:04:23.296505541 +0800 @@ -51,6 +51,7 @@ #include "alsa-mixer.h" #include "alsa-util.h" #include "alsa-ucm.h" +#include "alsa-jack-inputdev.h" #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) @@ -588,7 +589,12 @@ pa_hashmap_put(ports, name, port); pa_log_debug("Add port %s: %s", port->name, port->description); port->profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func); - /* TODO: jack detection */ + } + if (num == 1) { //not combinated port + if (dev->jack_inputdev_link) { + dev->jack_inputdev_link->port = port; + pa_device_port_ref(port); + } } port->priority = priority; if (is_sink) @@ -1127,3 +1133,14 @@ } } } + +void ucm_jack_inputdev_probe(pa_hashmap* devs, pa_alsa_ucm_config *ucm) { + struct pa_alsa_ucm_verb *verb; + struct pa_alsa_ucm_device *dev; + + PA_LLIST_FOREACH(verb, ucm->verbs) { + PA_LLIST_FOREACH(dev, verb->devices) { + dev->jack_inputdev_link = pa_alsa_jack_inputdev_match_ucm(devs, dev); + } + } +} Index: pulseaudio-1.1/src/modules/alsa/alsa-ucm.h =================================================================== --- pulseaudio-1.1.orig/src/modules/alsa/alsa-ucm.h 2012-02-16 17:49:05.360505051 +0800 +++ pulseaudio-1.1/src/modules/alsa/alsa-ucm.h 2012-02-16 17:49:05.376505051 +0800 @@ -32,6 +32,7 @@ typedef struct pa_alsa_ucm_config pa_alsa_ucm_config; typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context; typedef struct pa_alsa_port_data_ucm pa_alsa_port_data_ucm; +typedef struct pa_alsa_jack_inputdev_link pa_alsa_jack_inputdev_link; int ucm_set_profile(struct pa_alsa_ucm_config *ucm, const char *new_profile, const char *old_profile); void free_ucm(struct pa_alsa_ucm_config *ucm); @@ -45,6 +46,7 @@ int ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, int is_sink); void ucm_new_stream_role(pa_alsa_ucm_config *ucm, const char *role, int is_sink); void ucm_del_stream_role(pa_alsa_ucm_config *ucm, const char *role, int is_sink); +void ucm_jack_inputdev_probe(pa_hashmap* devs, pa_alsa_ucm_config *ucm); /* UCM modifier action direction */ enum { @@ -66,6 +68,7 @@ int n_suppdev; char **conflicting_devices; char **supported_devices; + pa_alsa_jack_inputdev_link *jack_inputdev_link; }; struct pa_alsa_ucm_modifier { Index: pulseaudio-1.1/src/modules/alsa/module-alsa-card.c =================================================================== --- pulseaudio-1.1.orig/src/modules/alsa/module-alsa-card.c 2012-02-16 17:49:05.360505051 +0800 +++ pulseaudio-1.1/src/modules/alsa/module-alsa-card.c 2012-02-16 17:49:05.376505051 +0800 @@ -640,6 +640,8 @@ u->profile_set->ignore_dB = ignore_dB; u->profile_set->jack_inputdevs = pa_alsa_jack_inputdev_enum(alsa_card_index); + if (u->use_ucm) + ucm_jack_inputdev_probe(u->profile_set->jack_inputdevs, &u->ucm); pa_alsa_profile_set_probe(u->profile_set, u->device_id, &m->core->default_sample_spec, m->core->default_n_fragments, m->core->default_fragment_size_msec); pa_alsa_profile_set_dump(u->profile_set); Index: pulseaudio-1.1/src/modules/alsa/alsa-jack-inputdev.c =================================================================== --- pulseaudio-1.1.orig/src/modules/alsa/alsa-jack-inputdev.c 2012-02-16 17:55:32.776505258 +0800 +++ pulseaudio-1.1/src/modules/alsa/alsa-jack-inputdev.c 2012-02-16 18:09:41.668505711 +0800 @@ -257,6 +257,29 @@ return NULL; } +pa_alsa_jack_inputdev_link* pa_alsa_jack_inputdev_match_ucm(pa_hashmap* devs, struct pa_alsa_ucm_device *ucm_dev) { + void *state; + pa_alsa_jack_inputdev *inputdev; + const char *dev_name; + pa_alsa_jack_inputdev_link *jil; + + dev_name = pa_proplist_gets(ucm_dev->proplist, PA_PROP_UCM_NAME); + + PA_HASHMAP_FOREACH(inputdev, devs, state) { + if (strstr(inputdev->devname, dev_name)) { + /* Found a match, let's add it! */ + jil = pa_xnew0(pa_alsa_jack_inputdev_link, 1); + jil->dev = inputdev; + jil->ucm_dev = ucm_dev; + jil->switches_enable = inputdev->switches_supported; + pa_hashmap_put(inputdev->links, jil, jil); + pa_log_info("Matched input device %s to ucm device %s", inputdev->devname, dev_name); + return jil; + } + } + return NULL; +} + static void jack_report(pa_alsa_jack_inputdev *dev, uint64_t bitmask, uint64_t bitvalue) { pa_alsa_jack_inputdev_link *jil; void* state; -- Wei.Feng (irc wei_feng) Linaro Multimedia Team Linaro.org???Open source software for ARM SoCs Follow?Linaro:?Facebook?|?Twitter?|?Blog