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$"); 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); 55189130Srnoland dev->driver->load = r128_driver_load; 56183573Srnoland dev->driver->preclose = r128_driver_preclose; 57183573Srnoland dev->driver->lastclose = r128_driver_lastclose; 58183573Srnoland dev->driver->get_vblank_counter = r128_get_vblank_counter; 59183573Srnoland dev->driver->enable_vblank = r128_enable_vblank; 60183573Srnoland dev->driver->disable_vblank = r128_disable_vblank; 61183573Srnoland dev->driver->irq_preinstall = r128_driver_irq_preinstall; 62183573Srnoland dev->driver->irq_postinstall = r128_driver_irq_postinstall; 63183573Srnoland dev->driver->irq_uninstall = r128_driver_irq_uninstall; 64183573Srnoland dev->driver->irq_handler = r128_driver_irq_handler; 65183573Srnoland dev->driver->dma_ioctl = r128_cce_buffers; 66145132Sanholt 67183573Srnoland dev->driver->ioctls = r128_ioctls; 68183573Srnoland dev->driver->max_ioctl = r128_max_ioctl; 69145132Sanholt 70183573Srnoland dev->driver->name = DRIVER_NAME; 71183573Srnoland dev->driver->desc = DRIVER_DESC; 72183573Srnoland dev->driver->date = DRIVER_DATE; 73183573Srnoland dev->driver->major = DRIVER_MAJOR; 74183573Srnoland dev->driver->minor = DRIVER_MINOR; 75183573Srnoland dev->driver->patchlevel = DRIVER_PATCHLEVEL; 76145132Sanholt} 77145132Sanholt 78145132Sanholtstatic int 79189563Srnolandr128_probe(device_t kdev) 80145132Sanholt{ 81189563Srnoland return drm_probe(kdev, r128_pciidlist); 82145132Sanholt} 83145132Sanholt 84145132Sanholtstatic int 85189563Srnolandr128_attach(device_t kdev) 86145132Sanholt{ 87189563Srnoland struct drm_device *dev = device_get_softc(kdev); 88145132Sanholt 89183833Srnoland dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER, 90183604Srnoland M_WAITOK | M_ZERO); 91183604Srnoland 92145132Sanholt r128_configure(dev); 93183573Srnoland 94189563Srnoland return drm_attach(kdev, r128_pciidlist); 95145132Sanholt} 96145132Sanholt 97189130Srnolandint r128_driver_load(struct drm_device * dev, unsigned long flags) 98189130Srnoland{ 99189130Srnoland return drm_vblank_init(dev, 1); 100189130Srnoland} 101189130Srnoland 102183573Srnolandstatic int 103189563Srnolandr128_detach(device_t kdev) 104183573Srnoland{ 105189563Srnoland struct drm_device *dev = device_get_softc(kdev); 106183573Srnoland int ret; 107183573Srnoland 108189563Srnoland ret = drm_detach(kdev); 109183573Srnoland 110183833Srnoland free(dev->driver, DRM_MEM_DRIVER); 111183573Srnoland 112183573Srnoland return ret; 113183573Srnoland} 114183573Srnoland 115145132Sanholtstatic device_method_t r128_methods[] = { 116145132Sanholt /* Device interface */ 117145132Sanholt DEVMETHOD(device_probe, r128_probe), 118145132Sanholt DEVMETHOD(device_attach, r128_attach), 119183573Srnoland DEVMETHOD(device_detach, r128_detach), 120145132Sanholt 121145132Sanholt { 0, 0 } 122145132Sanholt}; 123145132Sanholt 124145132Sanholtstatic driver_t r128_driver = { 125145132Sanholt "drm", 126145132Sanholt r128_methods, 127182080Srnoland sizeof(struct drm_device) 128145132Sanholt}; 129145132Sanholt 130145132Sanholtextern devclass_t drm_devclass; 131153579SjhbDRIVER_MODULE(r128, vgapci, r128_driver, drm_devclass, 0, 0); 132145132SanholtMODULE_DEPEND(r128, drm, 1, 1, 1); 133