[alsa-devel] [PATCH v8 1/7] ALSA: jack: implement kctl creating for jack device

Takashi Iwai tiwai at suse.de
Wed Apr 22 13:27:56 CEST 2015


At Wed, 22 Apr 2015 14:03:47 +0800,
Jie Yang wrote:
> 
> Currently the ALSA jack core registers only input devices for each jack
> registered. These jack input devices are not readable by userspace devices
> that run as non root. This patch and the following series patches will
> implement kctls inside the core jack part, including kctls creating, status
> changing report, for both HD-Audio and ASoC jack. This allows non root
> userspace to read jack status and act on it.
> 
> This patch implement snd_jack_add_new_kctl(), which will create a kcontrol,
> add it to the card, and also attach it to the jack kctl list.
> 
> The patch also initial the jack kctl list after jack is newed, and report
> kctl status when doing jack report.
> 
> In the following patches, We will update snd_jack_new() to support phantom
> jack creating, and also enable a kcontrol creating at this jack new stage.
> After that, we can remove these part from HDA jack, and leave jack kctls
> handled by core part thoroughly.
> 
> Signed-off-by: Liam Girdwood <liam.r.girdwood at linux.intel.com>
> Modified-by: Jie Yang <yang.jie at intel.com>
> Signed-off-by: Jie Yang <yang.jie at intel.com>
> Reveiwed-by: Mark Brown <broonie at kernel.org>
> ---
>  include/sound/jack.h  |  15 +++++++-
>  sound/core/Kconfig    |   3 --
>  sound/core/Makefile   |   3 +-
>  sound/core/jack.c     | 104 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  sound/pci/hda/Kconfig |   1 -
>  5 files changed, 118 insertions(+), 8 deletions(-)
> 
> diff --git a/include/sound/jack.h b/include/sound/jack.h
> index 2182350..9781e75 100644
> --- a/include/sound/jack.h
> +++ b/include/sound/jack.h
> @@ -73,6 +73,8 @@ enum snd_jack_types {
>  
>  struct snd_jack {
>  	struct input_dev *input_dev;
> +	struct list_head kctl_list;
> +	struct snd_card *card;
>  	int registered;
>  	int type;
>  	const char *id;
> @@ -82,10 +84,17 @@ struct snd_jack {
>  	void (*private_free)(struct snd_jack *);
>  };
>  
> +struct snd_jack_kctl {
> +	struct snd_kcontrol *kctl;
> +	struct list_head list;		/* list of controls belong to the same jack */
> +	unsigned int mask_bits;	/* one of the corresponding bits of status change will report to this kctl */
> +};

This struct isn't referred outside jack.c, so we can move it to
jack.c.  This hides the internal implementation details.


>  #ifdef CONFIG_SND_JACK
>  
>  int snd_jack_new(struct snd_card *card, const char *id, int type,
>  		 struct snd_jack **jack);
> +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,
>  		     int keytype);
> @@ -93,13 +102,17 @@ int snd_jack_set_key(struct snd_jack *jack, enum snd_jack_types type,
>  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)
>  {
>  	return 0;
>  }
>  
> +static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask)
> +{
> +	return 0;
> +}
> +
>  static inline void snd_jack_set_parent(struct snd_jack *jack,
>  				       struct device *parent)
>  {
> diff --git a/sound/core/Kconfig b/sound/core/Kconfig
> index 313f22e..63cc2e9 100644
> --- a/sound/core/Kconfig
> +++ b/sound/core/Kconfig
> @@ -221,9 +221,6 @@ config SND_PCM_XRUN_DEBUG
>  config SND_VMASTER
>  	bool
>  
> -config SND_KCTL_JACK
> -	bool
> -
>  config SND_DMA_SGBUF
>  	def_bool y
>  	depends on X86
> diff --git a/sound/core/Makefile b/sound/core/Makefile
> index 4daf2f5..e041dc2 100644
> --- a/sound/core/Makefile
> +++ b/sound/core/Makefile
> @@ -7,8 +7,7 @@ snd-y     := sound.o init.o memory.o info.o control.o misc.o device.o
>  snd-$(CONFIG_ISA_DMA_API) += isadma.o
>  snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o
>  snd-$(CONFIG_SND_VMASTER) += vmaster.o
> -snd-$(CONFIG_SND_KCTL_JACK) += ctljack.o
> -snd-$(CONFIG_SND_JACK)	  += jack.o
> +snd-$(CONFIG_SND_JACK)	  += ctljack.o jack.o

I guess this breaks the build when CONFIG_SND_HDA_INPUT_JACK=n.


Takashi


More information about the Alsa-devel mailing list