blob: 5eb56f83c38a57640d1fff2877ed7410ebfcf869 [file] [log] [blame]
David Dawes44aa4d62002-01-27 20:05:42 +00001/* tdfx_drv.c -- tdfx driver -*- linux-c -*-
Doug Rabsonfa0a35a2000-05-30 17:13:31 +00002 * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
Eric Anholt10ddbc82005-04-16 03:02:52 +00003 */
4/*-
Doug Rabsonfa0a35a2000-05-30 17:13:31 +00005 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
Doug Rabsond399dbc2000-06-13 17:38:09 +00006 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
Doug Rabsonfa0a35a2000-05-30 17:13:31 +00007 * All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
David Dawes44aa4d62002-01-27 20:05:42 +000015 *
Doug Rabsonfa0a35a2000-05-30 17:13:31 +000016 * The above copyright notice and this permission notice (including the next
17 * paragraph) shall be included in all copies or substantial portions of the
18 * Software.
David Dawes44aa4d62002-01-27 20:05:42 +000019 *
Doug Rabsonfa0a35a2000-05-30 17:13:31 +000020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
David Dawes44aa4d62002-01-27 20:05:42 +000027 *
Doug Rabsond399dbc2000-06-13 17:38:09 +000028 * Authors:
29 * Rickard E. (Rik) Faith <faith@valinux.com>
30 * Daryll Strauss <daryll@valinux.com>
David Dawes44aa4d62002-01-27 20:05:42 +000031 * Gareth Hughes <gareth@valinux.com>
Eric Anholt9b2b2332003-04-24 00:46:03 +000032 *
Doug Rabsonfa0a35a2000-05-30 17:13:31 +000033 */
34
Eric Anholtcb5aaa82004-11-06 23:02:07 +000035#include "tdfx_drv.h"
David Dawes44aa4d62002-01-27 20:05:42 +000036#include "drmP.h"
Eric Anholtcb5aaa82004-11-06 23:02:07 +000037#include "drm_pciids.h"
David Dawes44aa4d62002-01-27 20:05:42 +000038
Eric Anholtcb5aaa82004-11-06 23:02:07 +000039/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
40static drm_pci_id_list_t tdfx_pciidlist[] = {
41 tdfx_PCI_IDS
42};
43
Eric Anholtcb5aaa82004-11-06 23:02:07 +000044static void tdfx_configure(drm_device_t *dev)
45{
Eric Anholtc789ea12005-08-05 03:50:23 +000046 dev->driver.buf_priv_size = 1; /* No dev_priv */
Eric Anholtcb5aaa82004-11-06 23:02:07 +000047
Eric Anholtc789ea12005-08-05 03:50:23 +000048 dev->driver.max_ioctl = 0;
Eric Anholtcb5aaa82004-11-06 23:02:07 +000049
Eric Anholtc789ea12005-08-05 03:50:23 +000050 dev->driver.name = DRIVER_NAME;
51 dev->driver.desc = DRIVER_DESC;
52 dev->driver.date = DRIVER_DATE;
53 dev->driver.major = DRIVER_MAJOR;
54 dev->driver.minor = DRIVER_MINOR;
55 dev->driver.patchlevel = DRIVER_PATCHLEVEL;
Eric Anholtcb5aaa82004-11-06 23:02:07 +000056
Eric Anholtc789ea12005-08-05 03:50:23 +000057 dev->driver.use_mtrr = 1;
Eric Anholtcb5aaa82004-11-06 23:02:07 +000058}
Doug Rabsonfa0a35a2000-05-30 17:13:31 +000059
Alan Hourihane74ef13f2002-07-05 08:31:11 +000060#ifdef __FreeBSD__
Eric Anholtcb5aaa82004-11-06 23:02:07 +000061static int
62tdfx_probe(device_t dev)
Dave Airlie5c9ed832004-08-17 13:10:05 +000063{
Eric Anholtcb5aaa82004-11-06 23:02:07 +000064 return drm_probe(dev, tdfx_pciidlist);
Dave Airlie5c9ed832004-08-17 13:10:05 +000065}
Eric Anholtcb5aaa82004-11-06 23:02:07 +000066
67static int
68tdfx_attach(device_t nbdev)
69{
70 drm_device_t *dev = device_get_softc(nbdev);
71
72 bzero(dev, sizeof(drm_device_t));
73 tdfx_configure(dev);
74 return drm_attach(nbdev, tdfx_pciidlist);
75}
76
77static device_method_t tdfx_methods[] = {
78 /* Device interface */
79 DEVMETHOD(device_probe, tdfx_probe),
80 DEVMETHOD(device_attach, tdfx_attach),
81 DEVMETHOD(device_detach, drm_detach),
82
83 { 0, 0 }
84};
85
86static driver_t tdfx_driver = {
87 "drm",
88 tdfx_methods,
89 sizeof(drm_device_t)
90};
91
92extern devclass_t drm_devclass;
Eric Anholt7f2c7f92005-12-30 02:17:05 +000093#if __FreeBSD_version >= 700010
94DRIVER_MODULE(tdfx, vgapci, tdfx_driver, drm_devclass, 0, 0);
95#else
Eric Anholtcb5aaa82004-11-06 23:02:07 +000096DRIVER_MODULE(tdfx, pci, tdfx_driver, drm_devclass, 0, 0);
Eric Anholt7f2c7f92005-12-30 02:17:05 +000097#endif
Eric Anholtcb5aaa82004-11-06 23:02:07 +000098MODULE_DEPEND(tdfx, drm, 1, 1, 1);
99
100#elif defined(__NetBSD__) || defined(__OpenBSD__)
Eric Anholt751765d2005-06-06 06:45:41 +0000101#ifdef _LKM
Eric Anholtcb5aaa82004-11-06 23:02:07 +0000102CFDRIVER_DECL(tdfx, DV_TTY, NULL);
Eric Anholt751765d2005-06-06 06:45:41 +0000103#else
104CFATTACH_DECL(tdfx, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach,
105 drm_activate);
106#endif
Eric Anholtcb5aaa82004-11-06 23:02:07 +0000107#endif