• 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 namespace gfxstream {
21 
22 // See definitions in rutabaga_gfx_ffi.h
23 #define VIRTGPU_CAPSET_VIRGL 1
24 #define VIRTGPU_CAPSET_VIRGL2 2
25 #define VIRTGPU_CAPSET_GFXSTREAM_VULKAN 3
26 #define VIRTGPU_CAPSET_VENUS 4
27 #define VIRTGPU_CAPSET_CROSS_DOMAIN 5
28 #define VIRTGPU_CAPSET_DRM 6
29 #define VIRTGPU_CAPSET_GFXSTREAM_MAGMA 7
30 #define VIRTGPU_CAPSET_GFXSTREAM_GLES 8
31 #define VIRTGPU_CAPSET_GFXSTREAM_COMPOSER 9
32 
33 // Address Space Graphics contexts
34 #define GFXSTREAM_CONTEXT_CREATE                0x1001
35 #define GFXSTREAM_CONTEXT_PING                  0x1002
36 #define GFXSTREAM_CONTEXT_PING_WITH_RESPONSE    0x1003
37 
38 // Native Sync FD
39 #define GFXSTREAM_CREATE_EXPORT_SYNC            0x9000
40 #define GFXSTREAM_CREATE_IMPORT_SYNC            0x9001
41 
42 // Vulkan Sync
43 #define GFXSTREAM_CREATE_EXPORT_SYNC_VK         0xa000
44 #define GFXSTREAM_CREATE_IMPORT_SYNC_VK         0xa001
45 #define GFXSTREAM_CREATE_QSRI_EXPORT_VK         0xa002
46 
47 // clang-format off
48 // A placeholder command to ensure virtio-gpu completes
49 #define GFXSTREAM_PLACEHOLDER_COMMAND_VK        0xf002
50 // clang-format on
51 
52 struct gfxstreamHeader {
53     uint32_t opCode;
54 };
55 
56 struct gfxstreamContextCreate {
57     struct gfxstreamHeader hdr;
58     uint32_t resourceId;
59 };
60 
61 struct gfxstreamContextPing {
62     struct gfxstreamHeader hdr;
63     uint32_t resourceId;
64 };
65 
66 struct gfxstreamCreateExportSync {
67     struct gfxstreamHeader hdr;
68     uint32_t syncHandleLo;
69     uint32_t syncHandleHi;
70 };
71 
72 struct gfxstreamCreateExportSyncVK {
73     struct gfxstreamHeader hdr;
74     uint32_t deviceHandleLo;
75     uint32_t deviceHandleHi;
76     uint32_t fenceHandleLo;
77     uint32_t fenceHandleHi;
78 };
79 
80 struct gfxstreamCreateQSRIExportVK {
81     struct gfxstreamHeader hdr;
82     uint32_t imageHandleLo;
83     uint32_t imageHandleHi;
84 };
85 
86 struct gfxstreamPlaceholderCommandVk {
87     struct gfxstreamHeader hdr;
88     uint32_t pad;
89     uint32_t padding;
90 };
91 
92 struct vulkanCapset {
93     uint32_t protocolVersion;
94 
95     // ASG Ring Parameters
96     uint32_t ringSize;
97     uint32_t bufferSize;
98 
99     uint32_t colorBufferMemoryIndex;
100     uint32_t deferredMapping;
101     uint32_t blobAlignment;
102     uint32_t noRenderControlEnc;
103     uint32_t padding[14];
104 };
105 
106 struct magmaCapset {
107     uint32_t protocolVersion;
108     // ASG Ring Parameters
109     uint32_t ringSize;
110     uint32_t bufferSize;
111     uint32_t blobAlignment;
112 };
113 
114 struct glesCapset {
115     uint32_t protocolVersion;
116     // ASG Ring Parameters
117     uint32_t ringSize;
118     uint32_t bufferSize;
119     uint32_t blobAlignment;
120 };
121 
122 struct composerCapset {
123     uint32_t protocolVersion;
124     // ASG Ring Parameters
125     uint32_t ringSize;
126     uint32_t bufferSize;
127     uint32_t blobAlignment;
128 };
129 
130 }  // namespace gfxstream
131 
132 #endif
133