diff options
Diffstat (limited to 'sound/core/jack.c')
-rw-r--r-- | sound/core/jack.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/sound/core/jack.c b/sound/core/jack.c index dd4a12dc09aa..d54d1a05fe65 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c | |||
@@ -23,10 +23,21 @@ | |||
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; |
29 | 37 | ||
38 | if (jack->private_free) | ||
39 | jack->private_free(jack); | ||
40 | |||
30 | /* If the input device is registered with the input subsystem | 41 | /* If the input device is registered with the input subsystem |
31 | * then we need to use a different deallocator. */ | 42 | * then we need to use a different deallocator. */ |
32 | if (jack->registered) | 43 | if (jack->registered) |
@@ -47,7 +58,7 @@ static int snd_jack_dev_register(struct snd_device *device) | |||
47 | int err; | 58 | int err; |
48 | 59 | ||
49 | snprintf(jack->name, sizeof(jack->name), "%s %s", | 60 | snprintf(jack->name, sizeof(jack->name), "%s %s", |
50 | card->longname, jack->id); | 61 | card->shortname, jack->id); |
51 | jack->input_dev->name = jack->name; | 62 | jack->input_dev->name = jack->name; |
52 | 63 | ||
53 | /* Default to the sound card device. */ | 64 | /* Default to the sound card device. */ |
@@ -79,6 +90,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, | |||
79 | { | 90 | { |
80 | struct snd_jack *jack; | 91 | struct snd_jack *jack; |
81 | int err; | 92 | int err; |
93 | int i; | ||
82 | static struct snd_device_ops ops = { | 94 | static struct snd_device_ops ops = { |
83 | .dev_free = snd_jack_dev_free, | 95 | .dev_free = snd_jack_dev_free, |
84 | .dev_register = snd_jack_dev_register, | 96 | .dev_register = snd_jack_dev_register, |
@@ -100,18 +112,10 @@ int snd_jack_new(struct snd_card *card, const char *id, int type, | |||
100 | 112 | ||
101 | jack->type = type; | 113 | jack->type = type; |
102 | 114 | ||
103 | if (type & SND_JACK_HEADPHONE) | 115 | for (i = 0; i < ARRAY_SIZE(jack_types); i++) |
104 | input_set_capability(jack->input_dev, EV_SW, | 116 | if (type & (1 << i)) |
105 | SW_HEADPHONE_INSERT); | 117 | input_set_capability(jack->input_dev, EV_SW, |
106 | if (type & SND_JACK_LINEOUT) | 118 | 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 | 119 | ||
116 | err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); | 120 | err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops); |
117 | if (err < 0) | 121 | if (err < 0) |
@@ -154,21 +158,17 @@ EXPORT_SYMBOL(snd_jack_set_parent); | |||
154 | */ | 158 | */ |
155 | void snd_jack_report(struct snd_jack *jack, int status) | 159 | void snd_jack_report(struct snd_jack *jack, int status) |
156 | { | 160 | { |
161 | int i; | ||
162 | |||
157 | if (!jack) | 163 | if (!jack) |
158 | return; | 164 | return; |
159 | 165 | ||
160 | if (jack->type & SND_JACK_HEADPHONE) | 166 | for (i = 0; i < ARRAY_SIZE(jack_types); i++) { |
161 | input_report_switch(jack->input_dev, SW_HEADPHONE_INSERT, | 167 | int testbit = 1 << i; |
162 | status & SND_JACK_HEADPHONE); | 168 | if (jack->type & testbit) |
163 | if (jack->type & SND_JACK_LINEOUT) | 169 | input_report_switch(jack->input_dev, jack_types[i], |
164 | input_report_switch(jack->input_dev, SW_LINEOUT_INSERT, | 170 | status & testbit); |
165 | status & SND_JACK_LINEOUT); | 171 | } |
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 | 172 | ||
173 | input_sync(jack->input_dev); | 173 | input_sync(jack->input_dev); |
174 | } | 174 | } |