Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Red Hat Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
| 22 | * Authors: Dave Airlie |
| 23 | * Alon Levy |
| 24 | */ |
| 25 | |
| 26 | #include "qxl_drv.h" |
| 27 | #include "qxl_object.h" |
| 28 | |
| 29 | /* |
| 30 | * TODO: allocating a new gem(in qxl_bo) for each request. |
| 31 | * This is wasteful since bo's are page aligned. |
| 32 | */ |
Dave Airlie | 6d01f1f | 2013-04-16 13:24:25 +1000 | [diff] [blame] | 33 | static int qxl_alloc_ioctl(struct drm_device *dev, void *data, |
| 34 | struct drm_file *file_priv) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 35 | { |
| 36 | struct qxl_device *qdev = dev->dev_private; |
| 37 | struct drm_qxl_alloc *qxl_alloc = data; |
| 38 | int ret; |
| 39 | struct qxl_bo *qobj; |
| 40 | uint32_t handle; |
| 41 | u32 domain = QXL_GEM_DOMAIN_VRAM; |
| 42 | |
| 43 | if (qxl_alloc->size == 0) { |
| 44 | DRM_ERROR("invalid size %d\n", qxl_alloc->size); |
| 45 | return -EINVAL; |
| 46 | } |
| 47 | ret = qxl_gem_object_create_with_handle(qdev, file_priv, |
| 48 | domain, |
| 49 | qxl_alloc->size, |
| 50 | NULL, |
| 51 | &qobj, &handle); |
| 52 | if (ret) { |
| 53 | DRM_ERROR("%s: failed to create gem ret=%d\n", |
| 54 | __func__, ret); |
| 55 | return -ENOMEM; |
| 56 | } |
| 57 | qxl_alloc->handle = handle; |
| 58 | return 0; |
| 59 | } |
| 60 | |
Dave Airlie | 6d01f1f | 2013-04-16 13:24:25 +1000 | [diff] [blame] | 61 | static int qxl_map_ioctl(struct drm_device *dev, void *data, |
| 62 | struct drm_file *file_priv) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 63 | { |
| 64 | struct qxl_device *qdev = dev->dev_private; |
| 65 | struct drm_qxl_map *qxl_map = data; |
| 66 | |
| 67 | return qxl_mode_dumb_mmap(file_priv, qdev->ddev, qxl_map->handle, |
| 68 | &qxl_map->offset); |
| 69 | } |
| 70 | |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 71 | struct qxl_reloc_info { |
| 72 | int type; |
| 73 | struct qxl_bo *dst_bo; |
| 74 | uint32_t dst_offset; |
| 75 | struct qxl_bo *src_bo; |
| 76 | int src_offset; |
| 77 | }; |
| 78 | |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 79 | /* |
| 80 | * dst must be validated, i.e. whole bo on vram/surfacesram (right now all bo's |
| 81 | * are on vram). |
| 82 | * *(dst + dst_off) = qxl_bo_physical_address(src, src_off) |
| 83 | */ |
| 84 | static void |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 85 | apply_reloc(struct qxl_device *qdev, struct qxl_reloc_info *info) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 86 | { |
| 87 | void *reloc_page; |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 88 | reloc_page = qxl_bo_kmap_atomic_page(qdev, info->dst_bo, info->dst_offset & PAGE_MASK); |
| 89 | *(uint64_t *)(reloc_page + (info->dst_offset & ~PAGE_MASK)) = qxl_bo_physical_address(qdev, |
| 90 | info->src_bo, |
| 91 | info->src_offset); |
| 92 | qxl_bo_kunmap_atomic_page(qdev, info->dst_bo, reloc_page); |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | static void |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 96 | apply_surf_reloc(struct qxl_device *qdev, struct qxl_reloc_info *info) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 97 | { |
| 98 | uint32_t id = 0; |
| 99 | void *reloc_page; |
| 100 | |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 101 | if (info->src_bo && !info->src_bo->is_primary) |
| 102 | id = info->src_bo->surface_id; |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 103 | |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 104 | reloc_page = qxl_bo_kmap_atomic_page(qdev, info->dst_bo, info->dst_offset & PAGE_MASK); |
| 105 | *(uint32_t *)(reloc_page + (info->dst_offset & ~PAGE_MASK)) = id; |
| 106 | qxl_bo_kunmap_atomic_page(qdev, info->dst_bo, reloc_page); |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /* return holding the reference to this object */ |
Dave Airlie | 6d01f1f | 2013-04-16 13:24:25 +1000 | [diff] [blame] | 110 | static struct qxl_bo *qxlhw_handle_to_bo(struct qxl_device *qdev, |
| 111 | struct drm_file *file_priv, uint64_t handle, |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 112 | struct qxl_release *release) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 113 | { |
| 114 | struct drm_gem_object *gobj; |
| 115 | struct qxl_bo *qobj; |
| 116 | int ret; |
| 117 | |
| 118 | gobj = drm_gem_object_lookup(qdev->ddev, file_priv, handle); |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 119 | if (!gobj) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 120 | return NULL; |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 121 | |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 122 | qobj = gem_to_qxl_bo(gobj); |
| 123 | |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 124 | ret = qxl_release_list_add(release, qobj); |
Frediano Ziglio | 74d9a63 | 2015-06-03 12:09:18 +0100 | [diff] [blame^] | 125 | drm_gem_object_unreference_unlocked(gobj); |
| 126 | if (ret) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 127 | return NULL; |
| 128 | |
| 129 | return qobj; |
| 130 | } |
| 131 | |
| 132 | /* |
| 133 | * Usage of execbuffer: |
| 134 | * Relocations need to take into account the full QXLDrawable size. |
| 135 | * However, the command as passed from user space must *not* contain the initial |
| 136 | * QXLReleaseInfo struct (first XXX bytes) |
| 137 | */ |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 138 | static int qxl_process_single_command(struct qxl_device *qdev, |
| 139 | struct drm_qxl_command *cmd, |
| 140 | struct drm_file *file_priv) |
| 141 | { |
| 142 | struct qxl_reloc_info *reloc_info; |
| 143 | int release_type; |
| 144 | struct qxl_release *release; |
| 145 | struct qxl_bo *cmd_bo; |
| 146 | void *fb_cmd; |
Frediano Ziglio | 74d9a63 | 2015-06-03 12:09:18 +0100 | [diff] [blame^] | 147 | int i, ret, num_relocs; |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 148 | int unwritten; |
| 149 | |
| 150 | switch (cmd->type) { |
| 151 | case QXL_CMD_DRAW: |
| 152 | release_type = QXL_RELEASE_DRAWABLE; |
| 153 | break; |
| 154 | case QXL_CMD_SURFACE: |
| 155 | case QXL_CMD_CURSOR: |
| 156 | default: |
| 157 | DRM_DEBUG("Only draw commands in execbuffers\n"); |
| 158 | return -EINVAL; |
| 159 | break; |
| 160 | } |
| 161 | |
| 162 | if (cmd->command_size > PAGE_SIZE - sizeof(union qxl_release_info)) |
| 163 | return -EINVAL; |
| 164 | |
| 165 | if (!access_ok(VERIFY_READ, |
| 166 | (void *)(unsigned long)cmd->command, |
| 167 | cmd->command_size)) |
| 168 | return -EFAULT; |
| 169 | |
| 170 | reloc_info = kmalloc(sizeof(struct qxl_reloc_info) * cmd->relocs_num, GFP_KERNEL); |
| 171 | if (!reloc_info) |
| 172 | return -ENOMEM; |
| 173 | |
| 174 | ret = qxl_alloc_release_reserved(qdev, |
| 175 | sizeof(union qxl_release_info) + |
| 176 | cmd->command_size, |
| 177 | release_type, |
| 178 | &release, |
| 179 | &cmd_bo); |
| 180 | if (ret) |
| 181 | goto out_free_reloc; |
| 182 | |
| 183 | /* TODO copy slow path code from i915 */ |
| 184 | fb_cmd = qxl_bo_kmap_atomic_page(qdev, cmd_bo, (release->release_offset & PAGE_SIZE)); |
| 185 | unwritten = __copy_from_user_inatomic_nocache(fb_cmd + sizeof(union qxl_release_info) + (release->release_offset & ~PAGE_SIZE), (void *)(unsigned long)cmd->command, cmd->command_size); |
| 186 | |
| 187 | { |
| 188 | struct qxl_drawable *draw = fb_cmd; |
| 189 | draw->mm_time = qdev->rom->mm_clock; |
| 190 | } |
| 191 | |
| 192 | qxl_bo_kunmap_atomic_page(qdev, cmd_bo, fb_cmd); |
| 193 | if (unwritten) { |
| 194 | DRM_ERROR("got unwritten %d\n", unwritten); |
| 195 | ret = -EFAULT; |
| 196 | goto out_free_release; |
| 197 | } |
| 198 | |
| 199 | /* fill out reloc info structs */ |
| 200 | num_relocs = 0; |
| 201 | for (i = 0; i < cmd->relocs_num; ++i) { |
| 202 | struct drm_qxl_reloc reloc; |
| 203 | |
Daniel Vetter | 1d6ac18 | 2013-12-11 11:34:44 +0100 | [diff] [blame] | 204 | if (copy_from_user(&reloc, |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 205 | &((struct drm_qxl_reloc *)(uintptr_t)cmd->relocs)[i], |
| 206 | sizeof(reloc))) { |
| 207 | ret = -EFAULT; |
| 208 | goto out_free_bos; |
| 209 | } |
| 210 | |
| 211 | /* add the bos to the list of bos to validate - |
| 212 | need to validate first then process relocs? */ |
| 213 | if (reloc.reloc_type != QXL_RELOC_TYPE_BO && reloc.reloc_type != QXL_RELOC_TYPE_SURF) { |
Frediano Ziglio | 55cc3df | 2015-06-03 12:09:11 +0100 | [diff] [blame] | 214 | DRM_DEBUG("unknown reloc type %d\n", reloc.reloc_type); |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 215 | |
| 216 | ret = -EINVAL; |
| 217 | goto out_free_bos; |
| 218 | } |
| 219 | reloc_info[i].type = reloc.reloc_type; |
| 220 | |
| 221 | if (reloc.dst_handle) { |
| 222 | reloc_info[i].dst_bo = qxlhw_handle_to_bo(qdev, file_priv, |
| 223 | reloc.dst_handle, release); |
| 224 | if (!reloc_info[i].dst_bo) { |
| 225 | ret = -EINVAL; |
| 226 | reloc_info[i].src_bo = NULL; |
| 227 | goto out_free_bos; |
| 228 | } |
| 229 | reloc_info[i].dst_offset = reloc.dst_offset; |
| 230 | } else { |
| 231 | reloc_info[i].dst_bo = cmd_bo; |
| 232 | reloc_info[i].dst_offset = reloc.dst_offset + release->release_offset; |
| 233 | } |
| 234 | num_relocs++; |
| 235 | |
| 236 | /* reserve and validate the reloc dst bo */ |
| 237 | if (reloc.reloc_type == QXL_RELOC_TYPE_BO || reloc.src_handle > 0) { |
| 238 | reloc_info[i].src_bo = |
| 239 | qxlhw_handle_to_bo(qdev, file_priv, |
| 240 | reloc.src_handle, release); |
| 241 | if (!reloc_info[i].src_bo) { |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 242 | ret = -EINVAL; |
| 243 | goto out_free_bos; |
| 244 | } |
| 245 | reloc_info[i].src_offset = reloc.src_offset; |
| 246 | } else { |
| 247 | reloc_info[i].src_bo = NULL; |
| 248 | reloc_info[i].src_offset = 0; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | /* validate all buffers */ |
| 253 | ret = qxl_release_reserve_list(release, false); |
| 254 | if (ret) |
| 255 | goto out_free_bos; |
| 256 | |
| 257 | for (i = 0; i < cmd->relocs_num; ++i) { |
| 258 | if (reloc_info[i].type == QXL_RELOC_TYPE_BO) |
| 259 | apply_reloc(qdev, &reloc_info[i]); |
| 260 | else if (reloc_info[i].type == QXL_RELOC_TYPE_SURF) |
| 261 | apply_surf_reloc(qdev, &reloc_info[i]); |
| 262 | } |
| 263 | |
| 264 | ret = qxl_push_command_ring_release(qdev, release, cmd->type, true); |
| 265 | if (ret) |
| 266 | qxl_release_backoff_reserve_list(release); |
| 267 | else |
| 268 | qxl_release_fence_buffer_objects(release); |
| 269 | |
| 270 | out_free_bos: |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 271 | out_free_release: |
| 272 | if (ret) |
| 273 | qxl_release_free(qdev, release); |
| 274 | out_free_reloc: |
| 275 | kfree(reloc_info); |
| 276 | return ret; |
| 277 | } |
| 278 | |
Dave Airlie | 6d01f1f | 2013-04-16 13:24:25 +1000 | [diff] [blame] | 279 | static int qxl_execbuffer_ioctl(struct drm_device *dev, void *data, |
| 280 | struct drm_file *file_priv) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 281 | { |
| 282 | struct qxl_device *qdev = dev->dev_private; |
| 283 | struct drm_qxl_execbuffer *execbuffer = data; |
| 284 | struct drm_qxl_command user_cmd; |
| 285 | int cmd_num; |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 286 | int ret; |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 287 | |
| 288 | for (cmd_num = 0; cmd_num < execbuffer->commands_num; ++cmd_num) { |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 289 | |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 290 | struct drm_qxl_command *commands = |
Dave Airlie | 970fa98 | 2013-05-31 12:45:09 +1000 | [diff] [blame] | 291 | (struct drm_qxl_command *)(uintptr_t)execbuffer->commands; |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 292 | |
Daniel Vetter | 1d6ac18 | 2013-12-11 11:34:44 +0100 | [diff] [blame] | 293 | if (copy_from_user(&user_cmd, &commands[cmd_num], |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 294 | sizeof(user_cmd))) |
| 295 | return -EFAULT; |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 296 | |
Dave Airlie | 8002db6 | 2013-07-23 14:16:42 +1000 | [diff] [blame] | 297 | ret = qxl_process_single_command(qdev, &user_cmd, file_priv); |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 298 | if (ret) |
| 299 | return ret; |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 300 | } |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 301 | return 0; |
| 302 | } |
| 303 | |
Dave Airlie | 6d01f1f | 2013-04-16 13:24:25 +1000 | [diff] [blame] | 304 | static int qxl_update_area_ioctl(struct drm_device *dev, void *data, |
| 305 | struct drm_file *file) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 306 | { |
| 307 | struct qxl_device *qdev = dev->dev_private; |
| 308 | struct drm_qxl_update_area *update_area = data; |
| 309 | struct qxl_rect area = {.left = update_area->left, |
| 310 | .top = update_area->top, |
| 311 | .right = update_area->right, |
| 312 | .bottom = update_area->bottom}; |
| 313 | int ret; |
| 314 | struct drm_gem_object *gobj = NULL; |
| 315 | struct qxl_bo *qobj = NULL; |
| 316 | |
| 317 | if (update_area->left >= update_area->right || |
| 318 | update_area->top >= update_area->bottom) |
| 319 | return -EINVAL; |
| 320 | |
| 321 | gobj = drm_gem_object_lookup(dev, file, update_area->handle); |
| 322 | if (gobj == NULL) |
| 323 | return -ENOENT; |
| 324 | |
| 325 | qobj = gem_to_qxl_bo(gobj); |
| 326 | |
| 327 | ret = qxl_bo_reserve(qobj, false); |
| 328 | if (ret) |
| 329 | goto out; |
| 330 | |
| 331 | if (!qobj->pin_count) { |
Dave Airlie | 4f49ec9 | 2013-07-23 14:06:07 +1000 | [diff] [blame] | 332 | qxl_ttm_placement_from_domain(qobj, qobj->type, false); |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 333 | ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, |
| 334 | true, false); |
| 335 | if (unlikely(ret)) |
| 336 | goto out; |
| 337 | } |
| 338 | |
| 339 | ret = qxl_bo_check_id(qdev, qobj); |
| 340 | if (ret) |
| 341 | goto out2; |
| 342 | if (!qobj->surface_id) |
| 343 | DRM_ERROR("got update area for surface with no id %d\n", update_area->handle); |
| 344 | ret = qxl_io_update_area(qdev, qobj, &area); |
| 345 | |
| 346 | out2: |
| 347 | qxl_bo_unreserve(qobj); |
| 348 | |
| 349 | out: |
| 350 | drm_gem_object_unreference_unlocked(gobj); |
| 351 | return ret; |
| 352 | } |
| 353 | |
| 354 | static int qxl_getparam_ioctl(struct drm_device *dev, void *data, |
| 355 | struct drm_file *file_priv) |
| 356 | { |
| 357 | struct qxl_device *qdev = dev->dev_private; |
| 358 | struct drm_qxl_getparam *param = data; |
| 359 | |
| 360 | switch (param->param) { |
| 361 | case QXL_PARAM_NUM_SURFACES: |
| 362 | param->value = qdev->rom->n_surfaces; |
| 363 | break; |
| 364 | case QXL_PARAM_MAX_RELOCS: |
| 365 | param->value = QXL_MAX_RES; |
| 366 | break; |
| 367 | default: |
| 368 | return -EINVAL; |
| 369 | } |
| 370 | return 0; |
| 371 | } |
| 372 | |
| 373 | static int qxl_clientcap_ioctl(struct drm_device *dev, void *data, |
| 374 | struct drm_file *file_priv) |
| 375 | { |
| 376 | struct qxl_device *qdev = dev->dev_private; |
| 377 | struct drm_qxl_clientcap *param = data; |
| 378 | int byte, idx; |
| 379 | |
| 380 | byte = param->index / 8; |
| 381 | idx = param->index % 8; |
| 382 | |
| 383 | if (qdev->pdev->revision < 4) |
| 384 | return -ENOSYS; |
| 385 | |
Dave Airlie | 62c8ba7 | 2013-04-16 13:36:00 +1000 | [diff] [blame] | 386 | if (byte >= 58) |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 387 | return -ENOSYS; |
| 388 | |
| 389 | if (qdev->rom->client_capabilities[byte] & (1 << idx)) |
| 390 | return 0; |
| 391 | return -ENOSYS; |
| 392 | } |
| 393 | |
| 394 | static int qxl_alloc_surf_ioctl(struct drm_device *dev, void *data, |
| 395 | struct drm_file *file) |
| 396 | { |
| 397 | struct qxl_device *qdev = dev->dev_private; |
| 398 | struct drm_qxl_alloc_surf *param = data; |
| 399 | struct qxl_bo *qobj; |
| 400 | int handle; |
| 401 | int ret; |
| 402 | int size, actual_stride; |
| 403 | struct qxl_surface surf; |
| 404 | |
| 405 | /* work out size allocate bo with handle */ |
| 406 | actual_stride = param->stride < 0 ? -param->stride : param->stride; |
| 407 | size = actual_stride * param->height + actual_stride; |
| 408 | |
| 409 | surf.format = param->format; |
| 410 | surf.width = param->width; |
| 411 | surf.height = param->height; |
| 412 | surf.stride = param->stride; |
| 413 | surf.data = 0; |
| 414 | |
| 415 | ret = qxl_gem_object_create_with_handle(qdev, file, |
| 416 | QXL_GEM_DOMAIN_SURFACE, |
| 417 | size, |
| 418 | &surf, |
| 419 | &qobj, &handle); |
| 420 | if (ret) { |
| 421 | DRM_ERROR("%s: failed to create gem ret=%d\n", |
| 422 | __func__, ret); |
| 423 | return -ENOMEM; |
| 424 | } else |
| 425 | param->handle = handle; |
| 426 | return ret; |
| 427 | } |
| 428 | |
Rob Clark | baa7094 | 2013-08-02 13:27:49 -0400 | [diff] [blame] | 429 | const struct drm_ioctl_desc qxl_ioctls[] = { |
Dave Airlie | f64122c | 2013-02-25 14:47:55 +1000 | [diff] [blame] | 430 | DRM_IOCTL_DEF_DRV(QXL_ALLOC, qxl_alloc_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 431 | |
| 432 | DRM_IOCTL_DEF_DRV(QXL_MAP, qxl_map_ioctl, DRM_AUTH|DRM_UNLOCKED), |
| 433 | |
| 434 | DRM_IOCTL_DEF_DRV(QXL_EXECBUFFER, qxl_execbuffer_ioctl, |
| 435 | DRM_AUTH|DRM_UNLOCKED), |
| 436 | DRM_IOCTL_DEF_DRV(QXL_UPDATE_AREA, qxl_update_area_ioctl, |
| 437 | DRM_AUTH|DRM_UNLOCKED), |
| 438 | DRM_IOCTL_DEF_DRV(QXL_GETPARAM, qxl_getparam_ioctl, |
| 439 | DRM_AUTH|DRM_UNLOCKED), |
| 440 | DRM_IOCTL_DEF_DRV(QXL_CLIENTCAP, qxl_clientcap_ioctl, |
| 441 | DRM_AUTH|DRM_UNLOCKED), |
| 442 | |
| 443 | DRM_IOCTL_DEF_DRV(QXL_ALLOC_SURF, qxl_alloc_surf_ioctl, |
| 444 | DRM_AUTH|DRM_UNLOCKED), |
| 445 | }; |
| 446 | |
Damien Lespiau | f95aeb1 | 2014-06-09 14:39:49 +0100 | [diff] [blame] | 447 | int qxl_max_ioctls = ARRAY_SIZE(qxl_ioctls); |