From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4A83723E25A; Mon, 31 Mar 2025 14:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743432966; cv=none; b=Yr+Iu6rNaKp54lJcCwxyITP5DWhaYu0TrBmuBbz5SjjpLUxWQKPjRusWRYTfGtEMOInszY7R+H64us76Hyi08brgII44AvgdNe5bgS6NBJ/3UR1ozDjmcEDnMNtTko2RIaaacDxDQnmrkFbUjgHVnKAtuHjz5FZTrqvYCrGdt60= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743432966; c=relaxed/simple; bh=WwKf7qEzym3fm1+PYCXiS5nCEC8E5Q7PGj26QpqD5CM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Do6w8XLuHe5cDlnkkj0/2Gf16Ho9A2ACaNvmnXeWHStdp7hY5tystHDAhR18v2Iat3L0tbtyosI0Msq9C2qbueEg3nkMgPtdkWL648iMnNsP/P+uRG4evYLFzmqHop6jOZzwFPNtqtDOHuggAIP+60cCLtuFbjwjBhuSimye1E8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LnjOVnHK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LnjOVnHK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F871C4CEE3; Mon, 31 Mar 2025 14:56:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743432965; bh=WwKf7qEzym3fm1+PYCXiS5nCEC8E5Q7PGj26QpqD5CM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LnjOVnHKjAHe5+N+rDRpnCKpzjNjwBuLwLaMQAmftcixlGV/tTxmw7ZRk82sH798J BeS2YOBk7ltA7OpDib+SiWIT6lqvuz9V/DkUpDOsdA1BxAlBrpw4t1uepS4CiC9wtR OiFrP9WgdlPObJ76vUwBP+yZb5IKVB5RAPzZgrGoY2yLrRi2emZTTCSIy35KrQXHqP GfFaqQqIIX1MiJD5Rlea9j1+uu1HHoRjbEAzSeF5gy/n2KsnvSfehm3HR9Wmh8reAL V+ZC54sdnJ4pIcmyGIx+OMwFwyMWGrRTd7Ij0OLUu8t/LkI+wHhuUnSAPAhALvRDT0 Q6iUUZNLWmiYg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Tomasz=20Paku=C5=82a?= , Makarenko Oleg , =?UTF-8?q?Micha=C5=82=20Kope=C4=87?= , Paul Dino Jones , =?UTF-8?q?Crist=C3=B3ferson=20Bueno?= , Pablo Cisneros , Jiri Kosina , Sasha Levin , jikos@kernel.org, bentiss@kernel.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 02/19] HID: pidff: Convert infinite length from Linux API to PID standard Date: Mon, 31 Mar 2025 10:55:43 -0400 Message-Id: <20250331145601.1705784-2-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250331145601.1705784-1-sashal@kernel.org> References: <20250331145601.1705784-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.85 Content-Transfer-Encoding: 8bit From: Tomasz Pakuła [ Upstream commit 37e0591fe44dce39d1ebc7a82d5b6e4dba1582eb ] Software uses 0 as de-facto infinite lenght on Linux FF apis (SDL), Linux doesn't actually define anythi as of now, while USB PID defines NULL (0xffff). Most PID devices do not expect a 0-length effect and can't interpret it as infinite. This change fixes Force Feedback for most PID compliant devices. As most games depend on updating the values of already playing infinite effects, this is crucial to ensure they will actually work. Previously, users had to rely on third-party software to do this conversion and make their PID devices usable. Co-developed-by: Makarenko Oleg Signed-off-by: Makarenko Oleg Signed-off-by: Tomasz Pakuła Reviewed-by: Michał Kopeć Reviewed-by: Paul Dino Jones Tested-by: Paul Dino Jones Tested-by: Cristóferson Bueno Tested-by: Pablo Cisneros Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/usbhid/hid-pidff.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 3b4ee21cd8111..5fe4422bb5bad 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -21,6 +21,7 @@ #include "usbhid.h" #define PID_EFFECTS_MAX 64 +#define PID_INFINITE 0xffff /* Report usage table used to put reports into an array */ @@ -301,7 +302,12 @@ static void pidff_set_effect_report(struct pidff_device *pidff, pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]; pidff->set_effect_type->value[0] = pidff->create_new_effect_type->value[0]; - pidff->set_effect[PID_DURATION].value[0] = effect->replay.length; + + /* Convert infinite length from Linux API (0) + to PID standard (NULL) if needed */ + pidff->set_effect[PID_DURATION].value[0] = + effect->replay.length == 0 ? PID_INFINITE : effect->replay.length; + pidff->set_effect[PID_TRIGGER_BUTTON].value[0] = effect->trigger.button; pidff->set_effect[PID_TRIGGER_REPEAT_INT].value[0] = effect->trigger.interval; -- 2.39.5