Skip to content

Commit cdc6936

Browse files
broonietiwai
authored andcommitted
ALSA: Add support for mechanical jack insertion
Some systems support both mechanical and electrical jack detection, allowing them to report that a jack is physically present but does not have any functioning connections. Add a new jack type for these, allowing user space to report faulty connections. Thanks to Guillem Jover for the suggestion. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent a53ccab commit cdc6936

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎include/linux/input.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,7 @@ struct input_absinfo {
645645
#define SW_MICROPHONE_INSERT 0x04 /* set = inserted */
646646
#define SW_DOCK 0x05 /* set = plugged into dock */
647647
#define SW_LINEOUT_INSERT 0x06 /* set = inserted */
648+
#define SW_JACK_PHYSICAL_INSERT 0x07 /* set = mechanical switch set */
648649
#define SW_MAX 0x0f
649650
#define SW_CNT (SW_MAX+1)
650651

‎include/sound/jack.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum snd_jack_types {
3636
SND_JACK_MICROPHONE = 0x0002,
3737
SND_JACK_HEADSET = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE,
3838
SND_JACK_LINEOUT = 0x0004,
39+
SND_JACK_MECHANICAL = 0x0008, /* If detected separately */
3940
};
4041

4142
struct snd_jack {

‎sound/core/jack.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
108108
if (type & SND_JACK_MICROPHONE)
109109
input_set_capability(jack->input_dev, EV_SW,
110110
SW_MICROPHONE_INSERT);
111+
if (type & SND_JACK_MECHANICAL)
112+
input_set_capability(jack->input_dev, EV_SW,
113+
SW_JACK_PHYSICAL_INSERT);
111114

112115
err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
113116
if (err < 0)
@@ -159,6 +162,9 @@ void snd_jack_report(struct snd_jack *jack, int status)
159162
if (jack->type & SND_JACK_MICROPHONE)
160163
input_report_switch(jack->input_dev, SW_MICROPHONE_INSERT,
161164
status & SND_JACK_MICROPHONE);
165+
if (jack->type & SND_JACK_MECHANICAL)
166+
input_report_switch(jack->input_dev, SW_JACK_PHYSICAL_INSERT,
167+
status & SND_JACK_MECHANICAL);
162168

163169
input_sync(jack->input_dev);
164170
}

0 commit comments

Comments
 (0)