drm/nouveau: constify instances of nouveau_bitfield and nouveau_enum structs
[deliverable/linux.git] / drivers / gpu / drm / nouveau / nouveau_drm.c
CommitLineData
94580299
BS
1/*
2 * Copyright 2012 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
77145f1c 25#include <linux/console.h>
94580299
BS
26#include <linux/module.h>
27#include <linux/pci.h>
28
29#include <core/device.h>
30#include <core/client.h>
ebb945a9 31#include <core/gpuobj.h>
94580299
BS
32#include <core/class.h>
33
34#include <subdev/device.h>
ebb945a9 35#include <subdev/vm.h>
94580299
BS
36
37#include "nouveau_drm.h"
77145f1c 38#include "nouveau_irq.h"
ebb945a9 39#include "nouveau_dma.h"
77145f1c
BS
40#include "nouveau_ttm.h"
41#include "nouveau_gem.h"
cb75d97e 42#include "nouveau_agp.h"
77145f1c
BS
43#include "nouveau_vga.h"
44#include "nouveau_pm.h"
45#include "nouveau_acpi.h"
46#include "nouveau_bios.h"
47#include "nouveau_ioctl.h"
ebb945a9
BS
48#include "nouveau_abi16.h"
49#include "nouveau_fbcon.h"
50#include "nouveau_fence.h"
51
52#include "nouveau_ttm.h"
94580299 53
94580299
BS
54MODULE_PARM_DESC(config, "option string to pass to driver core");
55static char *nouveau_config;
56module_param_named(config, nouveau_config, charp, 0400);
57
58MODULE_PARM_DESC(debug, "debug string to pass to driver core");
59static char *nouveau_debug;
60module_param_named(debug, nouveau_debug, charp, 0400);
61
ebb945a9
BS
62MODULE_PARM_DESC(noaccel, "disable kernel/abi16 acceleration");
63static int nouveau_noaccel = 0;
64module_param_named(noaccel, nouveau_noaccel, int, 0400);
65
77145f1c
BS
66MODULE_PARM_DESC(modeset, "enable driver");
67int nouveau_modeset = -1;
68module_param_named(modeset, nouveau_modeset, int, 0400);
69
70static struct drm_driver driver;
71
94580299
BS
72static u64
73nouveau_name(struct pci_dev *pdev)
74{
75 u64 name = (u64)pci_domain_nr(pdev->bus) << 32;
76 name |= pdev->bus->number << 16;
77 name |= PCI_SLOT(pdev->devfn) << 8;
78 return name | PCI_FUNC(pdev->devfn);
79}
80
81static int
82nouveau_cli_create(struct pci_dev *pdev, u32 name, int size, void **pcli)
83{
84 struct nouveau_cli *cli;
85 int ret;
86
87 ret = nouveau_client_create_(name, nouveau_name(pdev), nouveau_config,
88 nouveau_debug, size, pcli);
89 cli = *pcli;
90 if (ret)
91 return ret;
92
93 mutex_init(&cli->mutex);
94 return 0;
95}
96
97static void
98nouveau_cli_destroy(struct nouveau_cli *cli)
99{
100 struct nouveau_object *client = nv_object(cli);
ebb945a9 101 nouveau_vm_ref(NULL, &cli->base.vm, NULL);
94580299
BS
102 nouveau_client_fini(&cli->base, false);
103 atomic_set(&client->refcount, 1);
104 nouveau_object_ref(NULL, &client);
105}
106
ebb945a9
BS
107static void
108nouveau_accel_fini(struct nouveau_drm *drm)
109{
110 nouveau_gpuobj_ref(NULL, &drm->notify);
111 nouveau_channel_del(&drm->channel);
49981046 112 nouveau_channel_del(&drm->cechan);
ebb945a9
BS
113 if (drm->fence)
114 nouveau_fence(drm)->dtor(drm);
115}
116
117static void
118nouveau_accel_init(struct nouveau_drm *drm)
119{
120 struct nouveau_device *device = nv_device(drm->device);
121 struct nouveau_object *object;
49981046 122 u32 arg0, arg1;
ebb945a9
BS
123 int ret;
124
125 if (nouveau_noaccel)
126 return;
127
128 /* initialise synchronisation routines */
129 if (device->card_type < NV_10) ret = nv04_fence_create(drm);
130 else if (device->chipset < 0x84) ret = nv10_fence_create(drm);
131 else if (device->card_type < NV_C0) ret = nv84_fence_create(drm);
132 else ret = nvc0_fence_create(drm);
133 if (ret) {
134 NV_ERROR(drm, "failed to initialise sync subsystem, %d\n", ret);
135 nouveau_accel_fini(drm);
136 return;
137 }
138
49981046
BS
139 if (device->card_type >= NV_E0) {
140 ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE,
141 NVDRM_CHAN + 1,
142 NVE0_CHANNEL_IND_ENGINE_CE0 |
143 NVE0_CHANNEL_IND_ENGINE_CE1, 0,
144 &drm->cechan);
145 if (ret)
146 NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
147
148 arg0 = NVE0_CHANNEL_IND_ENGINE_GR;
149 arg1 = 0;
150 } else {
151 arg0 = NvDmaFB;
152 arg1 = NvDmaTT;
153 }
154
ebb945a9 155 ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE, NVDRM_CHAN,
49981046 156 arg0, arg1, &drm->channel);
ebb945a9
BS
157 if (ret) {
158 NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
159 nouveau_accel_fini(drm);
160 return;
161 }
162
163 if (device->card_type < NV_C0) {
164 ret = nouveau_gpuobj_new(drm->device, NULL, 32, 0, 0,
165 &drm->notify);
166 if (ret) {
167 NV_ERROR(drm, "failed to allocate notifier, %d\n", ret);
168 nouveau_accel_fini(drm);
169 return;
170 }
171
172 ret = nouveau_object_new(nv_object(drm),
173 drm->channel->handle, NvNotify0,
174 0x003d, &(struct nv_dma_class) {
175 .flags = NV_DMA_TARGET_VRAM |
176 NV_DMA_ACCESS_RDWR,
177 .start = drm->notify->addr,
178 .limit = drm->notify->addr + 31
179 }, sizeof(struct nv_dma_class),
180 &object);
181 if (ret) {
182 nouveau_accel_fini(drm);
183 return;
184 }
185 }
186
187
49981046 188 nouveau_bo_move_init(drm);
ebb945a9
BS
189}
190
94580299
BS
191static int __devinit
192nouveau_drm_probe(struct pci_dev *pdev, const struct pci_device_id *pent)
193{
194 struct nouveau_device *device;
ebb945a9
BS
195 struct apertures_struct *aper;
196 bool boot = false;
94580299
BS
197 int ret;
198
ebb945a9
BS
199 /* remove conflicting drivers (vesafb, efifb etc) */
200 aper = alloc_apertures(3);
201 if (!aper)
202 return -ENOMEM;
203
204 aper->ranges[0].base = pci_resource_start(pdev, 1);
205 aper->ranges[0].size = pci_resource_len(pdev, 1);
206 aper->count = 1;
207
208 if (pci_resource_len(pdev, 2)) {
209 aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
210 aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
211 aper->count++;
212 }
213
214 if (pci_resource_len(pdev, 3)) {
215 aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
216 aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
217 aper->count++;
218 }
219
220#ifdef CONFIG_X86
221 boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
222#endif
223 remove_conflicting_framebuffers(aper, "nouveaufb", boot);
224
94580299
BS
225 ret = nouveau_device_create(pdev, nouveau_name(pdev), pci_name(pdev),
226 nouveau_config, nouveau_debug, &device);
227 if (ret)
228 return ret;
229
230 pci_set_master(pdev);
231
77145f1c 232 ret = drm_get_pci_dev(pdev, pent, &driver);
94580299 233 if (ret) {
ebb945a9 234 nouveau_object_ref(NULL, (struct nouveau_object **)&device);
94580299
BS
235 return ret;
236 }
237
238 return 0;
239}
240
241int
242nouveau_drm_load(struct drm_device *dev, unsigned long flags)
243{
244 struct pci_dev *pdev = dev->pdev;
ebb945a9 245 struct nouveau_device *device;
94580299
BS
246 struct nouveau_drm *drm;
247 int ret;
248
249 ret = nouveau_cli_create(pdev, 0, sizeof(*drm), (void**)&drm);
94580299
BS
250 if (ret)
251 return ret;
252
77145f1c
BS
253 dev->dev_private = drm;
254 drm->dev = dev;
255
94580299 256 INIT_LIST_HEAD(&drm->clients);
ebb945a9 257 spin_lock_init(&drm->tile.lock);
94580299 258
cb75d97e
BS
259 /* make sure AGP controller is in a consistent state before we
260 * (possibly) execute vbios init tables (see nouveau_agp.h)
261 */
262 if (drm_pci_device_is_agp(dev) && dev->agp) {
263 /* dummy device object, doesn't init anything, but allows
264 * agp code access to registers
265 */
266 ret = nouveau_object_new(nv_object(drm), NVDRM_CLIENT,
267 NVDRM_DEVICE, 0x0080,
268 &(struct nv_device_class) {
269 .device = ~0,
270 .disable =
271 ~(NV_DEVICE_DISABLE_MMIO |
272 NV_DEVICE_DISABLE_IDENTIFY),
273 .debug0 = ~0,
274 }, sizeof(struct nv_device_class),
275 &drm->device);
276 if (ret)
ebb945a9 277 goto fail_device;
cb75d97e
BS
278
279 nouveau_agp_reset(drm);
280 nouveau_object_del(nv_object(drm), NVDRM_CLIENT, NVDRM_DEVICE);
281 }
282
94580299
BS
283 ret = nouveau_object_new(nv_object(drm), NVDRM_CLIENT, NVDRM_DEVICE,
284 0x0080, &(struct nv_device_class) {
285 .device = ~0,
286 .disable = 0,
287 .debug0 = 0,
288 }, sizeof(struct nv_device_class),
289 &drm->device);
290 if (ret)
291 goto fail_device;
292
77145f1c
BS
293 /* workaround an odd issue on nvc1 by disabling the device's
294 * nosnoop capability. hopefully won't cause issues until a
295 * better fix is found - assuming there is one...
296 */
ebb945a9 297 device = nv_device(drm->device);
77145f1c
BS
298 if (nv_device(drm->device)->chipset == 0xc1)
299 nv_mask(device, 0x00088080, 0x00000800, 0x00000000);
ebb945a9 300
77145f1c 301 nouveau_vga_init(drm);
cb75d97e
BS
302 nouveau_agp_init(drm);
303
ebb945a9
BS
304 if (device->card_type >= NV_50) {
305 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40),
306 0x1000, &drm->client.base.vm);
307 if (ret)
308 goto fail_device;
309 }
310
311 ret = nouveau_ttm_init(drm);
94580299 312 if (ret)
77145f1c
BS
313 goto fail_ttm;
314
315 ret = nouveau_bios_init(dev);
316 if (ret)
317 goto fail_bios;
318
319 ret = nouveau_irq_init(dev);
320 if (ret)
321 goto fail_irq;
94580299 322
77145f1c 323 ret = nouveau_display_create(dev);
ebb945a9 324 if (ret)
77145f1c
BS
325 goto fail_dispctor;
326
327 if (dev->mode_config.num_crtc) {
328 ret = nouveau_display_init(dev);
329 if (ret)
330 goto fail_dispinit;
331 }
332
333 nouveau_pm_init(dev);
ebb945a9
BS
334
335 nouveau_accel_init(drm);
336 nouveau_fbcon_init(dev);
94580299
BS
337 return 0;
338
77145f1c
BS
339fail_dispinit:
340 nouveau_display_destroy(dev);
341fail_dispctor:
342 nouveau_irq_fini(dev);
343fail_irq:
344 nouveau_bios_takedown(dev);
345fail_bios:
ebb945a9 346 nouveau_ttm_fini(drm);
77145f1c
BS
347fail_ttm:
348 nouveau_agp_fini(drm);
349 nouveau_vga_fini(drm);
94580299
BS
350fail_device:
351 nouveau_cli_destroy(&drm->client);
352 return ret;
353}
354
355int
356nouveau_drm_unload(struct drm_device *dev)
357{
77145f1c 358 struct nouveau_drm *drm = nouveau_drm(dev);
94580299 359
ebb945a9
BS
360 nouveau_fbcon_fini(dev);
361 nouveau_accel_fini(drm);
362
77145f1c
BS
363 nouveau_pm_fini(dev);
364
365 nouveau_display_fini(dev);
366 nouveau_display_destroy(dev);
367
368 nouveau_irq_fini(dev);
369 nouveau_bios_takedown(dev);
94580299 370
ebb945a9 371 nouveau_ttm_fini(drm);
cb75d97e 372 nouveau_agp_fini(drm);
77145f1c 373 nouveau_vga_fini(drm);
cb75d97e 374
94580299
BS
375 nouveau_cli_destroy(&drm->client);
376 return 0;
377}
378
379static void
380nouveau_drm_remove(struct pci_dev *pdev)
381{
77145f1c
BS
382 struct drm_device *dev = pci_get_drvdata(pdev);
383 struct nouveau_drm *drm = nouveau_drm(dev);
ebb945a9 384 struct nouveau_object *device;
77145f1c
BS
385
386 device = drm->client.base.device;
387 drm_put_dev(dev);
388
ebb945a9
BS
389 nouveau_object_ref(NULL, &device);
390 nouveau_object_debug();
94580299
BS
391}
392
393int
394nouveau_drm_suspend(struct pci_dev *pdev, pm_message_t pm_state)
395{
396 struct drm_device *dev = pci_get_drvdata(pdev);
77145f1c 397 struct nouveau_drm *drm = nouveau_drm(dev);
94580299
BS
398 struct nouveau_cli *cli;
399 int ret;
400
401 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
402 pm_state.event == PM_EVENT_PRETHAW)
403 return 0;
404
ebb945a9
BS
405 NV_INFO(drm, "suspending fbcon...\n");
406 nouveau_fbcon_set_suspend(dev, 1);
407
77145f1c
BS
408 NV_INFO(drm, "suspending display...\n");
409 ret = nouveau_display_suspend(dev);
94580299
BS
410 if (ret)
411 return ret;
412
ebb945a9
BS
413 NV_INFO(drm, "evicting buffers...\n");
414 ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM);
415
416 if (drm->fence && nouveau_fence(drm)->suspend) {
417 if (!nouveau_fence(drm)->suspend(drm))
418 return -ENOMEM;
419 }
420
421 NV_INFO(drm, "suspending client object trees...\n");
94580299
BS
422 list_for_each_entry(cli, &drm->clients, head) {
423 ret = nouveau_client_fini(&cli->base, true);
424 if (ret)
425 goto fail_client;
426 }
427
428 ret = nouveau_client_fini(&drm->client.base, true);
429 if (ret)
430 goto fail_client;
431
cb75d97e
BS
432 nouveau_agp_fini(drm);
433
94580299
BS
434 pci_save_state(pdev);
435 if (pm_state.event == PM_EVENT_SUSPEND) {
436 pci_disable_device(pdev);
437 pci_set_power_state(pdev, PCI_D3hot);
438 }
439
440 return 0;
441
442fail_client:
443 list_for_each_entry_continue_reverse(cli, &drm->clients, head) {
444 nouveau_client_init(&cli->base);
445 }
446
77145f1c
BS
447 NV_INFO(drm, "resuming display...\n");
448 nouveau_display_resume(dev);
94580299
BS
449 return ret;
450}
451
452int
453nouveau_drm_resume(struct pci_dev *pdev)
454{
455 struct drm_device *dev = pci_get_drvdata(pdev);
77145f1c 456 struct nouveau_drm *drm = nouveau_drm(dev);
94580299
BS
457 struct nouveau_cli *cli;
458 int ret;
459
460 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
461 return 0;
462
ebb945a9 463 NV_INFO(drm, "re-enabling device...\n");
94580299
BS
464 pci_set_power_state(pdev, PCI_D0);
465 pci_restore_state(pdev);
466 ret = pci_enable_device(pdev);
467 if (ret)
468 return ret;
469 pci_set_master(pdev);
470
cb75d97e
BS
471 nouveau_agp_reset(drm);
472
ebb945a9 473 NV_INFO(drm, "resuming client object trees...\n");
94580299 474 nouveau_client_init(&drm->client.base);
ebb945a9 475 nouveau_agp_init(drm);
94580299
BS
476
477 list_for_each_entry(cli, &drm->clients, head) {
478 nouveau_client_init(&cli->base);
479 }
cb75d97e 480
ebb945a9
BS
481 if (drm->fence && nouveau_fence(drm)->resume)
482 nouveau_fence(drm)->resume(drm);
94580299 483
77145f1c
BS
484 nouveau_run_vbios_init(dev);
485 nouveau_irq_postinstall(dev);
486 nouveau_pm_resume(dev);
487
488 NV_INFO(drm, "resuming display...\n");
489 nouveau_display_resume(dev);
490 return 0;
94580299
BS
491}
492
ebb945a9
BS
493int
494nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
495{
496 struct pci_dev *pdev = dev->pdev;
497 struct nouveau_drm *drm = nouveau_drm(dev);
498 struct nouveau_cli *cli;
499 int ret;
500
501 ret = nouveau_cli_create(pdev, fpriv->pid, sizeof(*cli), (void **)&cli);
502 if (ret)
503 return ret;
504
505 if (nv_device(drm->device)->card_type >= NV_50) {
506 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40),
507 0x1000, &cli->base.vm);
508 if (ret) {
509 nouveau_cli_destroy(cli);
510 return ret;
511 }
512 }
513
514 fpriv->driver_priv = cli;
515
516 mutex_lock(&drm->client.mutex);
517 list_add(&cli->head, &drm->clients);
518 mutex_unlock(&drm->client.mutex);
519 return 0;
520}
521
522void
523nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv)
524{
525 struct nouveau_cli *cli = nouveau_cli(fpriv);
526 struct nouveau_drm *drm = nouveau_drm(dev);
527
528 if (cli->abi16)
529 nouveau_abi16_fini(cli->abi16);
530
531 mutex_lock(&drm->client.mutex);
532 list_del(&cli->head);
533 mutex_unlock(&drm->client.mutex);
534}
535
536void
537nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
538{
539 struct nouveau_cli *cli = nouveau_cli(fpriv);
540 nouveau_cli_destroy(cli);
541}
542
77145f1c
BS
543static struct drm_ioctl_desc
544nouveau_ioctls[] = {
545 DRM_IOCTL_DEF_DRV(NOUVEAU_GETPARAM, nouveau_abi16_ioctl_getparam, DRM_UNLOCKED|DRM_AUTH),
546 DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
547 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_UNLOCKED|DRM_AUTH),
548 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_UNLOCKED|DRM_AUTH),
549 DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_UNLOCKED|DRM_AUTH),
550 DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_UNLOCKED|DRM_AUTH),
551 DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_UNLOCKED|DRM_AUTH),
552 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_UNLOCKED|DRM_AUTH),
553 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_UNLOCKED|DRM_AUTH),
554 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_UNLOCKED|DRM_AUTH),
555 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_UNLOCKED|DRM_AUTH),
556 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_UNLOCKED|DRM_AUTH),
557};
558
559static const struct file_operations
560nouveau_driver_fops = {
561 .owner = THIS_MODULE,
562 .open = drm_open,
563 .release = drm_release,
564 .unlocked_ioctl = drm_ioctl,
565 .mmap = nouveau_ttm_mmap,
566 .poll = drm_poll,
567 .fasync = drm_fasync,
568 .read = drm_read,
569#if defined(CONFIG_COMPAT)
570 .compat_ioctl = nouveau_compat_ioctl,
571#endif
572 .llseek = noop_llseek,
573};
574
575static struct drm_driver
576driver = {
577 .driver_features =
578 DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
579 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM |
580 DRIVER_MODESET | DRIVER_PRIME,
581
582 .load = nouveau_drm_load,
583 .unload = nouveau_drm_unload,
584 .open = nouveau_drm_open,
585 .preclose = nouveau_drm_preclose,
586 .postclose = nouveau_drm_postclose,
587 .lastclose = nouveau_vga_lastclose,
588
589 .irq_preinstall = nouveau_irq_preinstall,
590 .irq_postinstall = nouveau_irq_postinstall,
591 .irq_uninstall = nouveau_irq_uninstall,
592 .irq_handler = nouveau_irq_handler,
593
594 .get_vblank_counter = drm_vblank_count,
595 .enable_vblank = nouveau_vblank_enable,
596 .disable_vblank = nouveau_vblank_disable,
597
598 .ioctls = nouveau_ioctls,
599 .fops = &nouveau_driver_fops,
600
601 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
602 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
603 .gem_prime_export = nouveau_gem_prime_export,
604 .gem_prime_import = nouveau_gem_prime_import,
605
606 .gem_init_object = nouveau_gem_object_new,
607 .gem_free_object = nouveau_gem_object_del,
608 .gem_open_object = nouveau_gem_object_open,
609 .gem_close_object = nouveau_gem_object_close,
610
611 .dumb_create = nouveau_display_dumb_create,
612 .dumb_map_offset = nouveau_display_dumb_map_offset,
613 .dumb_destroy = nouveau_display_dumb_destroy,
614
615 .name = DRIVER_NAME,
616 .desc = DRIVER_DESC,
617#ifdef GIT_REVISION
618 .date = GIT_REVISION,
619#else
620 .date = DRIVER_DATE,
621#endif
622 .major = DRIVER_MAJOR,
623 .minor = DRIVER_MINOR,
624 .patchlevel = DRIVER_PATCHLEVEL,
625};
626
94580299
BS
627static struct pci_device_id
628nouveau_drm_pci_table[] = {
629 {
630 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
631 .class = PCI_BASE_CLASS_DISPLAY << 16,
632 .class_mask = 0xff << 16,
633 },
634 {
635 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID),
636 .class = PCI_BASE_CLASS_DISPLAY << 16,
637 .class_mask = 0xff << 16,
638 },
639 {}
640};
641
642static struct pci_driver
643nouveau_drm_pci_driver = {
644 .name = "nouveau",
645 .id_table = nouveau_drm_pci_table,
646 .probe = nouveau_drm_probe,
647 .remove = nouveau_drm_remove,
648 .suspend = nouveau_drm_suspend,
649 .resume = nouveau_drm_resume,
650};
651
652static int __init
653nouveau_drm_init(void)
654{
77145f1c
BS
655 driver.num_ioctls = ARRAY_SIZE(nouveau_ioctls);
656
657 if (nouveau_modeset == -1) {
658#ifdef CONFIG_VGA_CONSOLE
659 if (vgacon_text_force())
660 nouveau_modeset = 0;
661 else
662#endif
663 nouveau_modeset = 1;
664 }
665
666 if (!nouveau_modeset)
667 return 0;
668
669 nouveau_register_dsm_handler();
670 return drm_pci_init(&driver, &nouveau_drm_pci_driver);
94580299
BS
671}
672
673static void __exit
674nouveau_drm_exit(void)
675{
77145f1c
BS
676 if (!nouveau_modeset)
677 return;
678
679 drm_pci_exit(&driver, &nouveau_drm_pci_driver);
680 nouveau_unregister_dsm_handler();
94580299
BS
681}
682
683module_init(nouveau_drm_init);
684module_exit(nouveau_drm_exit);
685
686MODULE_DEVICE_TABLE(pci, nouveau_drm_pci_table);
77145f1c
BS
687MODULE_AUTHOR(DRIVER_AUTHOR);
688MODULE_DESCRIPTION(DRIVER_DESC);
94580299 689MODULE_LICENSE("GPL and additional rights");
This page took 0.204369 seconds and 5 git commands to generate.