xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/i810/i810_drv.c (revision 41ec02673d281bbb3d38e6c78504ce6e30c228c1)
1 /*	$NetBSD: i810_drv.c,v 1.4 2021/12/18 23:45:27 riastradh Exp $	*/
2 
3 /* i810_drv.c -- I810 driver -*- linux-c -*-
4  * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
5  *
6  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
7  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8  * All Rights Reserved.
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice (including the next
18  * paragraph) shall be included in all copies or substantial portions of the
19  * Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
24  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27  * OTHER DEALINGS IN THE SOFTWARE.
28  *
29  * Authors:
30  *    Rickard E. (Rik) Faith <faith@valinux.com>
31  *    Jeff Hartmann <jhartmann@valinux.com>
32  *    Gareth Hughes <gareth@valinux.com>
33  */
34 
35 #include <sys/cdefs.h>
36 __KERNEL_RCSID(0, "$NetBSD: i810_drv.c,v 1.4 2021/12/18 23:45:27 riastradh Exp $");
37 
38 #include "i810_drv.h"
39 
40 #include <linux/module.h>
41 #include <linux/pci.h>
42 
43 #include <drm/drm_drv.h>
44 #include <drm/drm_file.h>
45 #include <drm/drm_pciids.h>
46 #include <drm/i810_drm.h>
47 
48 
49 static struct pci_device_id pciidlist[] = {
50 	i810_PCI_IDS
51 };
52 
53 static const struct file_operations i810_driver_fops = {
54 	.owner = THIS_MODULE,
55 	.open = drm_open,
56 	.release = drm_release,
57 	.unlocked_ioctl = drm_ioctl,
58 	.mmap = drm_legacy_mmap,
59 	.poll = drm_poll,
60 	.compat_ioctl = drm_compat_ioctl,
61 	.llseek = noop_llseek,
62 };
63 
64 static struct drm_driver driver = {
65 	.driver_features = DRIVER_USE_AGP | DRIVER_HAVE_DMA | DRIVER_LEGACY,
66 	.dev_priv_size = sizeof(drm_i810_buf_priv_t),
67 	.load = i810_driver_load,
68 	.lastclose = i810_driver_lastclose,
69 	.preclose = i810_driver_preclose,
70 	.dma_quiescent = i810_driver_dma_quiescent,
71 	.ioctls = i810_ioctls,
72 	.fops = &i810_driver_fops,
73 	.name = DRIVER_NAME,
74 	.desc = DRIVER_DESC,
75 	.date = DRIVER_DATE,
76 	.major = DRIVER_MAJOR,
77 	.minor = DRIVER_MINOR,
78 	.patchlevel = DRIVER_PATCHLEVEL,
79 };
80 
81 static struct pci_driver i810_pci_driver = {
82 	.name = DRIVER_NAME,
83 	.id_table = pciidlist,
84 };
85 
i810_init(void)86 static int __init i810_init(void)
87 {
88 	if (num_possible_cpus() > 1) {
89 		pr_err("drm/i810 does not support SMP\n");
90 		return -EINVAL;
91 	}
92 	driver.num_ioctls = i810_max_ioctl;
93 	return drm_legacy_pci_init(&driver, &i810_pci_driver);
94 }
95 
i810_exit(void)96 static void __exit i810_exit(void)
97 {
98 	drm_legacy_pci_exit(&driver, &i810_pci_driver);
99 }
100 
101 module_init(i810_init);
102 module_exit(i810_exit);
103 
104 MODULE_AUTHOR(DRIVER_AUTHOR);
105 MODULE_DESCRIPTION(DRIVER_DESC);
106 MODULE_LICENSE("GPL and additional rights");
107