From: Maxim Mikityanskiy <maxtram95@gmail.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Daniel Kurtz <djkurtz@chromium.org>,
Oliver Neukum <oneukum@suse.de>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Maxim Mikityanskiy <maxtram95@gmail.com>
Subject: [PATCH 6/6] HID: jabra: Change mute LED state to avoid missing key press events
Date: Sun, 4 Jul 2021 01:02:02 +0300 [thread overview]
Message-ID: <20210703220202.5637-7-maxtram95@gmail.com> (raw)
In-Reply-To: <20210703220202.5637-1-maxtram95@gmail.com>
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@gmail.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
prev parent reply other threads:[~2021-07-03 22:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-03 22:01 [PATCH 0/6] Add support for common USB HID headset features Maxim Mikityanskiy
2021-07-03 22:01 ` [PATCH 1/6] HID: hid-input: Add offhook and ring LEDs for headsets Maxim Mikityanskiy
2021-07-06 8:02 ` Benjamin Tissoires
2021-07-15 18:57 ` Jiri Kosina
2021-07-15 20:39 ` Dmitry Torokhov
2021-07-15 22:49 ` Pavel Machek
2021-07-16 17:23 ` Maxim Mikityanskiy
2021-08-09 18:30 ` Maxim Mikityanskiy
2021-08-31 19:11 ` Jiri Kosina
2021-09-07 6:30 ` Dmitry Torokhov
2021-07-03 22:01 ` [PATCH 2/6] HID: hid-input: Add phone hook and mic mute buttons " Maxim Mikityanskiy
2021-07-03 22:01 ` [PATCH 3/6] HID: plantronics: Expose headset LEDs Maxim Mikityanskiy
2021-07-03 22:02 ` [PATCH 4/6] HID: plantronics: Expose headset telephony buttons Maxim Mikityanskiy
2021-07-03 22:02 ` [PATCH 5/6] HID: hid-input: Update LEDs in all HID reports Maxim Mikityanskiy
2021-07-03 22:02 ` Maxim Mikityanskiy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210703220202.5637-7-maxtram95@gmail.com \
--to=maxtram95@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=djkurtz@chromium.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oneukum@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).