From patchwork Fri Jul 4 16:07:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 4481861 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 AD6AABEEAA for ; Fri, 4 Jul 2014 16:11:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8E0B2038C for ; Fri, 4 Jul 2014 16:11:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0E1622022D for ; Fri, 4 Jul 2014 16:11:21 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 04CDF265A4C; Fri, 4 Jul 2014 18:11:20 +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 EED9E265A3A; Fri, 4 Jul 2014 18:10:10 +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 5D26D265A21; Fri, 4 Jul 2014 18:10:09 +0200 (CEST) Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by alsa0.perex.cz (Postfix) with ESMTP id A2E37265A13 for ; Fri, 4 Jul 2014 18:09:32 +0200 (CEST) Received: by mail-wg0-f47.google.com with SMTP id a1so54817wgh.18 for ; Fri, 04 Jul 2014 09:09:32 -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=Cc+omnn/NjqNzTtALJRoU739xYjVdY5W3gju6p+/Jag=; b=jBFNngfgnebIQ9mpDKf8IIRA6KelNeT4ztYoHbkGf9GebpV/q6Bcxo2lzeMNEiRIAN 9jEP/xbU/+vgA16lwcnIrrvzNi0aeBGiKH0fC/uBYUy6tM/4yOL4pTwD0RNruzgjnLEY 4xUxfZbGew6hPreemmwp7C+/OyN3zpD43eChKPbr0Dznk9wcLOd0/XHYtFoyaSvoyoQm V+GHiyRYjBqq1upDXSNM96REhnkVaY7eaatSSHa+gN1ZWVMEiWBqvTMs2rssuGWkjRZK 23BrbWQbuSsZLbFVYj2iBM2k81vJGIvkI15hGMu2xJNumdDzvjkS9Fl5+20+Hw32YcHO dXPA== X-Gm-Message-State: ALoCoQnX6zKPKUQ4OcT/8/YiMXdU9wLzDWWnBDLJUldRxaxXh2KR2+oFWv1MhnJGEV5eo56ZmwKR X-Received: by 10.180.149.175 with SMTP id ub15mr19086999wib.53.1404490172403; Fri, 04 Jul 2014 09:09:32 -0700 (PDT) Received: from localhost.localdomain ([46.218.123.34]) by mx.google.com with ESMTPSA id bx2sm69840593wjb.47.2014.07.04.09.09.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Jul 2014 09:09:31 -0700 (PDT) From: Benoit Cousson To: broonie@kernel.org, lgirdwood@gmail.com, lars@metafoo.de Date: Fri, 4 Jul 2014 18:07:53 +0200 Message-Id: <1404490075-24997-4-git-send-email-bcousson@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404490075-24997-1-git-send-email-bcousson@baylibre.com> References: <1404490075-24997-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 v5 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 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); }