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