xref: /OK3568_Linux_fs/kernel/drivers/gpu/drm/mga/mga_drv.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
2*4882a593Smuzhiyun  * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5*4882a593Smuzhiyun  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6*4882a593Smuzhiyun  * All Rights Reserved.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
9*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
10*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
11*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
13*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * The above copyright notice and this permission notice (including the next
16*4882a593Smuzhiyun  * paragraph) shall be included in all copies or substantial portions of the
17*4882a593Smuzhiyun  * Software.
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22*4882a593Smuzhiyun  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23*4882a593Smuzhiyun  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24*4882a593Smuzhiyun  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25*4882a593Smuzhiyun  * OTHER DEALINGS IN THE SOFTWARE.
26*4882a593Smuzhiyun  *
27*4882a593Smuzhiyun  * Authors:
28*4882a593Smuzhiyun  *    Rickard E. (Rik) Faith <faith@valinux.com>
29*4882a593Smuzhiyun  *    Gareth Hughes <gareth@valinux.com>
30*4882a593Smuzhiyun  */
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun #include <linux/module.h>
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #include <drm/drm_drv.h>
35*4882a593Smuzhiyun #include <drm/drm_pciids.h>
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #include "mga_drv.h"
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun static struct pci_device_id pciidlist[] = {
40*4882a593Smuzhiyun 	mga_PCI_IDS
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun static const struct file_operations mga_driver_fops = {
44*4882a593Smuzhiyun 	.owner = THIS_MODULE,
45*4882a593Smuzhiyun 	.open = drm_open,
46*4882a593Smuzhiyun 	.release = drm_release,
47*4882a593Smuzhiyun 	.unlocked_ioctl = drm_ioctl,
48*4882a593Smuzhiyun 	.mmap = drm_legacy_mmap,
49*4882a593Smuzhiyun 	.poll = drm_poll,
50*4882a593Smuzhiyun #ifdef CONFIG_COMPAT
51*4882a593Smuzhiyun 	.compat_ioctl = mga_compat_ioctl,
52*4882a593Smuzhiyun #endif
53*4882a593Smuzhiyun 	.llseek = noop_llseek,
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun static struct drm_driver driver = {
57*4882a593Smuzhiyun 	.driver_features =
58*4882a593Smuzhiyun 	    DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_LEGACY |
59*4882a593Smuzhiyun 	    DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ,
60*4882a593Smuzhiyun 	.dev_priv_size = sizeof(drm_mga_buf_priv_t),
61*4882a593Smuzhiyun 	.load = mga_driver_load,
62*4882a593Smuzhiyun 	.unload = mga_driver_unload,
63*4882a593Smuzhiyun 	.lastclose = mga_driver_lastclose,
64*4882a593Smuzhiyun 	.dma_quiescent = mga_driver_dma_quiescent,
65*4882a593Smuzhiyun 	.get_vblank_counter = mga_get_vblank_counter,
66*4882a593Smuzhiyun 	.enable_vblank = mga_enable_vblank,
67*4882a593Smuzhiyun 	.disable_vblank = mga_disable_vblank,
68*4882a593Smuzhiyun 	.irq_preinstall = mga_driver_irq_preinstall,
69*4882a593Smuzhiyun 	.irq_postinstall = mga_driver_irq_postinstall,
70*4882a593Smuzhiyun 	.irq_uninstall = mga_driver_irq_uninstall,
71*4882a593Smuzhiyun 	.irq_handler = mga_driver_irq_handler,
72*4882a593Smuzhiyun 	.ioctls = mga_ioctls,
73*4882a593Smuzhiyun 	.dma_ioctl = mga_dma_buffers,
74*4882a593Smuzhiyun 	.fops = &mga_driver_fops,
75*4882a593Smuzhiyun 	.name = DRIVER_NAME,
76*4882a593Smuzhiyun 	.desc = DRIVER_DESC,
77*4882a593Smuzhiyun 	.date = DRIVER_DATE,
78*4882a593Smuzhiyun 	.major = DRIVER_MAJOR,
79*4882a593Smuzhiyun 	.minor = DRIVER_MINOR,
80*4882a593Smuzhiyun 	.patchlevel = DRIVER_PATCHLEVEL,
81*4882a593Smuzhiyun };
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun static struct pci_driver mga_pci_driver = {
84*4882a593Smuzhiyun 	.name = DRIVER_NAME,
85*4882a593Smuzhiyun 	.id_table = pciidlist,
86*4882a593Smuzhiyun };
87*4882a593Smuzhiyun 
mga_init(void)88*4882a593Smuzhiyun static int __init mga_init(void)
89*4882a593Smuzhiyun {
90*4882a593Smuzhiyun 	driver.num_ioctls = mga_max_ioctl;
91*4882a593Smuzhiyun 	return drm_legacy_pci_init(&driver, &mga_pci_driver);
92*4882a593Smuzhiyun }
93*4882a593Smuzhiyun 
mga_exit(void)94*4882a593Smuzhiyun static void __exit mga_exit(void)
95*4882a593Smuzhiyun {
96*4882a593Smuzhiyun 	drm_legacy_pci_exit(&driver, &mga_pci_driver);
97*4882a593Smuzhiyun }
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun module_init(mga_init);
100*4882a593Smuzhiyun module_exit(mga_exit);
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun MODULE_AUTHOR(DRIVER_AUTHOR);
103*4882a593Smuzhiyun MODULE_DESCRIPTION(DRIVER_DESC);
104*4882a593Smuzhiyun MODULE_LICENSE("GPL and additional rights");
105