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$");
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
47182080Srnolandstatic void tdfx_configure(struct drm_device *dev)
48145132Sanholt{
49183573Srnoland	dev->driver->driver_features =
50183573Srnoland	    DRIVER_USE_MTRR;
51145132Sanholt
52183573Srnoland	dev->driver->buf_priv_size	= 1; /* No dev_priv */
53145132Sanholt
54183573Srnoland	dev->driver->max_ioctl		= 0;
55145132Sanholt
56183573Srnoland	dev->driver->name		= DRIVER_NAME;
57183573Srnoland	dev->driver->desc		= DRIVER_DESC;
58183573Srnoland	dev->driver->date		= DRIVER_DATE;
59183573Srnoland	dev->driver->major		= DRIVER_MAJOR;
60183573Srnoland	dev->driver->minor		= DRIVER_MINOR;
61183573Srnoland	dev->driver->patchlevel		= DRIVER_PATCHLEVEL;
62145132Sanholt}
63145132Sanholt
64145132Sanholtstatic int
65189563Srnolandtdfx_probe(device_t kdev)
66145132Sanholt{
67189563Srnoland	return drm_probe(kdev, tdfx_pciidlist);
68145132Sanholt}
69145132Sanholt
70145132Sanholtstatic int
71189563Srnolandtdfx_attach(device_t kdev)
72145132Sanholt{
73189563Srnoland	struct drm_device *dev = device_get_softc(kdev);
74145132Sanholt
75183833Srnoland	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
76183604Srnoland	    M_WAITOK | M_ZERO);
77183604Srnoland
78145132Sanholt	tdfx_configure(dev);
79183573Srnoland
80189563Srnoland	return drm_attach(kdev, tdfx_pciidlist);
81145132Sanholt}
82145132Sanholt
83183573Srnolandstatic int
84189563Srnolandtdfx_detach(device_t kdev)
85183573Srnoland{
86189563Srnoland	struct drm_device *dev = device_get_softc(kdev);
87183573Srnoland	int ret;
88183573Srnoland
89189563Srnoland	ret = drm_detach(kdev);
90183573Srnoland
91183833Srnoland	free(dev->driver, DRM_MEM_DRIVER);
92183573Srnoland
93183573Srnoland	return ret;
94183573Srnoland}
95183573Srnoland
96145132Sanholtstatic device_method_t tdfx_methods[] = {
97145132Sanholt	/* Device interface */
98145132Sanholt	DEVMETHOD(device_probe,		tdfx_probe),
99145132Sanholt	DEVMETHOD(device_attach,	tdfx_attach),
100183573Srnoland	DEVMETHOD(device_detach,	tdfx_detach),
101145132Sanholt
102145132Sanholt	{ 0, 0 }
103145132Sanholt};
104145132Sanholt
105145132Sanholtstatic driver_t tdfx_driver = {
106145132Sanholt	"drm",
107145132Sanholt	tdfx_methods,
108182080Srnoland	sizeof(struct drm_device)
109145132Sanholt};
110145132Sanholt
111145132Sanholtextern devclass_t drm_devclass;
112153579SjhbDRIVER_MODULE(tdfx, vgapci, tdfx_driver, drm_devclass, 0, 0);
113145132SanholtMODULE_DEPEND(tdfx, drm, 1, 1, 1);
114