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;