Skip to content

Commit 726491f

Browse files
Thomas Zimmermannlag-linaro
authored andcommitted
backlight: Implement fbdev tracking with blank state from event
Look at the blank state provided by FB_EVENT_BLANK to determine whether to enable or disable a backlight. Remove the tracking fields from struct backlight_device. Tracking requires three variables, fb_on, prev_fb_on and the backlight's use_count. If fb_on is true, the display has been unblanked. The backlight needs to be enabled if the display was blanked before (i.e., prev_fb_on is false) or if use_count is still at 0. If fb_on is false, the display has been blanked. In this case, the backlight has to be disabled was unblanked before and the backlight's use_count is greater than 0. This change removes fbdev state tracking from blacklight. All the backlight requires it its own use counter and information about changes to the display. Removing fbdev internals makes backlight drivers easier to integrate into other display drivers, such as DRM. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: "Daniel Thompson (RISCstar)" <danielt@kernel.org> Acked-by: Simona Vetter <simona.vetter@ffwll.ch> Link: https://lore.kernel.org/r/20250321095517.313713-5-tzimmermann@suse.de Signed-off-by: Lee Jones <lee@kernel.org>
1 parent dfb4bf1 commit 726491f

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

drivers/video/backlight/backlight.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ static int fb_notifier_callback(struct notifier_block *self,
9898
struct backlight_device *bd;
9999
struct fb_event *evdata = data;
100100
struct fb_info *info = evdata->info;
101+
const int *fb_blank = evdata->data;
101102
struct backlight_device *fb_bd = fb_bl_device(info);
102-
int node = info->node;
103-
int fb_blank = 0;
103+
bool fb_on, prev_fb_on;
104104

105105
/* If we aren't interested in this event, skip it immediately ... */
106106
if (event != FB_EVENT_BLANK)
@@ -116,15 +116,15 @@ static int fb_notifier_callback(struct notifier_block *self,
116116
if (fb_bd && fb_bd != bd)
117117
goto out;
118118

119-
fb_blank = *(int *)evdata->data;
120-
if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) {
121-
bd->fb_bl_on[node] = true;
119+
fb_on = fb_blank[0] == FB_BLANK_UNBLANK;
120+
prev_fb_on = fb_blank[1] == FB_BLANK_UNBLANK;
121+
122+
if (fb_on && (!prev_fb_on || !bd->use_count)) {
122123
if (!bd->use_count++) {
123124
bd->props.state &= ~BL_CORE_FBBLANK;
124125
backlight_update_status(bd);
125126
}
126-
} else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) {
127-
bd->fb_bl_on[node] = false;
127+
} else if (!fb_on && prev_fb_on && bd->use_count) {
128128
if (!(--bd->use_count)) {
129129
bd->props.state |= BL_CORE_FBBLANK;
130130
backlight_update_status(bd);

include/linux/backlight.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,7 @@ struct backlight_device {
294294
struct device dev;
295295

296296
/**
297-
* @fb_bl_on: The state of individual fbdev's.
298-
*
299-
* Multiple fbdev's may share one backlight device. The fb_bl_on
300-
* records the state of the individual fbdev.
301-
*/
302-
bool fb_bl_on[FB_MAX];
303-
304-
/**
305-
* @use_count: The number of uses of fb_bl_on.
297+
* @use_count: The number of unblanked displays.
306298
*/
307299
int use_count;
308300
};

0 commit comments

Comments
 (0)