From patchwork Fri Apr 3 12:07:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jie, Yang" X-Patchwork-Id: 6156071 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 34BBCBF4A6 for ; Fri, 3 Apr 2015 12:05:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 341E9203B6 for ; Fri, 3 Apr 2015 12:05:22 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E947C200E7 for ; Fri, 3 Apr 2015 12:05:20 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 285CF26598F; Fri, 3 Apr 2015 14:05:20 +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, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id E640E26588F; Fri, 3 Apr 2015 14:04:28 +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 C562926588B; Fri, 3 Apr 2015 14:04:27 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id BE47C265870 for ; Fri, 3 Apr 2015 14:04:18 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 03 Apr 2015 05:04:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,517,1422950400"; d="scan'208";a="476352360" Received: from keyon-u1310.sh.intel.com ([10.239.13.15]) by FMSMGA003.fm.intel.com with ESMTP; 03 Apr 2015 05:04:16 -0700 From: Jie Yang To: tiwai@suse.de Date: Fri, 3 Apr 2015 20:07:15 +0800 Message-Id: <1428062838-14786-3-git-send-email-yang.jie@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428062838-14786-1-git-send-email-yang.jie@intel.com> References: <1428062838-14786-1-git-send-email-yang.jie@intel.com> Cc: alsa-devel@alsa-project.org, broonie@kernel.org, liam.r.girdwood@intel.com Subject: [alsa-devel] [PATCH v4 2/5] ALSA: jack: add a parameter to pass kctl for snd_jack_new 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 Currentlly, for HDA jack, we will create jack kctl before calling snd_jack_new(). In our new design, this kctl should belong to the jack, so we add a param(struct snd_jack_kctl *) to pass the kctl, then we can add the kctl to jack during jack creating. This make our design more compatible with existing HDA jack kctl. Signed-off-by: Jie Yang --- include/sound/jack.h | 4 ++-- sound/core/jack.c | 11 +++++++++-- sound/pci/hda/hda_jack.c | 2 +- sound/pci/oxygen/xonar_wm87x6.c | 2 +- sound/soc/soc-jack.c | 2 +- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/sound/jack.h b/include/sound/jack.h index 07f7035..5b580f8 100644 --- a/include/sound/jack.h +++ b/include/sound/jack.h @@ -96,7 +96,7 @@ struct snd_jack_kctl { struct snd_jack_kctl * snd_jack_kctl_new(struct snd_card *card, const char *kctl_name, unsigned int mask); int snd_jack_new(struct snd_card *card, const char *id, int type, - struct snd_jack **jack); + struct snd_jack **jack, struct snd_jack_kctl *jack_kctl); int snd_jack_add_new_kctls(struct snd_jack *jack, const char * name, int mask); void snd_jack_set_parent(struct snd_jack *jack, struct device *parent); int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type, @@ -111,7 +111,7 @@ static inline struct snd_jack_kctl * snd_jack_kctl_new(struct snd_card *card, co } static inline int snd_jack_new(struct snd_card *card, const char *id, int type, - struct snd_jack **jack) + struct snd_jack **jack, struct snd_jack_kctl *jack_kctl) { return 0; } diff --git a/sound/core/jack.c b/sound/core/jack.c index c74111f..b6e7be1 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -205,6 +205,8 @@ EXPORT_SYMBOL(snd_jack_kctl_new); * @type: a bitmask of enum snd_jack_type values that can be detected by * this jack * @jjack: Used to provide the allocated jack object to the caller. + * @kctl: if kctl != NULL, it means we don't need create new kcontrol for this + * jack, just assign it to the jack. * * Creates a new jack object. * @@ -212,7 +214,7 @@ EXPORT_SYMBOL(snd_jack_kctl_new); * On success @jjack will be initialised. */ int snd_jack_new(struct snd_card *card, const char *id, int type, - struct snd_jack **jjack) + struct snd_jack **jjack, struct snd_jack_kctl *jack_kctl) { struct snd_jack *jack; int err; @@ -236,7 +238,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, } jack->input_dev->phys = "ALSA"; - + jack->card = card; jack->type = type; for (i = 0; i < SND_JACK_SWITCH_TYPES; i++) @@ -248,6 +250,11 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, if (err < 0) goto fail_input; + INIT_LIST_HEAD(&jack->kctl_list); + + if (jack_kctl) + snd_jack_kctl_add(jack, jack_kctl); + *jjack = jack; return 0; diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index e664307..9397250 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -417,7 +417,7 @@ static int __snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid, if (!phantom_jack) { jack->type = get_input_jack_type(codec, nid); err = snd_jack_new(codec->bus->card, name, jack->type, - &jack->jack); + &jack->jack, NULL); if (err < 0) return err; jack->jack->private_data = jack; diff --git a/sound/pci/oxygen/xonar_wm87x6.c b/sound/pci/oxygen/xonar_wm87x6.c index 6ce6860..d30ec63 100644 --- a/sound/pci/oxygen/xonar_wm87x6.c +++ b/sound/pci/oxygen/xonar_wm87x6.c @@ -286,7 +286,7 @@ static void xonar_ds_init(struct oxygen *chip) xonar_enable_output(chip); snd_jack_new(chip->card, "Headphone", - SND_JACK_HEADPHONE, &data->hp_jack); + SND_JACK_HEADPHONE, &data->hp_jack, NULL); xonar_ds_handle_hp_jack(chip); snd_component_add(chip->card, "WM8776"); diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 9f60c25..3c87e32 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -48,7 +48,7 @@ int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, INIT_LIST_HEAD(&jack->jack_zones); BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); - ret = snd_jack_new(card->snd_card, id, type, &jack->jack); + ret = snd_jack_new(card->snd_card, id, type, &jack->jack, NULL); if (ret) return ret;