Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 28 | #include <drm/drmP.h> |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 29 | #include "radeon.h" |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 30 | #include <drm/radeon_drm.h> |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 31 | #include "radeon_asic.h" |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 32 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 33 | #include <linux/vga_switcheroo.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 34 | #include <linux/slab.h> |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 35 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 36 | /** |
| 37 | * radeon_driver_unload_kms - Main unload function for KMS. |
| 38 | * |
| 39 | * @dev: drm dev pointer |
| 40 | * |
| 41 | * This is the main unload function for KMS (all asics). |
| 42 | * It calls radeon_modeset_fini() to tear down the |
| 43 | * displays, and radeon_device_fini() to tear down |
| 44 | * the rest of the device (CP, writeback, etc.). |
| 45 | * Returns 0 on success. |
| 46 | */ |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 47 | int radeon_driver_unload_kms(struct drm_device *dev) |
| 48 | { |
| 49 | struct radeon_device *rdev = dev->dev_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 50 | |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 51 | if (rdev == NULL) |
| 52 | return 0; |
Alex Deucher | c491707 | 2012-07-31 17:14:35 -0400 | [diff] [blame] | 53 | radeon_acpi_fini(rdev); |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 54 | radeon_modeset_fini(rdev); |
| 55 | radeon_device_fini(rdev); |
| 56 | kfree(rdev); |
| 57 | dev->dev_private = NULL; |
| 58 | return 0; |
| 59 | } |
| 60 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 61 | /** |
| 62 | * radeon_driver_load_kms - Main load function for KMS. |
| 63 | * |
| 64 | * @dev: drm dev pointer |
| 65 | * @flags: device flags |
| 66 | * |
| 67 | * This is the main load function for KMS (all asics). |
| 68 | * It calls radeon_device_init() to set up the non-display |
| 69 | * parts of the chip (asic init, CP, writeback, etc.), and |
| 70 | * radeon_modeset_init() to set up the display parts |
| 71 | * (crtcs, encoders, hotplug detect, etc.). |
| 72 | * Returns 0 on success, error on failure. |
| 73 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 74 | int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags) |
| 75 | { |
| 76 | struct radeon_device *rdev; |
Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 77 | int r, acpi_status; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 78 | |
| 79 | rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL); |
| 80 | if (rdev == NULL) { |
| 81 | return -ENOMEM; |
| 82 | } |
| 83 | dev->dev_private = (void *)rdev; |
| 84 | |
| 85 | /* update BUS flag */ |
Dave Airlie | 8410ea3 | 2010-12-15 03:16:38 +1000 | [diff] [blame] | 86 | if (drm_pci_device_is_agp(dev)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 87 | flags |= RADEON_IS_AGP; |
Jon Mason | 58b6542 | 2011-06-27 16:07:50 +0000 | [diff] [blame] | 88 | } else if (pci_is_pcie(dev->pdev)) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 89 | flags |= RADEON_IS_PCIE; |
| 90 | } else { |
| 91 | flags |= RADEON_IS_PCI; |
| 92 | } |
| 93 | |
Jerome Glisse | 6cf8a3f | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 94 | /* radeon_device_init should report only fatal error |
| 95 | * like memory allocation failure or iomapping failure, |
| 96 | * or memory manager initialization failure, it must |
| 97 | * properly initialize the GPU MC controller and permit |
| 98 | * VRAM allocation |
| 99 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 100 | r = radeon_device_init(rdev, dev, dev->pdev, flags); |
| 101 | if (r) { |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 102 | dev_err(&dev->pdev->dev, "Fatal error during GPU init\n"); |
| 103 | goto out; |
Jerome Glisse | 6cf8a3f | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 104 | } |
Alberto Milone | d7a2952 | 2010-07-06 11:40:24 -0400 | [diff] [blame] | 105 | |
Jerome Glisse | 6cf8a3f | 2009-09-10 21:46:48 +0200 | [diff] [blame] | 106 | /* Again modeset_init should fail only on fatal error |
| 107 | * otherwise it should provide enough functionalities |
| 108 | * for shadowfb to run |
| 109 | */ |
| 110 | r = radeon_modeset_init(rdev); |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 111 | if (r) |
| 112 | dev_err(&dev->pdev->dev, "Fatal error during modeset init\n"); |
Luca Tettamanti | fda4b25 | 2012-07-30 21:20:35 +0200 | [diff] [blame] | 113 | |
| 114 | /* Call ACPI methods: require modeset init |
| 115 | * but failure is not fatal |
| 116 | */ |
| 117 | if (!r) { |
| 118 | acpi_status = radeon_acpi_init(rdev); |
| 119 | if (acpi_status) |
| 120 | dev_dbg(&dev->pdev->dev, |
| 121 | "Error during ACPI methods call\n"); |
| 122 | } |
| 123 | |
Jerome Glisse | cf0fe45 | 2009-12-09 18:21:55 +0100 | [diff] [blame] | 124 | out: |
| 125 | if (r) |
| 126 | radeon_driver_unload_kms(dev); |
| 127 | return r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 128 | } |
| 129 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 130 | /** |
| 131 | * radeon_set_filp_rights - Set filp right. |
| 132 | * |
| 133 | * @dev: drm dev pointer |
| 134 | * @owner: drm file |
| 135 | * @applier: drm file |
| 136 | * @value: value |
| 137 | * |
| 138 | * Sets the filp rights for the device (all asics). |
| 139 | */ |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 140 | static void radeon_set_filp_rights(struct drm_device *dev, |
| 141 | struct drm_file **owner, |
| 142 | struct drm_file *applier, |
| 143 | uint32_t *value) |
| 144 | { |
| 145 | mutex_lock(&dev->struct_mutex); |
| 146 | if (*value == 1) { |
| 147 | /* wants rights */ |
| 148 | if (!*owner) |
| 149 | *owner = applier; |
| 150 | } else if (*value == 0) { |
| 151 | /* revokes rights */ |
| 152 | if (*owner == applier) |
| 153 | *owner = NULL; |
| 154 | } |
| 155 | *value = *owner == applier ? 1 : 0; |
| 156 | mutex_unlock(&dev->struct_mutex); |
| 157 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 158 | |
| 159 | /* |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 160 | * Userspace get information ioctl |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 161 | */ |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 162 | /** |
| 163 | * radeon_info_ioctl - answer a device specific request. |
| 164 | * |
| 165 | * @rdev: radeon device pointer |
| 166 | * @data: request object |
| 167 | * @filp: drm filp |
| 168 | * |
| 169 | * This function is used to pass device specific parameters to the userspace |
| 170 | * drivers. Examples include: pci device id, pipeline parms, tiling params, |
| 171 | * etc. (all asics). |
| 172 | * Returns 0 on success, -EINVAL on failure. |
| 173 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 174 | int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) |
| 175 | { |
| 176 | struct radeon_device *rdev = dev->dev_private; |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 177 | struct drm_radeon_info *info = data; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 178 | struct radeon_mode_info *minfo = &rdev->mode_info; |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 179 | uint32_t value, *value_ptr; |
| 180 | uint64_t value64, *value_ptr64; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 181 | struct drm_crtc *crtc; |
| 182 | int i, found; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 183 | |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 184 | /* TIMESTAMP is a 64-bit value, needs special handling. */ |
| 185 | if (info->request == RADEON_INFO_TIMESTAMP) { |
| 186 | if (rdev->family >= CHIP_R600) { |
| 187 | value_ptr64 = (uint64_t*)((unsigned long)info->value); |
| 188 | if (rdev->family >= CHIP_TAHITI) { |
| 189 | value64 = si_get_gpu_clock(rdev); |
| 190 | } else { |
| 191 | value64 = r600_get_gpu_clock(rdev); |
| 192 | } |
| 193 | |
| 194 | if (DRM_COPY_TO_USER(value_ptr64, &value64, sizeof(value64))) { |
| 195 | DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); |
| 196 | return -EFAULT; |
| 197 | } |
| 198 | return 0; |
| 199 | } else { |
| 200 | DRM_DEBUG_KMS("timestamp is r6xx+ only!\n"); |
| 201 | return -EINVAL; |
| 202 | } |
| 203 | } |
| 204 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 205 | value_ptr = (uint32_t *)((unsigned long)info->value); |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 206 | if (DRM_COPY_FROM_USER(&value, value_ptr, sizeof(value))) { |
| 207 | DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__); |
Dr. David Alan Gilbert | d8ab355 | 2010-08-02 09:43:52 +1000 | [diff] [blame] | 208 | return -EFAULT; |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 209 | } |
Dr. David Alan Gilbert | d8ab355 | 2010-08-02 09:43:52 +1000 | [diff] [blame] | 210 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 211 | switch (info->request) { |
| 212 | case RADEON_INFO_DEVICE_ID: |
| 213 | value = dev->pci_device; |
| 214 | break; |
| 215 | case RADEON_INFO_NUM_GB_PIPES: |
| 216 | value = rdev->num_gb_pipes; |
| 217 | break; |
Alex Deucher | f779b3e | 2009-08-19 19:11:39 -0400 | [diff] [blame] | 218 | case RADEON_INFO_NUM_Z_PIPES: |
| 219 | value = rdev->num_z_pipes; |
| 220 | break; |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 221 | case RADEON_INFO_ACCEL_WORKING: |
Alex Deucher | 148a03b | 2010-06-03 19:00:03 -0400 | [diff] [blame] | 222 | /* xf86-video-ati 6.13.0 relies on this being false for evergreen */ |
| 223 | if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK)) |
| 224 | value = false; |
| 225 | else |
| 226 | value = rdev->accel_working; |
Jerome Glisse | 733289c | 2009-09-16 15:24:21 +0200 | [diff] [blame] | 227 | break; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 228 | case RADEON_INFO_CRTC_FROM_ID: |
| 229 | for (i = 0, found = 0; i < rdev->num_crtc; i++) { |
| 230 | crtc = (struct drm_crtc *)minfo->crtcs[i]; |
| 231 | if (crtc && crtc->base.id == value) { |
Alex Deucher | 0baf2d8 | 2010-07-21 14:05:35 -0400 | [diff] [blame] | 232 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); |
| 233 | value = radeon_crtc->crtc_id; |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 234 | found = 1; |
| 235 | break; |
| 236 | } |
| 237 | } |
| 238 | if (!found) { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 239 | DRM_DEBUG_KMS("unknown crtc id %d\n", value); |
Jerome Glisse | bc35afd | 2010-05-12 18:01:13 +0200 | [diff] [blame] | 240 | return -EINVAL; |
| 241 | } |
| 242 | break; |
Alex Deucher | 148a03b | 2010-06-03 19:00:03 -0400 | [diff] [blame] | 243 | case RADEON_INFO_ACCEL_WORKING2: |
| 244 | value = rdev->accel_working; |
| 245 | break; |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 246 | case RADEON_INFO_TILING_CONFIG: |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 247 | if (rdev->family >= CHIP_TAHITI) |
| 248 | value = rdev->config.si.tile_config; |
| 249 | else if (rdev->family >= CHIP_CAYMAN) |
Alex Deucher | fecf1d0 | 2011-03-02 20:07:29 -0500 | [diff] [blame] | 250 | value = rdev->config.cayman.tile_config; |
| 251 | else if (rdev->family >= CHIP_CEDAR) |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 252 | value = rdev->config.evergreen.tile_config; |
| 253 | else if (rdev->family >= CHIP_RV770) |
| 254 | value = rdev->config.rv770.tile_config; |
| 255 | else if (rdev->family >= CHIP_R600) |
| 256 | value = rdev->config.r600.tile_config; |
| 257 | else { |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 258 | DRM_DEBUG_KMS("tiling config is r6xx+ only!\n"); |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 259 | return -EINVAL; |
| 260 | } |
Alex Deucher | b824b36 | 2010-08-12 08:25:47 -0400 | [diff] [blame] | 261 | break; |
Dave Airlie | ab9e1f5 | 2010-07-13 11:11:11 +1000 | [diff] [blame] | 262 | case RADEON_INFO_WANT_HYPERZ: |
Marek Olšák | 43861f7 | 2010-08-07 03:36:34 +0200 | [diff] [blame] | 263 | /* The "value" here is both an input and output parameter. |
| 264 | * If the input value is 1, filp requests hyper-z access. |
| 265 | * If the input value is 0, filp revokes its hyper-z access. |
| 266 | * |
| 267 | * When returning, the value is 1 if filp owns hyper-z access, |
| 268 | * 0 otherwise. */ |
| 269 | if (value >= 2) { |
| 270 | DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", value); |
| 271 | return -EINVAL; |
Dave Airlie | ab9e1f5 | 2010-07-13 11:11:11 +1000 | [diff] [blame] | 272 | } |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 273 | radeon_set_filp_rights(dev, &rdev->hyperz_filp, filp, &value); |
| 274 | break; |
| 275 | case RADEON_INFO_WANT_CMASK: |
| 276 | /* The same logic as Hyper-Z. */ |
| 277 | if (value >= 2) { |
| 278 | DRM_DEBUG_KMS("WANT_CMASK: invalid value %d\n", value); |
| 279 | return -EINVAL; |
Marek Olšák | 43861f7 | 2010-08-07 03:36:34 +0200 | [diff] [blame] | 280 | } |
Marek Olšák | 9eba4a9 | 2011-01-05 05:46:48 +0100 | [diff] [blame] | 281 | radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, &value); |
Alex Deucher | e7aeeba | 2010-06-04 13:10:12 -0400 | [diff] [blame] | 282 | break; |
Alex Deucher | 58bbf01 | 2011-01-24 17:14:26 -0500 | [diff] [blame] | 283 | case RADEON_INFO_CLOCK_CRYSTAL_FREQ: |
| 284 | /* return clock value in KHz */ |
Alex Deucher | 454d2e2 | 2013-02-14 10:04:02 -0500 | [diff] [blame^] | 285 | if (rdev->asic->get_xclk) |
| 286 | value = radeon_get_xclk(rdev) * 10; |
| 287 | else |
| 288 | value = rdev->clock.spll.reference_freq * 10; |
Alex Deucher | 58bbf01 | 2011-01-24 17:14:26 -0500 | [diff] [blame] | 289 | break; |
Dave Airlie | 486af18 | 2011-03-01 14:32:27 +1000 | [diff] [blame] | 290 | case RADEON_INFO_NUM_BACKENDS: |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 291 | if (rdev->family >= CHIP_TAHITI) |
| 292 | value = rdev->config.si.max_backends_per_se * |
| 293 | rdev->config.si.max_shader_engines; |
| 294 | else if (rdev->family >= CHIP_CAYMAN) |
Alex Deucher | fecf1d0 | 2011-03-02 20:07:29 -0500 | [diff] [blame] | 295 | value = rdev->config.cayman.max_backends_per_se * |
| 296 | rdev->config.cayman.max_shader_engines; |
| 297 | else if (rdev->family >= CHIP_CEDAR) |
Dave Airlie | 486af18 | 2011-03-01 14:32:27 +1000 | [diff] [blame] | 298 | value = rdev->config.evergreen.max_backends; |
| 299 | else if (rdev->family >= CHIP_RV770) |
| 300 | value = rdev->config.rv770.max_backends; |
| 301 | else if (rdev->family >= CHIP_R600) |
| 302 | value = rdev->config.r600.max_backends; |
| 303 | else { |
| 304 | return -EINVAL; |
| 305 | } |
| 306 | break; |
Alex Deucher | 6565945 | 2011-04-26 13:27:43 -0400 | [diff] [blame] | 307 | case RADEON_INFO_NUM_TILE_PIPES: |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 308 | if (rdev->family >= CHIP_TAHITI) |
| 309 | value = rdev->config.si.max_tile_pipes; |
| 310 | else if (rdev->family >= CHIP_CAYMAN) |
Alex Deucher | 6565945 | 2011-04-26 13:27:43 -0400 | [diff] [blame] | 311 | value = rdev->config.cayman.max_tile_pipes; |
| 312 | else if (rdev->family >= CHIP_CEDAR) |
| 313 | value = rdev->config.evergreen.max_tile_pipes; |
| 314 | else if (rdev->family >= CHIP_RV770) |
| 315 | value = rdev->config.rv770.max_tile_pipes; |
| 316 | else if (rdev->family >= CHIP_R600) |
| 317 | value = rdev->config.r600.max_tile_pipes; |
| 318 | else { |
| 319 | return -EINVAL; |
| 320 | } |
| 321 | break; |
Alex Deucher | 8aeb96f | 2011-05-03 19:28:02 -0400 | [diff] [blame] | 322 | case RADEON_INFO_FUSION_GART_WORKING: |
| 323 | value = 1; |
| 324 | break; |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 325 | case RADEON_INFO_BACKEND_MAP: |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 326 | if (rdev->family >= CHIP_TAHITI) |
| 327 | value = rdev->config.si.backend_map; |
| 328 | else if (rdev->family >= CHIP_CAYMAN) |
Alex Deucher | e55b942 | 2011-07-15 19:53:52 +0000 | [diff] [blame] | 329 | value = rdev->config.cayman.backend_map; |
| 330 | else if (rdev->family >= CHIP_CEDAR) |
| 331 | value = rdev->config.evergreen.backend_map; |
| 332 | else if (rdev->family >= CHIP_RV770) |
| 333 | value = rdev->config.rv770.backend_map; |
| 334 | else if (rdev->family >= CHIP_R600) |
| 335 | value = rdev->config.r600.backend_map; |
| 336 | else { |
| 337 | return -EINVAL; |
| 338 | } |
| 339 | break; |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 340 | case RADEON_INFO_VA_START: |
| 341 | /* this is where we report if vm is supported or not */ |
| 342 | if (rdev->family < CHIP_CAYMAN) |
| 343 | return -EINVAL; |
| 344 | value = RADEON_VA_RESERVED_SIZE; |
| 345 | break; |
| 346 | case RADEON_INFO_IB_VM_MAX_SIZE: |
| 347 | /* this is where we report if vm is supported or not */ |
| 348 | if (rdev->family < CHIP_CAYMAN) |
| 349 | return -EINVAL; |
| 350 | value = RADEON_IB_VM_MAX_SIZE; |
| 351 | break; |
Tom Stellard | 609c1e1 | 2012-03-20 17:17:55 -0400 | [diff] [blame] | 352 | case RADEON_INFO_MAX_PIPES: |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 353 | if (rdev->family >= CHIP_TAHITI) |
Alex Deucher | 1a8ca75 | 2012-06-01 18:58:22 -0400 | [diff] [blame] | 354 | value = rdev->config.si.max_cu_per_sh; |
Michel Dänzer | c1b2f69 | 2012-03-20 17:18:26 -0400 | [diff] [blame] | 355 | else if (rdev->family >= CHIP_CAYMAN) |
Tom Stellard | 609c1e1 | 2012-03-20 17:17:55 -0400 | [diff] [blame] | 356 | value = rdev->config.cayman.max_pipes_per_simd; |
| 357 | else if (rdev->family >= CHIP_CEDAR) |
| 358 | value = rdev->config.evergreen.max_pipes; |
| 359 | else if (rdev->family >= CHIP_RV770) |
| 360 | value = rdev->config.rv770.max_pipes; |
| 361 | else if (rdev->family >= CHIP_R600) |
| 362 | value = rdev->config.r600.max_pipes; |
| 363 | else { |
| 364 | return -EINVAL; |
| 365 | } |
| 366 | break; |
Alex Deucher | 2e1a767 | 2012-12-04 12:55:37 -0500 | [diff] [blame] | 367 | case RADEON_INFO_MAX_SE: |
| 368 | if (rdev->family >= CHIP_TAHITI) |
| 369 | value = rdev->config.si.max_shader_engines; |
| 370 | else if (rdev->family >= CHIP_CAYMAN) |
| 371 | value = rdev->config.cayman.max_shader_engines; |
| 372 | else if (rdev->family >= CHIP_CEDAR) |
| 373 | value = rdev->config.evergreen.num_ses; |
| 374 | else |
| 375 | value = 1; |
| 376 | break; |
| 377 | case RADEON_INFO_MAX_SH_PER_SE: |
| 378 | if (rdev->family >= CHIP_TAHITI) |
| 379 | value = rdev->config.si.max_sh_per_se; |
| 380 | else |
| 381 | return -EINVAL; |
| 382 | break; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 383 | default: |
Dave Airlie | d9fdaaf | 2010-08-02 10:42:55 +1000 | [diff] [blame] | 384 | DRM_DEBUG_KMS("Invalid request %d\n", info->request); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 385 | return -EINVAL; |
| 386 | } |
| 387 | if (DRM_COPY_TO_USER(value_ptr, &value, sizeof(uint32_t))) { |
Marek Olšák | 6759a0a | 2012-08-09 16:34:17 +0200 | [diff] [blame] | 388 | DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 389 | return -EFAULT; |
| 390 | } |
| 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | |
| 395 | /* |
| 396 | * Outdated mess for old drm with Xorg being in charge (void function now). |
| 397 | */ |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 398 | /** |
| 399 | * radeon_driver_firstopen_kms - drm callback for first open |
| 400 | * |
| 401 | * @dev: drm dev pointer |
| 402 | * |
| 403 | * Nothing to be done for KMS (all asics). |
| 404 | * Returns 0 on success. |
| 405 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 406 | int radeon_driver_firstopen_kms(struct drm_device *dev) |
| 407 | { |
| 408 | return 0; |
| 409 | } |
| 410 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 411 | /** |
| 412 | * radeon_driver_firstopen_kms - drm callback for last close |
| 413 | * |
| 414 | * @dev: drm dev pointer |
| 415 | * |
| 416 | * Switch vga switcheroo state after last close (all asics). |
| 417 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 418 | void radeon_driver_lastclose_kms(struct drm_device *dev) |
| 419 | { |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 420 | vga_switcheroo_process_delayed_switch(); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 421 | } |
| 422 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 423 | /** |
| 424 | * radeon_driver_open_kms - drm callback for open |
| 425 | * |
| 426 | * @dev: drm dev pointer |
| 427 | * @file_priv: drm file |
| 428 | * |
| 429 | * On device open, init vm on cayman+ (all asics). |
| 430 | * Returns 0 on success, error on failure. |
| 431 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 432 | int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) |
| 433 | { |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 434 | struct radeon_device *rdev = dev->dev_private; |
| 435 | |
| 436 | file_priv->driver_priv = NULL; |
| 437 | |
| 438 | /* new gpu have virtual address space support */ |
| 439 | if (rdev->family >= CHIP_CAYMAN) { |
| 440 | struct radeon_fpriv *fpriv; |
Christian König | d72d43c | 2012-10-09 13:31:18 +0200 | [diff] [blame] | 441 | struct radeon_bo_va *bo_va; |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 442 | int r; |
| 443 | |
| 444 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); |
| 445 | if (unlikely(!fpriv)) { |
| 446 | return -ENOMEM; |
| 447 | } |
| 448 | |
Christian König | d72d43c | 2012-10-09 13:31:18 +0200 | [diff] [blame] | 449 | radeon_vm_init(rdev, &fpriv->vm); |
| 450 | |
| 451 | /* map the ib pool buffer read only into |
| 452 | * virtual address space */ |
| 453 | bo_va = radeon_vm_bo_add(rdev, &fpriv->vm, |
| 454 | rdev->ring_tmp_bo.bo); |
| 455 | r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET, |
| 456 | RADEON_VM_PAGE_READABLE | |
| 457 | RADEON_VM_PAGE_SNOOPED); |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 458 | if (r) { |
| 459 | radeon_vm_fini(rdev, &fpriv->vm); |
| 460 | kfree(fpriv); |
| 461 | return r; |
| 462 | } |
| 463 | |
| 464 | file_priv->driver_priv = fpriv; |
| 465 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 466 | return 0; |
| 467 | } |
| 468 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 469 | /** |
| 470 | * radeon_driver_postclose_kms - drm callback for post close |
| 471 | * |
| 472 | * @dev: drm dev pointer |
| 473 | * @file_priv: drm file |
| 474 | * |
| 475 | * On device post close, tear down vm on cayman+ (all asics). |
| 476 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 477 | void radeon_driver_postclose_kms(struct drm_device *dev, |
| 478 | struct drm_file *file_priv) |
| 479 | { |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 480 | struct radeon_device *rdev = dev->dev_private; |
| 481 | |
| 482 | /* new gpu have virtual address space support */ |
| 483 | if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) { |
| 484 | struct radeon_fpriv *fpriv = file_priv->driver_priv; |
Christian König | d72d43c | 2012-10-09 13:31:18 +0200 | [diff] [blame] | 485 | struct radeon_bo_va *bo_va; |
| 486 | int r; |
| 487 | |
| 488 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); |
| 489 | if (!r) { |
| 490 | bo_va = radeon_vm_bo_find(&fpriv->vm, |
| 491 | rdev->ring_tmp_bo.bo); |
| 492 | if (bo_va) |
| 493 | radeon_vm_bo_rmv(rdev, bo_va); |
| 494 | radeon_bo_unreserve(rdev->ring_tmp_bo.bo); |
| 495 | } |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 496 | |
| 497 | radeon_vm_fini(rdev, &fpriv->vm); |
| 498 | kfree(fpriv); |
| 499 | file_priv->driver_priv = NULL; |
| 500 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 501 | } |
| 502 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 503 | /** |
| 504 | * radeon_driver_preclose_kms - drm callback for pre close |
| 505 | * |
| 506 | * @dev: drm dev pointer |
| 507 | * @file_priv: drm file |
| 508 | * |
| 509 | * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx |
| 510 | * (all asics). |
| 511 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 512 | void radeon_driver_preclose_kms(struct drm_device *dev, |
| 513 | struct drm_file *file_priv) |
| 514 | { |
Dave Airlie | ab9e1f5 | 2010-07-13 11:11:11 +1000 | [diff] [blame] | 515 | struct radeon_device *rdev = dev->dev_private; |
| 516 | if (rdev->hyperz_filp == file_priv) |
| 517 | rdev->hyperz_filp = NULL; |
Marek Olšák | dca0d61 | 2011-01-27 22:46:15 +0100 | [diff] [blame] | 518 | if (rdev->cmask_filp == file_priv) |
| 519 | rdev->cmask_filp = NULL; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 520 | } |
| 521 | |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 522 | /* |
| 523 | * VBlank related functions. |
| 524 | */ |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 525 | /** |
| 526 | * radeon_get_vblank_counter_kms - get frame count |
| 527 | * |
| 528 | * @dev: drm dev pointer |
| 529 | * @crtc: crtc to get the frame count from |
| 530 | * |
| 531 | * Gets the frame count on the requested crtc (all asics). |
| 532 | * Returns frame count on success, -EINVAL on failure. |
| 533 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 534 | u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc) |
| 535 | { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 536 | struct radeon_device *rdev = dev->dev_private; |
| 537 | |
Dave Airlie | 9c950a4 | 2010-04-23 13:21:58 +1000 | [diff] [blame] | 538 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 539 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 540 | return -EINVAL; |
| 541 | } |
| 542 | |
| 543 | return radeon_get_vblank_counter(rdev, crtc); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 544 | } |
| 545 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 546 | /** |
| 547 | * radeon_enable_vblank_kms - enable vblank interrupt |
| 548 | * |
| 549 | * @dev: drm dev pointer |
| 550 | * @crtc: crtc to enable vblank interrupt for |
| 551 | * |
| 552 | * Enable the interrupt on the requested crtc (all asics). |
| 553 | * Returns 0 on success, -EINVAL on failure. |
| 554 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 555 | int radeon_enable_vblank_kms(struct drm_device *dev, int crtc) |
| 556 | { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 557 | struct radeon_device *rdev = dev->dev_private; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 558 | unsigned long irqflags; |
| 559 | int r; |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 560 | |
Dave Airlie | 9c950a4 | 2010-04-23 13:21:58 +1000 | [diff] [blame] | 561 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 562 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 563 | return -EINVAL; |
| 564 | } |
| 565 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 566 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 567 | rdev->irq.crtc_vblank_int[crtc] = true; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 568 | r = radeon_irq_set(rdev); |
| 569 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
| 570 | return r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 571 | } |
| 572 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 573 | /** |
| 574 | * radeon_disable_vblank_kms - disable vblank interrupt |
| 575 | * |
| 576 | * @dev: drm dev pointer |
| 577 | * @crtc: crtc to disable vblank interrupt for |
| 578 | * |
| 579 | * Disable the interrupt on the requested crtc (all asics). |
| 580 | */ |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 581 | void radeon_disable_vblank_kms(struct drm_device *dev, int crtc) |
| 582 | { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 583 | struct radeon_device *rdev = dev->dev_private; |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 584 | unsigned long irqflags; |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 585 | |
Dave Airlie | 9c950a4 | 2010-04-23 13:21:58 +1000 | [diff] [blame] | 586 | if (crtc < 0 || crtc >= rdev->num_crtc) { |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 587 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 588 | return; |
| 589 | } |
| 590 | |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 591 | spin_lock_irqsave(&rdev->irq.lock, irqflags); |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 592 | rdev->irq.crtc_vblank_int[crtc] = false; |
Michel Dänzer | 7ed220d | 2009-08-13 11:10:51 +0200 | [diff] [blame] | 593 | radeon_irq_set(rdev); |
Christian Koenig | fb98257 | 2012-05-17 01:33:30 +0200 | [diff] [blame] | 594 | spin_unlock_irqrestore(&rdev->irq.lock, irqflags); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 595 | } |
| 596 | |
Alex Deucher | f482a14 | 2012-07-17 14:02:34 -0400 | [diff] [blame] | 597 | /** |
| 598 | * radeon_get_vblank_timestamp_kms - get vblank timestamp |
| 599 | * |
| 600 | * @dev: drm dev pointer |
| 601 | * @crtc: crtc to get the timestamp for |
| 602 | * @max_error: max error |
| 603 | * @vblank_time: time value |
| 604 | * @flags: flags passed to the driver |
| 605 | * |
| 606 | * Gets the timestamp on the requested crtc based on the |
| 607 | * scanout position. (all asics). |
| 608 | * Returns postive status flags on success, negative error on failure. |
| 609 | */ |
Mario Kleiner | f5a8020 | 2010-10-23 04:42:17 +0200 | [diff] [blame] | 610 | int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc, |
| 611 | int *max_error, |
| 612 | struct timeval *vblank_time, |
| 613 | unsigned flags) |
| 614 | { |
| 615 | struct drm_crtc *drmcrtc; |
| 616 | struct radeon_device *rdev = dev->dev_private; |
| 617 | |
| 618 | if (crtc < 0 || crtc >= dev->num_crtcs) { |
| 619 | DRM_ERROR("Invalid crtc %d\n", crtc); |
| 620 | return -EINVAL; |
| 621 | } |
| 622 | |
| 623 | /* Get associated drm_crtc: */ |
| 624 | drmcrtc = &rdev->mode_info.crtcs[crtc]->base; |
| 625 | |
| 626 | /* Helper routine in DRM core does all the work: */ |
| 627 | return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error, |
| 628 | vblank_time, flags, |
| 629 | drmcrtc); |
| 630 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 631 | |
| 632 | /* |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 633 | * IOCTL. |
| 634 | */ |
| 635 | int radeon_dma_ioctl_kms(struct drm_device *dev, void *data, |
| 636 | struct drm_file *file_priv) |
| 637 | { |
| 638 | /* Not valid in KMS. */ |
| 639 | return -EINVAL; |
| 640 | } |
| 641 | |
| 642 | #define KMS_INVALID_IOCTL(name) \ |
| 643 | int name(struct drm_device *dev, void *data, struct drm_file *file_priv)\ |
| 644 | { \ |
| 645 | DRM_ERROR("invalid ioctl with kms %s\n", __func__); \ |
| 646 | return -EINVAL; \ |
| 647 | } |
| 648 | |
| 649 | /* |
| 650 | * All these ioctls are invalid in kms world. |
| 651 | */ |
| 652 | KMS_INVALID_IOCTL(radeon_cp_init_kms) |
| 653 | KMS_INVALID_IOCTL(radeon_cp_start_kms) |
| 654 | KMS_INVALID_IOCTL(radeon_cp_stop_kms) |
| 655 | KMS_INVALID_IOCTL(radeon_cp_reset_kms) |
| 656 | KMS_INVALID_IOCTL(radeon_cp_idle_kms) |
| 657 | KMS_INVALID_IOCTL(radeon_cp_resume_kms) |
| 658 | KMS_INVALID_IOCTL(radeon_engine_reset_kms) |
| 659 | KMS_INVALID_IOCTL(radeon_fullscreen_kms) |
| 660 | KMS_INVALID_IOCTL(radeon_cp_swap_kms) |
| 661 | KMS_INVALID_IOCTL(radeon_cp_clear_kms) |
| 662 | KMS_INVALID_IOCTL(radeon_cp_vertex_kms) |
| 663 | KMS_INVALID_IOCTL(radeon_cp_indices_kms) |
| 664 | KMS_INVALID_IOCTL(radeon_cp_texture_kms) |
| 665 | KMS_INVALID_IOCTL(radeon_cp_stipple_kms) |
| 666 | KMS_INVALID_IOCTL(radeon_cp_indirect_kms) |
| 667 | KMS_INVALID_IOCTL(radeon_cp_vertex2_kms) |
| 668 | KMS_INVALID_IOCTL(radeon_cp_cmdbuf_kms) |
| 669 | KMS_INVALID_IOCTL(radeon_cp_getparam_kms) |
| 670 | KMS_INVALID_IOCTL(radeon_cp_flip_kms) |
| 671 | KMS_INVALID_IOCTL(radeon_mem_alloc_kms) |
| 672 | KMS_INVALID_IOCTL(radeon_mem_free_kms) |
| 673 | KMS_INVALID_IOCTL(radeon_mem_init_heap_kms) |
| 674 | KMS_INVALID_IOCTL(radeon_irq_emit_kms) |
| 675 | KMS_INVALID_IOCTL(radeon_irq_wait_kms) |
| 676 | KMS_INVALID_IOCTL(radeon_cp_setparam_kms) |
| 677 | KMS_INVALID_IOCTL(radeon_surface_alloc_kms) |
| 678 | KMS_INVALID_IOCTL(radeon_surface_free_kms) |
| 679 | |
| 680 | |
| 681 | struct drm_ioctl_desc radeon_ioctls_kms[] = { |
Dave Airlie | 1b2f148 | 2010-08-14 20:20:34 +1000 | [diff] [blame] | 682 | DRM_IOCTL_DEF_DRV(RADEON_CP_INIT, radeon_cp_init_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 683 | DRM_IOCTL_DEF_DRV(RADEON_CP_START, radeon_cp_start_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 684 | DRM_IOCTL_DEF_DRV(RADEON_CP_STOP, radeon_cp_stop_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 685 | DRM_IOCTL_DEF_DRV(RADEON_CP_RESET, radeon_cp_reset_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 686 | DRM_IOCTL_DEF_DRV(RADEON_CP_IDLE, radeon_cp_idle_kms, DRM_AUTH), |
| 687 | DRM_IOCTL_DEF_DRV(RADEON_CP_RESUME, radeon_cp_resume_kms, DRM_AUTH), |
| 688 | DRM_IOCTL_DEF_DRV(RADEON_RESET, radeon_engine_reset_kms, DRM_AUTH), |
| 689 | DRM_IOCTL_DEF_DRV(RADEON_FULLSCREEN, radeon_fullscreen_kms, DRM_AUTH), |
| 690 | DRM_IOCTL_DEF_DRV(RADEON_SWAP, radeon_cp_swap_kms, DRM_AUTH), |
| 691 | DRM_IOCTL_DEF_DRV(RADEON_CLEAR, radeon_cp_clear_kms, DRM_AUTH), |
| 692 | DRM_IOCTL_DEF_DRV(RADEON_VERTEX, radeon_cp_vertex_kms, DRM_AUTH), |
| 693 | DRM_IOCTL_DEF_DRV(RADEON_INDICES, radeon_cp_indices_kms, DRM_AUTH), |
| 694 | DRM_IOCTL_DEF_DRV(RADEON_TEXTURE, radeon_cp_texture_kms, DRM_AUTH), |
| 695 | DRM_IOCTL_DEF_DRV(RADEON_STIPPLE, radeon_cp_stipple_kms, DRM_AUTH), |
| 696 | DRM_IOCTL_DEF_DRV(RADEON_INDIRECT, radeon_cp_indirect_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 697 | DRM_IOCTL_DEF_DRV(RADEON_VERTEX2, radeon_cp_vertex2_kms, DRM_AUTH), |
| 698 | DRM_IOCTL_DEF_DRV(RADEON_CMDBUF, radeon_cp_cmdbuf_kms, DRM_AUTH), |
| 699 | DRM_IOCTL_DEF_DRV(RADEON_GETPARAM, radeon_cp_getparam_kms, DRM_AUTH), |
| 700 | DRM_IOCTL_DEF_DRV(RADEON_FLIP, radeon_cp_flip_kms, DRM_AUTH), |
| 701 | DRM_IOCTL_DEF_DRV(RADEON_ALLOC, radeon_mem_alloc_kms, DRM_AUTH), |
| 702 | DRM_IOCTL_DEF_DRV(RADEON_FREE, radeon_mem_free_kms, DRM_AUTH), |
| 703 | DRM_IOCTL_DEF_DRV(RADEON_INIT_HEAP, radeon_mem_init_heap_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), |
| 704 | DRM_IOCTL_DEF_DRV(RADEON_IRQ_EMIT, radeon_irq_emit_kms, DRM_AUTH), |
| 705 | DRM_IOCTL_DEF_DRV(RADEON_IRQ_WAIT, radeon_irq_wait_kms, DRM_AUTH), |
| 706 | DRM_IOCTL_DEF_DRV(RADEON_SETPARAM, radeon_cp_setparam_kms, DRM_AUTH), |
| 707 | DRM_IOCTL_DEF_DRV(RADEON_SURF_ALLOC, radeon_surface_alloc_kms, DRM_AUTH), |
| 708 | DRM_IOCTL_DEF_DRV(RADEON_SURF_FREE, radeon_surface_free_kms, DRM_AUTH), |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 709 | /* KMS */ |
Dave Airlie | 1b2f148 | 2010-08-14 20:20:34 +1000 | [diff] [blame] | 710 | DRM_IOCTL_DEF_DRV(RADEON_GEM_INFO, radeon_gem_info_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 711 | DRM_IOCTL_DEF_DRV(RADEON_GEM_CREATE, radeon_gem_create_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 712 | DRM_IOCTL_DEF_DRV(RADEON_GEM_MMAP, radeon_gem_mmap_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 713 | DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_DOMAIN, radeon_gem_set_domain_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 714 | DRM_IOCTL_DEF_DRV(RADEON_GEM_PREAD, radeon_gem_pread_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 715 | DRM_IOCTL_DEF_DRV(RADEON_GEM_PWRITE, radeon_gem_pwrite_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 716 | DRM_IOCTL_DEF_DRV(RADEON_GEM_WAIT_IDLE, radeon_gem_wait_idle_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 717 | DRM_IOCTL_DEF_DRV(RADEON_CS, radeon_cs_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 718 | DRM_IOCTL_DEF_DRV(RADEON_INFO, radeon_info_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 719 | DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_TILING, radeon_gem_set_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 720 | DRM_IOCTL_DEF_DRV(RADEON_GEM_GET_TILING, radeon_gem_get_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 721 | DRM_IOCTL_DEF_DRV(RADEON_GEM_BUSY, radeon_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED), |
Jerome Glisse | 721604a | 2012-01-05 22:11:05 -0500 | [diff] [blame] | 722 | DRM_IOCTL_DEF_DRV(RADEON_GEM_VA, radeon_gem_va_ioctl, DRM_AUTH|DRM_UNLOCKED), |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 723 | }; |
| 724 | int radeon_max_kms_ioctl = DRM_ARRAY_SIZE(radeon_ioctls_kms); |