5 * \author Gareth Hughes <gareth@valinux.com>
9 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
10 * All Rights Reserved.
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:
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
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.
34 #include "radeon_drm.h"
35 #include "radeon_drv.h"
37 #include "drm_pciids.h"
40 int radeon_dynclks = 1;
42 MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers\n");
43 module_param_named(no_wb, radeon_no_wb, int, 0444);
45 unsigned int radeon_modeset = 0;
46 module_param_named(modeset, radeon_modeset, int, 0400);
48 MODULE_PARM_DESC(dynclks, "Disable/Enable dynamic clocks");
49 module_param_named(dynclks, radeon_dynclks, int, 0444);
51 static int dri_library_name(struct drm_device * dev, char * buf)
53 drm_radeon_private_t *dev_priv = dev->dev_private;
54 int family = dev_priv->flags & RADEON_FAMILY_MASK;
56 return snprintf(buf, PAGE_SIZE, "%s\n",
57 (family < CHIP_R200) ? "radeon" :
58 ((family < CHIP_R300) ? "r200" :
62 static int radeon_suspend(struct drm_device *dev, pm_message_t state)
64 drm_radeon_private_t *dev_priv = dev->dev_private;
66 /* Disable *all* interrupts */
67 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690)
68 RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
69 RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
73 static int radeon_resume(struct drm_device *dev)
75 drm_radeon_private_t *dev_priv = dev->dev_private;
77 /* Restore interrupt registers */
78 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS690)
79 RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
80 RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
84 static struct pci_device_id pciidlist[] = {
88 extern struct drm_fence_driver radeon_fence_driver;
90 static uint32_t radeon_mem_prios[] = {DRM_BO_MEM_VRAM, DRM_BO_MEM_TT, DRM_BO_MEM_LOCAL};
91 static uint32_t radeon_busy_prios[] = {DRM_BO_MEM_TT, DRM_BO_MEM_VRAM, DRM_BO_MEM_LOCAL};
93 static struct drm_bo_driver radeon_bo_driver = {
94 .mem_type_prio = radeon_mem_prios,
95 .mem_busy_prio = radeon_busy_prios,
96 .num_mem_type_prio = sizeof(radeon_mem_prios)/sizeof(uint32_t),
97 .num_mem_busy_prio = sizeof(radeon_busy_prios)/sizeof(uint32_t),
98 .create_ttm_backend_entry = radeon_create_ttm_backend_entry,
99 .fence_type = radeon_fence_types,
100 .invalidate_caches = radeon_invalidate_caches,
101 .init_mem_type = radeon_init_mem_type,
103 .evict_flags = radeon_evict_flags,
106 static int probe(struct pci_dev *pdev, const struct pci_device_id *ent);
107 static struct drm_driver driver = {
109 DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
110 DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_GEM,
111 .dev_priv_size = sizeof(drm_radeon_buf_priv_t),
112 .load = radeon_driver_load,
113 .firstopen = radeon_driver_firstopen,
114 .open = radeon_driver_open,
115 .preclose = radeon_driver_preclose,
116 .postclose = radeon_driver_postclose,
117 .lastclose = radeon_driver_lastclose,
118 .unload = radeon_driver_unload,
119 .suspend = radeon_suspend,
120 .resume = radeon_resume,
121 .get_vblank_counter = radeon_get_vblank_counter,
122 .enable_vblank = radeon_enable_vblank,
123 .disable_vblank = radeon_disable_vblank,
124 .dri_library_name = dri_library_name,
125 .irq_preinstall = radeon_driver_irq_preinstall,
126 .irq_postinstall = radeon_driver_irq_postinstall,
127 .irq_uninstall = radeon_driver_irq_uninstall,
128 .irq_handler = radeon_driver_irq_handler,
129 .reclaim_buffers = drm_core_reclaim_buffers,
130 .get_map_ofs = drm_core_get_map_ofs,
131 .get_reg_ofs = drm_core_get_reg_ofs,
132 .ioctls = radeon_ioctls,
133 .gem_init_object = radeon_gem_init_object,
134 .gem_free_object = radeon_gem_free_object,
135 .dma_ioctl = radeon_cp_buffers,
136 .master_create = radeon_master_create,
137 .master_destroy = radeon_master_destroy,
139 .owner = THIS_MODULE,
141 .release = drm_release,
145 .fasync = drm_fasync,
146 #if defined(CONFIG_COMPAT) && LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)
147 .compat_ioctl = radeon_compat_ioctl,
152 .id_table = pciidlist,
154 .remove = __devexit_p(drm_cleanup_pci),
157 .fence_driver = &radeon_fence_driver,
158 .bo_driver = &radeon_bo_driver,
163 .major = DRIVER_MAJOR,
164 .minor = DRIVER_MINOR,
165 .patchlevel = DRIVER_PATCHLEVEL,
168 static int probe(struct pci_dev *pdev, const struct pci_device_id *ent)
170 return drm_get_dev(pdev, ent, &driver);
173 static int __init radeon_init(void)
175 driver.num_ioctls = radeon_max_ioctl;
177 if (radeon_modeset == 1)
178 driver.driver_features |= DRIVER_MODESET;
180 return drm_init(&driver, pciidlist);
183 static void __exit radeon_exit(void)
188 module_init(radeon_init);
189 module_exit(radeon_exit);
191 MODULE_AUTHOR(DRIVER_AUTHOR);
192 MODULE_DESCRIPTION(DRIVER_DESC);
193 MODULE_LICENSE("GPL and additional rights");