blob: 49ff3d1a610238009f242af5fdf4606d9a1951b9 [file] [log] [blame]
Jerome Glisse771fe6b2009-06-05 14:42:42 +02001/*
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 Howells760285e2012-10-02 18:01:07 +010028#include <drm/drmP.h>
Jerome Glisse771fe6b2009-06-05 14:42:42 +020029#include "radeon.h"
David Howells760285e2012-10-02 18:01:07 +010030#include <drm/radeon_drm.h>
Marek Olšák6759a0a2012-08-09 16:34:17 +020031#include "radeon_asic.h"
Jerome Glisse771fe6b2009-06-05 14:42:42 +020032
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100033#include <linux/vga_switcheroo.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090034#include <linux/slab.h>
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100035
Alex Deucherf482a142012-07-17 14:02:34 -040036/**
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 Glissecf0fe452009-12-09 18:21:55 +010047int radeon_driver_unload_kms(struct drm_device *dev)
48{
49 struct radeon_device *rdev = dev->dev_private;
Jerome Glisse771fe6b2009-06-05 14:42:42 +020050
Jerome Glissecf0fe452009-12-09 18:21:55 +010051 if (rdev == NULL)
52 return 0;
Alex Deucher0cd9cb72013-04-12 19:15:52 -040053 if (rdev->rmmio == NULL)
54 goto done_free;
Alex Deucherc4917072012-07-31 17:14:35 -040055 radeon_acpi_fini(rdev);
Jerome Glissecf0fe452009-12-09 18:21:55 +010056 radeon_modeset_fini(rdev);
57 radeon_device_fini(rdev);
Alex Deucher0cd9cb72013-04-12 19:15:52 -040058
59done_free:
Jerome Glissecf0fe452009-12-09 18:21:55 +010060 kfree(rdev);
61 dev->dev_private = NULL;
62 return 0;
63}
64
Alex Deucherf482a142012-07-17 14:02:34 -040065/**
66 * radeon_driver_load_kms - Main load function for KMS.
67 *
68 * @dev: drm dev pointer
69 * @flags: device flags
70 *
71 * This is the main load function for KMS (all asics).
72 * It calls radeon_device_init() to set up the non-display
73 * parts of the chip (asic init, CP, writeback, etc.), and
74 * radeon_modeset_init() to set up the display parts
75 * (crtcs, encoders, hotplug detect, etc.).
76 * Returns 0 on success, error on failure.
77 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +020078int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
79{
80 struct radeon_device *rdev;
Alberto Miloned7a29522010-07-06 11:40:24 -040081 int r, acpi_status;
Jerome Glisse771fe6b2009-06-05 14:42:42 +020082
83 rdev = kzalloc(sizeof(struct radeon_device), GFP_KERNEL);
84 if (rdev == NULL) {
85 return -ENOMEM;
86 }
87 dev->dev_private = (void *)rdev;
88
89 /* update BUS flag */
Dave Airlie8410ea32010-12-15 03:16:38 +100090 if (drm_pci_device_is_agp(dev)) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +020091 flags |= RADEON_IS_AGP;
Jon Mason58b65422011-06-27 16:07:50 +000092 } else if (pci_is_pcie(dev->pdev)) {
Jerome Glisse771fe6b2009-06-05 14:42:42 +020093 flags |= RADEON_IS_PCIE;
94 } else {
95 flags |= RADEON_IS_PCI;
96 }
97
Jerome Glisse6cf8a3f2009-09-10 21:46:48 +020098 /* radeon_device_init should report only fatal error
99 * like memory allocation failure or iomapping failure,
100 * or memory manager initialization failure, it must
101 * properly initialize the GPU MC controller and permit
102 * VRAM allocation
103 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200104 r = radeon_device_init(rdev, dev, dev->pdev, flags);
105 if (r) {
Jerome Glissecf0fe452009-12-09 18:21:55 +0100106 dev_err(&dev->pdev->dev, "Fatal error during GPU init\n");
107 goto out;
Jerome Glisse6cf8a3f2009-09-10 21:46:48 +0200108 }
Alberto Miloned7a29522010-07-06 11:40:24 -0400109
Jerome Glisse6cf8a3f2009-09-10 21:46:48 +0200110 /* Again modeset_init should fail only on fatal error
111 * otherwise it should provide enough functionalities
112 * for shadowfb to run
113 */
114 r = radeon_modeset_init(rdev);
Jerome Glissecf0fe452009-12-09 18:21:55 +0100115 if (r)
116 dev_err(&dev->pdev->dev, "Fatal error during modeset init\n");
Luca Tettamantifda4b252012-07-30 21:20:35 +0200117
118 /* Call ACPI methods: require modeset init
119 * but failure is not fatal
120 */
121 if (!r) {
122 acpi_status = radeon_acpi_init(rdev);
123 if (acpi_status)
124 dev_dbg(&dev->pdev->dev,
125 "Error during ACPI methods call\n");
126 }
127
Jerome Glissecf0fe452009-12-09 18:21:55 +0100128out:
129 if (r)
130 radeon_driver_unload_kms(dev);
131 return r;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200132}
133
Alex Deucherf482a142012-07-17 14:02:34 -0400134/**
135 * radeon_set_filp_rights - Set filp right.
136 *
137 * @dev: drm dev pointer
138 * @owner: drm file
139 * @applier: drm file
140 * @value: value
141 *
142 * Sets the filp rights for the device (all asics).
143 */
Marek Olšák9eba4a92011-01-05 05:46:48 +0100144static void radeon_set_filp_rights(struct drm_device *dev,
145 struct drm_file **owner,
146 struct drm_file *applier,
147 uint32_t *value)
148{
149 mutex_lock(&dev->struct_mutex);
150 if (*value == 1) {
151 /* wants rights */
152 if (!*owner)
153 *owner = applier;
154 } else if (*value == 0) {
155 /* revokes rights */
156 if (*owner == applier)
157 *owner = NULL;
158 }
159 *value = *owner == applier ? 1 : 0;
160 mutex_unlock(&dev->struct_mutex);
161}
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200162
163/*
Marek Olšák9eba4a92011-01-05 05:46:48 +0100164 * Userspace get information ioctl
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200165 */
Alex Deucherf482a142012-07-17 14:02:34 -0400166/**
167 * radeon_info_ioctl - answer a device specific request.
168 *
169 * @rdev: radeon device pointer
170 * @data: request object
171 * @filp: drm filp
172 *
173 * This function is used to pass device specific parameters to the userspace
174 * drivers. Examples include: pci device id, pipeline parms, tiling params,
175 * etc. (all asics).
176 * Returns 0 on success, -EINVAL on failure.
177 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200178int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
179{
180 struct radeon_device *rdev = dev->dev_private;
Marek Olšák6759a0a2012-08-09 16:34:17 +0200181 struct drm_radeon_info *info = data;
Jerome Glissebc35afd2010-05-12 18:01:13 +0200182 struct radeon_mode_info *minfo = &rdev->mode_info;
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400183 uint32_t *value, value_tmp, *value_ptr, value_size;
184 uint64_t value64;
Jerome Glissebc35afd2010-05-12 18:01:13 +0200185 struct drm_crtc *crtc;
186 int i, found;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200187
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200188 value_ptr = (uint32_t *)((unsigned long)info->value);
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400189 value = &value_tmp;
190 value_size = sizeof(uint32_t);
Dr. David Alan Gilbertd8ab3552010-08-02 09:43:52 +1000191
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200192 switch (info->request) {
193 case RADEON_INFO_DEVICE_ID:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400194 *value = dev->pci_device;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200195 break;
196 case RADEON_INFO_NUM_GB_PIPES:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400197 *value = rdev->num_gb_pipes;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200198 break;
Alex Deucherf779b3e2009-08-19 19:11:39 -0400199 case RADEON_INFO_NUM_Z_PIPES:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400200 *value = rdev->num_z_pipes;
Alex Deucherf779b3e2009-08-19 19:11:39 -0400201 break;
Jerome Glisse733289c2009-09-16 15:24:21 +0200202 case RADEON_INFO_ACCEL_WORKING:
Alex Deucher148a03b2010-06-03 19:00:03 -0400203 /* xf86-video-ati 6.13.0 relies on this being false for evergreen */
204 if ((rdev->family >= CHIP_CEDAR) && (rdev->family <= CHIP_HEMLOCK))
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400205 *value = false;
Alex Deucher148a03b2010-06-03 19:00:03 -0400206 else
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400207 *value = rdev->accel_working;
Jerome Glisse733289c2009-09-16 15:24:21 +0200208 break;
Jerome Glissebc35afd2010-05-12 18:01:13 +0200209 case RADEON_INFO_CRTC_FROM_ID:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400210 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
211 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
212 return -EFAULT;
213 }
Jerome Glissebc35afd2010-05-12 18:01:13 +0200214 for (i = 0, found = 0; i < rdev->num_crtc; i++) {
215 crtc = (struct drm_crtc *)minfo->crtcs[i];
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400216 if (crtc && crtc->base.id == *value) {
Alex Deucher0baf2d82010-07-21 14:05:35 -0400217 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400218 *value = radeon_crtc->crtc_id;
Jerome Glissebc35afd2010-05-12 18:01:13 +0200219 found = 1;
220 break;
221 }
222 }
223 if (!found) {
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400224 DRM_DEBUG_KMS("unknown crtc id %d\n", *value);
Jerome Glissebc35afd2010-05-12 18:01:13 +0200225 return -EINVAL;
226 }
227 break;
Alex Deucher148a03b2010-06-03 19:00:03 -0400228 case RADEON_INFO_ACCEL_WORKING2:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400229 *value = rdev->accel_working;
Alex Deucher148a03b2010-06-03 19:00:03 -0400230 break;
Alex Deuchere7aeeba2010-06-04 13:10:12 -0400231 case RADEON_INFO_TILING_CONFIG:
Alex Deucher64f759c2012-07-06 17:40:32 -0400232 if (rdev->family >= CHIP_BONAIRE)
233 *value = rdev->config.cik.tile_config;
234 else if (rdev->family >= CHIP_TAHITI)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400235 *value = rdev->config.si.tile_config;
Michel Dänzerc1b2f692012-03-20 17:18:26 -0400236 else if (rdev->family >= CHIP_CAYMAN)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400237 *value = rdev->config.cayman.tile_config;
Alex Deucherfecf1d02011-03-02 20:07:29 -0500238 else if (rdev->family >= CHIP_CEDAR)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400239 *value = rdev->config.evergreen.tile_config;
Alex Deuchere7aeeba2010-06-04 13:10:12 -0400240 else if (rdev->family >= CHIP_RV770)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400241 *value = rdev->config.rv770.tile_config;
Alex Deuchere7aeeba2010-06-04 13:10:12 -0400242 else if (rdev->family >= CHIP_R600)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400243 *value = rdev->config.r600.tile_config;
Alex Deuchere7aeeba2010-06-04 13:10:12 -0400244 else {
Dave Airlied9fdaaf2010-08-02 10:42:55 +1000245 DRM_DEBUG_KMS("tiling config is r6xx+ only!\n");
Alex Deuchere7aeeba2010-06-04 13:10:12 -0400246 return -EINVAL;
247 }
Alex Deucherb824b362010-08-12 08:25:47 -0400248 break;
Dave Airlieab9e1f52010-07-13 11:11:11 +1000249 case RADEON_INFO_WANT_HYPERZ:
Marek Olšák43861f72010-08-07 03:36:34 +0200250 /* The "value" here is both an input and output parameter.
251 * If the input value is 1, filp requests hyper-z access.
252 * If the input value is 0, filp revokes its hyper-z access.
253 *
254 * When returning, the value is 1 if filp owns hyper-z access,
255 * 0 otherwise. */
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400256 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
257 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
258 return -EFAULT;
259 }
260 if (*value >= 2) {
261 DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", *value);
Marek Olšák43861f72010-08-07 03:36:34 +0200262 return -EINVAL;
Dave Airlieab9e1f52010-07-13 11:11:11 +1000263 }
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400264 radeon_set_filp_rights(dev, &rdev->hyperz_filp, filp, value);
Marek Olšák9eba4a92011-01-05 05:46:48 +0100265 break;
266 case RADEON_INFO_WANT_CMASK:
267 /* The same logic as Hyper-Z. */
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400268 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
269 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
270 return -EFAULT;
271 }
272 if (*value >= 2) {
273 DRM_DEBUG_KMS("WANT_CMASK: invalid value %d\n", *value);
Marek Olšák9eba4a92011-01-05 05:46:48 +0100274 return -EINVAL;
Marek Olšák43861f72010-08-07 03:36:34 +0200275 }
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400276 radeon_set_filp_rights(dev, &rdev->cmask_filp, filp, value);
Alex Deuchere7aeeba2010-06-04 13:10:12 -0400277 break;
Alex Deucher58bbf012011-01-24 17:14:26 -0500278 case RADEON_INFO_CLOCK_CRYSTAL_FREQ:
279 /* return clock value in KHz */
Alex Deucher454d2e22013-02-14 10:04:02 -0500280 if (rdev->asic->get_xclk)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400281 *value = radeon_get_xclk(rdev) * 10;
Alex Deucher454d2e22013-02-14 10:04:02 -0500282 else
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400283 *value = rdev->clock.spll.reference_freq * 10;
Alex Deucher58bbf012011-01-24 17:14:26 -0500284 break;
Dave Airlie486af182011-03-01 14:32:27 +1000285 case RADEON_INFO_NUM_BACKENDS:
Alex Deucher64f759c2012-07-06 17:40:32 -0400286 if (rdev->family >= CHIP_BONAIRE)
287 *value = rdev->config.cik.max_backends_per_se *
288 rdev->config.cik.max_shader_engines;
289 else if (rdev->family >= CHIP_TAHITI)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400290 *value = rdev->config.si.max_backends_per_se *
Michel Dänzerc1b2f692012-03-20 17:18:26 -0400291 rdev->config.si.max_shader_engines;
292 else if (rdev->family >= CHIP_CAYMAN)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400293 *value = rdev->config.cayman.max_backends_per_se *
Alex Deucherfecf1d02011-03-02 20:07:29 -0500294 rdev->config.cayman.max_shader_engines;
295 else if (rdev->family >= CHIP_CEDAR)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400296 *value = rdev->config.evergreen.max_backends;
Dave Airlie486af182011-03-01 14:32:27 +1000297 else if (rdev->family >= CHIP_RV770)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400298 *value = rdev->config.rv770.max_backends;
Dave Airlie486af182011-03-01 14:32:27 +1000299 else if (rdev->family >= CHIP_R600)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400300 *value = rdev->config.r600.max_backends;
Dave Airlie486af182011-03-01 14:32:27 +1000301 else {
302 return -EINVAL;
303 }
304 break;
Alex Deucher65659452011-04-26 13:27:43 -0400305 case RADEON_INFO_NUM_TILE_PIPES:
Alex Deucher64f759c2012-07-06 17:40:32 -0400306 if (rdev->family >= CHIP_BONAIRE)
307 *value = rdev->config.cik.max_tile_pipes;
308 else if (rdev->family >= CHIP_TAHITI)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400309 *value = rdev->config.si.max_tile_pipes;
Michel Dänzerc1b2f692012-03-20 17:18:26 -0400310 else if (rdev->family >= CHIP_CAYMAN)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400311 *value = rdev->config.cayman.max_tile_pipes;
Alex Deucher65659452011-04-26 13:27:43 -0400312 else if (rdev->family >= CHIP_CEDAR)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400313 *value = rdev->config.evergreen.max_tile_pipes;
Alex Deucher65659452011-04-26 13:27:43 -0400314 else if (rdev->family >= CHIP_RV770)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400315 *value = rdev->config.rv770.max_tile_pipes;
Alex Deucher65659452011-04-26 13:27:43 -0400316 else if (rdev->family >= CHIP_R600)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400317 *value = rdev->config.r600.max_tile_pipes;
Alex Deucher65659452011-04-26 13:27:43 -0400318 else {
319 return -EINVAL;
320 }
321 break;
Alex Deucher8aeb96f2011-05-03 19:28:02 -0400322 case RADEON_INFO_FUSION_GART_WORKING:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400323 *value = 1;
Alex Deucher8aeb96f2011-05-03 19:28:02 -0400324 break;
Alex Deuchere55b9422011-07-15 19:53:52 +0000325 case RADEON_INFO_BACKEND_MAP:
Alex Deucher64f759c2012-07-06 17:40:32 -0400326 if (rdev->family >= CHIP_BONAIRE)
327 return -EINVAL;
328 else if (rdev->family >= CHIP_TAHITI)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400329 *value = rdev->config.si.backend_map;
Michel Dänzerc1b2f692012-03-20 17:18:26 -0400330 else if (rdev->family >= CHIP_CAYMAN)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400331 *value = rdev->config.cayman.backend_map;
Alex Deuchere55b9422011-07-15 19:53:52 +0000332 else if (rdev->family >= CHIP_CEDAR)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400333 *value = rdev->config.evergreen.backend_map;
Alex Deuchere55b9422011-07-15 19:53:52 +0000334 else if (rdev->family >= CHIP_RV770)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400335 *value = rdev->config.rv770.backend_map;
Alex Deuchere55b9422011-07-15 19:53:52 +0000336 else if (rdev->family >= CHIP_R600)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400337 *value = rdev->config.r600.backend_map;
Alex Deuchere55b9422011-07-15 19:53:52 +0000338 else {
339 return -EINVAL;
340 }
341 break;
Jerome Glisse721604a2012-01-05 22:11:05 -0500342 case RADEON_INFO_VA_START:
343 /* this is where we report if vm is supported or not */
344 if (rdev->family < CHIP_CAYMAN)
345 return -EINVAL;
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400346 *value = RADEON_VA_RESERVED_SIZE;
Jerome Glisse721604a2012-01-05 22:11:05 -0500347 break;
348 case RADEON_INFO_IB_VM_MAX_SIZE:
349 /* this is where we report if vm is supported or not */
350 if (rdev->family < CHIP_CAYMAN)
351 return -EINVAL;
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400352 *value = RADEON_IB_VM_MAX_SIZE;
Jerome Glisse721604a2012-01-05 22:11:05 -0500353 break;
Tom Stellard609c1e12012-03-20 17:17:55 -0400354 case RADEON_INFO_MAX_PIPES:
Alex Deucher64f759c2012-07-06 17:40:32 -0400355 if (rdev->family >= CHIP_BONAIRE)
356 *value = rdev->config.cik.max_cu_per_sh;
357 else if (rdev->family >= CHIP_TAHITI)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400358 *value = rdev->config.si.max_cu_per_sh;
Michel Dänzerc1b2f692012-03-20 17:18:26 -0400359 else if (rdev->family >= CHIP_CAYMAN)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400360 *value = rdev->config.cayman.max_pipes_per_simd;
Tom Stellard609c1e12012-03-20 17:17:55 -0400361 else if (rdev->family >= CHIP_CEDAR)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400362 *value = rdev->config.evergreen.max_pipes;
Tom Stellard609c1e12012-03-20 17:17:55 -0400363 else if (rdev->family >= CHIP_RV770)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400364 *value = rdev->config.rv770.max_pipes;
Tom Stellard609c1e12012-03-20 17:17:55 -0400365 else if (rdev->family >= CHIP_R600)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400366 *value = rdev->config.r600.max_pipes;
Tom Stellard609c1e12012-03-20 17:17:55 -0400367 else {
368 return -EINVAL;
369 }
370 break;
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400371 case RADEON_INFO_TIMESTAMP:
372 if (rdev->family < CHIP_R600) {
373 DRM_DEBUG_KMS("timestamp is r6xx+ only!\n");
374 return -EINVAL;
375 }
376 value = (uint32_t*)&value64;
377 value_size = sizeof(uint64_t);
378 value64 = radeon_get_gpu_clock_counter(rdev);
379 break;
Alex Deucher2e1a7672012-12-04 12:55:37 -0500380 case RADEON_INFO_MAX_SE:
Alex Deucher64f759c2012-07-06 17:40:32 -0400381 if (rdev->family >= CHIP_BONAIRE)
382 *value = rdev->config.cik.max_shader_engines;
383 else if (rdev->family >= CHIP_TAHITI)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400384 *value = rdev->config.si.max_shader_engines;
Alex Deucher2e1a7672012-12-04 12:55:37 -0500385 else if (rdev->family >= CHIP_CAYMAN)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400386 *value = rdev->config.cayman.max_shader_engines;
Alex Deucher2e1a7672012-12-04 12:55:37 -0500387 else if (rdev->family >= CHIP_CEDAR)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400388 *value = rdev->config.evergreen.num_ses;
Alex Deucher2e1a7672012-12-04 12:55:37 -0500389 else
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400390 *value = 1;
Alex Deucher2e1a7672012-12-04 12:55:37 -0500391 break;
392 case RADEON_INFO_MAX_SH_PER_SE:
Alex Deucher64f759c2012-07-06 17:40:32 -0400393 if (rdev->family >= CHIP_BONAIRE)
394 *value = rdev->config.cik.max_sh_per_se;
395 else if (rdev->family >= CHIP_TAHITI)
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400396 *value = rdev->config.si.max_sh_per_se;
Alex Deucher2e1a7672012-12-04 12:55:37 -0500397 else
398 return -EINVAL;
399 break;
Samuel Lia0a53aa2013-04-08 17:25:47 -0400400 case RADEON_INFO_FASTFB_WORKING:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400401 *value = rdev->fastfb_working;
Samuel Lia0a53aa2013-04-08 17:25:47 -0400402 break;
Christian König902aaef2013-04-09 10:35:42 -0400403 case RADEON_INFO_RING_WORKING:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400404 if (DRM_COPY_FROM_USER(value, value_ptr, sizeof(uint32_t))) {
405 DRM_ERROR("copy_from_user %s:%u\n", __func__, __LINE__);
406 return -EFAULT;
407 }
408 switch (*value) {
Christian König902aaef2013-04-09 10:35:42 -0400409 case RADEON_CS_RING_GFX:
410 case RADEON_CS_RING_COMPUTE:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400411 *value = rdev->ring[RADEON_RING_TYPE_GFX_INDEX].ready;
Christian König902aaef2013-04-09 10:35:42 -0400412 break;
413 case RADEON_CS_RING_DMA:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400414 *value = rdev->ring[R600_RING_TYPE_DMA_INDEX].ready;
415 *value |= rdev->ring[CAYMAN_RING_TYPE_DMA1_INDEX].ready;
Christian König902aaef2013-04-09 10:35:42 -0400416 break;
417 case RADEON_CS_RING_UVD:
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400418 *value = rdev->ring[R600_RING_TYPE_UVD_INDEX].ready;
Christian König902aaef2013-04-09 10:35:42 -0400419 break;
420 default:
421 return -EINVAL;
422 }
423 break;
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400424 case RADEON_INFO_SI_TILE_MODE_ARRAY:
Alex Deucher64f759c2012-07-06 17:40:32 -0400425 if (rdev->family >= CHIP_BONAIRE) {
Alex Deucher39aee492013-04-10 13:41:25 -0400426 value = rdev->config.cik.tile_mode_array;
427 value_size = sizeof(uint32_t)*32;
428 } else if (rdev->family >= CHIP_TAHITI) {
429 value = rdev->config.si.tile_mode_array;
430 value_size = sizeof(uint32_t)*32;
431 } else {
432 DRM_DEBUG_KMS("tile mode array is si+ only!\n");
Alex Deucher64f759c2012-07-06 17:40:32 -0400433 return -EINVAL;
434 }
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400435 break;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200436 default:
Dave Airlied9fdaaf2010-08-02 10:42:55 +1000437 DRM_DEBUG_KMS("Invalid request %d\n", info->request);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200438 return -EINVAL;
439 }
Jerome Glisse64d7b8b2013-04-09 11:17:08 -0400440 if (DRM_COPY_TO_USER(value_ptr, (char*)value, value_size)) {
Marek Olšák6759a0a2012-08-09 16:34:17 +0200441 DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200442 return -EFAULT;
443 }
444 return 0;
445}
446
447
448/*
449 * Outdated mess for old drm with Xorg being in charge (void function now).
450 */
Alex Deucherf482a142012-07-17 14:02:34 -0400451/**
452 * radeon_driver_firstopen_kms - drm callback for first open
453 *
454 * @dev: drm dev pointer
455 *
456 * Nothing to be done for KMS (all asics).
457 * Returns 0 on success.
458 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200459int radeon_driver_firstopen_kms(struct drm_device *dev)
460{
461 return 0;
462}
463
Alex Deucherf482a142012-07-17 14:02:34 -0400464/**
465 * radeon_driver_firstopen_kms - drm callback for last close
466 *
467 * @dev: drm dev pointer
468 *
469 * Switch vga switcheroo state after last close (all asics).
470 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200471void radeon_driver_lastclose_kms(struct drm_device *dev)
472{
Dave Airlie6a9ee8a2010-02-01 15:38:10 +1000473 vga_switcheroo_process_delayed_switch();
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200474}
475
Alex Deucherf482a142012-07-17 14:02:34 -0400476/**
477 * radeon_driver_open_kms - drm callback for open
478 *
479 * @dev: drm dev pointer
480 * @file_priv: drm file
481 *
482 * On device open, init vm on cayman+ (all asics).
483 * Returns 0 on success, error on failure.
484 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200485int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
486{
Jerome Glisse721604a2012-01-05 22:11:05 -0500487 struct radeon_device *rdev = dev->dev_private;
488
489 file_priv->driver_priv = NULL;
490
491 /* new gpu have virtual address space support */
492 if (rdev->family >= CHIP_CAYMAN) {
493 struct radeon_fpriv *fpriv;
Christian Königd72d43c2012-10-09 13:31:18 +0200494 struct radeon_bo_va *bo_va;
Jerome Glisse721604a2012-01-05 22:11:05 -0500495 int r;
496
497 fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
498 if (unlikely(!fpriv)) {
499 return -ENOMEM;
500 }
501
Christian Königd72d43c2012-10-09 13:31:18 +0200502 radeon_vm_init(rdev, &fpriv->vm);
503
504 /* map the ib pool buffer read only into
505 * virtual address space */
506 bo_va = radeon_vm_bo_add(rdev, &fpriv->vm,
507 rdev->ring_tmp_bo.bo);
508 r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET,
509 RADEON_VM_PAGE_READABLE |
510 RADEON_VM_PAGE_SNOOPED);
Jerome Glisse721604a2012-01-05 22:11:05 -0500511 if (r) {
512 radeon_vm_fini(rdev, &fpriv->vm);
513 kfree(fpriv);
514 return r;
515 }
516
517 file_priv->driver_priv = fpriv;
518 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200519 return 0;
520}
521
Alex Deucherf482a142012-07-17 14:02:34 -0400522/**
523 * radeon_driver_postclose_kms - drm callback for post close
524 *
525 * @dev: drm dev pointer
526 * @file_priv: drm file
527 *
528 * On device post close, tear down vm on cayman+ (all asics).
529 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200530void radeon_driver_postclose_kms(struct drm_device *dev,
531 struct drm_file *file_priv)
532{
Jerome Glisse721604a2012-01-05 22:11:05 -0500533 struct radeon_device *rdev = dev->dev_private;
534
535 /* new gpu have virtual address space support */
536 if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) {
537 struct radeon_fpriv *fpriv = file_priv->driver_priv;
Christian Königd72d43c2012-10-09 13:31:18 +0200538 struct radeon_bo_va *bo_va;
539 int r;
540
541 r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
542 if (!r) {
543 bo_va = radeon_vm_bo_find(&fpriv->vm,
544 rdev->ring_tmp_bo.bo);
545 if (bo_va)
546 radeon_vm_bo_rmv(rdev, bo_va);
547 radeon_bo_unreserve(rdev->ring_tmp_bo.bo);
548 }
Jerome Glisse721604a2012-01-05 22:11:05 -0500549
550 radeon_vm_fini(rdev, &fpriv->vm);
551 kfree(fpriv);
552 file_priv->driver_priv = NULL;
553 }
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200554}
555
Alex Deucherf482a142012-07-17 14:02:34 -0400556/**
557 * radeon_driver_preclose_kms - drm callback for pre close
558 *
559 * @dev: drm dev pointer
560 * @file_priv: drm file
561 *
562 * On device pre close, tear down hyperz and cmask filps on r1xx-r5xx
563 * (all asics).
564 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200565void radeon_driver_preclose_kms(struct drm_device *dev,
566 struct drm_file *file_priv)
567{
Dave Airlieab9e1f52010-07-13 11:11:11 +1000568 struct radeon_device *rdev = dev->dev_private;
569 if (rdev->hyperz_filp == file_priv)
570 rdev->hyperz_filp = NULL;
Marek Olšákdca0d612011-01-27 22:46:15 +0100571 if (rdev->cmask_filp == file_priv)
572 rdev->cmask_filp = NULL;
Christian Königf2ba57b2013-04-08 12:41:29 +0200573 radeon_uvd_free_handles(rdev, file_priv);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200574}
575
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200576/*
577 * VBlank related functions.
578 */
Alex Deucherf482a142012-07-17 14:02:34 -0400579/**
580 * radeon_get_vblank_counter_kms - get frame count
581 *
582 * @dev: drm dev pointer
583 * @crtc: crtc to get the frame count from
584 *
585 * Gets the frame count on the requested crtc (all asics).
586 * Returns frame count on success, -EINVAL on failure.
587 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200588u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc)
589{
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200590 struct radeon_device *rdev = dev->dev_private;
591
Dave Airlie9c950a42010-04-23 13:21:58 +1000592 if (crtc < 0 || crtc >= rdev->num_crtc) {
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200593 DRM_ERROR("Invalid crtc %d\n", crtc);
594 return -EINVAL;
595 }
596
597 return radeon_get_vblank_counter(rdev, crtc);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200598}
599
Alex Deucherf482a142012-07-17 14:02:34 -0400600/**
601 * radeon_enable_vblank_kms - enable vblank interrupt
602 *
603 * @dev: drm dev pointer
604 * @crtc: crtc to enable vblank interrupt for
605 *
606 * Enable the interrupt on the requested crtc (all asics).
607 * Returns 0 on success, -EINVAL on failure.
608 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200609int radeon_enable_vblank_kms(struct drm_device *dev, int crtc)
610{
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200611 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200612 unsigned long irqflags;
613 int r;
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200614
Dave Airlie9c950a42010-04-23 13:21:58 +1000615 if (crtc < 0 || crtc >= rdev->num_crtc) {
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200616 DRM_ERROR("Invalid crtc %d\n", crtc);
617 return -EINVAL;
618 }
619
Christian Koenigfb982572012-05-17 01:33:30 +0200620 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200621 rdev->irq.crtc_vblank_int[crtc] = true;
Christian Koenigfb982572012-05-17 01:33:30 +0200622 r = radeon_irq_set(rdev);
623 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
624 return r;
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200625}
626
Alex Deucherf482a142012-07-17 14:02:34 -0400627/**
628 * radeon_disable_vblank_kms - disable vblank interrupt
629 *
630 * @dev: drm dev pointer
631 * @crtc: crtc to disable vblank interrupt for
632 *
633 * Disable the interrupt on the requested crtc (all asics).
634 */
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200635void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
636{
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200637 struct radeon_device *rdev = dev->dev_private;
Christian Koenigfb982572012-05-17 01:33:30 +0200638 unsigned long irqflags;
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200639
Dave Airlie9c950a42010-04-23 13:21:58 +1000640 if (crtc < 0 || crtc >= rdev->num_crtc) {
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200641 DRM_ERROR("Invalid crtc %d\n", crtc);
642 return;
643 }
644
Christian Koenigfb982572012-05-17 01:33:30 +0200645 spin_lock_irqsave(&rdev->irq.lock, irqflags);
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200646 rdev->irq.crtc_vblank_int[crtc] = false;
Michel Dänzer7ed220d2009-08-13 11:10:51 +0200647 radeon_irq_set(rdev);
Christian Koenigfb982572012-05-17 01:33:30 +0200648 spin_unlock_irqrestore(&rdev->irq.lock, irqflags);
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200649}
650
Alex Deucherf482a142012-07-17 14:02:34 -0400651/**
652 * radeon_get_vblank_timestamp_kms - get vblank timestamp
653 *
654 * @dev: drm dev pointer
655 * @crtc: crtc to get the timestamp for
656 * @max_error: max error
657 * @vblank_time: time value
658 * @flags: flags passed to the driver
659 *
660 * Gets the timestamp on the requested crtc based on the
661 * scanout position. (all asics).
662 * Returns postive status flags on success, negative error on failure.
663 */
Mario Kleinerf5a80202010-10-23 04:42:17 +0200664int radeon_get_vblank_timestamp_kms(struct drm_device *dev, int crtc,
665 int *max_error,
666 struct timeval *vblank_time,
667 unsigned flags)
668{
669 struct drm_crtc *drmcrtc;
670 struct radeon_device *rdev = dev->dev_private;
671
672 if (crtc < 0 || crtc >= dev->num_crtcs) {
673 DRM_ERROR("Invalid crtc %d\n", crtc);
674 return -EINVAL;
675 }
676
677 /* Get associated drm_crtc: */
678 drmcrtc = &rdev->mode_info.crtcs[crtc]->base;
679
680 /* Helper routine in DRM core does all the work: */
681 return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc, max_error,
682 vblank_time, flags,
683 drmcrtc);
684}
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200685
686/*
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200687 * IOCTL.
688 */
689int radeon_dma_ioctl_kms(struct drm_device *dev, void *data,
690 struct drm_file *file_priv)
691{
692 /* Not valid in KMS. */
693 return -EINVAL;
694}
695
696#define KMS_INVALID_IOCTL(name) \
697int name(struct drm_device *dev, void *data, struct drm_file *file_priv)\
698{ \
699 DRM_ERROR("invalid ioctl with kms %s\n", __func__); \
700 return -EINVAL; \
701}
702
703/*
704 * All these ioctls are invalid in kms world.
705 */
706KMS_INVALID_IOCTL(radeon_cp_init_kms)
707KMS_INVALID_IOCTL(radeon_cp_start_kms)
708KMS_INVALID_IOCTL(radeon_cp_stop_kms)
709KMS_INVALID_IOCTL(radeon_cp_reset_kms)
710KMS_INVALID_IOCTL(radeon_cp_idle_kms)
711KMS_INVALID_IOCTL(radeon_cp_resume_kms)
712KMS_INVALID_IOCTL(radeon_engine_reset_kms)
713KMS_INVALID_IOCTL(radeon_fullscreen_kms)
714KMS_INVALID_IOCTL(radeon_cp_swap_kms)
715KMS_INVALID_IOCTL(radeon_cp_clear_kms)
716KMS_INVALID_IOCTL(radeon_cp_vertex_kms)
717KMS_INVALID_IOCTL(radeon_cp_indices_kms)
718KMS_INVALID_IOCTL(radeon_cp_texture_kms)
719KMS_INVALID_IOCTL(radeon_cp_stipple_kms)
720KMS_INVALID_IOCTL(radeon_cp_indirect_kms)
721KMS_INVALID_IOCTL(radeon_cp_vertex2_kms)
722KMS_INVALID_IOCTL(radeon_cp_cmdbuf_kms)
723KMS_INVALID_IOCTL(radeon_cp_getparam_kms)
724KMS_INVALID_IOCTL(radeon_cp_flip_kms)
725KMS_INVALID_IOCTL(radeon_mem_alloc_kms)
726KMS_INVALID_IOCTL(radeon_mem_free_kms)
727KMS_INVALID_IOCTL(radeon_mem_init_heap_kms)
728KMS_INVALID_IOCTL(radeon_irq_emit_kms)
729KMS_INVALID_IOCTL(radeon_irq_wait_kms)
730KMS_INVALID_IOCTL(radeon_cp_setparam_kms)
731KMS_INVALID_IOCTL(radeon_surface_alloc_kms)
732KMS_INVALID_IOCTL(radeon_surface_free_kms)
733
734
735struct drm_ioctl_desc radeon_ioctls_kms[] = {
Dave Airlie1b2f1482010-08-14 20:20:34 +1000736 DRM_IOCTL_DEF_DRV(RADEON_CP_INIT, radeon_cp_init_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
737 DRM_IOCTL_DEF_DRV(RADEON_CP_START, radeon_cp_start_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
738 DRM_IOCTL_DEF_DRV(RADEON_CP_STOP, radeon_cp_stop_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
739 DRM_IOCTL_DEF_DRV(RADEON_CP_RESET, radeon_cp_reset_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
740 DRM_IOCTL_DEF_DRV(RADEON_CP_IDLE, radeon_cp_idle_kms, DRM_AUTH),
741 DRM_IOCTL_DEF_DRV(RADEON_CP_RESUME, radeon_cp_resume_kms, DRM_AUTH),
742 DRM_IOCTL_DEF_DRV(RADEON_RESET, radeon_engine_reset_kms, DRM_AUTH),
743 DRM_IOCTL_DEF_DRV(RADEON_FULLSCREEN, radeon_fullscreen_kms, DRM_AUTH),
744 DRM_IOCTL_DEF_DRV(RADEON_SWAP, radeon_cp_swap_kms, DRM_AUTH),
745 DRM_IOCTL_DEF_DRV(RADEON_CLEAR, radeon_cp_clear_kms, DRM_AUTH),
746 DRM_IOCTL_DEF_DRV(RADEON_VERTEX, radeon_cp_vertex_kms, DRM_AUTH),
747 DRM_IOCTL_DEF_DRV(RADEON_INDICES, radeon_cp_indices_kms, DRM_AUTH),
748 DRM_IOCTL_DEF_DRV(RADEON_TEXTURE, radeon_cp_texture_kms, DRM_AUTH),
749 DRM_IOCTL_DEF_DRV(RADEON_STIPPLE, radeon_cp_stipple_kms, DRM_AUTH),
750 DRM_IOCTL_DEF_DRV(RADEON_INDIRECT, radeon_cp_indirect_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
751 DRM_IOCTL_DEF_DRV(RADEON_VERTEX2, radeon_cp_vertex2_kms, DRM_AUTH),
752 DRM_IOCTL_DEF_DRV(RADEON_CMDBUF, radeon_cp_cmdbuf_kms, DRM_AUTH),
753 DRM_IOCTL_DEF_DRV(RADEON_GETPARAM, radeon_cp_getparam_kms, DRM_AUTH),
754 DRM_IOCTL_DEF_DRV(RADEON_FLIP, radeon_cp_flip_kms, DRM_AUTH),
755 DRM_IOCTL_DEF_DRV(RADEON_ALLOC, radeon_mem_alloc_kms, DRM_AUTH),
756 DRM_IOCTL_DEF_DRV(RADEON_FREE, radeon_mem_free_kms, DRM_AUTH),
757 DRM_IOCTL_DEF_DRV(RADEON_INIT_HEAP, radeon_mem_init_heap_kms, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
758 DRM_IOCTL_DEF_DRV(RADEON_IRQ_EMIT, radeon_irq_emit_kms, DRM_AUTH),
759 DRM_IOCTL_DEF_DRV(RADEON_IRQ_WAIT, radeon_irq_wait_kms, DRM_AUTH),
760 DRM_IOCTL_DEF_DRV(RADEON_SETPARAM, radeon_cp_setparam_kms, DRM_AUTH),
761 DRM_IOCTL_DEF_DRV(RADEON_SURF_ALLOC, radeon_surface_alloc_kms, DRM_AUTH),
762 DRM_IOCTL_DEF_DRV(RADEON_SURF_FREE, radeon_surface_free_kms, DRM_AUTH),
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200763 /* KMS */
Dave Airlie1b2f1482010-08-14 20:20:34 +1000764 DRM_IOCTL_DEF_DRV(RADEON_GEM_INFO, radeon_gem_info_ioctl, DRM_AUTH|DRM_UNLOCKED),
765 DRM_IOCTL_DEF_DRV(RADEON_GEM_CREATE, radeon_gem_create_ioctl, DRM_AUTH|DRM_UNLOCKED),
766 DRM_IOCTL_DEF_DRV(RADEON_GEM_MMAP, radeon_gem_mmap_ioctl, DRM_AUTH|DRM_UNLOCKED),
767 DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_DOMAIN, radeon_gem_set_domain_ioctl, DRM_AUTH|DRM_UNLOCKED),
768 DRM_IOCTL_DEF_DRV(RADEON_GEM_PREAD, radeon_gem_pread_ioctl, DRM_AUTH|DRM_UNLOCKED),
769 DRM_IOCTL_DEF_DRV(RADEON_GEM_PWRITE, radeon_gem_pwrite_ioctl, DRM_AUTH|DRM_UNLOCKED),
770 DRM_IOCTL_DEF_DRV(RADEON_GEM_WAIT_IDLE, radeon_gem_wait_idle_ioctl, DRM_AUTH|DRM_UNLOCKED),
771 DRM_IOCTL_DEF_DRV(RADEON_CS, radeon_cs_ioctl, DRM_AUTH|DRM_UNLOCKED),
772 DRM_IOCTL_DEF_DRV(RADEON_INFO, radeon_info_ioctl, DRM_AUTH|DRM_UNLOCKED),
773 DRM_IOCTL_DEF_DRV(RADEON_GEM_SET_TILING, radeon_gem_set_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED),
774 DRM_IOCTL_DEF_DRV(RADEON_GEM_GET_TILING, radeon_gem_get_tiling_ioctl, DRM_AUTH|DRM_UNLOCKED),
775 DRM_IOCTL_DEF_DRV(RADEON_GEM_BUSY, radeon_gem_busy_ioctl, DRM_AUTH|DRM_UNLOCKED),
Jerome Glisse721604a2012-01-05 22:11:05 -0500776 DRM_IOCTL_DEF_DRV(RADEON_GEM_VA, radeon_gem_va_ioctl, DRM_AUTH|DRM_UNLOCKED),
Jerome Glisse771fe6b2009-06-05 14:42:42 +0200777};
778int radeon_max_kms_ioctl = DRM_ARRAY_SIZE(radeon_ioctls_kms);