1*41ec0267Sriastradh /* $NetBSD: mga_drv.c,v 1.5 2021/12/18 23:45:32 riastradh Exp $ */
2efa246c0Sriastradh
3fcd0cb28Sriastradh /* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
4fcd0cb28Sriastradh * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
5fcd0cb28Sriastradh *
6fcd0cb28Sriastradh * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
7fcd0cb28Sriastradh * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8fcd0cb28Sriastradh * All Rights Reserved.
9fcd0cb28Sriastradh *
10fcd0cb28Sriastradh * Permission is hereby granted, free of charge, to any person obtaining a
11fcd0cb28Sriastradh * copy of this software and associated documentation files (the "Software"),
12fcd0cb28Sriastradh * to deal in the Software without restriction, including without limitation
13fcd0cb28Sriastradh * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14fcd0cb28Sriastradh * and/or sell copies of the Software, and to permit persons to whom the
15fcd0cb28Sriastradh * Software is furnished to do so, subject to the following conditions:
16fcd0cb28Sriastradh *
17fcd0cb28Sriastradh * The above copyright notice and this permission notice (including the next
18fcd0cb28Sriastradh * paragraph) shall be included in all copies or substantial portions of the
19fcd0cb28Sriastradh * Software.
20fcd0cb28Sriastradh *
21fcd0cb28Sriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22fcd0cb28Sriastradh * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23fcd0cb28Sriastradh * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24fcd0cb28Sriastradh * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25fcd0cb28Sriastradh * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26fcd0cb28Sriastradh * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27fcd0cb28Sriastradh * OTHER DEALINGS IN THE SOFTWARE.
28fcd0cb28Sriastradh *
29fcd0cb28Sriastradh * Authors:
30fcd0cb28Sriastradh * Rickard E. (Rik) Faith <faith@valinux.com>
31fcd0cb28Sriastradh * Gareth Hughes <gareth@valinux.com>
32fcd0cb28Sriastradh */
33fcd0cb28Sriastradh
34efa246c0Sriastradh #include <sys/cdefs.h>
35*41ec0267Sriastradh __KERNEL_RCSID(0, "$NetBSD: mga_drv.c,v 1.5 2021/12/18 23:45:32 riastradh Exp $");
36efa246c0Sriastradh
37fcd0cb28Sriastradh #include <linux/module.h>
38fcd0cb28Sriastradh
39*41ec0267Sriastradh #include <drm/drm_drv.h>
40fcd0cb28Sriastradh #include <drm/drm_pciids.h>
41fcd0cb28Sriastradh
42*41ec0267Sriastradh #include "mga_drv.h"
43fcd0cb28Sriastradh
44fcd0cb28Sriastradh static struct pci_device_id pciidlist[] = {
45fcd0cb28Sriastradh mga_PCI_IDS
46fcd0cb28Sriastradh };
47fcd0cb28Sriastradh
48fcd0cb28Sriastradh static const struct file_operations mga_driver_fops = {
49fcd0cb28Sriastradh .owner = THIS_MODULE,
50fcd0cb28Sriastradh .open = drm_open,
51fcd0cb28Sriastradh .release = drm_release,
52fcd0cb28Sriastradh .unlocked_ioctl = drm_ioctl,
53efa246c0Sriastradh .mmap = drm_legacy_mmap,
54fcd0cb28Sriastradh .poll = drm_poll,
55fcd0cb28Sriastradh #ifdef CONFIG_COMPAT
56fcd0cb28Sriastradh .compat_ioctl = mga_compat_ioctl,
57fcd0cb28Sriastradh #endif
58fcd0cb28Sriastradh .llseek = noop_llseek,
59fcd0cb28Sriastradh };
60fcd0cb28Sriastradh
61fcd0cb28Sriastradh static struct drm_driver driver = {
62fcd0cb28Sriastradh .driver_features =
63*41ec0267Sriastradh DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_LEGACY |
64*41ec0267Sriastradh DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ,
65fcd0cb28Sriastradh .dev_priv_size = sizeof(drm_mga_buf_priv_t),
66fcd0cb28Sriastradh .load = mga_driver_load,
67fcd0cb28Sriastradh .unload = mga_driver_unload,
68fcd0cb28Sriastradh .lastclose = mga_driver_lastclose,
69fcd0cb28Sriastradh .dma_quiescent = mga_driver_dma_quiescent,
70fcd0cb28Sriastradh .get_vblank_counter = mga_get_vblank_counter,
71fcd0cb28Sriastradh .enable_vblank = mga_enable_vblank,
72fcd0cb28Sriastradh .disable_vblank = mga_disable_vblank,
73fcd0cb28Sriastradh .irq_preinstall = mga_driver_irq_preinstall,
74fcd0cb28Sriastradh .irq_postinstall = mga_driver_irq_postinstall,
75fcd0cb28Sriastradh .irq_uninstall = mga_driver_irq_uninstall,
76fcd0cb28Sriastradh .irq_handler = mga_driver_irq_handler,
7737ac6a77Sriastradh #ifdef __NetBSD__
7837ac6a77Sriastradh .request_irq = drm_pci_request_irq,
7937ac6a77Sriastradh .free_irq = drm_pci_free_irq,
8037ac6a77Sriastradh #endif
81fcd0cb28Sriastradh .ioctls = mga_ioctls,
82fcd0cb28Sriastradh .dma_ioctl = mga_dma_buffers,
83fcd0cb28Sriastradh .fops = &mga_driver_fops,
84fcd0cb28Sriastradh .name = DRIVER_NAME,
85fcd0cb28Sriastradh .desc = DRIVER_DESC,
86fcd0cb28Sriastradh .date = DRIVER_DATE,
87fcd0cb28Sriastradh .major = DRIVER_MAJOR,
88fcd0cb28Sriastradh .minor = DRIVER_MINOR,
89fcd0cb28Sriastradh .patchlevel = DRIVER_PATCHLEVEL,
90fcd0cb28Sriastradh };
91fcd0cb28Sriastradh
92fcd0cb28Sriastradh static struct pci_driver mga_pci_driver = {
93fcd0cb28Sriastradh .name = DRIVER_NAME,
94fcd0cb28Sriastradh .id_table = pciidlist,
95fcd0cb28Sriastradh };
96fcd0cb28Sriastradh
mga_init(void)97fcd0cb28Sriastradh static int __init mga_init(void)
98fcd0cb28Sriastradh {
99fcd0cb28Sriastradh driver.num_ioctls = mga_max_ioctl;
100*41ec0267Sriastradh return drm_legacy_pci_init(&driver, &mga_pci_driver);
101fcd0cb28Sriastradh }
102fcd0cb28Sriastradh
mga_exit(void)103fcd0cb28Sriastradh static void __exit mga_exit(void)
104fcd0cb28Sriastradh {
105*41ec0267Sriastradh drm_legacy_pci_exit(&driver, &mga_pci_driver);
106fcd0cb28Sriastradh }
107fcd0cb28Sriastradh
108fcd0cb28Sriastradh module_init(mga_init);
109fcd0cb28Sriastradh module_exit(mga_exit);
110fcd0cb28Sriastradh
111fcd0cb28Sriastradh MODULE_AUTHOR(DRIVER_AUTHOR);
112fcd0cb28Sriastradh MODULE_DESCRIPTION(DRIVER_DESC);
113fcd0cb28Sriastradh MODULE_LICENSE("GPL and additional rights");
114