Fix for presense detection of headset plugging which only reports presence/absense of the microphone part, relates to gemian/gemian#7
This commit is contained in:
parent
995913eaf3
commit
930e65658c
1 changed files with 20 additions and 2 deletions
|
|
@ -125,22 +125,30 @@ static const char *headset_ports[] = {
|
|||
static void notify_ports(pa_droid_extevdev *u) {
|
||||
unsigned int i;
|
||||
|
||||
pa_log_debug("headphone: %d, microphone: %d, lineout: %d, yes: %d, no: %d", u->sw_headphone_insert,
|
||||
u->sw_microphone_insert, u->sw_lineout_insert, PA_AVAILABLE_YES, PA_AVAILABLE_NO);
|
||||
|
||||
pa_available_t has_headphone =
|
||||
((u->sw_headphone_insert || u->sw_lineout_insert)
|
||||
&& !u->sw_microphone_insert) ? PA_AVAILABLE_YES : PA_AVAILABLE_NO;
|
||||
|
||||
pa_log_debug("has_headphone: %d", has_headphone);
|
||||
|
||||
for (i=0; i < N_ELEMENTS(headphone_ports); i++) {
|
||||
pa_device_port *p = pa_hashmap_get(u->card->ports, headphone_ports[i]);
|
||||
pa_log_debug("headphone device port %d, %d", i, p);
|
||||
if (p)
|
||||
pa_device_port_set_available(p, has_headphone);
|
||||
}
|
||||
|
||||
pa_available_t has_headset =
|
||||
((u->sw_headphone_insert || u->sw_lineout_insert)
|
||||
&& u->sw_microphone_insert) ? PA_AVAILABLE_YES : PA_AVAILABLE_NO;
|
||||
u->sw_microphone_insert ? PA_AVAILABLE_YES : PA_AVAILABLE_NO;
|
||||
|
||||
pa_log_debug("has_headset: %d", has_headset);
|
||||
|
||||
for (i=0; i < N_ELEMENTS(headset_ports); i++) {
|
||||
pa_device_port *p = pa_hashmap_get(u->card->ports, headset_ports[i]);
|
||||
pa_log_debug("headset device port %d, %d", i, p);
|
||||
if (p)
|
||||
pa_device_port_set_available(p, has_headset);
|
||||
}
|
||||
|
|
@ -155,6 +163,8 @@ static void evdev_cb(pa_mainloop_api *a, pa_io_event *e, int fd,
|
|||
int err;
|
||||
struct input_event ev;
|
||||
|
||||
pa_log_debug("EV callback start...");
|
||||
|
||||
while (1) {
|
||||
err = libevdev_next_event(u->evdev_dev, flags, &ev);
|
||||
|
||||
|
|
@ -184,22 +194,30 @@ static void evdev_cb(pa_mainloop_api *a, pa_io_event *e, int fd,
|
|||
if (ev.type == EV_SW) {
|
||||
switch (ev.code) {
|
||||
case SW_HEADPHONE_INSERT:
|
||||
pa_log_debug("Headphone Insert %d", ev.value);
|
||||
u->sw_headphone_insert = ev.value;
|
||||
break;
|
||||
case SW_MICROPHONE_INSERT:
|
||||
pa_log_debug("Microphone Insert %d", ev.value);
|
||||
u->sw_microphone_insert = ev.value;
|
||||
break;
|
||||
case SW_LINEOUT_INSERT:
|
||||
pa_log_debug("Lineout Insert %d", ev.value);
|
||||
u->sw_lineout_insert = ev.value;
|
||||
break;
|
||||
default:
|
||||
pa_log_debug("Unknown switch %d", ev.code);
|
||||
/* Ignore unknown switch. */
|
||||
break;
|
||||
}
|
||||
} else if (ev.type == EV_SYN && ev.code == SYN_REPORT) {
|
||||
pa_log_debug("SYN Report");
|
||||
notify_ports(u);
|
||||
}
|
||||
}
|
||||
|
||||
pa_log_debug("EV callback end.");
|
||||
|
||||
}
|
||||
|
||||
static void read_initial_switch_values(pa_droid_extevdev *u) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue