modesetting-101: rename modeflags, as to avoid conflicts with the xorg definitions
[platform/upstream/libdrm.git] / linux-core / radeon_ms_drv.c
1 /*
2  * Copyright 2007 Jerome Glisse.
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  * PRECISION INSIGHT 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 OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /*
25  * Authors:
26  *    Jerome Glisse <glisse@freedesktop.org>
27  */
28 #include "drm_pciids.h"
29 #include "radeon_ms.h"
30
31 extern struct drm_fence_driver r3xx_fence_driver;
32 extern struct drm_bo_driver radeon_ms_bo_driver;
33 extern struct drm_ioctl_desc radeon_ms_ioctls[];
34 extern int radeon_ms_num_ioctls;
35
36 static int radeon_ms_driver_dri_library_name(struct drm_device * dev,
37                                              char * buf);
38 static int radeon_ms_driver_probe(struct pci_dev *pdev,
39                                   const struct pci_device_id *ent);
40
41 static struct pci_device_id pciidlist[] = {
42         radeon_ms_PCI_IDS
43 };
44
45 static struct drm_driver driver = {
46         .load = radeon_ms_driver_load,
47         .firstopen = NULL,
48         .open = radeon_ms_driver_open,
49         .preclose = NULL,
50         .postclose = NULL,
51         .lastclose = radeon_ms_driver_lastclose,
52         .unload = radeon_ms_driver_unload,
53         .dma_ioctl = radeon_ms_driver_dma_ioctl,
54         .dma_ready = NULL,
55         .dma_quiescent = NULL,
56         .context_ctor = NULL,
57         .context_dtor = NULL,
58         .kernel_context_switch = NULL,
59         .kernel_context_switch_unlock = NULL,
60         .dri_library_name = radeon_ms_driver_dri_library_name,
61         .device_is_agp = NULL,
62         .irq_handler = radeon_ms_irq_handler,
63         .irq_preinstall = radeon_ms_irq_preinstall,
64         .irq_postinstall = radeon_ms_irq_postinstall,
65         .irq_uninstall = radeon_ms_irq_uninstall,
66         .reclaim_buffers = drm_core_reclaim_buffers,
67         .reclaim_buffers_locked = NULL,
68         .reclaim_buffers_idlelocked = NULL,
69         .get_map_ofs = drm_core_get_map_ofs,
70         .get_reg_ofs = drm_core_get_reg_ofs,
71         .set_version = NULL,
72         .fb_probe = radeonfb_probe,
73         .fb_remove = radeonfb_remove,
74         .fence_driver = &r3xx_fence_driver,
75         .bo_driver = &radeon_ms_bo_driver,
76         .major = DRIVER_MAJOR,
77         .minor = DRIVER_MINOR,
78         .patchlevel = DRIVER_PATCHLEVEL,
79         .name = DRIVER_NAME,
80         .desc = DRIVER_DESC,
81         .date = DRIVER_DATE,
82         .driver_features =
83             DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
84             DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED,
85         .dev_priv_size = 0, 
86         .ioctls = radeon_ms_ioctls,
87         .num_ioctls = 0,
88         .fops = {
89                 .owner = THIS_MODULE,
90                 .open = drm_open,
91                 .release = drm_release,
92                 .ioctl = drm_ioctl,
93                 .mmap = drm_mmap,
94                 .poll = drm_poll,
95                 .fasync = drm_fasync,
96 #if defined(CONFIG_COMPAT) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
97                 .compat_ioctl = radeon_ms_compat_ioctl,
98 #endif
99                 },
100         .pci_driver = {
101                 .name = DRIVER_NAME,
102                 .id_table = pciidlist,
103                 .probe = radeon_ms_driver_probe,
104                 .remove = __devexit_p(drm_cleanup_pci),
105         },
106 };
107
108 static int radeon_ms_driver_probe(struct pci_dev *pdev,
109                                   const struct pci_device_id *ent)
110 {
111         return drm_get_dev(pdev, ent, &driver);
112 }
113
114 static int radeon_ms_driver_dri_library_name(struct drm_device * dev,
115                                              char * buf)
116 {
117         struct drm_radeon_private *dev_priv = dev->dev_private;
118         int ret;
119
120         switch (dev_priv->family) {
121         default:
122                 ret = snprintf(buf, PAGE_SIZE, "\n");
123         }
124         return ret;
125 }
126
127 static void __exit radeon_ms_driver_exit(void)
128 {
129         drm_exit(&driver);
130 }
131
132 static int __init radeon_ms_driver_init(void)
133 {
134         driver.num_ioctls = radeon_ms_num_ioctls;
135         driver.driver_features |= DRIVER_MODESET;
136         return drm_init(&driver, pciidlist);
137 }
138
139 module_init(radeon_ms_driver_init);
140 module_exit(radeon_ms_driver_exit);
141
142 MODULE_AUTHOR(DRIVER_AUTHOR);
143 MODULE_DESCRIPTION(DRIVER_DESC);
144 MODULE_LICENSE("GPL and additional rights");