1 // Copyright (C) 2020 The Android Open Source Project 2 // Copyright (C) 2020 Google Inc. 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 #pragma once 16 17 #ifndef HOST_BUILD 18 #include "drm.h" 19 #endif 20 21 #define PIPE_BUFFER 0 22 #define VIRGL_FORMAT_R8_UNORM 64 23 #define VIRGL_BIND_CUSTOM (1 << 17) 24 25 #define DRM_VIRTGPU_RESOURCE_CREATE_BLOB 0x0a 26 27 #define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */ 28 #define VIRTGPU_PARAM_HOST_VISIBLE 4 29 30 struct drm_virtgpu_resource_create_blob { 31 #define VIRTGPU_BLOB_MEM_GUEST 0x0001 32 #define VIRTGPU_BLOB_MEM_HOST 0x0002 33 #define VIRTGPU_BLOB_MEM_HOST_GUEST 0x0003 34 35 #define VIRTGPU_BLOB_FLAG_MAPPABLE 0x0001 36 #define VIRTGPU_BLOB_FLAG_SHAREABLE 0x0002 37 #define VIRTGPU_BLOB_FLAG_CROSS_DEVICE 0x0004 38 /* zero is invalid blob_mem */ 39 uint32_t blob_mem; 40 uint32_t blob_flags; 41 uint32_t bo_handle; 42 uint32_t res_handle; 43 uint64_t size; 44 45 /* 46 * for 3D contexts with VIRTGPU_BLOB_MEM_HOSTGUEST and 47 * VIRTGPU_BLOB_MEM_HOST otherwise, must be zero. 48 */ 49 uint32_t pad; 50 uint32_t cmd_size; 51 uint64_t cmd; 52 uint64_t blob_id; 53 }; 54 55 56 #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB \ 57 DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE_BLOB, \ 58 struct drm_virtgpu_resource_create_blob) 59