1 // SPDX-License-Identifier: GPL-2.0
3 * Based on the fbdev code in drivers/video/fbdev/core/fb_cmdline:
5 * Copyright (C) 2014 Intel Corp
6 * Copyright (C) 1994 Martin Schaller
8 * 2001 - Documented with DocBook
9 * - Brad Douglas <brad@neruo.com>
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file COPYING in the main directory of this archive
16 * Daniel Vetter <daniel.vetter@ffwll.ch>
19 #include <linux/fb.h> /* for FB_MAX */
20 #include <linux/init.h>
22 #include <video/cmdline.h>
25 * FB_MAX is the maximum number of framebuffer devices and also
26 * the maximum number of video= parameters. Although not directly
27 * related to each other, it makes sense to keep it that way.
29 static const char *video_options
[FB_MAX
] __read_mostly
;
30 static const char *video_option __read_mostly
;
31 static int video_of_only __read_mostly
;
33 static const char *__video_get_option_string(const char *name
)
35 const char *options
= NULL
;
39 name_len
= strlen(name
);
45 for (i
= 0; i
< ARRAY_SIZE(video_options
); ++i
) {
46 if (!video_options
[i
])
48 if (video_options
[i
][0] == '\0')
50 opt
= video_options
[i
];
51 if (!strncmp(opt
, name
, name_len
) && opt
[name_len
] == ':')
52 options
= opt
+ name_len
+ 1;
56 /* No match, return global options */
58 options
= video_option
;
64 * video_get_options - get kernel boot parameters
65 * @name: name of the output as it would appear in the boot parameter
66 * line (video=<name>:<options>)
68 * Looks up the video= options for the given name. Names are connector
69 * names with DRM, or driver names with fbdev. If no video option for
70 * the name has been specified, the function returns the global video=
71 * setting. A @name of NULL always returns the global video setting.
74 * The string of video options for the given name, or NULL if no video
75 * option has been specified.
77 const char *video_get_options(const char *name
)
79 return __video_get_option_string(name
);
81 EXPORT_SYMBOL(video_get_options
);
83 #if IS_ENABLED(CONFIG_FB_CORE)
84 bool __video_get_options(const char *name
, const char **options
, bool is_of
)
87 const char *opt
= NULL
;
89 if (video_of_only
&& !is_of
)
92 opt
= __video_get_option_string(name
);
99 EXPORT_SYMBOL(__video_get_options
);
103 * Process command line options for video adapters. This function is
104 * a __setup and __init function. It only stores the options. Drivers
105 * have to call video_get_options() as necessary.
107 static int __init
video_setup(char *options
)
109 if (!options
|| !*options
)
112 if (!strncmp(options
, "ofonly", 6)) {
113 video_of_only
= true;
117 if (strchr(options
, ':')) {
121 for (i
= 0; i
< ARRAY_SIZE(video_options
); i
++) {
122 if (!video_options
[i
]) {
123 video_options
[i
] = options
;
129 video_option
= options
;
135 __setup("video=", video_setup
);