Skip to contentSkip to conversation

pwm_backlight: Add device tree support for Low Threshold Brightness

PATCH Superseded Philip, Avinash 2 participants 5 messages Jul 25, 2012 – Sep 21, 2012

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm_backlight: Add device tree support for Low Threshold Brightness

Low Threshold Brightness should be configured to have a linear relation in brightness scale. This patch adds device tree support for low threshold brightness as optional one for pwm_backlight.

---
:100644 100644 1e4fc72... 5c54380... M Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
:100644 100644 995f016... 4965408... M drivers/video/backlight/pwm_bl.c

 .../bindings/video/backlight/pwm-backlight.txt     |   21 ++++++++++++++++++++
 drivers/video/backlight/pwm_bl.c                   |    5 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +21 -0
index 1e4fc72..5c54380 100644
@@ -14,6 +14,8 @@ Required properties:
 Optional properties:
   - pwm-names: a list of names for the PWM devices specified in the
                "pwms" property (see PWM binding[0])
+  - low_threshold_brightness: brightness threshold low level. (get linear
+		 scales in brightness in low end of brightness levels)
 
 [0]: Documentation/devicetree/bindings/pwm/pwm.txt
 
@@ -26,3 +28,22 @@ Example:
 		brightness-levels = <0 4 8 16 32 64 128 255>;
 		default-brightness-level = <6>;
 	};
