Subject: [PATCH 13/15] backlight: omap1: Use backlight helpers

From: Sam Ravnborg <[email protected]>

Rework backlight handling to avoid access to the deprecated
backlight_properties.fb_blank member.

The rework includes removal of get_brightness() operation,
because there was no read back from HW so no use for it.

Signed-off-by: Sam Ravnborg <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Daniel Thompson <[email protected]>
Cc: Jingoo Han <[email protected]>
---
drivers/video/backlight/omap1_bl.c | 67 +++++---------------------------------
1 file changed, 9 insertions(+), 58 deletions(-)

diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
index 69a49384b3de..49f37da857e7 100644
--- a/drivers/video/backlight/omap1_bl.c
+++ b/drivers/video/backlight/omap1_bl.c
@@ -20,9 +20,6 @@
#define OMAPBL_MAX_INTENSITY 0xff

struct omap_backlight {
- int powermode;
- int current_intensity;
-
struct device *dev;
struct omap_backlight_config *pdata;
};
@@ -37,82 +34,40 @@ static inline void omapbl_send_enable(int enable)
omap_writeb(enable, OMAP_PWL_CLK_ENABLE);
}

-static void omapbl_blank(struct omap_backlight *bl, int mode)
-{
- if (bl->pdata->set_power)
- bl->pdata->set_power(bl->dev, mode);
-
- switch (mode) {
- case FB_BLANK_NORMAL:
- case FB_BLANK_VSYNC_SUSPEND:
- case FB_BLANK_HSYNC_SUSPEND:
- case FB_BLANK_POWERDOWN:
- omapbl_send_intensity(0);
- omapbl_send_enable(0);
- break;
-
- case FB_BLANK_UNBLANK:
- omapbl_send_intensity(bl->current_intensity);
- omapbl_send_enable(1);
- break;
- }
-}
-
#ifdef CONFIG_PM_SLEEP
static int omapbl_suspend(struct device *dev)
{
struct backlight_device *bl_dev = dev_get_drvdata(dev);
- struct omap_backlight *bl = bl_get_data(bl_dev);

- omapbl_blank(bl, FB_BLANK_POWERDOWN);
+ backlight_disable(bl_dev);
return 0;
}

static int omapbl_resume(struct device *dev)
{
struct backlight_device *bl_dev = dev_get_drvdata(dev);
- struct omap_backlight *bl = bl_get_data(bl_dev);

- omapbl_blank(bl, bl->powermode);
+ backlight_enable(bl_dev);
return 0;
}
#endif

