3 * Setup/Cleanup for DRM
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 * \author Gareth Hughes <gareth@valinux.com>
10 * Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
12 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
13 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
14 * All Rights Reserved.
16 * Permission is hereby granted, free of charge, to any person obtaining a
17 * copy of this software and associated documentation files (the "Software"),
18 * to deal in the Software without restriction, including without limitation
19 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
20 * and/or sell copies of the Software, and to permit persons to whom the
21 * Software is furnished to do so, subject to the following conditions:
23 * The above copyright notice and this permission notice (including the next
24 * paragraph) shall be included in all copies or substantial portions of the
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
30 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
31 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
32 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
33 * OTHER DEALINGS IN THE SOFTWARE.
38 /** Debug flags. Set by parse_option(). */
40 int DRM(flags) = DRM_FLAG_DEBUG;
46 * Parse a single option.
48 * \param s option string.
50 * \sa See parse_options() for details.
52 static void DRM(parse_option)(char *s)
56 DRM_DEBUG("\"%s\"\n", s);
57 if (!s || !*s) return;
58 for (c = s; *c && *c != ':'; c++); /* find : or \0 */
59 if (*c) r = c + 1; else r = NULL; /* remember remainder */
60 *c = '\0'; /* terminate */
61 if (!strcmp(s, "debug")) {
62 DRM(flags) |= DRM_FLAG_DEBUG;
63 DRM_INFO("Debug messages ON\n");
66 DRM_ERROR("\"%s\" is not a valid option\n", s);
71 * Parse the insmod "drm_opts=" options, or the command-line
72 * options passed to the kernel via LILO.
74 * \param s contains option_list without the 'drm_opts=' part.
76 * The grammar of the format is as
80 * drm ::= 'drm_opts=' option_list
81 * option_list ::= option [ ';' option_list ]
82 * option ::= 'device:' major
88 * - device=major,minor specifies the device number used for /dev/drm
89 * - if major == 0 then the misc device is used
90 * - if major == 0 and minor == 0 then dynamic misc allocation is used
91 * - debug=on specifies that debugging messages will be printk'd
92 * - debug=trace specifies that each function call will be logged via printk
93 * - debug=off turns off all debugging options
95 * \todo Actually only the \e presence of the 'debug' option is currently
99 void DRM(parse_options)(char *s)
103 DRM_DEBUG("\"%s\"\n", s ?: "");
104 if (!s || !*s) return;
106 for (h = t = n = s; h && *h; h = n) {
107 for (; *t && *t != ';'; t++); /* find ; or \0 */
108 if (*t) n = t + 1; else n = NULL; /* remember next */
109 *t = '\0'; /* terminate */
110 DRM(parse_option)(h); /* parse */
115 * Check whether DRI will run on this CPU.
117 * \return non-zero if the DRI will run on this CPU, or zero otherwise.
119 int DRM(cpu_valid)(void)
121 #if defined(__i386__)
122 if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */
124 #if defined(__sparc__) && !defined(__sparc_v9__)
125 return 0; /* No cmpxchg before v9 sparc. */