drm_init.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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