Merge branch 'vendor/OPENSSL'
[dragonfly.git] / sys / dev / drm / r128_drv.c
1 /* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
2  * Created: Mon Dec 13 09:47:27 1999 by faith@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  * $DragonFly: src/sys/dev/drm/r128_drv.c,v 1.1 2008/04/05 18:12:29 hasso Exp $
33  */
34
35 #include "drmP.h"
36 #include "drm.h"
37 #include "r128_drm.h"
38 #include "r128_drv.h"
39 #include "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 r128_pciidlist[] = {
43         r128_PCI_IDS
44 };
45
46 static void r128_configure(drm_device_t *dev)
47 {
48         dev->driver.buf_priv_size       = sizeof(drm_r128_buf_priv_t);
49         dev->driver.preclose            = r128_driver_preclose;
50         dev->driver.lastclose           = r128_driver_lastclose;
51         dev->driver.vblank_wait         = r128_driver_vblank_wait;
52         dev->driver.irq_preinstall      = r128_driver_irq_preinstall;
53         dev->driver.irq_postinstall     = r128_driver_irq_postinstall;
54         dev->driver.irq_uninstall       = r128_driver_irq_uninstall;
55         dev->driver.irq_handler         = r128_driver_irq_handler;
56         dev->driver.dma_ioctl           = r128_cce_buffers;
57
58         dev->driver.ioctls              = r128_ioctls;
59         dev->driver.max_ioctl           = r128_max_ioctl;
60
61         dev->driver.name                = DRIVER_NAME;
62         dev->driver.desc                = DRIVER_DESC;
63         dev->driver.date                = DRIVER_DATE;
64         dev->driver.major               = DRIVER_MAJOR;
65         dev->driver.minor               = DRIVER_MINOR;
66         dev->driver.patchlevel          = DRIVER_PATCHLEVEL;
67
68         dev->driver.use_agp             = 1;
69         dev->driver.use_mtrr            = 1;
70         dev->driver.use_pci_dma         = 1;
71         dev->driver.use_sg              = 1;
72         dev->driver.use_dma             = 1;
73         dev->driver.use_irq             = 1;
74         dev->driver.use_vbl_irq         = 1;
75 }
76
77 #if defined(__FreeBSD__) || defined(__DragonFly__)
78 static int
79 r128_probe(device_t dev)
80 {
81         return drm_probe(dev, r128_pciidlist);
82 }
83
84 static int
85 r128_attach(device_t nbdev)
86 {
87         drm_device_t *dev = device_get_softc(nbdev);
88
89         bzero(dev, sizeof(drm_device_t));
90         r128_configure(dev);
91         return drm_attach(nbdev, r128_pciidlist);
92 }
93
94 static device_method_t r128_methods[] = {
95         /* Device interface */
96         DEVMETHOD(device_probe,         r128_probe),
97         DEVMETHOD(device_attach,        r128_attach),
98         DEVMETHOD(device_detach,        drm_detach),
99
100         { 0, 0 }
101 };
102
103 static driver_t r128_driver = {
104         "drm",
105         r128_methods,
106         sizeof(drm_device_t)
107 };
108
109 extern devclass_t drm_devclass;
110 #if __FreeBSD_version >= 700010
111 DRIVER_MODULE(r128, vgapci, r128_driver, drm_devclass, 0, 0);
112 #else
113 DRIVER_MODULE(r128, pci, r128_driver, drm_devclass, 0, 0);
114 #endif
115 MODULE_DEPEND(r128, drm, 1, 1, 1);
116
117 #elif defined(__NetBSD__) || defined(__OpenBSD__)
118 #ifdef _LKM
119 CFDRIVER_DECL(r128, DV_TTY, NULL);
120 #else
121 CFATTACH_DECL(r128, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
122     drm_activate);
123 #endif
124 #endif