blob: f66bc795604e635e53941508a7241d75ff72fd62 [file] [log] [blame]
Alan Hourihane74ef13f2002-07-05 08:31:11 +00001/* radeon_drv.c -- ATI Radeon driver -*- linux-c -*-
2 * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
Eric Anholt10ddbc82005-04-16 03:02:52 +00003 */
4/*-
Alan Hourihane74ef13f2002-07-05 08:31:11 +00005 * 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>
Eric Anholt9b2b2332003-04-24 00:46:03 +000029 *
Alan Hourihane74ef13f2002-07-05 08:31:11 +000030 */
31
Alan Hourihane74ef13f2002-07-05 08:31:11 +000032#include "drmP.h"
33#include "drm.h"
34#include "radeon_drm.h"
35#include "radeon_drv.h"
Eric Anholtc9202c82004-11-06 01:41:47 +000036#include "drm_pciids.h"
Alan Hourihane74ef13f2002-07-05 08:31:11 +000037
Dave Airlief42cdc82005-09-30 06:41:10 +000038int radeon_no_wb;
39
Eric Anholtc9202c82004-11-06 01:41:47 +000040/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
41static drm_pci_id_list_t radeon_pciidlist[] = {
42 radeon_PCI_IDS
43};
44
Eric Anholtc9202c82004-11-06 01:41:47 +000045static void radeon_configure(drm_device_t *dev)
46{
Eric Anholtc789ea12005-08-05 03:50:23 +000047 dev->driver.buf_priv_size = sizeof(drm_radeon_buf_priv_t);
48 dev->driver.load = radeon_driver_load;
49 dev->driver.unload = radeon_driver_unload;
50 dev->driver.firstopen = radeon_driver_firstopen;
51 dev->driver.open = radeon_driver_open;
52 dev->driver.preclose = radeon_driver_preclose;
53 dev->driver.postclose = radeon_driver_postclose;
54 dev->driver.lastclose = radeon_driver_lastclose;
55 dev->driver.vblank_wait = radeon_driver_vblank_wait;
56 dev->driver.irq_preinstall = radeon_driver_irq_preinstall;
57 dev->driver.irq_postinstall = radeon_driver_irq_postinstall;
58 dev->driver.irq_uninstall = radeon_driver_irq_uninstall;
59 dev->driver.irq_handler = radeon_driver_irq_handler;
60 dev->driver.dma_ioctl = radeon_cp_buffers;
Eric Anholtc9202c82004-11-06 01:41:47 +000061
Eric Anholtc789ea12005-08-05 03:50:23 +000062 dev->driver.ioctls = radeon_ioctls;
63 dev->driver.max_ioctl = radeon_max_ioctl;
Eric Anholtc9202c82004-11-06 01:41:47 +000064
Eric Anholtc789ea12005-08-05 03:50:23 +000065 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;
Eric Anholtc9202c82004-11-06 01:41:47 +000071
Eric Anholtc789ea12005-08-05 03:50:23 +000072 dev->driver.use_agp = 1;
73 dev->driver.use_mtrr = 1;
74 dev->driver.use_pci_dma = 1;
75 dev->driver.use_sg = 1;
76 dev->driver.use_dma = 1;
77 dev->driver.use_irq = 1;
78 dev->driver.use_vbl_irq = 1;
Eric Anholtc9202c82004-11-06 01:41:47 +000079}
Alan Hourihane74ef13f2002-07-05 08:31:11 +000080
Eric Anholt9b2b2332003-04-24 00:46:03 +000081#ifdef __FreeBSD__
Eric Anholtc9202c82004-11-06 01:41:47 +000082static int
83radeon_probe(device_t dev)
84{
85 return drm_probe(dev, radeon_pciidlist);
86}
87
88static int
89radeon_attach(device_t nbdev)
90{
91 drm_device_t *dev = device_get_softc(nbdev);
92
93 bzero(dev, sizeof(drm_device_t));
94 radeon_configure(dev);
95 return drm_attach(nbdev, radeon_pciidlist);
96}
97
98static device_method_t radeon_methods[] = {
99 /* Device interface */
100 DEVMETHOD(device_probe, radeon_probe),
101 DEVMETHOD(device_attach, radeon_attach),
102 DEVMETHOD(device_detach, drm_detach),
103
104 { 0, 0 }
105};
106
107static driver_t radeon_driver = {
108 "drm",
109 radeon_methods,
110 sizeof(drm_device_t)
111};
112
113extern devclass_t drm_devclass;
Eric Anholt7f2c7f92005-12-30 02:17:05 +0000114#if __FreeBSD_version >= 700010
115DRIVER_MODULE(radeon, vgapci, radeon_driver, drm_devclass, 0, 0);
116#else
Eric Anholtc9202c82004-11-06 01:41:47 +0000117DRIVER_MODULE(radeon, pci, radeon_driver, drm_devclass, 0, 0);
Eric Anholt7f2c7f92005-12-30 02:17:05 +0000118#endif
Eric Anholtc9202c82004-11-06 01:41:47 +0000119MODULE_DEPEND(radeon, drm, 1, 1, 1);
120
Eric Anholtcb5aaa82004-11-06 23:02:07 +0000121#elif defined(__NetBSD__) || defined(__OpenBSD__)
Eric Anholt751765d2005-06-06 06:45:41 +0000122#ifdef _LKM
Eric Anholt9b2b2332003-04-24 00:46:03 +0000123CFDRIVER_DECL(radeon, DV_TTY, NULL);
Eric Anholt751765d2005-06-06 06:45:41 +0000124#else
125CFATTACH_DECL(radeon, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
126 drm_activate);
127#endif
Eric Anholt9b2b2332003-04-24 00:46:03 +0000128#endif /* __FreeBSD__ */