aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2009-03-23 19:35:43 -0400
committerTakashi Iwai <tiwai@suse.de>2009-03-23 19:35:43 -0400
commit5b56eec77498f15317f3ff5ac9101372f400c859 (patch)
tree1acfb40ca6a19323a292131aa7fca68ef4ef330b
parentc2f43981e5dbc92884149aa2234064cc2c340acd (diff)
parent662c319ae4b4fb60001816dfe1dde5fdfc7a2af9 (diff)
Merge branch 'topic/jack' into for-linus
-rw-r--r--Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl3
-rw-r--r--include/linux/input.h1
-rw-r--r--include/sound/jack.h5
-rw-r--r--sound/core/jack.c45
4 files changed, 30 insertions, 24 deletions
diff --git a/Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl b/Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl
index 9d644f7e241e..37b006cdf2f9 100644
--- a/Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl
+++ b/Documentation/sound/alsa/DocBook/alsa-driver-api.tmpl
@@ -89,6 +89,9 @@
89 <sect1><title>Hardware-Dependent Devices API</title> 89 <sect1><title>Hardware-Dependent Devices API</title>
90!Esound/core/hwdep.c 90!Esound/core/hwdep.c
91 </sect1> 91 </sect1>
92 <sect1><title>Jack Abstraction Layer API</title>
93!Esound/core/jack.c
94 </sect1>
92 <sect1><title>ISA DMA Helpers</title> 95 <sect1><title>ISA DMA Helpers</title>
93!Esound/core/isadma.c 96!Esound/core/isadma.c
94 </sect1> 97 </sect1>
diff --git a/include/linux/input.h b/include/linux/input.h
index 1249a0c20a38..6b28048fc568 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -661,6 +661,7 @@ struct input_absinfo {
661#define SW_DOCK 0x05 /* set = plugged into dock */ 661#define SW_DOCK 0x05 /* set = plugged into dock */
662#define SW_LINEOUT_INSERT 0x06 /* set = inserted */ 662#define SW_LINEOUT_INSERT 0x06 /* set = inserted */
663#define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */ 663#define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */
664#define SW_VIDEOOUT_INSERT 0x08 /* set = inserted */
664#define SW_MAX 0x0f 665#define SW_MAX 0x0f
665#define SW_CNT (SW_MAX+1) 666#define SW_CNT (SW_MAX+1)
666 667
diff --git a/include/sound/jack.h b/include/sound/jack.h
index 2e0315cdd0d6..6b013c6f6a04 100644
--- a/include/sound/jack.h
+++ b/include/sound/jack.h
@@ -30,6 +30,9 @@ struct input_dev;
30/** 30/**
31 * Jack types which can be reported. These values are used as a 31 * Jack types which can be reported. These values are used as a
32 * bitmask. 32 * bitmask.
33 *
34 * Note that this must be kept in sync with the lookup table in
35 * sound/core/jack.c.
33 */ 36 */
34enum snd_jack_types { 37enum snd_jack_types {
35 SND_JACK_HEADPHONE = 0x0001, 38 SND_JACK_HEADPHONE = 0x0001,
@@ -37,6 +40,8 @@ enum snd_jack_types {
37 SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE, 40 SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
38 SND_JACK_LINEOUT = 0x0004, 41 SND_JACK_LINEOUT = 0x0004,
39 SND_JACK_MECHANICAL = 0x0008, /* If detected separately */ 42 SND_JACK_MECHANICAL = 0x0008, /* If detected separately */
43 SND_JACK_VIDEOOUT = 0x0010,
44 SND_JACK_AVOUT = SND_JACK_LINEOUT | SND_JACK_VIDEOOUT,
40}; 45};
41 46
42struct snd_jack { 47struct snd_jack {
diff --git a/sound/core/jack.c b/sound/core/jack.c
index 077a85262c1c..c8254c667c62 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -23,6 +23,14 @@
23#include <sound/jack.h> 23#include <sound/jack.h>
24#include <sound/core.h> 24#include <sound/core.h>
25 25
26static int jack_types[] = {
27 SW_HEADPHONE_INSERT,
28 SW_MICROPHONE_INSERT,
29 SW_LINEOUT_INSERT,
30 SW_JACK_PHYSICAL_INSERT,
31 SW_VIDEOOUT_INSERT,
32};
33
26static int snd_jack_dev_free(struct snd_device *device) 34static int snd_jack_dev_free(struct snd_device *device)
27{ 35{
28 struct snd_jack *jack = device->device_data; 36 struct snd_jack *jack = device->device_data;
@@ -79,6 +87,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
79{ 87{
80 struct snd_jack *jack; 88 struct snd_jack *jack;
81 int err; 89 int err;
90 int i;
82 static struct snd_device_ops ops = { 91 static struct snd_device_ops ops = {
83 .dev_free = snd_jack_dev_free, 92 .dev_free = snd_jack_dev_free,
84 .dev_register = snd_jack_dev_register, 93 .dev_register = snd_jack_dev_register,
@@ -100,18 +109,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
100 109
101 jack->type = type; 110 jack->type = type;
102 111
103 if (type & SND_JACK_HEADPHONE) 112 for (i = 0; i < ARRAY_SIZE(jack_types); i++)
104 input_set_capability(jack->input_dev, EV_SW, 113 if (type & (1 << i))
105 SW_HEADPHONE_INSERT); 114 input_set_capability(jack->input_dev, EV_SW,
106 if (type & SND_JACK_LINEOUT) 115 jack_types[i]);
107 input_set_capability(jack->input_dev, EV_SW,
108 SW_LINEOUT_INSERT);
109 if (type & SND_JACK_MICROPHONE)
110 input_set_capability(jack->input_dev, EV_SW,
111 SW_MICROPHONE_INSERT);
112 if (type & SND_JACK_MECHANICAL)
113 input_set_capability(jack->input_dev, EV_SW,
114 SW_JACK_PHYSICAL_INSERT);
115 116
116 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); 117 err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
117 if (err < 0) 118 if (err < 0)
@@ -154,21 +155,17 @@ EXPORT_SYMBOL(snd_jack_set_parent);
154 */ 155 */
155void snd_jack_report(struct snd_jack *jack, int status) 156void snd_jack_report(struct snd_jack *jack, int status)
156{ 157{
158 int i;
159
157 if (!jack) 160 if (!jack)
158 return; 161 return;
159 162
160 if (jack->type & SND_JACK_HEADPHONE) 163 for (i = 0; i < ARRAY_SIZE(jack_types); i++) {
161 input_report_switch(jack->input_dev, SW_HEADPHONE_INSERT, 164 int testbit = 1 << i;
162 status & SND_JACK_HEADPHONE); 165 if (jack->type & testbit)
163 if (jack->type & SND_JACK_LINEOUT) 166 input_report_switch(jack->input_dev, jack_types[i],
164 input_report_switch(jack->input_dev, SW_LINEOUT_INSERT, 167 status & testbit);
165 status & SND_JACK_LINEOUT); 168 }
166 if (jack->type & SND_JACK_MICROPHONE)
167 input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT,
168 status & SND_JACK_MICROPHONE);
169 if (jack->type & SND_JACK_MECHANICAL)
170 input_report_switch(jack->input_dev, SW_JACK_PHYSICAL_INSERT,
171 status & SND_JACK_MECHANICAL);
172 169
173 input_sync(jack->input_dev); 170 input_sync(jack->input_dev);
174} 171}