fb_cmdline.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. static char *video_options[FB_MAX] __read_mostly;
  20. static int ofonly __read_mostly;
  21. const char *fb_mode_option;
  22. EXPORT_SYMBOL_GPL(fb_mode_option);
  23. /**
  24. * fb_get_options - get kernel boot parameters
  25. * @name: framebuffer name as it would appear in
  26. * the boot parameter line
  27. * (video=<name>:<options>)
  28. * @option: the option will be stored here
  29. *
  30. * NOTE: Needed to maintain backwards compatibility
  31. */
  32. int fb_get_options(const char *name, char **option)
  33. {
  34. char *opt, *options = NULL;
  35. int retval = 0;
  36. int name_len = strlen(name), i;
  37. if (name_len && ofonly && strncmp(name, "offb", 4))
  38. retval = 1;
  39. if (name_len && !retval) {
  40. for (i = 0; i < FB_MAX; i++) {
  41. if (video_options[i] == NULL)
  42. continue;
  43. if (!video_options[i][0])
  44. continue;
  45. opt = video_options[i];
  46. if (!strncmp(name, opt, name_len) &&
  47. opt[name_len] == ':')
  48. options = opt + name_len + 1;
  49. }
  50. }
  51. /* No match, pass global option */
  52. if (!options && option && fb_mode_option)
  53. options = kstrdup(fb_mode_option, GFP_KERNEL);
  54. if (options && !strncmp(options, "off", 3))
  55. retval = 1;
  56. if (option)
  57. *option = options;
  58. return retval;
  59. }
  60. EXPORT_SYMBOL(fb_get_options);
  61. /**
  62. * video_setup - process command line options
  63. * @options: string of options
  64. *
  65. * Process command line options for frame buffer subsystem.
  66. *
  67. * NOTE: This function is a __setup and __init function.
  68. * It only stores the options. Drivers have to call
  69. * fb_get_options() as necessary.
  70. *
  71. * Returns zero.
  72. *
  73. */
  74. static int __init video_setup(char *options)
  75. {
  76. int i, global = 0;
  77. if (!options || !*options)
  78. global = 1;
  79. if (!global && !strncmp(options, "ofonly", 6)) {
  80. ofonly = 1;
  81. global = 1;
  82. }
  83. if (!global && !strchr(options, ':')) {
  84. fb_mode_option = options;
  85. global = 1;
  86. }
  87. if (!global) {
  88. for (i = 0; i < FB_MAX; i++) {
  89. if (video_options[i] == NULL) {
  90. video_options[i] = options;
  91. break;
  92. }
  93. }
  94. }
  95. return 1;
  96. }
  97. __setup("video=", video_setup);