aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-11-02 03:36:06 -0400
committerTakashi Iwai <tiwai@suse.de>2011-11-16 05:14:03 -0500
commit35be544af367170a9c6bf63adcf9d0cb2d569dbb (patch)
tree7bcd2dabde3b3f950916962edb5c601482c00335 /sound/core
parent3a93897ea37cbb8277f8a4232c12c0c18168a7db (diff)
ALSA: Introduce common helper functions for jack-detection control
Now move the helper function for creating and reporting the jack-detection to the common place. The driver that needs this functionality should select CONFIG_SND_KCTL_JACK kconfig. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/Kconfig3
-rw-r--r--sound/core/Makefile1
-rw-r--r--sound/core/ctljack.c55
3 files changed, 59 insertions, 0 deletions
diff --git a/sound/core/Kconfig b/sound/core/Kconfig
index 475455c76610..66f287f2f759 100644
--- a/sound/core/Kconfig
+++ b/sound/core/Kconfig
@@ -207,6 +207,9 @@ config SND_PCM_XRUN_DEBUG
207config SND_VMASTER 207config SND_VMASTER
208 bool 208 bool
209 209
210config SND_KCTL_JACK
211 bool
212
210config SND_DMA_SGBUF 213config SND_DMA_SGBUF
211 def_bool y 214 def_bool y
212 depends on X86 215 depends on X86
diff --git a/sound/core/Makefile b/sound/core/Makefile
index 350a08d277f4..b4637c3e776e 100644
--- a/sound/core/Makefile
+++ b/sound/core/Makefile
@@ -7,6 +7,7 @@ snd-y := sound.o init.o memory.o info.o control.o misc.o device.o
7snd-$(CONFIG_ISA_DMA_API) += isadma.o 7snd-$(CONFIG_ISA_DMA_API) += isadma.o
8snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o 8snd-$(CONFIG_SND_OSSEMUL) += sound_oss.o info_oss.o
9snd-$(CONFIG_SND_VMASTER) += vmaster.o 9snd-$(CONFIG_SND_VMASTER) += vmaster.o
10snd-$(CONFIG_SND_KCTL_JACK) += ctljack.o
10snd-$(CONFIG_SND_JACK) += jack.o 11snd-$(CONFIG_SND_JACK) += jack.o
11 12
12snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \ 13snd-pcm-objs := pcm.o pcm_native.o pcm_lib.o pcm_timer.o pcm_misc.o \
diff --git a/sound/core/ctljack.c b/sound/core/ctljack.c
new file mode 100644
index 000000000000..af0e78a3809c
--- /dev/null
+++ b/sound/core/ctljack.c
@@ -0,0 +1,55 @@
1/*
2 * Helper functions for jack-detection kcontrols
3 *
4 * Copyright (c) 2011 Takashi Iwai <tiwai@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 */
11
12#include <linux/kernel.h>
13#include <sound/core.h>
14#include <sound/control.h>
15
16#define jack_detect_kctl_info snd_ctl_boolean_mono_info
17
18static int jack_detect_kctl_get(struct snd_kcontrol *kcontrol,
19 struct snd_ctl_elem_value *ucontrol)
20{
21 ucontrol->value.integer.value[0] = kcontrol->private_value;
22 return 0;
23}
24
25static struct snd_kcontrol_new jack_detect_kctl = {
26 /* name is filled later */
27 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
28 .access = SNDRV_CTL_ELEM_ACCESS_READ,
29 .info = jack_detect_kctl_info,
30 .get = jack_detect_kctl_get,
31};
32
33struct snd_kcontrol *
34snd_kctl_jack_new(const char *name, int idx, void *private_data)
35{
36 struct snd_kcontrol *kctl;
37 kctl = snd_ctl_new1(&jack_detect_kctl, private_data);
38 if (!kctl)
39 return NULL;
40 snprintf(kctl->id.name, sizeof(kctl->id.name), "%s Jack", name);
41 kctl->id.index = idx;
42 kctl->private_value = 0;
43 return kctl;
44}
45EXPORT_SYMBOL_GPL(snd_kctl_jack_new);
46
47void snd_kctl_jack_report(struct snd_card *card,
48 struct snd_kcontrol *kctl, bool status)
49{
50 if (kctl->private_value == status)
51 return;
52 kctl->private_value = status;
53 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id);
54}
55EXPORT_SYMBOL_GPL(snd_kctl_jack_report);