modesetting-101: rename modeflags, as to avoid conflicts with the xorg definitions
[platform/upstream/libdrm.git] / linux-core / nouveau_drv.c
1 /*
2  * Copyright 2005 Stephane Marchesin.
3  * All Rights Reserved.
4  *
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:
11  *
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.
15  *
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.
23  */
24
25 #include "drmP.h"
26 #include "drm.h"
27 #include "nouveau_drv.h"
28
29 #include "drm_pciids.h"
30
31 unsigned int nouveau_modeset = 0; /* kms */
32 module_param_named(modeset, nouveau_modeset, int, 0400);
33
34 static struct pci_device_id pciidlist[] = {
35         {
36                 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
37                 .class = PCI_BASE_CLASS_DISPLAY << 16,
38                 .class_mask  = 0xff << 16,
39         },
40         {
41                 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID),
42                 .class = PCI_BASE_CLASS_DISPLAY << 16,
43                 .class_mask  = 0xff << 16,
44         }
45 };
46
47 extern struct drm_ioctl_desc nouveau_ioctls[];
48 extern int nouveau_max_ioctl;
49
50 static int probe(struct pci_dev *pdev, const struct pci_device_id *ent);
51 static struct drm_driver driver = {
52         .driver_features =
53                 DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
54                 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
55         .load = nouveau_load,
56         .firstopen = nouveau_firstopen,
57         .lastclose = nouveau_lastclose,
58         .unload = nouveau_unload,
59         .preclose = nouveau_preclose,
60         .irq_preinstall = nouveau_irq_preinstall,
61         .irq_postinstall = nouveau_irq_postinstall,
62         .irq_uninstall = nouveau_irq_uninstall,
63         .irq_handler = nouveau_irq_handler,
64         .reclaim_buffers = drm_core_reclaim_buffers,
65         .get_map_ofs = drm_core_get_map_ofs,
66         .get_reg_ofs = drm_core_get_reg_ofs,
67         .ioctls = nouveau_ioctls,
68         .fops = {
69                 .owner = THIS_MODULE,
70                 .open = drm_open,
71                 .release = drm_release,
72                 .ioctl = drm_ioctl,
73                 .mmap = drm_mmap,
74                 .poll = drm_poll,
75                 .fasync = drm_fasync,
76 #if defined(CONFIG_COMPAT) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
77                 .compat_ioctl = nouveau_compat_ioctl,
78 #endif
79         },
80         .pci_driver = {
81                 .name = DRIVER_NAME,
82                 .id_table = pciidlist,
83                 .probe = probe,
84                 .remove = __devexit_p(drm_cleanup_pci),
85         },
86
87         .bo_driver = &nouveau_bo_driver,
88         .fence_driver = &nouveau_fence_driver,
89
90         .name = DRIVER_NAME,
91         .desc = DRIVER_DESC,
92 #ifdef GIT_REVISION
93         .date = GIT_REVISION,
94 #else
95         .date = DRIVER_DATE,
96 #endif
97         .major = DRIVER_MAJOR,
98         .minor = DRIVER_MINOR,
99         .patchlevel = DRIVER_PATCHLEVEL,
100 };
101
102 static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
103 {
104         return drm_get_dev(pdev, ent, &driver);
105 }
106
107 static int __init nouveau_init(void)
108 {
109         driver.num_ioctls = nouveau_max_ioctl;
110
111         if (nouveau_modeset == 1)
112                 driver.driver_features |= DRIVER_MODESET;
113
114         return drm_init(&driver, pciidlist);
115 }
116
117 static void __exit nouveau_exit(void)
118 {
119         drm_exit(&driver);
120 }
121
122 module_init(nouveau_init);
123 module_exit(nouveau_exit);
124
125 MODULE_AUTHOR(DRIVER_AUTHOR);
126 MODULE_DESCRIPTION(DRIVER_DESC);
127 MODULE_LICENSE("GPL and additional rights");