diff mbox series

[01/15] video: fbdev: atmel_lcdfb: Rework backlight handling

Message ID 20230107-sam-video-backlight-drop-fb_blank-v1-1-1bd9bafb351f@ravnborg.org
State New
Headers show
Series [01/15] video: fbdev: atmel_lcdfb: Rework backlight handling | expand

Commit Message

Sam Ravnborg via B4 Relay Jan. 7, 2023, 6:26 p.m. UTC
From: Sam Ravnborg <sam@ravnborg.org>

The atmel_lcdfb had code to save/restore power state.
This is not needed so drop it.

Introduce backlight_is_brightness() to make logic simpler.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
Cc: linux-fbdev@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
---
 drivers/video/fbdev/atmel_lcdfb.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

Comments

Stephen Kitt Jan. 7, 2023, 8:36 p.m. UTC | #1
On 7 January 2023 19:26:15 CET, Sam Ravnborg via B4 Submission Endpoint <devnull+sam.ravnborg.org@kernel.org> wrote:
>From: Sam Ravnborg <sam@ravnborg.org>
>
>The atmel_lcdfb had code to save/restore power state.
>This is not needed so drop it.
>
>Introduce backlight_is_brightness() to make logic simpler.
>
>Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
>Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
>Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
>Cc: linux-fbdev@vger.kernel.org
>Cc: linux-arm-kernel@lists.infradead.org
>---
> drivers/video/fbdev/atmel_lcdfb.c | 24 +++---------------------
> 1 file changed, 3 insertions(+), 21 deletions(-)
>
>diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c
>index 1fc8de4ecbeb..d297b3892637 100644
>--- a/drivers/video/fbdev/atmel_lcdfb.c
>+++ b/drivers/video/fbdev/atmel_lcdfb.c
>@@ -49,7 +49,6 @@ struct atmel_lcdfb_info {
> 	struct clk		*lcdc_clk;
> 
> 	struct backlight_device	*backlight;
>-	u8			bl_power;
> 	u8			saved_lcdcon;
> 
> 	u32			pseudo_palette[16];
>@@ -109,32 +108,18 @@ static u32 contrast_ctr = ATMEL_LCDC_PS_DIV8
> static int atmel_bl_update_status(struct backlight_device *bl)
> {
> 	struct atmel_lcdfb_info *sinfo = bl_get_data(bl);
>-	int			power = sinfo->bl_power;
>-	int			brightness = bl->props.brightness;
>+	int brightness;
> 
>-	/* REVISIT there may be a meaningful difference between
>-	 * fb_blank and power ... there seem to be some cases
>-	 * this doesn't handle correctly.
>-	 */
>-	if (bl->props.fb_blank != sinfo->bl_power)
>-		power = bl->props.fb_blank;
>-	else if (bl->props.power != sinfo->bl_power)
>-		power = bl->props.power;
>-
>-	if (brightness < 0 && power == FB_BLANK_UNBLANK)
>-		brightness = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
>-	else if (power != FB_BLANK_UNBLANK)
>-		brightness = 0;
>+	brightness = backlight_get_brightness(bl);
> 
> 	lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness);
>+
> 	if (contrast_ctr & ATMEL_LCDC_POL_POSITIVE)
> 		lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR,
> 			brightness ? contrast_ctr : 0);
> 	else
> 		lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr);
> 
>-	bl->props.fb_blank = bl->props.power = sinfo->bl_power = power;
>-
> 	return 0;
> }
> 
>@@ -155,8 +140,6 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
> 	struct backlight_properties props;
> 	struct backlight_device	*bl;
> 
>-	sinfo->bl_power = FB_BLANK_UNBLANK;
>-
> 	if (sinfo->backlight)
> 		return;
> 
>@@ -173,7 +156,6 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
> 	sinfo->backlight = bl;
> 
> 	bl->props.power = FB_BLANK_UNBLANK;
>-	bl->props.fb_blank = FB_BLANK_UNBLANK;
> 	bl->props.brightness = atmel_bl_get_brightness(bl);
> }
> 
>

Hi Sam,

I’d submitted quite a few more of these previously (and you’d reviewed them), see e.g. the thread starting at https://lkml.org/lkml/2022/6/7/4365, and yesterday, https://lkml.org/lkml/2023/1/6/520, https://lkml.org/lkml/2023/1/6/656, https://lkml.org/lkml/2023/1/6/970, https://lkml.org/lkml/2023/1/6/643, and https://lkml.org/lkml/2023/1/6/680. There are a few more, I can find them if it’s any use.

Regards,

