From patchwork Mon Jan 6 21:35:30 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: 855343 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.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 9CFAB1DFE38; Mon, 6 Jan 2025 21:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199348; cv=none; b=F39lmxlKwpVIom+J6CGEcQsDXBBU1XtbrrmoczgokBeZ0hGsn9Y/z9Y9TlvbHGBw2ppS/YQSS8S/Ino+YIcYIEiQRFaEuh3colDHv8gbDKU1HsRw5yWsKr/DIQKT2Xt4ZnW+QTsPOTHzrovBmrJZmF0rtIm6OTof9JhtHdRbsJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199348; c=relaxed/simple; bh=60aSOMQx14zfMVGYITpU0cwL1JQM2IC1G8kgAFjv5ys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K2kL2NK0g/yFAHElzbvBFOewPIM3SAqMGparYNf3xfz3OcryRQO463TdAIhf+0KWTPrQjhDgom1JTv8MZ9DCVUa2bvbViGnud1P+szOItCD6ydNkFIYiGccddC72P5Oisa5GHKAB7V+oBiZF6e/StoSfGUMyjdyDOghxh75JEWo= 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=Hj0IrOJb; arc=none smtp.client-ip=209.85.208.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="Hj0IrOJb" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-5d3cfa1da14so3133599a12.1; Mon, 06 Jan 2025 13:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736199345; x=1736804145; 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=ZMTdGnyyJWXuH6aEDEPHe6IuTncIDqPC0Rg1e/KX1X8=; b=Hj0IrOJby189fvEKXMszYI5+r8/j07iOFh40fmuh7nrfMp2KSkRUKArV8irJr4jaxi iObQOSol/3vkLXqVaNhpLixDloePgBEPn92oFU98HlZbA4VZ+d1oCbQfCMfn+Zf3yu0w 4U2bwUPZwfF1r6BPL1cOsGfVQuarahAhnj3aIukXEtG0jWlvW91EGdC3O7nh6bN8tO40 u05kf2kCCRg9aSGlLRNXF1Pm+00HzFU24UC+hEElisBbyiGFVlppzkk4x3F3TUYygB3R 7OxO4oq8AU5BCwbHdUaye/Xrxo/lvQ0xp13veVG5duqkvXTP9aAmkWC4J37dYkzjHQX/ gLxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736199345; x=1736804145; 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=ZMTdGnyyJWXuH6aEDEPHe6IuTncIDqPC0Rg1e/KX1X8=; b=DvhGw8h3vh7EkhhMx/Kt04MASKeyC4nG3SUO/eJNqoAI/7YOErfKtz2TS/3aGVNJIG 3IhtXya6bJDivK2UsGJl/v+j9IHZUS/1CPsLwmqXuKwFH1SmMXFcgVetc2D1yKQVy9Md 3m+rlnVSM2doUjJ+uZ1HH7/Tyzyp1WhbSJcKBgbMjmZzt42bk/BCkSQ3pi+p2hA7ke00 0wlu9Af+/x2GWEECMYoZV0giPk12jkKzQZkaj1nYSs+7c6S/+76F2W5+XnxMP2Y985Z5 ebCkY5g0M86jpMNhvyBwbpKHdpmQ2c2ES2f4D5U9dDUEpo1gL5Z4akngLosjMr7V8yzr JKcw== X-Forwarded-Encrypted: i=1; AJvYcCX90He3otxm40KAdipiCkSuOsf1m46SsalyeUPXBCcjoV3MYOxtTXzLDH9iC5owvfLslklu9Sc1ITU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7MJygeXOn56qN2wY+R1xfKmmqvkw25TLiNJC7LAaoyW0V9ZJf l5rD16JEeCQp6wyYNjD7PbXU9qWkzEwCFi1ee7E8zIG7vh/ml+p8Tfb3nNxG X-Gm-Gg: ASbGncuPi/dAnYVcTk6zWHFNi6SPzfC7T+bgLvv7CgsTgQBHxr31LwF3uvYA/CrLGDx xm1vqE36ArvfUIpyJ2KgfNCAWxk04kjF18uLnBYNIH6y6UufrnSQC60Nln9wCFGinOgZMeRUTvj aiAUz8jmVcI5Rhqvs41DZPcsDOi49l+0RrC/tmKYLl+mWIKxWJWgFeKJ0jE/jF/Hs8pi+OfQ61E lzkZNDoiD6XqeUQI3YvxjPwl6NZ9jvu1XC5kgeoV1EUcmttLdnTB1Dc9KfLNZxhGueoPIKCzplV XyUOTTX2FBqLYJMLy0unKZT5dbs= X-Google-Smtp-Source: AGHT+IEzCYYiNd745kQpx4ofP4CyvT4uBaER669kvtUAhW55t9aMvo8vYfBByQTR6sHxJ4psV+dT3g== X-Received: by 2002:a05:6402:274e:b0:5d0:d183:cc11 with SMTP id 4fb4d7f45d1cf-5d81dd6422amr19450229a12.2.1736199344696; Mon, 06 Jan 2025 13:35:44 -0800 (PST) Received: from laptok.lan (89-64-31-140.dynamic.chello.pl. [89.64.31.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80676f9acsm23375991a12.31.2025.01.06.13.35.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 13:35:44 -0800 (PST) From: =?utf-8?q?Tomasz_Paku=C5=82a?= To: jikos@kernel.org, bentiss@kernel.org Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v3 01/10] HID: pidff: Convert infinite length from Linux API to PID standard Date: Mon, 6 Jan 2025 22:35:30 +0100 Message-ID: <20250106213539.77709-2-tomasz.pakula.oficjalny@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106213539.77709-1-tomasz.pakula.oficjalny@gmail.com> References: <20250106213539.77709-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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 3b4ee21cd811..3899d72a0b02 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -301,7 +301,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 ? 0xffff : 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; From patchwork Mon Jan 6 21:35:32 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: 855342 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 54D621E00AC; Mon, 6 Jan 2025 21:35:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199351; cv=none; b=j/OEVkKhlOOBuD6EWmeU5jV3QRLvMhJ56w/jm2y0pez4W0WrOfE3GAYj0Uung517llgXvEuR+FWfDZKE/3a4xZcKZesSKp28tI2C/1pe4jQq6VoQRkk7tFeV08K9wyuwvgukRY0TnIzFLRpz9V5kRz1PMj3FcihHbymkiH1lPZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199351; c=relaxed/simple; bh=eJ/IPvw5UT6F1TJJeyixqWwLsKzSSiRHTTNylaWJIo0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Jq0i+yEKtXvMBWF1G/GhRWFaouitr9hM01vOWKpyNzoBkCiHXa9p0qI7iTs5mAz20zMxy07DuaaOR+nXX3OWPQ99+3iGXk/ioqZHJSb0fQBnTEMHRrQ4r4/UFqqzccOQrY7Xyyx5+zs7tl1sq+Z62FOQX2T+ui+8hgKxKmkUCSo= 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=VX95oteZ; arc=none smtp.client-ip=209.85.208.49 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="VX95oteZ" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-5d3ea2a5a9fso2221300a12.2; Mon, 06 Jan 2025 13:35:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736199347; x=1736804147; 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=6ERMQSDSSP4kaB35zxEBbEdMyWN68eRlF2X7GLXmoNs=; b=VX95oteZxX104CjbS32lQplXiiJRE9185ZUToxXsx2dy69RYbqSDKh4UFA9woBf+Fx w+tCO5zj/+p+WmvQ8U34+Ps6Pv1IqdAcQkbv21Imxf0It+PytjMFmY0KDAMiZu4wch65 2iIG8cSJ/dth7cIWld2b+DLZdSAS+xQmNRpKNm4jn1DsYlgFDSO4jnmM/Jjx5cNdS02+ Yb//CAfe44nOuOplP+6WDid+KGdEsMmMgsET5lRCPGdFk83v8xHWpYLRqixt8kFdjHYN o3RV4N+9mZR3Fbo2fSwcSLutqPnTW8o5dokYaShF4E+z7bghPvd6sZ3nw+525fPA/iUa DpvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736199347; x=1736804147; 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=6ERMQSDSSP4kaB35zxEBbEdMyWN68eRlF2X7GLXmoNs=; b=sR3ypJkyKTJlyrQNIxzMQJlfpWTfJS+0Cp2V7tzeV+EDajuYct6kyGkUlkiAyczpNe NflVVPYctDEyzhC0DCSw3erfl+icAtEvjvWL+oupYtt9Ot0TyWOwk1izd3D8jWegU3k1 MrSRd1YwwQaGAm8R3Ud2n1H87fPMU1wIHmFkH7MIC+/vBNx1RnsorM0/QKEYFqd7PJMJ 5p7A+HygzF68uWjdtaSBA8tCPXlNp0d9oEjoVSjQ1S7KiFnld+GGRWAvT5w5nuEbEoD+ e50eUwGQTqMuRO4S03tr0GSUQAYGXlQdlXpT1KpoxRO3E/HcWNswSbBJuAkeIaU74qnz WbaQ== X-Forwarded-Encrypted: i=1; AJvYcCUyODoEthuKPmsXUC4IdBwuMxFAY++II0A7h5M7GzpimUHePmaso0h80mWAzcOj/zdWLP+6C4YEfsg=@vger.kernel.org X-Gm-Message-State: AOJu0YyAg0aU7/HAdRoIrz+7OVUMQe00Bx7LXUvW5LG3sy2BrDEnb1ek 9pg1yAJ5TulOjwl1vLuEmw5mmKIwknx6d+53S4gUoJf5qYkpzhU4yN1vbJR/ X-Gm-Gg: ASbGncto3G+YBmg4sVvpvwcwPLb73OY10dcrnkH2/7Sw/LCfnpFG0cT7vmb5PeXu3GV rAMm3VDRfKguWWFUOc+wsyG7d4/qI6RSMNultxoeiYeieKVF7jaPV1enSta/fwYgL3tdhBMj284 OPOiTZD2tiGxFiQJEaM2Jr+O59WWtHOkNbSRxPDNXpcBD2uITeseXmgQNyWiOEfKHcvrz+Z91aE VQxYTzvOPFEpfhcWYz0d5LexsPXOH6FzNtIY49Ny1kRAwm/d50knsj73mVDGxaWoNOFidj8I71T e9+DdH2P9hghVpoK4fn3mZs/ZFs= X-Google-Smtp-Source: AGHT+IGkC0T67Noi5JaQ8ju/83mrKDBlN+hzKnLF8YwXNSZFgYcLrXRRlrGnKvwj2B8clvzeLPIH7g== X-Received: by 2002:a05:6402:2790:b0:5d0:e852:dca0 with SMTP id 4fb4d7f45d1cf-5d81de1c377mr21066376a12.11.1736199347450; Mon, 06 Jan 2025 13:35:47 -0800 (PST) Received: from laptok.lan (89-64-31-140.dynamic.chello.pl. [89.64.31.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80676f9acsm23375991a12.31.2025.01.06.13.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 13:35:46 -0800 (PST) From: =?utf-8?q?Tomasz_Paku=C5=82a?= To: jikos@kernel.org, bentiss@kernel.org Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v3 03/10] HID: pidff: Clamp PERIODIC effect period to device's logical range Date: Mon, 6 Jan 2025 22:35:32 +0100 Message-ID: <20250106213539.77709-4-tomasz.pakula.oficjalny@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106213539.77709-1-tomasz.pakula.oficjalny@gmail.com> References: <20250106213539.77709-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 This ensures the effect can actually be played on the connected force feedback device. Adds clamping functions used instead of rescaling, as we don't want to change the characteristics of the periodic effects. Fixes edge cases found on Moza Racing and some other hardware where the effects would not play if the period is outside the defined logical range. Signed-off-by: Tomasz Pakuła --- drivers/hid/usbhid/hid-pidff.c | 36 +++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index cf8163d92ea4..7af7744e3cf2 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -205,6 +205,36 @@ static int pidff_rescale_signed(int i, struct hid_field *field) field->logical_minimum / -0x8000; } +/* + * Clamp minimum value for the given field + */ +static int pidff_clamp_min(int i, struct hid_field *field) +{ + int ret = i < field->logical_minimum ? field->logical_minimum : i; + pr_debug("clamped min value from %d to %d\n", i, ret); + return ret; +} + +/* + * Clamp maximum value for the given field + */ +static int pidff_clamp_max(int i, struct hid_field *field) +{ + int ret = i > field->logical_maximum ? field->logical_maximum : i; + pr_debug("clamped max value from %d to %d\n", i, ret); + return ret; +} + +/* + * Clamp value for the given field + */ +static int pidff_clamp(int i, struct hid_field *field) +{ + i = pidff_clamp_min(i, field); + i = pidff_clamp_max(i, field); + return i; +} + static void pidff_set(struct pidff_usage *usage, u16 value) { usage->value[0] = pidff_rescale(value, 0xffff, usage->field); @@ -357,7 +387,11 @@ static void pidff_set_periodic_report(struct pidff_device *pidff, pidff_set_signed(&pidff->set_periodic[PID_OFFSET], effect->u.periodic.offset); pidff_set(&pidff->set_periodic[PID_PHASE], effect->u.periodic.phase); - pidff->set_periodic[PID_PERIOD].value[0] = effect->u.periodic.period; + + // Clamp period to ensure the device can play the effect + pidff->set_periodic[PID_PERIOD].value[0] = + pidff_clamp(effect->u.periodic.period, + pidff->set_periodic[PID_PERIOD].field); hid_hw_request(pidff->hid, pidff->reports[PID_SET_PERIODIC], HID_REQ_SET_REPORT); From patchwork Mon Jan 6 21:35:34 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: 855341 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 C92671D47A2; Mon, 6 Jan 2025 21:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199353; cv=none; b=WnUvkeGyTRjlfQZ4QDo6Zqhk1ptLbRjo5pFQIY4/h2RJ8JliLqwdsBj2U9G15VB71pHJilV4OCD3yA8AaxiOPdt34UUWSvr10CNf8r61fdEGtzq1Q3ka7G0HfzPPw8HUIJ0jL9VfTemY2XSgH/N3oxhV1XhpWafkrt98JOlzZLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199353; c=relaxed/simple; bh=Y01bZZyEKBS4Wp/QSV8+diqsxBe4MEehIrGd35l+14c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=deVzeGkF0YGgroFuogrWhmqpOXllVHBe+9qP9CNejCV4gRpwJLKJyO0CjyiPc42UYtlzEAL5459mQRccMbq1iqL4BW8ZJFW9ZZZ3+fnK44orADuq2fRPQ+MOunwwlgJl+rqnQlJEErZ/eIzUWY8Kk4273q4b2vbLR0WNiRHZpoQ= 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=dHX7MPhL; arc=none smtp.client-ip=209.85.208.41 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="dHX7MPhL" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5d3cd821c60so3451071a12.3; Mon, 06 Jan 2025 13:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736199350; x=1736804150; 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=RMzq8PvIJV+z6yV01GtbnkWq1T0M+f9X2iY5dtwH21c=; b=dHX7MPhL6riV4tNF1NtTMmsK0X2jhQ+XYbLk9sRWVNG6/P45GvvTL+p119sSjBamaA piqrA1+1ANc7kHWyspyWcsWUAvXkAL0xs+jaxIdXYbyo6VOGgCUxXlwrO260fgr5lAGG 1j//uh/RLl8ga6xo1RK62GryF5GEPq2/81VxP9NytPwrKKyBW8JcFC06lZFFUQ1cZabB 7K94WsjVl8XRCO53llwBaqFh6wxiX7pghdiE/ca52YNupuFo5wPC3LzBh/3iH0PohQZr zKR+M4g2qYTwvVJ0wZG0Teg26IAiUYaCrE1sdKM1Tbq9lT8jQcazDAkLpKsVDejQoeMv /1fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736199350; x=1736804150; 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=RMzq8PvIJV+z6yV01GtbnkWq1T0M+f9X2iY5dtwH21c=; b=vgEjeS2SLTO49vmg95slPVSxC+S357lUechxkJL5bxgN1LWCNH9mO4/1KNck7ox6xd zFB7zw39LtOMsRs3I51PAwVtyv5szUNZZU++dRR9a7tvEL/clcN3w4TR8mj2PzY62aq5 A8NSgICVv0A3B0C0BCEvvMA8lb9mCn1V1bF8B2GIc6e7rWxA4IYG/Su70OMpFDbUWSZI wfrEvQuz0AJO9pwwwPVmBvG5mKkMoLfA00so30SdzGc6Xp4f5WSNMlojJW08vuqQiVOZ q2+IRJ8uqZIh9qtplHQ93IBRLX0LiGnj64ZK7OeAHAez7mYTy5G8oVLwJkcZVmVuiJKX yltQ== X-Forwarded-Encrypted: i=1; AJvYcCXRLCWUy4n2x3+QV1prU77vUd96/ioR3GqHxESOk24MH3S03GISweD/K7qNJoi8cpEEvGLPVLJ0zAw=@vger.kernel.org X-Gm-Message-State: AOJu0YyoYLfZ6MoDyjD5iTBh4Hz4bGGgesdE/jhtiZLqpdfBZB5hnT8M i8+H4ooTSsbEsPFpuFxBXYY0Md3rC1NGMiQrpjbbH0hXGfeD+avHzDz6Ubac X-Gm-Gg: ASbGnctRi+key0ngAHw5nGbQZY6SuV0HM5KhjdWIVCx8F03XmYwN23X66u65slUnS9B Zf3U+oJrV7EOsJGMDpTIsy+3ytjK3ED187deFf6CDcxUrMLzIKPAbyDaf/mVgPvHNLKgrOXWh8R qKf3IJdMKDsltTO6BabX9ZmgjJrRS8QqBWgd2sSRT3JjuK/WxpgYtCyB6O/CkVttt0gIaxVn7YT Mc/UJLQLGIQPkAB7L35D4UXtP6gYUDaGZDEk/M51wRbAN3K3IIPa8vEbeXaxoyKj3NohUn5H4wY qSLgJBwzwwr7u6sNKrBJ8rxjib4= X-Google-Smtp-Source: AGHT+IGRWGu9lEj+TyUq1EHaVU1NUY201j+6/c3czWD4kUx/2wfUYrdW0AHgCtGORO+sOV7YbKWIAA== X-Received: by 2002:a05:6402:254f:b0:5d3:efcf:f163 with SMTP id 4fb4d7f45d1cf-5d81de38c3amr17957152a12.11.1736199349881; Mon, 06 Jan 2025 13:35:49 -0800 (PST) Received: from laptok.lan (89-64-31-140.dynamic.chello.pl. [89.64.31.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80676f9acsm23375991a12.31.2025.01.06.13.35.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 13:35:48 -0800 (PST) From: =?utf-8?q?Tomasz_Paku=C5=82a?= To: jikos@kernel.org, bentiss@kernel.org Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v3 05/10] HID: pidff: Add MISSING_PBO quirk and its detection Date: Mon, 6 Jan 2025 22:35:34 +0100 Message-ID: <20250106213539.77709-6-tomasz.pakula.oficjalny@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106213539.77709-1-tomasz.pakula.oficjalny@gmail.com> References: <20250106213539.77709-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 Some devices with only one axis are missing PARAMETER_BLOCK_OFFSET field for conditional effects. They can only have one axis, so we're limiting the max_axis when setting the report for those effects. Automatic detection ensures compatibility even if such device won't be explicitly defined in the kernel. Fixes initialization of VRS DirectForce PRO and possibly other devices. Co-developed-by: Makarenko Oleg Signed-off-by: Makarenko Oleg Signed-off-by: Tomasz Pakuła --- drivers/hid/usbhid/hid-pidff.c | 46 +++++++++++++++++++++------------- include/linux/hid.h | 1 + 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 28f42f30e2b3..d792a07b5a5d 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -421,12 +421,19 @@ static int pidff_needs_set_periodic(struct ff_effect *effect, static void pidff_set_condition_report(struct pidff_device *pidff, struct ff_effect *effect) { - int i; + unsigned char i; + + // Devices missing Parameter Block Offset can only have one axis + unsigned char max_axis = pidff->quirks & HID_PIDFF_QUIRK_MISSING_PBO ? 1 : 2; pidff->set_condition[PID_EFFECT_BLOCK_INDEX].value[0] = pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]; - for (i = 0; i < 2; i++) { + for (i = 0; i < max_axis; i++) { + // Omit Parameter Block Offset if missing + if (!(pidff->quirks & HID_PIDFF_QUIRK_MISSING_PBO)) + pidff->set_condition[PID_PARAM_BLOCK_OFFSET].value[0] = i; + pidff->set_condition[PID_PARAM_BLOCK_OFFSET].value[0] = i; pidff_set_signed(&pidff->set_condition[PID_CP_OFFSET], effect->u.condition[i].center); @@ -839,6 +846,11 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, pr_debug("Setting MISSING_DELAY quirk\n"); return_value |= HID_PIDFF_QUIRK_MISSING_DELAY; } + else if (!found && table[k] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET]) { + pr_debug("PBO field not found, but that's OK\n"); + pr_debug("Setting MISSING_PBO quirk\n"); + return_value |= HID_PIDFF_QUIRK_MISSING_PBO; + } else if (!found && strict) { pr_debug("failed to locate %d\n", k); return -1; @@ -1118,7 +1130,6 @@ static int pidff_find_effects(struct pidff_device *pidff, */ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) { - int envelope_ok = 0; int status = 0; // Save info about the device not having the DELAY ffb field. @@ -1149,13 +1160,10 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) return -ENODEV; } - if (!PIDFF_FIND_FIELDS(set_envelope, PID_SET_ENVELOPE, 1)) - envelope_ok = 1; - if (pidff_find_special_fields(pidff) || pidff_find_effects(pidff, dev)) return -ENODEV; - if (!envelope_ok) { + if (PIDFF_FIND_FIELDS(set_envelope, PID_SET_ENVELOPE, 1)) { if (test_and_clear_bit(FF_CONSTANT, dev->ffbit)) hid_warn(pidff->hid, "has constant effect but no envelope\n"); @@ -1180,16 +1188,20 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) clear_bit(FF_RAMP, dev->ffbit); } - if ((test_bit(FF_SPRING, dev->ffbit) || - test_bit(FF_DAMPER, dev->ffbit) || - test_bit(FF_FRICTION, dev->ffbit) || - test_bit(FF_INERTIA, dev->ffbit)) && - PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) { - hid_warn(pidff->hid, "unknown condition effect layout\n"); - clear_bit(FF_SPRING, dev->ffbit); - clear_bit(FF_DAMPER, dev->ffbit); - clear_bit(FF_FRICTION, dev->ffbit); - clear_bit(FF_INERTIA, dev->ffbit); + if (test_bit(FF_SPRING, dev->ffbit) || + test_bit(FF_DAMPER, dev->ffbit) || + test_bit(FF_FRICTION, dev->ffbit) || + test_bit(FF_INERTIA, dev->ffbit)) { + status = PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1); + + if (status < 0) { + hid_warn(pidff->hid, "unknown condition effect layout\n"); + clear_bit(FF_SPRING, dev->ffbit); + clear_bit(FF_DAMPER, dev->ffbit); + clear_bit(FF_FRICTION, dev->ffbit); + clear_bit(FF_INERTIA, dev->ffbit); + } + pidff->quirks |= status; } if (test_bit(FF_PERIODIC, dev->ffbit) && diff --git a/include/linux/hid.h b/include/linux/hid.h index 94ad5a510639..29f0a91f505f 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -1229,6 +1229,7 @@ int hid_pidff_init(struct hid_device *hid); /* HID PIDFF quirks */ #define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) +#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1) #define dbg_hid(fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__) From patchwork Mon Jan 6 21:35:36 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: 855340 Received: from mail-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 08E951E0DDA; Mon, 6 Jan 2025 21:35:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199355; cv=none; b=U6EOzwtI6fAdiyep8lACVSAUk5yHklvhoQuRjaVl9I1x4oRyMXiZYiWIlrrQsFkBLONdJI9rF5lVi0x+/JKoNE8jZZ0W8oQingc+E/EwO///0Js/qbQbyvHAwNxzp2RS1elRVW7M4Vm6OCDf96JKO8CoiA6XamT424Ei/F5AdGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199355; c=relaxed/simple; bh=QpcFmZSNF3TCKbFLUHLW4V0YOIJt0/4SLo+cWhmfzTI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fl5l9NkFQxktA4dO6aVxqQ69gD7znInSOjRrfGs0BR6qqoRuueis2BhsfjavQql0TdY26LtlNtraJoCGeJHSzhgyUKlaJbUYchuRxgfTNajC4ohOmqrOZJ5osiHc0iu5ngsNXy04itgK9qbyxnKAqaZkj/bZzGgRsga4CfKoIDo= 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=SfL5ksrF; arc=none smtp.client-ip=209.85.208.45 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="SfL5ksrF" Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-5d3cfa1da14so3133614a12.1; Mon, 06 Jan 2025 13:35:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736199352; x=1736804152; 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=uL/zqFXHROf9ZEt+23hat/TCGZHaDdrfMcQYQykn+sQ=; b=SfL5ksrFxFYC6QR9Lub4IZ3330ZndWuP2fPy3u8JoZ2Na2JwcQz48OIHhQyC88FLe8 SReR0VqKtAwGNSdp8V2DZBiVsw4fVuv7LzL7BojUOn2Sj+ddOfA/i/dwqmId4b/fraa5 sEWZtv+FBOdmpT/ca7/kuhptB0akD9XL6gTdmrA9rqHFvVvfrbhP8XzppZKwNt1a9iIp PnonyAObyPKyuj7DYiwfOk7eVkZ0/wJ1rGtiqdK+uAhxtzXWvocoy011NqC5/vjmWH37 JlIuJqB1TjhMvHn20WFOumSq+6CryHI1TfIBI1tOHDYpjLzjRKpfCunSk2d27K+nkQ0L l7ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736199352; x=1736804152; 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=uL/zqFXHROf9ZEt+23hat/TCGZHaDdrfMcQYQykn+sQ=; b=vGET2RUyOEAC5+o2vnweJhifBuEvLesHYOuxhGKXAEiE7PKlo3/X9rz07DIXYZ/ikl WETTm3KU6svlheJPmtfMyOyJ0AQtvS+bO/XW4u+90126sQ6ZK/tfShleEMTga7YNAkpf OrUZDkEyKWWvxsxmUhDdU6fPg284uMfkve/KTBk7bvOjiEmy4uYwjpGBTyJupY2RxcIu teu02Nj3BjfJlPXn+Mplv5TNrHd5gVcWjN/nfISg3vXNP6DDVhnIfnBWS8CkyJAciTbv ws3KZAN6VybCKn8E3oG3JLKG/0f/IIrjYtiA+7SIA+ga3QkqVP0uJjBY1xMs3KFaTjzL dY6w== X-Forwarded-Encrypted: i=1; AJvYcCVI5zHB1AKL4br66Nbbyhds3IRhzMFTMxTcB3zHJYFesjv0v9aATExGAs53Qt6g/ARCtIA/9u+caPM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5qjTKNmEx8PM1M5jgh619Lo4ZHFf8PlFuCPyPXUG1+0Oe5p96 G3Cj4axTR6QIzf491yCRvF17Hzvc9nKrIj08+txRGPfgHwwlXq+x3RtldOHX X-Gm-Gg: ASbGncuBY9vwMoLYHOm7/LHIPfaUmcMYfiqZL+NxVS/fSYKQ/2hLRQO+4X+OoGD86Uw dC+6n7k6vs7dCRT5Lj897+OKBWk0WVaISKZiT93MolKr4QWObEwc/68ZHyXTl7rdsh+KmcUOcBJ +VHU4OvkzcNNXA1CpOudo8iRr1BOtlriSgPsFM5b1028fm+e8o2x0GE/uD80pJglJ9mMR1Z3/Po Jz4KJ2ITwIp6Stu2f5EphMv6d0HB9qqtBEV91kWsgrwKfboKyrfXy1uwXUSh9XvbrdY4L6YSC+f 1hKynNS7k0VKwX0D2ML/gaAZMvI= X-Google-Smtp-Source: AGHT+IGMvCFVdT5qK9wrMt+xLqgscbsHuH5eO7aFMjBvyrLlO+XxMBjMQ+mpyTVK35pI7Hvm4u6S/w== X-Received: by 2002:a05:6402:348b:b0:5d3:fdf5:4b28 with SMTP id 4fb4d7f45d1cf-5d81de36c71mr19484232a12.10.1736199352156; Mon, 06 Jan 2025 13:35:52 -0800 (PST) Received: from laptok.lan (89-64-31-140.dynamic.chello.pl. [89.64.31.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80676f9acsm23375991a12.31.2025.01.06.13.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 13:35:51 -0800 (PST) From: =?utf-8?q?Tomasz_Paku=C5=82a?= To: jikos@kernel.org, bentiss@kernel.org Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v3 07/10] HID: pidff: Add hid_pidff_init_with_quirks and export as GPL symbol Date: Mon, 6 Jan 2025 22:35:36 +0100 Message-ID: <20250106213539.77709-8-tomasz.pakula.oficjalny@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106213539.77709-1-tomasz.pakula.oficjalny@gmail.com> References: <20250106213539.77709-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 This lays out a way to provide an initial set of quirks to enable before device initialization takes place. GPL symbol export needed for the possibility of building HID drivers which use this function as modules. Adding a wrapper function to ensure compatibility with the old behavior of hid_pidff_init. Signed-off-by: Tomasz Pakuła --- drivers/hid/usbhid/hid-pidff.c | 15 ++++++++++++++- include/linux/hid.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 53b16a4e54a6..5a328860685b 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -1299,8 +1299,9 @@ static int pidff_check_autocenter(struct pidff_device *pidff, /* * Check if the device is PID and initialize it + * Set initial quirks */ -int hid_pidff_init(struct hid_device *hid) +int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks) { struct pidff_device *pidff; struct hid_input *hidinput = list_entry(hid->inputs.next, @@ -1322,6 +1323,7 @@ int hid_pidff_init(struct hid_device *hid) return -ENOMEM; pidff->hid = hid; + pidff->quirks = initial_quirks; hid_device_io_start(hid); @@ -1400,3 +1402,14 @@ int hid_pidff_init(struct hid_device *hid) kfree(pidff); return error; } +EXPORT_SYMBOL_GPL(hid_pidff_init_with_quirks); + +/* + * Check if the device is PID and initialize it + * Wrapper made to keep the compatibility with old + * init function + */ +int hid_pidff_init(struct hid_device *hid) +{ + return hid_pidff_init_with_quirks(hid, 0); +} diff --git a/include/linux/hid.h b/include/linux/hid.h index 2af9db0296d1..93233c5b75a6 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -1223,8 +1223,10 @@ void hid_quirks_exit(__u16 bus); #ifdef CONFIG_HID_PID int hid_pidff_init(struct hid_device *hid); +int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks); #else #define hid_pidff_init NULL +#define hid_pidff_init_with_quirks NULL #endif /* HID PIDFF quirks */ From patchwork Mon Jan 6 21:35:38 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: 855339 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 392B31E00A7; Mon, 6 Jan 2025 21:35:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199357; cv=none; b=UOs/7pe1scvc6w9VSlyAgrzR0J7AptCOejfRqi0494eCp0iYnAAcC4nLCsBdtkDQQ+H2AApPUwvMUu/CI1dmhP0O3NeiG9k0z+GpJWsd7b+Sf6U6niqmJuaIBtKjQokvgsY9dMfmyh1sc71ZfRl6Orv6mo8l0JXuy+3ladaXUv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736199357; c=relaxed/simple; bh=b+zfvgwJH2RorKAcLzDD+FZq/xIErAzyO4/KBsNmong=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=P+t3zY8LR0L8Wznt0N9YQQ9y7M0MH51/jLLPk8z7tpYXcOMkEYexmO/cwmEcq/Nk4RjOT7bYdVE/7BF7pXdRH6ZxSPhmh8/J7p1yf3q3rzuDV3o9Kpn9gvBb8pHE9vlg4QLRPSkBvulsaIgq1b+Ntc2KQf1JM1acyqeKm+fUVX0= 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=Sw+dJv8b; arc=none smtp.client-ip=209.85.208.53 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="Sw+dJv8b" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5d0bf4ec53fso3098710a12.0; Mon, 06 Jan 2025 13:35:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1736199354; x=1736804154; 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=CIWbvhwfyoOTXpZRGFAZUIU+5fdfCWd5LhGB3garQ30=; b=Sw+dJv8bIND7AoxFPwLs2BgmmEEeP/jWBfcvDrrHHy0msjVGn1bBsRv23dGoBbilEg l/d0qFwecpLQSphJUBkDNDn917yatOdTUrn8USA+has3NGX7wHRlw5lq98Q8iAYZzCB8 rLJ94BwWfVSzrBs6N4Se5/vJ70mJjOA49AFi6kGrqmzn3jiodsswkl0tIR8tbwkUhLcs q9yV0KhayzNyEwEYxU0JnZhURfGhjnkD1E75LWCdlc/KJPT99d5PAQ8l1ZX1rRyNxT9f gMLdsDNiv8gaDl3Z2XbstTW0EaVNVPnUFZFbKSl71IHI9+g7nfyZqNq4kNzGRYePsY+S zw9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736199354; x=1736804154; 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=CIWbvhwfyoOTXpZRGFAZUIU+5fdfCWd5LhGB3garQ30=; b=pHeiSWdESh73EPjyJuxeBO24Uxk6RX8Yb949Iml837cOSw3F9wpKT5amtTDOy+GzBz MpqGBvhfgfmDSz7lwdqxjfYhq2olX+43HZaH/W1gvvb9l24f1qGH/Kv998QX7fcEmG/D RVo+pTf/3J4yoiV72icmGmLHCVR78DcZWZnNsHhsiC3kMRIBpjHb280aLQuPFQqz+PHM q+xoGL475KFJAJtv8VbgJvRoa77+f714JNbD9zp83o85JsDDuvWQibDVHJ4aVR8I7qfU Au3Md++cd/XwWQZwt3c23eT8v2F73qVjGrncnQrovOu/DOrZbYtRGY7a/yqJD/EC8JIC bSbg== X-Forwarded-Encrypted: i=1; AJvYcCVAzoC5lVQzPEOQ/sB6qlhoXXjbmEgVvDebYmQ6KsuJmw7+Hq3vt78qwl7qc9Eu8wbdiDRSNpNHUgI=@vger.kernel.org X-Gm-Message-State: AOJu0YwshAcsM5nj8YJdFhcdzETroG74z7ZB0z2jqMKIzCcrjgBmhgms KTEXHmU2tsIKa7ICU4aw59BH7s6KuyRAwHD9nNr2jiz78x2mZXTuMceysmI0 X-Gm-Gg: ASbGncvnBTATmVTcQ+K+RcEssUJ6xEBwWGyUN73Y+6jmBymcRAI7gwFOuS87re6feci T/k74oDF+8wcBlINQVFvRS2q8vsun1lodXVsJkqSHEadIjj74DpZ9zbEK6GkosGHU9HGUz5cwOC gDbgJvBp7z3BW63snRwhCtISy25/YDSX8lp+ZxBt74a1xyoMOlIXxi35sTx/JYFQbfBrDCb2fuU 4FlGbPQA4GSGS+675D+XNquFZVRpgjvbEyLUBY7S3Tig8iKWTcbY6q3gmSH1gdE9v1Cui7zzJmx aQCWRBOtbLrxocWRA2ZHA+D7YaA= X-Google-Smtp-Source: AGHT+IEbm8CI6PSn1fYSqMr+ze0pUcK/B9DMBbMLgLF8TZL26BppdCyYLbZrMq5B/4KZeBWh0QsArw== X-Received: by 2002:a05:6402:524b:b0:5d3:d747:6496 with SMTP id 4fb4d7f45d1cf-5d81de2dcccmr19597530a12.10.1736199354351; Mon, 06 Jan 2025 13:35:54 -0800 (PST) Received: from laptok.lan (89-64-31-140.dynamic.chello.pl. [89.64.31.140]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d80676f9acsm23375991a12.31.2025.01.06.13.35.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 13:35:53 -0800 (PST) From: =?utf-8?q?Tomasz_Paku=C5=82a?= To: jikos@kernel.org, bentiss@kernel.org Cc: linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH v3 09/10] HID: pidff: Stop all effects before enabling actuators Date: Mon, 6 Jan 2025 22:35:38 +0100 Message-ID: <20250106213539.77709-10-tomasz.pakula.oficjalny@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106213539.77709-1-tomasz.pakula.oficjalny@gmail.com> References: <20250106213539.77709-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 Some PID compliant devices automatically play effects after boot (i.e. autocenter spring) that prevent the rendering of other effects since it is done outside the kernel driver. This makes sure all the effects currently played are stopped after resetting the device. It brings compatibility to the Brunner CLS-P joystick and others Signed-off-by: Tomasz Pakuła --- drivers/hid/usbhid/hid-pidff.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 6b4c4ecf4943..25ae80f68507 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -109,8 +109,9 @@ static const u8 pidff_pool[] = { 0x80, 0x83, 0xa9 }; /* Special field key tables used to put special field keys into arrays */ #define PID_ENABLE_ACTUATORS 0 -#define PID_RESET 1 -static const u8 pidff_device_control[] = { 0x97, 0x9a }; +#define PID_STOP_ALL_EFFECTS 1 +#define PID_RESET 2 +static const u8 pidff_device_control[] = { 0x97, 0x99, 0x9a }; #define PID_CONSTANT 0 #define PID_RAMP 1 @@ -1240,6 +1241,10 @@ static void pidff_reset(struct pidff_device *pidff) hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT); hid_hw_wait(hid); + pidff->device_control->value[0] = pidff->control_id[PID_STOP_ALL_EFFECTS]; + hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT); + hid_hw_wait(hid); + pidff->device_control->value[0] = pidff->control_id[PID_ENABLE_ACTUATORS]; hid_hw_request(hid, pidff->reports[PID_DEVICE_CONTROL], HID_REQ_SET_REPORT);