HID: logitech-headset: add a battery driver for the PRO X 2
Subsystems (2)
PATCH v3 1/1 HID: logitech-headset: add a battery driver for the PRO X 2
The PRO X 2 LIGHTSPEED receiver does not speak HID++, so hid-logitech-hidpp cannot read its battery. Its report descriptor has a consumer collection for the media keys and two vendor collections, and no report 0x10 or 0x11.
The battery answers on usage page 0xffa0. A single 64 byte frame on report 0x51 asks for it, with no handshake, and the reply gives the level and whether the headset is charging. The driver asks every 120 seconds. It also reads the power frames that the headset sends on its own. A switch-off frame marks the headset absent at once, and a switch-on frame moves the next request to one second later, so the level appears without waiting for the poll.
hid-generic sets HID_QUIRK_INPUT_PER_APP, so this receiver had one input device per application collection, among them the Consumer Control node for the media keys. A driver does not inherit that quirk, so probe sets it and the input devices stay as they were.
The power supply is registered with POWER_SUPPLY_SCOPE_DEVICE. The headset is present from a reply until the next switch-off frame, and capacity returns -ENODATA while it is absent, so a headset that is off when the driver binds reports no level.
The G522 LIGHTSPEED uses the same vendor protocol with a different frame layout. That device is left out until someone can test it.
---
Changes in v3:
- Request the battery level one second after a power-on frame, so the level appears without waiting for the 120 second poll.
- Report the headset as absent until the first battery reply, and return -ENODATA for capacity while it is absent.
- Queue the poll on system_dfl_wq instead of the system_wq.
drivers/hid/Kconfig | 11 + drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-logitech-headset.c | 319 +++++++++++++++++++++++++++++ 4 files changed, 332 insertions(+) create mode 100644 drivers/hid/hid-logitech-headset.c
drivers/hid/Kconfig +11 -0
@@ -670,6 +670,17 @@ config HID_LOGITECH_DJ generic USB_HID driver and all incoming events will be multiplexed into a single mouse and a single keyboard device. +config HID_LOGITECH_HEADSET + tristate "Logitech wireless headset battery" + depends on USB_HID + select POWER_SUPPLY + help + Support for the battery of Logitech wireless gaming headsets that + report it over a vendor collection instead of HID++. + + Supported devices: + - PRO X 2 LIGHTSPEED + config HID_LOGITECH_HIDPP tristate "Logitech HID++ devices support" depends on HID_LOGITECH
drivers/hid/Makefile +1 -0
@@ -82,6 +82,7 @@ obj-$(CONFIG_HID_LETSKETCH) += hid-letsketch.o obj-$(CONFIG_HID_LOGITECH) += hid-logitech.o obj-$(CONFIG_HID_LOGITECH) += hid-lg-g15.o obj-$(CONFIG_HID_LOGITECH_DJ) += hid-logitech-dj.o +obj-$(CONFIG_HID_LOGITECH_HEADSET) += hid-logitech-headset.o obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o obj-$(CONFIG_HID_MACALLY) += hid-macally.o obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o
drivers/hid/hid-ids.h +1 -0
@@ -910,6 +910,7 @@#define USB_VENDOR_ID_LOGITECH 0x046d#define USB_DEVICE_ID_LOGITECH_Z_10_SPK 0x0a07#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e +#define USB_DEVICE_ID_LOGITECH_PRO_X_2_LIGHTSPEED 0x0af7#define USB_DEVICE_ID_LOGITECH_T651 0xb00c#define USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD 0xb309#define USB_DEVICE_ID_LOGITECH_CASA_TOUCHPAD 0xbb00
drivers/hid/hid-logitech-headset.c new file +319 -0
319 lines not on this page · raw message
base-commit: 58e7295cfecaddec94629160386412e0f2b1e8fe
Signature · 1 line
2.56.0
Jiri Kosina
maintainerQuoted 48 lines · Méven Car
The PRO X 2 LIGHTSPEED receiver does not speak HID++, so hid-logitech-hidpp cannot read its battery. Its report descriptor has a consumer collection for the media keys and two vendor collections, and no report
0x10or0x11.The battery answers on usage page
0xffa0. A single 64 byte frame on report0x51asks for it, with no handshake, and the reply gives the level and whether the headset is charging. The driver asks every 120 seconds. It also reads the power frames that the headset sends on its own. A switch-off frame marks the headset absent at once, and a switch-on frame moves the next request to one second later, so the level appears without waiting for the poll.hid-generic sets
HID_QUIRK_INPUT_PER_APP, so this receiver had one input device per application collection, among them the Consumer Control node for the media keys. A driver does not inherit that quirk, so probe sets it and the input devices stay as they were.The power supply is registered with
POWER_SUPPLY_SCOPE_DEVICE. The headset is present from a reply until the next switch-off frame, and capacity returns-ENODATAwhile it is absent, so a headset that is off when the driver binds reports no level.The G522 LIGHTSPEED uses the same vendor protocol with a different frame layout. That device is left out until someone can test it.
Assisted-by Claude:claude-opus-5Signed-off-by Méven Car <[email protected]>---
Changes in v3:
- Request the battery level one second after a power-on frame, so the level appears without waiting for the 120 second poll.
- Report the headset as absent until the first battery reply, and return-ENODATAfor capacity while it is absent.
- Queue the poll onsystem_dfl_wqinstead of thesystem_wq.drivers/hid/Kconfig | 11 + drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-logitech-headset.c | 319 +++++++++++++++++++++++++++++ 4 files changed, 332 insertions(+) create mode 100644 drivers/hid/hid-logitech-headset.cdrivers/hid/Kconfig +0
-0
drivers/hid/Kconfig config HID_LOGITECH_DJ · line 679
Quoted 10 lines
drivers/hid/Kconfig +7
-0@@ -670,6 +670,17 @@ config HID_LOGITECH_DJ generic USB_HID driver and all incoming events will be multiplexed into a single mouse and a single keyboard device. +config HID_LOGITECH_HEADSET + tristate "Logitech wireless headset battery" + depends on USB_HID + select POWER_SUPPLY + help + Support for the battery of Logitech wireless gaming headsets that + report it over a vendor collection instead of HID++.
Thanks a lot for the patch.
One question though -- is it really practical to have this as a user selectable option?
I think it'd make sense to have just selected by HID_LOGITECH_DJ the same way as it selects HID_LOGITECH_HIDPP. What do you think?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Subject: Re: [PATCH v3] HID: logitech-headset: add a battery driver for the PRO X 2
Quoted 4 lines · Jiri Kosina
One question though -- is it really practical to have this as a user selectable option?
I think it'd make sense to have just selected byHID_LOGITECH_DJthe same way as it selectsHID_LOGITECH_HIDPP. What do you think?
Agreed, a separate prompt is not useful here. The driver only matters to people with a Logitech receiver, and those kernels have HID_LOGITECH_DJ enabled anyway. I missed this opportunity.
In v4, HID_LOGITECH_HEADSET is a hidden option, and HID_LOGITECH_DJ selects it next to HID_LOGITECH_HIDPP. HID_LOGITECH_DJ already depends on USB_HID, so the select leaves no dependency unmet. I will send it shortly.
Thanks,
Méven
Quoted 75 lines · Jiri Kosina
Quoted 48 lines · Méven Car
The PRO X 2 LIGHTSPEED receiver does not speak HID++, so hid-logitech-hidpp cannot read its battery. Its report descriptor has a consumer collection for the media keys and two vendor collections, and no report
0x10or0x11.The battery answers on usage page
0xffa0. A single 64 byte frame on report0x51asks for it, with no handshake, and the reply gives the level and whether the headset is charging. The driver asks every 120 seconds. It also reads the power frames that the headset sends on its own. A switch-off frame marks the headset absent at once, and a switch-on frame moves the next request to one second later, so the level appears without waiting for the poll.hid-generic sets
HID_QUIRK_INPUT_PER_APP, so this receiver had one input device per application collection, among them the Consumer Control node for the media keys. A driver does not inherit that quirk, so probe sets it and the input devices stay as they were.The power supply is registered with
POWER_SUPPLY_SCOPE_DEVICE. The headset is present from a reply until the next switch-off frame, and capacity returns-ENODATAwhile it is absent, so a headset that is off when the driver binds reports no level.The G522 LIGHTSPEED uses the same vendor protocol with a different frame layout. That device is left out until someone can test it.
Assisted-by Claude:claude-opus-5Signed-off-by Méven Car <[email protected]>---
Changes in v3:
- Request the battery level one second after a power-on frame, so the level appears without waiting for the 120 second poll.
- Report the headset as absent until the first battery reply, and return-ENODATAfor capacity while it is absent.
- Queue the poll onsystem_dfl_wqinstead of thesystem_wq.drivers/hid/Kconfig | 11 + drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-logitech-headset.c | 319 +++++++++++++++++++++++++++++ 4 files changed, 332 insertions(+) create mode 100644 drivers/hid/hid-logitech-headset.cdrivers/hid/Kconfig +0
-0drivers/hid/Kconfig config HID_LOGITECH_DJ · line 679
Quoted 10 lines
drivers/hid/Kconfig +7
-0@@ -670,6 +670,17 @@ config HID_LOGITECH_DJ generic USB_HID driver and all incoming events will be multiplexed into a single mouse and a single keyboard device. +config HID_LOGITECH_HEADSET + tristate "Logitech wireless headset battery" + depends on USB_HID + select POWER_SUPPLY + help + Support for the battery of Logitech wireless gaming headsets that + report it over a vendor collection instead of HID++.Thanks a lot for the patch.
One question though -- is it really practical to have this as a user selectable option?
I think it'd make sense to have just selected byHID_LOGITECH_DJthe same way as it selectsHID_LOGITECH_HIDPP. What do you think?Thanks,
--
Jiri Kosina
SUSE Labs
Signature · 1 line
Méven