-static int omapbl_set_power(struct backlight_device *dev, int state)
-{
- struct omap_backlight *bl = bl_get_data(dev);
-
- omapbl_blank(bl, state);
- bl->powermode = state;
-
- return 0;
-}
-
static int omapbl_update_status(struct backlight_device *dev)
{
- struct omap_backlight *bl = bl_get_data(dev);
+ int brightness = backlight_get_brightness(dev);

- if (bl->current_intensity != dev->props.brightness) {
- if (bl->powermode == FB_BLANK_UNBLANK)
- omapbl_send_intensity(dev->props.brightness);
- bl->current_intensity = dev->props.brightness;
+ if (brightness > 0) {
+ omapbl_send_intensity(dev->props.brightness);
+ omapbl_send_enable(1);
+ } else {
+ omapbl_send_intensity(0);
+ omapbl_send_enable(0);
}

- if (dev->props.fb_blank != bl->powermode)
- omapbl_set_power(dev, dev->props.fb_blank);
-
return 0;
}

-static int omapbl_get_intensity(struct backlight_device *dev)
-{
- struct omap_backlight *bl = bl_get_data(dev);
-
- return bl->current_intensity;
-}
-
static const struct backlight_ops omapbl_ops = {
- .get_brightness = omapbl_get_intensity,
.update_status = omapbl_update_status,
};

@@ -139,9 +94,6 @@ static int omapbl_probe(struct platform_device *pdev)
if (IS_ERR(dev))
return PTR_ERR(dev);

- bl->powermode = FB_BLANK_POWERDOWN;
- bl->current_intensity = 0;
-
bl->pdata = pdata;
bl->dev = &pdev->dev;

@@ -149,7 +101,6 @@ static int omapbl_probe(struct platform_device *pdev)

omap_cfg_reg(PWL); /* Conflicts with UART3 */

- dev->props.fb_blank = FB_BLANK_UNBLANK;
dev->props.brightness = pdata->default_intensity;
omapbl_update_status(dev);


--
2.34.1


2023-01-08 20:04:15

by Stephen Kitt

[permalink] [raw]
Subject: Re: [PATCH 13/15] backlight: omap1: Use backlight helpers

On Sat, 07 Jan 2023 19:26:27 +0100, Sam Ravnborg via B4 Submission Endpoint
<[email protected]> wrote:

> From: Sam Ravnborg <[email protected]>
>
> Rework backlight handling to avoid access to the deprecated
> backlight_properties.fb_blank member.
>
> The rework includes removal of get_brightness() operation,
> because there was no read back from HW so no use for it.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: Lee Jones <[email protected]>
> Cc: Daniel Thompson <[email protected]>
> Cc: Jingoo Han <[email protected]>
> ---
> drivers/video/backlight/omap1_bl.c | 67
> +++++--------------------------------- 1 file changed, 9 insertions(+), 58
> deletions(-)
>
> diff --git a/drivers/video/backlight/omap1_bl.c
> b/drivers/video/backlight/omap1_bl.c index 69a49384b3de..49f37da857e7 100644
> --- a/drivers/video/backlight/omap1_bl.c
> +++ b/drivers/video/backlight/omap1_bl.c
> @@ -20,9 +20,6 @@
> #define OMAPBL_MAX_INTENSITY 0xff
>
> struct omap_backlight {
> - int powermode;
> - int current_intensity;
> -
> struct device *dev;
> struct omap_backlight_config *pdata;
> };
> @@ -37,82 +34,40 @@ static inline void omapbl_send_enable(int enable)
> omap_writeb(enable, OMAP_PWL_CLK_ENABLE);
> }
>
> -static void omapbl_blank(struct omap_backlight *bl, int mode)
> -{
> - if (bl->pdata->set_power)
> - bl->pdata->set_power(bl->dev, mode);
> -
> - switch (mode) {
> - case FB_BLANK_NORMAL:
> - case FB_BLANK_VSYNC_SUSPEND:
> - case FB_BLANK_HSYNC_SUSPEND:
> - case FB_BLANK_POWERDOWN:
> - omapbl_send_intensity(0);
> - omapbl_send_enable(0);
> - break;
> -
> - case FB_BLANK_UNBLANK:
> - omapbl_send_intensity(bl->current_intensity);
> - omapbl_send_enable(1);
> - break;
> - }
> -}
> -
> #ifdef CONFIG_PM_SLEEP
> static int omapbl_suspend(struct device *dev)
> {
> struct backlight_device *bl_dev = dev_get_drvdata(dev);
> - struct omap_backlight *bl = bl_get_data(bl_dev);
>
> - omapbl_blank(bl, FB_BLANK_POWERDOWN);
> + backlight_disable(bl_dev);
> return 0;
> }
>
> static int omapbl_resume(struct device *dev)
> {
> struct backlight_device *bl_dev = dev_get_drvdata(dev);
> - struct omap_backlight *bl = bl_get_data(bl_dev);
>
> - omapbl_blank(bl, bl->powermode);
> + backlight_enable(bl_dev);
> return 0;
> }
> #endif
>
> -static int omapbl_set_power(struct backlight_device *dev, int state)
> -{
> - struct omap_backlight *bl = bl_get_data(dev);
> -
> - omapbl_blank(bl, state);
> - bl->powermode = state;
> -
> - return 0;
> -}
> -
> static int omapbl_update_status(struct backlight_device *dev)
> {
> - struct omap_backlight *bl = bl_get_data(dev);
> + int brightness = backlight_get_brightness(dev);
>
> - if (bl->current_intensity != dev->props.brightness) {
> - if (bl->powermode == FB_BLANK_UNBLANK)
> - omapbl_send_intensity(dev->props.brightness);
> - bl->current_intensity = dev->props.brightness;
> + if (brightness > 0) {
> + omapbl_send_intensity(dev->props.brightness);
> + omapbl_send_enable(1);
> + } else {
> + omapbl_send_intensity(0);
> + omapbl_send_enable(0);
> }
>
> - if (dev->props.fb_blank != bl->powermode)
> - omapbl_set_power(dev, dev->props.fb_blank);
> -
> return 0;
> }
>
> -static int omapbl_get_intensity(struct backlight_device *dev)
> -{
> - struct omap_backlight *bl = bl_get_data(dev);
> -
> - return bl->current_intensity;
> -}
> -
> static const struct backlight_ops omapbl_ops = {
> - .get_brightness = omapbl_get_intensity,
> .update_status = omapbl_update_status,
> };
>
> @@ -139,9 +94,6 @@ static int omapbl_probe(struct platform_device *pdev)
> if (IS_ERR(dev))
> return PTR_ERR(dev);
>
> - bl->powermode = FB_BLANK_POWERDOWN;
> - bl->current_intensity = 0;
> -
> bl->pdata = pdata;
> bl->dev = &pdev->dev;
>
> @@ -149,7 +101,6 @@ static int omapbl_probe(struct platform_device *pdev)
>
> omap_cfg_reg(PWL); /* Conflicts with UART3 */
>
> - dev->props.fb_blank = FB_BLANK_UNBLANK;
> dev->props.brightness = pdata->default_intensity;
> omapbl_update_status(dev);
>
>
> --
> 2.34.1

Wow that gets rid of a lot of unnecessary code!

Reviewed-by: Stephen Kitt <[email protected]>


Attachments:
(No filename) (849.00 B)
OpenPGP digital signature

2023-01-09 11:16:48

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH 13/15] backlight: omap1: Use backlight helpers

