Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp425754rdh; Wed, 7 Feb 2024 08:38:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXf0+cdQAQhRA9WYma9zEfCYKpAZEgk0fUcBqqnBRTGwAyiLu2mmUn4HS1Buzcn/IDYfxpnCqPi/Cpa3ZaL3GRKmKo2viu0hhzOa38j9g== X-Google-Smtp-Source: AGHT+IFZcnzFZ/1Dq+VGD3Ya78L9ycUPGLC92Jyv9TZuVV5sJBmNAjyrwOVe2iIPvSdXTx7hZcNx X-Received: by 2002:a05:6e02:1e0a:b0:363:cedf:678b with SMTP id g10-20020a056e021e0a00b00363cedf678bmr9675055ila.22.1707323886705; Wed, 07 Feb 2024 08:38:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707323886; cv=pass; d=google.com; s=arc-20160816; b=RTkQ3c1t/4Thmqv2Vcbxes9YRkzjDlVkb9QSjAyA/7XQf+OInimTcg+IvlfdR4yGCX 5LNhU4gX4INDJiGdB1y7WAwW9oTogH6PHvtO0bUBusAMwUtrfgz2ImYIq6AC3c0lC6q8 2q5h4DZ+aJ5Eq3DxggtuPj+mZ7EqGT0GZKmy15udh39GCEHs+6t2EduNxWcMvDHJVMnV MktIt05xNkb79GcVZfMTnn5JtT1kNCUWRouHOz3RscpJxTVAorlJq/p5UC2i9FkwipPU pf+qWzL3fw8TbqoMzgukuTScnDyx4P6F+3Yc6bDsiWqoNCIcpZBIhXsDxDasN9yV2ogd /BtA== 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=L/sunb6pZVr4b8aizcpdGNt7bDbswIXH4tSdNenX8lQ=; b=KH76EOveChrDob6NlwbPfavFvlDrFxhmtOmxYcSYZbHADe5kr5hqknObZQsFhU1coQ edIhXjsYTq1Or+chbkFC95hsq7RKmV/iaeecJB01LGWRWwaWi1o3uZhINz1K10LO0LoE 4Sc8sy+ttvngX10G9j6EOG+x/5xAkYxhrSr63cb7jTduiBLI+P1umowTwYugTi12qTfb tsJwcIsJiEo8XZKXTmZvXjjBFl5UcN0F/do6WALQlfI8SrUnNIlVC4Md4Kt3fq9qKu80 jF6hHZ1gsC1GHz1mAZgbmZ0ZjaPyYoSlCN/ClvMibTPqP3f7/zFdPY66ZZ6D9dz1RdVi K76w==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56778-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXphg4uBJr2ikTyNM1qIBNCjCBbVvwT0U9aIsxTKSCSYYwTYSQlP+WL0W+7XeaspWL1P9MmBqOdK64BlD9lxfSuVcaTZjN1b8byFK9klg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w184-20020a6382c1000000b005ca4098bf5fsi1847339pgd.620.2024.02.07.08.38.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 08:38:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56778-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=enpas.org); spf=pass (google.com: domain of linux-kernel+bounces-56778-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56778-linux.lists.archive=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 591BA284688 for ; Wed, 7 Feb 2024 16:38:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73ECD823BD; Wed, 7 Feb 2024 16:37:41 +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 Content-Transfer-Encoding: 8bit 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; -- 2.39.2