From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:19
This series removes the remaining dependencies on fbdev from the
backlight, lcd and led subsystems. Each depends on fbdev events to
track display state. Make fbdev inform each subsystem via a dedicated
interface instead.
Patches 1 to 3 make fbdev track blank state for each display, so that
backlight code doesn't have to.
Patches 4 to 6 remove fbdev event handling from backlight code. Patches
7 and 8 remove fbdev event handling from lcd code and patches 9 and 10
do the same for led's backlight trigger.
The final patch removes the event constants from fbdev.
With the series applied, the three subsystems do no longer depend on
fbdev. It's also a clean up for fbdev. Fbdev used to send out a large
number of events. That mechanism has been deprecated for some time and
converted call to dedicated functions instead.
Testing is very welcome, as I don't have the hardware to test this
series.
v3:
- export several symbols
- static-inline declare empty placeholders
v2:
- avoid IS_REACHABLE() in source file (Lee)
- simplify several interfaces and helpers
- use lock guards
- initialize global lists and mutices
Thomas Zimmermann (11):
fbdev: Rework fb_blank()
fbdev: Track display blanking state
fbdev: Send old blank state in FB_EVENT_BLANK
backlight: Implement fbdev tracking with blank state from event
backlight: Move blank-state handling into helper
backlight: Replace fb events with a dedicated function call
backlight: lcd: Move event handling into helpers
backlight: lcd: Replace fb events with a dedicated function call
leds: backlight trigger: Move blank-state handling into helper
leds: backlight trigger: Replace fb events with a dedicated function
call
fbdev: Remove constants of unused events
drivers/leds/trigger/ledtrig-backlight.c | 48 +++++-----
drivers/video/backlight/backlight.c | 93 +++++--------------
drivers/video/backlight/lcd.c | 108 +++++++++--------------
drivers/video/fbdev/core/fb_backlight.c | 12 +++
drivers/video/fbdev/core/fb_info.c | 1 +
drivers/video/fbdev/core/fbmem.c | 82 ++++++++++++++---
drivers/video/fbdev/core/fbsysfs.c | 8 +-
include/linux/backlight.h | 22 ++---
include/linux/fb.h | 12 +--
include/linux/lcd.h | 21 ++++-
include/linux/leds.h | 6 ++
11 files changed, 205 insertions(+), 208 deletions(-)
--
2.48.1
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:16
Reimplement fb_blank() to return early on errors. No functional
changes. Prepares the helper for tracking the blanking state in
struct fb_info.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/fbdev/core/fbmem.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:21
The event FB_EVENT_BLANK sends the new blank state in the event's
data field. Also send the old state. It's an additional field in the
data array; existing receivers won't notice the difference.
The backlight subsystem currently tracks blank state per display per
backlight. That is not optimal as it ties backlight code to fbdev. A
subsystem should not track internal state of another subsystem. With
both, new and old, blank state in FB_EVENT_BLANK, the backlight code
will not require its own state tracker any longer.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/fbdev/core/fbmem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
@@ -343,6 +343,7 @@ int fb_blank(struct fb_info *info, int blank){intold_blank=info->blank;structfb_eventevent;+intdata[2];intret;if(!info->fbops->fb_blank)
@@ -351,8 +352,10 @@ int fb_blank(struct fb_info *info, int blank)if(blank>FB_BLANK_POWERDOWN)blank=FB_BLANK_POWERDOWN;+data[0]=blank;+data[1]=old_blank;event.info=info;-event.data=␣+event.data=data;info->blank=blank;
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:21
Store the display's blank status in struct fb_info.blank and track
it in fb_blank(). As an extra, the status is now available from the
sysfs blank attribute.
Support for blanking is optional. Therefore framebuffer_alloc()
initializes the state to FB_BLANK_UNBLANK (i.e., the display is
on). If the fb_blank callback has been set, register_framebuffer()
sets the state to FB_BLANK_POWERDOWN. On the first modeset, the
call to fb_blank() will update it to _UNBLANK. This is important,
as listeners to FB_EVENT_BLANK will now see the display being
switched on.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/fbdev/core/fb_info.c | 1 +
drivers/video/fbdev/core/fbmem.c | 17 ++++++++++++++++-
drivers/video/fbdev/core/fbsysfs.c | 8 ++++----
include/linux/fb.h | 2 ++
4 files changed, 23 insertions(+), 5 deletions(-)
@@ -353,13 +354,19 @@ int fb_blank(struct fb_info *info, int blank)event.info=info;event.data=␣+info->blank=blank;+ret=info->fbops->fb_blank(blank,info);if(ret)-returnret;+gotoerr;fb_notifier_call_chain(FB_EVENT_BLANK,&event);return0;++err:+info->blank=old_blank;+returnret;}EXPORT_SYMBOL(fb_blank);
@@ -408,6 +415,14 @@ static int do_register_framebuffer(struct fb_info *fb_info)mutex_init(&fb_info->lock);mutex_init(&fb_info->mm_lock);+/*+*Withanfb_blankcallbackpresent,weassumethatthe+*displayisblank,sothatfb_blank()enablesitonthe+*firstmodeset.+*/+if(fb_info->fbops->fb_blank)+fb_info->blank=FB_BLANK_POWERDOWN;+fb_device_create(fb_info);if(fb_info->pixmap.addr==NULL){
@@ -471,6 +471,8 @@ struct fb_info {structlist_headmodelist;/* mode list */structfb_videomode*mode;/* current mode */+intblank;/* current blanking; see FB_BLANK_ constants */+#if IS_ENABLED(CONFIG_FB_BACKLIGHT)/* assigned backlight device *//* set before framebuffer registration,
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:25
Move the handling of blank-state updates into a separate helper,
so that is can be called without the fbdev event. No functional
changes.
As a minor improvement over the original code, the update replaces
manual locking with a guard.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/backlight/backlight.c | 46 +++++++++++++++++------------
1 file changed, 27 insertions(+), 19 deletions(-)
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:25
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>
---
drivers/video/backlight/backlight.c | 14 +++++++-------
include/linux/backlight.h | 10 +---------
2 files changed, 8 insertions(+), 16 deletions(-)
@@ -98,9 +98,9 @@ static int fb_notifier_callback(struct notifier_block *self,structbacklight_device*bd;structfb_event*evdata=data;structfb_info*info=evdata->info;+constint*fb_blank=evdata->data;structbacklight_device*fb_bd=fb_bl_device(info);-intnode=info->node;-intfb_blank=0;+boolfb_on,prev_fb_on;/* If we aren't interested in this event, skip it immediately ... */if(event!=FB_EVENT_BLANK)
@@ -116,15 +116,15 @@ static int fb_notifier_callback(struct notifier_block *self,if(fb_bd&&fb_bd!=bd)gotoout;-fb_blank=*(int*)evdata->data;-if(fb_blank==FB_BLANK_UNBLANK&&!bd->fb_bl_on[node]){-bd->fb_bl_on[node]=true;+fb_on=fb_blank[0]==FB_BLANK_UNBLANK;+prev_fb_on=fb_blank[1]==FB_BLANK_UNBLANK;++if(fb_on&&(!prev_fb_on||!bd->use_count)){if(!bd->use_count++){bd->props.state&=~BL_CORE_FBBLANK;backlight_update_status(bd);}-}elseif(fb_blank!=FB_BLANK_UNBLANK&&bd->fb_bl_on[node]){-bd->fb_bl_on[node]=false;+}elseif(!fb_on&&prev_fb_on&&bd->use_count){if(!(--bd->use_count)){bd->props.state|=BL_CORE_FBBLANK;backlight_update_status(bd);
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:29
Remove support for fb events from backlight subsystem. Provide the
helper backlight_notify_blank_all() instead. Also export the existing
helper backlight_notify_blank() to update a single backlight device.
In fbdev, call either helper to inform the backlight subsystem of
changes to a display's blank state. If the framebuffer device has a
specific backlight, only update this one; otherwise update all.
v3:
- declare empty fb_bl_notify_blank() as static inline (kernel test robot)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/backlight/backlight.c | 85 ++++---------------------
drivers/video/fbdev/core/fb_backlight.c | 12 ++++
drivers/video/fbdev/core/fbmem.c | 2 +
include/linux/backlight.h | 12 ++--
include/linux/fb.h | 4 ++
5 files changed, 36 insertions(+), 79 deletions(-)
@@ -103,68 +99,18 @@ static void backlight_notify_blank(struct backlight_device *bd,}}}+EXPORT_SYMBOL(backlight_notify_blank);-/*-*fb_notifier_callback-*-*Thiscallbackgetscalledwhensomethingimportanthappensinsidea-*framebufferdriver.ThebacklightcoreonlycaresaboutFB_BLANK_UNBLANK-*whichisreportedtothedriverusingbacklight_update_status()-*asastatechange.-*-*Theremaybeseveralfbdev'sconnectedtothebacklightdevice,-*inwhichcasetheyarekepttrackof.Astatechangeisonlyreported-*ifthereisachangeinbacklightforthespecifiedfbdev.-*/-staticintfb_notifier_callback(structnotifier_block*self,-unsignedlongevent,void*data)+voidbacklight_notify_blank_all(structdevice*display_dev,boolfb_on,boolprev_fb_on){structbacklight_device*bd;-structfb_event*evdata=data;-structfb_info*info=evdata->info;-constint*fb_blank=evdata->data;-structbacklight_device*fb_bd=fb_bl_device(info);-boolfb_on,prev_fb_on;--/* If we aren't interested in this event, skip it immediately ... */-if(event!=FB_EVENT_BLANK)-return0;--bd=container_of(self,structbacklight_device,fb_notif);--if(fb_bd&&fb_bd!=bd)-return0;--fb_on=fb_blank[0]==FB_BLANK_UNBLANK;-prev_fb_on=fb_blank[1]==FB_BLANK_UNBLANK;--backlight_notify_blank(bd,info->device,fb_on,prev_fb_on);--return0;-}--staticintbacklight_register_fb(structbacklight_device*bd)-{-memset(&bd->fb_notif,0,sizeof(bd->fb_notif));-bd->fb_notif.notifier_call=fb_notifier_callback;-returnfb_register_client(&bd->fb_notif);-}+guard(mutex)(&backlight_dev_list_mutex);-staticvoidbacklight_unregister_fb(structbacklight_device*bd)-{-fb_unregister_client(&bd->fb_notif);-}-#else-staticinlineintbacklight_register_fb(structbacklight_device*bd)-{-return0;+list_for_each_entry(bd,&backlight_dev_list,entry)+backlight_notify_blank(bd,display_dev,fb_on,prev_fb_on);}--staticinlinevoidbacklight_unregister_fb(structbacklight_device*bd)-{-}-#endif /* CONFIG_FB_CORE */+EXPORT_SYMBOL(backlight_notify_blank_all);staticvoidbacklight_generate_event(structbacklight_device*bd,enumbacklight_update_reasonreason)
@@ -363,6 +363,8 @@ int fb_blank(struct fb_info *info, int blank)if(ret)gotoerr;+fb_bl_notify_blank(info,old_blank);+fb_notifier_call_chain(FB_EVENT_BLANK,&event);return0;
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:29
Move the handling of display updates to separate helper functions.
There is code for handling fbdev blank events and fbdev mode changes.
The code currently runs from fbdev event notifiers, which will be
replaced.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/backlight/lcd.c | 38 ++++++++++++++++++++++++++---------
1 file changed, 28 insertions(+), 10 deletions(-)
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:33
Move the handling of blank-state updates into a separate helper,
so that is can be called without the fbdev event. No functional
changes.
v2:
- rename helper to avoid renaming in a later patch (Lee)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/leds/trigger/ledtrig-backlight.c | 30 ++++++++++++++----------
1 file changed, 18 insertions(+), 12 deletions(-)
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:35
Remove support for fb events from the lcd subsystem. Provide the
helper lcd_notify_blank_all() instead. In fbdev, call
lcd_notify_blank_all() to inform the lcd subsystem of changes
to a display's blank state.
Fbdev maintains a list of all installed notifiers. Instead of fbdev
notifiers, maintain an internal list of lcd devices.
v3:
- export lcd_notify_mode_change_all() (kernel test robot)
v2:
- maintain global list of lcd devices
- avoid IS_REACHABLE() in source file
- use lock guards
- initialize lcd list and list mutex
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/video/backlight/lcd.c | 98 +++++++++-----------------------
drivers/video/fbdev/core/fbmem.c | 39 +++++++++++--
include/linux/lcd.h | 21 ++++++-
3 files changed, 79 insertions(+), 79 deletions(-)
@@ -331,14 +337,38 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)if(ret)returnret;-event.info=info;-event.data=&mode;-fb_notifier_call_chain(FB_EVENT_MODE_CHANGE,&event);+fb_lcd_notify_mode_change(info,&mode);return0;}EXPORT_SYMBOL(fb_set_var);+staticvoidfb_lcd_notify_blank(structfb_info*info)+{+intpower;++switch(info->blank){+caseFB_BLANK_UNBLANK:+power=LCD_POWER_ON;+break;+/* deprecated; TODO: should become 'off' */+caseFB_BLANK_NORMAL:+power=LCD_POWER_REDUCED;+break;+caseFB_BLANK_VSYNC_SUSPEND:+power=LCD_POWER_REDUCED_VSYNC_SUSPEND;+break;+/* 'off' */+caseFB_BLANK_HSYNC_SUSPEND:+caseFB_BLANK_POWERDOWN:+default:+power=LCD_POWER_OFF;+break;+}++lcd_notify_blank_all(info->device,power);+}+intfb_blank(structfb_info*info,intblank){intold_blank=info->blank;
@@ -364,6 +394,7 @@ int fb_blank(struct fb_info *info, int blank)gotoerr;fb_bl_notify_blank(info,old_blank);+fb_lcd_notify_blank(info);fb_notifier_call_chain(FB_EVENT_BLANK,&event);
@@ -11,7 +11,6 @@#include<linux/device.h>#include<linux/mutex.h>-#include<linux/notifier.h>#define LCD_POWER_ON (0)#define LCD_POWER_REDUCED (1) // deprecated; don't use in new code
@@ -79,8 +78,11 @@ struct lcd_device {conststructlcd_ops*ops;/* Serialise access to set_power method */structmutexupdate_lock;-/* The framebuffer notifier block */-structnotifier_blockfb_notif;++/**+*@entry:Listentryofallregisteredlcddevices+*/+structlist_headentry;structdevicedev;};
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:37
Remove support for fb events from the led backlight trigger. Provide
the helper ledtrig_backlight_blank() instead. Call it from fbdev to
inform the trigger of changes to a display's blank state.
Fbdev maintains a list of all installed notifiers. Instead of the fbdev
notifiers, maintain an internal list of led backlight triggers.
v3:
- export ledtrig_backlight_blank()
v2:
- maintain global list of led backlight triggers (Lee)
- avoid IS_REACHABLE() in source file (Lee)
- notify on changes to blank state instead of display state
- use lock guards
- initialize led list and list mutex
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/leds/trigger/ledtrig-backlight.c | 42 ++++++++++--------------
drivers/video/fbdev/core/fbmem.c | 19 ++++++-----
include/linux/leds.h | 6 ++++
3 files changed, 33 insertions(+), 34 deletions(-)
@@ -42,26 +45,17 @@ static void ledtrig_backlight_notify_blank(struct bl_trig_notifier *n, int new_sn->old_status=new_status;}-staticintfb_notifier_callback(structnotifier_block*p,-unsignedlongevent,void*data)+voidledtrig_backlight_blank(boolblank){-structbl_trig_notifier*n=container_of(p,-structbl_trig_notifier,notifier);-structfb_event*fb_event=data;-int*blank;-intnew_status;--/* If we aren't interested in this event, skip it immediately ... */-if(event!=FB_EVENT_BLANK)-return0;--blank=fb_event->data;-new_status=*blank?BLANK:UNBLANK;+structbl_trig_notifier*n;+intnew_status=blank?BLANK:UNBLANK;-ledtrig_backlight_notify_blank(n,new_status);+guard(mutex)(&ledtrig_backlight_list_mutex);-return0;+list_for_each_entry(n,&ledtrig_backlight_list,entry)+ledtrig_backlight_notify_blank(n,new_status);}+EXPORT_SYMBOL(ledtrig_backlight_blank);staticssize_tbl_trig_invert_show(structdevice*dev,structdevice_attribute*attr,char*buf)
@@ -382,11 +389,6 @@ int fb_blank(struct fb_info *info, int blank)if(blank>FB_BLANK_POWERDOWN)blank=FB_BLANK_POWERDOWN;-data[0]=blank;-data[1]=old_blank;-event.info=info;-event.data=data;-info->blank=blank;ret=info->fbops->fb_blank(blank,info);
@@ -395,8 +397,7 @@ int fb_blank(struct fb_info *info, int blank)fb_bl_notify_blank(info,old_blank);fb_lcd_notify_blank(info);--fb_notifier_call_chain(FB_EVENT_BLANK,&event);+fb_ledtrig_backlight_notify_blank(info);return0;
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-06 14:13:42
The constants FB_EVENT_MODE_CHANGE and FB_EVENT_BLANK are unused.
Remove them from the header file.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
include/linux/fb.h | 6 ------
1 file changed, 6 deletions(-)
@@ -129,18 +129,12 @@ struct fb_cursor_user {*Register/unregisterforframebufferevents*/-/* The resolution of the passed in fb_info about to change */-#define FB_EVENT_MODE_CHANGE 0x01-#ifdef CONFIG_GUMSTIX_AM200EPD/* only used by mach-pxa/am200epd.c */#define FB_EVENT_FB_REGISTERED 0x05#define FB_EVENT_FB_UNREGISTERED 0x06#endif-/* A display blank is requested */-#define FB_EVENT_BLANK 0x09-structfb_event{structfb_info*info;void*data;
>>> referenced by fb_backlight.c:49 (drivers/video/fbdev/core/fb_backlight.c:49)
>>> drivers/video/fbdev/core/fb_backlight.o:(fb_bl_notify_blank) in archive vmlinux.a
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
From: Lee Jones <lee@kernel.org> Date: 2025-03-13 16:52:01
On Thu, 06 Mar 2025, Thomas Zimmermann wrote:
This series removes the remaining dependencies on fbdev from the
backlight, lcd and led subsystems. Each depends on fbdev events to
track display state. Make fbdev inform each subsystem via a dedicated
interface instead.
Patches 1 to 3 make fbdev track blank state for each display, so that
backlight code doesn't have to.
Patches 4 to 6 remove fbdev event handling from backlight code. Patches
7 and 8 remove fbdev event handling from lcd code and patches 9 and 10
do the same for led's backlight trigger.
The final patch removes the event constants from fbdev.
With the series applied, the three subsystems do no longer depend on
fbdev. It's also a clean up for fbdev. Fbdev used to send out a large
number of events. That mechanism has been deprecated for some time and
converted call to dedicated functions instead.
Testing is very welcome, as I don't have the hardware to test this
series.
v3:
- export several symbols
- static-inline declare empty placeholders
v2:
- avoid IS_REACHABLE() in source file (Lee)
- simplify several interfaces and helpers
- use lock guards
- initialize global lists and mutices
Thomas Zimmermann (11):
fbdev: Rework fb_blank()
fbdev: Track display blanking state
fbdev: Send old blank state in FB_EVENT_BLANK
backlight: Implement fbdev tracking with blank state from event
backlight: Move blank-state handling into helper
backlight: Replace fb events with a dedicated function call
backlight: lcd: Move event handling into helpers
backlight: lcd: Replace fb events with a dedicated function call
leds: backlight trigger: Move blank-state handling into helper
leds: backlight trigger: Replace fb events with a dedicated function
call
fbdev: Remove constants of unused events
drivers/leds/trigger/ledtrig-backlight.c | 48 +++++-----
drivers/video/backlight/backlight.c | 93 +++++--------------
drivers/video/backlight/lcd.c | 108 +++++++++--------------
drivers/video/fbdev/core/fb_backlight.c | 12 +++
drivers/video/fbdev/core/fb_info.c | 1 +
drivers/video/fbdev/core/fbmem.c | 82 ++++++++++++++---
drivers/video/fbdev/core/fbsysfs.c | 8 +-
include/linux/backlight.h | 22 ++---
include/linux/fb.h | 12 +--
include/linux/lcd.h | 21 ++++-
include/linux/leds.h | 6 ++
11 files changed, 205 insertions(+), 208 deletions(-)
No immediately obvious issues from the LEDs side.
Still needs reviews from Backlight and fbdev.
--
Lee Jones [李琼斯]
On Thu, Mar 13, 2025 at 04:51:51PM +0000, Lee Jones wrote:
On Thu, 06 Mar 2025, Thomas Zimmermann wrote:
quoted
This series removes the remaining dependencies on fbdev from the
backlight, lcd and led subsystems. Each depends on fbdev events to
track display state. Make fbdev inform each subsystem via a dedicated
interface instead.
Patches 1 to 3 make fbdev track blank state for each display, so that
backlight code doesn't have to.
Patches 4 to 6 remove fbdev event handling from backlight code. Patches
7 and 8 remove fbdev event handling from lcd code and patches 9 and 10
do the same for led's backlight trigger.
The final patch removes the event constants from fbdev.
With the series applied, the three subsystems do no longer depend on
fbdev. It's also a clean up for fbdev. Fbdev used to send out a large
number of events. That mechanism has been deprecated for some time and
converted call to dedicated functions instead.
Testing is very welcome, as I don't have the hardware to test this
series.
v3:
- export several symbols
- static-inline declare empty placeholders
v2:
- avoid IS_REACHABLE() in source file (Lee)
- simplify several interfaces and helpers
- use lock guards
- initialize global lists and mutices
Thomas Zimmermann (11):
fbdev: Rework fb_blank()
fbdev: Track display blanking state
fbdev: Send old blank state in FB_EVENT_BLANK
backlight: Implement fbdev tracking with blank state from event
backlight: Move blank-state handling into helper
backlight: Replace fb events with a dedicated function call
backlight: lcd: Move event handling into helpers
backlight: lcd: Replace fb events with a dedicated function call
leds: backlight trigger: Move blank-state handling into helper
leds: backlight trigger: Replace fb events with a dedicated function
call
fbdev: Remove constants of unused events
drivers/leds/trigger/ledtrig-backlight.c | 48 +++++-----
drivers/video/backlight/backlight.c | 93 +++++--------------
drivers/video/backlight/lcd.c | 108 +++++++++--------------
drivers/video/fbdev/core/fb_backlight.c | 12 +++
drivers/video/fbdev/core/fb_info.c | 1 +
drivers/video/fbdev/core/fbmem.c | 82 ++++++++++++++---
drivers/video/fbdev/core/fbsysfs.c | 8 +-
include/linux/backlight.h | 22 ++---
include/linux/fb.h | 12 +--
include/linux/lcd.h | 21 ++++-
include/linux/leds.h | 6 ++
11 files changed, 205 insertions(+), 208 deletions(-)
No immediately obvious issues from the LEDs side.
Still needs reviews from Backlight and fbdev.
I looked throught the series and it's a small step, but I think it's the
right direction for where we want backlight/fbdev/drm-kms to head towards
long-term. So on the series:
Acked-by: Simona Vetter <redacted>
Cheers, Sima
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-17 08:42:25
Hi
Am 13.03.25 um 17:51 schrieb Lee Jones:
On Thu, 06 Mar 2025, Thomas Zimmermann wrote:
quoted
This series removes the remaining dependencies on fbdev from the
backlight, lcd and led subsystems. Each depends on fbdev events to
track display state. Make fbdev inform each subsystem via a dedicated
interface instead.
Patches 1 to 3 make fbdev track blank state for each display, so that
backlight code doesn't have to.
Patches 4 to 6 remove fbdev event handling from backlight code. Patches
7 and 8 remove fbdev event handling from lcd code and patches 9 and 10
do the same for led's backlight trigger.
The final patch removes the event constants from fbdev.
With the series applied, the three subsystems do no longer depend on
fbdev. It's also a clean up for fbdev. Fbdev used to send out a large
number of events. That mechanism has been deprecated for some time and
converted call to dedicated functions instead.
Testing is very welcome, as I don't have the hardware to test this
series.
v3:
- export several symbols
- static-inline declare empty placeholders
v2:
- avoid IS_REACHABLE() in source file (Lee)
- simplify several interfaces and helpers
- use lock guards
- initialize global lists and mutices
Thomas Zimmermann (11):
fbdev: Rework fb_blank()
fbdev: Track display blanking state
fbdev: Send old blank state in FB_EVENT_BLANK
backlight: Implement fbdev tracking with blank state from event
backlight: Move blank-state handling into helper
backlight: Replace fb events with a dedicated function call
backlight: lcd: Move event handling into helpers
backlight: lcd: Replace fb events with a dedicated function call
leds: backlight trigger: Move blank-state handling into helper
leds: backlight trigger: Replace fb events with a dedicated function
call
fbdev: Remove constants of unused events
drivers/leds/trigger/ledtrig-backlight.c | 48 +++++-----
drivers/video/backlight/backlight.c | 93 +++++--------------
drivers/video/backlight/lcd.c | 108 +++++++++--------------
drivers/video/fbdev/core/fb_backlight.c | 12 +++
drivers/video/fbdev/core/fb_info.c | 1 +
drivers/video/fbdev/core/fbmem.c | 82 ++++++++++++++---
drivers/video/fbdev/core/fbsysfs.c | 8 +-
include/linux/backlight.h | 22 ++---
include/linux/fb.h | 12 +--
include/linux/lcd.h | 21 ++++-
include/linux/leds.h | 6 ++
11 files changed, 205 insertions(+), 208 deletions(-)
No immediately obvious issues from the LEDs side.
Still needs reviews from Backlight and fbdev.
I'm confused. Are you not the backlight maintainer?
Best regards
Thomas
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
From: Daniel Thompson <hidden> Date: 2025-03-17 17:14:26
On Mon, Mar 17, 2025 at 09:42:11AM +0100, Thomas Zimmermann wrote:
Hi
Am 13.03.25 um 17:51 schrieb Lee Jones:
quoted
On Thu, 06 Mar 2025, Thomas Zimmermann wrote:
quoted
This series removes the remaining dependencies on fbdev from the
backlight, lcd and led subsystems. Each depends on fbdev events to
track display state. Make fbdev inform each subsystem via a dedicated
interface instead.
Patches 1 to 3 make fbdev track blank state for each display, so that
backlight code doesn't have to.
Patches 4 to 6 remove fbdev event handling from backlight code. Patches
7 and 8 remove fbdev event handling from lcd code and patches 9 and 10
do the same for led's backlight trigger.
The final patch removes the event constants from fbdev.
With the series applied, the three subsystems do no longer depend on
fbdev. It's also a clean up for fbdev. Fbdev used to send out a large
number of events. That mechanism has been deprecated for some time and
converted call to dedicated functions instead.
Testing is very welcome, as I don't have the hardware to test this
series.
v3:
- export several symbols
- static-inline declare empty placeholders
v2:
- avoid IS_REACHABLE() in source file (Lee)
- simplify several interfaces and helpers
- use lock guards
- initialize global lists and mutices
Thomas Zimmermann (11):
fbdev: Rework fb_blank()
fbdev: Track display blanking state
fbdev: Send old blank state in FB_EVENT_BLANK
backlight: Implement fbdev tracking with blank state from event
backlight: Move blank-state handling into helper
backlight: Replace fb events with a dedicated function call
backlight: lcd: Move event handling into helpers
backlight: lcd: Replace fb events with a dedicated function call
leds: backlight trigger: Move blank-state handling into helper
leds: backlight trigger: Replace fb events with a dedicated function
call
fbdev: Remove constants of unused events
drivers/leds/trigger/ledtrig-backlight.c | 48 +++++-----
drivers/video/backlight/backlight.c | 93 +++++--------------
drivers/video/backlight/lcd.c | 108 +++++++++--------------
drivers/video/fbdev/core/fb_backlight.c | 12 +++
drivers/video/fbdev/core/fb_info.c | 1 +
drivers/video/fbdev/core/fbmem.c | 82 ++++++++++++++---
drivers/video/fbdev/core/fbsysfs.c | 8 +-
include/linux/backlight.h | 22 ++---
include/linux/fb.h | 12 +--
include/linux/lcd.h | 21 ++++-
include/linux/leds.h | 6 ++
11 files changed, 205 insertions(+), 208 deletions(-)
No immediately obvious issues from the LEDs side.
Still needs reviews from Backlight and fbdev.
I'm confused. Are you not the backlight maintainer?
Lee is, yes, but this kind of comment is usually a hint that I've
been delinquent in my backlight reviews and records that he hasn't
looked at the backlight code yet ;-).
I'll get on it tomorrow!
Daniel.
From: Daniel Thompson <danielt@kernel.org> Date: 2025-03-18 09:05:55
On Thu, Mar 06, 2025 at 03:05:46PM +0100, Thomas Zimmermann wrote:
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>
Daniel.
From: Daniel Thompson <danielt@kernel.org> Date: 2025-03-18 09:07:43
On Thu, Mar 06, 2025 at 03:05:47PM +0100, Thomas Zimmermann wrote:
Move the handling of blank-state updates into a separate helper,
so that is can be called without the fbdev event. No functional
changes.
As a minor improvement over the original code, the update replaces
manual locking with a guard.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
Daniel.
From: Daniel Thompson <danielt@kernel.org> Date: 2025-03-18 09:23:47
On Thu, Mar 06, 2025 at 03:05:48PM +0100, Thomas Zimmermann wrote:
Remove support for fb events from backlight subsystem. Provide the
helper backlight_notify_blank_all() instead. Also export the existing
helper backlight_notify_blank() to update a single backlight device.
In fbdev, call either helper to inform the backlight subsystem of
changes to a display's blank state. If the framebuffer device has a
specific backlight, only update this one; otherwise update all.
v3:
- declare empty fb_bl_notify_blank() as static inline (kernel test robot)
Looks like there are still configs where we get build failure.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Other than the build issues, generally this looks great. Just a couple
of small issues below.
-/*- * fb_notifier_callback- *- * This callback gets called when something important happens inside a- * framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK- * which is reported to the driver using backlight_update_status()- * as a state change.- *- * There may be several fbdev's connected to the backlight device,- * in which case they are kept track of. A state change is only reported- * if there is a change in backlight for the specified fbdev.- */-static int fb_notifier_callback(struct notifier_block *self,- unsigned long event, void *data)+void backlight_notify_blank_all(struct device *display_dev, bool fb_on, bool prev_fb_on) { struct backlight_device *bd;- struct fb_event *evdata = data;- struct fb_info *info = evdata->info;- const int *fb_blank = evdata->data;- struct backlight_device *fb_bd = fb_bl_device(info);- bool fb_on, prev_fb_on;-- /* If we aren't interested in this event, skip it immediately ... */- if (event != FB_EVENT_BLANK)- return 0;-- bd = container_of(self, struct backlight_device, fb_notif);-- if (fb_bd && fb_bd != bd)- return 0;-- fb_on = fb_blank[0] == FB_BLANK_UNBLANK;- prev_fb_on = fb_blank[1] == FB_BLANK_UNBLANK;-- backlight_notify_blank(bd, info->device, fb_on, prev_fb_on);-- return 0;-}--static int backlight_register_fb(struct backlight_device *bd)-{- memset(&bd->fb_notif, 0, sizeof(bd->fb_notif));- bd->fb_notif.notifier_call = fb_notifier_callback;- return fb_register_client(&bd->fb_notif);-}+ guard(mutex)(&backlight_dev_list_mutex);-static void backlight_unregister_fb(struct backlight_device *bd)-{- fb_unregister_client(&bd->fb_notif);-}-#else-static inline int backlight_register_fb(struct backlight_device *bd)-{- return 0;+ list_for_each_entry(bd, &backlight_dev_list, entry)+ backlight_notify_blank(bd, display_dev, fb_on, prev_fb_on); }--static inline void backlight_unregister_fb(struct backlight_device *bd)-{-}-#endif /* CONFIG_FB_CORE */+EXPORT_SYMBOL(backlight_notify_blank_all);
From: Daniel Thompson <danielt@kernel.org> Date: 2025-03-18 09:25:21
On Thu, Mar 06, 2025 at 03:05:49PM +0100, Thomas Zimmermann wrote:
Move the handling of display updates to separate helper functions.
There is code for handling fbdev blank events and fbdev mode changes.
The code currently runs from fbdev event notifiers, which will be
replaced.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
Daniel.
From: Daniel Thompson <danielt@kernel.org> Date: 2025-03-18 09:41:12
On Thu, Mar 06, 2025 at 03:05:50PM +0100, Thomas Zimmermann wrote:
Remove support for fb events from the lcd subsystem. Provide the
helper lcd_notify_blank_all() instead. In fbdev, call
lcd_notify_blank_all() to inform the lcd subsystem of changes
to a display's blank state.
Fbdev maintains a list of all installed notifiers. Instead of fbdev
notifiers, maintain an internal list of lcd devices.
I don't love the LCD devices list, however I can see the list of notifiers
had the same semantic effect (only less explicit) so I can live with
it ;-).
v3:
- export lcd_notify_mode_change_all() (kernel test robot)
v2:
- maintain global list of lcd devices
- avoid IS_REACHABLE() in source file
- use lock guards
- initialize lcd list and list mutex
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Happy with these changes, but have the same EXPORT_SYMBOL_GPL()
questions I did with the backlight code.
Daniel.
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-21 08:13:14
Hi
Am 18.03.25 um 10:23 schrieb Daniel Thompson:
On Thu, Mar 06, 2025 at 03:05:48PM +0100, Thomas Zimmermann wrote:
quoted
Remove support for fb events from backlight subsystem. Provide the
helper backlight_notify_blank_all() instead. Also export the existing
helper backlight_notify_blank() to update a single backlight device.
In fbdev, call either helper to inform the backlight subsystem of
changes to a display's blank state. If the framebuffer device has a
specific backlight, only update this one; otherwise update all.
v3:
- declare empty fb_bl_notify_blank() as static inline (kernel test robot)
Looks like there are still configs where we get build failure.
quoted
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Other than the build issues, generally this looks great. Just a couple
of small issues below.
The other symbols in this source file are exported with EXPORT_SYMBOL().
Best regards
Thomas
quoted
-/*- * fb_notifier_callback- *- * This callback gets called when something important happens inside a- * framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK- * which is reported to the driver using backlight_update_status()- * as a state change.- *- * There may be several fbdev's connected to the backlight device,- * in which case they are kept track of. A state change is only reported- * if there is a change in backlight for the specified fbdev.- */-static int fb_notifier_callback(struct notifier_block *self,- unsigned long event, void *data)+void backlight_notify_blank_all(struct device *display_dev, bool fb_on, bool prev_fb_on) { struct backlight_device *bd;- struct fb_event *evdata = data;- struct fb_info *info = evdata->info;- const int *fb_blank = evdata->data;- struct backlight_device *fb_bd = fb_bl_device(info);- bool fb_on, prev_fb_on;-- /* If we aren't interested in this event, skip it immediately ... */- if (event != FB_EVENT_BLANK)- return 0;-- bd = container_of(self, struct backlight_device, fb_notif);-- if (fb_bd && fb_bd != bd)- return 0;-- fb_on = fb_blank[0] == FB_BLANK_UNBLANK;- prev_fb_on = fb_blank[1] == FB_BLANK_UNBLANK;-- backlight_notify_blank(bd, info->device, fb_on, prev_fb_on);-- return 0;-}--static int backlight_register_fb(struct backlight_device *bd)-{- memset(&bd->fb_notif, 0, sizeof(bd->fb_notif));- bd->fb_notif.notifier_call = fb_notifier_callback;- return fb_register_client(&bd->fb_notif);-}+ guard(mutex)(&backlight_dev_list_mutex);-static void backlight_unregister_fb(struct backlight_device *bd)-{- fb_unregister_client(&bd->fb_notif);-}-#else-static inline int backlight_register_fb(struct backlight_device *bd)-{- return 0;+ list_for_each_entry(bd, &backlight_dev_list, entry)+ backlight_notify_blank(bd, display_dev, fb_on, prev_fb_on); }--static inline void backlight_unregister_fb(struct backlight_device *bd)-{-}-#endif /* CONFIG_FB_CORE */+EXPORT_SYMBOL(backlight_notify_blank_all);
Same here.
Daniel.
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
From: Thomas Zimmermann <tzimmermann@suse.de> Date: 2025-03-21 08:16:24
Hi
Am 18.03.25 um 10:40 schrieb Daniel Thompson:
On Thu, Mar 06, 2025 at 03:05:50PM +0100, Thomas Zimmermann wrote:
quoted
Remove support for fb events from the lcd subsystem. Provide the
helper lcd_notify_blank_all() instead. In fbdev, call
lcd_notify_blank_all() to inform the lcd subsystem of changes
to a display's blank state.
Fbdev maintains a list of all installed notifiers. Instead of fbdev
notifiers, maintain an internal list of lcd devices.
I don't love the LCD devices list, however I can see the list of notifiers
had the same semantic effect (only less explicit) so I can live with
it ;-).
quoted
v3:
- export lcd_notify_mode_change_all() (kernel test robot)
v2:
- maintain global list of lcd devices
- avoid IS_REACHABLE() in source file
- use lock guards
- initialize lcd list and list mutex
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Happy with these changes, but have the same EXPORT_SYMBOL_GPL()
questions I did with the backlight code.
As in backlight.c, all existing symbols are exported with EXPORT_SYMBOL(). I simply used what was already there.
Best regards
Thomas
Daniel.
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)