Skip to content

Commit ea6763c

Browse files
committed
video/fbdev: Always built-in video= cmdline parsing
In drm/i915 we want to get at the video= cmdline modes even when we don't have fbdev support enabled, so that users can always override the kernel's initial mode selection. But that gives us a direct depency upon the parsing code in the fbdev subsystem. Since it's so little code just extract these 2 functions and always build them in. Whiel at it fix the checkpatch fail in this code. v2: Also move fb_mode_option. Spotted by the kbuild. v3: Review from Geert: - Keep the old copyright notice from fb_mem.c, although I have no idea what exactly applies. - Only compile this when needed. Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: linux-fbdev@vger.kernel.org Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> -- I prefer if we can merge this through drm-next since we'll use it there in follow-up patches. -Daniel
1 parent 83f45fc commit ea6763c

File tree

5 files changed

+115
-95
lines changed

5 files changed

+115
-95
lines changed

drivers/video/fbdev/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
menuconfig FB
66
tristate "Support for frame buffer devices"
7+
select FB_CMDLINE
78
---help---
89
The frame buffer device provides an abstraction for the graphics
910
hardware. It represents the frame buffer of some video hardware and
@@ -52,6 +53,9 @@ config FIRMWARE_EDID
5253
combination with certain motherboards and monitors are known to
5354
suffer from this problem.
5455

56+
config FB_CMDLINE
57+
bool
58+
5559
config FB_DDC
5660
tristate
5761
depends on FB

drivers/video/fbdev/core/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
obj-y += fb_notify.o
2+
obj-$(CONFIG_FB_CMDLINE) += fb_cmdline.o
23
obj-$(CONFIG_FB) += fb.o
34
fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
45
modedb.o fbcvt.o

drivers/video/fbdev/core/fb_cmdline.c

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* linux/drivers/video/fb_cmdline.c
3+
*
4+
* Copyright (C) 2014 Intel Corp
5+
* Copyright (C) 1994 Martin Schaller
6+
*
7+
* 2001 - Documented with DocBook
8+
* - Brad Douglas <brad@neruo.com>
9+
*
10+
* This file is subject to the terms and conditions of the GNU General Public
11+
* License. See the file COPYING in the main directory of this archive
12+
* for more details.
13+
*
14+
* Authors:
15+
* Vetter <danie.vetter@ffwll.ch>
16+
*/
17+
#include <linux/init.h>
18+
#include <linux/fb.h>
19+
20+
static char *video_options[FB_MAX] __read_mostly;
21+
static int ofonly __read_mostly;
22+
23+
const char *fb_mode_option;
24+
EXPORT_SYMBOL_GPL(fb_mode_option);
25+
26+
/**
27+
* fb_get_options - get kernel boot parameters
28+
* @name: framebuffer name as it would appear in
29+
* the boot parameter line
30+
* (video=<name>:<options>)
31+
* @option: the option will be stored here
32+
*
33+
* NOTE: Needed to maintain backwards compatibility
34+
*/
35+
int fb_get_options(const char *name, char **option)
36+
{
37+
char *opt, *options = NULL;
38+
int retval = 0;
39+
int name_len = strlen(name), i;
40+
41+
if (name_len && ofonly && strncmp(name, "offb", 4))
42+
retval = 1;
43+
44+
if (name_len && !retval) {
45+
for (i = 0; i < FB_MAX; i++) {
46+
if (video_options[i] == NULL)
47+
continue;
48+
if (!video_options[i][0])
49+
continue;
50+
opt = video_options[i];
51+
if (!strncmp(name, opt, name_len) &&
52+
opt[name_len] == ':')
53+
options = opt + name_len + 1;
54+
}
55+
}
56+
/* No match, pass global option */
57+
if (!options && option && fb_mode_option)
58+
options = kstrdup(fb_mode_option, GFP_KERNEL);
59+
if (options && !strncmp(options, "off", 3))
60+
retval = 1;
61+
62+
if (option)
63+
*option = options;
64+
65+
return retval;
66+
}
67+
EXPORT_SYMBOL(fb_get_options);
68+
69+
/**
70+
* video_setup - process command line options
71+
* @options: string of options
72+
*
73+
* Process command line options for frame buffer subsystem.
74+
*
75+
* NOTE: This function is a __setup and __init function.
76+
* It only stores the options. Drivers have to call
77+
* fb_get_options() as necessary.
78+
*
79+
* Returns zero.
80+
*
81+
*/
82+
static int __init video_setup(char *options)
83+
{
84+
int i, global = 0;
85+
86+
if (!options || !*options)
87+
global = 1;
88+
89+
if (!global && !strncmp(options, "ofonly", 6)) {
90+
ofonly = 1;
91+
global = 1;
92+
}
93+
94+
if (!global && !strchr(options, ':')) {
95+
fb_mode_option = options;
96+
global = 1;
97+
}
98+
99+
if (!global) {
100+
for (i = 0; i < FB_MAX; i++) {
101+
if (video_options[i] == NULL) {
102+
video_options[i] = options;
103+
break;
104+
}
105+
}
106+
}
107+
108+
return 1;
109+
}
110+
__setup("video=", video_setup);

