From patchwork Sun Feb 15 01:22:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 5829031 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D8A619F336 for ; Sun, 15 Feb 2015 01:23:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC863201BC for ; Sun, 15 Feb 2015 01:23:38 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id D388D2020E for ; Sun, 15 Feb 2015 01:23:33 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E9BAD2604EE; Sun, 15 Feb 2015 02:23:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 47BE5260492; Sun, 15 Feb 2015 02:23:24 +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 A5249260498; Sun, 15 Feb 2015 02:23:22 +0100 (CET) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by alsa0.perex.cz (Postfix) with ESMTP id A9434260488 for ; Sun, 15 Feb 2015 02:23:15 +0100 (CET) Received: by mail-pa0-f50.google.com with SMTP id hz1so26999010pad.9 for ; Sat, 14 Feb 2015 17:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=GvXmG9WF7X9RTxXsxcM9N5Oadvy8VhF2oB+7bA1zxIc=; b=GZzQ1DFgUKNFfwkf8KEydnTsUGeevXIUerzNvrpGpC9s9+Oe/GBWfsaL0fXr92i4Bg etjSdlc+/wPRAMB4XCHoBG4L/mqGBb+nw1gZuX/wt6M4qVfI9ouqwDTaTx2mIWAp6kMm itX26CZJTohJsfj21sqroxD2e0YT129F5c3axwfe9R09nUqbsSNonMVQJm5tX0ZzmH0J Y9pD0z2mEAqE9fvnBBkDzDi9zvaC+BIYNkhmdXVccZaRAaLkV0yPxp/imaik/SZceofn 8LE0Sv+eIGvtCeTKnG5aqF7jy6H3y6SHDm8ek2DJ6kqv0//FAU6/iPdEvQXPCvkq4Jb8 WsiA== X-Received: by 10.70.88.39 with SMTP id bd7mr16936628pdb.83.1423963394329; Sat, 14 Feb 2015 17:23:14 -0800 (PST) Received: from Alpha.attlocal.net (99-189-113-45.lightspeed.sntcca.sbcglobal.net. [99.189.113.45]) by mx.google.com with ESMTPSA id uu10sm10536826pbc.52.2015.02.14.17.23.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Feb 2015 17:23:13 -0800 (PST) From: Nicolin Chen To: broonie@kernel.org Date: Sat, 14 Feb 2015 17:22:49 -0800 Message-Id: <15b0ecaefffcd48bb5f56fe76326d705c3467438.1423963314.git.nicoleotsuka@gmail.com> X-Mailer: git-send-email 1.9.1 Cc: tiwai@suse.de, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, lgirdwood@gmail.com Subject: [alsa-devel] [PATCH 1/2] ASoC: core: Add extra dapm properties for Device Tree 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 The current helper functions, snd_soc_of_parse_audio_simple_widgets() and snd_soc_of_parse_audio_routing(), set dapm_widgets and dapm_routes without caring if they are already set by using build-in widgets and routes in the card driver. So there could be one of them, build-in one or Device Tree one, overrided by the other depending on which one was assigned later. This patch adds an extra pair of dapm_widgets and dapm_routes for DT use only so as to prevent unexpected overriding. Signed-off-by: Nicolin Chen --- include/sound/soc.h | 5 +++++ sound/soc/soc-core.c | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index ac8b333..7443062 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1068,11 +1068,16 @@ struct snd_soc_card { /* * Card-specific routes and widgets. + * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in. */ const struct snd_soc_dapm_widget *dapm_widgets; int num_dapm_widgets; const struct snd_soc_dapm_route *dapm_routes; int num_dapm_routes; + const struct snd_soc_dapm_widget *of_dapm_widgets; + int num_of_dapm_widgets; + const struct snd_soc_dapm_route *of_dapm_routes; + int num_of_dapm_routes; bool fully_routed; struct work_struct deferred_resume_work; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c024962..2695a12 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1486,6 +1486,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, card->num_dapm_widgets); + if (card->of_dapm_widgets) + snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets, + card->num_of_dapm_widgets); + /* initialise the sound card only once */ if (card->probe) { ret = card->probe(card); @@ -1541,6 +1545,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, card->num_dapm_routes); + if (card->of_dapm_routes) + snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes, + card->num_of_dapm_routes); + for (i = 0; i < card->num_links; i++) { struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; dai_link = &card->dai_link[i]; @@ -3187,8 +3195,8 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card, widgets[i].name = wname; } - card->dapm_widgets = widgets; - card->num_dapm_widgets = num_widgets; + card->of_dapm_widgets = widgets; + card->num_of_dapm_widgets = num_widgets; return 0; } @@ -3272,8 +3280,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, } } - card->num_dapm_routes = num_routes; - card->dapm_routes = routes; + card->num_of_dapm_routes = num_routes; + card->of_dapm_routes = routes; return 0; }