mach64_drv.c revision 145132
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 * $FreeBSD: head/sys/dev/drm/mach64_drv.c 145132 2005-04-16 03:44:47Z anholt $
33145132Sanholt */
34145132Sanholt
35145132Sanholt
36145132Sanholt#include <sys/types.h>
37145132Sanholt
38145132Sanholt#include "dev/drm/drmP.h"
39145132Sanholt#include "dev/drm/drm.h"
40145132Sanholt#include "dev/drm/mach64_drm.h"
41145132Sanholt#include "dev/drm/mach64_drv.h"
42145132Sanholt#include "dev/drm/drm_pciids.h"
43145132Sanholt
44145132Sanholt/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
45145132Sanholtstatic drm_pci_id_list_t mach64_pciidlist[] = {
46145132Sanholt	mach64_PCI_IDS
47145132Sanholt};
48145132Sanholt
49145132Sanholtextern drm_ioctl_desc_t mach64_ioctls[];
50145132Sanholtextern int mach64_max_ioctl;
51145132Sanholt
52145132Sanholtstatic void mach64_configure(drm_device_t *dev)
53145132Sanholt{
54145132Sanholt	dev->dev_priv_size = 1; /* No dev_priv */
55145132Sanholt	dev->pretakedown = mach64_driver_pretakedown;
56145132Sanholt	dev->vblank_wait = mach64_driver_vblank_wait;
57145132Sanholt	dev->irq_preinstall = mach64_driver_irq_preinstall;
58145132Sanholt	dev->irq_postinstall = mach64_driver_irq_postinstall;
59145132Sanholt	dev->irq_uninstall = mach64_driver_irq_uninstall;
60145132Sanholt	dev->irq_handler = mach64_driver_irq_handler;
61145132Sanholt	dev->dma_ioctl = mach64_dma_buffers;
62145132Sanholt
63145132Sanholt	dev->driver_ioctls = mach64_ioctls;
64145132Sanholt	dev->max_driver_ioctl = mach64_max_ioctl;
65145132Sanholt
66145132Sanholt	dev->driver_name = DRIVER_NAME;
67145132Sanholt	dev->driver_desc = DRIVER_DESC;
68145132Sanholt	dev->driver_date = DRIVER_DATE;
69145132Sanholt	dev->driver_major = DRIVER_MAJOR;
70145132Sanholt	dev->driver_minor = DRIVER_MINOR;
71145132Sanholt	dev->driver_patchlevel = DRIVER_PATCHLEVEL;
72145132Sanholt
73145132Sanholt	dev->use_agp = 1;
74145132Sanholt	dev->use_mtrr = 1;
75145132Sanholt	dev->use_pci_dma = 1;
76145132Sanholt	dev->use_dma = 1;
77145132Sanholt	dev->use_irq = 1;
78145132Sanholt	dev->use_vbl_irq = 1;
79145132Sanholt}
80145132Sanholt
81145132Sanholt#ifdef __FreeBSD__
82145132Sanholtstatic int
83145132Sanholtmach64_probe(device_t dev)
84145132Sanholt{
85145132Sanholt	return drm_probe(dev, mach64_pciidlist);
86145132Sanholt}
87145132Sanholt
88145132Sanholtstatic int
89145132Sanholtmach64_attach(device_t nbdev)
90145132Sanholt{
91145132Sanholt	drm_device_t *dev = device_get_softc(nbdev);
92145132Sanholt
93145132Sanholt	bzero(dev, sizeof(drm_device_t));
94145132Sanholt	mach64_configure(dev);
95145132Sanholt	return drm_attach(nbdev, mach64_pciidlist);
96145132Sanholt}
97145132Sanholt
98145132Sanholtstatic device_method_t mach64_methods[] = {
99145132Sanholt	/* Device interface */
100145132Sanholt	DEVMETHOD(device_probe,		mach64_probe),
101145132Sanholt	DEVMETHOD(device_attach,	mach64_attach),
102145132Sanholt	DEVMETHOD(device_detach,	drm_detach),
103145132Sanholt
104145132Sanholt	{ 0, 0 }
105145132Sanholt};
106145132Sanholt
107145132Sanholtstatic driver_t mach64_driver = {
108145132Sanholt	"drm",
109145132Sanholt	mach64_methods,
110145132Sanholt	sizeof(drm_device_t)
111145132Sanholt};
112145132Sanholt
113145132Sanholtextern devclass_t drm_devclass;
114145132SanholtDRIVER_MODULE(mach64, pci, mach64_driver, drm_devclass, 0, 0);
115145132SanholtMODULE_DEPEND(mach64, drm, 1, 1, 1);
116145132Sanholt
117145132Sanholt#elif defined(__NetBSD__) || defined(__OpenBSD__)
118145132SanholtCFDRIVER_DECL(mach64, DV_TTY, NULL);
119145132Sanholt#endif
120