Skip to content

Commit d9d5623

Browse files
hadessbentiss
authored andcommitted
HID: logitech-hidpp: Set wireless_status for G935 receiver
Set the USB interface "wireless_status" for the G935 receiver when receiving battery notifications. This will allow sound daemons such as Pipewire or PulseAudio to know whether or not the headset is turned on and connected. Signed-off-by: Bastien Nocera <hadess@hadess.net> Link: https://lore.kernel.org/r/20230302105555.51417-6-hadess@hadess.net Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 0a4db18 commit d9d5623

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

drivers/hid/hid-logitech-hidpp.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ MODULE_PARM_DESC(disable_tap_to_click,
7474
#define HIDPP_QUIRK_HIDPP_EXTRA_MOUSE_BTNS BIT(27)
7575
#define HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS BIT(28)
7676
#define HIDPP_QUIRK_HI_RES_SCROLL_1P0 BIT(29)
77+
#define HIDPP_QUIRK_WIRELESS_STATUS BIT(30)
7778

7879
/* These are just aliases for now */
7980
#define HIDPP_QUIRK_KBD_SCROLL_WHEEL HIDPP_QUIRK_HIDPP_WHEELS
@@ -473,6 +474,26 @@ static void hidpp_prefix_name(char **name, int name_length)
473474
*name = new_name;
474475
}
475476

477+
/*
478+
* Updates the USB wireless_status based on whether the headset
479+
* is turned on and reachable.
480+
*/
481+
static void hidpp_update_usb_wireless_status(struct hidpp_device *hidpp)
482+
{
483+
struct hid_device *hdev = hidpp->hid_dev;
484+
struct usb_interface *intf;
485+
486+
if (!(hidpp->quirks & HIDPP_QUIRK_WIRELESS_STATUS))
487+
return;
488+
if (!hid_is_usb(hdev))
489+
return;
490+
491+
intf = to_usb_interface(hdev->dev.parent);
492+
usb_set_wireless_status(intf, hidpp->battery.online ?
493+
USB_WIRELESS_STATUS_CONNECTED :
494+
USB_WIRELESS_STATUS_DISCONNECTED);
495+
}
496+
476497
/**
477498
* hidpp_scroll_counter_handle_scroll() - Send high- and low-resolution scroll
478499
* events given a high-resolution wheel
@@ -1920,6 +1941,7 @@ static int hidpp20_query_adc_measurement_info_1f20(struct hidpp_device *hidpp)
19201941
&hidpp->battery.voltage);
19211942
hidpp->battery.capacity = hidpp20_map_adc_measurement_1f20_capacity(hidpp->hid_dev,
19221943
hidpp->battery.voltage);
1944+
hidpp_update_usb_wireless_status(hidpp);
19231945

19241946
return 0;
19251947
}
@@ -1944,6 +1966,7 @@ static int hidpp20_adc_measurement_event_1f20(struct hidpp_device *hidpp,
19441966
hidpp->battery.capacity = hidpp20_map_adc_measurement_1f20_capacity(hidpp->hid_dev, voltage);
19451967
if (hidpp->battery.ps)
19461968
power_supply_changed(hidpp->battery.ps);
1969+
hidpp_update_usb_wireless_status(hidpp);
19471970
}
19481971
return 0;
19491972
}
@@ -4595,7 +4618,8 @@ static const struct hid_device_id hidpp_devices[] = {
45954618
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0xC088) },
45964619

45974620
{ /* G935 Gaming Headset */
4598-
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0x0a87) },
4621+
HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 0x0a87),
4622+
.driver_data = HIDPP_QUIRK_WIRELESS_STATUS },
45994623

46004624
{ /* MX5000 keyboard over Bluetooth */
46014625
HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb305),

0 commit comments

Comments
 (0)