From patchwork Tue Jul 8 21:19:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 4510081 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6FA59BEEAA for ; Tue, 8 Jul 2014 21:23:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43E852026D for ; Tue, 8 Jul 2014 21:23:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A5EF9201E4 for ; Tue, 8 Jul 2014 21:23:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6F3AD264EBF; Tue, 8 Jul 2014 23:23:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id CA524261A9C; Tue, 8 Jul 2014 23:21:33 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9FDC9261A9C; Tue, 8 Jul 2014 23:21:32 +0200 (CEST) Received: from mail-we0-f170.google.com (mail-we0-f170.google.com [74.125.82.170]) by alsa0.perex.cz (Postfix) with ESMTP id CA643261B07 for ; Tue, 8 Jul 2014 23:20:53 +0200 (CEST) Received: by mail-we0-f170.google.com with SMTP id w61so6525305wes.29 for ; Tue, 08 Jul 2014 14:20:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cePgz1d9VCgARTBO67o5UEnKi09G7iopazVcvmiW31I=; b=E/qxXAQtOzb/NJCjKyFusUQ2aWz7UELurZxOKCz/NZa89X/WAwxAHWfaiDln++Yejx aZbXgyM7pjE/U/HObDzwknsvkOGcgJTz2C1o8eEpT5UJaJg6UtWLbMf2DqByfd+th8tW hR7orcJKPG0ltpUbZvS0X69nj7Byuu3CVsbQKfPUBn3h7T4C2lFbEvUBEVovJjtKi1BE Oqcz0Y7dV9XFOHGgXGJZzy0DhLyN6X9yZBCt/s1nADgoXK0LDXtS3uSnmltAQIGrm9iB 7ct2oMR9wBiEtLpAuRpSAi+kdvXZi/iIZbN70z8EP4nJCHLPb3kqQ/19w13RTRw6wToM oakg== X-Gm-Message-State: ALoCoQmTwl0r+uTySYPdJ7G1Fma+CfySMUDp6wGA+uDGjP1F7HIoPsbkdTYy37fV7UNtGdUO7Rki X-Received: by 10.180.228.106 with SMTP id sh10mr6662631wic.51.1404854453564; Tue, 08 Jul 2014 14:20:53 -0700 (PDT) Received: from localhost.localdomain ([90.84.144.69]) by mx.google.com with ESMTPSA id lq17sm11295135wic.19.2014.07.08.14.20.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Jul 2014 14:20:52 -0700 (PDT) From: Benoit Cousson To: broonie@kernel.org, lgirdwood@gmail.com, lars@metafoo.de Date: Tue, 8 Jul 2014 23:19:36 +0200 Message-Id: <1404854378-25828-4-git-send-email-bcousson@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404854378-25828-1-git-send-email-bcousson@baylibre.com> References: <1404854378-25828-1-git-send-email-bcousson@baylibre.com> Cc: Fabien Parent , misael.lopez@ti.com, alsa-devel@alsa-project.org, Benoit Cousson Subject: [alsa-devel] [PATCH v6 3/5] ASoC: dapm: Add support for DAI multicodec X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add multicodec support in soc-dapm.c Signed-off-by: Benoit Cousson Signed-off-by: Misael Lopez Cruz Signed-off-by: Fabien Parent Tested-by: Lars-Peter Clausen Reviewed-by: Lars-Peter Clausen --- sound/soc/soc-dapm.c | 67 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 4bf08cf..5c63c3b 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2084,12 +2084,8 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, } EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power); -/* show dapm widget status in sys fs */ -static ssize_t dapm_widget_show(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t dapm_widget_show_codec(struct snd_soc_codec *codec, char *buf) { - struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); - struct snd_soc_codec *codec =rtd->codec; struct snd_soc_dapm_widget *w; int count = 0; char *state = "not set"; @@ -2142,6 +2138,21 @@ static ssize_t dapm_widget_show(struct device *dev, return count; } +/* show dapm widget status in sys fs */ +static ssize_t dapm_widget_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); + int i, count = 0; + + for (i = 0; i < rtd->num_codecs; i++) { + struct snd_soc_codec *codec = rtd->codec_dais[i]->codec; + count += dapm_widget_show_codec(codec, buf + count); + } + + return count; +} + static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); int snd_soc_dapm_sys_add(struct device *dev) @@ -3395,25 +3406,18 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) return 0; } -void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) +static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, + struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_pcm_runtime *rtd = card->rtd; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dapm_widget *sink, *source; - struct snd_soc_dai *cpu_dai, *codec_dai; + struct snd_soc_dapm_route r; int i; - /* for each BE DAI link... */ - for (i = 0; i < card->num_rtd; i++) { - rtd = &card->rtd[i]; - cpu_dai = rtd->cpu_dai; - codec_dai = rtd->codec_dai; + memset(&r, 0, sizeof(r)); - /* - * dynamic FE links have no fixed DAI mapping. - * CODEC<->CODEC links have no direct connection. - */ - if (rtd->dai_link->dynamic || rtd->dai_link->params) - continue; + for (i = 0; i < rtd->num_codecs; i++) { + struct snd_soc_dai *codec_dai = rtd->codec_dais[i]; /* there is no point in connecting BE DAI links with dummies */ if (snd_soc_dai_is_dummy(codec_dai) || @@ -3475,11 +3479,34 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream, } } +void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) +{ + struct snd_soc_pcm_runtime *rtd = card->rtd; + int i; + + /* for each BE DAI link... */ + for (i = 0; i < card->num_rtd; i++) { + rtd = &card->rtd[i]; + + /* + * dynamic FE links have no fixed DAI mapping. + * CODEC<->CODEC links have no direct connection. + */ + if (rtd->dai_link->dynamic || rtd->dai_link->params) + continue; + + dapm_connect_dai_link_widgets(card, rtd); + } +} + static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, int event) { + int i; + soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event); - soc_dapm_dai_stream_event(rtd->codec_dai, stream, event); + for (i = 0; i < rtd->num_codecs; i++) + soc_dapm_dai_stream_event(rtd->codec_dais[i], stream, event); dapm_power_widgets(rtd->card, event); }