]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/drm/radeon_drv.c
This commit was generated by cvs2svn to compensate for changes in r173682,
[FreeBSD/FreeBSD.git] / sys / dev / drm / radeon_drv.c
1 /* radeon_drv.c -- ATI Radeon driver -*- linux-c -*-
2  * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
3  */
4 /*-
5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6  * All Rights Reserved.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the next
16  * paragraph) shall be included in all copies or substantial portions of the
17  * Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  *
27  * Authors:
28  *    Gareth Hughes <gareth@valinux.com>
29  *
30  */
31
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
34
35 #include "dev/drm/drmP.h"
36 #include "dev/drm/drm.h"
37 #include "dev/drm/radeon_drm.h"
38 #include "dev/drm/radeon_drv.h"
39 #include "dev/drm/drm_pciids.h"
40
41 int radeon_no_wb;
42
43 /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
44 static drm_pci_id_list_t radeon_pciidlist[] = {
45         radeon_PCI_IDS
46 };
47
48 static void radeon_configure(drm_device_t *dev)
49 {
50         dev->driver.buf_priv_size       = sizeof(drm_radeon_buf_priv_t);
51         dev->driver.load                = radeon_driver_load;
52         dev->driver.unload              = radeon_driver_unload;
53         dev->driver.firstopen           = radeon_driver_firstopen;
54         dev->driver.open                = radeon_driver_open;
55         dev->driver.preclose            = radeon_driver_preclose;
56         dev->driver.postclose           = radeon_driver_postclose;
57         dev->driver.lastclose           = radeon_driver_lastclose;
58         dev->driver.vblank_wait         = radeon_driver_vblank_wait;
59         dev->driver.irq_preinstall      = radeon_driver_irq_preinstall;
60         dev->driver.irq_postinstall     = radeon_driver_irq_postinstall;
61         dev->driver.irq_uninstall       = radeon_driver_irq_uninstall;
62         dev->driver.irq_handler         = radeon_driver_irq_handler;
63         dev->driver.dma_ioctl           = radeon_cp_buffers;
64
65         dev->driver.ioctls              = radeon_ioctls;
66         dev->driver.max_ioctl           = radeon_max_ioctl;
67
68         dev->driver.name                = DRIVER_NAME;
69         dev->driver.desc                = DRIVER_DESC;
70         dev->driver.date                = DRIVER_DATE;
71         dev->driver.major               = DRIVER_MAJOR;
72         dev->driver.minor               = DRIVER_MINOR;
73         dev->driver.patchlevel          = DRIVER_PATCHLEVEL;
74
75         dev->driver.use_agp             = 1;
76         dev->driver.use_mtrr            = 1;
77         dev->driver.use_pci_dma         = 1;
78         dev->driver.use_sg              = 1;
79         dev->driver.use_dma             = 1;
80         dev->driver.use_irq             = 1;
81         dev->driver.use_vbl_irq         = 1;
82 }
83
84 #ifdef __FreeBSD__
85 static int
86 radeon_probe(device_t dev)
87 {
88         return drm_probe(dev, radeon_pciidlist);
89 }
90
91 static int
92 radeon_attach(device_t nbdev)
93 {
94         drm_device_t *dev = device_get_softc(nbdev);
95
96         bzero(dev, sizeof(drm_device_t));
97         radeon_configure(dev);
98         return drm_attach(nbdev, radeon_pciidlist);
99 }
100
101 static device_method_t radeon_methods[] = {
102         /* Device interface */
103         DEVMETHOD(device_probe,         radeon_probe),
104         DEVMETHOD(device_attach,        radeon_attach),
105         DEVMETHOD(device_detach,        drm_detach),
106
107         { 0, 0 }
108 };
109
110 static driver_t radeon_driver = {
111         "drm",
112         radeon_methods,
113         sizeof(drm_device_t)
114 };
115
116 extern devclass_t drm_devclass;
117 #if __FreeBSD_version >= 700010
118 DRIVER_MODULE(radeon, vgapci, radeon_driver, drm_devclass, 0, 0);
119 #else
120 DRIVER_MODULE(radeon, pci, radeon_driver, drm_devclass, 0, 0);
121 #endif
122 MODULE_DEPEND(radeon, drm, 1, 1, 1);
123
124 #elif defined(__NetBSD__) || defined(__OpenBSD__)
125 #ifdef _LKM
126 CFDRIVER_DECL(radeon, DV_TTY, NULL);
127 #else
128 CFATTACH_DECL(radeon, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
129     drm_activate);
130 #endif
131 #endif /* __FreeBSD__ */