18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2013 Red Hat 38c2ecf20Sopenharmony_ci * All Rights Reserved. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 68c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 78c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 88c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 98c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 108c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 138c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 148c2ecf20Sopenharmony_ci * Software. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 178c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 188c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 198c2ecf20Sopenharmony_ci * THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 208c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 218c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 228c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci#ifndef VIRTGPU_DRM_H 258c2ecf20Sopenharmony_ci#define VIRTGPU_DRM_H 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#include "drm.h" 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#if defined(__cplusplus) 308c2ecf20Sopenharmony_ciextern "C" { 318c2ecf20Sopenharmony_ci#endif 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* Please note that modifications to all structs defined here are 348c2ecf20Sopenharmony_ci * subject to backwards-compatibility constraints. 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * Do not use pointers, use __u64 instead for 32 bit / 64 bit user/kernel 378c2ecf20Sopenharmony_ci * compatibility Keep fields aligned to their size 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_MAP 0x01 418c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_EXECBUFFER 0x02 428c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_GETPARAM 0x03 438c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_RESOURCE_CREATE 0x04 448c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_RESOURCE_INFO 0x05 458c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_TRANSFER_FROM_HOST 0x06 468c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_TRANSFER_TO_HOST 0x07 478c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_WAIT 0x08 488c2ecf20Sopenharmony_ci#define DRM_VIRTGPU_GET_CAPS 0x09 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define VIRTGPU_EXECBUF_FENCE_FD_IN 0x01 518c2ecf20Sopenharmony_ci#define VIRTGPU_EXECBUF_FENCE_FD_OUT 0x02 528c2ecf20Sopenharmony_ci#define VIRTGPU_EXECBUF_FLAGS (\ 538c2ecf20Sopenharmony_ci VIRTGPU_EXECBUF_FENCE_FD_IN |\ 548c2ecf20Sopenharmony_ci VIRTGPU_EXECBUF_FENCE_FD_OUT |\ 558c2ecf20Sopenharmony_ci 0) 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistruct drm_virtgpu_map { 588c2ecf20Sopenharmony_ci __u64 offset; /* use for mmap system call */ 598c2ecf20Sopenharmony_ci __u32 handle; 608c2ecf20Sopenharmony_ci __u32 pad; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistruct drm_virtgpu_execbuffer { 648c2ecf20Sopenharmony_ci __u32 flags; 658c2ecf20Sopenharmony_ci __u32 size; 668c2ecf20Sopenharmony_ci __u64 command; /* void* */ 678c2ecf20Sopenharmony_ci __u64 bo_handles; 688c2ecf20Sopenharmony_ci __u32 num_bo_handles; 698c2ecf20Sopenharmony_ci __s32 fence_fd; /* in/out fence fd (see VIRTGPU_EXECBUF_FENCE_FD_IN/OUT) */ 708c2ecf20Sopenharmony_ci}; 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci#define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */ 738c2ecf20Sopenharmony_ci#define VIRTGPU_PARAM_CAPSET_QUERY_FIX 2 /* do we have the capset fix */ 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistruct drm_virtgpu_getparam { 768c2ecf20Sopenharmony_ci __u64 param; 778c2ecf20Sopenharmony_ci __u64 value; 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* NO_BO flags? NO resource flag? */ 818c2ecf20Sopenharmony_ci/* resource flag for y_0_top */ 828c2ecf20Sopenharmony_cistruct drm_virtgpu_resource_create { 838c2ecf20Sopenharmony_ci __u32 target; 848c2ecf20Sopenharmony_ci __u32 format; 858c2ecf20Sopenharmony_ci __u32 bind; 868c2ecf20Sopenharmony_ci __u32 width; 878c2ecf20Sopenharmony_ci __u32 height; 888c2ecf20Sopenharmony_ci __u32 depth; 898c2ecf20Sopenharmony_ci __u32 array_size; 908c2ecf20Sopenharmony_ci __u32 last_level; 918c2ecf20Sopenharmony_ci __u32 nr_samples; 928c2ecf20Sopenharmony_ci __u32 flags; 938c2ecf20Sopenharmony_ci __u32 bo_handle; /* if this is set - recreate a new resource attached to this bo ? */ 948c2ecf20Sopenharmony_ci __u32 res_handle; /* returned by kernel */ 958c2ecf20Sopenharmony_ci __u32 size; /* validate transfer in the host */ 968c2ecf20Sopenharmony_ci __u32 stride; /* validate transfer in the host */ 978c2ecf20Sopenharmony_ci}; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistruct drm_virtgpu_resource_info { 1008c2ecf20Sopenharmony_ci __u32 bo_handle; 1018c2ecf20Sopenharmony_ci __u32 res_handle; 1028c2ecf20Sopenharmony_ci __u32 size; 1038c2ecf20Sopenharmony_ci __u32 stride; 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistruct drm_virtgpu_3d_box { 1078c2ecf20Sopenharmony_ci __u32 x; 1088c2ecf20Sopenharmony_ci __u32 y; 1098c2ecf20Sopenharmony_ci __u32 z; 1108c2ecf20Sopenharmony_ci __u32 w; 1118c2ecf20Sopenharmony_ci __u32 h; 1128c2ecf20Sopenharmony_ci __u32 d; 1138c2ecf20Sopenharmony_ci}; 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_cistruct drm_virtgpu_3d_transfer_to_host { 1168c2ecf20Sopenharmony_ci __u32 bo_handle; 1178c2ecf20Sopenharmony_ci struct drm_virtgpu_3d_box box; 1188c2ecf20Sopenharmony_ci __u32 level; 1198c2ecf20Sopenharmony_ci __u32 offset; 1208c2ecf20Sopenharmony_ci}; 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistruct drm_virtgpu_3d_transfer_from_host { 1238c2ecf20Sopenharmony_ci __u32 bo_handle; 1248c2ecf20Sopenharmony_ci struct drm_virtgpu_3d_box box; 1258c2ecf20Sopenharmony_ci __u32 level; 1268c2ecf20Sopenharmony_ci __u32 offset; 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci#define VIRTGPU_WAIT_NOWAIT 1 /* like it */ 1308c2ecf20Sopenharmony_cistruct drm_virtgpu_3d_wait { 1318c2ecf20Sopenharmony_ci __u32 handle; /* 0 is an invalid handle */ 1328c2ecf20Sopenharmony_ci __u32 flags; 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cistruct drm_virtgpu_get_caps { 1368c2ecf20Sopenharmony_ci __u32 cap_set_id; 1378c2ecf20Sopenharmony_ci __u32 cap_set_ver; 1388c2ecf20Sopenharmony_ci __u64 addr; 1398c2ecf20Sopenharmony_ci __u32 size; 1408c2ecf20Sopenharmony_ci __u32 pad; 1418c2ecf20Sopenharmony_ci}; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_MAP \ 1448c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map) 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_EXECBUFFER \ 1478c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\ 1488c2ecf20Sopenharmony_ci struct drm_virtgpu_execbuffer) 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_GETPARAM \ 1518c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GETPARAM,\ 1528c2ecf20Sopenharmony_ci struct drm_virtgpu_getparam) 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE \ 1558c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE, \ 1568c2ecf20Sopenharmony_ci struct drm_virtgpu_resource_create) 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_RESOURCE_INFO \ 1598c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_INFO, \ 1608c2ecf20Sopenharmony_ci struct drm_virtgpu_resource_info) 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_TRANSFER_FROM_HOST \ 1638c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_FROM_HOST, \ 1648c2ecf20Sopenharmony_ci struct drm_virtgpu_3d_transfer_from_host) 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_TRANSFER_TO_HOST \ 1678c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_TRANSFER_TO_HOST, \ 1688c2ecf20Sopenharmony_ci struct drm_virtgpu_3d_transfer_to_host) 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_WAIT \ 1718c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_WAIT, \ 1728c2ecf20Sopenharmony_ci struct drm_virtgpu_3d_wait) 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci#define DRM_IOCTL_VIRTGPU_GET_CAPS \ 1758c2ecf20Sopenharmony_ci DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_GET_CAPS, \ 1768c2ecf20Sopenharmony_ci struct drm_virtgpu_get_caps) 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#if defined(__cplusplus) 1798c2ecf20Sopenharmony_ci} 1808c2ecf20Sopenharmony_ci#endif 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci#endif 183