Stephen
Stephen Kitt Jan. 8, 2023, 7:45 a.m. UTC | #2
On 7 January 2023 21:53:46 CET, Sam Ravnborg <sam@ravnborg.org> wrote:
>Hi Stephen.
>
>On Sat, Jan 07, 2023 at 09:36:47PM +0100, Stephen Kitt wrote:
>> On 7 January 2023 19:26:15 CET, Sam Ravnborg via B4 Submission Endpoint <devnull+sam.ravnborg.org@kernel.org> wrote:
>> >From: Sam Ravnborg <sam@ravnborg.org>
>> >
>> >The atmel_lcdfb had code to save/restore power state.
>> >This is not needed so drop it.
>> >
>> >Introduce backlight_is_brightness() to make logic simpler.
>> >
>> >Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>> >Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
>> >Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
>> >Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
>> >Cc: linux-fbdev@vger.kernel.org
>> >Cc: linux-arm-kernel@lists.infradead.org
>> >---
>> > drivers/video/fbdev/atmel_lcdfb.c | 24 +++---------------------
>> > 1 file changed, 3 insertions(+), 21 deletions(-)
>...
>> 
>> Hi Sam,
>> 
>> I’d submitted quite a few more of these previously (and you’d reviewed them), see e.g. the thread starting at https://lkml.org/lkml/2022/6/7/4365, and yesterday, https://lkml.org/lkml/2023/1/6/520, https://lkml.org/lkml/2023/1/6/656, https://lkml.org/lkml/2023/1/6/970, https://lkml.org/lkml/2023/1/6/643, and https://lkml.org/lkml/2023/1/6/680. There are a few more, I can find them if it’s any use.
>
>The patches from yesterday was what triggered me to resurrect an old
>branch of mine where I had done something similar. I had lost all
>memory of reviewing similar patches from you.
>
>
>Helge - could you pick the reviewed patches from:
>https://lore.kernel.org/all/20220607192335.1137249-1-steve@sk2.org/
>[This is the same mail as Stephen refer to above - looked up via lore].
>
>Stephen - I expect Daniel/Lee to take care of the patches from yesterday.
>If you can look up other pending patches from you please do so, so we
>can have them applied.
>Preferably with links to lore - as this makes it easier to apply them.
>
>Review of what is unique in this set would be appreciated.
>
>	Sam

Hi Sam,

Here are my pending patches from last June on lore:

* https://lore.kernel.org/lkml/20220607190925.1134737-1-steve@sk2.org/
* https://lore.kernel.org/lkml/20220608205623.2106113-1-steve@sk2.org/
* https://lore.kernel.org/lkml/20220607192335.1137249-1-steve@sk2.org/
* https://lore.kernel.org/lkml/20220616170425.1346081-1-steve@sk2.org/

I’ll send reviews of your other patches later today or tomorrow.

Regards,

Stephen
Helge Deller Jan. 8, 2023, 5:26 p.m. UTC | #3
On 1/7/23 21:53, Sam Ravnborg wrote:
> Hi Stephen.
>
> On Sat, Jan 07, 2023 at 09:36:47PM +0100, Stephen Kitt wrote:
>> On 7 January 2023 19:26:15 CET, Sam Ravnborg via B4 Submission Endpoint <devnull+sam.ravnborg.org@kernel.org> wrote:
>>> From: Sam Ravnborg <sam@ravnborg.org>
>>>
>>> The atmel_lcdfb had code to save/restore power state.
>>> This is not needed so drop it.
>>>
>>> Introduce backlight_is_brightness() to make logic simpler.
>>>
>>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>>> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
>>> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
>>> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
>>> Cc: linux-fbdev@vger.kernel.org
>>> Cc: linux-arm-kernel@lists.infradead.org
>>> ---
>>> drivers/video/fbdev/atmel_lcdfb.c | 24 +++---------------------
>>> 1 file changed, 3 insertions(+), 21 deletions(-)
> ...
>>
>> Hi Sam,
>>
>> I’d submitted quite a few more of these previously (and you’d reviewed them), see e.g. the thread starting at https://lkml.org/lkml/2022/6/7/4365, and yesterday, https://lkml.org/lkml/2023/1/6/520, https://lkml.org/lkml/2023/1/6/656, https://lkml.org/lkml/2023/1/6/970, https://lkml.org/lkml/2023/1/6/643, and https://lkml.org/lkml/2023/1/6/680. There are a few more, I can find them if it’s any use.
>
> The patches from yesterday was what triggered me to resurrect an old
> branch of mine where I had done something similar. I had lost all
> memory of reviewing similar patches from you.
>
>
> Helge - could you pick the reviewed patches from:
> https://lore.kernel.org/all/20220607192335.1137249-1-steve@sk2.org/
> [This is the same mail as Stephen refer to above - looked up via lore].

