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 * Daniel Vetter <daniel.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 * The caller owns the string returned in @option and is 34 * responsible for releasing the memory. 35 * 36 * NOTE: Needed to maintain backwards compatibility 37 */ 38 int fb_get_options(const char *name, char **option) 39 { 40 const char *options = NULL; 41 int retval = 0; 42 size_t name_len; 43 char *opt; 44 45 if (name) 46 name_len = strlen(name); 47 48 if (name_len && ofonly && strncmp(name, "offb", 4)) 49 retval = 1; 50 51 if (name_len && !retval) { 52 unsigned int i; 53 54 for (i = 0; i < FB_MAX; i++) { 55 if (video_options[i] == NULL) 56 continue; 57 if (!video_options[i][0]) 58 continue; 59 opt = video_options[i]; 60 if (!strncmp(name, opt, name_len) && 61 opt[name_len] == ':') 62 options = opt + name_len + 1; 63 } 64 } 65 /* No match, pass global option */ 66 if (!options && option && fb_mode_option) 67 options = fb_mode_option; 68 if (options && !strncmp(options, "off", 3)) 69 retval = 1; 70 71 if (option) { 72 if (options) 73 *option = kstrdup(options, GFP_KERNEL); 74 else 75 *option = NULL; 76 } 77 78 return retval; 79 } 80 EXPORT_SYMBOL(fb_get_options); 81 82 /** 83 * video_setup - process command line options 84 * @options: string of options 85 * 86 * Process command line options for frame buffer subsystem. 87 * 88 * NOTE: This function is a __setup and __init function. 89 * It only stores the options. Drivers have to call 90 * fb_get_options() as necessary. 91 */ 92 static int __init video_setup(char *options) 93 { 94 if (!options || !*options) 95 goto out; 96 97 if (!strncmp(options, "ofonly", 6)) { 98 ofonly = 1; 99 goto out; 100 } 101 102 if (strchr(options, ':')) { 103 /* named */ 104 int i; 105 106 for (i = 0; i < FB_MAX; i++) { 107 if (video_options[i] == NULL) { 108 video_options[i] = options; 109 break; 110 } 111 } 112 } else { 113 /* global */ 114 fb_mode_option = options; 115 } 116 117 out: 118 return 1; 119 } 120 __setup("video=", video_setup); 121