backlight: gpio_backlight: Use a default state enum.
Subsystems (3)
PATCH v7 1/2 backlight: gpio_backlight: Use a default state enum.
That enum adds a "keep" state which permits to tell the
driver trough its platform data not to touch the hardware during the probe.
---
ChangeLog v5->v6:
- New patch.
--- drivers/video/backlight/gpio_backlight.c | 7 +++++-- include/linux/platform_data/gpio_backlight.h | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/video/backlight/gpio_backlight.c +5 -2
@@ -23,6 +23,7 @@ struct gpio_backlight {int gpio;int active; +enum gpio_backlight_default_state def_value; };static int gpio_backlight_update_status (struct backlight_device *bl)
@@ -103,8 +104,10 @@ static int gpio_backlight_probe(struct platform_device *pdev)return PTR_ERR (bl); } - bl->props.brightness = pdata->def_value; -backlight_update_status (bl); +if (pdata->def_value !=BACKLIGHT_GPIO_DEFSTATE_KEEP ) { + bl->props.brightness = pdata->def_value; +backlight_update_status (bl); + }platform_set_drvdata (pdev, bl);return 0 ;
include/linux/platform_data/gpio_backlight.h +6 -0
@@ -10,6 +10,12 @@struct device ; +enum gpio_backlight_default_state { +BACKLIGHT_GPIO_DEFSTATE_OFF , +BACKLIGHT_GPIO_DEFSTATE_ON , +BACKLIGHT_GPIO_DEFSTATE_KEEP , +}; +struct gpio_backlight_platform_data {struct device *fbdev;int gpio;
Signature · 1 line
1.7.9.5
PATCH v7 2/2 video: backlight: gpio-backlight: Add DT support.
---
ChangeLog v6->v7:
- removed a compilation warning with the removal of the useless ret declaration.
ChangeLog v5->v6:
- The default state handling was reworked:
- it's now called default-state, and looks like the gpio-leds default-state.
- it now has a "keep" option, like for the gpio-leds.
- that "keep" option is the default when the default-state property is not set.
- The documentation was updated accordingly.
ChangeLog v4->v5:
- The default-brightness property now defaults to 0 in the driver.
- def_value int becomes a bool.
- The check for the gpio validity has been reworked.
--- .../bindings/video/backlight/gpio-backlight.txt | 23 +++++++ drivers/video/backlight/gpio_backlight.c | 71 +++++++++++++++++--- 2 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt new file +23 -0
@@ -0,0 +1,23 @@ +gpio-backlight bindings + +Required properties: + - compatible: "gpio-backlight" + - gpios: describes the gpio that is used for enabling/disabling the backlight + (see GPIO binding[0] for more details). + +Optional properties: + - default-state: The initial state of the backlight. + Valid values are "on", "off", and "keep". + The "keep" setting will keep the backlight at whatever its current + state is, without producing a glitch. The default is keep if this + property is not present. + +[0]: Documentation/devicetree/bindings/gpio/gpio.txt + +Example: + + backlight { + compatible = "gpio-backlight"; + gpios = <&gpio3 4 0>; + default-state = "on"; + };
drivers/video/backlight/gpio_backlight.c +63 -8
117 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v7 2/2 video: backlight: gpio-backlight: Add DT support.
On Thu, Dec 05, 2013 at 06:55:09PM +0100, Denis Carikli wrote:
[...]
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt line 13
Quoted 6 lines
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt new file +6
-0+Optional properties: + - default-state: The initial state of the backlight. + Valid values are "on", "off", and "keep". + The "keep" setting will keep the backlight at whatever its current + state is, without producing a glitch. The default is keep if this + property is not present.
I'm not sure if "on", "off" and "keep" are a good choice for this binding. Having strings for these tristate values seems suboptimal. Other bindings have chosen a representation that, transposed to this use-case, would read something like this:
- default-state: The initial state of the backlight. Valid values:
- 0: off
- 1: on
If the "default-state" property is not present, the default will be to keep the current backlight state.
Which is in fact the exact behaviour that your binding describes, but it's much more intuitive in my opinion.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131206/fd9e72af/attachment.sig>
Re: [PATCHv7][ 2/2] video: backlight: gpio-backlight: Add DT support.
Quoted 19 lines · Denis Carikli
[...]
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt line 13
Quoted 6 lines
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt new file +6
-0+Optional properties: + - default-state: The initial state of the backlight. + Valid values are "on", "off", and "keep". + The "keep" setting will keep the backlight at whatever its current + state is, without producing a glitch. The default is keep if this + property is not present.I'm not sure if "on", "off" and "keep" are a good choice for this binding. Having strings for these tristate values seems suboptimal. Other bindings have chosen a representation that, transposed to this use-case, would read something like this:
- default-state: The initial state of the backlight. Valid values:
- 0: off
- 1: on
Quoted 5 lines
If the "default-state" property is not present, the default will be to keep the current backlight state.
Which is in fact the exact behaviour that your binding describes, but it's much more intuitive in my opinion.
Why we cannot use GPIO bindings for active level here? What a reason for "keep" state? Can this be an additional property?
---
PATCH v7 2/2 video: backlight: gpio-backlight: Add DT support.
Quoted 19 lines · Alexander Shiyan
Quoted 19 lines · Denis Carikli
[...]
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt line 13
Quoted 6 lines
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt new file +6
-0+Optional properties: + - default-state: The initial state of the backlight. + Valid values are "on", "off", and "keep". + The "keep" setting will keep the backlight at whatever its current + state is, without producing a glitch. The default is keep if this + property is not present.I'm not sure if "on", "off" and "keep" are a good choice for this binding. Having strings for these tristate values seems suboptimal. Other bindings have chosen a representation that, transposed to this use-case, would read something like this:
- default-state: The initial state of the backlight. Valid values:
- 0: off
- 1: on
Quoted 8 lines
Quoted 5 lines
If the "default-state" property is not present, the default will be to keep the current backlight state.
Which is in fact the exact behaviour that your binding describes, but it's much more intuitive in my opinion.
Why we cannot use GPIO bindings for active level here? What a reason for "keep" state? Can this be an additional property?
Default state and active level are two different things.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131206/6b4b0460/attachment.sig>
Re: [PATCHv7][ 2/2] video: backlight: gpio-backlight: Add DT support.
Quoted 23 lines · Alexander Shiyan
Quoted 22 lines
Quoted 22 lines · Denis Carikli
[...]
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt line 13
Quoted 6 lines
Documentation/devicetree/bindings/video/backlight/gpio-backlight.txt new file +6
-0+Optional properties: + - default-state: The initial state of the backlight. + Valid values are "on", "off", and "keep". + The "keep" setting will keep the backlight at whatever its current + state is, without producing a glitch. The default is keep if this + property is not present.I'm not sure if "on", "off" and "keep" are a good choice for this binding. Having strings for these tristate values seems suboptimal. Other bindings have chosen a representation that, transposed to this use-case, would read something like this:
- default-state: The initial state of the backlight. Valid values:
- 0: off
- 1: onIf the "default-state" property is not present, the default will be to keep the current backlight state.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Which is in fact the exact behaviour that your binding describes, but it's much more intuitive in my opinion.
Why we cannot use GPIO bindings for active level here? What a reason for "keep" state? Can this be an additional property?
Default state and active level are two different things.
OK. And what is "default" state? State before "unblank"?
---