From patchwork Tue Jun 5 02:38:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Wei X-Patchwork-Id: 9103 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 82C1E23E37 for ; Tue, 5 Jun 2012 02:39:08 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2BDBCA180F7 for ; Tue, 5 Jun 2012 02:39:08 +0000 (UTC) Received: by ghbz12 with SMTP id z12so4125455ghb.11 for ; Mon, 04 Jun 2012 19:39:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-forefront-antispam-report:x-spamscore:x-bigfish :x-fb-domain-ip-match:from:to:cc:subject:date:message-id:x-mailer :mime-version:content-type:x-originatororg:x-gm-message-state; bh=DMfiYZoVDiY3/GvBrh0oOY3L6UND8002uhH0mtL78jk=; b=IS9rlD8TOBrCyiH5E80vOjgPiLkaYONJQntydF0ZAEip6NZKMndK5cGngcal5tYdBA 7JD4URRy7zE1oJMqLefPCiEZqzgkT4Eq5T6lfoECKYa/e/XDLXDk8YeOdFunzwmadtIX rtL+osnpn6OJkGyi2jI/cDHVSTck5v/9ncScH8RKTXApAKQocnwPE0spEaM1unK/zWNd ZJPiarpSx6ox77PdwSXMgRxvEciNmKbBiD+xkIsbQjB9jj2E4+7FRL1ut0KGqQ2Qtg0b IIrGZUb+0+aWs/NcPq6GGyB7jPWWtGwseCUX4dhJftv/fw+6UQFBAWEIMxwoqIcxhwle dl8A== Received: by 10.50.193.196 with SMTP id hq4mr405452igc.57.1338863947556; Mon, 04 Jun 2012 19:39:07 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp265ibb; Mon, 4 Jun 2012 19:39:06 -0700 (PDT) Received: by 10.229.204.169 with SMTP id fm41mr4346287qcb.78.1338863945232; Mon, 04 Jun 2012 19:39:05 -0700 (PDT) Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe004.messaging.microsoft.com. [216.32.181.184]) by mx.google.com with ESMTPS id d9si460690qap.49.2012.06.04.19.38.59 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 04 Jun 2012 19:39:05 -0700 (PDT) Received-SPF: neutral (google.com: 216.32.181.184 is neither permitted nor denied by best guess record for domain of feng.wei@linaro.org) client-ip=216.32.181.184; Authentication-Results: mx.google.com; spf=neutral (google.com: 216.32.181.184 is neither permitted nor denied by best guess record for domain of feng.wei@linaro.org) smtp.mail=feng.wei@linaro.org Received: from mail211-ch1-R.bigfish.com (10.43.68.252) by CH1EHSOBE018.bigfish.com (10.43.70.68) with Microsoft SMTP Server id 14.1.225.23; Tue, 5 Jun 2012 02:38:17 +0000 Received: from mail211-ch1 (localhost [127.0.0.1]) by mail211-ch1-R.bigfish.com (Postfix) with ESMTP id 88A052202FA; Tue, 5 Jun 2012 02:38:17 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275dhz2dh87h2a8h668h839hd24he5bhe96hf0ah) X-FB-DOMAIN-IP-MATCH: fail Received: from mail211-ch1 (localhost.localdomain [127.0.0.1]) by mail211-ch1 (MessageSwitch) id 1338863895503708_22997; Tue, 5 Jun 2012 02:38:15 +0000 (UTC) Received: from CH1EHSMHS014.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.244]) by mail211-ch1.bigfish.com (Postfix) with ESMTP id 78E4C2E0047; Tue, 5 Jun 2012 02:38:15 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS014.bigfish.com (10.43.70.14) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 5 Jun 2012 02:38:15 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.2.298.5; Mon, 4 Jun 2012 21:38:55 -0500 Received: from wayne-Latitude-E6410.ap.freescale.net ([10.213.130.145]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id q552coGc002706; Mon, 4 Jun 2012 19:38:51 -0700 From: To: CC: , , , Feng Wei Subject: [RFC PATCH continued] PA2.0 UCM integration Date: Tue, 5 Jun 2012 10:38:22 +0800 Message-ID: <1338863902-8999-1-git-send-email-feng.wei@linaro.org> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-Gm-Message-State: ALoCoQlgpzpSNlDOOoNSQ1vKodXFQb6ODHF7SVgKqnjijmkdUjwUTCpZ58pgtEV0o/+F17tjLe2g From: Feng Wei UCM: make jack and port single direction. remove possibilities of dual direction jack and port Signed-off-by: Feng Wei --- 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; iucm_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 {