]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fbdev: Wrap user-invoked calls to fb_set_var() in helper
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 27 May 2026 15:14:02 +0000 (17:14 +0200)
committerHelge Deller <deller@gmx.de>
Tue, 9 Jun 2026 14:00:10 +0000 (16:00 +0200)
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_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.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/core/fb_chrdev.c
drivers/video/fbdev/core/fbcon.c
drivers/video/fbdev/core/fbmem.c
drivers/video/fbdev/core/fbsysfs.c
drivers/video/fbdev/ps3fb.c
drivers/video/fbdev/sh_mobile_lcdcfb.c
include/linux/fb.h

index 4ebd16b7e3b8d677928f53866eb794ae3f534868..54f926fb411bd46775fecf9e246aa28765dbb7bc 100644 (file)
@@ -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 && copy_to_user(argp, &var, sizeof(var)))
index 86d014a27397432bef4fb411c85d359408f281d4..a5e197b7b234c83770fe97b4b78afa735a327e64 100644 (file)
@@ -2701,7 +2701,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)
@@ -2729,7 +2728,6 @@ int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo *va
 
        return 0;
 }
-EXPORT_SYMBOL_GPL(fbcon_modechange_possible);
 
 int fbcon_mode_deleted(struct fb_info *info,
                       struct fb_videomode *mode)
index 30f2b59c47bf9d8bb0250125d3bb65497a54b481..d37a1039e22190df454c3b693477c88c1f97f10a 100644 (file)
@@ -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;
index baa2bae0fb5b302ff47accb822e9782be93e6890..5ece236e625208811608198ad2b5e1509410f31e 100644 (file)
@@ -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)
index dbcda307f6a671dd5070ad15a497bde1307de90f..1376d19b19aebac234c3ef27fd7e678f7c5ec864 100644 (file)
@@ -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;
index 72969fe8e513486037e20f777c493f4dbb3e4489..e8324b01700f6d75fca0064192bdf6c528a6b0f5 100644 (file)
@@ -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);
 }
 
 /*
index 5178a33c752c635d230919449c01a02d8466594b..88680a7cabd5538cfd1bacda9d95b78c15b8c02b 100644 (file)
@@ -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
  */