I just pulled those 7 patches into fbdev/for-next.
If you need more, please let me know,

Thanks!
Helge


>
> Stephen - I expect Daniel/Lee to take care of the patches from yesterday.
> If you can look up other pending patches from you please do so, so we
> can have them applied.
> Preferably with links to lore - as this makes it easier to apply them.
>
> Review of what is unique in this set would be appreciated.
>
> 	Sam
Sam Ravnborg Jan. 8, 2023, 8:24 p.m. UTC | #4
Hi Stephen.

 
> Here are my pending patches from last June on lore:
> 

All patches are handled I think except this:
> * https://lore.kernel.org/lkml/20220608205623.2106113-1-steve@sk2.org/

Can I ask you to drop the assignment that is not needed, and resend with
the collected acks/r-b.

With this, then all fbdev patches are handled.

	Sam
Stephen Kitt Jan. 9, 2023, 8:18 p.m. UTC | #5
On Sun, 8 Jan 2023 18:26:12 +0100, Helge Deller <deller@gmx.de> wrote:

> On 1/7/23 21:53, Sam Ravnborg wrote:
> > Hi Stephen.
> >
> > On Sat, Jan 07, 2023 at 09:36:47PM +0100, Stephen Kitt wrote:  
> >> On 7 January 2023 19:26:15 CET, Sam Ravnborg via B4 Submission Endpoint
> >> <devnull+sam.ravnborg.org@kernel.org> wrote:  
> >>> From: Sam Ravnborg <sam@ravnborg.org>
> >>>
> >>> The atmel_lcdfb had code to save/restore power state.
> >>> This is not needed so drop it.
> >>>
> >>> Introduce backlight_is_brightness() to make logic simpler.
> >>>
> >>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> >>> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> >>> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
> >>> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
> >>> Cc: linux-fbdev@vger.kernel.org
> >>> Cc: linux-arm-kernel@lists.infradead.org
> >>> ---
> >>> drivers/video/fbdev/atmel_lcdfb.c | 24 +++---------------------
> >>> 1 file changed, 3 insertions(+), 21 deletions(-)  
> > ...  
> >>
> >> Hi Sam,
> >>
> >> I’d submitted quite a few more of these previously (and you’d reviewed
> >> them), see e.g. the thread starting at
> >> https://lkml.org/lkml/2022/6/7/4365, and yesterday,
> >> https://lkml.org/lkml/2023/1/6/520, https://lkml.org/lkml/2023/1/6/656,
> >> https://lkml.org/lkml/2023/1/6/970, https://lkml.org/lkml/2023/1/6/643,
> >> and https://lkml.org/lkml/2023/1/6/680. There are a few more, I can find
> >> them if it’s any use.  
> >
> > The patches from yesterday was what triggered me to resurrect an old
> > branch of mine where I had done something similar. I had lost all
> > memory of reviewing similar patches from you.
> >
> >
> > Helge - could you pick the reviewed patches from:
> > https://lore.kernel.org/all/20220607192335.1137249-1-steve@sk2.org/
> > [This is the same mail as Stephen refer to above - looked up via lore].  
> 
> I just pulled those 7 patches into fbdev/for-next.
> If you need more, please let me know,

