xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/savage/savage_drv.c (revision e6c7e151de239c49d2e38720a061ed9d1fa99309)
1 /*	$NetBSD: savage_drv.c,v 1.3 2018/08/28 03:41:39 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.3 2018/08/28 03:41:39 riastradh Exp $");
30 
31 #include <linux/module.h>
32 
33 #include <drm/drmP.h>
34 #include <drm/savage_drm.h>
35 #include "savage_drv.h"
36 
37 #include <drm/drm_pciids.h>
38 
39 static struct pci_device_id pciidlist[] = {
40 	savage_PCI_IDS
41 };
42 
43 static const struct file_operations savage_driver_fops = {
44 	.owner = THIS_MODULE,
45 	.open = drm_open,
46 	.release = drm_release,
47 	.unlocked_ioctl = drm_ioctl,
48 	.mmap = drm_legacy_mmap,
49 	.poll = drm_poll,
50 #ifdef CONFIG_COMPAT
51 	.compat_ioctl = drm_compat_ioctl,
52 #endif
53 	.llseek = noop_llseek,
54 };
55 
56 static struct drm_driver driver = {
57 	.driver_features =
58 	    DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_PCI_DMA,
59 	.dev_priv_size = sizeof(drm_savage_buf_priv_t),
60 	.load = savage_driver_load,
61 	.firstopen = savage_driver_firstopen,
62 	.preclose = savage_reclaim_buffers,
63 	.lastclose = savage_driver_lastclose,
64 	.unload = savage_driver_unload,
65 	.set_busid = drm_pci_set_busid,
66 	.set_unique = drm_pci_set_unique,
67 	.ioctls = savage_ioctls,
68 	.dma_ioctl = savage_bci_buffers,
69 	.fops = &savage_driver_fops,
70 	.name = DRIVER_NAME,
71 	.desc = DRIVER_DESC,
72 	.date = DRIVER_DATE,
73 	.major = DRIVER_MAJOR,
74 	.minor = DRIVER_MINOR,
75 	.patchlevel = DRIVER_PATCHLEVEL,
76 };
77 
78 static struct pci_driver savage_pci_driver = {
79 	.name = DRIVER_NAME,
80 	.id_table = pciidlist,
81 };
82 
83 static int __init savage_init(void)
84 {
85 	driver.num_ioctls = savage_max_ioctl;
86 	return drm_pci_init(&driver, &savage_pci_driver);
87 }
88 
89 static void __exit savage_exit(void)
90 {
91 	drm_pci_exit(&driver, &savage_pci_driver);
92 }
93 
94 module_init(savage_init);
95 module_exit(savage_exit);
96 
97 MODULE_AUTHOR(DRIVER_AUTHOR);
98 MODULE_DESCRIPTION(DRIVER_DESC);
99 MODULE_LICENSE("GPL and additional rights");
100