On Sat, Jan 07, 2023 at 07:26:27PM +0100, Sam Ravnborg via B4 Submission Endpoint wrote:
> From: Sam Ravnborg <[email protected]>
>
> Rework backlight handling to avoid access to the deprecated
> backlight_properties.fb_blank member.
>
> The rework includes removal of get_brightness() operation,
> because there was no read back from HW so no use for it.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: Lee Jones <[email protected]>
> Cc: Daniel Thompson <[email protected]>
> Cc: Jingoo Han <[email protected]>

This rework will result in additional calls to omapbl_send_enable()
during updates so, if anyone who cares about omap1, is filtering LKML
then a Tested-by: would be nice.

However, I doubt the additional calls will do any harm so even with
that absent:
Reviewed-by: Daniel Thompson <[email protected]>


Daniel.

2023-01-19 22:58:01

by Konstantin Ryabitsev

[permalink] [raw]
Subject: Re: [PATCH 13/15] backlight: omap1: Use backlight helpers

On Thu, Jan 19, 2023 at 09:54:16PM +0000, Lee Jones wrote:
> My tools appear to dislike the line break in the Message-Id header.
> This isn't something I've encountered before. Is this a B4 thing?

It's more like it's a Python thing. The upcoming version of b4 will avoid this
(by not relying on Python to do message generation).

> Is this standard? Should I adapt my tooling to scan over line breaks?

This is RFC conformant, so if your tools are not able to deal with this
situation, you should consider modifying them.

-K

2023-01-20 05:52:52

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 13/15] backlight: omap1: Use backlight helpers

On Sat, 07 Jan 2023, Sam Ravnborg via B4 Submission Endpoint wrote:

> From: Sam Ravnborg <[email protected]>
>
> Rework backlight handling to avoid access to the deprecated
> backlight_properties.fb_blank member.
>
> The rework includes removal of get_brightness() operation,
> because there was no read back from HW so no use for it.
>
> Signed-off-by: Sam Ravnborg <[email protected]>
> Cc: Lee Jones <[email protected]>
> Cc: Daniel Thompson <[email protected]>
> Cc: Jingoo Han <[email protected]>
> ---
> drivers/video/backlight/omap1_bl.c | 67 +++++---------------------------------
> 1 file changed, 9 insertions(+), 58 deletions(-)

My tools appear to dislike the line break in the Message-Id header.

This isn't something I've encountered before. Is this a B4 thing?

Is this standard? Should I adapt my tooling to scan over line breaks?

--
Lee Jones [李琼斯]

2023-01-20 08:49:27

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH 13/15] backlight: omap1: Use backlight helpers

On Thu, 19 Jan 2023, Konstantin Ryabitsev wrote:

> On Thu, Jan 19, 2023 at 09:54:16PM +0000, Lee Jones wrote:
> > My tools appear to dislike the line break in the Message-Id header.
> > This isn't something I've encountered before. Is this a B4 thing?
>
> It's more like it's a Python thing. The upcoming version of b4 will avoid this
> (by not relying on Python to do message generation).

Understood.

> > Is this standard? Should I adapt my tooling to scan over line breaks?
>
> This is RFC conformant, so if your tools are not able to deal with this
> situation, you should consider modifying them.

Thanks for the info Konstantin, I'll do just that.

--
Lee Jones [李琼斯]