+
+Example for brightness_threshold_level:
+
+	backlight {
+		compatible	= "pwm-backlight";
+		pwms = <&pwm 0 50000>;
+
+		brightness-levels = <0 4 8 16 32 64 128 255>;
+		default-brightness-level = <6>;
+		low_threshold_brightness = <50>;
+	};
+};
+Note:
+Low threshold support is required to have linear brightness scale from
+0 to max. For some panels, backlight absent on low end of brightness
+scale. So support for Low Threshold been required. So that the scale of
+brightness changed from Low Threshold to Max in scales defined in
+brightness-levels. In this example 20% maximum brightness scale should
+be required to turn on panel backlight.
drivers/video/backlight/pwm_bl.c +5 -0
index 995f016..4965408 100644
@@ -143,6 +143,11 @@ static int pwm_backlight_parse_dt(struct device *dev,
 
 		data->dft_brightness = value;
 		data->max_brightness--;
+
+		ret = of_property_read_u32(node, "low_threshold_brightness",
+					   &value);
+		if (!ret)
+			data->lth_brightness = value;
 	}
 
 	/*
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Avinash

Low Threshold Brightness should be configured to have a linear relation in brightness scale. This patch adds device tree support for low threshold brightness as optional one for pwm_backlight.

I think this should be more explicit as to why this is required, perhaps something like this:

Some backlights perform poorly when driven by a PWM with a short duty-cycle. For such devices, the low threshold can be used to specify a lower bound for the duty-cycle and should be chosen to exclude the problematic range.

This patch adds support for an optional low-threshold-brightness property.

Perhaps a similar explanation should be given somewhere else instead of just the changelog. It took me some time to understand what exactly this low threshold means and I think it'd make sense to write this kind of information down somewhere. I'll see if I can make time to add a bit of documentation somewhere below Documentation/backlight perhaps.

Quoted 13 lines

---
:100644 100644 1e4fc72... 5c54380... M Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
:100644 100644 995f016... 4965408... M drivers/video/backlight/pwm_bl.c

 .../bindings/video/backlight/pwm-backlight.txt     |   21 ++++++++++++++++++++
 drivers/video/backlight/pwm_bl.c                   |    5 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +0 -0
index 1e4fc72..5c54380 100644

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Required properties: · line 18

Quoted 5 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +2 -0
@@ -14,6 +14,8 @@ Required properties:
 Optional properties:
   - pwm-names: a list of names for the PWM devices specified in the
                "pwms" property (see PWM binding[0])
+  - low_threshold_brightness: brightness threshold low level. (get linear
+		 scales in brightness in low end of brightness levels)

The convention is to use dashes, not underscores, in device tree property names, so this should be "low-threshold-brightness". I'd also omit the comment in parentheses because the DT binding document shouldn't specify any particular use-case. However I think it'd make sense to add some information about the number space of the low threshold value.

Maybe we should also rethink how the low threshold is handled in cases where the brightness levels are used. I'm not sure it makes sense to specify the low threshold as a value relative to the range given by the levels. Perhaps it is more meaningful to specify it as relative to the period/duty-cycle.

Quoted 9 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +2 -0
 [0]: Documentation/devicetree/bindings/pwm/pwm.txt
 
@@ -26,3 +28,22 @@ Example:
 		brightness-levels = <0 4 8 16 32 64 128 255>;
 		default-brightness-level = <6>;
 	};
+
+Example for brightness_threshold_level:

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Example: · line 42

Quoted 10 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +10 -0
+
+	backlight {
+		compatible	= "pwm-backlight";
+		pwms = <&pwm 0 50000>;
+
+		brightness-levels = <0 4 8 16 32 64 128 255>;
+		default-brightness-level = <6>;
+		low_threshold_brightness = <50>;
+	};
+};

I think you can just merge the low-threshold-brightness with the previous example.

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Example: · line 49

Quoted 7 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +7 -0
+Note:
+Low threshold support is required to have linear brightness scale from
+0 to max. For some panels, backlight absent on low end of brightness
+scale. So support for Low Threshold been required. So that the scale of
+brightness changed from Low Threshold to Max in scales defined in
+brightness-levels. In this example 20% maximum brightness scale should
+be required to turn on panel backlight.

I think this kind of documentation doesn't belong in the device tree binding. I'll work something like that into the proper documentation.

Quoted 5 lines
drivers/video/backlight/pwm_bl.c +0 -0
index 995f016..4965408 100644

drivers/video/backlight/pwm_bl.c static int pwm_backlight_parse_dt(struct device *dev, · line 151

Quoted 9 lines
drivers/video/backlight/pwm_bl.c +5 -0
@@ -143,6 +143,11 @@ static int pwm_backlight_parse_dt(struct device *dev,
 
 		data->dft_brightness = value;
 		data->max_brightness--;
+
+		ret = of_property_read_u32(node, "low_threshold_brightness",
+					   &value);
+		if (!ret)
+			data->lth_brightness = value;
 	}

This obviously should also be low-threshold-brightness.

Thierry

#2 lore raw
Quoted 8 lines · Thierry Reding
Quoted 3 lines · Avinash

Low Threshold Brightness should be configured to have a linear relation in brightness scale. This patch adds device tree support for low threshold brightness as optional one for pwm_backlight.

I think this should be more explicit as to why this is required, perhaps something like this:

Quoted 7 lines

Some backlights perform poorly when driven by a PWM with a short duty-cycle. For such devices, the low threshold can be used to specify a lower bound for the duty-cycle and should be chosen to exclude the problematic range.

This patch adds support for an optional low-threshold-brightness property.

Ok I will correct it.

Quoted 24 lines

Perhaps a similar explanation should be given somewhere else instead of just the changelog. It took me some time to understand what exactly this low threshold means and I think it'd make sense to write this kind of information down somewhere. I'll see if I can make time to add a bit of documentation somewhere below Documentation/backlight perhaps.

Quoted 17 lines

---
:100644 100644 1e4fc72... 5c54380... M Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
:100644 100644 995f016... 4965408... M drivers/video/backlight/pwm_bl.c

 .../bindings/video/backlight/pwm-backlight.txt     |   21 ++++++++++++++++++++
 drivers/video/backlight/pwm_bl.c                   |    5 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +1 -0
index 1e4fc72..5c54380 100644
@@ -14,6 +14,8 @@ Required properties:
 Optional properties:
   - pwm-names: a list of names for the PWM devices specified in the
                "pwms" property (see PWM binding[0])
+  - low_threshold_brightness: brightness threshold low level. (get linear
Quoted 8 lines

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Required properties: · line 18

Quoted 1 line
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +1 -0
+		 scales in brightness in low end of brightness levels)

The convention is to use dashes, not underscores, in device tree property names, so this should be "low-threshold-brightness". I'd also omit the comment in parentheses because the DT binding document shouldn't specify any particular use-case. However I think it'd make sense to add some information about the number space of the low threshold value.

Ok, I will correct it.

Quoted 21 lines

Maybe we should also rethink how the low threshold is handled in cases where the brightness levels are used. I'm not sure it makes sense to specify the low threshold as a value relative to the range given by the levels. Perhaps it is more meaningful to specify it as relative to the period/duty-cycle.

Quoted 14 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +7 -0
 [0]: Documentation/devicetree/bindings/pwm/pwm.txt
 
@@ -26,3 +28,22 @@ Example:
 		brightness-levels = <0 4 8 16 32 64 128 255>;
 		default-brightness-level = <6>;
 	};
+
+Example for brightness_threshold_level:
+
+	backlight {
+		compatible	= "pwm-backlight";
+		pwms = <&pwm 0 50000>;
+
Quoted 8 lines

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Example: · line 42

Quoted 5 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +5 -0
+		brightness-levels = <0 4 8 16 32 64 128 255>;
+		default-brightness-level = <6>;
+		low_threshold_brightness = <50>;
+	};
+};

I think you can just merge the low-threshold-brightness with the previous example.

Ok I will check and correct it.

Quoted 18 lines

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Example: · line 49

Quoted 8 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +7 -0
+Note:
+Low threshold support is required to have linear brightness scale from
+0 to max. For some panels, backlight absent on low end of brightness
+scale. So support for Low Threshold been required. So that the scale of
+brightness changed from Low Threshold to Max in scales defined in
+brightness-levels. In this example 20% maximum brightness scale should
+be required to turn on panel backlight.

I think this kind of documentation doesn't belong in the device tree binding. I'll work something like that into the proper documentation.

Quoted 6 lines
drivers/video/backlight/pwm_bl.c +0 -0
index 995f016..4965408 100644
@@ -143,6 +143,11 @@ static int pwm_backlight_parse_dt(struct device *dev,
 
Quoted 10 lines

drivers/video/backlight/pwm_bl.c static int pwm_backlight_parse_dt(struct device *dev, · line 151

Quoted 8 lines
drivers/video/backlight/pwm_bl.c +5 -0
 		data->dft_brightness = value;
 		data->max_brightness--;
+
+		ret = of_property_read_u32(node, "low_threshold_brightness",
+					   &value);
+		if (!ret)
+			data->lth_brightness = value;
 	}

This obviously should also be low-threshold-brightness.

I will change to

ret = of_property_read_u32(node, " low-threshold-brightness ",

Thanks
Avinash

Quoted 3 lines

Thierry

#3 lore raw
Quoted 115 lines · Avinash
Quoted 8 lines · Thierry Reding
Quoted 3 lines · Avinash

Low Threshold Brightness should be configured to have a linear relation in brightness scale. This patch adds device tree support for low threshold brightness as optional one for pwm_backlight.

I think this should be more explicit as to why this is required, perhaps something like this:

Quoted 7 lines

Some backlights perform poorly when driven by a PWM with a short duty-cycle. For such devices, the low threshold can be used to specify a lower bound for the duty-cycle and should be chosen to exclude the problematic range.

This patch adds support for an optional low-threshold-brightness property.

Ok I will correct it.

Quoted 24 lines

Perhaps a similar explanation should be given somewhere else instead of just the changelog. It took me some time to understand what exactly this low threshold means and I think it'd make sense to write this kind of information down somewhere. I'll see if I can make time to add a bit of documentation somewhere below Documentation/backlight perhaps.

Quoted 17 lines

---
:100644 100644 1e4fc72... 5c54380... M Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
:100644 100644 995f016... 4965408... M drivers/video/backlight/pwm_bl.c

 .../bindings/video/backlight/pwm-backlight.txt     |   21 ++++++++++++++++++++
 drivers/video/backlight/pwm_bl.c                   |    5 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +1 -0
index 1e4fc72..5c54380 100644
@@ -14,6 +14,8 @@ Required properties:
 Optional properties:
   - pwm-names: a list of names for the PWM devices specified in the
                "pwms" property (see PWM binding[0])
+  - low_threshold_brightness: brightness threshold low level. (get linear
Quoted 8 lines

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Required properties: · line 18

Quoted 1 line
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +1 -0
+		 scales in brightness in low end of brightness levels)

The convention is to use dashes, not underscores, in device tree property names, so this should be "low-threshold-brightness". I'd also omit the comment in parentheses because the DT binding document shouldn't specify any particular use-case. However I think it'd make sense to add some information about the number space of the low threshold value.

Ok, I will correct it.

Quoted 21 lines

Maybe we should also rethink how the low threshold is handled in cases where the brightness levels are used. I'm not sure it makes sense to specify the low threshold as a value relative to the range given by the levels. Perhaps it is more meaningful to specify it as relative to the period/duty-cycle.

Quoted 14 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +7 -0
 [0]: Documentation/devicetree/bindings/pwm/pwm.txt
 
@@ -26,3 +28,22 @@ Example:
 		brightness-levels = <0 4 8 16 32 64 128 255>;
 		default-brightness-level = <6>;
 	};
+
+Example for brightness_threshold_level:
+
+	backlight {
+		compatible	= "pwm-backlight";
+		pwms = <&pwm 0 50000>;
+
Quoted 8 lines

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Example: · line 42

Quoted 5 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +5 -0
+		brightness-levels = <0 4 8 16 32 64 128 255>;
+		default-brightness-level = <6>;
+		low_threshold_brightness = <50>;
+	};
+};

I think you can just merge the low-threshold-brightness with the previous example.

Ok I will check and correct it.

Quoted 18 lines

Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt Example: · line 49

Quoted 8 lines
Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt +7 -0
+Note:
+Low threshold support is required to have linear brightness scale from
+0 to max. For some panels, backlight absent on low end of brightness
+scale. So support for Low Threshold been required. So that the scale of
+brightness changed from Low Threshold to Max in scales defined in
+brightness-levels. In this example 20% maximum brightness scale should
+be required to turn on panel backlight.

I think this kind of documentation doesn't belong in the device tree binding. I'll work something like that into the proper documentation.

Quoted 6 lines
drivers/video/backlight/pwm_bl.c +0 -0
index 995f016..4965408 100644
@@ -143,6 +143,11 @@ static int pwm_backlight_parse_dt(struct device *dev,
 
Quoted 10 lines

drivers/video/backlight/pwm_bl.c static int pwm_backlight_parse_dt(struct device *dev, · line 151

Quoted 8 lines
drivers/video/backlight/pwm_bl.c +5 -0
 		data->dft_brightness = value;
 		data->max_brightness--;
+
+		ret = of_property_read_u32(node, "low_threshold_brightness",
+					   &value);
+		if (!ret)
+			data->lth_brightness = value;
 	}

This obviously should also be low-threshold-brightness.

Quoted 6 lines

I will change to

ret = of_property_read_u32(node, " low-threshold-brightness ",

Thanks
Avinash

I think you never sent an updated patch or maybe I missed it. But I noticed that this patch has now ended up in Andrew's tree without the comments being addressed. Can you please follow up?

Andrew: Can you remove this from your tree? As you can see it has been discussed before. I've mentioned elsewhere that I volunteer to take over maintenance of pwm-backlight so I'll carry this patch through the PWM tree.

Thierry

#4 lore raw
Quoted 17 lines · Thierry Reding
Quoted 16 lines · Avinash
Quoted 15 lines · Thierry Reding
Quoted 3 lines · Avinash

Low Threshold Brightness should be configured to have a linear relation in brightness scale. This patch adds device tree support for low threshold brightness as optional one for pwm_backlight.

I think this should be more explicit as to why this is required, perhaps something like this:

Some backlights perform poorly when driven by a PWM with a short duty-cycle. For such devices, the low threshold can be used to specify a lower bound for the duty-cycle and should be chosen to exclude the problematic range.

This patch adds support for an optional low-threshold-brightness property.

[snip]

Quoted 4 lines

I think you never sent an updated patch or maybe I missed it. But I noticed that this patch has now ended up in Andrew's tree without the comments being addressed. Can you please follow up?

I will send a revised patch.

Thanks
Avinash