Skip to content

Commit 9179726

Browse files
endriftJiri Kosina
authored andcommitted
HID: hid-steam: Disable watchdog instead of using a heartbeat
The Steam Deck has a setting that controls whether or not the watchdog is enabled, so instead of using a heartbeat to keep the watchdog from triggering, this commit changes the behavior to simply disable the watchdog instead. Signed-off-by: Jiri Kosina <[email protected]>
1 parent 34281b4 commit 9179726

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

drivers/hid/hid-steam.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static LIST_HEAD(steam_devices);
101101
#define STEAM_REG_GYRO_MODE 0x30
102102
#define STEAM_REG_LPAD_CLICK_PRESSURE 0x34
103103
#define STEAM_REG_RPAD_CLICK_PRESSURE 0x35
104+
#define STEAM_REG_WATCHDOG_ENABLE 0x47
104105

105106
/* Raw event identifiers */
106107
#define STEAM_EV_INPUT_DATA 0x01
@@ -134,7 +135,6 @@ struct steam_device {
134135
struct power_supply __rcu *battery;
135136
u8 battery_charge;
136137
u16 voltage;
137-
struct delayed_work heartbeat;
138138
struct work_struct rumble_work;
139139
u16 rumble_left;
140140
u16 rumble_right;
@@ -340,8 +340,6 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
340340
steam_send_report_byte(steam, STEAM_CMD_DEFAULT_MAPPINGS);
341341
/* enable mouse */
342342
steam_send_report_byte(steam, STEAM_CMD_DEFAULT_MOUSE);
343-
344-
cancel_delayed_work_sync(&steam->heartbeat);
345343
} else {
346344
/* disable esc, enter, cursor */
347345
steam_send_report_byte(steam, STEAM_CMD_CLEAR_MAPPINGS);
@@ -352,13 +350,8 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
352350
STEAM_REG_RPAD_MODE, 0x07, /* disable mouse */
353351
STEAM_REG_LPAD_CLICK_PRESSURE, 0xFFFF, /* disable clicky pad */
354352
STEAM_REG_RPAD_CLICK_PRESSURE, 0xFFFF, /* disable clicky pad */
353+
STEAM_REG_WATCHDOG_ENABLE, 0, /* disable watchdog that tests if Steam is active */
355354
0);
356-
/*
357-
* The Steam Deck has a watchdog that automatically enables
358-
* lizard mode if it doesn't see any traffic for too long
359-
*/
360-
if (!work_busy(&steam->heartbeat.work))
361-
schedule_delayed_work(&steam->heartbeat, 5 * HZ);
362355
} else {
363356
steam_write_registers(steam,
364357
STEAM_REG_LPAD_MODE, 0x07, /* disable mouse */
@@ -733,22 +726,6 @@ static bool steam_is_valve_interface(struct hid_device *hdev)
733726
return !list_empty(&rep_enum->report_list);
734727
}
735728

736-
static void steam_lizard_mode_heartbeat(struct work_struct *work)
737-
{
738-
struct steam_device *steam = container_of(work, struct steam_device,
739-
heartbeat.work);
740-
741-
mutex_lock(&steam->mutex);
742-
if (!steam->client_opened && steam->client_hdev) {
743-
steam_send_report_byte(steam, STEAM_CMD_CLEAR_MAPPINGS);
744-
steam_write_registers(steam,
745-
STEAM_REG_RPAD_MODE, 0x07, /* disable mouse */
746-
0);
747-
schedule_delayed_work(&steam->heartbeat, 5 * HZ);
748-
}
749-
mutex_unlock(&steam->mutex);
750-
}
751-
752729
static int steam_client_ll_parse(struct hid_device *hdev)
753730
{
754731
struct steam_device *steam = hdev->driver_data;
@@ -887,7 +864,6 @@ static int steam_probe(struct hid_device *hdev,
887864
steam->quirks = id->driver_data;
888865
INIT_WORK(&steam->work_connect, steam_work_connect_cb);
889866
INIT_LIST_HEAD(&steam->list);
890-
INIT_DEFERRABLE_WORK(&steam->heartbeat, steam_lizard_mode_heartbeat);
891867
INIT_WORK(&steam->rumble_work, steam_haptic_rumble_cb);
892868

893869
steam->client_hdev = steam_create_client_hid(hdev);
@@ -944,7 +920,6 @@ static int steam_probe(struct hid_device *hdev,
944920
hid_destroy_device(steam->client_hdev);
945921
client_hdev_fail:
946922
cancel_work_sync(&steam->work_connect);
947-
cancel_delayed_work_sync(&steam->heartbeat);
948923
cancel_work_sync(&steam->rumble_work);
949924
steam_alloc_fail:
950925
hid_err(hdev, "%s: failed with error %d\n",
@@ -965,7 +940,6 @@ static void steam_remove(struct hid_device *hdev)
965940
mutex_lock(&steam->mutex);
966941
steam->client_hdev = NULL;
967942
steam->client_opened = false;
968-
cancel_delayed_work_sync(&steam->heartbeat);
969943
mutex_unlock(&steam->mutex);
970944
cancel_work_sync(&steam->work_connect);
971945
if (steam->quirks & STEAM_QUIRK_WIRELESS) {

0 commit comments

Comments
 (0)