Import 2.4.0-test2pre7
[davej-history.git] / drivers / char / drm / init.c
blobad887490bda78a9f0260b668ddb5662768453636
1 /* init.c -- Setup/Cleanup for DRM -*- linux-c -*-
2 * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
26 * Authors:
27 * Rickard E. (Rik) Faith <faith@precisioninsight.com>
31 #define __NO_VERSION__
32 #include "drmP.h"
34 int drm_flags = 0;
36 /* drm_parse_option parses a single option. See description for
37 drm_parse_options for details. */
39 static void drm_parse_option(char *s)
41 char *c, *r;
43 DRM_DEBUG("\"%s\"\n", s);
44 if (!s || !*s) return;
45 for (c = s; *c && *c != ':'; c++); /* find : or \0 */
46 if (*c) r = c + 1; else r = NULL; /* remember remainder */
47 *c = '\0'; /* terminate */
48 if (!strcmp(s, "noctx")) {
49 drm_flags |= DRM_FLAG_NOCTX;
50 DRM_INFO("Server-mediated context switching OFF\n");
51 return;
53 if (!strcmp(s, "debug")) {
54 drm_flags |= DRM_FLAG_DEBUG;
55 DRM_INFO("Debug messages ON\n");
56 return;
58 DRM_ERROR("\"%s\" is not a valid option\n", s);
59 return;
62 /* drm_parse_options parse the insmod "drm=" options, or the command-line
63 * options passed to the kernel via LILO. The grammar of the format is as
64 * follows:
66 * drm ::= 'drm=' option_list
67 * option_list ::= option [ ';' option_list ]
68 * option ::= 'device:' major
69 * | 'debug'
70 * | 'noctx'
71 * major ::= INTEGER
73 * Note that 's' contains option_list without the 'drm=' part.
75 * device=major,minor specifies the device number used for /dev/drm
76 * if major == 0 then the misc device is used
77 * if major == 0 and minor == 0 then dynamic misc allocation is used
78 * debug=on specifies that debugging messages will be printk'd
79 * debug=trace specifies that each function call will be logged via printk
80 * debug=off turns off all debugging options
84 void drm_parse_options(char *s)
86 char *h, *t, *n;
88 DRM_DEBUG("\"%s\"\n", s ?: "");
89 if (!s || !*s) return;
91 for (h = t = n = s; h && *h; h = n) {
92 for (; *t && *t != ';'; t++); /* find ; or \0 */
93 if (*t) n = t + 1; else n = NULL; /* remember next */
94 *t = '\0'; /* terminate */
95 drm_parse_option(h); /* parse */
99 /* drm_cpu_valid returns non-zero if the DRI will run on this CPU, and 0
100 * otherwise. */
102 int drm_cpu_valid(void)
104 #if defined(__i386__)
105 if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */
106 #endif
107 #if defined(__sparc__) && !defined(__sparc_v9__)
108 if (1)
109 return 0; /* No cmpxchg before v9 sparc. */
110 #endif
111 return 1;