glsl2: Add and use new variable mode ir_var_temporary
[mesa/nouveau-pmpeg.git] / src / gallium / targets / xorg-vmwgfx / vmw_xorg.c
blob87aad25b24f311c0f552874eab5729d794799e84
1 /**********************************************************
2 * Copyright 2008-2009 VMware, Inc. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
24 **********************************************************/
26 /**
27 * @file
28 * Glue file for Xorg State Tracker.
30 * @author Alan Hourihane <alanh@tungstengraphics.com>
31 * @author Jakob Bornecrantz <wallbraker@gmail.com>
34 #include "vmw_hook.h"
38 * Defines and modinfo
41 #define VMWGFX_DRIVER_NAME "vmwgfx"
43 #define VMW_STRING_INNER(s) #s
44 #define VMW_STRING(str) VMW_STRING_INNER(str)
46 #define VMWGFX_VERSION_MAJOR 11
47 #define VMWGFX_VERSION_MINOR 0
48 #define VMWGFX_VERSION_PATCH 0
49 #define VMWGFX_VERSION_STRING_MAJOR VMW_STRING(VMWGFX_VERSION_MAJOR)
50 #define VMWGFX_VERSION_STRING_MINOR VMW_STRING(VMWGFX_VERSION_MINOR)
51 #define VMWGFX_VERSION_STRING_PATCH VMW_STRING(VMWGFX_VERSION_PATCH)
53 #define VMWGFX_DRIVER_VERSION \
54 (VMWGFX_VERSION_MAJOR * 65536 + VMWGFX_VERSION_MINOR * 256 + VMWGFX_VERSION_PATCH)
55 #define VMWGFX_DRIVER_VERSION_STRING \
56 VMWGFX_VERSION_STRING_MAJOR "." VMWGFX_VERSION_STRING_MINOR \
57 "." VMWGFX_VERSION_STRING_PATCH
60 * Standard four digit version string expected by VMware Tools installer.
61 * As the driver's version is only {major, minor, patchlevel}, simply append an
62 * extra zero for the fourth digit.
64 #ifdef __GNUC__
65 _X_EXPORT const char vmwgfx_drv_modinfo[] __attribute__((section(".modinfo"),unused)) =
66 "version=" VMWGFX_DRIVER_VERSION_STRING ".0";
67 #endif
69 static void vmw_xorg_identify(int flags);
70 _X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver,
71 int entity_num,
72 struct pci_device *device,
73 intptr_t match_data);
77 * Tables
80 static const struct pci_id_match vmw_xorg_device_match[] = {
81 {0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0},
82 {0, 0, 0, 0, 0, 0, 0},
85 static SymTabRec vmw_xorg_chipsets[] = {
86 {PCI_MATCH_ANY, "VMware SVGA Device"},
87 {-1, NULL}
90 static PciChipsets vmw_xorg_pci_devices[] = {
91 {PCI_MATCH_ANY, PCI_MATCH_ANY, NULL},
92 {-1, -1, NULL}
95 static XF86ModuleVersionInfo vmw_xorg_version = {
96 VMWGFX_DRIVER_NAME,
97 MODULEVENDORSTRING,
98 MODINFOSTRING1,
99 MODINFOSTRING2,
100 XORG_VERSION_CURRENT,
101 VMWGFX_VERSION_MAJOR, VMWGFX_VERSION_MINOR, VMWGFX_VERSION_PATCH,
102 ABI_CLASS_VIDEODRV,
103 ABI_VIDEODRV_VERSION,
104 MOD_CLASS_VIDEODRV,
105 {0, 0, 0, 0}
109 * Xorg driver exported structures
112 _X_EXPORT DriverRec vmwgfx = {
114 VMWGFX_DRIVER_NAME,
115 vmw_xorg_identify,
116 NULL,
117 xorg_tracker_available_options,
118 NULL,
120 NULL,
121 vmw_xorg_device_match,
122 vmw_xorg_pci_probe
125 static MODULESETUPPROTO(vmw_xorg_setup);
127 _X_EXPORT XF86ModuleData vmwgfxModuleData = {
128 &vmw_xorg_version,
129 vmw_xorg_setup,
130 NULL
135 * Xorg driver functions
138 static pointer
139 vmw_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
141 static Bool setupDone = 0;
143 /* This module should be loaded only once, but check to be sure.
145 if (!setupDone) {
146 setupDone = 1;
147 xf86AddDriver(&vmwgfx, module, HaveDriverFuncs);
150 * The return value must be non-NULL on success even though there
151 * is no TearDownProc.
153 return (pointer) 1;
154 } else {
155 if (errmaj)
156 *errmaj = LDR_ONCEONLY;
157 return NULL;
161 static void
162 vmw_xorg_identify(int flags)
164 xf86PrintChipsets("vmwgfx", "Driver for VMware SVGA device",
165 vmw_xorg_chipsets);
168 _X_EXPORT Bool
169 vmw_xorg_pci_probe(DriverPtr driver,
170 int entity_num, struct pci_device *device, intptr_t match_data)
172 ScrnInfoPtr scrn = NULL;
173 EntityInfoPtr entity;
175 scrn = xf86ConfigPciEntity(scrn, 0, entity_num, vmw_xorg_pci_devices,
176 NULL, NULL, NULL, NULL, NULL);
177 if (scrn != NULL) {
178 scrn->driverVersion = 1;
179 scrn->driverName = "vmwgfx";
180 scrn->name = "vmwgfx";
181 scrn->Probe = NULL;
183 entity = xf86GetEntityInfo(entity_num);
185 /* Use all the functions from the xorg tracker */
186 xorg_tracker_set_functions(scrn);
188 vmw_screen_set_functions(scrn);
190 return scrn != NULL;