2 * Copyright 2012 Red Hat Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
25 #include <linux/console.h>
26 #include <linux/module.h>
27 #include <linux/pci.h>
29 #include <core/device.h>
30 #include <core/client.h>
31 #include <core/gpuobj.h>
32 #include <core/class.h>
34 #include <engine/device.h>
35 #include <engine/disp.h>
36 #include <engine/fifo.h>
38 #include <subdev/vm.h>
40 #include "nouveau_drm.h"
41 #include "nouveau_dma.h"
42 #include "nouveau_ttm.h"
43 #include "nouveau_gem.h"
44 #include "nouveau_agp.h"
45 #include "nouveau_vga.h"
46 #include "nouveau_pm.h"
47 #include "nouveau_acpi.h"
48 #include "nouveau_bios.h"
49 #include "nouveau_ioctl.h"
50 #include "nouveau_abi16.h"
51 #include "nouveau_fbcon.h"
52 #include "nouveau_fence.h"
53 #include "nouveau_debugfs.h"
55 MODULE_PARM_DESC(config
, "option string to pass to driver core");
56 static char *nouveau_config
;
57 module_param_named(config
, nouveau_config
, charp
, 0400);
59 MODULE_PARM_DESC(debug
, "debug string to pass to driver core");
60 static char *nouveau_debug
;
61 module_param_named(debug
, nouveau_debug
, charp
, 0400);
63 MODULE_PARM_DESC(noaccel
, "disable kernel/abi16 acceleration");
64 static int nouveau_noaccel
= 0;
65 module_param_named(noaccel
, nouveau_noaccel
, int, 0400);
67 MODULE_PARM_DESC(modeset
, "enable driver (default: auto, "
68 "0 = disabled, 1 = enabled, 2 = headless)");
69 int nouveau_modeset
= -1;
70 module_param_named(modeset
, nouveau_modeset
, int, 0400);
72 static struct drm_driver driver
;
75 nouveau_drm_vblank_handler(struct nouveau_eventh
*event
, int head
)
77 struct nouveau_drm
*drm
=
78 container_of(event
, struct nouveau_drm
, vblank
[head
]);
79 drm_handle_vblank(drm
->dev
, head
);
80 return NVKM_EVENT_KEEP
;
84 nouveau_drm_vblank_enable(struct drm_device
*dev
, int head
)
86 struct nouveau_drm
*drm
= nouveau_drm(dev
);
87 struct nouveau_disp
*pdisp
= nouveau_disp(drm
->device
);
89 if (WARN_ON_ONCE(head
> ARRAY_SIZE(drm
->vblank
)))
91 WARN_ON_ONCE(drm
->vblank
[head
].func
);
92 drm
->vblank
[head
].func
= nouveau_drm_vblank_handler
;
93 nouveau_event_get(pdisp
->vblank
, head
, &drm
->vblank
[head
]);
98 nouveau_drm_vblank_disable(struct drm_device
*dev
, int head
)
100 struct nouveau_drm
*drm
= nouveau_drm(dev
);
101 struct nouveau_disp
*pdisp
= nouveau_disp(drm
->device
);
102 if (drm
->vblank
[head
].func
)
103 nouveau_event_put(pdisp
->vblank
, head
, &drm
->vblank
[head
]);
106 drm
->vblank
[head
].func
= NULL
;
110 nouveau_name(struct pci_dev
*pdev
)
112 u64 name
= (u64
)pci_domain_nr(pdev
->bus
) << 32;
113 name
|= pdev
->bus
->number
<< 16;
114 name
|= PCI_SLOT(pdev
->devfn
) << 8;
115 return name
| PCI_FUNC(pdev
->devfn
);
119 nouveau_cli_create(struct pci_dev
*pdev
, const char *name
,
120 int size
, void **pcli
)
122 struct nouveau_cli
*cli
;
126 ret
= nouveau_client_create_(name
, nouveau_name(pdev
), nouveau_config
,
127 nouveau_debug
, size
, pcli
);
131 nouveau_client_destroy(&cli
->base
);
136 mutex_init(&cli
->mutex
);
141 nouveau_cli_destroy(struct nouveau_cli
*cli
)
143 struct nouveau_object
*client
= nv_object(cli
);
144 nouveau_vm_ref(NULL
, &cli
->base
.vm
, NULL
);
145 nouveau_client_fini(&cli
->base
, false);
146 atomic_set(&client
->refcount
, 1);
147 nouveau_object_ref(NULL
, &client
);
151 nouveau_accel_fini(struct nouveau_drm
*drm
)
153 nouveau_gpuobj_ref(NULL
, &drm
->notify
);
154 nouveau_channel_del(&drm
->channel
);
155 nouveau_channel_del(&drm
->cechan
);
157 nouveau_fence(drm
)->dtor(drm
);
161 nouveau_accel_init(struct nouveau_drm
*drm
)
163 struct nouveau_device
*device
= nv_device(drm
->device
);
164 struct nouveau_object
*object
;
168 if (nouveau_noaccel
|| !nouveau_fifo(device
) /*XXX*/)
171 /* initialise synchronisation routines */
172 if (device
->card_type
< NV_10
) ret
= nv04_fence_create(drm
);
173 else if (device
->chipset
< 0x17) ret
= nv10_fence_create(drm
);
174 else if (device
->card_type
< NV_50
) ret
= nv17_fence_create(drm
);
175 else if (device
->chipset
< 0x84) ret
= nv50_fence_create(drm
);
176 else if (device
->card_type
< NV_C0
) ret
= nv84_fence_create(drm
);
177 else ret
= nvc0_fence_create(drm
);
179 NV_ERROR(drm
, "failed to initialise sync subsystem, %d\n", ret
);
180 nouveau_accel_fini(drm
);
184 if (device
->card_type
>= NV_E0
) {
185 ret
= nouveau_channel_new(drm
, &drm
->client
, NVDRM_DEVICE
,
187 NVE0_CHANNEL_IND_ENGINE_CE0
|
188 NVE0_CHANNEL_IND_ENGINE_CE1
, 0,
191 NV_ERROR(drm
, "failed to create ce channel, %d\n", ret
);
193 arg0
= NVE0_CHANNEL_IND_ENGINE_GR
;
200 ret
= nouveau_channel_new(drm
, &drm
->client
, NVDRM_DEVICE
, NVDRM_CHAN
,
201 arg0
, arg1
, &drm
->channel
);
203 NV_ERROR(drm
, "failed to create kernel channel, %d\n", ret
);
204 nouveau_accel_fini(drm
);
208 if (device
->card_type
< NV_C0
) {
209 ret
= nouveau_gpuobj_new(drm
->device
, NULL
, 32, 0, 0,
212 NV_ERROR(drm
, "failed to allocate notifier, %d\n", ret
);
213 nouveau_accel_fini(drm
);
217 ret
= nouveau_object_new(nv_object(drm
),
218 drm
->channel
->handle
, NvNotify0
,
219 0x003d, &(struct nv_dma_class
) {
220 .flags
= NV_DMA_TARGET_VRAM
|
222 .start
= drm
->notify
->addr
,
223 .limit
= drm
->notify
->addr
+ 31
224 }, sizeof(struct nv_dma_class
),
227 nouveau_accel_fini(drm
);
233 nouveau_bo_move_init(drm
);
236 static int nouveau_drm_probe(struct pci_dev
*pdev
,
237 const struct pci_device_id
*pent
)
239 struct nouveau_device
*device
;
240 struct apertures_struct
*aper
;
244 /* remove conflicting drivers (vesafb, efifb etc) */
245 aper
= alloc_apertures(3);
249 aper
->ranges
[0].base
= pci_resource_start(pdev
, 1);
250 aper
->ranges
[0].size
= pci_resource_len(pdev
, 1);
253 if (pci_resource_len(pdev
, 2)) {
254 aper
->ranges
[aper
->count
].base
= pci_resource_start(pdev
, 2);
255 aper
->ranges
[aper
->count
].size
= pci_resource_len(pdev
, 2);
259 if (pci_resource_len(pdev
, 3)) {
260 aper
->ranges
[aper
->count
].base
= pci_resource_start(pdev
, 3);
261 aper
->ranges
[aper
->count
].size
= pci_resource_len(pdev
, 3);
266 boot
= pdev
->resource
[PCI_ROM_RESOURCE
].flags
& IORESOURCE_ROM_SHADOW
;
268 remove_conflicting_framebuffers(aper
, "nouveaufb", boot
);
271 ret
= nouveau_device_create(pdev
, nouveau_name(pdev
), pci_name(pdev
),
272 nouveau_config
, nouveau_debug
, &device
);
276 pci_set_master(pdev
);
278 ret
= drm_get_pci_dev(pdev
, pent
, &driver
);
280 nouveau_object_ref(NULL
, (struct nouveau_object
**)&device
);
287 static struct lock_class_key drm_client_lock_class_key
;
290 nouveau_drm_load(struct drm_device
*dev
, unsigned long flags
)
292 struct pci_dev
*pdev
= dev
->pdev
;
293 struct nouveau_device
*device
;
294 struct nouveau_drm
*drm
;
297 ret
= nouveau_cli_create(pdev
, "DRM", sizeof(*drm
), (void**)&drm
);
300 lockdep_set_class(&drm
->client
.mutex
, &drm_client_lock_class_key
);
302 dev
->dev_private
= drm
;
305 INIT_LIST_HEAD(&drm
->clients
);
306 spin_lock_init(&drm
->tile
.lock
);
308 /* make sure AGP controller is in a consistent state before we
309 * (possibly) execute vbios init tables (see nouveau_agp.h)
311 if (drm_pci_device_is_agp(dev
) && dev
->agp
) {
312 /* dummy device object, doesn't init anything, but allows
313 * agp code access to registers
315 ret
= nouveau_object_new(nv_object(drm
), NVDRM_CLIENT
,
316 NVDRM_DEVICE
, 0x0080,
317 &(struct nv_device_class
) {
320 ~(NV_DEVICE_DISABLE_MMIO
|
321 NV_DEVICE_DISABLE_IDENTIFY
),
323 }, sizeof(struct nv_device_class
),
328 nouveau_agp_reset(drm
);
329 nouveau_object_del(nv_object(drm
), NVDRM_CLIENT
, NVDRM_DEVICE
);
332 ret
= nouveau_object_new(nv_object(drm
), NVDRM_CLIENT
, NVDRM_DEVICE
,
333 0x0080, &(struct nv_device_class
) {
337 }, sizeof(struct nv_device_class
),
342 /* workaround an odd issue on nvc1 by disabling the device's
343 * nosnoop capability. hopefully won't cause issues until a
344 * better fix is found - assuming there is one...
346 device
= nv_device(drm
->device
);
347 if (nv_device(drm
->device
)->chipset
== 0xc1)
348 nv_mask(device
, 0x00088080, 0x00000800, 0x00000000);
350 nouveau_vga_init(drm
);
351 nouveau_agp_init(drm
);
353 if (device
->card_type
>= NV_50
) {
354 ret
= nouveau_vm_new(nv_device(drm
->device
), 0, (1ULL << 40),
355 0x1000, &drm
->client
.base
.vm
);
360 ret
= nouveau_ttm_init(drm
);
364 ret
= nouveau_bios_init(dev
);
368 ret
= nouveau_display_create(dev
);
372 if (dev
->mode_config
.num_crtc
) {
373 ret
= nouveau_display_init(dev
);
378 nouveau_pm_init(dev
);
380 nouveau_accel_init(drm
);
381 nouveau_fbcon_init(dev
);
385 nouveau_display_destroy(dev
);
387 nouveau_bios_takedown(dev
);
389 nouveau_ttm_fini(drm
);
391 nouveau_agp_fini(drm
);
392 nouveau_vga_fini(drm
);
394 nouveau_cli_destroy(&drm
->client
);
399 nouveau_drm_unload(struct drm_device
*dev
)
401 struct nouveau_drm
*drm
= nouveau_drm(dev
);
403 nouveau_fbcon_fini(dev
);
404 nouveau_accel_fini(drm
);
406 nouveau_pm_fini(dev
);
408 if (dev
->mode_config
.num_crtc
)
409 nouveau_display_fini(dev
);
410 nouveau_display_destroy(dev
);
412 nouveau_bios_takedown(dev
);
414 nouveau_ttm_fini(drm
);
415 nouveau_agp_fini(drm
);
416 nouveau_vga_fini(drm
);
418 nouveau_cli_destroy(&drm
->client
);
423 nouveau_drm_remove(struct pci_dev
*pdev
)
425 struct drm_device
*dev
= pci_get_drvdata(pdev
);
426 struct nouveau_drm
*drm
= nouveau_drm(dev
);
427 struct nouveau_object
*device
;
429 device
= drm
->client
.base
.device
;
432 nouveau_object_ref(NULL
, &device
);
433 nouveau_object_debug();
437 nouveau_do_suspend(struct drm_device
*dev
)
439 struct nouveau_drm
*drm
= nouveau_drm(dev
);
440 struct nouveau_cli
*cli
;
443 if (dev
->mode_config
.num_crtc
) {
444 NV_INFO(drm
, "suspending fbcon...\n");
445 nouveau_fbcon_set_suspend(dev
, 1);
447 NV_INFO(drm
, "suspending display...\n");
448 ret
= nouveau_display_suspend(dev
);
453 NV_INFO(drm
, "evicting buffers...\n");
454 ttm_bo_evict_mm(&drm
->ttm
.bdev
, TTM_PL_VRAM
);
456 NV_INFO(drm
, "waiting for kernel channels to go idle...\n");
458 ret
= nouveau_channel_idle(drm
->cechan
);
464 ret
= nouveau_channel_idle(drm
->channel
);
469 NV_INFO(drm
, "suspending client object trees...\n");
470 if (drm
->fence
&& nouveau_fence(drm
)->suspend
) {
471 if (!nouveau_fence(drm
)->suspend(drm
))
475 list_for_each_entry(cli
, &drm
->clients
, head
) {
476 ret
= nouveau_client_fini(&cli
->base
, true);
481 NV_INFO(drm
, "suspending kernel object tree...\n");
482 ret
= nouveau_client_fini(&drm
->client
.base
, true);
486 nouveau_agp_fini(drm
);
490 list_for_each_entry_continue_reverse(cli
, &drm
->clients
, head
) {
491 nouveau_client_init(&cli
->base
);
494 if (dev
->mode_config
.num_crtc
) {
495 NV_INFO(drm
, "resuming display...\n");
496 nouveau_display_resume(dev
);
501 int nouveau_pmops_suspend(struct device
*dev
)
503 struct pci_dev
*pdev
= to_pci_dev(dev
);
504 struct drm_device
*drm_dev
= pci_get_drvdata(pdev
);
507 if (drm_dev
->switch_power_state
== DRM_SWITCH_POWER_OFF
)
510 ret
= nouveau_do_suspend(drm_dev
);
514 pci_save_state(pdev
);
515 pci_disable_device(pdev
);
516 pci_set_power_state(pdev
, PCI_D3hot
);
522 nouveau_do_resume(struct drm_device
*dev
)
524 struct nouveau_drm
*drm
= nouveau_drm(dev
);
525 struct nouveau_cli
*cli
;
527 NV_INFO(drm
, "re-enabling device...\n");
529 nouveau_agp_reset(drm
);
531 NV_INFO(drm
, "resuming kernel object tree...\n");
532 nouveau_client_init(&drm
->client
.base
);
533 nouveau_agp_init(drm
);
535 NV_INFO(drm
, "resuming client object trees...\n");
536 if (drm
->fence
&& nouveau_fence(drm
)->resume
)
537 nouveau_fence(drm
)->resume(drm
);
539 list_for_each_entry(cli
, &drm
->clients
, head
) {
540 nouveau_client_init(&cli
->base
);
543 nouveau_run_vbios_init(dev
);
544 nouveau_pm_resume(dev
);
546 if (dev
->mode_config
.num_crtc
) {
547 NV_INFO(drm
, "resuming display...\n");
548 nouveau_display_resume(dev
);
553 int nouveau_pmops_resume(struct device
*dev
)
555 struct pci_dev
*pdev
= to_pci_dev(dev
);
556 struct drm_device
*drm_dev
= pci_get_drvdata(pdev
);
559 if (drm_dev
->switch_power_state
== DRM_SWITCH_POWER_OFF
)
562 pci_set_power_state(pdev
, PCI_D0
);
563 pci_restore_state(pdev
);
564 ret
= pci_enable_device(pdev
);
567 pci_set_master(pdev
);
569 return nouveau_do_resume(drm_dev
);
572 static int nouveau_pmops_freeze(struct device
*dev
)
574 struct pci_dev
*pdev
= to_pci_dev(dev
);
575 struct drm_device
*drm_dev
= pci_get_drvdata(pdev
);
577 return nouveau_do_suspend(drm_dev
);
580 static int nouveau_pmops_thaw(struct device
*dev
)
582 struct pci_dev
*pdev
= to_pci_dev(dev
);
583 struct drm_device
*drm_dev
= pci_get_drvdata(pdev
);
585 return nouveau_do_resume(drm_dev
);
590 nouveau_drm_open(struct drm_device
*dev
, struct drm_file
*fpriv
)
592 struct pci_dev
*pdev
= dev
->pdev
;
593 struct nouveau_drm
*drm
= nouveau_drm(dev
);
594 struct nouveau_cli
*cli
;
595 char name
[32], tmpname
[TASK_COMM_LEN
];
598 get_task_comm(tmpname
, current
);
599 snprintf(name
, sizeof(name
), "%s[%d]", tmpname
, pid_nr(fpriv
->pid
));
601 ret
= nouveau_cli_create(pdev
, name
, sizeof(*cli
), (void **)&cli
);
605 if (nv_device(drm
->device
)->card_type
>= NV_50
) {
606 ret
= nouveau_vm_new(nv_device(drm
->device
), 0, (1ULL << 40),
607 0x1000, &cli
->base
.vm
);
609 nouveau_cli_destroy(cli
);
614 fpriv
->driver_priv
= cli
;
616 mutex_lock(&drm
->client
.mutex
);
617 list_add(&cli
->head
, &drm
->clients
);
618 mutex_unlock(&drm
->client
.mutex
);
623 nouveau_drm_preclose(struct drm_device
*dev
, struct drm_file
*fpriv
)
625 struct nouveau_cli
*cli
= nouveau_cli(fpriv
);
626 struct nouveau_drm
*drm
= nouveau_drm(dev
);
629 nouveau_abi16_fini(cli
->abi16
);
631 mutex_lock(&drm
->client
.mutex
);
632 list_del(&cli
->head
);
633 mutex_unlock(&drm
->client
.mutex
);
637 nouveau_drm_postclose(struct drm_device
*dev
, struct drm_file
*fpriv
)
639 struct nouveau_cli
*cli
= nouveau_cli(fpriv
);
640 nouveau_cli_destroy(cli
);
643 static struct drm_ioctl_desc
645 DRM_IOCTL_DEF_DRV(NOUVEAU_GETPARAM
, nouveau_abi16_ioctl_getparam
, DRM_UNLOCKED
|DRM_AUTH
),
646 DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM
, nouveau_abi16_ioctl_setparam
, DRM_UNLOCKED
|DRM_AUTH
|DRM_MASTER
|DRM_ROOT_ONLY
),
647 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC
, nouveau_abi16_ioctl_channel_alloc
, DRM_UNLOCKED
|DRM_AUTH
),
648 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE
, nouveau_abi16_ioctl_channel_free
, DRM_UNLOCKED
|DRM_AUTH
),
649 DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC
, nouveau_abi16_ioctl_grobj_alloc
, DRM_UNLOCKED
|DRM_AUTH
),
650 DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC
, nouveau_abi16_ioctl_notifierobj_alloc
, DRM_UNLOCKED
|DRM_AUTH
),
651 DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE
, nouveau_abi16_ioctl_gpuobj_free
, DRM_UNLOCKED
|DRM_AUTH
),
652 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW
, nouveau_gem_ioctl_new
, DRM_UNLOCKED
|DRM_AUTH
),
653 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF
, nouveau_gem_ioctl_pushbuf
, DRM_UNLOCKED
|DRM_AUTH
),
654 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP
, nouveau_gem_ioctl_cpu_prep
, DRM_UNLOCKED
|DRM_AUTH
),
655 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI
, nouveau_gem_ioctl_cpu_fini
, DRM_UNLOCKED
|DRM_AUTH
),
656 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO
, nouveau_gem_ioctl_info
, DRM_UNLOCKED
|DRM_AUTH
),
659 static const struct file_operations
660 nouveau_driver_fops
= {
661 .owner
= THIS_MODULE
,
663 .release
= drm_release
,
664 .unlocked_ioctl
= drm_ioctl
,
665 .mmap
= nouveau_ttm_mmap
,
667 .fasync
= drm_fasync
,
669 #if defined(CONFIG_COMPAT)
670 .compat_ioctl
= nouveau_compat_ioctl
,
672 .llseek
= noop_llseek
,
675 static struct drm_driver
678 DRIVER_USE_AGP
| DRIVER_PCI_DMA
| DRIVER_SG
|
679 DRIVER_GEM
| DRIVER_MODESET
| DRIVER_PRIME
,
681 .load
= nouveau_drm_load
,
682 .unload
= nouveau_drm_unload
,
683 .open
= nouveau_drm_open
,
684 .preclose
= nouveau_drm_preclose
,
685 .postclose
= nouveau_drm_postclose
,
686 .lastclose
= nouveau_vga_lastclose
,
688 #if defined(CONFIG_DEBUG_FS)
689 .debugfs_init
= nouveau_debugfs_init
,
690 .debugfs_cleanup
= nouveau_debugfs_takedown
,
693 .get_vblank_counter
= drm_vblank_count
,
694 .enable_vblank
= nouveau_drm_vblank_enable
,
695 .disable_vblank
= nouveau_drm_vblank_disable
,
697 .ioctls
= nouveau_ioctls
,
698 .fops
= &nouveau_driver_fops
,
700 .prime_handle_to_fd
= drm_gem_prime_handle_to_fd
,
701 .prime_fd_to_handle
= drm_gem_prime_fd_to_handle
,
702 .gem_prime_export
= drm_gem_prime_export
,
703 .gem_prime_import
= drm_gem_prime_import
,
704 .gem_prime_pin
= nouveau_gem_prime_pin
,
705 .gem_prime_get_sg_table
= nouveau_gem_prime_get_sg_table
,
706 .gem_prime_import_sg_table
= nouveau_gem_prime_import_sg_table
,
707 .gem_prime_vmap
= nouveau_gem_prime_vmap
,
708 .gem_prime_vunmap
= nouveau_gem_prime_vunmap
,
710 .gem_init_object
= nouveau_gem_object_new
,
711 .gem_free_object
= nouveau_gem_object_del
,
712 .gem_open_object
= nouveau_gem_object_open
,
713 .gem_close_object
= nouveau_gem_object_close
,
715 .dumb_create
= nouveau_display_dumb_create
,
716 .dumb_map_offset
= nouveau_display_dumb_map_offset
,
717 .dumb_destroy
= nouveau_display_dumb_destroy
,
722 .date
= GIT_REVISION
,
726 .major
= DRIVER_MAJOR
,
727 .minor
= DRIVER_MINOR
,
728 .patchlevel
= DRIVER_PATCHLEVEL
,
731 static struct pci_device_id
732 nouveau_drm_pci_table
[] = {
734 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA
, PCI_ANY_ID
),
735 .class = PCI_BASE_CLASS_DISPLAY
<< 16,
736 .class_mask
= 0xff << 16,
739 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS
, PCI_ANY_ID
),
740 .class = PCI_BASE_CLASS_DISPLAY
<< 16,
741 .class_mask
= 0xff << 16,
746 static const struct dev_pm_ops nouveau_pm_ops
= {
747 .suspend
= nouveau_pmops_suspend
,
748 .resume
= nouveau_pmops_resume
,
749 .freeze
= nouveau_pmops_freeze
,
750 .thaw
= nouveau_pmops_thaw
,
751 .poweroff
= nouveau_pmops_freeze
,
752 .restore
= nouveau_pmops_resume
,
755 static struct pci_driver
756 nouveau_drm_pci_driver
= {
758 .id_table
= nouveau_drm_pci_table
,
759 .probe
= nouveau_drm_probe
,
760 .remove
= nouveau_drm_remove
,
761 .driver
.pm
= &nouveau_pm_ops
,
765 nouveau_drm_init(void)
767 driver
.num_ioctls
= ARRAY_SIZE(nouveau_ioctls
);
769 if (nouveau_modeset
== -1) {
770 #ifdef CONFIG_VGA_CONSOLE
771 if (vgacon_text_force())
776 if (!nouveau_modeset
)
779 nouveau_register_dsm_handler();
780 return drm_pci_init(&driver
, &nouveau_drm_pci_driver
);
784 nouveau_drm_exit(void)
786 if (!nouveau_modeset
)
789 drm_pci_exit(&driver
, &nouveau_drm_pci_driver
);
790 nouveau_unregister_dsm_handler();
793 module_init(nouveau_drm_init
);
794 module_exit(nouveau_drm_exit
);
796 MODULE_DEVICE_TABLE(pci
, nouveau_drm_pci_table
);
797 MODULE_AUTHOR(DRIVER_AUTHOR
);
798 MODULE_DESCRIPTION(DRIVER_DESC
);
799 MODULE_LICENSE("GPL and additional rights");