fbdev: Internalize fbcon
Subsystems (7)
Thomas Zimmermann
maintainerPATCH 1/4 fbdev: Wrap user-invoked calls to fb_set_var() in helper
In reply to Thomas ZimmermannHandle fbcon during display updates in fb_set_var_from_user(). Check with fbcon if the mode change is possible, update hardware state and finally update fbcon. Update all callers.
Only the FBIOPUT_VSCREENINFO ioctl currently does all steps. Other mode-changes callers in sysfs and driver code are missing fbcon-related steps.
With the new helper, ps3fb and sh_mobile_lcdcfb no longer maintain fbcon state themselves.
--- drivers/video/fbdev/core/fb_chrdev.c | 6 +----- drivers/video/fbdev/core/fbcon.c | 2 -- drivers/video/fbdev/core/fbmem.c | 13 +++++++++++++ drivers/video/fbdev/core/fbsysfs.c | 4 +--- drivers/video/fbdev/ps3fb.c | 5 +---- drivers/video/fbdev/sh_mobile_lcdcfb.c | 5 +---- include/linux/fb.h | 2 ++ 7 files changed, 19 insertions(+), 18 deletions(-)
drivers/video/fbdev/core/fb_chrdev.c +1 -5
@@ -85,11 +85,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, var.activate &= ~FB_ACTIVATE_KD_TEXT ;console_lock ();lock_fb_info (info); - ret =fbcon_modechange_possible (info, &var); -if (!ret) - ret =fb_set_var (info, &var); -if (!ret) -fbcon_update_vcs (info, var.activate &FB_ACTIVATE_ALL ); + ret =fb_set_var_from_user (info, &var);unlock_fb_info (info);console_unlock ();if (!ret &©_to_user (argp, &var,sizeof (var)))
drivers/video/fbdev/core/fbcon.c +0 -2
@@ -2699,7 +2699,6 @@ void fbcon_update_vcs(struct fb_info *info, bool all)else fbcon_modechanged (info); } -EXPORT_SYMBOL (fbcon_update_vcs);/* let fbcon check if it supports a new screen resolution */ int fbcon_modechange_possible (struct fb_info *info,struct fb_var_screeninfo *var)
@@ -2727,7 +2726,6 @@ int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo *vareturn 0 ; } -EXPORT_SYMBOL_GPL (fbcon_modechange_possible);int fbcon_mode_deleted (struct fb_info *info,struct fb_videomode *mode)
drivers/video/fbdev/core/fbmem.c +13 -0
@@ -346,6 +346,19 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) }EXPORT_SYMBOL (fb_set_var); +int fb_set_var_from_user (struct fb_info *info,struct fb_var_screeninfo *var) +{ +int ret =fbcon_modechange_possible (info, var); + +if (!ret) + ret =fb_set_var (info, var); +if (!ret) +fbcon_update_vcs (info, var->activate &FB_ACTIVATE_ALL ); + +return ret; +} +EXPORT_SYMBOL (fb_set_var_from_user); +static void fb_lcd_notify_blank (struct fb_info *info) {int power;
drivers/video/fbdev/core/fbsysfs.c +1 -3
@@ -19,9 +19,7 @@ static int activate(struct fb_info *fb_info, struct fb_var_screeninfo *var) var->activate |=FB_ACTIVATE_FORCE ;console_lock ();lock_fb_info (fb_info); - err =fb_set_var (fb_info, var); -if (!err) -fbcon_update_vcs (fb_info, var->activate &FB_ACTIVATE_ALL ); + err =fb_set_var_from_user (fb_info, var);unlock_fb_info (fb_info);console_unlock ();if (err)
drivers/video/fbdev/ps3fb.c +1 -4
@@ -29,7 +29,6 @@#include <linux/freezer.h> #include <linux/uaccess.h> #include <linux/fb.h> -#include <linux/fbcon.h> #include <linux/init.h> #include <asm/cell-regs.h>
@@ -830,9 +829,7 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd,/* Force, in case only special bits changed */ var.activate |=FB_ACTIVATE_FORCE ; par->new_mode_id = val; - retval =fb_set_var (info, &var); -if (!retval) -fbcon_update_vcs (info, var.activate &FB_ACTIVATE_ALL ); + retval =fb_set_var_from_user (info, &var);console_unlock (); }break ;
drivers/video/fbdev/sh_mobile_lcdcfb.c +1 -4
@@ -15,7 +15,6 @@#include <linux/ctype.h> #include <linux/dma-mapping.h> #include <linux/delay.h> -#include <linux/fbcon.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/ioctl.h>
@@ -1768,11 +1767,9 @@ static void sh_mobile_fb_reconfig(struct fb_info *info) var.height = ch->display.height; var.activate =FB_ACTIVATE_NOW ; -if (fb_set_var (info, &var) <0 ) +if (fb_set_var_from_user (info, &var) <0 )/* Couldn't reconfigure, hopefully, can continue as before */ return ; - -fbcon_update_vcs (info, true); }/*
include/linux/fb.h +2 -0
@@ -533,6 +533,8 @@ extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var);extern int fb_pan_display (struct fb_info *info,struct fb_var_screeninfo *var);extern int fb_blank (struct fb_info *info,int blank); +int fb_set_var_from_user (struct fb_info *info,struct fb_var_screeninfo *var); +/* * Helpers for framebuffers in I/O memory */
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainercover fbdev: Internalize fbcon
Turn fbcon into an internal client of fbdev. Manage all interactions with graphics drivers within fbdev. Add helpers for these tasks and convert drivers.
Fbdev's PS3 and SH-Mobile drivers update fbcon as part of user-invoked mode changes. Call the new helpers, which also fix inconsistencies among the various code paths.
Vga-switcheroo remaps the fbcon terminals when switching physical outputs. For now, hide this in another helper. The call will later move into DRM's fbdev emulation.
When all refactoring in place, fbdev manages fbcon interactions by itself. Remove the public interfaces.
Thomas Zimmermann (4):
fbdev: Wrap user-invoked calls to fb_set_var() in helper
fbdev: Wrap user-invoked calls to fb_blank() in helper
fbdev: Wrap fbcon updates from vga-switcheroo in helper
fbdev: Do not export fbcon from fbdev
MAINTAINERS | 1 - drivers/gpu/vga/vga_switcheroo.c | 6 +-- drivers/video/fbdev/core/fb_chrdev.c | 12 ++---- drivers/video/fbdev/core/fb_internal.h | 1 + drivers/video/fbdev/core/fbcon.c | 3 -- drivers/video/fbdev/core/fbcon.h | 50 +++++++++++++++++++++++ drivers/video/fbdev/core/fbmem.c | 35 +++++++++++++++- drivers/video/fbdev/core/fbsysfs.c | 9 +---- drivers/video/fbdev/ps3fb.c | 5 +-- drivers/video/fbdev/sh_mobile_lcdcfb.c | 5 +-- include/linux/fb.h | 3 ++ include/linux/fbcon.h | 55 -------------------------- 12 files changed, 98 insertions(+), 87 deletions(-) delete mode 100644 include/linux/fbcon.h
base-commit: 121c16f9d8c56ea07263df84ab971cc10870fe88
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerPATCH 3/4 fbdev: Wrap fbcon updates from vga-switcheroo in helper
Handle console remapping in fbcon in fb_switch_output(). Vga-switcheroo invokes this functionality before switching physical outputs to a new graphics device. Open-coding fbcon state in vga-switcheroo exposed fbdev implementation details.
Vga-switcheroo is used for switching physical outputs among graphics hardware. This functionality is only supported by DRM drivers. A later update will further move fb_switch_output() into DRM's fbdev emulation; thus fully decoupling vga-switcheroo from fbdev.
--- drivers/gpu/vga/vga_switcheroo.c | 6 +++--- drivers/video/fbdev/core/fbmem.c | 10 ++++++++++ include/linux/fb.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-)
drivers/gpu/vga/vga_switcheroo.c +3 -3
@@ -31,11 +31,9 @@#define pr_fmt (fmt) "vga_switcheroo: " fmt#include <linux/apple-gmux.h> -#include <linux/console.h> #include <linux/debugfs.h> #include <linux/fb.h> #include <linux/fs.h> -#include <linux/fbcon.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/pm_domain.h>
@@ -735,8 +733,10 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client)if (!active->driver_power_control)set_audio_state (active->id,VGA_SWITCHEROO_OFF ); +#if CONFIG_FB if (new_client->fb_info) -fbcon_remap_all (new_client->fb_info); +fb_switch_outputs (new_client->fb_info); +#endif mutex_lock (&vgasr_priv.mux_hw_lock); ret = vgasr_priv.handler->switchto (new_client->id);
drivers/video/fbdev/core/fbmem.c +10 -0
@@ -684,6 +684,16 @@ void fb_set_suspend(struct fb_info *info, int state) }EXPORT_SYMBOL (fb_set_suspend); +/** +* fb_switch_outputs - framebuffer got the outputs from vga-switcheroo +* @info: framebuffer +*/ +void fb_switch_outputs (struct fb_info *info) +{ +fbcon_remap_all (info); +} +EXPORT_SYMBOL (fb_switch_outputs); +static int __init fbmem_init (void ) {int ret;
include/linux/fb.h +1 -0
@@ -608,6 +608,7 @@ void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, const u8 *src, u32 idx, u32 h u32 shift_high, u32 shift_low, u32 mod);void fb_pad_aligned_buffer (u8 *dst,u32 d_pitch,const u8 *src,u32 s_pitch,u32 height);extern void fb_set_suspend (struct fb_info *info,int state); +extern void fb_switch_outputs (struct fb_info *info);extern int fb_get_color_depth (struct fb_var_screeninfo *var,struct fb_fix_screeninfo *fix);extern int fb_get_options (const char *name,char **option);
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerPATCH 2/4 fbdev: Wrap user-invoked calls to fb_blank() in helper
In reply to Thomas ZimmermannHandle fbcon during blanking in fb_blank_from_user(). First blank the hardware, then blank fbcon. Same for unblanking. Update all callers and resolve the duplicated logic.
With the new helper, fbdev's sysfb code no longer maintains fbcon state by itself.
--- drivers/video/fbdev/core/fb_chrdev.c | 4 +--- drivers/video/fbdev/core/fb_internal.h | 1 + drivers/video/fbdev/core/fbmem.c | 10 ++++++++++ drivers/video/fbdev/core/fbsysfs.c | 5 +---- 4 files changed, 13 insertions(+), 7 deletions(-)
drivers/video/fbdev/core/fb_chrdev.c +1 -3
@@ -138,9 +138,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,return -EINVAL ;console_lock ();lock_fb_info (info); - ret =fb_blank (info, arg); -/* might again call into fb_blank */ -fbcon_fb_blanked (info, arg); + ret =fb_blank_from_user (info, arg);unlock_fb_info (info);console_unlock ();break ;
drivers/video/fbdev/core/fb_internal.h +1 -0
@@ -44,6 +44,7 @@ extern struct fb_info *registered_fb[FB_MAX];extern int num_registered_fb;struct fb_info *get_fb_info (unsigned int idx);void put_fb_info (struct fb_info *fb_info); +int fb_blank_from_user (struct fb_info *info,int blank);/* fb_procfs.c */ #if defined(CONFIG_FB_DEVICE )
drivers/video/fbdev/core/fbmem.c +10 -0
@@ -422,6 +422,16 @@ int fb_blank(struct fb_info *info, int blank) }EXPORT_SYMBOL (fb_blank); +int fb_blank_from_user (struct fb_info *info,int blank) +{ +int ret =fb_blank (info, blank); + +/* might again call into fb_blank */ +fbcon_fb_blanked (info, blank); + +return ret; +} +static int fb_check_foreignness (struct fb_info *fi) {const bool foreign_endian = fi->flags &FBINFO_FOREIGN_ENDIAN ;
drivers/video/fbdev/core/fbsysfs.c +1 -4
@@ -7,7 +7,6 @@#include <linux/console.h> #include <linux/fb.h> -#include <linux/fbcon.h> #include <linux/major.h> #include "fb_internal.h"
@@ -229,9 +228,7 @@ static ssize_t store_blank(struct device *device, arg =simple_strtoul (buf, &last,0 );console_lock (); - err =fb_blank (fb_info, arg); -/* might again call into fb_blank */ -fbcon_fb_blanked (fb_info, arg); + err =fb_blank_from_user (fb_info, arg);console_unlock ();if (err <0 )return err;
Signature · 1 line
2.54.0
Thomas Zimmermann
maintainerPATCH 4/4 fbdev: Do not export fbcon from fbdev
In reply to Thomas ZimmermannThere are no callers of fbcon outside fbdev. Move the declarations into the internal header.
--- MAINTAINERS | 1 - drivers/video/fbdev/core/fb_chrdev.c | 2 +- drivers/video/fbdev/core/fbcon.c | 1 - drivers/video/fbdev/core/fbcon.h | 50 +++++++++++++++++++++++++ drivers/video/fbdev/core/fbmem.c | 2 +- include/linux/fbcon.h | 55 ---------------------------- 6 files changed, 52 insertions(+), 59 deletions(-) delete mode 100644 include/linux/fbcon.h
MAINTAINERS +0 -1
@@ -10141,7 +10141,6 @@ F: drivers/video/fbdev/core/fbcon_rotate.h F: drivers/video/fbdev/core/fbcon_ud.c F: drivers/video/fbdev/core/softcursor.c F: drivers/video/fbdev/core/tileblit.c -F: include/linux/fbcon.h F: include/linux/font.h F: lib/fonts/
drivers/video/fbdev/core/fb_chrdev.c +1 -1
@@ -3,10 +3,10 @@#include <linux/compat.h> #include <linux/console.h> #include <linux/fb.h> -#include <linux/fbcon.h> #include <linux/major.h> #include "fb_internal.h" +#include "fbcon.h" /* * We hold a reference to the fb_info in file->private_data,
drivers/video/fbdev/core/fbcon.c +0 -1
@@ -70,7 +70,6 @@#include <linux/printk.h> #include <linux/slab.h> #include <linux/fb.h> -#include <linux/fbcon.h> #include <linux/vt_kern.h> #include <linux/selection.h> #include <linux/font.h>
drivers/video/fbdev/core/fbcon.h +50 -0
66 lines not on this page · raw message
drivers/video/fbdev/core/fbmem.c +1 -1
@@ -14,13 +14,13 @@#include <linux/console.h> #include <linux/export.h> #include <linux/fb.h> -#include <linux/fbcon.h> #include <linux/lcd.h> #include <linux/leds.h> #include <video/nomodeset.h> #include "fb_internal.h" +#include "fbcon.h" /* * Frame buffer device initialization and setup routines
include/linux/fbcon.h deleted +0 -55
55 lines not on this page · raw message
Signature · 1 line
2.54.0
Helge Deller
maintainerRe: [PATCH 3/4] fbdev: Wrap fbcon updates from vga-switcheroo in helper
In reply to Thomas ZimmermannQuoted 34 lines · Thomas Zimmermann
Handle console remapping in fbcon in
fb_switch_output(). Vga-switcheroo invokes this functionality before switching physical outputs to a new graphics device. Open-coding fbcon state in vga-switcheroo exposed fbdev implementation details.Vga-switcheroo is used for switching physical outputs among graphics hardware. This functionality is only supported by DRM drivers. A later update will further move
fb_switch_output()into DRM's fbdev emulation; thus fully decoupling vga-switcheroo from fbdev.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/vga/vga_switcheroo.c | 6 +++--- drivers/video/fbdev/core/fbmem.c | 10 ++++++++++ include/linux/fb.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-)drivers/gpu/vga/vga_switcheroo.c +0
-2@@ -31,11 +31,9 @@#define pr_fmt (fmt) "vga_switcheroo: " fmt#include <linux/apple-gmux.h> -#include <linux/console.h> #include <linux/debugfs.h> #include <linux/fb.h> #include <linux/fs.h> -#include <linux/fbcon.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/pm_domain.h>
drivers/gpu/vga/vga_switcheroo.c static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) · line 736
Quoted 4 lines
drivers/gpu/vga/vga_switcheroo.c +1
-0@@ -735,8 +733,10 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client)if (!active->driver_power_control)set_audio_state (active->id,VGA_SWITCHEROO_OFF ); +#if CONFIG_FB
I think this should be
#ifdef CONFIG_FB
Helge
Helge Deller
maintainerRe: [PATCH 1/4] fbdev: Wrap user-invoked calls to fb_set_var() in helper
In reply to Thomas ZimmermannQuoted 28 lines · Thomas Zimmermann
Handle fbcon during display updates in
fb_set_var_from_user(). Check with fbcon if the mode change is possible, update hardware state and finally update fbcon. Update all callers.Only the
FBIOPUT_VSCREENINFOioctl currently does all steps. Other mode-changes callers in sysfs and driver code are missing fbcon-related steps.With the new helper, ps3fb and
sh_mobile_lcdcfbno longer maintain fbcon state themselves.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/video/fbdev/core/fb_chrdev.c | 6 +----- drivers/video/fbdev/core/fbcon.c | 2 -- drivers/video/fbdev/core/fbmem.c | 13 +++++++++++++ drivers/video/fbdev/core/fbsysfs.c | 4 +--- drivers/video/fbdev/ps3fb.c | 5 +---- drivers/video/fbdev/sh_mobile_lcdcfb.c | 5 +---- include/linux/fb.h | 2 ++ 7 files changed, 19 insertions(+), 18 deletions(-)...
include/linux/fb.h +0
-0
include/linux/fb.h extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var); · line 537
Quoted 5 lines
include/linux/fb.h +2
-0@@ -533,6 +533,8 @@ extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var);extern int fb_pan_display (struct fb_info *info,struct fb_var_screeninfo *var);extern int fb_blank (struct fb_info *info,int blank); +int fb_set_var_from_user (struct fb_info *info,struct fb_var_screeninfo *var); +
"extern" int fb_set_var_from_user(...) ?
Other than that the series is a nice cleanup!
Thanks!
Helge
Christophe Leroy (CS GROUP)
reviewerRe: [PATCH 1/4] fbdev: Wrap user-invoked calls to fb_set_var() in helper
Le 20/05/2026 à 20:51, Helge Deller a écrit :
Quoted 23 lines · Thomas Zimmermann
Quoted 22 lines
Handle fbcon during display updates in
fb_set_var_from_user(). Check with fbcon if the mode change is possible, update hardware state and finally update fbcon. Update all callers.Only the
FBIOPUT_VSCREENINFOioctl currently does all steps. Other mode-changes callers in sysfs and driver code are missing fbcon-related steps.With the new helper, ps3fb and
sh_mobile_lcdcfbno longer maintain fbcon state themselves.Signed-off-by Thomas Zimmermann <[email protected]>---
drivers/video/fbdev/core/fb_chrdev.c | 6 +----- drivers/video/fbdev/core/fbcon.c | 2 -- drivers/video/fbdev/core/fbmem.c | 13 +++++++++++++ drivers/video/fbdev/core/fbsysfs.c | 4 +--- drivers/video/fbdev/ps3fb.c | 5 +----drivers/video/fbdev/sh_mobile_lcdcfb.c| 5 +---- include/linux/fb.h | 2 ++7 files changed, 19 insertions(+), 18 deletions(-)
Quoted 14 lines
include/linux/fb.h extern int fb_set_var(struct fb_info *info, struct · line 538
Quoted 12 lines
...
include/linux/fb.h +2
-0@@ -533,6 +533,8 @@ extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var); extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var); extern int fb_blank(struct fb_info *info, int blank); +int fb_set_var_from_user (struct fb_info *info,struct fb_var_screeninfo *var); +"extern" int
fb_set_var_from_user(...)?
No, 'extern' is pointless for function prototypes and 'checkpatch --strict' will complain about it.
See following link, search for extern : https://docs.kernel.org/dev-tools/checkpatch.html
Quoted 5 lines
Other than that the series is a nice cleanup!
Thanks!
Helge
Thomas Zimmermann
maintainerRe: [PATCH 1/4] fbdev: Wrap user-invoked calls to fb_set_var() in helper
In reply to Helge DellerHi
Am 20.05.26 um 20:51 schrieb Helge Deller:
Quoted 23 lines · Thomas Zimmermann
Quoted 22 lines
Handle fbcon during display updates in
fb_set_var_from_user(). Check with fbcon if the mode change is possible, update hardware state and finally update fbcon. Update all callers.Only the
FBIOPUT_VSCREENINFOioctl currently does all steps. Other mode-changes callers in sysfs and driver code are missing fbcon-related steps.With the new helper, ps3fb and
sh_mobile_lcdcfbno longer maintain fbcon state themselves.Signed-off-by Thomas Zimmermann <[email protected]>---
drivers/video/fbdev/core/fb_chrdev.c | 6 +----- drivers/video/fbdev/core/fbcon.c | 2 -- drivers/video/fbdev/core/fbmem.c | 13 +++++++++++++ drivers/video/fbdev/core/fbsysfs.c | 4 +--- drivers/video/fbdev/ps3fb.c | 5 +----drivers/video/fbdev/sh_mobile_lcdcfb.c| 5 +---- include/linux/fb.h | 2 ++7 files changed, 19 insertions(+), 18 deletions(-)
Quoted 13 lines
include/linux/fb.h extern int fb_set_var(struct fb_info *info, · line 537
Quoted 11 lines
...
include/linux/fb.h +1
-0@@ -533,6 +533,8 @@ extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var); extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var); extern int fb_blank(struct fb_info *info, int blank); +int fb_set_var_from_user(struct fb_info *info, struct fb_var_screeninfo *var); +"extern" int
fb_set_var_from_user(...)?
As Christophe ointed out, not having extern is correct. I think, if anything, we should remove the existing externs from the headers.
Quoted 2 lines
Other than that the series is a nice cleanup!
Thanks. I'll send you an updated series with the #ifdef fix for patch 3. Sending just fixup patches can confuse the tracker bots and services (say patchwork), so I'd avoid that.
Best regards
Thomas
Quoted 3 lines
Thanks!
Helge
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)