Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp576571rdb; Mon, 15 Jan 2024 06:51:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTEqigHPteYh26OyOyBPJ2J1arSnXtHyygRut2yicma9hW2M+MFSFow5BDfH+/cJOIhMi6 X-Received: by 2002:a05:622a:60f:b0:429:c5d8:3f0c with SMTP id z15-20020a05622a060f00b00429c5d83f0cmr8490020qta.93.1705330289865; Mon, 15 Jan 2024 06:51:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705330289; cv=none; d=google.com; s=arc-20160816; b=odNzOuDXpdLci4DbSGQ/ypoCP/4XIw7V3bGXPWBa2jxVwrIXnxKPBEMzMar+N5IVE9 ri8JLidp1s1qiOGYzj5LIvnReZ+cDQ8Kjs3hjEuwD0Uy58koQu6+k1S3/1g4cxl0E83t 2BYKwrZ/W3/aW49O9cdBq267F70nvlYHhomMbRyocTHtZBq3/aUiNgyrIvjLQprr0mIg N5pqHElmoJkoxg1ufzM/SQURePpxAR/Q7LF/BPn2TeOFfCnoMeEbrpXOP3g+LjsRWvks T3Wm+6Uuhc42sPRCtCdZvNRJ9JUWHT9Ihqn3J4UuNTycThpyvjkY8+MPQQMNKcsw+4MF qdiQ== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26138-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v12-20020ac8578c000000b00429bfa9d10fsi8136590qta.485.2024.01.15.06.51.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:51:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26138-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26138-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 98D4A1C21A6A for ; Mon, 15 Jan 2024 14:51:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE30B17996; Mon, 15 Jan 2024 14:48:57 +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 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