From: Thomas Zimmermann <tzimmermann@suse.de>
To: lee@kernel.org, pavel@ucw.cz, danielt@kernel.org,
jingoohan1@gmail.com, deller@gmx.de, simona@ffwll.ch
Cc: linux-leds@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-fbdev@vger.kernel.org,
Thomas Zimmermann <tzimmermann@suse.de>,
Simona Vetter <simona.vetter@ffwll.ch>
Subject: [PATCH v4 04/11] backlight: Implement fbdev tracking with blank state from event
Date: Fri, 21 Mar 2025 10:53:57 +0100 [thread overview]
Message-ID: <20250321095517.313713-5-tzimmermann@suse.de> (raw)
In-Reply-To: <20250321095517.313713-1-tzimmermann@suse.de>
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>
---
drivers/video/backlight/backlight.c | 14 +++++++-------
include/linux/backlight.h | 10 +---------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index f699e5827ccb..bb01f57c4683 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -98,9 +98,9 @@ static int fb_notifier_callback(struct notifier_block *self,
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);
- int node = info->node;
- int fb_blank = 0;
+ bool fb_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)
goto out;
- 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);
}
- } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) {
- bd->fb_bl_on[node] = false;
+ } else if (!fb_on && prev_fb_on && bd->use_count) {
if (!(--bd->use_count)) {
bd->props.state |= BL_CORE_FBBLANK;
backlight_update_status(bd);
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index f5652e5a9060..03723a5478f8 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -294,15 +294,7 @@ struct backlight_device {
struct device dev;
/**
- * @fb_bl_on: The state of individual fbdev's.
- *
- * Multiple fbdev's may share one backlight device. The fb_bl_on
- * records the state of the individual fbdev.
- */
- bool fb_bl_on[FB_MAX];
-
- /**
- * @use_count: The number of uses of fb_bl_on.
+ * @use_count: The number of unblanked displays.
*/
int use_count;
};
--
2.48.1
next prev parent reply other threads:[~2025-03-21 9:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 9:53 [PATCH v4 00/11] backlight, lcd, led: Remove fbdev dependencies Thomas Zimmermann
2025-03-21 9:53 ` [PATCH v4 01/11] fbdev: Rework fb_blank() Thomas Zimmermann
2025-03-21 9:53 ` [PATCH v4 02/11] fbdev: Track display blanking state Thomas Zimmermann
2025-03-21 9:53 ` [PATCH v4 03/11] fbdev: Send old blank state in FB_EVENT_BLANK Thomas Zimmermann
2025-03-21 9:53 ` Thomas Zimmermann [this message]
2025-03-21 9:53 ` [PATCH v4 05/11] backlight: Move blank-state handling into helper Thomas Zimmermann
2025-03-21 9:53 ` [PATCH v4 06/11] backlight: Replace fb events with a dedicated function call Thomas Zimmermann
2025-03-21 11:26 ` Daniel Thompson
2025-03-21 9:54 ` [PATCH v4 07/11] backlight: lcd: Move event handling into helpers Thomas Zimmermann
2025-03-21 9:54 ` [PATCH v4 08/11] backlight: lcd: Replace fb events with a dedicated function call Thomas Zimmermann
2025-03-21 11:27 ` Daniel Thompson
2025-03-24 7:43 ` Thomas Zimmermann
2025-03-28 8:42 ` Lee Jones
2025-03-28 13:18 ` Thomas Zimmermann
2025-03-21 9:54 ` [PATCH v4 09/11] leds: backlight trigger: Move blank-state handling into helper Thomas Zimmermann
2025-03-21 9:54 ` [PATCH v4 10/11] leds: backlight trigger: Replace fb events with a dedicated function call Thomas Zimmermann
2025-03-21 9:54 ` [PATCH v4 11/11] fbdev: Remove constants of unused events Thomas Zimmermann
2025-04-10 9:39 ` [PATCH v4 00/11] backlight, lcd, led: Remove fbdev dependencies Lee Jones
2025-04-10 9:41 ` Lee Jones
2025-04-15 17:27 ` [GIT PULL] Immutable branch between Backlight, fbdev and LEDs for the v6.16 merge window Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250321095517.313713-5-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=danielt@kernel.org \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=lee@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=simona.vetter@ffwll.ch \
--cc=simona@ffwll.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).