1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#include "drmP.h"
33#include "drm.h"
34#include "mga_drm.h"
35#include "mga_drv.h"
36
37#include "drm_pciids.h"
38
39static int mga_driver_device_is_agp(struct drm_device * dev);
40
41static struct pci_device_id pciidlist[] = {
42 mga_PCI_IDS
43};
44
45static struct drm_driver driver = {
46 .driver_features =
47 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
48 DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
49 .dev_priv_size = sizeof(drm_mga_buf_priv_t),
50 .load = mga_driver_load,
51 .unload = mga_driver_unload,
52 .lastclose = mga_driver_lastclose,
53 .dma_quiescent = mga_driver_dma_quiescent,
54 .device_is_agp = mga_driver_device_is_agp,
55 .get_vblank_counter = mga_get_vblank_counter,
56 .enable_vblank = mga_enable_vblank,
57 .disable_vblank = mga_disable_vblank,
58 .irq_preinstall = mga_driver_irq_preinstall,
59 .irq_postinstall = mga_driver_irq_postinstall,
60 .irq_uninstall = mga_driver_irq_uninstall,
61 .irq_handler = mga_driver_irq_handler,
62 .reclaim_buffers = drm_core_reclaim_buffers,
63 .get_map_ofs = drm_core_get_map_ofs,
64 .get_reg_ofs = drm_core_get_reg_ofs,
65 .ioctls = mga_ioctls,
66 .dma_ioctl = mga_dma_buffers,
67 .fops = {
68 .owner = THIS_MODULE,
69 .open = drm_open,
70 .release = drm_release,
71 .ioctl = drm_ioctl,
72 .mmap = drm_mmap,
73 .poll = drm_poll,
74 .fasync = drm_fasync,
75#ifdef CONFIG_COMPAT
76 .compat_ioctl = mga_compat_ioctl,
77#endif
78 },
79 .pci_driver = {
80 .name = DRIVER_NAME,
81 .id_table = pciidlist,
82 },
83
84 .name = DRIVER_NAME,
85 .desc = DRIVER_DESC,
86 .date = DRIVER_DATE,
87 .major = DRIVER_MAJOR,
88 .minor = DRIVER_MINOR,
89 .patchlevel = DRIVER_PATCHLEVEL,
90};
91
92static int __init mga_init(void)
93{
94 driver.num_ioctls = mga_max_ioctl;
95 return drm_init(&driver);
96}
97
98static void __exit mga_exit(void)
99{
100 drm_exit(&driver);
101}
102
103module_init(mga_init);
104module_exit(mga_exit);
105
106MODULE_AUTHOR(DRIVER_AUTHOR);
107MODULE_DESCRIPTION(DRIVER_DESC);
108MODULE_LICENSE("GPL and additional rights");
109
110
111
112
113
114
115
116
117
118
119
120
121
122static int mga_driver_device_is_agp(struct drm_device * dev)
123{
124 const struct pci_dev *const pdev = dev->pdev;
125
126
127
128
129
130
131
132
133
134
135 if ((pdev->device == 0x0525) && pdev->bus->self
136 && (pdev->bus->self->vendor == 0x3388)
137 && (pdev->bus->self->device == 0x0021)) {
138 return 0;
139 }
140
141 return 2;
142}
143