Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /** |
| 2 | * \file radeon_drv.c |
| 3 | * ATI Radeon driver |
| 4 | * |
| 5 | * \author Gareth Hughes <gareth@valinux.com> |
| 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
| 10 | * All Rights Reserved. |
| 11 | * |
| 12 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 13 | * copy of this software and associated documentation files (the "Software"), |
| 14 | * to deal in the Software without restriction, including without limitation |
| 15 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 16 | * and/or sell copies of the Software, and to permit persons to whom the |
| 17 | * Software is furnished to do so, subject to the following conditions: |
| 18 | * |
| 19 | * The above copyright notice and this permission notice (including the next |
| 20 | * paragraph) shall be included in all copies or substantial portions of the |
| 21 | * Software. |
| 22 | * |
| 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 26 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 27 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 28 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 29 | * OTHER DEALINGS IN THE SOFTWARE. |
| 30 | */ |
| 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include "drmP.h" |
| 33 | #include "drm.h" |
| 34 | #include "radeon_drm.h" |
| 35 | #include "radeon_drv.h" |
| 36 | |
| 37 | #include "drm_pciids.h" |
| 38 | |
Dave Airlie | 689b9d7 | 2005-09-30 17:09:07 +1000 | [diff] [blame] | 39 | int radeon_no_wb; |
| 40 | |
Niels de Vos | 61a2d07 | 2008-07-31 00:07:23 -0700 | [diff] [blame] | 41 | MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers"); |
Dave Airlie | 689b9d7 | 2005-09-30 17:09:07 +1000 | [diff] [blame] | 42 | module_param_named(no_wb, radeon_no_wb, int, 0444); |
| 43 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 44 | static int radeon_suspend(struct drm_device *dev, pm_message_t state) |
| 45 | { |
| 46 | drm_radeon_private_t *dev_priv = dev->dev_private; |
| 47 | |
Dave Airlie | 03efb88 | 2009-03-10 18:36:38 +1000 | [diff] [blame] | 48 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) |
| 49 | return 0; |
| 50 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 51 | /* Disable *all* interrupts */ |
Alex Deucher | 800b699 | 2009-03-06 11:47:54 -0500 | [diff] [blame] | 52 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 53 | RADEON_WRITE(R500_DxMODE_INT_MASK, 0); |
| 54 | RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static int radeon_resume(struct drm_device *dev) |
| 59 | { |
| 60 | drm_radeon_private_t *dev_priv = dev->dev_private; |
| 61 | |
Dave Airlie | 03efb88 | 2009-03-10 18:36:38 +1000 | [diff] [blame] | 62 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600) |
| 63 | return 0; |
| 64 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 65 | /* Restore interrupt registers */ |
Alex Deucher | 800b699 | 2009-03-06 11:47:54 -0500 | [diff] [blame] | 66 | if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 67 | RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg); |
| 68 | RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg); |
| 69 | return 0; |
| 70 | } |
| 71 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | static struct pci_device_id pciidlist[] = { |
| 73 | radeon_PCI_IDS |
| 74 | }; |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | static struct drm_driver driver = { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 77 | .driver_features = |
| 78 | DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 79 | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | .dev_priv_size = sizeof(drm_radeon_buf_priv_t), |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 81 | .load = radeon_driver_load, |
| 82 | .firstopen = radeon_driver_firstopen, |
| 83 | .open = radeon_driver_open, |
| 84 | .preclose = radeon_driver_preclose, |
| 85 | .postclose = radeon_driver_postclose, |
| 86 | .lastclose = radeon_driver_lastclose, |
| 87 | .unload = radeon_driver_unload, |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 88 | .suspend = radeon_suspend, |
| 89 | .resume = radeon_resume, |
| 90 | .get_vblank_counter = radeon_get_vblank_counter, |
| 91 | .enable_vblank = radeon_enable_vblank, |
| 92 | .disable_vblank = radeon_disable_vblank, |
Dave Airlie | 60f2ee0 | 2008-12-19 10:22:02 +1100 | [diff] [blame] | 93 | .master_create = radeon_master_create, |
| 94 | .master_destroy = radeon_master_destroy, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | .irq_preinstall = radeon_driver_irq_preinstall, |
| 96 | .irq_postinstall = radeon_driver_irq_postinstall, |
| 97 | .irq_uninstall = radeon_driver_irq_uninstall, |
| 98 | .irq_handler = radeon_driver_irq_handler, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | .reclaim_buffers = drm_core_reclaim_buffers, |
| 100 | .get_map_ofs = drm_core_get_map_ofs, |
| 101 | .get_reg_ofs = drm_core_get_reg_ofs, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | .ioctls = radeon_ioctls, |
| 103 | .dma_ioctl = radeon_cp_buffers, |
| 104 | .fops = { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 105 | .owner = THIS_MODULE, |
| 106 | .open = drm_open, |
| 107 | .release = drm_release, |
| 108 | .ioctl = drm_ioctl, |
| 109 | .mmap = drm_mmap, |
| 110 | .poll = drm_poll, |
| 111 | .fasync = drm_fasync, |
Dave Airlie | 9a18664 | 2005-06-23 21:29:18 +1000 | [diff] [blame] | 112 | #ifdef CONFIG_COMPAT |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 113 | .compat_ioctl = radeon_compat_ioctl, |
Dave Airlie | 9a18664 | 2005-06-23 21:29:18 +1000 | [diff] [blame] | 114 | #endif |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 115 | }, |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | .pci_driver = { |
Dave Airlie | 22eae94 | 2005-11-10 22:16:34 +1100 | [diff] [blame] | 118 | .name = DRIVER_NAME, |
| 119 | .id_table = pciidlist, |
| 120 | }, |
| 121 | |
| 122 | .name = DRIVER_NAME, |
| 123 | .desc = DRIVER_DESC, |
| 124 | .date = DRIVER_DATE, |
| 125 | .major = DRIVER_MAJOR, |
| 126 | .minor = DRIVER_MINOR, |
| 127 | .patchlevel = DRIVER_PATCHLEVEL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | static int __init radeon_init(void) |
| 131 | { |
| 132 | driver.num_ioctls = radeon_max_ioctl; |
| 133 | return drm_init(&driver); |
| 134 | } |
| 135 | |
| 136 | static void __exit radeon_exit(void) |
| 137 | { |
| 138 | drm_exit(&driver); |
| 139 | } |
| 140 | |
| 141 | module_init(radeon_init); |
| 142 | module_exit(radeon_exit); |
| 143 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 144 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 145 | MODULE_DESCRIPTION(DRIVER_DESC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | MODULE_LICENSE("GPL and additional rights"); |