From patchwork Sat Jan 25 22:25:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Tomasz_Paku=C5=82a?= X-Patchwork-Id: 13950507 X-Patchwork-Delegate: jikos@jikos.cz Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F12F52066DB; Sat, 25 Jan 2025 22:25:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737843937; cv=none; b=lJPhz+nOnMpAoOVAGgJA/fW9hAqUmm8Ko5ZGa1R9g1JPHYtRoUvR4N5kFB8P4i+/1AFo0unYRY9wg6zD5PwewL5W7qUyEfv6qXGPcdU+hBN/mUPMZ+5bhmNLJeMC/6ZDfbDTlDhsFLtYJgmet1lUU1Eyng3UqHn1szH9g3TM4tE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737843937; c=relaxed/simple; bh=DhKOlDN0J91JsCofHQMVQCBR/3u/HEqZUulpq4EyNyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SAfuvVW+xhvcUL+RFzESyoNedwW634WgsjcbevlzftmHs0ikFFcyIaduAR2t26nzFXGDXzHTXfp8ksDm+FaslkrLyEvZgn7nytW90vn5zJ7dEJlzOb3CkUu9nmqRnI+j00eMmAze5Voa1G1UxpNfuHglSvsyVVAzlDazo9bmZb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ULl+jr/J; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ULl+jr/J" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-aa6647a7556so63025966b.2; Sat, 25 Jan 2025 14:25:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737843934; x=1738448734; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ssFFA6NC5w0PkH/hxlG/5x9jpkiDdQm3Ywo45Mto8CY=; b=ULl+jr/JuhOxZ0meMsSbaCx7oaNpoBEWQQ0mNhAwo5QZAOCtUsVdd6DKCLXUopdg0G /fPFa3VKs5K/fX7WAtJUK+G/yPULFPMZKjJGHhNsKsuYMfmfIeqdyWB8BKCKn4k+mPv+ 9Dyp9Yw1CCYA+UKIaK/t6TRx8bcfc+RNB0xVrVIQsi/x/4RGlTmrz/ikMK3+nSi4x6UR 8/ny8mNRvHKXlqXRAB+6twhrhZy1X4PpSJ/FqF1bPi2Glb3pGWe4zhqjALqSrpaEGbyh kmdkvLoKCjuLyx7+RZrLLKjo1x9lTpOkxPU7nqe88PChwR/+yhk9P75H8NpttnCjcFc5 av0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737843934; x=1738448734; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ssFFA6NC5w0PkH/hxlG/5x9jpkiDdQm3Ywo45Mto8CY=; b=pC0wTHOW/i7oTmN6tEX2GZcomsy7Ekgkxo5beNnKabRTNIPkoMRLFA10wv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w== X-Received: by 2002:a17:907:97d4:b0:aa6:6f12:aa45 with SMTP id a640c23a62f3a-ab6515b6a78mr563317666b.7.1737843933933; Sat, 25 Jan 2025 14:25:33 -0800 (PST) Received: from laptok.lan (89-64-31-140.dynamic.chello.pl. [89.64.31.140]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab68f1ef7besm136540166b.62.2025.01.25.14.25.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2025 14:25:33 -0800 (PST) From: =?utf-8?q?Tomasz_Paku=C5=82a?= To: jikos@kernel.org, bentiss@kernel.org Cc: anssi.hannula@gmail.com, oleg@makarenk.ooo, linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v7 01/17] HID: pidff: Convert infinite length from Linux API to PID standard Date: Sat, 25 Jan 2025 23:25:14 +0100 Message-ID: <20250125222530.45944-2-tomasz.pakula.oficjalny@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250125222530.45944-1-tomasz.pakula.oficjalny@gmail.com> References: <20250125222530.45944-1-tomasz.pakula.oficjalny@gmail.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Linux defines 0 length as infinite in its force feedback API 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 --- 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 3b4ee21cd811..5fe4422bb5ba 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;