From patchwork Thu Apr 16 20:48:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Girdwood X-Patchwork-Id: 6227761 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 95DAF9F2EC for ; Thu, 16 Apr 2015 20:50:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9D4FB202A1 for ; Thu, 16 Apr 2015 20:50:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 5397C2010F for ; Thu, 16 Apr 2015 20:50:30 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 836DD2652D1; Thu, 16 Apr 2015 22:50:29 +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 21E6F261A5A; Thu, 16 Apr 2015 22:49:03 +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 C031C264F07; Thu, 16 Apr 2015 22:49:01 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by alsa0.perex.cz (Postfix) with ESMTP id 2A1A22652CF for ; Thu, 16 Apr 2015 22:48:37 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 16 Apr 2015 13:48:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,590,1422950400"; d="scan'208";a="557316206" Received: from dmcadam-mobl.ger.corp.intel.com (HELO [10.252.22.40]) ([10.252.22.40]) by orsmga003.jf.intel.com with ESMTP; 16 Apr 2015 13:48:35 -0700 Message-ID: <1429217321.7100.21.camel@loki> From: Liam Girdwood To: Takashi Iwai , Mark Brown , "Koul, Vinod" Date: Thu, 16 Apr 2015 21:48:41 +0100 X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Cc: "alsa-devel@alsa-project.org" Subject: [alsa-devel] [RFC 3/4] ASoC: topology: Add topology support to ASoC core and DAPM. 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add dynamic object support to ASoC kcontrols, widgets, components and cards. Remove all dynamic objects on sound card removal and DAPM free. Signed-off-by: Liam Girdwood --- include/sound/soc-dapm.h | 2 ++ include/sound/soc.h | 11 +++++++++++ sound/soc/soc-core.c | 4 ++++ sound/soc/soc-dapm.c | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 3263e36..8d28b36 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -15,6 +15,7 @@ #include #include +#include #include struct device; @@ -533,6 +534,7 @@ struct snd_soc_dapm_widget { int num_kcontrols; const struct snd_kcontrol_new *kcontrol_news; struct snd_kcontrol **kcontrols; + struct snd_soc_dobj dobj; /* widget input and outputs */ struct list_head sources; diff --git a/include/sound/soc.h b/include/sound/soc.h index 0d1ade1..e7bc994 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -27,6 +27,7 @@ #include #include #include +#include /* * Convenience kcontrol builders @@ -753,6 +754,9 @@ struct snd_soc_component { struct mutex io_mutex; + /* attached dynamic objects */ + struct list_head dobj_list; + #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_root; #endif @@ -1088,6 +1092,9 @@ struct snd_soc_card { struct list_head dapm_list; struct list_head dapm_dirty; + /* attached dynamic objects */ + struct list_head dobj_list; + /* Generic DAPM context for the card */ struct snd_soc_dapm_context dapm; struct snd_soc_dapm_stats dapm_stats; @@ -1147,6 +1154,7 @@ struct soc_mixer_control { unsigned int sign_bit; unsigned int invert:1; unsigned int autodisable:1; + struct snd_soc_dobj dobj; }; struct soc_bytes { @@ -1157,6 +1165,8 @@ struct soc_bytes { struct soc_bytes_ext { int max; + struct snd_soc_dobj dobj; + /* used for TLV byte control */ int (*get)(unsigned int __user *bytes, unsigned int size); int (*put)(const unsigned int __user *bytes, unsigned int size); @@ -1177,6 +1187,7 @@ struct soc_enum { unsigned int mask; const char * const *texts; const unsigned int *values; + struct snd_soc_dobj dobj; }; /** diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9dfa2e2..3a6ae19 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #define CREATE_TRACE_POINTS @@ -2434,6 +2435,7 @@ int snd_soc_register_card(struct snd_soc_card *card) card->rtd_aux[i].card = card; INIT_LIST_HEAD(&card->dapm_dirty); + INIT_LIST_HEAD(&card->dobj_list); card->instantiated = 0; mutex_init(&card->mutex); mutex_init(&card->dapm_mutex); @@ -2748,6 +2750,7 @@ static void snd_soc_component_add_unlocked(struct snd_soc_component *component) } list_add(&component->list, &component_list); + INIT_LIST_HEAD(&component->dobj_list); } static void snd_soc_component_add(struct snd_soc_component *component) @@ -2824,6 +2827,7 @@ void snd_soc_unregister_component(struct device *dev) return; found: + snd_soc_tplg_component_remove(cmpnt, SND_SOC_TPLG_ID_ALL); snd_soc_component_del_unlocked(cmpnt); mutex_unlock(&client_mutex); snd_soc_component_cleanup(cmpnt); diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 86d350a..c768e02 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -2165,6 +2166,9 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm) list_for_each_entry_safe(p, next_p, &w->sinks, list_source) dapm_free_path(p); + /* check and free and dynamic widget kcontrols */ + snd_soc_tplg_widget_remove(w); + kfree(w->kcontrols); kfree(w->name); kfree(w);