summaryrefslogtreecommitdiff
path: root/drivers/video/fbdev/core
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2023-02-09 16:55:06 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2023-02-20 16:56:48 +0300
commit93604a5ade3a021fe3daf37f8d378b12cabb26b4 (patch)
tree3c9943124d14113bac4f362f37850c5e1406c023 /drivers/video/fbdev/core
parent367221793d4796b18181021b7a39091c268bf39b (diff)
downloadlinux-93604a5ade3a021fe3daf37f8d378b12cabb26b4.tar.xz
fbdev: Handle video= parameter in video/cmdline.c
Handle the command-line parameter video= in video/cmdline.c. Implement the fbdev helper fb_get_options() on top. Will allows to handle the kernel parameter in DRM without fbdev dependencies. Note that __video_get_options() has the meaning of its return value inverted compared to fb_get_options(). The new helper returns true if the adapter has been enabled, and false otherwise. There is the ofonly parameter, which disables output for non-OF-based framebuffers. It is only for offb and looks like a workaround. The actual purpose it not clear to me. Use 'video=off' or 'nomodeset' instead. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230209135509.7786-9-tzimmermann@suse.de
Diffstat (limited to 'drivers/video/fbdev/core')
-rw-r--r--drivers/video/fbdev/core/Makefile3
-rw-r--r--drivers/video/fbdev/core/fb_cmdline.c93
2 files changed, 13 insertions, 83 deletions
diff --git a/drivers/video/fbdev/core/Makefile b/drivers/video/fbdev/core/Makefile
index 26cbc965497c..08fabce76b74 100644
--- a/drivers/video/fbdev/core/Makefile
+++ b/drivers/video/fbdev/core/Makefile
@@ -1,9 +1,8 @@
# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_FB_CMDLINE) += fb_cmdline.o
obj-$(CONFIG_FB_NOTIFY) += fb_notify.o
obj-$(CONFIG_FB) += fb.o
fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
- modedb.o fbcvt.o
+ modedb.o fbcvt.o fb_cmdline.o
fb-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
ifeq ($(CONFIG_FRAMEBUFFER_CONSOLE),y)
diff --git a/drivers/video/fbdev/core/fb_cmdline.c b/drivers/video/fbdev/core/fb_cmdline.c
index f811c7b679e1..4d1634c492ec 100644
--- a/drivers/video/fbdev/core/fb_cmdline.c
+++ b/drivers/video/fbdev/core/fb_cmdline.c
@@ -14,42 +14,12 @@
* Authors:
* Daniel Vetter <daniel.vetter@ffwll.ch>
*/
-#include <linux/init.h>
-#include <linux/fb.h>
-
-static char *video_options[FB_MAX] __read_mostly;
-static const char *fb_mode_option __read_mostly;
-static int ofonly __read_mostly;
-
-static const char *__fb_get_options(const char *name)
-{
- const char *options = NULL;
- size_t name_len = 0;
-
- if (name)
- name_len = strlen(name);
- if (name_len) {
- unsigned int i;
- const char *opt;
-
- for (i = 0; i < ARRAY_SIZE(video_options); ++i) {
- if (!video_options[i])
- continue;
- if (video_options[i][0] == '\0')
- continue;
- opt = video_options[i];
- if (!strncmp(opt, name, name_len) && opt[name_len] == ':')
- options = opt + name_len + 1;
- }
- }
+#include <linux/export.h>
+#include <linux/fb.h>
+#include <linux/string.h>
- /* No match, return global options */
- if (!options)
- options = fb_mode_option;
-
- return options;
-}
+#include <video/cmdline.h>
/**
* fb_get_options - get kernel boot parameters
@@ -65,17 +35,18 @@ static const char *__fb_get_options(const char *name)
*/
int fb_get_options(const char *name, char **option)
{
- int retval = 0;
- const char *options;
+ const char *options = NULL;
+ bool is_of = false;
+ bool enabled;
- if (name && ofonly && strncmp(name, "offb", 4))
- retval = 1;
+ if (name)
+ is_of = strncmp(name, "offb", 4);
- options = __fb_get_options(name);
+ enabled = __video_get_options(name, &options, is_of);
if (options) {
if (!strncmp(options, "off", 3))
- retval = 1;
+ enabled = false;
}
if (option) {
@@ -85,46 +56,6 @@ int fb_get_options(const char *name, char **option)
*option = NULL;
}
- return retval;
+ return enabled ? 0 : 1; // 0 on success, 1 otherwise
}
EXPORT_SYMBOL(fb_get_options);
-
-/**
- * video_setup - process command line options
- * @options: string of options
- *
- * Process command line options for frame buffer subsystem.
- *
- * NOTE: This function is a __setup and __init function.
- * It only stores the options. Drivers have to call
- * fb_get_options() as necessary.
- */
-static int __init video_setup(char *options)
-{
- if (!options || !*options)
- goto out;
-
- if (!strncmp(options, "ofonly", 6)) {
- ofonly = 1;
- goto out;
- }
-
- if (strchr(options, ':')) {
- /* named */
- int i;
-
- for (i = 0; i < FB_MAX; i++) {
- if (video_options[i] == NULL) {
- video_options[i] = options;
- break;
- }
- }
- } else {
- /* global */
- fb_mode_option = options;
- }
-
-out:
- return 1;
-}
-__setup("video=", video_setup);