[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210703220202.5637-7-maxtram95@gmail.com>
Date: Sun, 4 Jul 2021 01:02:02 +0300
From: Maxim Mikityanskiy <maxtram95@...il.com>
To: Jiri Kosina <jikos@...nel.org>,
Benjamin Tissoires <benjamin.tissoires@...hat.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Daniel Kurtz <djkurtz@...omium.org>,
Oliver Neukum <oneukum@...e.de>
Cc: linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
Maxim Mikityanskiy <maxtram95@...il.com>
Subject: [PATCH 6/6] HID: jabra: Change mute LED state to avoid missing key press events
Jabra devices use their discretion regarding when to send the mute key
press events. Although every press on the mute button changes the LED
and actual mute state, key press events are only generated in the
offhook state and only if the mute state set by the host matches the
mute state of the headset.
Without the host's help, every second mute key press will be missed.
This patch addresses it by making the driver update the mute state every
time the mute button is pressed.
Tested with GN Netcom Jabra EVOLVE 20 MS (0b0e:0300). If some other
Jabra device doesn't suffer from this behavior, this workaround
shouldn't hurt.
Signed-off-by: Maxim Mikityanskiy <maxtram95@...il.com>
---
drivers/hid/hid-jabra.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/hid/hid-jabra.c b/drivers/hid/hid-jabra.c
index 41dc30fe2d16..818c174cd544 100644
--- a/drivers/hid/hid-jabra.c
+++ b/drivers/hid/hid-jabra.c
@@ -37,16 +37,51 @@ static int jabra_input_mapping(struct hid_device *hdev,
return is_vendor_defined ? -1 : 0;
}
+static int jabra_event(struct hid_device *hdev, struct hid_field *field,
+ struct hid_usage *usage, __s32 value)
+{
+ struct hid_field *mute_led_field;
+ int offset;
+
+ /* Usages are filtered in jabra_usages. */
+
+ if (!value) /* Handle key presses only. */
+ return 0;
+
+ offset = hidinput_find_field(hdev, EV_LED, LED_MUTE, &mute_led_field);
+ if (offset == -1)
+ return 0; /* No mute LED, proceed. */
+
+ /*
+ * The device changes the LED state automatically on the mute key press,
+ * however, it still expects the host to change the LED state. If there
+ * is a mismatch (i.e. the host didn't change the LED state), the next
+ * mute key press won't generate an event. To avoid missing every second
+ * mute key press, change the LED state here.
+ */
+ input_event(mute_led_field->hidinput->input, EV_LED, LED_MUTE,
+ !mute_led_field->value[offset]);
+
+ return 0;
+}
+
static const struct hid_device_id jabra_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_JABRA, HID_ANY_ID) },
{ }
};
MODULE_DEVICE_TABLE(hid, jabra_devices);
+static const struct hid_usage_id jabra_usages[] = {
+ { 0x000b002f, EV_KEY, HID_ANY_ID }, /* Mic mute */
+ { HID_TERMINATOR, HID_TERMINATOR, HID_TERMINATOR }
+};
+
static struct hid_driver jabra_driver = {
.name = "jabra",
.id_table = jabra_devices,
+ .usage_table = jabra_usages,
.input_mapping = jabra_input_mapping,
+ .event = jabra_event,
};
module_hid_driver(jabra_driver);
--
2.32.0
Powered by blists - more mailing lists