Please pull
https://lore.kernel.org/lkml/20230109200239.1850611-1-steve@sk2.org/ too, it
completes the fbdev set. (It’s a re-send of
https://lore.kernel.org/lkml/20220609180440.3138625-1-steve@sk2.org/).

Thanks,

Stephen
Helge Deller Jan. 9, 2023, 8:34 p.m. UTC | #6
On 1/9/23 21:18, Stephen Kitt wrote:
> On Sun, 8 Jan 2023 18:26:12 +0100, Helge Deller <deller@gmx.de> wrote:
>
>> On 1/7/23 21:53, Sam Ravnborg wrote:
>>> Hi Stephen.
>>>
>>> On Sat, Jan 07, 2023 at 09:36:47PM +0100, Stephen Kitt wrote:
>>>> On 7 January 2023 19:26:15 CET, Sam Ravnborg via B4 Submission Endpoint
>>>> <devnull+sam.ravnborg.org@kernel.org> wrote:
>>>>> From: Sam Ravnborg <sam@ravnborg.org>
>>>>>
>>>>> The atmel_lcdfb had code to save/restore power state.
>>>>> This is not needed so drop it.
>>>>>
>>>>> Introduce backlight_is_brightness() to make logic simpler.
>>>>>
>>>>> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
>>>>> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
>>>>> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
>>>>> Cc: Ludovic Desroches <ludovic.desroches@microchip.com>
>>>>> Cc: linux-fbdev@vger.kernel.org
>>>>> Cc: linux-arm-kernel@lists.infradead.org
>>>>> ---
>>>>> drivers/video/fbdev/atmel_lcdfb.c | 24 +++---------------------
>>>>> 1 file changed, 3 insertions(+), 21 deletions(-)
>>> ...
>>>>
>>>> Hi Sam,
>>>>
>>>> I’d submitted quite a few more of these previously (and you’d reviewed
>>>> them), see e.g. the thread starting at
>>>> https://lkml.org/lkml/2022/6/7/4365, and yesterday,
>>>> https://lkml.org/lkml/2023/1/6/520, https://lkml.org/lkml/2023/1/6/656,
>>>> https://lkml.org/lkml/2023/1/6/970, https://lkml.org/lkml/2023/1/6/643,
>>>> and https://lkml.org/lkml/2023/1/6/680. There are a few more, I can find
>>>> them if it’s any use.
>>>
>>> The patches from yesterday was what triggered me to resurrect an old
>>> branch of mine where I had done something similar. I had lost all
>>> memory of reviewing similar patches from you.
>>>
>>>
>>> Helge - could you pick the reviewed patches from:
>>> https://lore.kernel.org/all/20220607192335.1137249-1-steve@sk2.org/
>>> [This is the same mail as Stephen refer to above - looked up via lore].
>>
>> I just pulled those 7 patches into fbdev/for-next.
>> If you need more, please let me know,
>
> Please pull
> https://lore.kernel.org/lkml/20230109200239.1850611-1-steve@sk2.org/ too, it
> completes the fbdev set. (It’s a re-send of
> https://lore.kernel.org/lkml/20220609180440.3138625-1-steve@sk2.org/).

Done.

Thanks!
Helge
diff mbox series

Patch

diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c
index 1fc8de4ecbeb..d297b3892637 100644
--- a/drivers/video/fbdev/atmel_lcdfb.c
+++ b/drivers/video/fbdev/atmel_lcdfb.c
@@ -49,7 +49,6 @@  struct atmel_lcdfb_info {
 	struct clk		*lcdc_clk;
 
 	struct backlight_device	*backlight;
-	u8			bl_power;
 	u8			saved_lcdcon;
 
 	u32			pseudo_palette[16];
@@ -109,32 +108,18 @@  static u32 contrast_ctr = ATMEL_LCDC_PS_DIV8
 static int atmel_bl_update_status(struct backlight_device *bl)
 {
 	struct atmel_lcdfb_info *sinfo = bl_get_data(bl);
-	int			power = sinfo->bl_power;
-	int			brightness = bl->props.brightness;
+	int brightness;
 
-	/* REVISIT there may be a meaningful difference between
-	 * fb_blank and power ... there seem to be some cases
-	 * this doesn't handle correctly.
-	 */
-	if (bl->props.fb_blank != sinfo->bl_power)
-		power = bl->props.fb_blank;
-	else if (bl->props.power != sinfo->bl_power)
-		power = bl->props.power;
-
-	if (brightness < 0 && power == FB_BLANK_UNBLANK)
-		brightness = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
-	else if (power != FB_BLANK_UNBLANK)
-		brightness = 0;
+	brightness = backlight_get_brightness(bl);
 
 	lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness);
+
 	if (contrast_ctr & ATMEL_LCDC_POL_POSITIVE)
 		lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR,
 			brightness ? contrast_ctr : 0);
 	else
 		lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr);
 
-	bl->props.fb_blank = bl->props.power = sinfo->bl_power = power;
-
 	return 0;
 }
 
@@ -155,8 +140,6 @@  static void init_backlight(struct atmel_lcdfb_info *sinfo)
 	struct backlight_properties props;
 	struct backlight_device	*bl;
 
-	sinfo->bl_power = FB_BLANK_UNBLANK;
-
 	if (sinfo->backlight)
 		return;
 
@@ -173,7 +156,6 @@  static void init_backlight(struct atmel_lcdfb_info *sinfo)
 	sinfo->backlight = bl;
 
 	bl->props.power = FB_BLANK_UNBLANK;
-	bl->props.fb_blank = FB_BLANK_UNBLANK;
 	bl->props.brightness = atmel_bl_get_brightness(bl);
 }