1 /* $NetBSD: savage_drv.c,v 1.4 2021/12/18 23:45:43 riastradh Exp $ */
2
3 /* savage_drv.c -- Savage driver for Linux
4 *
5 * Copyright 2004 Felix Kuehling
6 * All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sub license,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
17 * of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NON-INFRINGEMENT. IN NO EVENT SHALL FELIX KUEHLING BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
24 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: savage_drv.c,v 1.4 2021/12/18 23:45:43 riastradh Exp $");
30
31 #include <linux/module.h>
32 #include <linux/pci.h>
33
34 #include <drm/drm_drv.h>
35 #include <drm/drm_file.h>
36 #include <drm/drm_pciids.h>
37
38 #include "savage_drv.h"
39
40 static struct pci_device_id pciidlist[] = {
41 savage_PCI_IDS
42 };
43
44 static const struct file_operations savage_driver_fops = {
45 .owner = THIS_MODULE,
46 .open = drm_open,
47 .release = drm_release,
48 .unlocked_ioctl = drm_ioctl,
49 .mmap = drm_legacy_mmap,
50 .poll = drm_poll,
51 .compat_ioctl = drm_compat_ioctl,
52 .llseek = noop_llseek,
53 };
54
55 static struct drm_driver driver = {
56 .driver_features =
57 DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA | DRIVER_LEGACY,
58 .dev_priv_size = sizeof(drm_savage_buf_priv_t),
59 .load = savage_driver_load,
60 .firstopen = savage_driver_firstopen,
61 .preclose = savage_reclaim_buffers,
62 .lastclose = savage_driver_lastclose,
63 .unload = savage_driver_unload,
64 .ioctls = savage_ioctls,
65 .dma_ioctl = savage_bci_buffers,
66 .fops = &savage_driver_fops,
67 .name = DRIVER_NAME,
68 .desc = DRIVER_DESC,
69 .date = DRIVER_DATE,
70 .major = DRIVER_MAJOR,
71 .minor = DRIVER_MINOR,
72 .patchlevel = DRIVER_PATCHLEVEL,
73 };
74
75 static struct pci_driver savage_pci_driver = {
76 .name = DRIVER_NAME,
77 .id_table = pciidlist,
78 };
79
savage_init(void)80 static int __init savage_init(void)
81 {
82 driver.num_ioctls = savage_max_ioctl;
83 return drm_legacy_pci_init(&driver, &savage_pci_driver);
84 }
85
savage_exit(void)86 static void __exit savage_exit(void)
87 {
88 drm_legacy_pci_exit(&driver, &savage_pci_driver);
89 }
90
91 module_init(savage_init);
92 module_exit(savage_exit);
93
94 MODULE_AUTHOR(DRIVER_AUTHOR);
95 MODULE_DESCRIPTION(DRIVER_DESC);
96 MODULE_LICENSE("GPL and additional rights");
97