From patchwork Mon Jan 15 14:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188207 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1749720dyc; Mon, 15 Jan 2024 06:51:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBQMkt7zv7ZlsQmdMKhU2A2Z7W5pJZCQe3j6yxUkJxUrgDHa19cp2sZsx9XBYRBE2imo8H X-Received: by 2002:a0c:db03:0:b0:680:f84c:f7b0 with SMTP id d3-20020a0cdb03000000b00680f84cf7b0mr6284683qvk.3.1705330310631; Mon, 15 Jan 2024 06:51:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330310; cv=none; d=google.com; s=arc-20160816; b=n4XQ2RCis8rpc2XvOKadP/y7DrUPhuyzyCVsUGCAbvgdX/pTv9hn8rjWW2f/5X6KIs RVdwJ6/S8+gpWwyV4UtYus3vs9YY+/GQC95RvqDw8wqccH4nCp3SdIoK604Ys/z25cHC aJ6dLayzhsAlpdZN2QGU7nRRupg7YsvHAbBdhWv0E5kg+q+cArByPZe6NAaZI01wT70H JHCEjHRLucOaTveuJrB7k+/yj3P5SNDN39wd7Tiu3uZ3+yYkzvlJJbsq44wSR2rrUEp4 P2IwPqUlRjzV4cbJItQgJcldm0wuZcs7pFnFfVJYt0ZdIYUiT3/ZiO1x4pDjBHXcJ5lD PoOw== ARC-Message-Signature: i=1; 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=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=tF1rQHFLyj7ASueY8KSiZTdWkZntXDXK/9xGAr9l+K8n0lB7oS+mwF0IjL/bpurWc3 snlgo2cBHMmlz5zbz7dK7DAF8BaxDpQbHhoUFCzgJVMY8LnPmqo2uRAZPWqGoPNvMJl2 2E8w8qmjjFfYfZ+YXuldmawnLDkBUamo7eXCd/9xdvju3+/mQf/f7Qeg5XrHvVl8SAiJ ZWPyW98mN+syX8veGvahDeDw/WeFXuHYb4imDzbCQ6RB/wBu0UxrYyIMPbNo4lBKtInB wFHtmYs6jWAYJFHgFEOfPZ8ZIF1b4AJkNJlmtARRiskUqwK5Va8Wqq8foB/3YDFPlkbK ++Dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c2-20020a0ce142000000b006812aec8373si956015qvl.430.2024.01.15.06.51.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:51:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26138-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; spf=pass (google.com: domain of linux-kernel+bounces-26138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26138-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 6F13B1C21BB8 for ; Mon, 15 Jan 2024 14:51:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E422A17BAC; Mon, 15 Jan 2024 14:48:58 +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 E7FAB175B5; Mon, 15 Jan 2024 14:48:53 +0000 (UTC) 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 9F44D101601; Mon, 15 Jan 2024 14:48:44 +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 v1 1/7] HID: playstation: DS4: Fix LED blinking Date: Mon, 15 Jan 2024 23:45:32 +0900 Message-Id: <20240115144538.12018-2-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-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: 1788168435385317317 X-GMAIL-MSGID: 1788168435385317317 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 Mon Jan 15 14:45:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188219 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1753027dyc; Mon, 15 Jan 2024 06:58:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEps0kgiohTVIT2WcK53QzHbQ3yV/XX1usrvmKmSSL32+Y36zvJfNHLjQ/BnUFjoKs6+qTz X-Received: by 2002:a05:6a00:2d15:b0:6d9:93cd:ed07 with SMTP id fa21-20020a056a002d1500b006d993cded07mr8488129pfb.24.1705330704216; Mon, 15 Jan 2024 06:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330704; cv=none; d=google.com; s=arc-20160816; b=wfmlJcNxus+eX9hJVcYE5kEzoq/8jwB3p4qvjYuFAbjH1nLl62DslQ6Mq+vrOGE813 Bm/MAHbJnpzlMZJLiCGebZ18sWDw/DcBN4syuTaK053bT8U/WpXGVeptrcz7uAIh4dT5 IBYiiyfsrYNnslSbDzyNP78fNdM0x75Yo3lBO8pF2uYVwD2vtgEKPECzh54jcsTpxgVq YWYQZmvG54xUfKDWeUM3kh6eGpMT+0wUyBVRRl9axqseJpM4D8ygh0/FVED0blDfNKQk gnpEPRAis+9tG/GNoC6NDEWf9sWMw90/7vGOUyBnt91YRiLu0EVsss2gFNzQ2IjDYz4b hIdw== ARC-Message-Signature: i=1; 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=r4qaaG4IzmgUAqzp5BVDGbgAyK8rJWxpNKdkgUFkw7w=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=U+7aKhgoy5tlJ+IlTjJqRhQYl0sr5yLa8zr434UdbwhpzgpvQsIdoPDBmwA8uZfywE qHD8vygvH8+d/pHW0yhGLB07RYplTGF02b2naSfxDKMmWpe/aUNe7qYyjwjYmKkHL7kS JjB4M4n71R49qMJ1OC60fojN9tHNk74CoBirl/g4s0Kg2okh89ztp5Qrf3aqrP4NG5iK Zz8c/iZcetd/nTakY+gnFvuj9JicUYe9W/DhS3i1s5WjI21XcSvmgANf9Epi2dNP4n5q mjn5oa9kUzia5A5U/KIhtl0BawegychNiJRCiPJieWZ99nG8BL3ZEiYBG+GIlaR8QgWL Bo6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26148-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26148-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n8-20020a62e508000000b006d9aab1bbd4si8587726pff.77.2024.01.15.06.58.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:58:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26148-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; spf=pass (google.com: domain of linux-kernel+bounces-26148-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26148-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 0697A282845 for ; Mon, 15 Jan 2024 14:58:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBE7717748; Mon, 15 Jan 2024 14:58:09 +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 DAB4617586; Mon, 15 Jan 2024 14:58:06 +0000 (UTC) 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 41FB5101643; Mon, 15 Jan 2024 14:48:47 +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 v1 2/7] HID: playstation: DS4: Don't fail on MAC address request Date: Mon, 15 Jan 2024 23:45:33 +0900 Message-Id: <20240115144538.12018-3-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-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: 1788168848195020257 X-GMAIL-MSGID: 1788168848195020257 Some third-party controllers can't report their MAC address. Since a unique ID is needed for ps_devices_list_add() and ps_device_register_battery(), let's use hdev->id for this when we don't have a MAC address. Signed-off-by: Max Staudt --- drivers/hid/hid-playstation.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 7f50e13601f0..0a3c442af305 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -1966,7 +1966,10 @@ static int dualshock4_get_mac_address(struct dualshock4 *ds4) DS4_FEATURE_REPORT_PAIRING_INFO_SIZE, false); if (ret) { hid_err(hdev, "Failed to retrieve DualShock4 pairing info: %d\n", ret); - goto err_free; + hid_err(hdev, "Generating fake MAC address for this device.\n"); + buf[1] = (hdev->id >> 0) & 0xff; + buf[2] = (hdev->id >> 8) & 0xff; + buf[3] = (hdev->id >> 16) & 0xff; } memcpy(ds4->base.mac_address, &buf[1], sizeof(ds4->base.mac_address)); @@ -1986,7 +1989,6 @@ static int dualshock4_get_mac_address(struct dualshock4 *ds4) return 0; } -err_free: kfree(buf); return ret; } @@ -2552,7 +2554,7 @@ static struct ps_device *dualshock4_create(struct hid_device *hdev) ret = dualshock4_get_mac_address(ds4); if (ret) { hid_err(hdev, "Failed to get MAC address from DualShock4\n"); - return ERR_PTR(ret); + hid_err(hdev, "Can't detect simultaneous USB/BT connections from this device.\n"); } snprintf(hdev->uniq, sizeof(hdev->uniq), "%pMR", ds4->base.mac_address); From patchwork Mon Jan 15 14:45:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188215 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1751177dyc; Mon, 15 Jan 2024 06:54:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4FuIn1DtOL2b8yes5AWGw9fV5wwAQ1Z1Jviz+IqNYqVj1cvmzqCPlWMzuzqLw4GeWgSDj X-Received: by 2002:a05:6358:189:b0:175:77d7:67b2 with SMTP id d9-20020a056358018900b0017577d767b2mr6383516rwa.32.1705330484723; Mon, 15 Jan 2024 06:54:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330484; cv=none; d=google.com; s=arc-20160816; b=Ww8UwzaeK0/rhXztkf8wUgLsX9n0uJvXc7+yWHIE26A7HKIkjct9pZCPfbwv5Jwo6G td57EeEh2V+DkUdTaS5tu6SHYRyBHPuowc7uZYgGI7I7I8kTFTd1Jn6c/d3E/ER0lp4s YvlY1kN/jURhMB4uuaM6k4k5WsWWvviAmXsanqLU68dS8aB57HbDPd3J1Kr1/0xrdRLJ +Prpfy1g7wLpbD4kCQkb9Uy2GTckZ9YCKtwXV451vlXeFG4zQS9W/iXbnH4fsH2E9Hhp jXdvaKdrJSSia97uSS6lW5j8kbYEtAcJeYb9+WM3UgG6LHHU1KVg9RzQHT9yZZbqPpoU HL/g== ARC-Message-Signature: i=1; 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=hVb10Q92WOfhp2iU7dZiB2FAv+ssZBUdjpky+Xil0g8=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=gPq+HkNMIiyqjjybmI9AfebiOJ8I85Bq9oAPCHQ4JaQkO54nyKEUMlaf1OxgPpseEY ihvJpcesvQH4uBHI5mMWn9/L16xEZz/2Ey2iQ2eKBA8mNhXOgM4a7YhxGRyIDC31bZGm mdZTmhg1+0Byj+3TL12zZrHKZtv4qFmZZBFHuBAUCOJPAHfKxzj8tUyAq6JE/FICKu8n +C6FGxBzwcdvdV3/Mz9fECpnC2l6BJfB4wD1Rl5e9SN+MzXqkpDlq/Zj+KdnWlvxNs9t XlJRRJACqKICNLe1hjIirLBahDQSDOH7+V5+1Vt+Tcpe4YU3dtPrHo968kxfOMyxXdkC tQcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26137-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26137-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e11-20020a65688b000000b005cdf85aa782si8846886pgt.279.2024.01.15.06.54.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:54:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26137-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26137-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26137-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 CA60EB21A84 for ; Mon, 15 Jan 2024 14:51:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E284179B0; Mon, 15 Jan 2024 14:48:58 +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 E7FDF175B6; Mon, 15 Jan 2024 14:48:53 +0000 (UTC) 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 D55ED101649; Mon, 15 Jan 2024 14:48:49 +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 v1 3/7] HID: playstation: DS4: Don't fail on FW/HW version request Date: Mon, 15 Jan 2024 23:45:34 +0900 Message-Id: <20240115144538.12018-4-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-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: 1788168618214485722 X-GMAIL-MSGID: 1788168618214485722 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 0a3c442af305..12321cae4416 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -2561,7 +2561,7 @@ 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_err(hdev, "HW/FW version data in sysfs will be invalid.\n"); } ret = ps_devices_list_add(ps_dev); From patchwork Mon Jan 15 14:45:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1749828dyc; Mon, 15 Jan 2024 06:52:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGwThHDEYXb1PDukXiDpZpsVEVo7EP0AEs8HYcsprrEQRCmkFZZZaPWuz7OkeDn8ghlLKfX X-Received: by 2002:aa7:de0f:0:b0:558:b975:1ff3 with SMTP id h15-20020aa7de0f000000b00558b9751ff3mr5641872edv.6.1705330323468; Mon, 15 Jan 2024 06:52:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330323; cv=none; d=google.com; s=arc-20160816; b=ybJmdshO1Mogqr1xdoAuVNl/iezeGuK8q9Xvu+UMQkIcuk3iFsGeWaofZsxsekjvI/ WQ5dqwvSmnw3h7p4NxiwPMHXE2pI6sStK3wXM6GQ8tQs6tRdD7MPj9HQA0zGoTQnSeD1 ScwEJ/ZYj72EzA1RO7bIGQL1eX+9rf9oYm4RE1Sd4Ui/38n8zFzLh7tqYxSA8i5lK/cu wp79usv+s/1BTjWP5uxyuQHtcH8R5YFMDo2v6W8Kvy5vv7vh07TK7FBIY4947toquAII SXCj1cm/Qz5dwid/z9HJm0V0qtcZS7KOjR23CKkHce0sbKNsfGb4vz2+DXFMfSDvPM1V PONg== ARC-Message-Signature: i=1; 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=uGyy5CQ+VTSM0sTxfsYr6J65ISsTQsrzlVu+E02BlCk=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=vSXG3vV/KWN96IaU9oZ6ClFCc/+YSM3ggNpwHKYseQkSf5MYjRmcKr4ZT7nkJMrFmR IYVkXo+e6zZEQ6A0oqsC+w3WRcoY0iinSTixXJamJG1wLGqXdr3daTPoKyfAxtT83XvT VWd72y67fF6avB+8jItv1FZVqigIGdiEzDfqHKTdG+g6/gkB1azvl+8nfUTqPwmfnRJT AH6jqUo+x64KqK1N2WwUIJrj6I8dkAmBz4keNoBs9MLlkK42ujP3neZGFYCufmlCh8oI wlSozxvIDSAvG0OggFrjLgYcnlrmSb/vUh3kaYri+JeYjBzVCPmXerHt/NgjbHiui3CS JBCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26139-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26139-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g13-20020a0564021ecd00b00558a8415b5asi3774272edg.20.2024.01.15.06.52.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:52:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26139-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26139-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26139-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 14E401F22922 for ; Mon, 15 Jan 2024 14:52:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0410A17BC9; Mon, 15 Jan 2024 14:49:00 +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 8BFF7175B2; Mon, 15 Jan 2024 14:48:56 +0000 (UTC) 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 7859A10164D; Mon, 15 Jan 2024 14:48:52 +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 v1 4/7] HID: playstation: DS4: Don't fail on calibration data request Date: Mon, 15 Jan 2024 23:45:35 +0900 Message-Id: <20240115144538.12018-5-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-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: 1788168448769043097 X-GMAIL-MSGID: 1788168448769043097 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 | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 12321cae4416..2bf44bd3cc8a 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 @@ -1798,24 +1800,25 @@ static int dualshock4_get_calibration_data(struct dualshock4 *ds4) hid_err(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) { + + if (ret) hid_err(hdev, "Failed to retrieve DualShock4 calibration info: %d\n", ret); - goto err_free; - } } + /* 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; } @@ -2571,7 +2577,7 @@ 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_err(hdev, "Gyroscope and accelerometer will be inaccurate.\n"); } ds4->gamepad = ps_gamepad_create(hdev, dualshock4_play_effect); From patchwork Mon Jan 15 14:45:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188216 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1751635dyc; Mon, 15 Jan 2024 06:55:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IEba/84NQQ7Pz0MZnmLDq85LrBGiPklD5q6gq55yFTvKIshczmYs8Aq6l4JKeEIYkSKzO3o X-Received: by 2002:a05:6a00:3d44:b0:6da:63a5:3f32 with SMTP id lp4-20020a056a003d4400b006da63a53f32mr3313483pfb.66.1705330539641; Mon, 15 Jan 2024 06:55:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330539; cv=none; d=google.com; s=arc-20160816; b=MxKzYX7TkZ/kVh0KtYGUq7fbaGYy10ZAwchJzk08p+wuXtVhA5vhtvqpx1ESMO/vTU 1lrW/I13OVx+Spe9M+k4A1o3AMN1YvaoSXiJA8DYJFMhyV2TzEzBYKko8vimsMIqb4bM n7ft8PyFYYXQO9yaPWwTB6qUNbQJNlWBEn62EBwF/wgfXlHE/BjvoJbuloYHRLYXjFMU RFacj7yA1YtfstWdrZUAookZOjF6igqUW7sk9FNJCRIVfMRAfb8aL9WmjU1x0eeWDj+y x28zbKIXNWTWiWClUNJUZj/pcyPXEWMxL2YbkBTG80Yeg1aPUKJM7n3Ir7P3/vFsgfzq GFIA== ARC-Message-Signature: i=1; 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=2fNoNO7qQPplzoaYS5Jc51nKUXMYB6w4HZ1sYBKQ6cU=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=K1+0G+KaPzKSbSTOE0jGrew90pkczXVeeopGuRROTTkcfKMXFo39xqeWUQs1yonaAE BwvesB9WvSZ2n2KDTUqhLQROhLJBCUdM4MyIDSk9Dm/+wSCUkWvkJ4SZpfA/tuVoYK5n eb9DyGh2kxiHjdv46VJOsO5XOLARl3kX2isGBJ7qrwqGaqx6ZdE4i5TZc8Tka5yAioHK tx7ZO38xZSwkmZ6zpxYPRw4neOmvCura/bMkidik+FmadaO6nodljSXCU1LNhqTXeMoY PKAqeBrN9TqS9NKHrl35CJNKd6YeoBEgNHL+n9u97vb+rG3AaWRUDsE7sNrXKfx9iywH eYMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26140-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26140-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d22-20020a63f256000000b005ca4098bf66si8884033pgk.637.2024.01.15.06.55.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:55:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26140-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26140-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26140-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 7BA4CB21EFE for ; Mon, 15 Jan 2024 14:52:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEE8818E2F; Mon, 15 Jan 2024 14:49:01 +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 1634D17BB2; Mon, 15 Jan 2024 14:48:58 +0000 (UTC) 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 17DA8101651; Mon, 15 Jan 2024 14:48:54 +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 v1 5/7] HID: playstation: DS4: Parse minimal report 0x01 Date: Mon, 15 Jan 2024 23:45:36 +0900 Message-Id: <20240115144538.12018-6-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-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: 1788168676119148124 X-GMAIL-MSGID: 1788168676119148124 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index 2bf44bd3cc8a..086b0768fa51 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 @@ -2198,6 +2200,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 @@ -2225,6 +2228,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; @@ -2258,6 +2273,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) + goto finish_minimal; + /* 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]); @@ -2365,6 +2383,7 @@ static int dualshock4_parse_report(struct ps_device *ps_dev, struct hid_report * ps_dev->battery_status = battery_status; spin_unlock_irqrestore(&ps_dev->lock, flags); +finish_minimal: return 0; } From patchwork Mon Jan 15 14:45:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1750074dyc; Mon, 15 Jan 2024 06:52:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBVKO+7dCDY+1+L2P4aZZ7hmqqibXZFjgi+UhbVlc6j4WxJj9yg4zl3rCWJAA71wiCzlnG X-Received: by 2002:a05:622a:344:b0:429:fc1d:55bf with SMTP id r4-20020a05622a034400b00429fc1d55bfmr607682qtw.137.1705330353381; Mon, 15 Jan 2024 06:52:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330353; cv=none; d=google.com; s=arc-20160816; b=CxbK/eeeG/eDVDjNa84TZY1hyeP33Dwsk+3CklCYN20gZvGRGBUo64DcF1lTsRXyqM xfjtTkenyY8UeGxhZLSCV4Y5DE3vv2uE/JmyNr8rmlFnGn3Z4EMAIB+YKCx58aDHZILw OnjVyABfnaF6Kg8MYnO7u/UItaY9pHP6tKEBxQFl3JDXAg0k2ZVT3LjZC1UwS1D3xI2Z Ps2rvjdj25KsgM40FYoMcckAfDxmDIYes65TiO5+N88t+YXzWQfdXjdYOPFGwC9T5jwJ ptdehEgPuWF6R0upDM5cECPH2cZMlalvovcYAWNbZhRH6xl9syJSqu+31bwlwTEkpM5P v52g== ARC-Message-Signature: i=1; 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=eXbtk15WYudYTLt/SuVMuCHdOAKXBpY9iXeaoCEUb5E=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=JV8uJo7DtEFDZYsIHvZJw4leyy45idg8BeVGiuq7p0xkG9Fqh+b1AY/bybKm7J3Xqy kVBwr8VP3+XGsJ6Ao6FU4Zp8z2sS4Q1HfzUUQEYeGT2lXNaHPKYOOjsm9bZL5o+5cYO/ OVsCyPOhEsgoN9WSZcDkNdlroPuZxF+l7ajGxi8VpFn0Supy857S2/rQx0jiZgeP2urR +vl5hNv93OlYfKe/Hu4x4Jz39DFGB32vE4pkdU6bHAW1JySoeVXAWUsMTrzwYbArQ+30 h+tcxH76pi+oLj1+YBscEdx9vnmNnLZ81LaasOkzvEWF82i8KVFwzjIdgrDndhr60eND yGDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26141-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26141-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id s22-20020a05622a019600b004299d9f52a6si8090786qtw.88.2024.01.15.06.52.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:52:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26141-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; spf=pass (google.com: domain of linux-kernel+bounces-26141-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26141-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 304031C21C1C for ; Mon, 15 Jan 2024 14:52:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A31F118ED0; Mon, 15 Jan 2024 14:49:04 +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 B05F717C70; Mon, 15 Jan 2024 14:49:01 +0000 (UTC) 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 AB9F0101653; Mon, 15 Jan 2024 14:48:57 +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 v1 6/7] HID: playstation: Simplify device type ID Date: Mon, 15 Jan 2024 23:45:37 +0900 Message-Id: <20240115144538.12018-7-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-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: 1788168480823229617 X-GMAIL-MSGID: 1788168480823229617 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 086b0768fa51..a0eb36d695d9 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; @@ -2690,17 +2695,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"); @@ -2734,16 +2736,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); From patchwork Mon Jan 15 14:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 188211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1750206dyc; Mon, 15 Jan 2024 06:52:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWM87G10ly5dM9X2zyDmyvGrwQ9RaH8o8ciyqbV9JIqX88W6YOOPpsVHo+dIMFP6dwJ610 X-Received: by 2002:a92:cda6:0:b0:360:63c0:545a with SMTP id g6-20020a92cda6000000b0036063c0545amr10550258ild.6.1705330368566; Mon, 15 Jan 2024 06:52:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330368; cv=none; d=google.com; s=arc-20160816; b=VSsS9bAssfDDhdhADGkiLozAjsHTREj2jrdCE2LwaNGB3G0Trn8Oh0Q8qgAgTmZJWP X4XRf67aDYG8k2MYD7F3jwrFK7Q4u6J02OJRdQmQLfFRTig3TcVLjCx1nhLqW26FlIg0 GWV5uWhWRwiC7cYFD+BDoMg5W3QME1aGQR5nD+qpTgWF/WDFZ8T8B8XD4PxSaWFgxjng VQlyTx/ldWAaDg4WcPawC3ixe8h0DvNl/puuDELmwHdXWvmxGq6naXtnMdG/qJ52GumG sQLZ27zhCzoyQVpXloHU/04TJxB0SNSaS/66YPUgEdG/L74jsNMZiX9fa9iyQX/M65Aq ZpSQ== ARC-Message-Signature: i=1; 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=EScg+YNM1Wa18SHzJHlO1KlYOZOlXiE+1nqdFlpzLcM=; fh=3M1PHg4byxu2MygWip944LqLZSq0Urk5Qa4iYXrexb8=; b=sHe1rpvzRe9q217m3NPq/bU4erJh5d7ysAFbh5fOBREIFhbP3KDw0F3Lm3z9+bs1wz opUDvtSL+HME/vqTCWLzXjqldX3OlpZnokkA+eumBSVhrOWVMkUsGbKxa/ACYUqKHL58 WslWcGD737uDQS0ELnnXIaNlEfyctto+lxWuznQi1FEcmVOlcFjtSJ30NMr4W/I1q/ve BYi6fzd+vi0EIJbArdZG2un4wbvEvBJ0R9UeV5ZLMSn+7+LiJMP32NBZz9hNTGeicktO RXHqM3kddFGYq5DXqB3kqx9rzey8ALqny4ge/R/rxnqcnThOhiTqNassqKjRRR74gnDt Uulw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26142-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26142-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s193-20020a632cca000000b005ce016cce2bsi8725931pgs.190.2024.01.15.06.52.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:52:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26142-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-26142-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26142-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 5AE0B282212 for ; Mon, 15 Jan 2024 14:52:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0607819461; Mon, 15 Jan 2024 14:49:07 +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 4A6D318EC8; Mon, 15 Jan 2024 14:49:03 +0000 (UTC) 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 4A1C7101655; Mon, 15 Jan 2024 14:49:00 +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 v1 7/7] HID: playstation: DS4: Add VID/PID for SZ-MYPOWER controllers Date: Mon, 15 Jan 2024 23:45:38 +0900 Message-Id: <20240115144538.12018-8-max@enpas.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240115144538.12018-1-max@enpas.org> References: <20240115144538.12018-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: 1788168496738538519 X-GMAIL-MSGID: 1788168496738538519 It seems like this USB VID is not officially assigned, so let's create a hid-ids.h entry without a vendor or product name. Signed-off-by: Max Staudt --- drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-playstation.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 72046039d1be..df831ab464a4 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -22,6 +22,9 @@ #define USB_DEVICE_ID_3M2256 0x0502 #define USB_DEVICE_ID_3M3266 0x0506 +#define USB_VENDOR_ID_7545 0x7545 +#define USB_DEVICE_ID_7545_0104 0x0104 + #define USB_VENDOR_ID_A4TECH 0x09da #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 #define USB_DEVICE_ID_A4TECH_X5_005D 0x000a diff --git a/drivers/hid/hid-playstation.c b/drivers/hid/hid-playstation.c index a0eb36d695d9..0aa474f1e96f 100644 --- a/drivers/hid/hid-playstation.c +++ b/drivers/hid/hid-playstation.c @@ -2747,6 +2747,10 @@ static const struct hid_device_id ps_devices[] = { { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE), .driver_data = PS_TYPE_PS4_DUALSHOCK4 }, + /* Third-party controllers identifying as "SZ-MYPOWER" */ + { HID_USB_DEVICE(USB_VENDOR_ID_7545, USB_DEVICE_ID_7545_0104), + .driver_data = PS_TYPE_PS4_DUALSHOCK4 }, + /* Sony DualSense controllers for PS5 */ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS5_CONTROLLER), .driver_data = PS_TYPE_PS5_DUALSENSE },