1 /* 2 * Copyright 2013 Red Hat 3 * All Rights Reserved. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * 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 AUTHORS AND/OR ITS SUPPLIERS 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 #ifndef QXL_DRM_H 25 #define QXL_DRM_H 26 27 #include <stddef.h> 28 #include "drm.h" 29 30 /* Please note that modifications to all structs defined here are 31 * subject to backwards-compatibility constraints. 32 * 33 * Do not use pointers, use uint64_t instead for 32 bit / 64 bit user/kernel 34 * compatibility Keep fields aligned to their size 35 */ 36 37 #define QXL_GEM_DOMAIN_CPU 0 38 #define QXL_GEM_DOMAIN_VRAM 1 39 #define QXL_GEM_DOMAIN_SURFACE 2 40 41 #define DRM_QXL_ALLOC 0x00 42 #define DRM_QXL_MAP 0x01 43 #define DRM_QXL_EXECBUFFER 0x02 44 #define DRM_QXL_UPDATE_AREA 0x03 45 #define DRM_QXL_GETPARAM 0x04 46 #define DRM_QXL_CLIENTCAP 0x05 47 48 #define DRM_QXL_ALLOC_SURF 0x06 49 50 struct drm_qxl_alloc { 51 uint32_t size; 52 uint32_t handle; /* 0 is an invalid handle */ 53 }; 54 55 struct drm_qxl_map { 56 uint64_t offset; /* use for mmap system call */ 57 uint32_t handle; 58 uint32_t pad; 59 }; 60 61 /* 62 * dest is the bo we are writing the relocation into 63 * src is bo we are relocating. 64 * *(dest_handle.base_addr + dest_offset) = physical_address(src_handle.addr + 65 * src_offset) 66 */ 67 #define QXL_RELOC_TYPE_BO 1 68 #define QXL_RELOC_TYPE_SURF 2 69 70 struct drm_qxl_reloc { 71 uint64_t src_offset; /* offset into src_handle or src buffer */ 72 uint64_t dst_offset; /* offset in dest handle */ 73 uint32_t src_handle; /* dest handle to compute address from */ 74 uint32_t dst_handle; /* 0 if to command buffer */ 75 uint32_t reloc_type; 76 uint32_t pad; 77 }; 78 79 struct drm_qxl_command { 80 uint64_t command; /* void* */ 81 uint64_t relocs; /* struct drm_qxl_reloc* */ 82 uint32_t type; 83 uint32_t command_size; 84 uint32_t relocs_num; 85 uint32_t pad; 86 }; 87 88 /* XXX: call it drm_qxl_commands? */ 89 struct drm_qxl_execbuffer { 90 uint32_t flags; /* for future use */ 91 uint32_t commands_num; 92 uint64_t commands; /* struct drm_qxl_command* */ 93 }; 94 95 struct drm_qxl_update_area { 96 uint32_t handle; 97 uint32_t top; 98 uint32_t left; 99 uint32_t bottom; 100 uint32_t right; 101 uint32_t pad; 102 }; 103 104 #define QXL_PARAM_NUM_SURFACES 1 /* rom->n_surfaces */ 105 #define QXL_PARAM_MAX_RELOCS 2 106 struct drm_qxl_getparam { 107 uint64_t param; 108 uint64_t value; 109 }; 110 111 /* these are one bit values */ 112 struct drm_qxl_clientcap { 113 uint32_t index; 114 uint32_t pad; 115 }; 116 117 struct drm_qxl_alloc_surf { 118 uint32_t format; 119 uint32_t width; 120 uint32_t height; 121 int32_t stride; 122 uint32_t handle; 123 uint32_t pad; 124 }; 125 126 #define DRM_IOCTL_QXL_ALLOC \ 127 DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC, struct drm_qxl_alloc) 128 129 #define DRM_IOCTL_QXL_MAP \ 130 DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_MAP, struct drm_qxl_map) 131 132 #define DRM_IOCTL_QXL_EXECBUFFER \ 133 DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_EXECBUFFER,\ 134 struct drm_qxl_execbuffer) 135 136 #define DRM_IOCTL_QXL_UPDATE_AREA \ 137 DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_UPDATE_AREA,\ 138 struct drm_qxl_update_area) 139 140 #define DRM_IOCTL_QXL_GETPARAM \ 141 DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_GETPARAM,\ 142 struct drm_qxl_getparam) 143 144 #define DRM_IOCTL_QXL_CLIENTCAP \ 145 DRM_IOW(DRM_COMMAND_BASE + DRM_QXL_CLIENTCAP,\ 146 struct drm_qxl_clientcap) 147 148 #define DRM_IOCTL_QXL_ALLOC_SURF \ 149 DRM_IOWR(DRM_COMMAND_BASE + DRM_QXL_ALLOC_SURF,\ 150 struct drm_qxl_alloc_surf) 151 152 #endif 153