via_drv.c revision 1.1.1.3 1 /* $NetBSD: via_drv.c,v 1.1.1.3 2018/08/27 01:34:59 riastradh Exp $ */
2
3 /*
4 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
5 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sub license,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
25 */
26
27 #include <sys/cdefs.h>
28 __KERNEL_RCSID(0, "$NetBSD: via_drv.c,v 1.1.1.3 2018/08/27 01:34:59 riastradh Exp $");
29
30 #include <linux/module.h>
31
32 #include <drm/drmP.h>
33 #include <drm/via_drm.h>
34 #include "via_drv.h"
35
36 #include <drm/drm_pciids.h>
37
38 static int via_driver_open(struct drm_device *dev, struct drm_file *file)
39 {
40 struct via_file_private *file_priv;
41
42 DRM_DEBUG_DRIVER("\n");
43 file_priv = kmalloc(sizeof(*file_priv), GFP_KERNEL);
44 if (!file_priv)
45 return -ENOMEM;
46
47 file->driver_priv = file_priv;
48
49 INIT_LIST_HEAD(&file_priv->obj_list);
50
51 return 0;
52 }
53
54 static void via_driver_postclose(struct drm_device *dev, struct drm_file *file)
55 {
56 struct via_file_private *file_priv = file->driver_priv;
57
58 kfree(file_priv);
59 }
60
61 static struct pci_device_id pciidlist[] = {
62 viadrv_PCI_IDS
63 };
64
65 static const struct file_operations via_driver_fops = {
66 .owner = THIS_MODULE,
67 .open = drm_open,
68 .release = drm_release,
69 .unlocked_ioctl = drm_ioctl,
70 .mmap = drm_legacy_mmap,
71 .poll = drm_poll,
72 #ifdef CONFIG_COMPAT
73 .compat_ioctl = drm_compat_ioctl,
74 #endif
75 .llseek = noop_llseek,
76 };
77
78 static struct drm_driver driver = {
79 .driver_features =
80 DRIVER_USE_AGP | DRIVER_HAVE_IRQ |
81 DRIVER_IRQ_SHARED,
82 .load = via_driver_load,
83 .unload = via_driver_unload,
84 .open = via_driver_open,
85 .preclose = via_reclaim_buffers_locked,
86 .postclose = via_driver_postclose,
87 .set_busid = drm_pci_set_busid,
88 .context_dtor = via_final_context,
89 .get_vblank_counter = via_get_vblank_counter,
90 .enable_vblank = via_enable_vblank,
91 .disable_vblank = via_disable_vblank,
92 .irq_preinstall = via_driver_irq_preinstall,
93 .irq_postinstall = via_driver_irq_postinstall,
94 .irq_uninstall = via_driver_irq_uninstall,
95 .irq_handler = via_driver_irq_handler,
96 .dma_quiescent = via_driver_dma_quiescent,
97 .lastclose = via_lastclose,
98 .ioctls = via_ioctls,
99 .fops = &via_driver_fops,
100 .name = DRIVER_NAME,
101 .desc = DRIVER_DESC,
102 .date = DRIVER_DATE,
103 .major = DRIVER_MAJOR,
104 .minor = DRIVER_MINOR,
105 .patchlevel = DRIVER_PATCHLEVEL,
106 };
107
108 static struct pci_driver via_pci_driver = {
109 .name = DRIVER_NAME,
110 .id_table = pciidlist,
111 };
112
113 static int __init via_init(void)
114 {
115 driver.num_ioctls = via_max_ioctl;
116 via_init_command_verifier();
117 return drm_pci_init(&driver, &via_pci_driver);
118 }
119
120 static void __exit via_exit(void)
121 {
122 drm_pci_exit(&driver, &via_pci_driver);
123 }
124
125 module_init(via_init);
126 module_exit(via_exit);
127
128 MODULE_AUTHOR(DRIVER_AUTHOR);
129 MODULE_DESCRIPTION(DRIVER_DESC);
130 MODULE_LICENSE("GPL and additional rights");
131