1ea6763c1SDaniel Vetter /*
2ea6763c1SDaniel Vetter * linux/drivers/video/fb_cmdline.c
3ea6763c1SDaniel Vetter *
4ea6763c1SDaniel Vetter * Copyright (C) 2014 Intel Corp
5ea6763c1SDaniel Vetter * Copyright (C) 1994 Martin Schaller
6ea6763c1SDaniel Vetter *
7ea6763c1SDaniel Vetter * 2001 - Documented with DocBook
8ea6763c1SDaniel Vetter * - Brad Douglas <brad@neruo.com>
9ea6763c1SDaniel Vetter *
10ea6763c1SDaniel Vetter * This file is subject to the terms and conditions of the GNU General Public
11ea6763c1SDaniel Vetter * License. See the file COPYING in the main directory of this archive
12ea6763c1SDaniel Vetter * for more details.
13ea6763c1SDaniel Vetter *
14ea6763c1SDaniel Vetter * Authors:
15c88b946aSThomas Zimmermann * Daniel Vetter <daniel.vetter@ffwll.ch>
16ea6763c1SDaniel Vetter */
17*93604a5aSThomas Zimmermann
18*93604a5aSThomas Zimmermann #include <linux/export.h>
19ea6763c1SDaniel Vetter #include <linux/fb.h>
20*93604a5aSThomas Zimmermann #include <linux/string.h>
21ea6763c1SDaniel Vetter
22*93604a5aSThomas Zimmermann #include <video/cmdline.h>
2336722179SThomas Zimmermann
24ea6763c1SDaniel Vetter /**
25ea6763c1SDaniel Vetter * fb_get_options - get kernel boot parameters
26ea6763c1SDaniel Vetter * @name: framebuffer name as it would appear in
27ea6763c1SDaniel Vetter * the boot parameter line
28ea6763c1SDaniel Vetter * (video=<name>:<options>)
29ea6763c1SDaniel Vetter * @option: the option will be stored here
30ea6763c1SDaniel Vetter *
3173ce73c3SThomas Zimmermann * The caller owns the string returned in @option and is
3273ce73c3SThomas Zimmermann * responsible for releasing the memory.
3373ce73c3SThomas Zimmermann *
34ea6763c1SDaniel Vetter * NOTE: Needed to maintain backwards compatibility
35ea6763c1SDaniel Vetter */
fb_get_options(const char * name,char ** option)36ea6763c1SDaniel Vetter int fb_get_options(const char *name, char **option)
37ea6763c1SDaniel Vetter {
38*93604a5aSThomas Zimmermann const char *options = NULL;
39*93604a5aSThomas Zimmermann bool is_of = false;
40*93604a5aSThomas Zimmermann bool enabled;
41ea6763c1SDaniel Vetter
42*93604a5aSThomas Zimmermann if (name)
43*93604a5aSThomas Zimmermann is_of = strncmp(name, "offb", 4);
44ea6763c1SDaniel Vetter
45*93604a5aSThomas Zimmermann enabled = __video_get_options(name, &options, is_of);
46cedaf7cdSThomas Zimmermann
4736722179SThomas Zimmermann if (options) {
4836722179SThomas Zimmermann if (!strncmp(options, "off", 3))
49*93604a5aSThomas Zimmermann enabled = false;
5036722179SThomas Zimmermann }
51ea6763c1SDaniel Vetter
5273ce73c3SThomas Zimmermann if (option) {
5373ce73c3SThomas Zimmermann if (options)
5473ce73c3SThomas Zimmermann *option = kstrdup(options, GFP_KERNEL);
5573ce73c3SThomas Zimmermann else
5673ce73c3SThomas Zimmermann *option = NULL;
5773ce73c3SThomas Zimmermann }
58ea6763c1SDaniel Vetter
59*93604a5aSThomas Zimmermann return enabled ? 0 : 1; // 0 on success, 1 otherwise
60ea6763c1SDaniel Vetter }
61ea6763c1SDaniel Vetter EXPORT_SYMBOL(fb_get_options);
62