Message ID | 20240206185400.596979-3-aren@peacevolution.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-55534-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1759160dyb; Tue, 6 Feb 2024 11:11:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYqZaXOkxSh5pXoKsf5H6Yt5f/TKNwC+Ugrc/FJTjIj/x210rTT5NtcuBzLGuYkay3o99X X-Received: by 2002:a05:6870:b48b:b0:214:98ae:8c62 with SMTP id y11-20020a056870b48b00b0021498ae8c62mr4097116oap.7.1707246664106; Tue, 06 Feb 2024 11:11:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707246664; cv=pass; d=google.com; s=arc-20160816; b=l4CKE0EgKje7Tx7slinl3YNsWOABE2N7dnnxCMsMmX8v/GESawQIax/v1uo2r3BXuh x7OFBKau3mwPizMZxUSnGf3CXTFSrk1c+goH1u3/3t5lvEcIPjd6LGcTX/TdcLJ2RSye 1RJXh0t1e8i05cLeMK/ipC9nVnUIqSIS36LHL99EmKBJfXBQubaas7GaHw+QeXGEFD3b g44oOl8+q7yK8tQodStYjcf2d7EiXkMbMv9RCMpjKrxFj5DgWfcg0icZ4s/EE3A+xEq/ oAJ4Y+3GaOkWucigMWdrVJJ4Url+Lbjjnr+JKE3ZN6X+yygq3x/XOYcgNA1hUmZN3RNJ LrpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from; bh=o6DDRcilCg3I7Q6EoW6q5k4FGWr7L3+KOlmCTdxiqwk=; fh=57hOTrfGocEHpxFWcuDMNY6gcF+2VWAMGKjPnFj4Jfk=; b=eG9v0pzrJs+8B4Zrh8O3TqcAdZw0jiVI6bQ7OfSyUKGLhRDfGsY/7CMMujJBktyrTJ JMrIkh2XrcVmGKHrvgIQbFwmnMQhvmewAx1UWpuldBwDbC5uXGeS4kWG05BllNm3PHdD oqe8sCh2LMb/7MmUsawc8qfcoK9UliaWHc2tYEFMwg+ptIxrn/IVbZEZvjtPagM0lfAZ LeojIYYqURFFrnbv1x/K/JDgufv1l1ia446xQl3gHyBLYBbsaPfQcf4q129LmL0UNN7P vicrR1D4lDIrR4KaCLxyDPvfKvbo5F/nNHcg9zNoTlsOA7rOMcAJy/w6qlVgperNGIPk 1BtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=VC0TL22s; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-55534-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55534-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.org X-Forwarded-Encrypted: i=1; AJvYcCXBQoozSLDjhbvvUnU3Kdq9Ww/JfZVbMQOmSuTwQw/daRykKfVQjIk1JaWFxv+K0rngnED5lOINgatjH6r1QVNBOyE+7Q== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 17-20020a630211000000b005cee03a5355si1998023pgc.518.2024.02.06.11.11.03 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 11:11:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55534-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; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=VC0TL22s; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-55534-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55534-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.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 BCED628B5E0 for <ouuuleilei@gmail.com>; Tue, 6 Feb 2024 19:05:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6CAF1B807; Tue, 6 Feb 2024 19:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="VC0TL22s" Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (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 D31C21B7F0; Tue, 6 Feb 2024 19:03:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707246205; cv=none; b=c+L2ucVjrbnqULDOjaga4Ud1HM0EMmGYhTSS+oa6c/B7u8YbZLu7sjVHESaRNOMSjwZjCSJAtUwKw48EGQ3KS/bjGws6lR29QN+TvkJf4vZsv3VsTrRPwLvNl+miwdvjzhR/0ADBqHbyol1NomehYgJoQO9lxNWY8QzfIOYYzNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707246205; c=relaxed/simple; bh=XYDsMDVcsP7odk8FeBn6mlA5XGeXcHZ/KkPG93FWgMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A89iL5JdTdLV5uCrwwkVZw2SX7CFXd0oGyh3Xy7LP2qNORnY2ZKQv09i5mVAfHyG9bSZxyBGjkOH3ElIRo10X977e1tYcaT32B4jQbBnJtu/jSCiuQ1anQ2INzLZpOrg0hQJl2OKz8ZeA+UyA2K8AQoEsM0MS3hI3GOCxj5d1rw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=VC0TL22s; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id 081F84583E; Tue, 6 Feb 2024 19:03:21 +0000 (UTC) From: Aren Moynihan <aren@peacevolution.org> To: linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Rob Herring <robh+dt@kernel.org>, devicetree@vger.kernel.org, Jean-Jacques Hiblot <jjhiblot@traphandler.com>, Chen-Yu Tsai <wens@csie.org>, Ondrej Jirman <megi@xff.cz>, linux-sunxi@lists.linux.dev, Lee Jones <lee@kernel.org>, Pavel Machek <pavel@ucw.cz>, linux-arm-kernel@lists.infradead.org, Jernej Skrabec <jernej.skrabec@gmail.com>, linux-leds@vger.kernel.org, Conor Dooley <conor+dt@kernel.org>, Miles Alan <m@milesalan.com>, Samuel Holland <samuel@sholland.org>, Aren Moynihan <aren@peacevolution.org> Subject: [PATCH v2 3/4] arm64: dts: sun50i-a64-pinephone: add multicolor led node Date: Tue, 6 Feb 2024 13:13:19 -0500 Message-ID: <20240206185400.596979-3-aren@peacevolution.org> In-Reply-To: <20240206185400.596979-1-aren@peacevolution.org> References: <20240206185400.596979-1-aren@peacevolution.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: ** X-Spamd-Bar: ++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1707246203; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=o6DDRcilCg3I7Q6EoW6q5k4FGWr7L3+KOlmCTdxiqwk=; b=VC0TL22sbbRARJCon5mZiI14jPEcLoImFrDoq4GBZtIijTpRaGeIu7Rb4q8BT7XvDWYV8C 8VDVgnhntAT0O2UK7pTktC9szWoeqIwBuVGvqm5xc6J6Ik+j4WsX+e5a2mKsacITrRDMJF x+LjefqJqs/zDQmDMA6ZIr9Td8dMLzw= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790177877743397272 X-GMAIL-MSGID: 1790177877743397272 |
Series |
[v2,1/4] leds: rgb: leds-group-multicolor: allow leds to stay on in suspend
|
|
Commit Message
Aren
Feb. 6, 2024, 6:13 p.m. UTC
The red, green, and blue leds currently in the device tree represent a
single rgb led on the front of the PinePhone.
Signed-off-by: Aren Moynihan <aren@peacevolution.org>
---
Changes in v2:
- remove function property from individual led nodes
.../boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
Comments
Hello Aren, On Tue, Feb 06, 2024 at 01:13:19PM -0500, Aren Moynihan wrote: > The red, green, and blue leds currently in the device tree represent a > single rgb led on the front of the PinePhone. > > Signed-off-by: Aren Moynihan <aren@peacevolution.org> > --- > > Changes in v2: > - remove function property from individual led nodes > > .../boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > index ad2476ee01e4..e53e0d4579a7 100644 > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > @@ -39,28 +39,32 @@ chosen { > leds { > compatible = "gpio-leds"; > > - led-0 { > - function = LED_FUNCTION_INDICATOR; This looks like a needless change that will just break people's current scripts and setup. It does mine, and there sure are others that will be surprised, too. This leads to a change in sysfs path from: /sys/class/leds/blue:indicator to /sys/class/leds/blue: which is 1) a weird name and 2) a backwards compatibility break for seemingly no apparent reason. Any reaons for the change? People normally hardcode these paths in eg. /etc/tmpfiles.d to apply LED triggers to particular LEDs. Kind regards, o. > + led0: led-0 { > color = <LED_COLOR_ID_BLUE>; > gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ > retain-state-suspended; > }; > > - led-1 { > - function = LED_FUNCTION_INDICATOR; > + led1: led-1 { > color = <LED_COLOR_ID_GREEN>; > gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */ > retain-state-suspended; > }; > > - led-2 { > - function = LED_FUNCTION_INDICATOR; > + led2: led-2 { > color = <LED_COLOR_ID_RED>; > gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */ > retain-state-suspended; > }; > }; > > + multi-led { > + compatible = "leds-group-multicolor"; > + color = <LED_COLOR_ID_RGB>; > + function = LED_FUNCTION_INDICATOR; > + leds = <&led0>, <&led1>, <&led2>; > + }; > + > reg_ps: ps-regulator { > compatible = "regulator-fixed"; > regulator-name = "ps"; > -- > 2.43.0 >
On Fri, Feb 23, 2024 at 09:46:25AM +0100, Ondřej Jirman wrote: > Hello Aren, > > On Tue, Feb 06, 2024 at 01:13:19PM -0500, Aren Moynihan wrote: > > The red, green, and blue leds currently in the device tree represent a > > single rgb led on the front of the PinePhone. > > > > Signed-off-by: Aren Moynihan <aren@peacevolution.org> > > --- > > > > Changes in v2: > > - remove function property from individual led nodes > > > > .../boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 16 ++++++++++------ > > 1 file changed, 10 insertions(+), 6 deletions(-) > > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > index ad2476ee01e4..e53e0d4579a7 100644 > > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > @@ -39,28 +39,32 @@ chosen { > > leds { > > compatible = "gpio-leds"; > > > > - led-0 { > > - function = LED_FUNCTION_INDICATOR; > > This looks like a needless change that will just break people's current scripts > and setup. It does mine, and there sure are others that will be surprised, too. > > This leads to a change in sysfs path from: > > /sys/class/leds/blue:indicator > > to > > /sys/class/leds/blue: > > which is 1) a weird name and 2) a backwards compatibility break for seemingly > no apparent reason. Any reaons for the change? Leds-group-multicolor will make those read-only, so that will break when it's enabled either way. Removing the function property makes it less likely that programs attempting to discover leds will use the wrong path. I left these in v1 of this patch, but was recommended to remove them. https://lore.kernel.org/lkml/k26bellccok4tj3kz2nrtp2vth2rnsiea677e2kzm56m767wjx@pnkqiz5hmiyb/ Thanks for taking a look at this - Aren > People normally hardcode these paths in eg. /etc/tmpfiles.d to apply LED triggers > to particular LEDs. > > Kind regards, > o. > > > + led0: led-0 { > > color = <LED_COLOR_ID_BLUE>; > > gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ > > retain-state-suspended; > > }; > > > > - led-1 { > > - function = LED_FUNCTION_INDICATOR; > > + led1: led-1 { > > color = <LED_COLOR_ID_GREEN>; > > gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */ > > retain-state-suspended; > > }; > > > > - led-2 { > > - function = LED_FUNCTION_INDICATOR; > > + led2: led-2 { > > color = <LED_COLOR_ID_RED>; > > gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */ > > retain-state-suspended; > > }; > > }; > > > > + multi-led { > > + compatible = "leds-group-multicolor"; > > + color = <LED_COLOR_ID_RGB>; > > + function = LED_FUNCTION_INDICATOR; > > + leds = <&led0>, <&led1>, <&led2>; > > + }; > > + > > reg_ps: ps-regulator { > > compatible = "regulator-fixed"; > > regulator-name = "ps"; > > -- > > 2.43.0 > >
Hello Aren, On Fri, Feb 23, 2024 at 10:22:36AM -0500, Aren wrote: > On Fri, Feb 23, 2024 at 09:46:25AM +0100, Ondřej Jirman wrote: > > Hello Aren, > > > > On Tue, Feb 06, 2024 at 01:13:19PM -0500, Aren Moynihan wrote: > > > The red, green, and blue leds currently in the device tree represent a > > > single rgb led on the front of the PinePhone. > > > > > > Signed-off-by: Aren Moynihan <aren@peacevolution.org> > > > --- > > > > > > Changes in v2: > > > - remove function property from individual led nodes > > > > > > .../boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 16 ++++++++++------ > > > 1 file changed, 10 insertions(+), 6 deletions(-) > > > > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > > index ad2476ee01e4..e53e0d4579a7 100644 > > > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > > @@ -39,28 +39,32 @@ chosen { > > > leds { > > > compatible = "gpio-leds"; > > > > > > - led-0 { > > > - function = LED_FUNCTION_INDICATOR; > > > > This looks like a needless change that will just break people's current scripts > > and setup. It does mine, and there sure are others that will be surprised, too. > > > > This leads to a change in sysfs path from: > > > > /sys/class/leds/blue:indicator > > > > to > > > > /sys/class/leds/blue: > > > > which is 1) a weird name and 2) a backwards compatibility break for seemingly > > no apparent reason. Any reaons for the change? > > Leds-group-multicolor will make those read-only, so that will break when > it's enabled either way. Removing the function property makes it less > likely that programs attempting to discover leds will use the wrong > path. Allright. Then this breaks even more usecases then I thought. I quite depend on being able to apply various kernel based LED triggers to individual LEDs in the RGB LED. (The LED is not really multi-color in practice - you don't get a mix of colors. It's only technically a RGB LED, but if you turn on red and green, you see red and green, individually. I suspect it's a clear capped LED, not a diffused one and expects an external difuser - which Pinephone doesn't have. So this works out quite fine from the user perspective, because you see individual colors and can assign meanings to them individually) So this change makes it that I'll not be able to map different triggers to individual colors now. Eg. I have a power manager driver for Pinephone keyboard that exports LED triggers to indicate various charging states of the keyboard battery, so that I get warnings when the KB is discharged, or disconnected from control algorithm due to its tendency to shut off, and disappear from I2C bus, etc. AXP20x driver also exports a bunch of useful triggers. --- As a side note, this new multicolor abstraction seems a bit lacking and cumbersome, too. I still have to control individual LEDs via multi_intensity file and have to parse multi_index to even know which number corresponds to what color. In addition I have to ensure correct value in brightness file. If I want to change one of the LEDs, I now have to first read the whole status of multi-color LED and update it somehow in a non-racy way, which is impossible with this API without going through some userspace daemon that centralizes the LED control. If this is expected to be usable in device independent way, then there's another problem: multi_intensity values don't seem to have any range defined in sysfs, so I can't know what is the max usable value. How do I know the range is 0-1 vs 0-255 or 0-200000? There's max_brightness but that seems to be related to possible values in brightness file. Seems like I can write pretty much anything to multi_intensity, even things like this: https://megous.com/dl/tmp/4c6db9376f148951.png (looks like all LEDs are turned on even for negative intensity) If multi_intensity is supposed to be some relative measure of brightenss of individual LEDs in RGB LED, then echo '1 1 1000' > multi_intensity should pretty much result in only red LED being on. But all are on at full brightness. So the kernel doesn't even represent the desired color properly, based on HW limitations it knows about. There's no aproximation/rounding to the limits of control of individual LEDs. Even 1 millionth of relative intensity will result in the LED being turned fully on. Discoverability of how to control the LEDs is also quite lacking. Individual directories under /sys/class/leds are still there for individual parts of RGB LED, and it's not clearly identifiable that you can't control them. brightness file still has -rw-r--r-- permissions. But writing to it produces EBUSY. As far as I can see, the only indication that something is amiss is that there's a device/consumer:platform:multi-led symlink under the individual LEDs. But that can have any name in practice, and how can one know that just because some device has a in-kernel consumer, that it's a kind of a consumer that blocks changes to the device? If I have to discover that some LED is controlled by some other driver only by trying to light it up, then that's not a great API, I'd say. End of side note. :) --- ^^^^ All this from the PoV of a (API) user. I can understand the device-tree appeal of representing the technically RGB LED as RGB node, but as a user who messes with sysfs, and likes the simplicity and flexibility of how things work now, with the upstream Pinephone DT, I really dislike the change, because it forces unpleasant userspace changes, incl. necessity for some userspace LED control daemon to get race-free LED control from multiple sources. And I'm not even sure what I'd do with the keyboard driver, and how to keep the triggers working. Anyway, I and others can get around all this by: echo multi-led > /sys/class/leds/rgb:status/device/driver/unbind at system startup and get back control via idndividual LED directories. But please don't change the names of directories that were there up to now. That will just break many people's scripts for no reason. So my only request is to make this fallback to previous way it worked easy. Kind regards, o. > I left these in v1 of this patch, but was recommended to remove them. > https://lore.kernel.org/lkml/k26bellccok4tj3kz2nrtp2vth2rnsiea677e2kzm56m767wjx@pnkqiz5hmiyb/ > > Thanks for taking a look at this > - Aren > > > People normally hardcode these paths in eg. /etc/tmpfiles.d to apply LED triggers > > to particular LEDs. > > > > Kind regards, > > o. > > > > > + led0: led-0 { > > > color = <LED_COLOR_ID_BLUE>; > > > gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ > > > retain-state-suspended; > > > }; > > > > > > - led-1 { > > > - function = LED_FUNCTION_INDICATOR; > > > + led1: led-1 { > > > color = <LED_COLOR_ID_GREEN>; > > > gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */ > > > retain-state-suspended; > > > }; > > > > > > - led-2 { > > > - function = LED_FUNCTION_INDICATOR; > > > + led2: led-2 { > > > color = <LED_COLOR_ID_RED>; > > > gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */ > > > retain-state-suspended; > > > }; > > > }; > > > > > > + multi-led { > > > + compatible = "leds-group-multicolor"; > > > + color = <LED_COLOR_ID_RGB>; > > > + function = LED_FUNCTION_INDICATOR; > > > + leds = <&led0>, <&led1>, <&led2>; > > > + }; > > > + > > > reg_ps: ps-regulator { > > > compatible = "regulator-fixed"; > > > regulator-name = "ps"; > > > -- > > > 2.43.0 > > >
On Sat, Feb 24, 2024 at 12:28:36AM +0100, Ondřej Jirman wrote: > Hello Aren, > > On Fri, Feb 23, 2024 at 10:22:36AM -0500, Aren wrote: > > On Fri, Feb 23, 2024 at 09:46:25AM +0100, Ondřej Jirman wrote: > > > Hello Aren, > > > > > > On Tue, Feb 06, 2024 at 01:13:19PM -0500, Aren Moynihan wrote: > > > > The red, green, and blue leds currently in the device tree represent a > > > > single rgb led on the front of the PinePhone. > > > > > > > > Signed-off-by: Aren Moynihan <aren@peacevolution.org> > > > > --- > > > > > > > > Changes in v2: > > > > - remove function property from individual led nodes > > > > > > > > .../boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 16 ++++++++++------ > > > > 1 file changed, 10 insertions(+), 6 deletions(-) > > > > > > > > diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > > > index ad2476ee01e4..e53e0d4579a7 100644 > > > > --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > > > +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi > > > > @@ -39,28 +39,32 @@ chosen { > > > > leds { > > > > compatible = "gpio-leds"; > > > > > > > > - led-0 { > > > > - function = LED_FUNCTION_INDICATOR; > > > > > > This looks like a needless change that will just break people's current scripts > > > and setup. It does mine, and there sure are others that will be surprised, too. > > > > > > This leads to a change in sysfs path from: > > > > > > /sys/class/leds/blue:indicator > > > > > > to > > > > > > /sys/class/leds/blue: > > > > > > which is 1) a weird name and 2) a backwards compatibility break for seemingly > > > no apparent reason. Any reaons for the change? > > > > Leds-group-multicolor will make those read-only, so that will break when > > it's enabled either way. Removing the function property makes it less > > likely that programs attempting to discover leds will use the wrong > > path. > > Allright. Then this breaks even more usecases then I thought. I quite depend on > being able to apply various kernel based LED triggers to individual LEDs in the > RGB LED. (The LED is not really multi-color in practice - you don't get a mix of > colors. It's only technically a RGB LED, but if you turn on red and green, you > see red and green, individually. I suspect it's a clear capped LED, not > a diffused one and expects an external difuser - which Pinephone doesn't have. > So this works out quite fine from the user perspective, because you see > individual colors and can assign meanings to them individually) > > So this change makes it that I'll not be able to map different triggers > to individual colors now. > > Eg. I have a power manager driver for Pinephone keyboard that exports LED triggers > to indicate various charging states of the keyboard battery, so that I get > warnings when the KB is discharged, or disconnected from control algorithm > due to its tendency to shut off, and disappear from I2C bus, etc. AXP20x driver > also exports a bunch of useful triggers. > > --- > > As a side note, this new multicolor abstraction seems a bit lacking and > cumbersome, too. > > I still have to control individual LEDs via multi_intensity file and have to > parse multi_index to even know which number corresponds to what color. In addition > I have to ensure correct value in brightness file. > > If I want to change one of the LEDs, I now have to first read the whole status > of multi-color LED and update it somehow in a non-racy way, which is > impossible with this API without going through some userspace daemon that > centralizes the LED control. > > If this is expected to be usable in device independent way, then there's another > problem: multi_intensity values don't seem to have any range defined in sysfs, > so I can't know what is the max usable value. How do I know the range is 0-1 vs > 0-255 or 0-200000? There's max_brightness but that seems to be related to > possible values in brightness file. Seems like I can write pretty much anything > to multi_intensity, even things like this: > > https://megous.com/dl/tmp/4c6db9376f148951.png > > (looks like all LEDs are turned on even for negative intensity) > > If multi_intensity is supposed to be some relative measure of brightenss of > individual LEDs in RGB LED, then echo '1 1 1000' > multi_intensity > should pretty much result in only red LED being on. But all are on at full > brightness. So the kernel doesn't even represent the desired color properly, > based on HW limitations it knows about. There's no aproximation/rounding to the > limits of control of individual LEDs. Even 1 millionth of relative intensity > will result in the LED being turned fully on. > > Discoverability of how to control the LEDs is also quite lacking. Individual > directories under /sys/class/leds are still there for individual parts of RGB > LED, and it's not clearly identifiable that you can't control them. brightness > file still has -rw-r--r-- permissions. But writing to it produces EBUSY. > As far as I can see, the only indication that something is amiss is that > there's a device/consumer:platform:multi-led symlink under the individual LEDs. > But that can have any name in practice, and how can one know that just because > some device has a in-kernel consumer, that it's a kind of a consumer that blocks > changes to the device? > > If I have to discover that some LED is controlled by some other driver only > by trying to light it up, then that's not a great API, I'd say. > > End of side note. :) > > --- > > ^^^^ All this from the PoV of a (API) user. I can understand the device-tree > appeal of representing the technically RGB LED as RGB node, but as a user who > messes with sysfs, and likes the simplicity and flexibility of how things work > now, with the upstream Pinephone DT, I really dislike the change, because it > forces unpleasant userspace changes, incl. necessity for some userspace LED > control daemon to get race-free LED control from multiple sources. And I'm not > even sure what I'd do with the keyboard driver, and how to keep the triggers > working. > > Anyway, I and others can get around all this by: > > echo multi-led > /sys/class/leds/rgb:status/device/driver/unbind > > at system startup and get back control via idndividual LED directories. > But please don't change the names of directories that were there up to now. That > will just break many people's scripts for no reason. So my only request is to > make this fallback to previous way it worked easy. Makes sense, I'll send v1 again with a revised commit message when I get a chance (this was the only change to the device tree part of this patchset between v1 and v2). Thanks - Aren > Kind regards, > o. > > > I left these in v1 of this patch, but was recommended to remove them. > > https://lore.kernel.org/lkml/k26bellccok4tj3kz2nrtp2vth2rnsiea677e2kzm56m767wjx@pnkqiz5hmiyb/ > > > > Thanks for taking a look at this > > - Aren > > > > > People normally hardcode these paths in eg. /etc/tmpfiles.d to apply LED triggers > > > to particular LEDs. > > > > > > Kind regards, > > > o. > > > > > > > + led0: led-0 { > > > > color = <LED_COLOR_ID_BLUE>; > > > > gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ > > > > retain-state-suspended; > > > > }; > > > > > > > > - led-1 { > > > > - function = LED_FUNCTION_INDICATOR; > > > > + led1: led-1 { > > > > color = <LED_COLOR_ID_GREEN>; > > > > gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */ > > > > retain-state-suspended; > > > > }; > > > > > > > > - led-2 { > > > > - function = LED_FUNCTION_INDICATOR; > > > > + led2: led-2 { > > > > color = <LED_COLOR_ID_RED>; > > > > gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */ > > > > retain-state-suspended; > > > > }; > > > > }; > > > > > > > > + multi-led { > > > > + compatible = "leds-group-multicolor"; > > > > + color = <LED_COLOR_ID_RGB>; > > > > + function = LED_FUNCTION_INDICATOR; > > > > + leds = <&led0>, <&led1>, <&led2>; > > > > + }; > > > > + > > > > reg_ps: ps-regulator { > > > > compatible = "regulator-fixed"; > > > > regulator-name = "ps"; > > > > -- > > > > 2.43.0 > > > >
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi index ad2476ee01e4..e53e0d4579a7 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi @@ -39,28 +39,32 @@ chosen { leds { compatible = "gpio-leds"; - led-0 { - function = LED_FUNCTION_INDICATOR; + led0: led-0 { color = <LED_COLOR_ID_BLUE>; gpios = <&pio 3 20 GPIO_ACTIVE_HIGH>; /* PD20 */ retain-state-suspended; }; - led-1 { - function = LED_FUNCTION_INDICATOR; + led1: led-1 { color = <LED_COLOR_ID_GREEN>; gpios = <&pio 3 18 GPIO_ACTIVE_HIGH>; /* PD18 */ retain-state-suspended; }; - led-2 { - function = LED_FUNCTION_INDICATOR; + led2: led-2 { color = <LED_COLOR_ID_RED>; gpios = <&pio 3 19 GPIO_ACTIVE_HIGH>; /* PD19 */ retain-state-suspended; }; }; + multi-led { + compatible = "leds-group-multicolor"; + color = <LED_COLOR_ID_RGB>; + function = LED_FUNCTION_INDICATOR; + leds = <&led0>, <&led1>, <&led2>; + }; + reg_ps: ps-regulator { compatible = "regulator-fixed"; regulator-name = "ps";