Set memory attributes on page
[pscnv.git] / pscnv / nouveau_drv.c
bloba70edd935f44d37a4b9e265436977ecde9007c3a
1 /*
2 * Copyright 2005 Stephane Marchesin.
3 * All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <linux/console.h>
26 #include <linux/version.h>
27 #include <linux/module.h>
29 #include "nouveau_drv.h"
30 #include "drm.h"
31 #include "drm_crtc_helper.h"
32 #include "nouveau_pm.h"
33 #include "pscnv_gem.h"
34 #include "pscnv_vm.h"
35 #if 0
36 #include "nouveau_hw.h"
37 #include "nouveau_fb.h"
38 #include "nouveau_fbcon.h"
39 #include "nv50_display.h"
40 #endif
42 #include "drm_pciids.h"
43 #include "pscnv_kapi.h"
44 #include "pscnv_ioctl.h"
46 MODULE_PARM_DESC(agpmode, "AGP mode (0 to disable AGP)");
47 int nouveau_agpmode = -1;
48 module_param_named(agpmode, nouveau_agpmode, int, 0400);
50 MODULE_PARM_DESC(modeset, "Enable kernel modesetting");
51 static int nouveau_modeset = 1; /* kms */
52 module_param_named(modeset, nouveau_modeset, int, 0400);
54 MODULE_PARM_DESC(vbios, "Override default VBIOS location");
55 char *nouveau_vbios;
56 module_param_named(vbios, nouveau_vbios, charp, 0400);
58 MODULE_PARM_DESC(duallink, "Allow dual-link TMDS (>=GeForce 8)");
59 int nouveau_duallink = 1;
60 module_param_named(duallink, nouveau_duallink, int, 0400);
62 MODULE_PARM_DESC(uscript_lvds, "LVDS output script table ID (>=GeForce 8)");
63 int nouveau_uscript_lvds = -1;
64 module_param_named(uscript_lvds, nouveau_uscript_lvds, int, 0400);
66 MODULE_PARM_DESC(uscript_tmds, "TMDS output script table ID (>=GeForce 8)");
67 int nouveau_uscript_tmds = -1;
68 module_param_named(uscript_tmds, nouveau_uscript_tmds, int, 0400);
70 MODULE_PARM_DESC(ignorelid, "Ignore ACPI lid status");
71 int nouveau_ignorelid = 0;
72 module_param_named(ignorelid, nouveau_ignorelid, int, 0400);
74 MODULE_PARM_DESC(noaccel, "Disable all acceleration");
75 int nouveau_noaccel = 0;
76 module_param_named(noaccel, nouveau_noaccel, int, 0400);
78 MODULE_PARM_DESC(nofbaccel, "Disable fbcon acceleration");
79 int nouveau_nofbaccel = 0;
80 module_param_named(nofbaccel, nouveau_nofbaccel, int, 0400);
82 MODULE_PARM_DESC(force_post, "Force POST");
83 int nouveau_force_post = 0;
84 module_param_named(force_post, nouveau_force_post, int, 0400);
86 MODULE_PARM_DESC(override_conntype, "Ignore DCB connector type");
87 int nouveau_override_conntype = 0;
88 module_param_named(override_conntype, nouveau_override_conntype, int, 0400);
90 MODULE_PARM_DESC(tv_disable, "Disable TV-out detection\n");
91 int nouveau_tv_disable = 0;
92 module_param_named(tv_disable, nouveau_tv_disable, int, 0400);
94 MODULE_PARM_DESC(tv_norm, "Default TV norm.\n"
95 "\t\tSupported: PAL, PAL-M, PAL-N, PAL-Nc, NTSC-M, NTSC-J,\n"
96 "\t\t\thd480i, hd480p, hd576i, hd576p, hd720p, hd1080i.\n"
97 "\t\tDefault: PAL\n"
98 "\t\t*NOTE* Ignored for cards with external TV encoders.");
99 char *nouveau_tv_norm;
100 module_param_named(tv_norm, nouveau_tv_norm, charp, 0400);
102 MODULE_PARM_DESC(reg_debug, "Register access debug bitmask:\n"
103 "\t\t0x1 mc, 0x2 video, 0x4 fb, 0x8 extdev,\n"
104 "\t\t0x10 crtc, 0x20 ramdac, 0x40 vgacrtc, 0x80 rmvio,\n"
105 "\t\t0x100 vgaattr, 0x200 EVO (G80+). ");
106 int nouveau_reg_debug;
107 module_param_named(reg_debug, nouveau_reg_debug, int, 0600);
109 MODULE_PARM_DESC(perflvl, "Performance level (default: boot)\n");
110 char *nouveau_perflvl;
111 module_param_named(perflvl, nouveau_perflvl, charp, 0400);
113 MODULE_PARM_DESC(perflvl_wr, "Allow perflvl changes (warning: dangerous!)\n");
114 int nouveau_perflvl_wr;
115 module_param_named(perflvl_wr, nouveau_perflvl_wr, int, 0400);
117 MODULE_PARM_DESC(mm_debug, "mm debug level: 0-2.");
118 int pscnv_mm_debug = 0;
119 module_param_named(mm_debug, pscnv_mm_debug, int, 0400);
121 MODULE_PARM_DESC(mem_debug, "memory debug level: 0-1.");
122 int pscnv_mem_debug = 0;
123 module_param_named(mem_debug, pscnv_mem_debug, int, 0400);
125 MODULE_PARM_DESC(vm_debug, "VM debug level: 0-2.");
126 int pscnv_vm_debug = 0;
127 module_param_named(vm_debug, pscnv_vm_debug, int, 0400);
129 MODULE_PARM_DESC(ramht_debug, "RAMHT debug level: 0-2.");
130 int pscnv_ramht_debug = 0;
131 module_param_named(ramht_debug, pscnv_ramht_debug, int, 0400);
133 MODULE_PARM_DESC(gem_debug, "GEM debug level: 0-1.");
134 int pscnv_gem_debug = 0;
135 module_param_named(gem_debug, pscnv_gem_debug, int, 0400);
137 int nouveau_fbpercrtc;
138 #if 0
139 module_param_named(fbpercrtc, nouveau_fbpercrtc, int, 0400);
140 #endif
142 #ifdef PSCNV_KAPI_DRM_IOCTL_DEF_DRV
143 static struct drm_ioctl_desc nouveau_ioctls[] = {
144 DRM_IOCTL_DEF_DRV(PSCNV_GETPARAM, pscnv_ioctl_getparam, DRM_UNLOCKED),
145 DRM_IOCTL_DEF_DRV(PSCNV_GEM_NEW, pscnv_ioctl_gem_new, DRM_UNLOCKED),
146 DRM_IOCTL_DEF_DRV(PSCNV_GEM_INFO, pscnv_ioctl_gem_info, DRM_UNLOCKED),
147 DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_NEW, pscnv_ioctl_vspace_new, DRM_UNLOCKED),
148 DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_FREE, pscnv_ioctl_vspace_free, DRM_UNLOCKED),
149 DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_MAP, pscnv_ioctl_vspace_map, DRM_UNLOCKED),
150 DRM_IOCTL_DEF_DRV(PSCNV_VSPACE_UNMAP, pscnv_ioctl_vspace_unmap, DRM_UNLOCKED),
151 DRM_IOCTL_DEF_DRV(PSCNV_CHAN_NEW, pscnv_ioctl_chan_new, DRM_UNLOCKED),
152 DRM_IOCTL_DEF_DRV(PSCNV_CHAN_FREE, pscnv_ioctl_chan_free, DRM_UNLOCKED),
153 DRM_IOCTL_DEF_DRV(PSCNV_OBJ_VDMA_NEW, pscnv_ioctl_obj_vdma_new, DRM_UNLOCKED),
154 DRM_IOCTL_DEF_DRV(PSCNV_FIFO_INIT, pscnv_ioctl_fifo_init, DRM_UNLOCKED),
155 DRM_IOCTL_DEF_DRV(PSCNV_OBJ_ENG_NEW, pscnv_ioctl_obj_eng_new, DRM_UNLOCKED),
156 DRM_IOCTL_DEF_DRV(PSCNV_FIFO_INIT_IB, pscnv_ioctl_fifo_init_ib, DRM_UNLOCKED),
158 #elif defined(PSCNV_KAPI_DRM_IOCTL_DEF)
159 static struct drm_ioctl_desc nouveau_ioctls[] = {
160 DRM_IOCTL_DEF(DRM_PSCNV_GETPARAM, pscnv_ioctl_getparam, DRM_UNLOCKED),
161 DRM_IOCTL_DEF(DRM_PSCNV_GEM_NEW, pscnv_ioctl_gem_new, DRM_UNLOCKED),
162 DRM_IOCTL_DEF(DRM_PSCNV_GEM_INFO, pscnv_ioctl_gem_info, DRM_UNLOCKED),
163 DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_NEW, pscnv_ioctl_vspace_new, DRM_UNLOCKED),
164 DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_FREE, pscnv_ioctl_vspace_free, DRM_UNLOCKED),
165 DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_MAP, pscnv_ioctl_vspace_map, DRM_UNLOCKED),
166 DRM_IOCTL_DEF(DRM_PSCNV_VSPACE_UNMAP, pscnv_ioctl_vspace_unmap, DRM_UNLOCKED),
167 DRM_IOCTL_DEF(DRM_PSCNV_CHAN_NEW, pscnv_ioctl_chan_new, DRM_UNLOCKED),
168 DRM_IOCTL_DEF(DRM_PSCNV_CHAN_FREE, pscnv_ioctl_chan_free, DRM_UNLOCKED),
169 DRM_IOCTL_DEF(DRM_PSCNV_OBJ_VDMA_NEW, pscnv_ioctl_obj_vdma_new, DRM_UNLOCKED),
170 DRM_IOCTL_DEF(DRM_PSCNV_FIFO_INIT, pscnv_ioctl_fifo_init, DRM_UNLOCKED),
171 DRM_IOCTL_DEF(DRM_PSCNV_OBJ_ENG_NEW, pscnv_ioctl_obj_eng_new, DRM_UNLOCKED),
172 DRM_IOCTL_DEF(DRM_PSCNV_FIFO_INIT_IB, pscnv_ioctl_fifo_init_ib, DRM_UNLOCKED),
174 #else
175 #error "Unknown IOCTLDEF method."
176 #endif
178 static struct pci_device_id pciidlist[] = {
180 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
181 .class = PCI_BASE_CLASS_DISPLAY << 16,
182 .class_mask = 0xff << 16,
185 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID),
186 .class = PCI_BASE_CLASS_DISPLAY << 16,
187 .class_mask = 0xff << 16,
192 MODULE_DEVICE_TABLE(pci, pciidlist);
194 static struct drm_driver driver;
196 static int __devinit
197 nouveau_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
199 #ifdef PSCNV_KAPI_DRM_GET_DEV
200 return drm_get_dev(pdev, ent, &driver);
201 #else
202 return drm_get_pci_dev(pdev, ent, &driver);
203 #endif
206 static void
207 nouveau_pci_remove(struct pci_dev *pdev)
209 struct drm_device *dev = pci_get_drvdata(pdev);
211 drm_put_dev(dev);
215 nouveau_pci_suspend(struct pci_dev *pdev, pm_message_t pm_state)
217 return -ENODEV;
218 #if 0
219 struct drm_device *dev = pci_get_drvdata(pdev);
220 struct drm_nouveau_private *dev_priv = dev->dev_private;
221 struct nouveau_instmem_engine *pinstmem = &dev_priv->engine.instmem;
222 struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
223 struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
224 struct nouveau_channel *chan;
225 struct drm_crtc *crtc;
226 int ret, i;
228 if (!drm_core_check_feature(dev, DRIVER_MODESET))
229 return -ENODEV;
231 if (pm_state.event == PM_EVENT_PRETHAW)
232 return 0;
234 NV_INFO(dev, "Disabling fbcon acceleration...\n");
235 nouveau_fbcon_save_disable_accel(dev);
237 NV_INFO(dev, "Unpinning framebuffer(s)...\n");
238 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
239 struct nouveau_framebuffer *nouveau_fb;
241 nouveau_fb = nouveau_framebuffer(crtc->fb);
242 if (!nouveau_fb || !nouveau_fb->nvbo)
243 continue;
245 nouveau_bo_unpin(nouveau_fb->nvbo);
248 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
249 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
251 nouveau_bo_unmap(nv_crtc->cursor.nvbo);
252 nouveau_bo_unpin(nv_crtc->cursor.nvbo);
255 NV_INFO(dev, "Evicting buffers...\n");
256 ttm_bo_evict_mm(&dev_priv->ttm.bdev, TTM_PL_VRAM);
258 NV_INFO(dev, "Idling channels...\n");
259 for (i = 0; i < pfifo->channels; i++) {
260 struct nouveau_fence *fence = NULL;
262 chan = dev_priv->channels.ptr[i];
263 if (!chan || !chan->pushbuf_bo)
264 continue;
266 ret = nouveau_fence_new(chan, &fence, true);
267 if (ret == 0) {
268 ret = nouveau_fence_wait(fence, NULL, false, false);
269 nouveau_fence_unref((void *)&fence);
272 if (ret) {
273 NV_ERROR(dev, "Failed to idle channel %d for suspend\n",
274 chan->id);
278 pgraph->fifo_access(dev, false);
279 nouveau_wait_for_idle(dev);
280 pfifo->reassign(dev, false);
281 pfifo->disable(dev);
282 pfifo->unload_context(dev);
283 pgraph->unload_context(dev);
285 NV_INFO(dev, "Suspending GPU objects...\n");
286 ret = nouveau_gpuobj_suspend(dev);
287 if (ret) {
288 NV_ERROR(dev, "... failed: %d\n", ret);
289 goto out_abort;
292 ret = pinstmem->suspend(dev);
293 if (ret) {
294 NV_ERROR(dev, "... failed: %d\n", ret);
295 nouveau_gpuobj_suspend_cleanup(dev);
296 goto out_abort;
299 NV_INFO(dev, "And we're gone!\n");
300 pci_save_state(pdev);
301 if (pm_state.event == PM_EVENT_SUSPEND) {
302 pci_disable_device(pdev);
303 pci_set_power_state(pdev, PCI_D3hot);
306 acquire_console_sem();
307 nouveau_fbcon_set_suspend(dev, 1);
308 release_console_sem();
309 nouveau_fbcon_restore_accel(dev);
310 return 0;
312 out_abort:
313 NV_INFO(dev, "Re-enabling acceleration..\n");
314 pfifo->enable(dev);
315 pfifo->reassign(dev, true);
316 pgraph->fifo_access(dev, true);
317 return ret;
318 #endif
322 nouveau_pci_resume(struct pci_dev *pdev)
324 return -ENODEV;
325 #if 0
326 struct drm_device *dev = pci_get_drvdata(pdev);
327 struct drm_nouveau_private *dev_priv = dev->dev_private;
328 struct nouveau_engine *engine = &dev_priv->engine;
329 struct drm_crtc *crtc;
330 int ret, i;
332 if (!drm_core_check_feature(dev, DRIVER_MODESET))
333 return -ENODEV;
335 nouveau_fbcon_save_disable_accel(dev);
337 NV_INFO(dev, "We're back, enabling device...\n");
338 pci_set_power_state(pdev, PCI_D0);
339 pci_restore_state(pdev);
340 if (pci_enable_device(pdev))
341 return -1;
342 pci_set_master(dev->pdev);
344 NV_INFO(dev, "POSTing device...\n");
345 ret = nouveau_run_vbios_init(dev);
346 if (ret)
347 return ret;
349 nouveau_pm_resume(dev);
351 if (dev_priv->gart_info.type == NOUVEAU_GART_AGP) {
352 ret = nouveau_mem_init_agp(dev);
353 if (ret) {
354 NV_ERROR(dev, "error reinitialising AGP: %d\n", ret);
355 return ret;
359 NV_INFO(dev, "Reinitialising engines...\n");
360 engine->instmem.resume(dev);
361 engine->mc.init(dev);
362 engine->timer.init(dev);
363 engine->fb.init(dev);
364 engine->graph.init(dev);
365 engine->fifo.init(dev);
367 NV_INFO(dev, "Restoring GPU objects...\n");
368 nouveau_gpuobj_resume(dev);
370 nouveau_irq_postinstall(dev);
372 /* Re-write SKIPS, they'll have been lost over the suspend */
373 if (nouveau_vram_pushbuf) {
374 struct nouveau_channel *chan;
375 int j;
377 for (i = 0; i < dev_priv->engine.fifo.channels; i++) {
378 chan = dev_priv->channels.ptr[i];
379 if (!chan || !chan->pushbuf_bo)
380 continue;
382 for (j = 0; j < NOUVEAU_DMA_SKIPS; j++)
383 nouveau_bo_wr32(chan->pushbuf_bo, i, 0);
387 NV_INFO(dev, "Restoring mode...\n");
388 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
389 struct nouveau_framebuffer *nouveau_fb;
391 nouveau_fb = nouveau_framebuffer(crtc->fb);
392 if (!nouveau_fb || !nouveau_fb->nvbo)
393 continue;
395 nouveau_bo_pin(nouveau_fb->nvbo, TTM_PL_FLAG_VRAM);
398 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
399 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
400 int ret;
402 ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM);
403 if (!ret)
404 ret = nouveau_bo_map(nv_crtc->cursor.nvbo);
405 if (ret)
406 NV_ERROR(dev, "Could not pin/map cursor.\n");
409 if (dev_priv->card_type < NV_50) {
410 nv04_display_restore(dev);
411 NVLockVgaCrtcs(dev, false);
412 } else
413 nv50_display_init(dev);
415 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
416 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
418 nv_crtc->cursor.set_offset(nv_crtc,
419 nv_crtc->cursor.nvbo->bo.offset -
420 dev_priv->vm_vram_base);
422 nv_crtc->cursor.set_pos(nv_crtc, nv_crtc->cursor_saved_x,
423 nv_crtc->cursor_saved_y);
426 /* Force CLUT to get re-loaded during modeset */
427 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
428 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
430 nv_crtc->lut.depth = 0;
433 acquire_console_sem();
434 nouveau_fbcon_set_suspend(dev, 0);
435 release_console_sem();
437 nouveau_fbcon_zfill_all(dev);
439 drm_helper_resume_force_mode(dev);
441 nouveau_fbcon_restore_accel(dev);
442 return 0;
443 #endif
446 #ifndef PSCNV_KAPI_DRM_DRIVER_FOPS
447 static const struct file_operations nouveau_driver_fops = {
448 .owner = THIS_MODULE,
449 .open = drm_open,
450 .release = drm_release,
451 .unlocked_ioctl = drm_ioctl,
452 .mmap = pscnv_mmap,
453 .poll = drm_poll,
454 .fasync = drm_fasync,
455 #ifdef CONFIG_COMPAT
456 .compat_ioctl = nouveau_compat_ioctl,
457 #endif
458 #ifdef PSCNV_KAPI_NOOP_LLSEEK
459 .llseek = noop_llseek,
460 #endif
462 #endif
464 static struct drm_driver driver = {
465 .driver_features =
466 DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
467 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM,
468 .load = nouveau_load,
469 .firstopen = nouveau_firstopen,
470 .lastclose = nouveau_lastclose,
471 .unload = nouveau_unload,
472 .preclose = nouveau_preclose,
473 #if defined(CONFIG_DRM_NOUVEAU_DEBUG)
474 .debugfs_init = nouveau_debugfs_init,
475 .debugfs_cleanup = nouveau_debugfs_takedown,
476 #endif
477 .irq_preinstall = nouveau_irq_preinstall,
478 .irq_postinstall = nouveau_irq_postinstall,
479 .irq_uninstall = nouveau_irq_uninstall,
480 .irq_handler = nouveau_irq_handler,
481 .reclaim_buffers = drm_core_reclaim_buffers,
482 #ifdef PSCNV_KAPI_MAP_OFS
483 .get_map_ofs = drm_core_get_map_ofs,
484 .get_reg_ofs = drm_core_get_reg_ofs,
485 #endif
486 .ioctls = nouveau_ioctls,
487 .num_ioctls = DRM_ARRAY_SIZE(nouveau_ioctls),
489 #ifdef PSCNV_KAPI_DRM_DRIVER_FOPS
490 .fops = {
491 .owner = THIS_MODULE,
492 .open = drm_open,
493 .release = drm_release,
494 .unlocked_ioctl = drm_ioctl,
495 .mmap = pscnv_mmap,
496 .poll = drm_poll,
497 .fasync = drm_fasync,
498 #if defined(CONFIG_COMPAT)
499 .compat_ioctl = nouveau_compat_ioctl,
500 #endif
502 #else
503 .fops = &nouveau_driver_fops,
504 #endif
506 #ifdef PSCNV_KAPI_DRM_INIT
507 .pci_driver = {
508 .name = DRIVER_NAME,
509 .id_table = pciidlist,
510 .probe = nouveau_pci_probe,
511 .remove = nouveau_pci_remove,
512 .suspend = nouveau_pci_suspend,
513 .resume = nouveau_pci_resume
515 #endif
517 .gem_free_object = pscnv_gem_free_object,
519 .name = DRIVER_NAME,
520 .desc = DRIVER_DESC,
521 #ifdef GIT_REVISION
522 .date = GIT_REVISION,
523 #else
524 .date = DRIVER_DATE,
525 #endif
526 .major = DRIVER_MAJOR,
527 .minor = DRIVER_MINOR,
528 .patchlevel = DRIVER_PATCHLEVEL,
531 #ifndef PSCNV_KAPI_DRM_INIT
532 static struct pci_driver nouveau_pci_driver = {
533 .name = DRIVER_NAME,
534 .id_table = pciidlist,
535 .probe = nouveau_pci_probe,
536 .remove = nouveau_pci_remove,
537 .suspend = nouveau_pci_suspend,
538 .resume = nouveau_pci_resume
540 #endif
542 static int __init nouveau_init(void)
544 if (nouveau_modeset == -1) {
545 #ifdef CONFIG_VGA_CONSOLE
546 if (vgacon_text_force())
547 nouveau_modeset = 0;
548 else
549 #endif
550 nouveau_modeset = 1;
553 if (nouveau_modeset == 1) {
554 driver.driver_features |= DRIVER_MODESET;
555 #if defined(CONFIG_FRAMEBUFFER_CONSOLE_MODULE)
556 request_module("fbcon");
557 #elif !defined(CONFIG_FRAMEBUFFER_CONSOLE)
558 printk(KERN_INFO "CONFIG_FRAMEBUFFER_CONSOLE was not enabled. You won't get any console output.\n");
559 #endif
560 nouveau_register_dsm_handler();
563 #ifdef PSCNV_KAPI_DRM_INIT
564 return drm_init(&driver);
565 #else
566 return drm_pci_init(&driver, &nouveau_pci_driver);
567 #endif
570 static void __exit nouveau_exit(void)
572 #ifdef PSCNV_KAPI_DRM_INIT
573 drm_exit(&driver);
574 #else
575 drm_pci_exit(&driver, &nouveau_pci_driver);
576 #endif
577 nouveau_unregister_dsm_handler();
580 module_init(nouveau_init);
581 module_exit(nouveau_exit);
583 MODULE_AUTHOR(DRIVER_AUTHOR);
584 MODULE_DESCRIPTION(DRIVER_DESC);
585 MODULE_LICENSE("GPL and additional rights");