Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1648315rwb; Sun, 2 Oct 2022 05:28:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6etDFUQIr8VlpaxwCxsg7HagLycbv2CQJsKA+9TKjuYH7qucd2meNLbQVXJMaopOCrzwTA X-Received: by 2002:a17:902:d58a:b0:177:f86c:4456 with SMTP id k10-20020a170902d58a00b00177f86c4456mr17500639plh.171.1664713711212; Sun, 02 Oct 2022 05:28:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664713711; cv=pass; d=google.com; s=arc-20160816; b=STqXmTzFMMwX43rzMSWJtXw5t2nDcp2khVAXs3VOv5K5ZrkDG6InBQw3VoMpjmUVDE OoQ9dSNJKlAoBStbw/OcAES0BAULCeWQVRnP8e06vj9SV1wMuDZOmNiXNNRVxAkmebqo ycuJhNTmcIRAR51yICvN7yW7nHZ0lHQhlC2+Ce3B4Utcf4tV+kkq3wRQpB5bn5eEPrcT SZeR+L/wf7+BQ6akzDLta58Y8uAlXXD6oREx58Qw2w2P9TMcoR5U/t3i+/uWUMumQug1 5OleQ7boJ77VZY4IVM56Dm3D1qSeMWNrfSBNFiPln87/TO/ChmccKCUlqFBDOpBYIhs/ K83A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:references :in-reply-to:subject:cc:to:from:date:mime-version:dkim-signature :dkim-filter:dkim-signature; bh=26aK0X8sSRVV4NLxJX755bfG54xzNcdDxpvJf/0n8B0=; b=hjTQ4uHze+zgs0FFPNCJd/FbzDtkpEy0y2XX7BrW0l9rwECilQKokxY3UUugNunDzx 6B8CG2Hn6hw2kLPcecwy98ZTkBlR/NiCGlm1kDND6OBIjbfPp1WbFg/Ff1Ht1x6XF9Y0 WbPvRpFhEWIwdedBeMp8cwzxjAL4kvpwiGQcB61XwSKx+tQrDAcaudfGCLTqA794Yj7w mxJAI4R2vpGPRyFrCG9ycxLsXwwK+s5uQQ1RWesV2O8LUvKbfVPxY/DsVU9pfpTZaGlp j6qvvIWUXuss0otMDWGMFQvFcnrrv1bgEDYbAaTzGVYYaQOWJFrqXi85nUhoMUUAN2Wa lsdQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=JcKAw3gV; dkim=pass header.i=@anssih.iki.fi header.s=default header.b=cAFLN82F; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c14-20020a170903234e00b0016f9420a15asi5986218plh.168.2022.10.02.05.28.19; Sun, 02 Oct 2022 05:28:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=JcKAw3gV; dkim=pass header.i=@anssih.iki.fi header.s=default header.b=cAFLN82F; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbiJBLe6 (ORCPT + 99 others); Sun, 2 Oct 2022 07:34:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiJBLew (ORCPT ); Sun, 2 Oct 2022 07:34:52 -0400 Received: from meesny.iki.fi (meesny.iki.fi [IPv6:2001:67c:2b0:1c1::201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20CD9165A2; Sun, 2 Oct 2022 04:34:49 -0700 (PDT) Received: from mail.onse.fi (87-95-225-209.bb.dnainternet.fi [87.95.225.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: anssi.hannula) by meesny.iki.fi (Postfix) with ESMTPSA id F402220048; Sun, 2 Oct 2022 14:34:45 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1664710486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=26aK0X8sSRVV4NLxJX755bfG54xzNcdDxpvJf/0n8B0=; b=JcKAw3gVOAUp4eqAtZXBTTSWl18rO+tItfM20urAbXaKYiFhA7PYw8pD6L3L5E3bkC0koa kuAjLacM+1AWP9SXG9iaeaDVpfSop8Qr125G79+OMR5UHhQ/oFAz/sxCpZur9uVo56hDMD O8L7L5zb51Gkejqa9TYc7l2QwMpLAeY= Received: from mail.onse.fi (delta.onse.fi [127.0.0.1]) by mail.onse.fi (Postfix) with ESMTP id 24BAD3200A4; Sun, 2 Oct 2022 14:34:45 +0300 (EEST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.onse.fi 24BAD3200A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anssih.iki.fi; s=default; t=1664710485; bh=26aK0X8sSRVV4NLxJX755bfG54xzNcdDxpvJf/0n8B0=; h=From:To:Cc:Subject:In-Reply-To:References:From; b=cAFLN82F1SwCTAlga4a//llHuCGDv+5MyC2MbUP/NS36lVPYfSkeM+NyWeRMKfXyA JOjKnaM3GdHV2m/f4IZfY/Wnkr70GdI7se6oNQmNt33UaQxu6iKZ6pewkscl8Z3Tte 8zb9m0C2SmaTb9SG0TjpHVOTb+++7LvD3DDbaFkQ= MIME-Version: 1.0 Date: Sun, 02 Oct 2022 14:34:45 +0300 From: Anssi Hannula To: Paul Dino Jones Cc: jikos@kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH] usbhid: Interpret 0 length ff effects as infinite (0xffff) length effects In-Reply-To: <20221001221657.gexisc2egjn3mpog@localhost.localdomain> References: <20221001221657.gexisc2egjn3mpog@localhost.localdomain> Message-ID: <93f708f3f9ac8b5c94e6d0b86c1efaa3@iki.fi> X-Sender: anssi.hannula@iki.fi Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=anssi.hannula smtp.mailfrom=anssi.hannula@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1664710486; a=rsa-sha256; cv=none; b=PuawkDF2iCtKTwxVTv4ZsZh/2WDYC8NH09Pv06qhrcWmaJs6YEzpnjslp3WV/NAqjU2X57 Eb3fNOkckltKJBPvjiqIXZNUibqFshCaRdzzXbYJhDgf4LvBjxTvBzgTwnIl2Gpu7Et3iv SCHy/U43bfx3iAWUWWUAqL0+Y2G+iOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1664710486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=26aK0X8sSRVV4NLxJX755bfG54xzNcdDxpvJf/0n8B0=; b=Wk+tzMPM/M0uTPWyHcluiohPfcAmqezqs+W65FYWNChCBt4N6pKnu0MeziNdkFXP/fxWIy HAIZi2IdlfRGmEUVWbwDDOM5wWQ4NGGHVwZ+NAp1UyKxf2DWIqBpxcEFOMRf/906dY0hFo bVcgpE28nQyczgHG/u1SZgfG3cT4WAM= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Paul Dino Jones kirjoitti 2022-10-02 01:16: > Greetings, Hello, and thanks for looking into this! > I started using my Accuforce V2 sim wheel on Linux. I was getting no > response from racing simulators through wine, while native linux test > tools worked properly. It appears that many real-world applications > will > send 0 as the replay length, which was resulting in the behavior I was > observing (nothing). The PID document does not explicitly state that 0 > length effects should be interpreted as infinite, but it does mention > null effects being infinite effects. Actually, it is Wine that is translating 0xFFFF from the application to 0x0000 for the Linux FF API: https://gitlab.winehq.org/wine/wine/-/blob/master/dlls/winebus.sys/bus_udev.c#L1124 Unfortunately "infinite" duration is not actually specified at all in our API currently. input.h just says that the all durations are in msecs and values above 0x7fff cause unspecified results. We have three places where the duration is handled: - ff-memless: Considers 0 as infinite (in ml_get_combo_effect() and calculate_next_time()). - iforce-ff: Just passes the duration to HW as-is - it is unknown what counts as infinite, if any. - pidff: Just passes the duration to HW as-is, so using the unspecified-by-API 0xffff results in infinite duration (per USB HID PID spec). So we probably want to specify some value to work as infinite, likely either 0 or 0xFFFF, and explicitly document that in input.h. I suspect that ff-memless devices are currently the most popular, and e.g. Wine already assumes 0 is infinite, and I can't think of a reason to have an "actual" 0-duration effect, so I guess 0 would be the most sensible value. Since iforce is an "ancestor" of HID PID of sorts, it may also support 0xffff = infinite. I'll try to get hold of one to test, though it may take a couple of weeks... > This patch will interpret 0 length force feedback effects as 0xffff > (infinite) length effects, leaving other values for replay length > unchanged. > > Signed-off-by: Paul Dino Jones > --- > drivers/hid/usbhid/hid-pidff.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hid/usbhid/hid-pidff.c > b/drivers/hid/usbhid/hid-pidff.c > index 3b4ee21cd811..70653451c860 100644 > --- a/drivers/hid/usbhid/hid-pidff.c > +++ b/drivers/hid/usbhid/hid-pidff.c > @@ -301,7 +301,7 @@ 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; > + 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; -- Anssi Hannula