Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 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 VIRTGPU_DRM_H |
| 25 | #define VIRTGPU_DRM_H |
| 26 | |
Gabriel Laskar | 6e82e9c | 2015-11-30 15:10:55 +0100 | [diff] [blame] | 27 | #include "drm.h" |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 28 | |
Emil Velikov | 3818081 | 2016-04-07 19:38:49 +0100 | [diff] [blame] | 29 | #if defined(__cplusplus) |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 33 | /* Please note that modifications to all structs defined here are |
| 34 | * subject to backwards-compatibility constraints. |
| 35 | * |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 36 | * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 37 | * compatibility Keep fields aligned to their size |
| 38 | */ |
| 39 | |
| 40 | #define DRM_VIRTGPU_MAP 0x01 |
| 41 | #define DRM_VIRTGPU_EXECBUFFER 0x02 |
| 42 | #define DRM_VIRTGPU_GETPARAM 0x03 |
| 43 | #define DRM_VIRTGPU_RESOURCE_CREATE 0x04 |
| 44 | #define DRM_VIRTGPU_RESOURCE_INFO 0x05 |
| 45 | #define DRM_VIRTGPU_TRANSFER_FROM_HOST 0x06 |
| 46 | #define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07 |
| 47 | #define DRM_VIRTGPU_WAIT 0x08 |
| 48 | #define DRM_VIRTGPU_GET_CAPS 0x09 |
| 49 | |
| 50 | struct drm_virtgpu_map { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 51 | __u64 offset; /* use for mmap system call */ |
| 52 | __u32 handle; |
| 53 | __u32 pad; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct drm_virtgpu_execbuffer { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 57 | __u32 flags; /* for future use */ |
| 58 | __u32 size; |
| 59 | __u64 command; /* void* */ |
| 60 | __u64 bo_handles; |
| 61 | __u32 num_bo_handles; |
| 62 | __u32 pad; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */ |
Dave Airlie | 9a191b1 | 2018-02-21 11:50:03 +1000 | [diff] [blame] | 66 | #define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */ |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 67 | |
| 68 | struct drm_virtgpu_getparam { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 69 | __u64 param; |
| 70 | __u64 value; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | /* NO_BO flags? NO resource flag? */ |
| 74 | /* resource flag for y_0_top */ |
| 75 | struct drm_virtgpu_resource_create { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 76 | __u32 target; |
| 77 | __u32 format; |
| 78 | __u32 bind; |
| 79 | __u32 width; |
| 80 | __u32 height; |
| 81 | __u32 depth; |
| 82 | __u32 array_size; |
| 83 | __u32 last_level; |
| 84 | __u32 nr_samples; |
| 85 | __u32 flags; |
| 86 | __u32 bo_handle; /* if this is set - recreate a new resource attached to this bo ? */ |
| 87 | __u32 res_handle; /* returned by kernel */ |
| 88 | __u32 size; /* validate transfer in the host */ |
| 89 | __u32 stride; /* validate transfer in the host */ |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | struct drm_virtgpu_resource_info { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 93 | __u32 bo_handle; |
| 94 | __u32 res_handle; |
| 95 | __u32 size; |
| 96 | __u32 stride; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | struct drm_virtgpu_3d_box { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 100 | __u32 x; |
| 101 | __u32 y; |
| 102 | __u32 z; |
| 103 | __u32 w; |
| 104 | __u32 h; |
| 105 | __u32 d; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | struct drm_virtgpu_3d_transfer_to_host { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 109 | __u32 bo_handle; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 110 | struct drm_virtgpu_3d_box box; |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 111 | __u32 level; |
| 112 | __u32 offset; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | struct drm_virtgpu_3d_transfer_from_host { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 116 | __u32 bo_handle; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 117 | struct drm_virtgpu_3d_box box; |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 118 | __u32 level; |
| 119 | __u32 offset; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | #define VIRTGPU_WAIT_NOWAIT 1 /* like it */ |
| 123 | struct drm_virtgpu_3d_wait { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 124 | __u32 handle; /* 0 is an invalid handle */ |
| 125 | __u32 flags; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | struct drm_virtgpu_get_caps { |
Gabriel Laskar | 29e08b0 | 2015-11-30 15:10:39 +0100 | [diff] [blame] | 129 | __u32 cap_set_id; |
| 130 | __u32 cap_set_ver; |
| 131 | __u64 addr; |
| 132 | __u32 size; |
| 133 | __u32 pad; |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 134 | }; |
| 135 | |
| 136 | #define DRM_IOCTL_VIRTGPU_MAP \ |
| 137 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map) |
| 138 | |
| 139 | #define DRM_IOCTL_VIRTGPU_EXECBUFFER \ |
| 140 | DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\ |
| 141 | struct drm_virtgpu_execbuffer) |
| 142 | |
| 143 | #define DRM_IOCTL_VIRTGPU_GETPARAM \ |
| 144 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM,\ |
| 145 | struct drm_virtgpu_getparam) |
| 146 | |
| 147 | #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE \ |
| 148 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE, \ |
| 149 | struct drm_virtgpu_resource_create) |
| 150 | |
| 151 | #define DRM_IOCTL_VIRTGPU_RESOURCE_INFO \ |
| 152 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, \ |
| 153 | struct drm_virtgpu_resource_info) |
| 154 | |
| 155 | #define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST \ |
| 156 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST, \ |
| 157 | struct drm_virtgpu_3d_transfer_from_host) |
| 158 | |
| 159 | #define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST \ |
| 160 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, \ |
| 161 | struct drm_virtgpu_3d_transfer_to_host) |
| 162 | |
| 163 | #define DRM_IOCTL_VIRTGPU_WAIT \ |
| 164 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT, \ |
| 165 | struct drm_virtgpu_3d_wait) |
| 166 | |
| 167 | #define DRM_IOCTL_VIRTGPU_GET_CAPS \ |
| 168 | DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \ |
| 169 | struct drm_virtgpu_get_caps) |
| 170 | |
Emil Velikov | 3818081 | 2016-04-07 19:38:49 +0100 | [diff] [blame] | 171 | #if defined(__cplusplus) |
| 172 | } |
| 173 | #endif |
| 174 | |
Gerd Hoffmann | 62fb7a5 | 2014-10-28 12:48:00 +0100 | [diff] [blame] | 175 | #endif |