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 DRM_VIRTGPU_RESOURCE_CREATE_BLOB 0x0a 22 23 #define VIRTGPU_PARAM_RESOURCE_BLOB 3 /* DRM_VIRTGPU_RESOURCE_CREATE_BLOB */ 24 #define VIRTGPU_PARAM_HOST_VISIBLE 4 25 26 #ifndef VIRTGPU_BLOB_MEM_HOST3D 27 struct drm_virtgpu_resource_create_blob { 28 #define VIRTGPU_BLOB_MEM_GUEST 0x0001 29 #define VIRTGPU_BLOB_MEM_HOST 0x0002 30 #define VIRTGPU_BLOB_MEM_HOST_GUEST 0x0003 31 32 #define VIRTGPU_BLOB_FLAG_MAPPABLE 0x0001 33 #define VIRTGPU_BLOB_FLAG_SHAREABLE 0x0002 34 #define VIRTGPU_BLOB_FLAG_CROSS_DEVICE 0x0004 35 /* zero is invalid blob_mem */ 36 uint32_t blob_mem; 37 uint32_t blob_flags; 38 uint32_t bo_handle; 39 uint32_t res_handle; 40 uint64_t size; 41 42 /* 43 * for 3D contexts with VIRTGPU_BLOB_MEM_HOSTGUEST and 44 * VIRTGPU_BLOB_MEM_HOST otherwise, must be zero. 45 */ 46 uint32_t pad; 47 uint32_t cmd_size; 48 uint64_t cmd; 49 uint64_t blob_id; 50 }; 51 #else 52 #define VIRTGPU_BLOB_MEM_HOST VIRTGPU_BLOB_MEM_HOST3D 53 #define VIRTGPU_BLOB_MEM_HOST_GUEST VIRTGPU_BLOB_MEM_HOST3D_GUEST 54 55 #define VIRTGPU_BLOB_FLAG_MAPPABLE VIRTGPU_BLOB_FLAG_USE_MAPPABLE 56 #define VIRTGPU_BLOB_FLAG_SHAREABLE VIRTGPU_BLOB_FLAG_USE_SHAREABLE 57 #define VIRTGPU_BLOB_FLAG_CROSS_DEVICE VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE 58 #endif 59 60 61 #define DRM_IOCTL_VIRTGPU_RESOURCE_CREATE_BLOB \ 62 DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_RESOURCE_CREATE_BLOB, \ 63 struct drm_virtgpu_resource_create_blob) 64