26 #include <linux/module.h>
27 #include <linux/pci.h>
55 static char *nouveau_config;
59 static char *nouveau_debug;
63 static int nouveau_noaccel = 0;
67 "0 = disabled, 1 = enabled, 2 = headless)");
71 static struct drm_driver
driver;
74 nouveau_name(
struct pci_dev *pdev)
77 name |= pdev->
bus->number << 16;
83 nouveau_cli_create(
struct pci_dev *pdev,
const char *name,
84 int size,
void **pcli)
90 nouveau_debug, size, pcli);
137 NV_ERROR(drm,
"failed to initialise sync subsystem, %d\n", ret);
138 nouveau_accel_fini(drm);
149 NV_ERROR(drm,
"failed to create ce channel, %d\n", ret);
161 NV_ERROR(drm,
"failed to create kernel channel, %d\n", ret);
162 nouveau_accel_fini(drm);
170 NV_ERROR(drm,
"failed to allocate notifier, %d\n", ret);
171 nouveau_accel_fini(drm);
180 .start = drm->
notify->addr,
181 .limit = drm->
notify->addr + 31
185 nouveau_accel_fini(drm);
198 struct apertures_struct *aper;
203 aper = alloc_apertures(3);
229 nouveau_config, nouveau_debug, &device);
235 ret = drm_get_pci_dev(pdev, pent, &
driver);
247 struct pci_dev *pdev = dev->pdev;
252 ret = nouveau_cli_create(pdev,
"DRM",
sizeof(*drm), (
void**)&drm);
256 dev->dev_private = drm;
265 if (drm_pci_device_is_agp(dev) && dev->agp) {
300 device = nv_device(drm->
device);
301 if (nv_device(drm->
device)->chipset == 0xc1)
302 nv_mask(device, 0x00088080, 0x00000800, 0x00000000);
309 0x1000, &drm->
client.base.vm);
330 if (dev->mode_config.num_crtc) {
338 nouveau_accel_init(drm);
354 nouveau_cli_destroy(&drm->
client);
364 nouveau_accel_fini(drm);
368 if (dev->mode_config.num_crtc)
379 nouveau_cli_destroy(&drm->
client);
384 nouveau_drm_remove(
struct pci_dev *pdev)
386 struct drm_device *dev = pci_get_drvdata(pdev);
390 device = drm->
client.base.device;
400 struct drm_device *dev = pci_get_drvdata(pdev);
405 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF ||
409 if (dev->mode_config.num_crtc) {
410 NV_INFO(drm,
"suspending fbcon...\n");
413 NV_INFO(drm,
"suspending display...\n");
419 NV_INFO(drm,
"evicting buffers...\n");
427 NV_INFO(drm,
"suspending client object trees...\n");
453 if (dev->mode_config.num_crtc) {
454 NV_INFO(drm,
"resuming display...\n");
463 struct drm_device *dev = pci_get_drvdata(pdev);
468 if (dev->switch_power_state == DRM_SWITCH_POWER_OFF)
471 NV_INFO(drm,
"re-enabling device...\n");
481 NV_INFO(drm,
"resuming client object trees...\n");
496 if (dev->mode_config.num_crtc) {
497 NV_INFO(drm,
"resuming display...\n");
504 nouveau_drm_open(
struct drm_device *dev,
struct drm_file *fpriv)
506 struct pci_dev *pdev = dev->pdev;
512 snprintf(name,
sizeof(name),
"%d", pid_nr(fpriv->pid));
514 ret = nouveau_cli_create(pdev, name,
sizeof(*cli), (
void **)&cli);
518 if (nv_device(drm->
device)->card_type >= NV_50) {
520 0x1000, &cli->
base.vm);
522 nouveau_cli_destroy(cli);
527 fpriv->driver_priv = cli;
536 nouveau_drm_preclose(
struct drm_device *dev,
struct drm_file *fpriv)
550 nouveau_drm_postclose(
struct drm_device *dev,
struct drm_file *fpriv)
553 nouveau_cli_destroy(cli);
556 static struct drm_ioctl_desc
573 nouveau_driver_fops = {
582 #if defined(CONFIG_COMPAT)
588 static struct drm_driver
591 DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
592 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM |
593 DRIVER_MODESET | DRIVER_PRIME,
595 .load = nouveau_drm_load,
596 .unload = nouveau_drm_unload,
597 .open = nouveau_drm_open,
598 .preclose = nouveau_drm_preclose,
599 .postclose = nouveau_drm_postclose,
611 .ioctls = nouveau_ioctls,
612 .fops = &nouveau_driver_fops,
631 .date = GIT_REVISION,
641 nouveau_drm_pci_table[] = {
645 .class_mask = 0xff << 16,
650 .class_mask = 0xff << 16,
656 nouveau_drm_pci_driver = {
658 .id_table = nouveau_drm_pci_table,
659 .probe = nouveau_drm_probe,
660 .remove = nouveau_drm_remove,
666 nouveau_drm_init(
void)
668 driver.num_ioctls =
ARRAY_SIZE(nouveau_ioctls);
671 #ifdef CONFIG_VGA_CONSOLE
685 nouveau_drm_exit(
void)