From patchwork Fri Mar 21 15:27:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 3875091 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 9FEF39F382 for ; Fri, 21 Mar 2014 15:33:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C85C420212 for ; Fri, 21 Mar 2014 15:33:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 91D8B201FD for ; Fri, 21 Mar 2014 15:32:58 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8F91026554D; Fri, 21 Mar 2014 16:32:57 +0100 (CET) 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 2AC30265469; Fri, 21 Mar 2014 16:29:11 +0100 (CET) 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 A9B2E265469; Fri, 21 Mar 2014 16:29:09 +0100 (CET) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by alsa0.perex.cz (Postfix) with ESMTP id 9EE3A26546B for ; Fri, 21 Mar 2014 16:28:26 +0100 (CET) Received: by mail-wi0-f180.google.com with SMTP id hn9so626330wib.7 for ; Fri, 21 Mar 2014 08:28:26 -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=ICBmX4FID8p+AIfPzCi20L1UrOPB6C6JAt8Yu/m9+Lc=; b=L9SAi9Yoy7PM9KLtzwgSRRo0tZFt2uz8+eb3GsB6z+z64xKS0uqPiBEM3HXzUNZQVc AGoItz3VhGiQA/R+1WdgTx+a7D4iIE24dXI1cnLWduvzYPGfI/gM2yBgmAiGWCQM0RQX 7gUAT65ozQ9RTWYc8SqGf0FolSD6DbPRSdSTolhqjrzBlO8d825y3YdvyLKYIzVaCkSw qdo9FC/W57JsOS6F4e2se68LOzm3ckGaPNcE57VwgjYqf+/7xQ438U/CRRN3tCA3TYge YVwPFZ7+l7WcdnqV61hGI6Uz7Y2CE3ar8ijExBp9vuzRfN1EAEMLEXjzU+2UIFcyu0h/ TDNw== X-Gm-Message-State: ALoCoQnp5Dcgh+uyIrEh0bAv2JHFTWDAFvOtTigJmcwwoTSmNIwosWVSlj4Xp7rSWOrxXUbicPfZ X-Received: by 10.180.106.40 with SMTP id gr8mr3114065wib.31.1395415706382; Fri, 21 Mar 2014 08:28:26 -0700 (PDT) Received: from homer.BUSINESSPOLE ([46.218.123.34]) by mx.google.com with ESMTPSA id q15sm14028573wjw.18.2014.03.21.08.28.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 21 Mar 2014 08:28:25 -0700 (PDT) From: Benoit Cousson To: broonie@kernel.org, lgirdwood@gmail.com Date: Fri, 21 Mar 2014 16:27:29 +0100 Message-Id: <1395415650-20045-6-git-send-email-bcousson@baylibre.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395415650-20045-1-git-send-email-bcousson@baylibre.com> References: <1395415650-20045-1-git-send-email-bcousson@baylibre.com> Cc: Fabien Parent , alsa-devel@alsa-project.org, lars@metafoo.de, Misael Lopez Cruz , Benoit Cousson Subject: [alsa-devel] [RFT v2 5/6] 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 | 74 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 76fdf43..cfa481e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1268,6 +1268,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) @@ -1275,38 +1332,27 @@ static int soc_post_component_init(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link = NULL; struct snd_soc_aux_dev *aux_dev = NULL; struct snd_soc_pcm_runtime *rtd; - const char *temp, *name; + const char *name; int ret = 0; if (!dailess) { 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; - - /* machine controls, routes and widgets are not prefixed */ - temp = codec->name_prefix; - codec->name_prefix = NULL; - /* 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; } - codec->name_prefix = temp; /* register the rtd device */ - rtd->codec = codec; - rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL); if (!rtd->dev) return -ENOMEM;