Alan Hourihane | 74ef13f | 2002-07-05 08:31:11 +0000 | [diff] [blame] | 1 | /* radeon_drv.c -- ATI Radeon driver -*- linux-c -*- |
| 2 | * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com |
Eric Anholt | 10ddbc8 | 2005-04-16 03:02:52 +0000 | [diff] [blame] | 3 | */ |
| 4 | /*- |
Alan Hourihane | 74ef13f | 2002-07-05 08:31:11 +0000 | [diff] [blame] | 5 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
| 6 | * All Rights Reserved. |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the "Software"), |
| 10 | * to deal in the Software without restriction, including without limitation |
| 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | * and/or sell copies of the Software, and to permit persons to whom the |
| 13 | * Software is furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice (including the next |
| 16 | * paragraph) shall be included in all copies or substantial portions of the |
| 17 | * Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 23 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 24 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 25 | * OTHER DEALINGS IN THE SOFTWARE. |
| 26 | * |
| 27 | * Authors: |
| 28 | * Gareth Hughes <gareth@valinux.com> |
Eric Anholt | 9b2b233 | 2003-04-24 00:46:03 +0000 | [diff] [blame] | 29 | * |
Alan Hourihane | 74ef13f | 2002-07-05 08:31:11 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
Alan Hourihane | 74ef13f | 2002-07-05 08:31:11 +0000 | [diff] [blame] | 32 | #include "drmP.h" |
| 33 | #include "drm.h" |
| 34 | #include "radeon_drm.h" |
| 35 | #include "radeon_drv.h" |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 36 | #include "drm_pciids.h" |
Alan Hourihane | 74ef13f | 2002-07-05 08:31:11 +0000 | [diff] [blame] | 37 | |
Dave Airlie | f42cdc8 | 2005-09-30 06:41:10 +0000 | [diff] [blame] | 38 | int radeon_no_wb; |
| 39 | |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 40 | /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */ |
| 41 | static drm_pci_id_list_t radeon_pciidlist[] = { |
| 42 | radeon_PCI_IDS |
| 43 | }; |
| 44 | |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 45 | static void radeon_configure(drm_device_t *dev) |
| 46 | { |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 47 | dev->driver.buf_priv_size = sizeof(drm_radeon_buf_priv_t); |
| 48 | dev->driver.load = radeon_driver_load; |
| 49 | dev->driver.unload = radeon_driver_unload; |
| 50 | dev->driver.firstopen = radeon_driver_firstopen; |
| 51 | dev->driver.open = radeon_driver_open; |
| 52 | dev->driver.preclose = radeon_driver_preclose; |
| 53 | dev->driver.postclose = radeon_driver_postclose; |
| 54 | dev->driver.lastclose = radeon_driver_lastclose; |
| 55 | dev->driver.vblank_wait = radeon_driver_vblank_wait; |
| 56 | dev->driver.irq_preinstall = radeon_driver_irq_preinstall; |
| 57 | dev->driver.irq_postinstall = radeon_driver_irq_postinstall; |
| 58 | dev->driver.irq_uninstall = radeon_driver_irq_uninstall; |
| 59 | dev->driver.irq_handler = radeon_driver_irq_handler; |
| 60 | dev->driver.dma_ioctl = radeon_cp_buffers; |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 61 | |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 62 | dev->driver.ioctls = radeon_ioctls; |
| 63 | dev->driver.max_ioctl = radeon_max_ioctl; |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 64 | |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 65 | dev->driver.name = DRIVER_NAME; |
| 66 | dev->driver.desc = DRIVER_DESC; |
| 67 | dev->driver.date = DRIVER_DATE; |
| 68 | dev->driver.major = DRIVER_MAJOR; |
| 69 | dev->driver.minor = DRIVER_MINOR; |
| 70 | dev->driver.patchlevel = DRIVER_PATCHLEVEL; |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 71 | |
Eric Anholt | c789ea1 | 2005-08-05 03:50:23 +0000 | [diff] [blame] | 72 | dev->driver.use_agp = 1; |
| 73 | dev->driver.use_mtrr = 1; |
| 74 | dev->driver.use_pci_dma = 1; |
| 75 | dev->driver.use_sg = 1; |
| 76 | dev->driver.use_dma = 1; |
| 77 | dev->driver.use_irq = 1; |
| 78 | dev->driver.use_vbl_irq = 1; |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 79 | } |
Alan Hourihane | 74ef13f | 2002-07-05 08:31:11 +0000 | [diff] [blame] | 80 | |
Eric Anholt | 9b2b233 | 2003-04-24 00:46:03 +0000 | [diff] [blame] | 81 | #ifdef __FreeBSD__ |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 82 | static int |
| 83 | radeon_probe(device_t dev) |
| 84 | { |
| 85 | return drm_probe(dev, radeon_pciidlist); |
| 86 | } |
| 87 | |
| 88 | static int |
| 89 | radeon_attach(device_t nbdev) |
| 90 | { |
| 91 | drm_device_t *dev = device_get_softc(nbdev); |
| 92 | |
| 93 | bzero(dev, sizeof(drm_device_t)); |
| 94 | radeon_configure(dev); |
| 95 | return drm_attach(nbdev, radeon_pciidlist); |
| 96 | } |
| 97 | |
| 98 | static device_method_t radeon_methods[] = { |
| 99 | /* Device interface */ |
| 100 | DEVMETHOD(device_probe, radeon_probe), |
| 101 | DEVMETHOD(device_attach, radeon_attach), |
| 102 | DEVMETHOD(device_detach, drm_detach), |
| 103 | |
| 104 | { 0, 0 } |
| 105 | }; |
| 106 | |
| 107 | static driver_t radeon_driver = { |
| 108 | "drm", |
| 109 | radeon_methods, |
| 110 | sizeof(drm_device_t) |
| 111 | }; |
| 112 | |
| 113 | extern devclass_t drm_devclass; |
Eric Anholt | 7f2c7f9 | 2005-12-30 02:17:05 +0000 | [diff] [blame] | 114 | #if __FreeBSD_version >= 700010 |
| 115 | DRIVER_MODULE(radeon, vgapci, radeon_driver, drm_devclass, 0, 0); |
| 116 | #else |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 117 | DRIVER_MODULE(radeon, pci, radeon_driver, drm_devclass, 0, 0); |
Eric Anholt | 7f2c7f9 | 2005-12-30 02:17:05 +0000 | [diff] [blame] | 118 | #endif |
Eric Anholt | c9202c8 | 2004-11-06 01:41:47 +0000 | [diff] [blame] | 119 | MODULE_DEPEND(radeon, drm, 1, 1, 1); |
| 120 | |
Eric Anholt | cb5aaa8 | 2004-11-06 23:02:07 +0000 | [diff] [blame] | 121 | #elif defined(__NetBSD__) || defined(__OpenBSD__) |
Eric Anholt | 751765d | 2005-06-06 06:45:41 +0000 | [diff] [blame] | 122 | #ifdef _LKM |
Eric Anholt | 9b2b233 | 2003-04-24 00:46:03 +0000 | [diff] [blame] | 123 | CFDRIVER_DECL(radeon, DV_TTY, NULL); |
Eric Anholt | 751765d | 2005-06-06 06:45:41 +0000 | [diff] [blame] | 124 | #else |
| 125 | CFATTACH_DECL(radeon, sizeof(drm_device_t), drm_probe, drm_attach, drm_detach, |
| 126 | drm_activate); |
| 127 | #endif |
Eric Anholt | 9b2b233 | 2003-04-24 00:46:03 +0000 | [diff] [blame] | 128 | #endif /* __FreeBSD__ */ |