1040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie/* 2040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * Copyright 2013 Red Hat 3040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * All Rights Reserved. 4040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * 5040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * Permission is hereby granted, free of charge, to any person obtaining a 6040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * copy of this software and associated documentation files (the "Software"), 7040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * to deal in the Software without restriction, including without limitation 8040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * and/or sell copies of the Software, and to permit persons to whom the 10040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * Software is furnished to do so, subject to the following conditions: 11040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * 12040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * The above copyright notice and this permission notice (including the next 13040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * paragraph) shall be included in all copies or substantial portions of the 14040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * Software. 15040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * 16040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * OTHER DEALINGS IN THE SOFTWARE. 23040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie */ 24040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#ifndef QXL_DRM_H 25040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_DRM_H 26040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 27040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#include <stddef.h> 288bdb4cfa450b16f2c70729f923fa05d9553d7118Andreas Boll#include "drm.h" 29040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 30040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie/* Please note that modifications to all structs defined here are 31040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * subject to backwards-compatibility constraints. 32040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * 33040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel 34040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * compatibility Keep fields aligned to their size 35040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie */ 36040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 37040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_GEM_DOMAIN_CPU 0 38040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_GEM_DOMAIN_VRAM 1 39040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_GEM_DOMAIN_SURFACE 2 40040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 41040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_QXL_ALLOC 0x00 42040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_QXL_MAP 0x01 43040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_QXL_EXECBUFFER 0x02 44040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_QXL_UPDATE_AREA 0x03 45040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_QXL_GETPARAM 0x04 46040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_QXL_CLIENTCAP 0x05 47040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 48040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_QXL_ALLOC_SURF 0x06 49040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 50040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_alloc { 51040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t size; 52040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t handle; /* 0 is an invalid handle */ 53040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 54040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 55040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_map { 56040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t offset; /* use for mmap system call */ 57040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t handle; 58040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t pad; 59040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 60040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 61040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie/* 62040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * dest is the bo we are writing the relocation into 63040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * src is bo we are relocating. 64040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * *(dest_handle.base_addr + dest_offset) = physical_address(src_handle.addr + 65040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie * src_offset) 66040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie */ 67040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_RELOC_TYPE_BO 1 68040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_RELOC_TYPE_SURF 2 69040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 70040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_reloc { 71040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t src_offset; /* offset into src_handle or src buffer */ 72040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t dst_offset; /* offset in dest handle */ 73040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t src_handle; /* dest handle to compute address from */ 74040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t dst_handle; /* 0 if to command buffer */ 75040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t reloc_type; 76040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t pad; 77040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 78040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 79040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_command { 80040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t command; /* void* */ 81040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t relocs; /* struct drm_qxl_reloc* */ 82040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t type; 83040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t command_size; 84040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t relocs_num; 85040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t pad; 86040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 87040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 88040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie/* XXX: call it drm_qxl_commands? */ 89040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_execbuffer { 90040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t flags; /* for future use */ 91040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t commands_num; 92040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t commands; /* struct drm_qxl_command* */ 93040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 94040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 95040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_update_area { 96040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t handle; 97040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t top; 98040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t left; 99040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t bottom; 100040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t right; 101040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t pad; 102040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 103040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 104040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_PARAM_NUM_SURFACES 1 /* rom->n_surfaces */ 105040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define QXL_PARAM_MAX_RELOCS 2 106040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_getparam { 107040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t param; 108040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint64_t value; 109040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 110040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 111040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie/* these are one bit values */ 112040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_clientcap { 113040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t index; 114040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t pad; 115040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 116040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 117040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airliestruct drm_qxl_alloc_surf { 118040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t format; 119040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t width; 120040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t height; 121040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie int32_t stride; 122040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t handle; 123040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie uint32_t pad; 124040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie}; 125040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 126040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_IOCTL_QXL_ALLOC \ 127040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc) 128040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 129040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_IOCTL_QXL_MAP \ 130040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map) 131040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 132040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_IOCTL_QXL_EXECBUFFER \ 133040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER,\ 134040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie struct drm_qxl_execbuffer) 135040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 136040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_IOCTL_QXL_UPDATE_AREA \ 137040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA,\ 138040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie struct drm_qxl_update_area) 139040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 140040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_IOCTL_QXL_GETPARAM \ 141040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM,\ 142040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie struct drm_qxl_getparam) 143040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 144040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_IOCTL_QXL_CLIENTCAP \ 145040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP,\ 146040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie struct drm_qxl_clientcap) 147040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 148040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#define DRM_IOCTL_QXL_ALLOC_SURF \ 149040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF,\ 150040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie struct drm_qxl_alloc_surf) 151040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie 152040f6b015ef7d9c1bda09f78a8873f6da45d5e95Dave Airlie#endif 153