From: Takashi Iwai <tiwai@suse.de>
To: Jie Yang <yang.jie@intel.com>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
liam.r.girdwood@intel.com
Subject: Re: [PATCH v7 3/7] ALSA: jack: extend snd_jack_new to support phantom jack
Date: Tue, 21 Apr 2015 11:57:10 +0200 [thread overview]
Message-ID: <s5hoamhztvt.wl-tiwai@suse.de> (raw)
In-Reply-To: <1429603545-21063-4-git-send-email-yang.jie@intel.com>
At Tue, 21 Apr 2015 16:05:41 +0800,
Jie Yang wrote:
>
> For phantom jack, we won't create real jack device, but jack kctl
> may be needed.
>
> Here, we extend snd_jack_new() to support phantom jack creating:
> pass in a bool param for [non-]phantom flag, and a non-Null param
> (struct snd_jack_kctl **) to indicate that we need create kctl
> at this jack creating stage.
>
> We can also add kctl to a jack after the jack is created.
>
> This make the integrating the existing HDA jack kctl and soc jack
> kctl possible.
>
> Signed-off-by: Jie Yang <yang.jie@intel.com>
> ---
> include/sound/jack.h | 4 +--
> sound/core/jack.c | 56 +++++++++++++++++++++++++----------------
> sound/pci/hda/hda_jack.c | 2 +-
> sound/pci/oxygen/xonar_wm87x6.c | 2 +-
> sound/soc/soc-jack.c | 2 +-
> 5 files changed, 39 insertions(+), 27 deletions(-)
>
> diff --git a/include/sound/jack.h b/include/sound/jack.h
> index 9781e75..34b6849 100644
> --- a/include/sound/jack.h
> +++ b/include/sound/jack.h
> @@ -93,7 +93,7 @@ struct snd_jack_kctl {
> #ifdef CONFIG_SND_JACK
>
> int snd_jack_new(struct snd_card *card, const char *id, int type,
> - struct snd_jack **jack);
> + struct snd_jack **jack, bool phantom_jack, struct snd_jack_kctl **jjack_kctl);
> int snd_jack_add_new_kctl(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,
> @@ -103,7 +103,7 @@ void snd_jack_report(struct snd_jack *jack, int status);
>
> #else
> static inline int snd_jack_new(struct snd_card *card, const char *id, int type,
> - struct snd_jack **jack)
> + struct snd_jack **jack, bool phantom_jack, struct snd_jack_kctl **jjack_kctl)
> {
> return 0;
> }
> diff --git a/sound/core/jack.c b/sound/core/jack.c
> index b13d0b1..edd55c8 100644
> --- a/sound/core/jack.c
> +++ b/sound/core/jack.c
> @@ -198,6 +198,10 @@ EXPORT_SYMBOL(snd_jack_add_new_kctl);
> * @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.
> + * @phantom_jack: for phantom jack, only create needed kctl, won't create
> + * real jackdevice
> + * @jjack_kctl: create kctl if non-NULL pointer passed in, and provide it to
> + * the caller. also add it to the non-phantom jack kctl list
> *
> * Creates a new jack object.
> *
> @@ -205,7 +209,7 @@ EXPORT_SYMBOL(snd_jack_add_new_kctl);
> * 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, bool phantom_jack, struct snd_jack_kctl **jjack_kctl)
The caller doesn't need to get struct snd_jack_kctl. Instead, it's
better to get struct snd_kcontrol. In that way, you can move the
definition of struct snd_jack_kctl locally into jack.c. It's merely
an internal object only for jack after all.
> {
> struct snd_jack *jack;
> int err;
> @@ -216,35 +220,43 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
> .dev_disconnect = snd_jack_dev_disconnect,
> };
>
> - jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL);
> - if (jack == NULL)
> - return -ENOMEM;
> + if (jjack_kctl)
> + *jjack_kctl = snd_jack_kctl_new(card, id, type);
>
> - jack->id = kstrdup(id, GFP_KERNEL);
> + /* don't creat real jack device for phantom jack */
> + if (!phantom_jack) {
> + jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL);
We need to create a jack object even for a phantom jack. It's the
place managing the list of kctls. Otherwise we can't track these
kctls.
Just skip creating jack->input_dev for phantom jacks.
Takashi
next prev parent reply other threads:[~2015-04-21 9:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-21 8:05 [PATCH v7 0/7] ALSA: jack: Refactoring for jack kctls Jie Yang
2015-04-21 8:05 ` [PATCH v7 1/7] ALSA: jack: implement kctl creating for jack device Jie Yang
2015-04-21 8:05 ` [PATCH v7 2/7] ALSA: Jack: refactoring snd_kctl_jack_new to support embedded kctl Jie Yang
2015-04-21 9:53 ` Takashi Iwai
2015-04-22 0:51 ` Jie, Yang
2015-04-22 5:32 ` Takashi Iwai
2015-04-22 5:33 ` Jie, Yang
2015-04-21 8:05 ` [PATCH v7 3/7] ALSA: jack: extend snd_jack_new to support phantom jack Jie Yang
2015-04-21 9:57 ` Takashi Iwai [this message]
2015-04-22 2:06 ` Jie, Yang
2015-04-22 2:51 ` Jie, Yang
2015-04-21 8:05 ` [PATCH v7 4/7] ALSA: hda - Update to use the new jack kctls method Jie Yang
2015-04-21 9:58 ` Takashi Iwai
2015-04-22 4:56 ` Jie, Yang
2015-04-21 8:05 ` [PATCH v7 5/7] ASoC: jack: create kctls according to jack pins info Jie Yang
2015-04-21 8:05 ` [PATCH v7 6/7] ALSA: jack: remove exporting ctljack functions Jie Yang
2015-04-21 8:05 ` [PATCH v7 7/7] ALSA: Docs: Add documentation for Jack kcontrols Jie Yang
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=s5hoamhztvt.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=liam.r.girdwood@intel.com \
--cc=yang.jie@intel.com \
/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