Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Jie Yang <yang.jie@intel.com>
Cc: alsa-devel@alsa-project.org, broonie@kernel.org,
	tanu.kaskinen@linux.intel.com, liam.r.girdwood@intel.com
Subject: Re: [PATCH v8 3/7] ALSA: jack: extend snd_jack_new to support phantom jack
Date: Wed, 22 Apr 2015 13:30:32 +0200	[thread overview]
Message-ID: <s5hd22wmmcn.wl-tiwai@suse.de> (raw)
In-Reply-To: <1429682633-10765-4-git-send-email-yang.jie@intel.com>

At Wed, 22 Apr 2015 14:03:49 +0800,
Jie Yang wrote:
> 
> diff --git a/sound/core/jack.c b/sound/core/jack.c
> index b13d0b1..6c729ef 100644
> --- a/sound/core/jack.c
> +++ b/sound/core/jack.c
> @@ -198,6 +198,9 @@ 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
> + *         input device
> + * @initial_kctl: create kctl if true, also add it to the non-phantom jack kctl list

Better to align with the actual argument order.

>   *
>   * Creates a new jack object.
>   *
> @@ -205,9 +208,10 @@ 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 initial_kctl, bool phantom_jack)
>  {
>  	struct snd_jack *jack;
> +	struct snd_jack_kctl *jack_kctl = NULL;
>  	int err;
>  	int i;
>  	static struct snd_device_ops ops = {
> @@ -216,26 +220,33 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
>  		.dev_disconnect = snd_jack_dev_disconnect,
>  	};
>  
> +	if (initial_kctl)
> +		jack_kctl = snd_jack_kctl_new(card, id, type);
> +

The function should return -ENOMEM if snd_jack_kctl_new() fails.

>  	jack = kzalloc(sizeof(struct snd_jack), GFP_KERNEL);
>  	if (jack == NULL)
>  		return -ENOMEM;
>  
>  	jack->id = kstrdup(id, GFP_KERNEL);
>  
> -	jack->input_dev = input_allocate_device();
> -	if (jack->input_dev == NULL) {
> -		err = -ENOMEM;
> -		goto fail_input;
> -	}
> +	/* don't creat input device for phantom jack */
> +	if (!phantom_jack) {
> +		jack->input_dev = input_allocate_device();
> +		if (jack->input_dev == NULL) {
> +			err = -ENOMEM;
> +			goto fail_input;
> +		}
>  
> -	jack->input_dev->phys = "ALSA";
> +		jack->input_dev->phys = "ALSA";
>  
> -	jack->type = type;
> +		jack->type = type;
>  
> -	for (i = 0; i < SND_JACK_SWITCH_TYPES; i++)
> -		if (type & (1 << i))
> -			input_set_capability(jack->input_dev, EV_SW,
> -					     jack_switch_types[i]);
> +		for (i = 0; i < SND_JACK_SWITCH_TYPES; i++)
> +			if (type & (1 << i))
> +				input_set_capability(jack->input_dev, EV_SW,
> +						     jack_switch_types[i]);
> +
> +	}
>  
>  	err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
>  	if (err < 0)
> @@ -244,6 +255,9 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
>  	jack->card = card;
>  	INIT_LIST_HEAD(&jack->kctl_list);
>  
> +	if (initial_kctl && jack_kctl)

... then here no need to check both.


Takashi

  reply	other threads:[~2015-04-22 11:30 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22  6:03 [PATCH v8 0/7] ALSA: jack: Refactoring for jack kctls Jie Yang
2015-04-22  6:03 ` [PATCH v8 1/7] ALSA: jack: implement kctl creating for jack device Jie Yang
2015-04-22 11:27   ` Takashi Iwai
2015-04-22 12:08     ` Jie, Yang
2015-04-22  6:03 ` [PATCH v8 2/7] ALSA: Jack: refactoring snd_kctl_jack_new to support embedded kctl Jie Yang
2015-04-22 11:32   ` Takashi Iwai
2015-04-22 12:40     ` Jie, Yang
2015-04-22 12:58       ` Takashi Iwai
2015-04-22 13:23         ` Jie, Yang
2015-04-22 13:56         ` Jie, Yang
2015-04-22 14:08           ` Takashi Iwai
2015-04-22 14:19             ` Jie, Yang
2015-04-22  6:03 ` [PATCH v8 3/7] ALSA: jack: extend snd_jack_new to support phantom jack Jie Yang
2015-04-22 11:30   ` Takashi Iwai [this message]
2015-04-22 12:49     ` Jie, Yang
2015-04-22  6:03 ` [PATCH v8 4/7] ALSA: hda - Update to use the new jack kctls method Jie Yang
2015-04-22  6:03 ` [PATCH v8 5/7] ASoC: jack: create kctls according to jack pins info Jie Yang
2015-04-22  6:03 ` [PATCH v8 6/7] ALSA: jack: remove exporting ctljack functions Jie Yang
2015-04-22  6:03 ` [PATCH v8 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=s5hd22wmmcn.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=tanu.kaskinen@linux.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