radeon_drv.c revision 145132
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 * $FreeBSD: head/sys/dev/drm/radeon_drv.c 145132 2005-04-16 03:44:47Z anholt $
31 */
32
33#include "dev/drm/drmP.h"
34#include "dev/drm/drm.h"
35#include "dev/drm/radeon_drm.h"
36#include "dev/drm/radeon_drv.h"
37#include "dev/drm/drm_pciids.h"
38
39/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
40static drm_pci_id_list_t radeon_pciidlist[] = {
41	radeon_PCI_IDS
42};
43
44extern drm_ioctl_desc_t radeon_ioctls[];
45extern int radeon_max_ioctl;
46
47static void radeon_configure(drm_device_t *dev)
48{
49	dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
50	dev->preinit = radeon_preinit;
51	dev->postcleanup = radeon_postcleanup;
52	dev->prerelease = radeon_driver_prerelease;
53	dev->pretakedown = radeon_driver_pretakedown;
54	dev->open_helper = radeon_driver_open_helper;
55	dev->free_filp_priv = radeon_driver_free_filp_priv;
56	dev->vblank_wait = radeon_driver_vblank_wait;
57	dev->irq_preinstall = radeon_driver_irq_preinstall;
58	dev->irq_postinstall = radeon_driver_irq_postinstall;
59	dev->irq_uninstall = radeon_driver_irq_uninstall;
60	dev->irq_handler = radeon_driver_irq_handler;
61	dev->dma_ioctl = radeon_cp_buffers;
62
63	dev->driver_ioctls = radeon_ioctls;
64	dev->max_driver_ioctl = radeon_max_ioctl;
65
66	dev->driver_name = DRIVER_NAME;
67	dev->driver_desc = DRIVER_DESC;
68	dev->driver_date = DRIVER_DATE;
69	dev->driver_major = DRIVER_MAJOR;
70	dev->driver_minor = DRIVER_MINOR;
71	dev->driver_patchlevel = DRIVER_PATCHLEVEL;
72
73	dev->use_agp = 1;
74	dev->use_mtrr = 1;
75	dev->use_pci_dma = 1;
76	dev->use_sg = 1;
77	dev->use_dma = 1;
78	dev->use_irq = 1;
79	dev->use_vbl_irq = 1;
80}
81
82#ifdef __FreeBSD__
83static int
84radeon_probe(device_t dev)
85{
86	return drm_probe(dev, radeon_pciidlist);
87}
88
89static int
90radeon_attach(device_t nbdev)
91{
92	drm_device_t *dev = device_get_softc(nbdev);
93
94	bzero(dev, sizeof(drm_device_t));
95	radeon_configure(dev);
96	return drm_attach(nbdev, radeon_pciidlist);
97}
98
99static device_method_t radeon_methods[] = {
100	/* Device interface */
101	DEVMETHOD(device_probe,		radeon_probe),
102	DEVMETHOD(device_attach,	radeon_attach),
103	DEVMETHOD(device_detach,	drm_detach),
104
105	{ 0, 0 }
106};
107
108static driver_t radeon_driver = {
109	"drm",
110	radeon_methods,
111	sizeof(drm_device_t)
112};
113
114extern devclass_t drm_devclass;
115DRIVER_MODULE(radeon, pci, radeon_driver, drm_devclass, 0, 0);
116MODULE_DEPEND(radeon, drm, 1, 1, 1);
117
118#elif defined(__NetBSD__) || defined(__OpenBSD__)
119CFDRIVER_DECL(radeon, DV_TTY, NULL);
120#endif /* __FreeBSD__ */
121