From patchwork Thu Apr 24 12:01:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 4050141 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 9F27E9F1F4 for ; Thu, 24 Apr 2014 12:04:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6C15202FF for ; Thu, 24 Apr 2014 12:04:01 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 75B322017D for ; Thu, 24 Apr 2014 12:04:00 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 4E0282652C1; Thu, 24 Apr 2014 14:03:59 +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 722322652D7; Thu, 24 Apr 2014 14:03:05 +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 BAB232652DA; Thu, 24 Apr 2014 14:03:03 +0200 (CEST) Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com [74.125.82.52]) by alsa0.perex.cz (Postfix) with ESMTP id 3523626524C for ; Thu, 24 Apr 2014 14:02:22 +0200 (CEST) Received: by mail-wg0-f52.google.com with SMTP id b13so948751wgh.35 for ; Thu, 24 Apr 2014 05:02:22 -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=/5MK84LenU5ZpW3SyauB8tU6sWUI4qzMLLzrKDhA97M=; b=eoN2c4VxIbgrhcOGVfWjBKVMkHEZxMEgNlV0PqWQjDYZjBwJiss5m4WcLWHF49nAU3 hv0xgso+LRVQMAFAZe5S4CIrn+eQlndIzGErK5TuzQD42zXownEn30UIe7OGYJUXaHNb PwIFGgGtNdAg4n+QZXrTIEvCqSOJVlCYTMAQl78FGgm9Hmkx8OZxFwzTYguUy30kwG4k iA8U/bH7jnwC0p+5L8sIJTsgUiaQ2uINTI+ajlKGn579wuSf6dqywHSSpJVlkbj4OsNw uuk6ZwPqQO0mNk0FPFAxGUM4/jyPZAnCC5pyJeUQamp+liNeU0iZM5BSVTvUD7O1q9lx htwA== X-Gm-Message-State: ALoCoQn49FWmnRMk6SbXWzdw8wAdZq0fUh8ZyFK1OJ1JP1Qhfsrl6KfhO7oS0DCrb1skoT1GUWIp X-Received: by 10.180.211.207 with SMTP id ne15mr6080106wic.31.1398340941920; Thu, 24 Apr 2014 05:02:21 -0700 (PDT) Received: from localhost.localdomain ([46.218.123.34]) by mx.google.com with ESMTPSA id wl6sm5926963wjb.3.2014.04.24.05.02.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Apr 2014 05:02:21 -0700 (PDT) From: Benoit Cousson To: broonie@kernel.org, lgirdwood@gmail.com, lars@metafoo.de Date: Thu, 24 Apr 2014 14:01:44 +0200 Message-Id: <1398340906-5017-2-git-send-email-bcousson@baylibre.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398340906-5017-1-git-send-email-bcousson@baylibre.com> References: <1398340906-5017-1-git-send-email-bcousson@baylibre.com> Cc: Fabien Parent , misael.lopez@ti.com, alsa-devel@alsa-project.org, Benoit Cousson Subject: [alsa-devel] [RFT v3 1/3] ASoC: core: Add helpers for dai link and aux dev init 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 From: Misael Lopez Cruz Separate DAI link and aux dev initialization in preparation for DAI multicodec support. Since aux dev will remain using single codecs but DAI links will be able to support multiple codecs. No functional change. Signed-off-by: Misael Lopez Cruz [fparent@baylibre.com: Adapt to 3.14+] Signed-off-by: Fabien Parent Signed-off-by: Benoit Cousson --- sound/soc/soc-core.c | 67 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 980da92..f18112a 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1266,6 +1266,63 @@ static void rtd_release(struct device *dev) kfree(dev); } +static int soc_aux_dev_init(struct snd_soc_card *card, + struct snd_soc_codec *codec, + int num) +{ + struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; + struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; + const char *temp; + int ret; + + rtd->card = card; + + temp = codec->name_prefix; + codec->name_prefix = NULL; + + /* do machine specific initialization */ + if (aux_dev->init) { + ret = aux_dev->init(&codec->dapm); + if (ret < 0) + return ret; + } + + codec->name_prefix = temp; + + rtd->codec = codec; + + return 0; +} + +static int soc_dai_link_init(struct snd_soc_card *card, + struct snd_soc_codec *codec, + int num) +{ + struct snd_soc_dai_link *dai_link = &card->dai_link[num]; + struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; + const char *temp; + int ret; + + rtd->card = card; + + /* machine controls, routes and widgets are not prefixed */ + temp = codec->name_prefix; + codec->name_prefix = NULL; + + /* do machine specific initialization */ + if (dai_link->init) { + ret = dai_link->init(rtd); + if (ret < 0) + return ret; + } + + codec->name_prefix = temp; + + rtd->codec = codec; + + return 0; +} + static int soc_post_component_init(struct snd_soc_card *card, struct snd_soc_codec *codec, int num, int dailess) @@ -1280,26 +1337,20 @@ static int soc_post_component_init(struct snd_soc_card *card, dai_link = &card->dai_link[num]; rtd = &card->rtd[num]; name = dai_link->name; + ret = soc_dai_link_init(card, codec, num); } else { aux_dev = &card->aux_dev[num]; rtd = &card->rtd_aux[num]; name = aux_dev->name; + ret = soc_aux_dev_init(card, codec, num); } - rtd->card = card; - /* do machine specific initialization */ - if (!dailess && dai_link->init) - ret = dai_link->init(rtd); - else if (dailess && aux_dev->init) - ret = aux_dev->init(&codec->dapm); if (ret < 0) { dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret); return ret; } /* register the rtd device */ - rtd->codec = codec; - rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL); if (!rtd->dev) return -ENOMEM;