From patchwork Wed Feb 7 16:36:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 197980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2354557dyb; Wed, 7 Feb 2024 08:38:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUC82ryU6Ma6GT/FsXatuSrNsiHTZRzURMHYIkH0hkqMS3LkPcmoqx5PL0ZDv1EyHmGe0Bz71piG6RObG5zPH8CiCvt4Q== X-Google-Smtp-Source: AGHT+IHgu92ZdrgLz+J8A4LQgLkqgLEY7hcYpvglmgyfSIIqUFeYgEyWO8yZ/MNwAub2SOFvyr4Z X-Received: by 2002:a05:6808:3027:b0:3be:2057:c20d with SMTP id ay39-20020a056808302700b003be2057c20dmr7199980oib.32.1707323905118; Wed, 07 Feb 2024 08:38:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707323905; cv=pass; d=google.com; s=arc-20160816; b=CFvEMQJpdS3P5MIH/Zh53FI1PjpQIQjJdj5wueM1k8q44NSVVXoFDF76JN5/25ZPt4 L5XAOKMQwtB/dFMULBhbe01+IyD4EiLVIrliYy9reJ4uJG+xWMU3jxrYNvgabajbVTjB nHWtCwSPjgS4w0c0He7MUeXkqK/bc+0ANmRU13WVc2Jm3E3n6kMS0W0MH4lcdYrWhql/ 8s3tM4SvgOyiF9nT2vRQG606u/BmuUYAOvBLPC+icEy/zXvGa7cBG8xM6py9KrqstkU1 oFpqv3ldJc45kRxISmY+de+geY4vCrnK6jtt6PbGh/MwYABp8xX6pN8KUp4qPaV/bRbE 5KGg== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Q7ky0jJf6VW4JTJaAMl9SwzWpwd6q3Bu4BdjaP0tTqU=; fh=IsJUmiHS6FykBd58Ld+rfynAXxv3N+I2W7I9GUEy6uA=; b=BUNm9PJ3GejBqm64SCNmD8BsXEkOJgCo1oDdN0LzYvVlPrSKxe0FQZtlYr4ANCnMdF Q+Eza6KxfOVAZjQJDxBsO4fQ76VbWkFMJqC7WUsZ7/e7S+pUoegZq10WLgVnBaJPI8ZO qreIoLcF5VFMa8VXWeApMBCEnHCbnwxftLFFU9niSzV5lb17QkrAidamYccgXqjalBJr X4XM2EvQyyDGFQX5BB2916+a+8TEA/Cq+9OYHLprtrTd2Sm1z2T+Lz/Kkloz99RLcXrl yqneqHEVXoDE0Y8MvM8/PUCDKIemZ2HrH9F9Uyc+O1cQzkJMoTLRmjzMwcq2oopa/tW0 z7HA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56778-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56778-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVs15yaQdZuIUafzY2f7m+u9PrC8ToLh+NvRY9GJ7fVYV2AUGfXqD/so3qoxnikQ6Efo5bKIMGq+nb4qv0JEvzw8QbmIA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a9-20020a05622a064900b0042c4208f213si1220741qtb.44.2024.02.07.08.38.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 08:38:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56778-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56778-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56778-ouuuleilei=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DF8091C23FB1 for ; Wed, 7 Feb 2024 16:38:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A0A982894; Wed, 7 Feb 2024 16:37:42 +0000 (UTC) Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) (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 0D182383BE; Wed, 7 Feb 2024 16:37:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.38.239.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323860; cv=none; b=iqz84/QzPKbN+Xp8jls0n/4Z2TxCaIcHNT+Z8MoVgQNjvjeFVj0FYK6s8Tc36QtmvBfs88LxkAJQ74bRGppFfGgQiAq6nvt05fF4zE44tWdfQsP54IEf+UHXAtSSVNl6fnSHntYKuOYIYqcmqNyUhnMigQnbOgiEpO0676BvDSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323860; c=relaxed/simple; bh=fWmHp9qGndSO8LmViime1duZ9oQo6Xowt2wrijb+7as=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XVear25+G38j5DiG+vlM0PK8lXLRAqDeqyeIM5eDxlebm+AqXeO9Cep9rPU0y9ofCfR+1kS67zkG4EQpwfKayUGJK47N7OJfRLiGLy7dmlrSBDV3Ds8jzc78KPnGQ5QvGpvY+YbarZm3KQHra0PNbJPr1zUHRxq0jfAkABZNk8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org; spf=pass smtp.mailfrom=enpas.org; arc=none smtp.client-ip=46.38.239.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enpas.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 2442E100BBA; Wed, 7 Feb 2024 16:37:28 +0000 (UTC) From: Max Staudt To: Roderick Colenbrander , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, max@enpas.org Subject: [PATCH v2 1/5] HID: playstation: DS4: Fix LED blinking Date: Thu, 8 Feb 2024 01:36:43 +0900 Message-Id: <20240207163647.15792-2-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207163647.15792-1-max@enpas.org> References: <20240207163647.15792-1-max@enpas.org> 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: 1790258871279439064 X-GMAIL-MSGID: 1790258871279439064 There was no way to disable blinking once enabled. Disable it on brightness = 0, as per the Linux LED spec. The driver reports back the values it sends to the controller, but they need to be scaled back to milliseconds. Setting the LED blinking via sysfs works as expected now. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 8ac8f7b8e317..7f50e13601f0 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -2037,8 +2037,9 @@ static int dualshock4_led_set_blink(struct led_classdev *led, unsigned long *del dualshock4_schedule_work(ds4); - *delay_on = ds4->lightbar_blink_on; - *delay_off = ds4->lightbar_blink_off; + /* Report scaled values back to LED subsystem */ + *delay_on = ds4->lightbar_blink_on * 10; + *delay_off = ds4->lightbar_blink_off * 10; return 0; } @@ -2065,6 +2066,13 @@ static int dualshock4_led_set_brightness(struct led_classdev *led, enum led_brig break; case 3: ds4->lightbar_enabled = !!value; + + /* brightness = 0 also cancels blinking in Linux. */ + if (!ds4->lightbar_enabled) { + ds4->lightbar_blink_off = 0; + ds4->lightbar_blink_on = 0; + ds4->update_lightbar_blink = true; + } } ds4->update_lightbar = true; From patchwork Wed Feb 7 16:36:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 197984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2356787dyb; Wed, 7 Feb 2024 08:42:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb7DWlKkKDVZ6Xu9MQ3rLp83QaS3NrCugA3gnJ4LS+WKtkG2qMXnoVwyKPkkkpDIXMe62e X-Received: by 2002:a05:6871:6a3:b0:218:f001:10bf with SMTP id l35-20020a05687106a300b00218f00110bfmr6373496oao.35.1707324133776; Wed, 07 Feb 2024 08:42:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707324133; cv=pass; d=google.com; s=arc-20160816; b=SZ63rj/Mr3jX92q2c8TtvUR/1u/PTa/w9sysYJdaxQ3hmjlAlvhl6BXmft/XkqzxPF m+C198LY7Lm44tx6fyB0/vpVMOI93SszdYXx3eO0/j4byVo41AdCt9neXhYjPVMBCXKc G1p5n6wIRQS8vKORZCpoO8+dkgO2XxOZ48MGl9KW/50sTU+SofitFsRTX8oRlIOCQXOJ unHySlJ5QeyKlJqhhkfRe1IZz3GWq/4FOPbYBXw2DgeFuoyQdmkT/gJzADfKQc3a69Qp wbUgj8va5tvwjWL6mMFgwnpYh+Lt7HKAPQOQLcMnj3a1gJMCLuitm0DLzOw8IojI4NNj sOdw== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=9XoQ1cGEBVAP26sn/kYXSlqM2SvncsCnA71ZRUcS508=; fh=VolOH7Q0DxjqppVVUAaJqWsvlSks59L0hqly6sfDc9M=; b=epxGkTl7mdP2XlMHVGrFKlh5DlfJj7/03mklg+Njb4lmQATXatbs/P8SXoUEcalXmn a/8isa2Ts5lIQk8LlFH/T9QXMH/0uUjwAuNcJ8nj7OF5kXPjWZADN+E3T6y8Rq2Qanb+ URY7qyQNakQyhPiGnfClT6pbj/tzf082ymAQdBKiKGOgZuH6guohGmBrlVICifo6zq5j ctuYt5DX8INNPndAa/TbpQ8MAVEj9mveBl640Z2Ngvo3XgiiyMbv+CWxG/VQmPjt9qfr rweXWYDUAVqYE52qseHogVlcv/7CwsXo7w0mHxTASNs6Mw9ndvMeLCQR4rAtqiImNWTw JI7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56780-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56780-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVoSG/CSPDturiSxAwc0ueMbOmwHldstF8V+FDT0ePfgPw0FGK3Jx+VGVOj5tF2rU8jfHCTRw2Mq0Usr4QFLRxLfHkskg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id j62-20020a638b41000000b005ce016cce21si1773084pge.191.2024.02.07.08.42.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 08:42:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56780-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56780-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56780-ouuuleilei=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 37B17B28C2B for ; Wed, 7 Feb 2024 16:38:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C745082D68; Wed, 7 Feb 2024 16:37:44 +0000 (UTC) Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) (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 7E045823BF; Wed, 7 Feb 2024 16:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.38.239.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323863; cv=none; b=iZ6IJItjKGV+Xkema5l8n5dq/GfxxZ/4JKY55dO5/bjdaXDD3DxWP2hwKuXHsb0brkRUPKFyCPA3Re+Hbkp5TeOzEl3WBOHNkM/dzA1DIUVp5m2zUzmz7iBkdCNlSFiNry7KT6CXR+XcW8X3zy5EqsXVzXzpaOZ40k/FKmrEDBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323863; c=relaxed/simple; bh=lOHItdgJbiCuF+QTQQRRcLdSwBfpIamrEpzDEwqonUA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fuqZhe5xJt33j/2XwLLNQbN3yP+jCMIv2PXs1jAPoe3/CR8vVGtHVuKZHdjGqYiWwiB1fwOUe7w3fx69qRWTJhvfpmODtRShQyUCICOp3ofvkZxiEwAETPBMgdqSdAcawhb8pz7JSM5uz3QvpgRztXAbmD4ExkkA5YdVsLLt8+0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org; spf=pass smtp.mailfrom=enpas.org; arc=none smtp.client-ip=46.38.239.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enpas.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id C04F7100BB9; Wed, 7 Feb 2024 16:37:31 +0000 (UTC) From: Max Staudt To: Roderick Colenbrander , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, max@enpas.org Subject: [PATCH v2 2/5] HID: playstation: DS4: Don't fail on FW/HW version request Date: Thu, 8 Feb 2024 01:36:44 +0900 Message-Id: <20240207163647.15792-3-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207163647.15792-1-max@enpas.org> References: <20240207163647.15792-1-max@enpas.org> 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: 1790259111002221133 X-GMAIL-MSGID: 1790259111002221133 Some third-party controllers can't report firmware/hardware version. Unlike for the DualSense, the driver does not use these values for anything in the DualShock 4 case, but merely exposes them via sysfs. They will simply be 0x0. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 7f50e13601f0..df50ca4dab90 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -2558,8 +2558,8 @@ static struct ps_device *dualshock4_create(struct hid_device *hdev) ret = dualshock4_get_firmware_info(ds4); if (ret) { - hid_err(hdev, "Failed to get firmware info from DualShock4\n"); - return ERR_PTR(ret); + hid_warn(hdev, "Failed to get firmware info from DualShock4\n"); + hid_warn(hdev, "HW/FW version data in sysfs will be invalid.\n"); } ret = ps_devices_list_add(ps_dev); From patchwork Wed Feb 7 16:36:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 197981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2354565dyb; Wed, 7 Feb 2024 08:38:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4hgAaOwIZSYT6GkS584DGmR8vX3keYJWt79OPZYs60OFwiPbYt981WdIkSu7+B5yItEZ8 X-Received: by 2002:a9d:7ac5:0:b0:6e1:377e:c413 with SMTP id m5-20020a9d7ac5000000b006e1377ec413mr7085124otn.27.1707323905673; Wed, 07 Feb 2024 08:38:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707323905; cv=pass; d=google.com; s=arc-20160816; b=ulU8OXIRum55VueFesmC2PX/u4o7+YMqq9H4rqQaJfvHNCWBmsv6hK/u+7tz74UzJa UnynCTcZn2XYdJ7JtvNKevyk1WeZq7xZqeIxR1ylySe5HZYPIVkmRILLF2YamdqF4t/g TlzXhC7S4lYbWn86leynhs3L46IN/k5Gs99OCXG8NE2iztjUyaNZY4uWj8RVAmgtP3dE cv1jM8Jvn//sB3FiLFcw0VLbOCOuWg3wQUTGu/EPNX9av3yYXULB+zI+GuN3h0J90xI6 1mXIldKMyzwg5dO+r3zW29a8E3kbJG/lOZ+oxAWMvPjxS0DE3OnXa1yYB33dlEaGbQkY 3DUA== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=qxIeEi5peV0OLUuKYYF+dTjqsIYyD1FPg3/7V75r7uo=; fh=Ip5sdu2CDnn7gC6vIk7W5FkWkYHz558FphrleyKkkqw=; b=rxVljCQLIQv0atePzK0dBtfLU6mBS+PmIn7dJ6Dqg/M5MyUx4vqWfUAsd529hPy8Zp vWiUXKskt1/BSTNEHvn8JB3s03Zpc7Vf+ZP11uncjCtMv3rJdO52/DF6QTDYEOR9BY1S 5AEJG7A+v2ed51Gd3nnXF4vfkm4OYDbUutQ8U74cNkj2viPs/fp6lEBRue5v0PRAEkbH vaj7EENmcfRL4lTOtou2+pvGS3XkHjkBMGJRxp4NagbcQktAINHir0mYee0dL62eAHrS Gw7UBmaGw/BEZ4h4zVuslWaTpZjpuGehcdUMHuMN1KyuNQJrWIrI25E4TGilkOTl5M86 7MHA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56777-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56777-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWZ+eRoWHvijxj+N5+9V7wXSCkX8QpqqT4P66e9+vtNnJCPhgZxS7nvEQwPpTcArq6tppYriBNKyJwv7mrtZDz5yVG8MQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n4-20020a05622a11c400b0042c312be382si1442285qtk.539.2024.02.07.08.38.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 08:38:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56777-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56777-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56777-ouuuleilei=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 69DFA1C21CC3 for ; Wed, 7 Feb 2024 16:38:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A3B982897; Wed, 7 Feb 2024 16:37:42 +0000 (UTC) Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) (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 5595033CA; Wed, 7 Feb 2024 16:37:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.38.239.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323860; cv=none; b=NowLc3Y4tzVEpgtAQSBrsT4En2O4335C0r9FDHV0SwhsciZXElnI8L2YItR35Lao3RIsWy4eHLaZ8mpuc7SmaS0Dz3+31DOcBdT+GWvYdQkXiNTkj9KgpPe8F1lbVbOAS0fqa/bkpHUcyl1iXol+9+Is1zKYytsdk3UW6YyBmkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323860; c=relaxed/simple; bh=vqtUsSo5ghicGhv7xGcTyQ2ci1iQwKusQkLqNXAcFzo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sJDOYtwd/VghDpaals8pnlZZZy3oeZ5A60WmdRG1X7NrkAtcSbJ2hT8VTlX595Cx+OVdvv1OblU/6aScnp/vLIyPligyOZj3EQivCr6ablmKw1ejuy9R+egbSZpfXA34vlHnjDQqcAYu10gtjEfldVspPAM7VnkijrV5+NnChiI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org; spf=pass smtp.mailfrom=enpas.org; arc=none smtp.client-ip=46.38.239.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enpas.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 5B9A4100BC4; Wed, 7 Feb 2024 16:37:34 +0000 (UTC) From: Max Staudt To: Roderick Colenbrander , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, max@enpas.org Subject: [PATCH v2 3/5] HID: playstation: DS4: Don't fail on calibration data request Date: Thu, 8 Feb 2024 01:36:45 +0900 Message-Id: <20240207163647.15792-4-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207163647.15792-1-max@enpas.org> References: <20240207163647.15792-1-max@enpas.org> 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: 1790258871894513545 X-GMAIL-MSGID: 1790258871894513545 Some third-party controllers can't report calibration data for the gyro/accelerometer. We can still use the gamepad as-is, so let's do that. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index df50ca4dab90..53bfc2828a61 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -1778,8 +1778,10 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4) int retries; buf = kzalloc(DS4_FEATURE_REPORT_CALIBRATION_SIZE, GFP_KERNEL); - if (!buf) - return -ENOMEM; + if (!buf) { + ret = -ENOMEM; + goto no_buffer_tail_check; + } /* We should normally receive the feature report data we asked * for, but hidraw applications such as Steam can issue feature @@ -1796,26 +1798,27 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4) continue; } - hid_err(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret); + hid_warn(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret); ret = -EILSEQ; - goto err_free; } else { break; } } } else { /* Bluetooth */ buf = kzalloc(DS4_FEATURE_REPORT_CALIBRATION_BT_SIZE, GFP_KERNEL); - if (!buf) - return -ENOMEM; + if (!buf) { + ret = -ENOMEM; + goto no_buffer_tail_check; + } ret = ps_get_report(hdev, DS4_FEATURE_REPORT_CALIBRATION_BT, buf, DS4_FEATURE_REPORT_CALIBRATION_BT_SIZE, true); - if (ret) { - hid_err(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret); - goto err_free; - } + + if (ret) + hid_warn(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret); } + /* Parse buffer. If the transfer failed, this safely copies zeroes. */ gyro_pitch_bias = get_unaligned_le16(&buf[1]); gyro_yaw_bias = get_unaligned_le16(&buf[3]); gyro_roll_bias = get_unaligned_le16(&buf[5]); @@ -1867,6 +1870,11 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4) ds4->gyro_calib_data[2].sens_denom = abs(gyro_roll_plus - gyro_roll_bias) + abs(gyro_roll_minus - gyro_roll_bias); + /* Done parsing the buffer, so let's free it. */ + kfree(buf); + +no_buffer_tail_check: + /* * Sanity check gyro calibration data. This is needed to prevent crashes * during report handling of virtual, clone or broken devices not implementing @@ -1919,8 +1927,6 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4) } } -err_free: - kfree(buf); return ret; } @@ -2568,8 +2574,8 @@ static struct ps_device *dualshock4_create(struct hid_device *hdev) ret = dualshock4_get_calibration_data(ds4); if (ret) { - hid_err(hdev, "Failed to get calibration data from DualShock4\n"); - goto err; + hid_warn(hdev, "Failed to get calibration data from DualShock4\n"); + hid_warn(hdev, "Gyroscope and accelerometer will be inaccurate.\n"); } ds4->gamepad = ps_gamepad_create(hdev, dualshock4_play_effect); From patchwork Wed Feb 7 16:36:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 197982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2354750dyb; Wed, 7 Feb 2024 08:38:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEObvhR2q4mU2LN9pIOCaChFkwcjsmyE1BnKJdmaVKynkJX2j3bvuQt7/sCaWi1ryTjyE0q X-Received: by 2002:ac8:5745:0:b0:42b:ebf7:d207 with SMTP id 5-20020ac85745000000b0042bebf7d207mr12302123qtx.29.1707323929686; Wed, 07 Feb 2024 08:38:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707323929; cv=pass; d=google.com; s=arc-20160816; b=lIMSe8UYRgfSaaNMXaPnpwEXVvuIGS8RKznDFwRwCurxcdFt2alsn2HyqPGIQqaa9r OXxxndTe0TTdskVcjHGBHad39a3Yd0XuOGeikE+IwxntvpZOfezw1mcItBbvgUcOJDkw 7bU56lU0WM4H3cd4ZW5T/UlURvZFcZlZLOyE28Ax/tJTnIAMg6GbcTWnmprYcwnd9YhR pHL4RGcK9NuvzpWrsiDZEJk2byykUpFddtsW5qiFJrXmDSjc8oxZ6adMDORKvp3FK2Bo cR94Vqawy05Xan8c/hWBNSnm5+9irBbWb9xNOl3YDkRyxUQKt8EoolvwcqKgPNK4csgt 6S2w== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=DYcxHMp8TVrNLZx0/+JngQEllD7xCCB/A6RdEAC4xcA=; fh=PNvzbpw3oMXduP9ctf9aNQ0ZOdjOZK0YPmZc9NkB9Mg=; b=xmSgs1BI0+oGQKBe0etzkqAI1UPG9cY6G57N87iuL2neBbhucVDWib0V6QL+FBr2iX 1l1vv2JAsKma6Hq6+yoN6dxCdksGMUL0ri+sB4XALkjPx2AX5mEDqRqMoDNideHGJm6G KX1FKxT2yVRfqWx2kZ8Bj/ibKP06LXvgR0SlLfRyES3H6rcXBBDcbVDs3B4pKwqINGFz 5CceU7OCtG8qYlKVOLrNlr38v5xq4CNHz+EvsaP1Vbqo8iiezD0AaS9+J4yofjIHBRK0 6/r8QDbC4ZP+qX5gN/1e7FYb01lqTg20fP/GxKRJF+qYmadeLZfm443H0uy22YyRWvjp InWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56779-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56779-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUoKgMsSszs8/CjmMlzR19GOLF0WkZpfqhjUHaTNnVHVTurgZdynWxWqrNfDG6hnyjwMd4SLtlx3u9Xr9Ly6M4J2P7NGQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e9-20020ac85989000000b0042c3a23133fsi1420081qte.572.2024.02.07.08.38.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 08:38:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56779-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56779-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56779-ouuuleilei=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 793D91C212F8 for ; Wed, 7 Feb 2024 16:38:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17E9E82D9E; Wed, 7 Feb 2024 16:37:44 +0000 (UTC) Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) (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 D3B1881AD4; Wed, 7 Feb 2024 16:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.38.239.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323862; cv=none; b=lsgA6ji51vbOQ41K0RLVnTFCnC/MCqQGnlCdPhUCcghMof2nTpPgUBgCfYHfl7tgwptbagEfEXjJKj7L0HizGySCxVVrJdC2Jmrr6Cj+k3SyVwhFM34uL70IprlkPYe5lbQUY0jcd+Zo6EN+NPbZDY/IAVm0nrOR6A0LnNEMQHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323862; c=relaxed/simple; bh=6ibKIqdKNK6p4jvhKmJBITPzh/ZNI0jwLkDjKmkAYQ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JD718r7I+pwTZ1I6RaIEJZnoSzRwRDFGKCvR5OXDBBq+7kG4f34zACfNRGYvLTy3Xwy6FriKxN0ME+MGF3rHZ91gkP5HDTcJqfOYkWt8FF0hsYw8FXHBSWRgDBt1Ia+BWczYXclB0gD+ijmtCzWfPksvF2e1AbB55yY6lOzedhY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org; spf=pass smtp.mailfrom=enpas.org; arc=none smtp.client-ip=46.38.239.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enpas.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id EC8F2100BC6; Wed, 7 Feb 2024 16:37:36 +0000 (UTC) From: Max Staudt To: Roderick Colenbrander , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, max@enpas.org Subject: [PATCH v2 4/5] HID: playstation: DS4: Parse minimal report 0x01 Date: Thu, 8 Feb 2024 01:36:46 +0900 Message-Id: <20240207163647.15792-5-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207163647.15792-1-max@enpas.org> References: <20240207163647.15792-1-max@enpas.org> 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: 1790258897045938231 X-GMAIL-MSGID: 1790258897045938231 Some third-party controllers never switch to the full 0x11 report. They keep sending the short 0x01 report, so let's parse that instead. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 53bfc2828a61..6b0f25688657 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -287,6 +287,8 @@ struct dualsense_output_report { #define DS4_INPUT_REPORT_USB 0x01 #define DS4_INPUT_REPORT_USB_SIZE 64 +#define DS4_INPUT_REPORT_BT_MINIMAL 0x01 +#define DS4_INPUT_REPORT_BT_MINIMAL_SIZE 10 #define DS4_INPUT_REPORT_BT 0x11 #define DS4_INPUT_REPORT_BT_SIZE 78 #define DS4_OUTPUT_REPORT_USB 0x05 @@ -2196,6 +2198,7 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report * int battery_status, i, j; uint16_t sensor_timestamp; unsigned long flags; + bool is_minimal = false; /* * DualShock4 in USB uses the full HID report for reportID 1, but @@ -2223,6 +2226,18 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report * ds4_report = &bt->common; num_touch_reports = bt->num_touch_reports; touch_reports = bt->touch_reports; + } else if (hdev->bus == BUS_BLUETOOTH && + report->id == DS4_INPUT_REPORT_BT_MINIMAL && + size == DS4_INPUT_REPORT_BT_MINIMAL_SIZE) { + /* Some third-party pads never switch to the full 0x11 report. + * The short 0x01 report is 10 bytes long: + * u8 report_id == 0x01 + * u8 first_bytes_of_full_report[9] + * So let's reuse the full report parser, and stop it after + * parsing the buttons. + */ + ds4_report = (struct dualshock4_input_report_common *)&data[1]; + is_minimal = true; } else { hid_err(hdev, "Unhandled reportID=%d\n", report->id); return -1; @@ -2256,6 +2271,9 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report * input_report_key(ds4->gamepad, BTN_MODE, ds4_report->buttons[2] & DS_BUTTONS2_PS_HOME); input_sync(ds4->gamepad); + if (is_minimal) + return 0; + /* Parse and calibrate gyroscope data. */ for (i = 0; i < ARRAY_SIZE(ds4_report->gyro); i++) { int raw_data = (short)le16_to_cpu(ds4_report->gyro[i]); From patchwork Wed Feb 7 16:36:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 197983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2356268dyb; Wed, 7 Feb 2024 08:41:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHskcEeV4Tvgr/M/7B8W4BtcJjueGgZ6l2DSb+YtZM+ANuALBiOgMXXzDIKWdwRCalfKc9 X-Received: by 2002:a17:903:228b:b0:1d9:f313:60a2 with SMTP id b11-20020a170903228b00b001d9f31360a2mr1904242plh.38.1707324082491; Wed, 07 Feb 2024 08:41:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707324082; cv=pass; d=google.com; s=arc-20160816; b=qF3a7LgZCy0UB0BZuPPcJj4aXhxFp96Yq6wsmkeaLprbZiSZQrMym0ei2bKFWaFrTR LpQlp4ZPOrb4yedqpRf5T6aL0a6Pj6lJxHXZOSk1c4VZfM59MtCy66qwtv/fFWBDlsXa 2g5O0rd2aUCPS3gQGzDtO0gy0K+w9dXhxhQVmIOIAm3oBCA1OFLm7okkT5LLM+ECbBAj WdvzkGZrcIWB4GJMFJI8hoGDvcKBVDS2jSESivAAKkLv891iwjnSZftb2WFuJdl2i3+V iEnMYNnPKAbsf85Z69LyYyelsPUhNxEiZ6DagnZ951ft83wmb0T2nnnXwK745Bm8AwMO Jalw== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Bx9vOdRmfjlnuTOwtrMELPnt4tiBPeQAgv5einhly1o=; fh=zxWovfB/STfZ6PsjXtdCUZCHY231sk8S+/fxB+TrASA=; b=ytYazUIHs5EEW+/+8fVw+GWXhOd7yWTYf01WsjgE6TCpD1HbzLW/jstTuEXKHEDDQd wSHxHgdZYavYW6uj1Ph3FXKzpXfcnn/9MsNncBgxG1PMHfAFBj2UxLulQiUckeOINu8h ne5+Ok3CmCNI0wjtpjp1PQyynb3c84LjRGYDJQ4VvSWPxeKUoqFfkB2U1bNEMwQ7wqP/ 8JK8C2RzQ0kKgHzD7KYQwsb7qLd30hXCBV4QjMqyP1jowOM4WzHsJvE6o2yNN8QfSJmX Rs6yCRAWPk5WM7p2hygtLNn1nkPp9x5u1p5UaTPvJ1C3KKYEfk/5OxuBXLvSa/1621AO M0gA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56781-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56781-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUXKqJYVBPJPLdvC89cQpLDF9ZM1CP+7QUp/P2eRrA/OiV+OWSsCy9ovrTfuSVcFyMDvuWyhVy7z7dqi3Vcg8lIhhYLvA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n5-20020a170902e54500b001d51f6f28cesi2110658plf.142.2024.02.07.08.41.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 08:41:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56781-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; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56781-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56781-ouuuleilei=gmail.com@vger.kernel.org" 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 D358F288BE2 for ; Wed, 7 Feb 2024 16:39:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4860683CCD; Wed, 7 Feb 2024 16:37:46 +0000 (UTC) Received: from mail.enpas.org (zhong.enpas.org [46.38.239.100]) (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 42AD982D6C; Wed, 7 Feb 2024 16:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.38.239.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323864; cv=none; b=rB+YTvR+82XREK8CPXpm1N9RRJ580uKL6YIEkb998tMcl0A1l88LCqeS29SP+xEw4QIG7Mjkzj7CUF++BmK4vA8AWVlra4R9V/LpVkMLmbQwEZAYxS0of5FlZDO/asKHw4gFK+PtOtmZP9H6KIbWKYypcHT6hZzXwIXBrKq+Xc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707323864; c=relaxed/simple; bh=ht0PP+NQoSopSGNlDo9KrMKWZ0EUv1IshXzKGdpnxi0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pt7Ti4GW2G5xD7fGJ34i3jPIswU9581RQEI2QhiJaGFCCN9skFDiiZOUsDhG7TgdhekBiIARr9741D3Vi9fYRr8hkXotjUem69cZQZ5ed8YZ3lZ+Z824hOe8mNvCFLJ8rehj9H2IJAWrOi5AO1RENBGM0fE0ZuQqjdfDx3l45UM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org; spf=pass smtp.mailfrom=enpas.org; arc=none smtp.client-ip=46.38.239.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=enpas.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enpas.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 84677100072; Wed, 7 Feb 2024 16:37:39 +0000 (UTC) From: Max Staudt To: Roderick Colenbrander , Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, max@enpas.org Subject: [PATCH v2 5/5] HID: playstation: Simplify device type ID Date: Thu, 8 Feb 2024 01:36:47 +0900 Message-Id: <20240207163647.15792-6-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240207163647.15792-1-max@enpas.org> References: <20240207163647.15792-1-max@enpas.org> 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: 1790259057048344967 X-GMAIL-MSGID: 1790259057048344967 Distinguish PS4/PS5 type controllers using .driver_data in MODULE_DEVICE_TABLE rather than by VID/PID. This allows adding compatible controllers with different VID/PID. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 40 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 6b0f25688657..edc46fc02e9a 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -27,6 +27,11 @@ static DEFINE_IDA(ps_player_id_allocator); #define HID_PLAYSTATION_VERSION_PATCH 0x8000 +enum PS_TYPE { + PS_TYPE_PS4_DUALSHOCK4, + PS_TYPE_PS5_DUALSENSE, +}; + /* Base class for playstation devices. */ struct ps_device { struct list_head list; @@ -2687,17 +2692,14 @@ static int ps_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err_stop; } - if (hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER || - hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 || - hdev->product == USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) { + if (id->driver_data == PS_TYPE_PS4_DUALSHOCK4) { dev = dualshock4_create(hdev); if (IS_ERR(dev)) { hid_err(hdev, "Failed to create dualshock4.\n"); ret = PTR_ERR(dev); goto err_close; } - } else if (hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER || - hdev->product == USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) { + } else if (id->driver_data == PS_TYPE_PS5_DUALSENSE) { dev = dualsense_create(hdev); if (IS_ERR(dev)) { hid_err(hdev, "Failed to create dualsense.\n"); @@ -2731,16 +2733,26 @@ static void ps_remove(struct hid_device *hdev) static const struct hid_device_id ps_devices[] = { /* Sony DualShock 4 controllers for PS4 */ - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) }, - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER) }, - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2) }, - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2) }, - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE) }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER), + .driver_data = PS_TYPE_PS4_DUALSHOCK4 }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER), + .driver_data = PS_TYPE_PS4_DUALSHOCK4 }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2), + .driver_data = PS_TYPE_PS4_DUALSHOCK4 }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2), + .driver_data = PS_TYPE_PS4_DUALSHOCK4 }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE), + .driver_data = PS_TYPE_PS4_DUALSHOCK4 }, + /* Sony DualSense controllers for PS5 */ - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER) }, - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER) }, - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) }, - { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER_2) }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER), + .driver_data = PS_TYPE_PS5_DUALSENSE }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER), + .driver_data = PS_TYPE_PS5_DUALSENSE }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER_2), + .driver_data = PS_TYPE_PS5_DUALSENSE }, + { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER_2), + .driver_data = PS_TYPE_PS5_DUALSENSE }, { } }; MODULE_DEVICE_TABLE(hid, ps_devices);