Skip to content

Commit 7e3711e

Browse files
Thomas Zimmermannlag-linaro
authored andcommitted
fbdev: Track display blanking state
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> Link: https://lore.kernel.org/r/20250321095517.313713-3-tzimmermann@suse.de Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 93e41f9 commit 7e3711e

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

drivers/video/fbdev/core/fb_info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev)
4242

4343
info->device = dev;
4444
info->fbcon_rotate_hint = -1;
45+
info->blank = FB_BLANK_UNBLANK;
4546

4647
#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
4748
mutex_init(&info->bl_curve_mutex);

drivers/video/fbdev/core/fbmem.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ EXPORT_SYMBOL(fb_set_var);
341341

342342
int fb_blank(struct fb_info *info, int blank)
343343
{
344+
int old_blank = info->blank;
344345
struct fb_event event;
345346
int ret;
346347

@@ -353,13 +354,19 @@ int fb_blank(struct fb_info *info, int blank)
353354
event.info = info;
354355
event.data = &blank;
355356

357+
info->blank = blank;
358+
356359
ret = info->fbops->fb_blank(blank, info);
357360
if (ret)
358-
return ret;
361+
goto err;
359362

360363
fb_notifier_call_chain(FB_EVENT_BLANK, &event);
361364

362365
return 0;
366+
367+
err:
368+
info->blank = old_blank;
369+
return ret;
363370
}
364371
EXPORT_SYMBOL(fb_blank);
365372

@@ -408,6 +415,14 @@ static int do_register_framebuffer(struct fb_info *fb_info)
408415
mutex_init(&fb_info->lock);
409416
mutex_init(&fb_info->mm_lock);
410417

418+
/*
419+
* With an fb_blank callback present, we assume that the
420+
* display is blank, so that fb_blank() enables it on the
421+
* first modeset.
422+
*/
423+
if (fb_info->fbops->fb_blank)
424+
fb_info->blank = FB_BLANK_POWERDOWN;
425+
411426
fb_device_create(fb_info);
412427

413428
if (fb_info->pixmap.addr == NULL) {

drivers/video/fbdev/core/fbsysfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ static ssize_t store_blank(struct device *device,
242242
return count;
243243
}
244244

245-
static ssize_t show_blank(struct device *device,
246-
struct device_attribute *attr, char *buf)
245+
static ssize_t show_blank(struct device *device, struct device_attribute *attr, char *buf)
247246
{
248-
// struct fb_info *fb_info = dev_get_drvdata(device);
249-
return 0;
247+
struct fb_info *fb_info = dev_get_drvdata(device);
248+
249+
return sysfs_emit(buf, "%d\n", fb_info->blank);
250250
}
251251

252252
static ssize_t store_console(struct device *device,

include/linux/fb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ struct fb_info {
472472
struct list_head modelist; /* mode list */
473473
struct fb_videomode *mode; /* current mode */
474474

475+
int blank; /* current blanking; see FB_BLANK_ constants */
476+
475477
#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
476478
/* assigned backlight device */
477479
/* set before framebuffer registration,

0 commit comments

Comments
 (0)