From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from endrift.com (endrift.com [173.255.198.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98D863AD524 for ; Thu, 2 Jul 2026 22:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.255.198.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783030984; cv=none; b=UwZB+PuZDaF/ValdjY8W0ogZmAsKsXg299tS36aTy1TOqZAzrQE/iFZkzvkNuBtgbJFyree8utlME8zhi9gneDGL3/uJWG7nBAxZUaia+Aelt1CKM4yRUxkPq1pyhfATOrOV+nVIitxtLNF0a9SaMatNwa/kjz5Ff6us16RibB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783030984; c=relaxed/simple; bh=LmYcQA1WWb6Z74TcZCW9XVoKtSj0sLZUK6cY5JXQvN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qvXYAWQDH55fZ/x4kzlprEI+g5Y4SrGiZWTol/61aWLKe/7IvVPLfYCAbBFrWoOTpBw/6pgEaJx5be0EfDJyneTFIwwYAOgEAxpuqlDu720AB1EFsYZhsVFieeYZ0nrwMCx4GuRSnPu/Mmn9mt0JSJBJv+IWkZmMAQgKvkwF8zw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endrift.com; spf=pass smtp.mailfrom=endrift.com; dkim=pass (2048-bit key) header.d=endrift.com header.i=@endrift.com header.b=DjbYfv8s; arc=none smtp.client-ip=173.255.198.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endrift.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=endrift.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=endrift.com header.i=@endrift.com header.b="DjbYfv8s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=endrift.com; s=2020; t=1783030983; bh=LmYcQA1WWb6Z74TcZCW9XVoKtSj0sLZUK6cY5JXQvN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DjbYfv8shAfcLV26NwC1pJSImJVUgiEZeqeVritNA5m9oW+gkag2uLpW7FInkDsSd saBgf2gCeY/iUu3YvlB4IhQuFZatccbe4ovyfhmcixSIEXAmCQXKMbrLdw7ciJstur NGr4ENVVH0ABAvMR616ZZ14dro00N0eT/zYGeM27HjPeRvY6HMwk1m2/kzxw7nhGop Mf8WmB1SpfozkR9mT0wGaZ+ItzR7KYpZqjgcJyLT27Mt4IgMMR/CF8siK3RVi/C/DF K/0b0ShWVRO3x2yGxMC+pp5Ydw9VpUAcdxw8XDMy8CVxuUeEVXSE3TMOepOr6BEUa5 oX3H2H/JCDpuw== Received: from microtis.vulpes.eutheria.net (71-212-73-87.tukw.qwest.net [71.212.73.87]) by endrift.com (Postfix) with ESMTPSA id CEAADA0F2; Thu, 02 Jul 2026 15:23:02 -0700 (PDT) From: Vicki Pfau To: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org Cc: Vicki Pfau , Yousef Alhouseen Subject: [PATCH 05/10] HID: steam: Coalesce rumble packets Date: Thu, 2 Jul 2026 15:21:38 -0700 Message-ID: <20260702222145.1863104-5-vi@endrift.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260702222145.1863104-1-vi@endrift.com> References: <20260702222145.1863104-1-vi@endrift.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The Steam Deck resets the haptic pattern every time it receives a rumble packet, leading to weird discontinuities or sometimes cutting out entirely. Instead of overloading the interface, Steam interally rate-limits sending these packets, so we should too. Signed-off-by: Vicki Pfau --- drivers/hid/hid-steam.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c index 34653ad383ac..01b64194ec97 100644 --- a/drivers/hid/hid-steam.c +++ b/drivers/hid/hid-steam.c @@ -343,6 +343,7 @@ struct steam_device { bool did_mode_switch; bool gamepad_mode; struct work_struct rumble_work; + struct delayed_work coalesce_rumble_work; u16 rumble_left; u16 rumble_right; unsigned int sensor_timestamp_us; @@ -603,10 +604,26 @@ static void steam_haptic_rumble_cb(struct work_struct *work) { struct steam_device *steam = container_of(work, struct steam_device, rumble_work); + + guard(mutex)(&steam->report_mutex); steam_haptic_rumble(steam, 0, steam->rumble_left, steam->rumble_right, 2, 0); } +static void steam_coalesce_rumble_cb(struct work_struct *work) +{ + struct steam_device *steam = container_of(to_delayed_work(work), + struct steam_device, + coalesce_rumble_work); + + guard(mutex)(&steam->report_mutex); + steam_haptic_rumble(steam, 0, steam->rumble_left, + steam->rumble_right, 2, 0); + + if (steam->rumble_left || steam->rumble_right) + schedule_delayed_work(&steam->coalesce_rumble_work, HZ / 20); +} + #ifdef CONFIG_STEAM_FF static int steam_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) @@ -616,6 +633,14 @@ static int steam_play_effect(struct input_dev *dev, void *data, steam->rumble_left = effect->u.rumble.strong_magnitude; steam->rumble_right = effect->u.rumble.weak_magnitude; + /* + * The interface gets somewhat overloaded when too many rumble + * packets are sent in a row, so Steam throttles it to 20 Hz + */ + if (delayed_work_pending(&steam->coalesce_rumble_work)) + return 0; + + schedule_delayed_work(&steam->coalesce_rumble_work, HZ / 20); return schedule_work(&steam->rumble_work); } #endif @@ -1360,6 +1385,7 @@ static int steam_probe(struct hid_device *hdev, INIT_DELAYED_WORK(&steam->mode_switch, steam_mode_switch_cb); INIT_LIST_HEAD(&steam->list); INIT_WORK(&steam->rumble_work, steam_haptic_rumble_cb); + INIT_DELAYED_WORK(&steam->coalesce_rumble_work, steam_coalesce_rumble_cb); steam->sensor_timestamp_us = 0; if (steam->quirks & STEAM_QUIRK_DECK) steam->sensor_update_rate_us = 4000; @@ -1426,6 +1452,7 @@ static int steam_probe(struct hid_device *hdev, cancel_work_sync(&steam->work_connect); cancel_delayed_work_sync(&steam->mode_switch); cancel_work_sync(&steam->rumble_work); + cancel_delayed_work_sync(&steam->coalesce_rumble_work); cancel_work_sync(&steam->unregister_work); return ret; @@ -1444,6 +1471,7 @@ static void steam_remove(struct hid_device *hdev) cancel_delayed_work_sync(&steam->mode_switch); cancel_work_sync(&steam->work_connect); cancel_work_sync(&steam->rumble_work); + cancel_delayed_work_sync(&steam->coalesce_rumble_work); cancel_work_sync(&steam->unregister_work); steam->client_hdev = NULL; steam->client_opened = 0; -- 2.54.0