Loading Documentation/sound/alsa/Jack-Controls.txt 0 → 100644 +43 −0 Original line number Diff line number Diff line Why we need Jack kcontrols ========================== ALSA uses kcontrols to export audio controls(switch, volume, Mux, ...) to user space. This means userspace applications like pulseaudio can switch off headphones and switch on speakers when no headphones are pluged in. The old ALSA jack code only created input devices for each registered jack. These jack input devices are not readable by userspace devices that run as non root. The new jack code creates embedded jack kcontrols for each jack that can be read by any process. This can be combined with UCM to allow userspace to route audio more intelligently based on jack insertion or removal events. Jack Kcontrol Internals ======================= Each jack will have a kcontrol list, so that we can create a kcontrol and attach it to the jack, at jack creation stage. We can also add a kcontrol to an existing jack, at anytime when required. Those kcontrols will be freed automatically when the Jack is freed. How to use jack kcontrols ========================= In order to keep compatibility, snd_jack_new() has been modified by adding two params :- - @initial_kctl: if true, create a kcontrol and add it to the jack list. - @phantom_jack: Don't create a input device for phantom jacks. HDA jacks can set phantom_jack to true in order to create a phantom jack and set initial_kctl to true to create an initial kcontrol with the correct id. ASoC jacks should set initial_kctl as false. The pin name will be assigned as the jack kcontrol name. include/sound/control.h +1 −1 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only); * Helper functions for jack-detection controls */ struct snd_kcontrol * snd_kctl_jack_new(const char *name, int idx, void *private_data); snd_kctl_jack_new(const char *name, struct snd_card *card); void snd_kctl_jack_report(struct snd_card *card, struct snd_kcontrol *kctl, bool status); Loading include/sound/jack.h +10 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -85,7 +87,8 @@ struct snd_jack { #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 initial_kctl, bool phantom_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); Loading @@ -93,9 +96,13 @@ 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) struct snd_jack **jack, bool initial_kctl, bool phantom_jack) { return 0; } static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask) { return 0; } Loading sound/core/Kconfig +0 −3 Original line number Diff line number Diff line Loading @@ -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 Loading sound/core/Makefile +1 −2 Original line number Diff line number Diff line Loading @@ -11,8 +11,7 @@ endif snd-$(CONFIG_ISA_DMA_API) += isadma.o snd-$(CONFIG_SND_OSSEMUL) += sound_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 snd-pcm-y := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ pcm_memory.o memalloc.o Loading Loading
Documentation/sound/alsa/Jack-Controls.txt 0 → 100644 +43 −0 Original line number Diff line number Diff line Why we need Jack kcontrols ========================== ALSA uses kcontrols to export audio controls(switch, volume, Mux, ...) to user space. This means userspace applications like pulseaudio can switch off headphones and switch on speakers when no headphones are pluged in. The old ALSA jack code only created input devices for each registered jack. These jack input devices are not readable by userspace devices that run as non root. The new jack code creates embedded jack kcontrols for each jack that can be read by any process. This can be combined with UCM to allow userspace to route audio more intelligently based on jack insertion or removal events. Jack Kcontrol Internals ======================= Each jack will have a kcontrol list, so that we can create a kcontrol and attach it to the jack, at jack creation stage. We can also add a kcontrol to an existing jack, at anytime when required. Those kcontrols will be freed automatically when the Jack is freed. How to use jack kcontrols ========================= In order to keep compatibility, snd_jack_new() has been modified by adding two params :- - @initial_kctl: if true, create a kcontrol and add it to the jack list. - @phantom_jack: Don't create a input device for phantom jacks. HDA jacks can set phantom_jack to true in order to create a phantom jack and set initial_kctl to true to create an initial kcontrol with the correct id. ASoC jacks should set initial_kctl as false. The pin name will be assigned as the jack kcontrol name.
include/sound/control.h +1 −1 Original line number Diff line number Diff line Loading @@ -252,7 +252,7 @@ void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only); * Helper functions for jack-detection controls */ struct snd_kcontrol * snd_kctl_jack_new(const char *name, int idx, void *private_data); snd_kctl_jack_new(const char *name, struct snd_card *card); void snd_kctl_jack_report(struct snd_card *card, struct snd_kcontrol *kctl, bool status); Loading
include/sound/jack.h +10 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -85,7 +87,8 @@ struct snd_jack { #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 initial_kctl, bool phantom_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); Loading @@ -93,9 +96,13 @@ 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) struct snd_jack **jack, bool initial_kctl, bool phantom_jack) { return 0; } static inline int snd_jack_add_new_kctl(struct snd_jack *jack, const char * name, int mask) { return 0; } Loading
sound/core/Kconfig +0 −3 Original line number Diff line number Diff line Loading @@ -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 Loading
sound/core/Makefile +1 −2 Original line number Diff line number Diff line Loading @@ -11,8 +11,7 @@ endif snd-$(CONFIG_ISA_DMA_API) += isadma.o snd-$(CONFIG_SND_OSSEMUL) += sound_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 snd-pcm-y := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ pcm_memory.o memalloc.o Loading