1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/**********************************************************
* Copyright 2010 VMware, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
**********************************************************/
#include <xorg-server.h>
#include <xf86.h>
#include <xf86drm.h>
/*
* Defines and exported module info.
*/
#define VMWARE_DRIVER_NAME "vmware"
#define VMWGFX_DRIVER_NAME "vmwgfx"
#define VMWLEGACY_DRIVER_NAME "vmwlegacy"
#define VMWARE_VERSION_MAJOR 10
#define VMWARE_VERSION_MINOR 16
#define VMWARE_VERSION_PATCH 9
static XF86ModuleVersionInfo vmware_version;
static MODULESETUPPROTO(vmware_setup);
_X_EXPORT XF86ModuleData vmwareModuleData = {
&vmware_version,
vmware_setup,
NULL
};
/*
* Chain loading functions
*/
static Bool
vmware_check_kernel_module()
{
/* Super simple way of knowing if the kernel driver is loaded */
int ret = drmOpen("vmwgfx", NULL);
if (ret < 0)
return FALSE;
drmClose(ret);
return TRUE;
}
static Bool
vmware_chain_module(pointer opts)
{
int vmwlegacy_devices;
int vmwgfx_devices;
int vmware_devices;
int matched;
char *driver_name;
GDevPtr *gdevs;
GDevPtr gdev;
int i;
vmware_devices = xf86MatchDevice(VMWARE_DRIVER_NAME, &gdevs);
vmwgfx_devices = xf86MatchDevice(VMWGFX_DRIVER_NAME, NULL);
vmwlegacy_devices = xf86MatchDevice(VMWLEGACY_DRIVER_NAME, NULL);
if (vmware_check_kernel_module()) {
driver_name = VMWGFX_DRIVER_NAME;
matched = vmwgfx_devices;
} else {
driver_name = VMWLEGACY_DRIVER_NAME;
matched = vmwlegacy_devices;
}
for (i = 0; i < vmware_devices; i++) {
gdev = gdevs[i];
gdev->driver = driver_name;
}
xfree(gdevs);
if (!matched)
xf86LoadOneModule(driver_name, opts);
}
/*
* Module info
*/
static XF86ModuleVersionInfo vmware_version = {
VMWARE_DRIVER_NAME,
MODULEVENDORSTRING,
MODINFOSTRING1,
MODINFOSTRING2,
XORG_VERSION_CURRENT,
VMWARE_VERSION_MAJOR, VMWARE_VERSION_MINOR, VMWARE_VERSION_PATCH,
ABI_CLASS_VIDEODRV,
ABI_VIDEODRV_VERSION,
MOD_CLASS_VIDEODRV,
{0, 0, 0, 0}
};
static pointer
vmware_setup(pointer module, pointer opts, int *errmaj, int *errmin)
{
static Bool setupDone = 0;
int ret;
/* This module should be loaded only once, but check to be sure. */
if (!setupDone) {
setupDone = 1;
/* Chain load the real driver */
vmware_chain_module(opts);
return (pointer) 1;
} else {
if (errmaj)
*errmaj = LDR_ONCEONLY;
return NULL;
}
}
|