From patchwork Sat Feb 24 12:00:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jules Noirant X-Patchwork-Id: 205832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1113146dyb; Sat, 24 Feb 2024 04:09:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXyYnNYRXppi3EB2k/6kb8rgYw85if73MVTBVjAHpvB2OB7HzMiC4oiRzAHTKhRkqvGqYsCB6fkrDFhmOVViwhQTwfTfg== X-Google-Smtp-Source: AGHT+IFY91jXEItSZ5Q2MfZKeHkNXpnhFguow4P7FB9j+zMKleRb96QeP9G/Fagt5nqO97eilwjY X-Received: by 2002:a05:6a21:e85:b0:1a0:e647:5d58 with SMTP id ma5-20020a056a210e8500b001a0e6475d58mr2653297pzb.23.1708776551911; Sat, 24 Feb 2024 04:09:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708776551; cv=pass; d=google.com; s=arc-20160816; b=FOWPMt3dvZvzskjCqXPpKskPY9IXWsEYJblqV5jtHIj7G+x9YH/U+8edqYXiI8DEdY I2HC9llQUGzQ4OP82wc/NbBo0bYQfVTbg5kKnqGmFgKgCUQFGcpv4OvEDoJMIjFmedD7 eVL5JaUTrHwfbkmr638jBSwdHbxX5K/KRbh7sbW0rTXBIxwkiqndPRQcoScR91msdQa0 5u0PCGITFOjhSxGPSr/ibxm54bsZ27pSJhG+C6QeUB5Qrhdtf8DxLfgMeXRRGPVpmXhq P+gW8NC7oAc0UCjIaJihs3H/eP3kJfjDvZZ78SWl9ARDfzldPgkaUJCBrs+V+JxFDNvI MxRQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=3dYE06cGrljHtTRYwZzkQUBSeOHR9BhQZqpePGYgV5k=; fh=YmU0v0S561R0p8xBZVshn5KfRJ5JrSTgtrFyZX4OfWo=; b=DISXTOi7jxodFa4nSWNQ0xWgt7OoS0QZhSZJDfsbngDRL+f0NkyrUO7/Zx9Ev9lMal +mNvLPQ460pWqXGcr/axzMse3LlhVWPP3gQ1HBrp8+ZBb2JZ89XEuORpSJGlA2VqWNJY OLJh3Mlb743/lmJJ7IHOEChMN+QAKR9SoomTJY5W14K+UX+1brd9NA6uBaL6+gJ7MN41 luXftY895z5CQjnyQatCq5YVzKpTmr2HXJntCoYiKu17yL8M4RyAdNQ5ZjPgrINo8rpI s3sjoWEwCI65PNLfCxnCKF4Fx0qVEvS3/4O4jzY+C9sfdVAHsomQymDhDkcuKJImqclN UT6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@orange.fr header.s=t20230301 header.b=REp8uHu2; arc=pass (i=1 spf=pass spfdomain=orange.fr dkim=pass dkdomain=orange.fr dmarc=pass fromdomain=orange.fr); spf=pass (google.com: domain of linux-kernel+bounces-79624-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79624-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=orange.fr Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h25-20020a632119000000b005dcbb8409ecsi826924pgh.611.2024.02.24.04.09.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 04:09:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79624-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@orange.fr header.s=t20230301 header.b=REp8uHu2; arc=pass (i=1 spf=pass spfdomain=orange.fr dkim=pass dkdomain=orange.fr dmarc=pass fromdomain=orange.fr); spf=pass (google.com: domain of linux-kernel+bounces-79624-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79624-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=orange.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B33D2283BA7 for ; Sat, 24 Feb 2024 12:09:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FB383D970; Sat, 24 Feb 2024 12:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=orange.fr header.i=@orange.fr header.b="REp8uHu2" Received: from smtp.smtpout.orange.fr (smtp-23.smtpout.orange.fr [80.12.242.23]) (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 96E9B288DB for ; Sat, 24 Feb 2024 12:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.23 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708776533; cv=none; b=fO7/LHMoOYgcEWQjVm3SVgv919fOZ7o1j23AuOlGRHZGPFpByfBDK6YsYdv0BRUK7VcWWMT78c4Bu29llTqbdLB4Hj2RHjkSs0rD44gu5ClF/eOPNh5+XPSaNIJPBdZzOVTEM/BpwLvGOtguIQdtyS6qGcRph72NIkF3RN20d+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708776533; c=relaxed/simple; bh=UZlUKzJDIE3Ejg/2uPUT90rGzS7fsqyUAE1JCjenB8I=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fSb4otCqK2whSHjSUwkD0fmfu9tjSArJynr9+MhFxuyrIvmvO68yvyqS2U/Q0Pfzj/5qqM20fu02nnPUqeRz21HuLUO5IaWndp3W30rmkXwbXk/ws+G9hMuRIzudmX/VYwPhE8dEHZQwLjw+CdmZamS8w8dCZeQWSjWQiqY+lXk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=orange.fr; spf=pass smtp.mailfrom=orange.fr; dkim=pass (2048-bit key) header.d=orange.fr header.i=@orange.fr header.b=REp8uHu2; arc=none smtp.client-ip=80.12.242.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=orange.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=orange.fr Received: from jules-desktop.dynamic.ziggo.nl ([84.105.71.69]) by smtp.orange.fr with ESMTPA id dqpVrjA78SI7xdqpfr56W6; Sat, 24 Feb 2024 13:08:44 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1708776524; bh=3dYE06cGrljHtTRYwZzkQUBSeOHR9BhQZqpePGYgV5k=; h=From:To:Cc:Subject:Date; b=REp8uHu2ui4eguwwrHv9egWBjrvKQ/OPuzquVqlNFsVZDCAsFKp5KXOl7HyAzyKG9 lDRufFGzsnv4/8tOtEOC5v7s1Bvzk2jr0xEjMj2WXGwyM//U40Ar91dwBQg2qfdwss 3YbBJB3bX3DoYH0hqD7tJRSqlBbsZ+joHR1itXb2AU9ELh7pcODybDZCnlZm43hBc0 sOePrK1IDPbkzblqCkrPjQ+umNNm7mRDdmZ/jDLpFRHv6OymbEezKVGV+bjDji87Q2 ocPa5djoNAM/+c+lwOiyRbjhTDF81Y3DwZm6Vywh96Ed9sL0ui7o4T83DHZeFwMu3J xWNyjttN8n+JQ== X-ME-Helo: jules-desktop.dynamic.ziggo.nl X-ME-Auth: anVsZXMubm9pcmFudEBvcmFuZ2UuZnI= X-ME-Date: Sat, 24 Feb 2024 13:08:44 +0100 X-ME-IP: 84.105.71.69 From: Jules Noirant To: Cc: jikos@kernel.org, Jules Noirant , Benjamin Tissoires , linux-usb@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: usbhid: hid-pidff: fix initialisation for devices that pre-play effects Date: Sat, 24 Feb 2024 13:00:56 +0100 Message-Id: <20240224120056.21251-1-jules.noirant@orange.fr> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791782081443397758 X-GMAIL-MSGID: 1791782081443397758 Some PID compliant devices play effects outside of the usb drivers when you power them, for example an autocenter spring. These effects are thus re-triggered when you reset the device through the driver init sequence, preventing other effects to be played in some cases. This fix makes sure all the effects currently played are stopped after resetting the device. More specifically, it brings compatibility to the Brunner CLS-P joystick and potentially more of their products. Signed-off-by: Jules Noirant --- 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 3b4ee21cd..aade18f9e 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 @@ -1157,6 +1158,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);