Skip to content

Commit ee4202d

Browse files
skitthdeller
authored andcommitted
fbdev: atmel_lcdfb: Rework backlight status updates
Instead of checking the state of various backlight_properties fields against the memorised state in atmel_lcdfb_info.bl_power, atmel_bl_update_status() should retrieve the desired state using backlight_get_brightness (which takes into account the power state, blanking etc.). This means the explicit checks using props.fb_blank and props.power can be dropped. The backlight framework ensures that backlight is never negative, so the test before reading the brightness from the hardware always ends up false and the whole block can be removed. The framework retrieves the brightness from the hardware through atmel_bl_get_brightness() when necessary. As a result, bl_power in struct atmel_lcdfb_info is no longer necessary, so remove that while we're at it. Since we only ever care about reading the current state in backlight_properties, drop the updates at the end of the function. Signed-off-by: Stephen Kitt <[email protected]> Acked-by: Sam Ravnborg <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 8791906 commit ee4202d

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

drivers/video/fbdev/atmel_lcdfb.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ struct atmel_lcdfb_info {
4949
struct clk *lcdc_clk;
5050

5151
struct backlight_device *backlight;
52-
u8 bl_power;
5352
u8 saved_lcdcon;
5453

5554
u32 pseudo_palette[16];
@@ -109,22 +108,7 @@ static u32 contrast_ctr = ATMEL_LCDC_PS_DIV8
109108
static int atmel_bl_update_status(struct backlight_device *bl)
110109
{
111110
struct atmel_lcdfb_info *sinfo = bl_get_data(bl);
112-
int power = sinfo->bl_power;
113-
int brightness = bl->props.brightness;
114-
115-
/* REVISIT there may be a meaningful difference between
116-
* fb_blank and power ... there seem to be some cases
117-
* this doesn't handle correctly.
118-
*/
119-
if (bl->props.fb_blank != sinfo->bl_power)
120-
power = bl->props.fb_blank;
121-
else if (bl->props.power != sinfo->bl_power)
122-
power = bl->props.power;
123-
124-
if (brightness < 0 && power == FB_BLANK_UNBLANK)
125-
brightness = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
126-
else if (power != FB_BLANK_UNBLANK)
127-
brightness = 0;
111+
int brightness = backlight_get_brightness(bl);
128112

129113
lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_VAL, brightness);
130114
if (contrast_ctr & ATMEL_LCDC_POL_POSITIVE)
@@ -133,8 +117,6 @@ static int atmel_bl_update_status(struct backlight_device *bl)
133117
else
134118
lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, contrast_ctr);
135119

136-
bl->props.fb_blank = bl->props.power = sinfo->bl_power = power;
137-
138120
return 0;
139121
}
140122

@@ -155,8 +137,6 @@ static void init_backlight(struct atmel_lcdfb_info *sinfo)
155137
struct backlight_properties props;
156138
struct backlight_device *bl;
157139

158-
sinfo->bl_power = FB_BLANK_UNBLANK;
159-
160140
if (sinfo->backlight)
161141
return;
162142

0 commit comments

Comments
 (0)