From: Jie Yang <yang.jie@intel.com>
To: tiwai@suse.de
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
liam.r.girdwood@intel.com
Subject: [PATCH v4 2/5] ALSA: jack: add a parameter to pass kctl for snd_jack_new
Date: Fri, 3 Apr 2015 20:07:15 +0800 [thread overview]
Message-ID: <1428062838-14786-3-git-send-email-yang.jie@intel.com> (raw)
In-Reply-To: <1428062838-14786-1-git-send-email-yang.jie@intel.com>
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 <yang.jie@intel.com>
---
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;
--
1.9.1
next prev parent reply other threads:[~2015-04-03 12:04 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-03 12:07 [PATCH v4 0/5] ALSA: jack: Refactoring for jack kctls Jie Yang
2015-04-03 12:07 ` [PATCH v4 1/5] ALSA: jack: create jack kcontrols for every jack input Jie Yang
2015-04-03 12:07 ` Jie Yang [this message]
2015-04-03 12:07 ` [PATCH v4 3/5] ALSA: hda - Update to use the new jack kctls method Jie Yang
2015-04-03 12:07 ` [PATCH v4 4/5] ASoC: jack: create kctls according to jack pins info Jie Yang
2015-04-03 12:07 ` [PATCH v4 5/5] ALSA: jack: remove export snd_kctl_jack_new() Jie Yang
2015-04-06 16:11 ` [PATCH v4 0/5] ALSA: jack: Refactoring for jack kctls Mark Brown
2015-04-07 16:06 ` Takashi Iwai
2015-04-08 2:53 ` Jie, Yang
2015-04-08 4:39 ` Raymond Yau
2015-04-08 7:20 ` David Henningsson
2015-04-08 7:34 ` Takashi Iwai
2015-04-08 7:49 ` David Henningsson
2015-04-08 7:59 ` Jie, Yang
2015-04-08 8:27 ` David Henningsson
2015-04-08 9:18 ` Jie, Yang
2015-04-08 9:22 ` Takashi Iwai
2015-04-08 14:14 ` Jie, Yang
2015-04-08 14:29 ` Takashi Iwai
2015-04-08 18:47 ` David Henningsson
2015-04-08 18:55 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1428062838-14786-3-git-send-email-yang.jie@intel.com \
--to=yang.jie@intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=liam.r.girdwood@intel.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox