mach64_drv.c revision 153579
1145132Sanholt/* mach64_drv.c -- ATI Rage 128 driver -*- linux-c -*-
2145132Sanholt * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
3145132Sanholt */
4145132Sanholt/*-
5145132Sanholt * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
6145132Sanholt * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
7145132Sanholt * All Rights Reserved.
8145132Sanholt *
9145132Sanholt * Permission is hereby granted, free of charge, to any person obtaining a
10145132Sanholt * copy of this software and associated documentation files (the "Software"),
11145132Sanholt * to deal in the Software without restriction, including without limitation
12145132Sanholt * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13145132Sanholt * and/or sell copies of the Software, and to permit persons to whom the
14145132Sanholt * Software is furnished to do so, subject to the following conditions:
15145132Sanholt *
16145132Sanholt * The above copyright notice and this permission notice (including the next
17145132Sanholt * paragraph) shall be included in all copies or substantial portions of the
18145132Sanholt * Software.
19145132Sanholt *
20145132Sanholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21145132Sanholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22145132Sanholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23145132Sanholt * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24145132Sanholt * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25145132Sanholt * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26145132Sanholt * OTHER DEALINGS IN THE SOFTWARE.
27145132Sanholt *
28145132Sanholt * Authors:
29145132Sanholt *    Rickard E. (Rik) Faith <faith@valinux.com>
30145132Sanholt *    Gareth Hughes <gareth@valinux.com>
31145132Sanholt */
32145132Sanholt
33152909Sanholt#include <sys/cdefs.h>
34152909Sanholt__FBSDID("$FreeBSD: head/sys/dev/drm/mach64_drv.c 153579 2005-12-20 22:44:36Z jhb $");
35145132Sanholt
36152909Sanholt
37145132Sanholt#include <sys/types.h>
38145132Sanholt
39145132Sanholt#include "dev/drm/drmP.h"
40145132Sanholt#include "dev/drm/drm.h"
41145132Sanholt#include "dev/drm/mach64_drm.h"
42145132Sanholt#include "dev/drm/mach64_drv.h"
43145132Sanholt#include "dev/drm/drm_pciids.h"
44145132Sanholt
45145132Sanholt/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
46145132Sanholtstatic drm_pci_id_list_t mach64_pciidlist[] = {
47145132Sanholt	mach64_PCI_IDS
48145132Sanholt};
49145132Sanholt
50145132Sanholtstatic void mach64_configure(drm_device_t *dev)
51145132Sanholt{
52152909Sanholt	dev->driver.buf_priv_size	= 1; /* No dev_priv */
53152909Sanholt	dev->driver.lastclose		= mach64_driver_lastclose;
54152909Sanholt	dev->driver.vblank_wait		= mach64_driver_vblank_wait;
55152909Sanholt	dev->driver.irq_preinstall	= mach64_driver_irq_preinstall;
56152909Sanholt	dev->driver.irq_postinstall	= mach64_driver_irq_postinstall;
57152909Sanholt	dev->driver.irq_uninstall	= mach64_driver_irq_uninstall;
58152909Sanholt	dev->driver.irq_handler		= mach64_driver_irq_handler;
59152909Sanholt	dev->driver.dma_ioctl		= mach64_dma_buffers;
60145132Sanholt
61152909Sanholt	dev->driver.ioctls		= mach64_ioctls;
62152909Sanholt	dev->driver.max_ioctl		= mach64_max_ioctl;
63145132Sanholt
64152909Sanholt	dev->driver.name		= DRIVER_NAME;
65152909Sanholt	dev->driver.desc		= DRIVER_DESC;
66152909Sanholt	dev->driver.date		= DRIVER_DATE;
67152909Sanholt	dev->driver.major		= DRIVER_MAJOR;
68152909Sanholt	dev->driver.minor		= DRIVER_MINOR;
69152909Sanholt	dev->driver.patchlevel		= DRIVER_PATCHLEVEL;
70145132Sanholt
71152909Sanholt	dev->driver.use_agp		= 1;
72152909Sanholt	dev->driver.use_mtrr		= 1;
73152909Sanholt	dev->driver.use_pci_dma		= 1;
74152909Sanholt	dev->driver.use_dma		= 1;
75152909Sanholt	dev->driver.use_irq		= 1;
76152909Sanholt	dev->driver.use_vbl_irq		= 1;
77145132Sanholt}
78145132Sanholt
79145132Sanholt#ifdef __FreeBSD__
80145132Sanholtstatic int
81145132Sanholtmach64_probe(device_t dev)
82145132Sanholt{
83145132Sanholt	return drm_probe(dev, mach64_pciidlist);
84145132Sanholt}
85145132Sanholt
86145132Sanholtstatic int
87145132Sanholtmach64_attach(device_t nbdev)
88145132Sanholt{
89145132Sanholt	drm_device_t *dev = device_get_softc(nbdev);
90145132Sanholt
91145132Sanholt	bzero(dev, sizeof(drm_device_t));
92145132Sanholt	mach64_configure(dev);
93145132Sanholt	return drm_attach(nbdev, mach64_pciidlist);
94145132Sanholt}
95145132Sanholt
96145132Sanholtstatic device_method_t mach64_methods[] = {
97145132Sanholt	/* Device interface */
98145132Sanholt	DEVMETHOD(device_probe,		mach64_probe),
99145132Sanholt	DEVMETHOD(device_attach,	mach64_attach),
100145132Sanholt	DEVMETHOD(device_detach,	drm_detach),
101145132Sanholt
102145132Sanholt	{ 0, 0 }
103145132Sanholt};
104145132Sanholt
105145132Sanholtstatic driver_t mach64_driver = {
106145132Sanholt	"drm",
107145132Sanholt	mach64_methods,
108145132Sanholt	sizeof(drm_device_t)
109145132Sanholt};
110145132Sanholt
111145132Sanholtextern devclass_t drm_devclass;
112153579Sjhb#if __FreeBSD_version >= 700010
113153579SjhbDRIVER_MODULE(mach64, vgapci, mach64_driver, drm_devclass, 0, 0);
114153579Sjhb#else
115145132SanholtDRIVER_MODULE(mach64, pci, mach64_driver, drm_devclass, 0, 0);
116153579Sjhb#endif
117145132SanholtMODULE_DEPEND(mach64, drm, 1, 1, 1);
118145132Sanholt
119145132Sanholt#elif defined(__NetBSD__) || defined(__OpenBSD__)
120145132SanholtCFDRIVER_DECL(mach64, DV_TTY, NULL);
121145132Sanholt#endif
122