]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/drm/mga_drv.c
This commit was generated by cvs2svn to compensate for changes in r147353,
[FreeBSD/FreeBSD.git] / sys / dev / drm / mga_drv.c
1 /* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
2  * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
3  */
4 /*-
5  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
6  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
7  * All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice (including the next
17  * paragraph) shall be included in all copies or substantial portions of the
18  * Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  *
28  * Authors:
29  *    Rickard E. (Rik) Faith <faith@valinux.com>
30  *    Gareth Hughes <gareth@valinux.com>
31  *
32  * $FreeBSD$
33  */
34
35 #include "dev/drm/drmP.h"
36 #include "dev/drm/drm.h"
37 #include "dev/drm/mga_drm.h"
38 #include "dev/drm/mga_drv.h"
39 #include "dev/drm/drm_pciids.h"
40
41 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
42 static drm_pci_id_list_t mga_pciidlist[] = {
43         mga_PCI_IDS
44 };
45
46 extern drm_ioctl_desc_t mga_ioctls[];
47 extern int mga_max_ioctl;
48
49 static void mga_configure(drm_device_t *dev)
50 {
51         dev->dev_priv_size = sizeof(drm_mga_buf_priv_t);
52         /* XXX dev->prerelease = mga_driver_prerelease; */
53         dev->pretakedown = mga_driver_pretakedown;
54         dev->vblank_wait = mga_driver_vblank_wait;
55         dev->irq_preinstall = mga_driver_irq_preinstall;
56         dev->irq_postinstall = mga_driver_irq_postinstall;
57         dev->irq_uninstall = mga_driver_irq_uninstall;
58         dev->irq_handler = mga_driver_irq_handler;
59         dev->dma_ioctl = mga_dma_buffers;
60         dev->dma_quiescent = mga_driver_dma_quiescent;
61
62         dev->driver_ioctls = mga_ioctls;
63         dev->max_driver_ioctl = mga_max_ioctl;
64
65         dev->driver_name = DRIVER_NAME;
66         dev->driver_desc = DRIVER_DESC;
67         dev->driver_date = DRIVER_DATE;
68         dev->driver_major = DRIVER_MAJOR;
69         dev->driver_minor = DRIVER_MINOR;
70         dev->driver_patchlevel = DRIVER_PATCHLEVEL;
71
72         dev->use_agp = 1;
73         dev->require_agp = 1;
74         dev->use_mtrr = 1;
75         dev->use_dma = 1;
76         dev->use_irq = 1;
77         dev->use_vbl_irq = 1;
78 }
79
80 #ifdef __FreeBSD__
81 static int
82 mga_probe(device_t dev)
83 {
84         return drm_probe(dev, mga_pciidlist);
85 }
86
87 static int
88 mga_attach(device_t nbdev)
89 {
90         drm_device_t *dev = device_get_softc(nbdev);
91
92         bzero(dev, sizeof(drm_device_t));
93         mga_configure(dev);
94         return drm_attach(nbdev, mga_pciidlist);
95 }
96
97 static device_method_t mga_methods[] = {
98         /* Device interface */
99         DEVMETHOD(device_probe,         mga_probe),
100         DEVMETHOD(device_attach,        mga_attach),
101         DEVMETHOD(device_detach,        drm_detach),
102
103         { 0, 0 }
104 };
105
106 static driver_t mga_driver = {
107         "drm",
108         mga_methods,
109         sizeof(drm_device_t)
110 };
111
112 extern devclass_t drm_devclass;
113 DRIVER_MODULE(mga, pci, mga_driver, drm_devclass, 0, 0);
114 MODULE_DEPEND(mga, drm, 1, 1, 1);
115
116 #elif defined(__NetBSD__) || defined(__OpenBSD__)
117 CFDRIVER_DECL(mga, DV_TTY, NULL);
118 #endif