tdfx_drv.c revision 183604
1233294Sstas/* tdfx_drv.c -- tdfx driver -*- linux-c -*- 2178825Sdfr * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com 3178825Sdfr */ 4178825Sdfr/*- 5178825Sdfr * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 6178825Sdfr * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 7178825Sdfr * All Rights Reserved. 8178825Sdfr * 9178825Sdfr * Permission is hereby granted, free of charge, to any person obtaining a 10178825Sdfr * copy of this software and associated documentation files (the "Software"), 11178825Sdfr * to deal in the Software without restriction, including without limitation 12178825Sdfr * the rights to use, copy, modify, merge, publish, distribute, sublicense, 13178825Sdfr * and/or sell copies of the Software, and to permit persons to whom the 14178825Sdfr * Software is furnished to do so, subject to the following conditions: 15178825Sdfr * 16178825Sdfr * The above copyright notice and this permission notice (including the next 17178825Sdfr * paragraph) shall be included in all copies or substantial portions of the 18178825Sdfr * Software. 19178825Sdfr * 20178825Sdfr * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21178825Sdfr * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22178825Sdfr * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23178825Sdfr * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 24178825Sdfr * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 25178825Sdfr * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26178825Sdfr * DEALINGS IN THE SOFTWARE. 27178825Sdfr * 28178825Sdfr * Authors: 29178825Sdfr * Rickard E. (Rik) Faith <faith@valinux.com> 30178825Sdfr * Daryll Strauss <daryll@valinux.com> 31178825Sdfr * Gareth Hughes <gareth@valinux.com> 32178825Sdfr * 33178825Sdfr */ 34178825Sdfr 35178825Sdfr#include <sys/cdefs.h> 36178825Sdfr__FBSDID("$FreeBSD: head/sys/dev/drm/tdfx_drv.c 183604 2008-10-04 14:48:40Z rnoland $"); 37178825Sdfr 38178825Sdfr#include "dev/drm/tdfx_drv.h" 39178825Sdfr#include "dev/drm/drmP.h" 40178825Sdfr#include "dev/drm/drm_pciids.h" 41178825Sdfr 42178825Sdfr/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ 43178825Sdfrstatic drm_pci_id_list_t tdfx_pciidlist[] = { 44178825Sdfr tdfx_PCI_IDS 45178825Sdfr}; 46178825Sdfr 47178825Sdfrstatic void tdfx_configure(struct drm_device *dev) 48178825Sdfr{ 49178825Sdfr dev->driver->driver_features = 50178825Sdfr DRIVER_USE_MTRR; 51178825Sdfr 52178825Sdfr dev->driver->buf_priv_size = 1; /* No dev_priv */ 53178825Sdfr 54178825Sdfr dev->driver->max_ioctl = 0; 55178825Sdfr 56178825Sdfr dev->driver->name = DRIVER_NAME; 57178825Sdfr dev->driver->desc = DRIVER_DESC; 58178825Sdfr dev->driver->date = DRIVER_DATE; 59178825Sdfr dev->driver->major = DRIVER_MAJOR; 60178825Sdfr dev->driver->minor = DRIVER_MINOR; 61178825Sdfr dev->driver->patchlevel = DRIVER_PATCHLEVEL; 62178825Sdfr} 63178825Sdfr 64static int 65tdfx_probe(device_t dev) 66{ 67 return drm_probe(dev, tdfx_pciidlist); 68} 69 70static int 71tdfx_attach(device_t nbdev) 72{ 73 struct drm_device *dev = device_get_softc(nbdev); 74 75 bzero(dev, sizeof(struct drm_device)); 76 77 dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, 78 M_WAITOK | M_ZERO); 79 80 tdfx_configure(dev); 81 82 return drm_attach(nbdev, tdfx_pciidlist); 83} 84 85static int 86tdfx_detach(device_t nbdev) 87{ 88 struct drm_device *dev = device_get_softc(nbdev); 89 int ret; 90 91 ret = drm_detach(nbdev); 92 93 free(dev->driver, M_DRM); 94 95 return ret; 96} 97 98static device_method_t tdfx_methods[] = { 99 /* Device interface */ 100 DEVMETHOD(device_probe, tdfx_probe), 101 DEVMETHOD(device_attach, tdfx_attach), 102 DEVMETHOD(device_detach, tdfx_detach), 103 104 { 0, 0 } 105}; 106 107static driver_t tdfx_driver = { 108 "drm", 109 tdfx_methods, 110 sizeof(struct drm_device) 111}; 112 113extern devclass_t drm_devclass; 114#if __FreeBSD_version >= 700010 115DRIVER_MODULE(tdfx, vgapci, tdfx_driver, drm_devclass, 0, 0); 116#else 117DRIVER_MODULE(tdfx, pci, tdfx_driver, drm_devclass, 0, 0); 118#endif 119MODULE_DEPEND(tdfx, drm, 1, 1, 1); 120