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