r128_drv.c revision 183573
195584Sanholt/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*- 2145132Sanholt * Created: Mon Dec 13 09:47:27 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 * VA LINUX SYSTEMS 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 2695584Sanholt * OTHER DEALINGS IN THE SOFTWARE. 2795584Sanholt * 2895584Sanholt * Authors: 2995584Sanholt * Rickard E. (Rik) Faith <faith@valinux.com> 3095584Sanholt * Gareth Hughes <gareth@valinux.com> 3195584Sanholt * 3295584Sanholt */ 3395584Sanholt 34152909Sanholt#include <sys/cdefs.h> 35152909Sanholt__FBSDID("$FreeBSD: head/sys/dev/drm/r128_drv.c 183573 2008-10-03 16:59:11Z rnoland $"); 36152909Sanholt 3795584Sanholt#include "dev/drm/drmP.h" 38112015Sanholt#include "dev/drm/drm.h" 3995746Sanholt#include "dev/drm/r128_drm.h" 4095584Sanholt#include "dev/drm/r128_drv.h" 41145132Sanholt#include "dev/drm/drm_pciids.h" 4295584Sanholt 43145132Sanholt/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ 44145132Sanholtstatic drm_pci_id_list_t r128_pciidlist[] = { 45145132Sanholt r128_PCI_IDS 46145132Sanholt}; 4795584Sanholt 48182080Srnolandstatic void r128_configure(struct drm_device *dev) 49145132Sanholt{ 50183573Srnoland dev->driver->driver_features = 51183573Srnoland DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | 52183573Srnoland DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ; 53145132Sanholt 54183573Srnoland dev->driver->buf_priv_size = sizeof(drm_r128_buf_priv_t); 55183573Srnoland dev->driver->preclose = r128_driver_preclose; 56183573Srnoland dev->driver->lastclose = r128_driver_lastclose; 57183573Srnoland dev->driver->get_vblank_counter = r128_get_vblank_counter; 58183573Srnoland dev->driver->enable_vblank = r128_enable_vblank; 59183573Srnoland dev->driver->disable_vblank = r128_disable_vblank; 60183573Srnoland dev->driver->irq_preinstall = r128_driver_irq_preinstall; 61183573Srnoland dev->driver->irq_postinstall = r128_driver_irq_postinstall; 62183573Srnoland dev->driver->irq_uninstall = r128_driver_irq_uninstall; 63183573Srnoland dev->driver->irq_handler = r128_driver_irq_handler; 64183573Srnoland dev->driver->dma_ioctl = r128_cce_buffers; 65145132Sanholt 66183573Srnoland dev->driver->ioctls = r128_ioctls; 67183573Srnoland dev->driver->max_ioctl = r128_max_ioctl; 68145132Sanholt 69183573Srnoland dev->driver->name = DRIVER_NAME; 70183573Srnoland dev->driver->desc = DRIVER_DESC; 71183573Srnoland dev->driver->date = DRIVER_DATE; 72183573Srnoland dev->driver->major = DRIVER_MAJOR; 73183573Srnoland dev->driver->minor = DRIVER_MINOR; 74183573Srnoland dev->driver->patchlevel = DRIVER_PATCHLEVEL; 75145132Sanholt} 76145132Sanholt 77145132Sanholtstatic int 78145132Sanholtr128_probe(device_t dev) 79145132Sanholt{ 80145132Sanholt return drm_probe(dev, r128_pciidlist); 81145132Sanholt} 82145132Sanholt 83145132Sanholtstatic int 84145132Sanholtr128_attach(device_t nbdev) 85145132Sanholt{ 86182080Srnoland struct drm_device *dev = device_get_softc(nbdev); 87145132Sanholt 88182080Srnoland bzero(dev, sizeof(struct drm_device)); 89183573Srnoland 90183573Srnoland dev->driver = malloc(sizeof(struct drm_driver_info), M_DRM, M_NOWAIT | M_ZERO); 91145132Sanholt r128_configure(dev); 92183573Srnoland 93145132Sanholt return drm_attach(nbdev, r128_pciidlist); 94145132Sanholt} 95145132Sanholt 96183573Srnolandstatic int 97183573Srnolandr128_detach(device_t nbdev) 98183573Srnoland{ 99183573Srnoland struct drm_device *dev = device_get_softc(nbdev); 100183573Srnoland int ret; 101183573Srnoland 102183573Srnoland ret = drm_detach(nbdev); 103183573Srnoland 104183573Srnoland free(dev->driver, M_DRM); 105183573Srnoland 106183573Srnoland return ret; 107183573Srnoland} 108183573Srnoland 109145132Sanholtstatic device_method_t r128_methods[] = { 110145132Sanholt /* Device interface */ 111145132Sanholt DEVMETHOD(device_probe, r128_probe), 112145132Sanholt DEVMETHOD(device_attach, r128_attach), 113183573Srnoland DEVMETHOD(device_detach, r128_detach), 114145132Sanholt 115145132Sanholt { 0, 0 } 116145132Sanholt}; 117145132Sanholt 118145132Sanholtstatic driver_t r128_driver = { 119145132Sanholt "drm", 120145132Sanholt r128_methods, 121182080Srnoland sizeof(struct drm_device) 122145132Sanholt}; 123145132Sanholt 124145132Sanholtextern devclass_t drm_devclass; 125153579Sjhb#if __FreeBSD_version >= 700010 126153579SjhbDRIVER_MODULE(r128, vgapci, r128_driver, drm_devclass, 0, 0); 127153579Sjhb#else 128145132SanholtDRIVER_MODULE(r128, pci, r128_driver, drm_devclass, 0, 0); 129153579Sjhb#endif 130145132SanholtMODULE_DEPEND(r128, drm, 1, 1, 1); 131