From patchwork Tue Jul 1 07:47:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 4456991 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DE73E9F26C for ; Tue, 1 Jul 2014 07:51:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30FC42017D for ; Tue, 1 Jul 2014 07:51:53 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E05A3201DE for ; Tue, 1 Jul 2014 07:51:51 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id D6B92265785; Tue, 1 Jul 2014 09:51:50 +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,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 18291265714; Tue, 1 Jul 2014 09:49:26 +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 D3A08265714; Tue, 1 Jul 2014 09:49:22 +0200 (CEST) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by alsa0.perex.cz (Postfix) with ESMTP id 20A8B2656FC for ; Tue, 1 Jul 2014 09:49:03 +0200 (CEST) Received: by mail-wi0-f180.google.com with SMTP id hi2so7225167wib.1 for ; Tue, 01 Jul 2014 00:49:02 -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=iNx85a3i4vrUl1OZo4+5xzR+oP5dA4tVIWHqWtsjNJU=; b=B5rNZ2hdJuQWXC6CU/uJA9nwYoitszPJcYOoWsS40lPxoRF2QCgMH790Ayzndsmg3d dl7A8P1tdEyN4C/wbkPPGXTRluZPfF8NZZnHuMtBd2QOuoPqIDDTy3w4/qfhGBxpZfBv /hnJZTP77GkndCD1iexd4e2Dctsn94MdL81GZfbEB5CkbtSIkeROOu0yPLfkZLlRMNOx VEh/QJ/GoN0slnTZtWb/Dlekg/iYjSIf8FexIwMyu+Dt5K2Sp6KqcKezQ+DYoqo3jC8N FZBEycO80UTh/ByCHZPZqy7ro2m9nT/umQ3pHacZZ3J92vgePatj0tY/SgOOmjEngu2m DMxA== X-Gm-Message-State: ALoCoQmhU/uN5Cg+wfSVWh4InGZWgTNw3xljIjt5lOUfVMULrM3/phcsldH/9h0pi13SPDIEC13f X-Received: by 10.180.206.144 with SMTP id lo16mr14564688wic.52.1404200942638; Tue, 01 Jul 2014 00:49:02 -0700 (PDT) Received: from localhost.localdomain (lau06-1-82-228-246-9.fbx.proxad.net. [82.228.246.9]) by mx.google.com with ESMTPSA id bq7sm40353720wib.7.2014.07.01.00.49.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Jul 2014 00:49:02 -0700 (PDT) From: Benoit Cousson To: broonie@kernel.org, lgirdwood@gmail.com, lars@metafoo.de Date: Tue, 1 Jul 2014 09:47:58 +0200 Message-Id: <1404200881-32253-6-git-send-email-bcousson@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404200881-32253-1-git-send-email-bcousson@baylibre.com> References: <1404200881-32253-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 v4 5/8] 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); }