• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef VIRTGPU_GFXSTREAM_PROTOCOL_H
16 #define VIRTGPU_GFXSTREAM_PROTOCOL_H
17 
18 #include <stdint.h>
19 
20 // See definitions in rutabaga_gfx_ffi.h
21 #define VIRTGPU_CAPSET_VIRGL 1
22 #define VIRTGPU_CAPSET_VIRGL2 2
23 #define VIRTGPU_CAPSET_GFXSTREAM_VULKAN 3
24 #define VIRTGPU_CAPSET_VENUS 4
25 #define VIRTGPU_CAPSET_CROSS_DOMAIN 5
26 #define VIRTGPU_CAPSET_DRM 6
27 #define VIRTGPU_CAPSET_GFXSTREAM_MAGMA 7
28 #define VIRTGPU_CAPSET_GFXSTREAM_GLES 8
29 #define VIRTGPU_CAPSET_GFXSTREAM_COMPOSER 9
30 
31 // Address Space Graphics contexts
32 #define GFXSTREAM_CONTEXT_CREATE                0x1001
33 #define GFXSTREAM_CONTEXT_PING                  0x1002
34 #define GFXSTREAM_CONTEXT_PING_WITH_RESPONSE    0x1003
35 
36 // Native Sync FD
37 #define GFXSTREAM_CREATE_EXPORT_SYNC            0x9000
38 #define GFXSTREAM_CREATE_IMPORT_SYNC            0x9001
39 
40 // Vulkan Sync
41 #define GFXSTREAM_CREATE_EXPORT_SYNC_VK         0xa000
42 #define GFXSTREAM_CREATE_IMPORT_SYNC_VK         0xa001
43 #define GFXSTREAM_CREATE_QSRI_EXPORT_VK         0xa002
44 
45 // clang-format off
46 // A placeholder command to ensure virtio-gpu completes
47 #define GFXSTREAM_PLACEHOLDER_COMMAND_VK        0xf002
48 // clang-format on
49 
50 struct gfxstreamHeader {
51     uint32_t opCode;
52 };
53 
54 struct gfxstreamContextCreate {
55     struct gfxstreamHeader hdr;
56     uint32_t resourceId;
57 };
58 
59 struct gfxstreamContextPing {
60     struct gfxstreamHeader hdr;
61     uint32_t resourceId;
62 };
63 
64 struct gfxstreamCreateExportSync {
65     struct gfxstreamHeader hdr;
66     uint32_t syncHandleLo;
67     uint32_t syncHandleHi;
68 };
69 
70 struct gfxstreamCreateExportSyncVK {
71     struct gfxstreamHeader hdr;
72     uint32_t deviceHandleLo;
73     uint32_t deviceHandleHi;
74     uint32_t fenceHandleLo;
75     uint32_t fenceHandleHi;
76 };
77 
78 struct gfxstreamCreateQSRIExportVK {
79     struct gfxstreamHeader hdr;
80     uint32_t imageHandleLo;
81     uint32_t imageHandleHi;
82 };
83 
84 struct gfxstreamPlaceholderCommandVk {
85     struct gfxstreamHeader hdr;
86     uint32_t pad;
87     uint32_t padding;
88 };
89 
90 struct vulkanCapset {
91     uint32_t protocolVersion;
92 
93     // ASG Ring Parameters
94     uint32_t ringSize;
95     uint32_t bufferSize;
96 
97     uint32_t colorBufferMemoryIndex;
98     uint32_t deferredMapping;
99     uint32_t blobAlignment;
100     uint32_t noRenderControlEnc;
101     uint32_t padding[14];
102 };
103 
104 struct magmaCapset {
105     uint32_t protocolVersion;
106     // ASG Ring Parameters
107     uint32_t ringSize;
108     uint32_t bufferSize;
109     uint32_t blobAlignment;
110 };
111 
112 struct glesCapset {
113     uint32_t protocolVersion;
114     // ASG Ring Parameters
115     uint32_t ringSize;
116     uint32_t bufferSize;
117     uint32_t blobAlignment;
118 };
119 
120 struct composerCapset {
121     uint32_t protocolVersion;
122     // ASG Ring Parameters
123     uint32_t ringSize;
124     uint32_t bufferSize;
125     uint32_t blobAlignment;
126 };
127 
128 #endif
129