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 02/11] fbdev: Track display blanking state
Date: Fri, 21 Mar 2025 10:53:55 +0100 [thread overview]
Message-ID: <20250321095517.313713-3-tzimmermann@suse.de> (raw)
In-Reply-To: <20250321095517.313713-1-tzimmermann@suse.de>
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>
Acked-by: Simona Vetter <simona.vetter@ffwll.ch>
---
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(-)
diff --git a/drivers/video/fbdev/core/fb_info.c b/drivers/video/fbdev/core/fb_info.c
index 4847ebe50d7d..52f9bd2c5417 100644
--- a/drivers/video/fbdev/core/fb_info.c
+++ b/drivers/video/fbdev/core/fb_info.c
@@ -42,6 +42,7 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev)
info->device = dev;
info->fbcon_rotate_hint = -1;
+ info->blank = FB_BLANK_UNBLANK;
#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
mutex_init(&info->bl_curve_mutex);
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index 39e2b81473ad..5d1529d300b7 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -341,6 +341,7 @@ EXPORT_SYMBOL(fb_set_var);
int fb_blank(struct fb_info *info, int blank)
{
+ int old_blank = info->blank;
struct fb_event event;
int ret;
@@ -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)
- return ret;
+ goto err;
fb_notifier_call_chain(FB_EVENT_BLANK, &event);
return 0;
+
+err:
+ info->blank = old_blank;
+ return ret;
}
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);
+ /*
+ * With an fb_blank callback present, we assume that the
+ * display is blank, so that fb_blank() enables it on the
+ * first modeset.
+ */
+ if (fb_info->fbops->fb_blank)
+ fb_info->blank = FB_BLANK_POWERDOWN;
+
fb_device_create(fb_info);
if (fb_info->pixmap.addr == NULL) {
diff --git a/drivers/video/fbdev/core/fbsysfs.c b/drivers/video/fbdev/core/fbsysfs.c
index 1b3c9958ef5c..e337660bce46 100644
--- a/drivers/video/fbdev/core/fbsysfs.c
+++ b/drivers/video/fbdev/core/fbsysfs.c
@@ -242,11 +242,11 @@ static ssize_t store_blank(struct device *device,
return count;
}
-static ssize_t show_blank(struct device *device,
- struct device_attribute *attr, char *buf)
+static ssize_t show_blank(struct device *device, struct device_attribute *attr, char *buf)
{
-// struct fb_info *fb_info = dev_get_drvdata(device);
- return 0;
+ struct fb_info *fb_info = dev_get_drvdata(device);
+
+ return sysfs_emit(buf, "%d\n", fb_info->blank);
}
static ssize_t store_console(struct device *device,
diff --git a/include/linux/fb.h b/include/linux/fb.h
index 5ba187e08cf7..f41d3334ac23 100644
--- a/include/linux/fb.h
+++ b/include/linux/fb.h
@@ -471,6 +471,8 @@ struct fb_info {
struct list_head modelist; /* mode list */
struct fb_videomode *mode; /* current mode */
+ int blank; /* current blanking; see FB_BLANK_ constants */
+
#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
/* assigned backlight device */
/* set before framebuffer registration,
--
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 ` Thomas Zimmermann [this message]
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 ` [PATCH v4 04/11] backlight: Implement fbdev tracking with blank state from event Thomas Zimmermann
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-3-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