2019-10-09 08:54:02

by Jean-Jacques Hiblot

[permalink] [raw]
Subject: [PATCH v10 5/6] dt-bindings: backlight: Add led-backlight binding

Add DT binding for led-backlight.

Cc: [email protected]
Signed-off-by: Jean-Jacques Hiblot <[email protected]>

---

.../leds/backlight/led-backlight.yaml | 55 +++++++++++++++++++
1 file changed, 55 insertions(+)
create mode 100644 Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml

diff --git a/Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml b/Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml
new file mode 100644
index 000000000000..47ae3d6b4f31
--- /dev/null
+++ b/Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/led-backlight.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LED-based Backlight Device Tree Bindings
+
+maintainers:
+ - Jean-Jacques Hiblot <[email protected]>
+
+description: |
+ This binding is used to describe a basic backlight device made of LEDs.
+ It can also be used to describe a backlight device controlled by the
+ output of a LED driver.
+
+properties:
+ compatible:
+ const: led-backlight
+
+ leds:
+ $ref: /schemas/types.yaml#/definitions/phandle-array
+ description: List of LEDs constitutive of the backlight.
+
+ default-brightness:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: Default brightness level on boot.
+ minimum: 0
+
+ brightness-levels:
+ $ref: /schemas/types.yaml#/definitions/uint32-array
+ description: Array of distinct brightness levels. The levels must be in
+ the range accepted by the underlying LED devices. This is used to
+ translate a backlight brightness level into a LED brightness level. If
+ it is not provided, the identity mapping is used.
+
+required:
+ - compatible
+ - backlight-leds
+
+examples:
+ - |
+ backlight {
+ compatible = "led-backlight";
+ backlight-leds = <&led1>;
+ brightness-levels = <0 4 8 16 32 64 128 255>;
+ default-brightness = <6>; /*6th level => brightness of the LEDs is 128*/
+ };
+ - |
+ backlight {
+ compatible = "led-backlight";
+ backlight-leds = <&led1>, <&led2>;
+ default-brightness = <255>;
+ };
+...
--
2.17.1


2019-10-09 19:36:02

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH v10 5/6] dt-bindings: backlight: Add led-backlight binding

On Wed, Oct 09, 2019 at 10:51:26AM +0200, Jean-Jacques Hiblot wrote:
> Add DT binding for led-backlight.
>
> Cc: [email protected]
> Signed-off-by: Jean-Jacques Hiblot <[email protected]>
>
> ---
>
> .../leds/backlight/led-backlight.yaml | 55 +++++++++++++++++++
> 1 file changed, 55 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml
>
> diff --git a/Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml b/Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml
> new file mode 100644
> index 000000000000..47ae3d6b4f31
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml
> @@ -0,0 +1,55 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/leds/backlight/led-backlight.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: LED-based Backlight Device Tree Bindings
> +
> +maintainers:
> + - Jean-Jacques Hiblot <[email protected]>
> +
> +description: |
> + This binding is used to describe a basic backlight device made of LEDs.
> + It can also be used to describe a backlight device controlled by the
> + output of a LED driver.
> +
> +properties:
> + compatible:
> + const: led-backlight
> +
> + leds:
> + $ref: /schemas/types.yaml#/definitions/phandle-array
> + description: List of LEDs constitutive of the backlight.
> +
> + default-brightness:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: Default brightness level on boot.

It's not clear that this is an index when 'brightness-levels' is present
and absolute level when not. I wonder if we've been consistent on that?

> + minimum: 0

Implied by being a uint32.

> +
> + brightness-levels:
> + $ref: /schemas/types.yaml#/definitions/uint32-array
> + description: Array of distinct brightness levels. The levels must be in
> + the range accepted by the underlying LED devices. This is used to
> + translate a backlight brightness level into a LED brightness level. If
> + it is not provided, the identity mapping is used.
> +
> +required:
> + - compatible
> + - backlight-leds

leds?


Add 'additionalProperties: false' here.

> +
> +examples:
> + - |
> + backlight {

Please also define $nodename is 'backlight'.

> + compatible = "led-backlight";
> + backlight-leds = <&led1>;

leds?

> + brightness-levels = <0 4 8 16 32 64 128 255>;
> + default-brightness = <6>; /*6th level => brightness of the LEDs is 128*/
> + };
> + - |
> + backlight {
> + compatible = "led-backlight";
> + backlight-leds = <&led1>, <&led2>;
> + default-brightness = <255>;
> + };
> +...
> --
> 2.17.1
>

2019-11-21 18:25:01

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH v10 5/6] dt-bindings: backlight: Add led-backlight binding

Hi,

* Rob Herring <[email protected]> [700101 00:00]:
> On Wed, Oct 09, 2019 at 10:51:26AM +0200, Jean-Jacques Hiblot wrote:
> > Add DT binding for led-backlight.
...
> > new file mode 100644
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/leds/backlight/led-backlight.yaml
...

> > + default-brightness:
> > + $ref: /schemas/types.yaml#/definitions/uint32
> > + description: Default brightness level on boot.
>
> It's not clear that this is an index when 'brightness-levels' is present
> and absolute level when not. I wonder if we've been consistent on that?

Yeah.. And should we use "default-brightness-level" here like we do
in the kernel now?

Sorry if I've missed some discussion on this before..

> > + brightness-levels = <0 4 8 16 32 64 128 255>;

What we're using for droid4 with an earlier version of this
patch set for the brightness-levels is generated backwards
with:

$ for i in 0 1 2 3 4 5 6 7; do echo "255 - ${i} * (256 / 8)" | bc; done

This produces the following range that seem to behave nicely:

brightness-levels = <31 63 95 127 159 191 223 255>;

Of course depends on the backing hardware, this is with
leds_lm3532 on droid4. But I think also the current example
in the binding might be from Pavel also for droid4?

If so, you might want to update the range :)

Regards,

Tony