tdfx_drv.c revision 152909
195584Sanholt/* tdfx_drv.c -- tdfx driver -*- linux-c -*-
2145132Sanholt * Created: Thu Oct  7 10:38:32 1999 by faith@precisioninsight.com
3145132Sanholt */
4139749Simp/*-
595584Sanholt * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
695584Sanholt * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
795584Sanholt * All Rights Reserved.
895584Sanholt *
995584Sanholt * Permission is hereby granted, free of charge, to any person obtaining a
1095584Sanholt * copy of this software and associated documentation files (the "Software"),
1195584Sanholt * to deal in the Software without restriction, including without limitation
1295584Sanholt * the rights to use, copy, modify, merge, publish, distribute, sublicense,
1395584Sanholt * and/or sell copies of the Software, and to permit persons to whom the
1495584Sanholt * Software is furnished to do so, subject to the following conditions:
1595584Sanholt *
1695584Sanholt * The above copyright notice and this permission notice (including the next
1795584Sanholt * paragraph) shall be included in all copies or substantial portions of the
1895584Sanholt * Software.
1995584Sanholt *
2095584Sanholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2195584Sanholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2295584Sanholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
2395584Sanholt * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
2495584Sanholt * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2595584Sanholt * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2695584Sanholt * DEALINGS IN THE SOFTWARE.
2795584Sanholt *
2895584Sanholt * Authors:
2995584Sanholt *    Rickard E. (Rik) Faith <faith@valinux.com>
3095584Sanholt *    Daryll Strauss <daryll@valinux.com>
3195584Sanholt *    Gareth Hughes <gareth@valinux.com>
3295584Sanholt *
3395584Sanholt */
3495584Sanholt
35152909Sanholt#include <sys/cdefs.h>
36152909Sanholt__FBSDID("$FreeBSD: head/sys/dev/drm/tdfx_drv.c 152909 2005-11-28 23:13:57Z anholt $");
37152909Sanholt
38145132Sanholt#include "dev/drm/tdfx_drv.h"
3995584Sanholt#include "dev/drm/drmP.h"
40145132Sanholt#include "dev/drm/drm_pciids.h"
4195584Sanholt
42145132Sanholt/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
43145132Sanholtstatic drm_pci_id_list_t tdfx_pciidlist[] = {
44145132Sanholt	tdfx_PCI_IDS
45145132Sanholt};
4695584Sanholt
47145132Sanholtstatic void tdfx_configure(drm_device_t *dev)
48145132Sanholt{
49152909Sanholt	dev->driver.buf_priv_size	= 1; /* No dev_priv */
50145132Sanholt
51152909Sanholt	dev->driver.max_ioctl		= 0;
52145132Sanholt
53152909Sanholt	dev->driver.name		= DRIVER_NAME;
54152909Sanholt	dev->driver.desc		= DRIVER_DESC;
55152909Sanholt	dev->driver.date		= DRIVER_DATE;
56152909Sanholt	dev->driver.major		= DRIVER_MAJOR;
57152909Sanholt	dev->driver.minor		= DRIVER_MINOR;
58152909Sanholt	dev->driver.patchlevel		= DRIVER_PATCHLEVEL;
59145132Sanholt
60152909Sanholt	dev->driver.use_mtrr		= 1;
61145132Sanholt}
62145132Sanholt
63112015Sanholt#ifdef __FreeBSD__
64145132Sanholtstatic int
65145132Sanholttdfx_probe(device_t dev)
66145132Sanholt{
67145132Sanholt	return drm_probe(dev, tdfx_pciidlist);
68145132Sanholt}
69145132Sanholt
70145132Sanholtstatic int
71145132Sanholttdfx_attach(device_t nbdev)
72145132Sanholt{
73145132Sanholt	drm_device_t *dev = device_get_softc(nbdev);
74145132Sanholt
75145132Sanholt	bzero(dev, sizeof(drm_device_t));
76145132Sanholt	tdfx_configure(dev);
77145132Sanholt	return drm_attach(nbdev, tdfx_pciidlist);
78145132Sanholt}
79145132Sanholt
80145132Sanholtstatic device_method_t tdfx_methods[] = {
81145132Sanholt	/* Device interface */
82145132Sanholt	DEVMETHOD(device_probe,		tdfx_probe),
83145132Sanholt	DEVMETHOD(device_attach,	tdfx_attach),
84145132Sanholt	DEVMETHOD(device_detach,	drm_detach),
85145132Sanholt
86145132Sanholt	{ 0, 0 }
87145132Sanholt};
88145132Sanholt
89145132Sanholtstatic driver_t tdfx_driver = {
90145132Sanholt	"drm",
91145132Sanholt	tdfx_methods,
92145132Sanholt	sizeof(drm_device_t)
93145132Sanholt};
94145132Sanholt
95145132Sanholtextern devclass_t drm_devclass;
96145132SanholtDRIVER_MODULE(tdfx, pci, tdfx_driver, drm_devclass, 0, 0);
97145132SanholtMODULE_DEPEND(tdfx, drm, 1, 1, 1);
98145132Sanholt
99145132Sanholt#elif defined(__NetBSD__) || defined(__OpenBSD__)
100152909Sanholt#ifdef _LKM
101112015SanholtCFDRIVER_DECL(tdfx, DV_TTY, NULL);
102152909Sanholt#else
103152909SanholtCFATTACH_DECL(tdfx, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
104152909Sanholt    drm_activate);
105145132Sanholt#endif
106152909Sanholt#endif
107