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