diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-03-23 19:35:43 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-03-23 19:35:43 -0400 |
commit | 5b56eec77498f15317f3ff5ac9101372f400c859 (patch) | |
tree | 1acfb40ca6a19323a292131aa7fca68ef4ef330b /sound | |
parent | c2f43981e5dbc92884149aa2234064cc2c340acd (diff) | |
parent | 662c319ae4b4fb60001816dfe1dde5fdfc7a2af9 (diff) |
Merge branch 'topic/jack' into for-linus
Diffstat (limited to 'sound')
-rw-r--r-- | sound/core/jack.c | 45 |
1 files changed, 21 insertions, 24 deletions
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 | ||
26 | static 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 | |||
26 | static int snd_jack_dev_free(struct snd_device *device) | 34 | static 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 | */ |
155 | void snd_jack_report(struct snd_jack *jack, int status) | 156 | void 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 | } |