Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Thomas Zimmermann and committed by
Lee Jones
726491f2 dfb4bf1a

+8 -16
+7 -7
drivers/video/backlight/backlight.c
··· 98 98 struct backlight_device *bd; 99 99 struct fb_event *evdata = data; 100 100 struct fb_info *info = evdata->info; 101 + const int *fb_blank = evdata->data; 101 102 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; 104 104 105 105 /* If we aren't interested in this event, skip it immediately ... */ 106 106 if (event != FB_EVENT_BLANK) ··· 116 116 if (fb_bd && fb_bd != bd) 117 117 goto out; 118 118 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)) { 122 123 if (!bd->use_count++) { 123 124 bd->props.state &= ~BL_CORE_FBBLANK; 124 125 backlight_update_status(bd); 125 126 } 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) { 128 128 if (!(--bd->use_count)) { 129 129 bd->props.state |= BL_CORE_FBBLANK; 130 130 backlight_update_status(bd);
+1 -9
include/linux/backlight.h
··· 294 294 struct device dev; 295 295 296 296 /** 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. 306 298 */ 307 299 int use_count; 308 300 };