Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  *  linux/drivers/video/fb_cmdline.c
0003  *
0004  *  Copyright (C) 2014 Intel Corp
0005  *  Copyright (C) 1994 Martin Schaller
0006  *
0007  *  2001 - Documented with DocBook
0008  *  - Brad Douglas <brad@neruo.com>
0009  *
0010  * This file is subject to the terms and conditions of the GNU General Public
0011  * License.  See the file COPYING in the main directory of this archive
0012  * for more details.
0013  *
0014  * Authors:
0015  *    Vetter <danie.vetter@ffwll.ch>
0016  */
0017 #include <linux/init.h>
0018 #include <linux/fb.h>
0019 
0020 static char *video_options[FB_MAX] __read_mostly;
0021 static int ofonly __read_mostly;
0022 
0023 const char *fb_mode_option;
0024 EXPORT_SYMBOL_GPL(fb_mode_option);
0025 
0026 /**
0027  * fb_get_options - get kernel boot parameters
0028  * @name:   framebuffer name as it would appear in
0029  *          the boot parameter line
0030  *          (video=<name>:<options>)
0031  * @option: the option will be stored here
0032  *
0033  * NOTE: Needed to maintain backwards compatibility
0034  */
0035 int fb_get_options(const char *name, char **option)
0036 {
0037     char *opt, *options = NULL;
0038     int retval = 0;
0039     int name_len = strlen(name), i;
0040 
0041     if (name_len && ofonly && strncmp(name, "offb", 4))
0042         retval = 1;
0043 
0044     if (name_len && !retval) {
0045         for (i = 0; i < FB_MAX; i++) {
0046             if (video_options[i] == NULL)
0047                 continue;
0048             if (!video_options[i][0])
0049                 continue;
0050             opt = video_options[i];
0051             if (!strncmp(name, opt, name_len) &&
0052                 opt[name_len] == ':')
0053                 options = opt + name_len + 1;
0054         }
0055     }
0056     /* No match, pass global option */
0057     if (!options && option && fb_mode_option)
0058         options = kstrdup(fb_mode_option, GFP_KERNEL);
0059     if (options && !strncmp(options, "off", 3))
0060         retval = 1;
0061 
0062     if (option)
0063         *option = options;
0064 
0065     return retval;
0066 }
0067 EXPORT_SYMBOL(fb_get_options);
0068 
0069 /**
0070  *  video_setup - process command line options
0071  *  @options: string of options
0072  *
0073  *  Process command line options for frame buffer subsystem.
0074  *
0075  *  NOTE: This function is a __setup and __init function.
0076  *            It only stores the options.  Drivers have to call
0077  *            fb_get_options() as necessary.
0078  */
0079 static int __init video_setup(char *options)
0080 {
0081     if (!options || !*options)
0082         goto out;
0083 
0084     if (!strncmp(options, "ofonly", 6)) {
0085         ofonly = 1;
0086         goto out;
0087     }
0088 
0089     if (strchr(options, ':')) {
0090         /* named */
0091         int i;
0092 
0093         for (i = 0; i < FB_MAX; i++) {
0094             if (video_options[i] == NULL) {
0095                 video_options[i] = options;
0096                 break;
0097             }
0098         }
0099     } else {
0100         /* global */
0101         fb_mode_option = options;
0102     }
0103 
0104 out:
0105     return 1;
0106 }
0107 __setup("video=", video_setup);