David Dawes | 44aa4d6 | 2002-01-27 20:05:42 +0000 | [diff] [blame] | 1 | /* tdfx_drv.c -- tdfx driver -*- linux-c -*- |
Doug Rabson | fa0a35a | 2000-05-30 17:13:31 +0000 | [diff] [blame] | 2 | * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com |
Eric Anholt | 10ddbc8 | 2005-04-16 03:02:52 +0000 | [diff] [blame] | 3 | */ |
| 4 | /*- |
Doug Rabson | fa0a35a | 2000-05-30 17:13:31 +0000 | [diff] [blame] | 5 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
Doug Rabson | d399dbc | 2000-06-13 17:38:09 +0000 | [diff] [blame] | 6 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
Doug Rabson | fa0a35a | 2000-05-30 17:13:31 +0000 | [diff] [blame] | 7 | * 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 Dawes | 44aa4d6 | 2002-01-27 20:05:42 +0000 | [diff] [blame] | 15 | * |
Doug Rabson | fa0a35a | 2000-05-30 17:13:31 +0000 | [diff] [blame] | 16 | * 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 Dawes | 44aa4d6 | 2002-01-27 20:05:42 +0000 | [diff] [blame] | 19 | * |
Doug Rabson | fa0a35a | 2000-05-30 17:13:31 +0000 | [diff] [blame] | 20 | * 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 Dawes | 44aa4d6 | 2002-01-27 20:05:42 +0000 | [diff] [blame] | 27 | * |
Doug Rabson | d399dbc | 2000-06-13 17:38:09 +0000 | [diff] [blame] | 28 | * Authors: |
| 29 | * Rickard E. (Rik) Faith <faith@valinux.com> |
| 30 | * Daryll Strauss <daryll@valinux.com> |
David Dawes | 44aa4d6 | 2002-01-27 20:05:42 +0000 | [diff] [blame] | 31 | * Gareth Hughes <gareth@valinux.com> |
Eric Anholt | 9b2b233 | 2003-04-24 00:46:03 +0000 | [diff] [blame] | 32 | * |
Doug Rabson | fa0a35a | 2000-05-30 17:13:31 +0000 | [diff] [blame] | 33 | */ |
| 34 | |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 35 | #include "tdfx_drv.h" |
David Dawes | 44aa4d6 | 2002-01-27 20:05:42 +0000 | [diff] [blame] | 36 | #include "drmP.h" |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 37 | #include "drm_pciids.h" |
David Dawes | 44aa4d6 | 2002-01-27 20:05:42 +0000 | [diff] [blame] | 38 | |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 39 | /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ |
| 40 | static drm_pci_id_list_t tdfx_pciidlist[] = { |
| 41 | tdfx_PCI_IDS |
| 42 | }; |
| 43 | |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 44 | static void tdfx_configure(drm_device_t *dev) |
| 45 | { |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 46 | dev->driver.buf_priv_size = 1; /* No dev_priv */ |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 47 | |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 48 | dev->driver.max_ioctl = 0; |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 49 | |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 50 | 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 Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 56 | |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 57 | dev->driver.use_mtrr = 1; |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 58 | } |
Doug Rabson | fa0a35a | 2000-05-30 17:13:31 +0000 | [diff] [blame] | 59 | |
Alan Hourihane | 74ef13f | 2002-07-05 08:31:11 +0000 | [diff] [blame] | 60 | #ifdef __FreeBSD__ |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 61 | static int |
| 62 | tdfx_probe(device_t dev) |
Dave Airlie | 5c9ed83 | 2004-08-17 13:10:05 +0000 | [diff] [blame] | 63 | { |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 64 | return drm_probe(dev, tdfx_pciidlist); |
Dave Airlie | 5c9ed83 | 2004-08-17 13:10:05 +0000 | [diff] [blame] | 65 | } |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 66 | |
| 67 | static int |
| 68 | tdfx_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 | |
| 77 | static 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 | |
| 86 | static driver_t tdfx_driver = { |
| 87 | "drm", |
| 88 | tdfx_methods, |
| 89 | sizeof(drm_device_t) |
| 90 | }; |
| 91 | |
| 92 | extern devclass_t drm_devclass; |
Eric Anholt | 7f2c7f9 | 2005-12-30 02:17:05 +0000 | [diff] [blame] | 93 | #if __FreeBSD_version >= 700010 |
| 94 | DRIVER_MODULE(tdfx, vgapci, tdfx_driver, drm_devclass, 0, 0); |
| 95 | #else |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 96 | DRIVER_MODULE(tdfx, pci, tdfx_driver, drm_devclass, 0, 0); |
Eric Anholt | 7f2c7f9 | 2005-12-30 02:17:05 +0000 | [diff] [blame] | 97 | #endif |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 98 | MODULE_DEPEND(tdfx, drm, 1, 1, 1); |
| 99 | |
| 100 | #elif defined(__NetBSD__) || defined(__OpenBSD__) |
Eric Anholt | 751765d | 2005-06-06 06:45:41 +0000 | [diff] [blame] | 101 | #ifdef _LKM |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 102 | CFDRIVER_DECL(tdfx, DV_TTY, NULL); |
Eric Anholt | 751765d | 2005-06-06 06:45:41 +0000 | [diff] [blame] | 103 | #else |
| 104 | CFATTACH_DECL(tdfx, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach, |
| 105 | drm_activate); |
| 106 | #endif |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 107 | #endif |