From patchwork Tue Sep 2 12:35:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Subhransu S. Prusty" X-Patchwork-Id: 4826191 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 796DF9F2ED for ; Tue, 2 Sep 2014 14:21:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B4282016C for ; Tue, 2 Sep 2014 14:21:05 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A1C98200ED for ; Tue, 2 Sep 2014 14:21:03 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 50780265572; Tue, 2 Sep 2014 16:21:02 +0200 (CEST) Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 751C2265529; Tue, 2 Sep 2014 15:09:13 +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 33628265532; Tue, 2 Sep 2014 15:09:12 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by alsa0.perex.cz (Postfix) with ESMTP id 2BF7A265529 for ; Tue, 2 Sep 2014 14:58:32 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 02 Sep 2014 05:58:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,449,1406617200"; d="scan'208";a="567123851" Received: from subhransu-udesk1.iind.intel.com ([10.223.96.40]) by orsmga001.jf.intel.com with ESMTP; 02 Sep 2014 05:58:30 -0700 From: "Subhransu S. Prusty" To: alsa-devel@alsa-project.org Date: Tue, 2 Sep 2014 18:05:58 +0530 Message-Id: <1409661367-19047-4-git-send-email-subhransu.s.prusty@intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1409661367-19047-1-git-send-email-subhransu.s.prusty@intel.com> References: <1409661367-19047-1-git-send-email-subhransu.s.prusty@intel.com> Cc: vinod.koul@intel.com, broonie@kernel.org, "Subhransu S. Prusty" , lgirdwood@gmail.com, Lars-Peter Clausen Subject: [alsa-devel] [PATCH v5 03/12] ALSA: control: Add init callback for kcontrol 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some controls need to initialize stuffs like pvt data, so they need a callback if the control creation is successful. Signed-off-by: Subhransu S. Prusty Signed-off-by: Vinod Koul --- include/sound/control.h | 3 +++ sound/core/control.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/include/sound/control.h b/include/sound/control.h index 0426139..1389f69 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -30,6 +30,7 @@ struct snd_kcontrol; typedef int (snd_kcontrol_info_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo); typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); +typedef int (snd_kcontrol_init_t) (struct snd_kcontrol * kcontrol); typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol, int op_flag, /* SNDRV_CTL_TLV_OP_XXX */ unsigned int size, @@ -52,6 +53,7 @@ struct snd_kcontrol_new { snd_kcontrol_info_t *info; snd_kcontrol_get_t *get; snd_kcontrol_put_t *put; + snd_kcontrol_init_t *init; union { snd_kcontrol_tlv_rw_t *c; const unsigned int *p; @@ -71,6 +73,7 @@ struct snd_kcontrol { snd_kcontrol_info_t *info; snd_kcontrol_get_t *get; snd_kcontrol_put_t *put; + snd_kcontrol_init_t *init; union { snd_kcontrol_tlv_rw_t *c; const unsigned int *p; diff --git a/sound/core/control.c b/sound/core/control.c index b961134..9d30663 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -256,6 +256,7 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, kctl.info = ncontrol->info; kctl.get = ncontrol->get; kctl.put = ncontrol->put; + kctl.init = ncontrol->init; kctl.tlv.p = ncontrol->tlv.p; kctl.private_value = ncontrol->private_value; kctl.private_data = private_data; @@ -362,6 +363,12 @@ int snd_ctl_add(struct snd_card *card, struct snd_kcontrol *kcontrol) err = -ENOMEM; goto error; } + if (kcontrol->init) { + err = kcontrol->init(kcontrol); + if (err < 0) + goto error; + } + list_add_tail(&kcontrol->list, &card->controls); card->controls_count += kcontrol->count; kcontrol->id.numid = card->last_numid + 1;