2 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Author: Alan Hourihane <alanh@tungstengraphics.com>
27 * Author: Jakob Bornecrantz <wallbraker@gmail.com>
31 #include "../../state_trackers/xorg/xorg_winsys.h"
32 #include <nouveau_drmif.h>
34 #include <xf86drmMode.h>
36 static void nouveau_xorg_identify(int flags
);
37 static Bool
nouveau_xorg_pci_probe(DriverPtr driver
, int entity_num
,
38 struct pci_device
*device
,
41 static const struct pci_id_match nouveau_xorg_device_match
[] = {
42 { 0x10de, PCI_MATCH_ANY
, PCI_MATCH_ANY
, PCI_MATCH_ANY
,
43 0x00030000, 0x00ffffff, 0 },
47 static PciChipsets nouveau_xorg_pci_devices
[] = {
48 {PCI_MATCH_ANY
, PCI_MATCH_ANY
, NULL
},
52 static XF86ModuleVersionInfo nouveau_xorg_version
= {
58 0, 1, 0, /* major, minor, patch */
66 * Xorg driver exported structures
69 _X_EXPORT DriverRec nouveau2
= {
72 nouveau_xorg_identify
,
74 xorg_tracker_available_options
,
78 nouveau_xorg_device_match
,
79 nouveau_xorg_pci_probe
82 static MODULESETUPPROTO(nouveau_xorg_setup
);
84 _X_EXPORT XF86ModuleData nouveau2ModuleData
= {
85 &nouveau_xorg_version
,
91 * Xorg driver functions
95 nouveau_xorg_setup(pointer module
, pointer opts
, int *errmaj
, int *errmin
)
97 static Bool setupDone
= 0;
99 /* This module should be loaded only once, but check to be sure.
103 xf86AddDriver(&nouveau2
, module
, HaveDriverFuncs
);
106 * The return value must be non-NULL on success even though there
107 * is no TearDownProc.
112 *errmaj
= LDR_ONCEONLY
;
118 nouveau_xorg_identify(int flags
)
120 xf86DrvMsg(0, X_INFO
, "nouveau2: Gallium3D based 2D driver for NV30+ NVIDIA chipsets\n");
124 nouveau_xorg_pci_probe(DriverPtr driver
,
125 int entity_num
, struct pci_device
*device
, intptr_t match_data
)
127 ScrnInfoPtr scrn
= NULL
;
128 EntityInfoPtr entity
;
129 struct nouveau_device
*dev
= NULL
;
133 if (device
->vendor_id
!= 0x10DE)
136 if (!xf86LoaderCheckSymbol("DRICreatePCIBusID")) {
137 xf86DrvMsg(-1, X_ERROR
, "[drm] No DRICreatePCIBusID symbol\n");
140 busid
= DRICreatePCIBusID(device
);
142 ret
= nouveau_device_open(&dev
, busid
);
144 xf86DrvMsg(-1, X_ERROR
, "[drm] failed to open device\n");
149 chipset
= dev
->chipset
;
150 nouveau_device_close(&dev
);
152 ret
= drmCheckModesettingSupported(busid
);
155 xf86DrvMsg(-1, X_ERROR
, "[drm] KMS not enabled\n");
159 switch (chipset
& 0xf0) {
163 xf86DrvMsg(-1, X_NOTICE
, "Too old chipset: NV%02x\n", chipset
);
173 xf86DrvMsg(-1, X_INFO
, "Detected chipset: NV%02x\n", chipset
);
176 xf86DrvMsg(-1, X_ERROR
, "Unknown chipset: NV%02x\n", chipset
);
180 scrn
= xf86ConfigPciEntity(scrn
, 0, entity_num
, nouveau_xorg_pci_devices
,
181 NULL
, NULL
, NULL
, NULL
, NULL
);
183 scrn
->driverVersion
= 1;
184 scrn
->driverName
= "nouveau";
185 scrn
->name
= "nouveau2";
188 entity
= xf86GetEntityInfo(entity_num
);
190 /* Use all the functions from the xorg tracker */
191 xorg_tracker_set_functions(scrn
);