drivers/video/fbdev/core/fbmem.c

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,96 +1908,4 @@ int fb_new_modelist(struct fb_info *info)
19081908
return err;
19091909
}
19101910

1911-
static char *video_options[FB_MAX] __read_mostly;
1912-
static int ofonly __read_mostly;
1913-
1914-
/**
1915-
* fb_get_options - get kernel boot parameters
1916-
* @name: framebuffer name as it would appear in
1917-
* the boot parameter line
1918-
* (video=<name>:<options>)
1919-
* @option: the option will be stored here
1920-
*
1921-
* NOTE: Needed to maintain backwards compatibility
1922-
*/
1923-
int fb_get_options(const char *name, char **option)
1924-
{
1925-
char *opt, *options = NULL;
1926-
int retval = 0;
1927-
int name_len = strlen(name), i;
1928-
1929-
if (name_len && ofonly && strncmp(name, "offb", 4))
1930-
retval = 1;
1931-
1932-
if (name_len && !retval) {
1933-
for (i = 0; i < FB_MAX; i++) {
1934-
if (video_options[i] == NULL)
1935-
continue;
1936-
if (!video_options[i][0])
1937-
continue;
1938-
opt = video_options[i];
1939-
if (!strncmp(name, opt, name_len) &&
1940-
opt[name_len] == ':')
1941-
options = opt + name_len + 1;
1942-
}
1943-
}
1944-
/* No match, pass global option */
1945-
if (!options && option && fb_mode_option)
1946-
options = kstrdup(fb_mode_option, GFP_KERNEL);
1947-
if (options && !strncmp(options, "off", 3))
1948-
retval = 1;
1949-
1950-
if (option)
1951-
*option = options;
1952-
1953-
return retval;
1954-
}
1955-
EXPORT_SYMBOL(fb_get_options);
1956-
1957-
#ifndef MODULE
1958-
/**
1959-
* video_setup - process command line options
1960-
* @options: string of options
1961-
*
1962-
* Process command line options for frame buffer subsystem.
1963-
*
1964-
* NOTE: This function is a __setup and __init function.
1965-
* It only stores the options. Drivers have to call
1966-
* fb_get_options() as necessary.
1967-
*
1968-
* Returns zero.
1969-
*
1970-
*/
1971-
static int __init video_setup(char *options)
1972-
{
1973-
int i, global = 0;
1974-
1975-
if (!options || !*options)
1976-
global = 1;
1977-
1978-
if (!global && !strncmp(options, "ofonly", 6)) {
1979-
ofonly = 1;
1980-
global = 1;
1981-
}
1982-
1983-
if (!global && !strchr(options, ':')) {
1984-
fb_mode_option = options;
1985-
global = 1;
1986-
}
1987-
1988-
if (!global) {
1989-
for (i = 0; i < FB_MAX; i++) {
1990-
if (video_options[i] == NULL) {
1991-
video_options[i] = options;
1992-
break;
1993-
}
1994-
1995-
}
1996-
}
1997-
1998-
return 1;
1999-
}
2000-
__setup("video=", video_setup);
2001-
#endif
2002-
20031911
MODULE_LICENSE("GPL");

drivers/video/fbdev/core/modedb.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
#define DPRINTK(fmt, args...)
3030
#endif
3131

32-
const char *fb_mode_option;
33-
EXPORT_SYMBOL_GPL(fb_mode_option);
34-
3532
/*
3633
* Standard video mode definitions (taken from XFree86)
3734
*/

0 commit comments

Comments
 (0)