1 // Copyright 2021 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef VIRTGPU_CROSS_DOMAIN_PROTOCOL_H 6 #define VIRTGPU_CROSS_DOMAIN_PROTOCOL_H 7 8 #include <stdint.h> 9 10 // Cross-domain commands (only a maximum of 255 supported) 11 #define CROSS_DOMAIN_CMD_INIT 1 12 #define CROSS_DOMAIN_CMD_GET_IMAGE_REQUIREMENTS 2 13 #define CROSS_DOMAIN_CMD_POLL 3 14 #define CROSS_DOMAIN_CMD_SEND 4 15 #define CROSS_DOMAIN_CMD_RECEIVE 5 16 #define CROSS_DOMAIN_CMD_READ 6 17 #define CROSS_DOMAIN_CMD_WRITE 7 18 19 // Channel types (must match rutabaga channel types) 20 #define CROSS_DOMAIN_CHANNEL_TYPE_WAYLAND 0x0001 21 #define CROSS_DOMAIN_CHANNEL_TYPE_CAMERA 0x0002 22 23 // The maximum number of identifiers (value based on wp_linux_dmabuf) 24 #define CROSS_DOMAIN_MAX_IDENTIFIERS 4 25 26 // virtgpu memory resource ID. Also works with non-blob memory resources, 27 // despite the name. 28 #define CROSS_DOMAIN_ID_TYPE_VIRTGPU_BLOB 1 29 30 // virtgpu synchronization resource id. 31 #define CROSS_DOMAIN_ID_TYPE_VIRTGPU_SYNC 2 32 33 // ID for Wayland pipe used for reading. The reading is done by the guest proxy 34 // and the host proxy. The host sends the write end of the proxied pipe over 35 // the host Wayland socket. 36 #define CROSS_DOMAIN_ID_TYPE_READ_PIPE 3 37 38 // ID for Wayland pipe used for writing. The writing is done by the guest and 39 // the host proxy. The host receives the write end of the pipe over the host 40 // Wayland socket. 41 #define CROSS_DOMAIN_ID_TYPE_WRITE_PIPE 4 42 43 // No ring used 44 #define CROSS_DOMAIN_RING_NONE 0xffffffff 45 // A ring for metadata queries. 46 #define CROSS_DOMAIN_QUERY_RING 0 47 // A ring based on this particular context's channel. 48 #define CROSS_DOMAIN_CHANNEL_RING 1 49 50 // Read pipe IDs start at this value. 51 #define CROSS_DOMAIN_PIPE_READ_START 0x80000000 52 53 struct CrossDomainCapabilities { 54 uint32_t version; 55 uint32_t supported_channels; 56 uint32_t supports_dmabuf; 57 uint32_t supports_external_gpu_memory; 58 }; 59 60 struct CrossDomainImageRequirements { 61 uint32_t strides[4]; 62 uint32_t offsets[4]; 63 uint64_t modifier; 64 uint64_t size; 65 uint32_t blob_id; 66 uint32_t map_info; 67 int32_t memory_idx; 68 int32_t physical_device_idx; 69 }; 70 71 struct CrossDomainHeader { 72 uint8_t cmd; 73 uint8_t fence_ctx_idx; 74 uint16_t cmd_size; 75 uint32_t pad; 76 }; 77 78 struct CrossDomainInit { 79 struct CrossDomainHeader hdr; 80 uint32_t query_ring_id; 81 uint32_t channel_ring_id; 82 uint32_t channel_type; 83 }; 84 85 struct CrossDomainGetImageRequirements { 86 struct CrossDomainHeader hdr; 87 uint32_t width; 88 uint32_t height; 89 uint32_t drm_format; 90 uint32_t flags; 91 }; 92 93 struct CrossDomainPoll { 94 struct CrossDomainHeader hdr; 95 uint64_t pad; 96 }; 97 98 struct CrossDomainSendReceive { 99 struct CrossDomainHeader hdr; 100 uint32_t num_identifiers; 101 uint32_t opaque_data_size; 102 uint32_t identifiers[CROSS_DOMAIN_MAX_IDENTIFIERS]; 103 uint32_t identifier_types[CROSS_DOMAIN_MAX_IDENTIFIERS]; 104 uint32_t identifier_sizes[CROSS_DOMAIN_MAX_IDENTIFIERS]; 105 }; 106 107 struct CrossDomainReadWrite { 108 struct CrossDomainHeader hdr; 109 uint32_t identifier; 110 uint32_t hang_up; 111 uint32_t opaque_data_size; 112 uint32_t pad; 113 }; 114 115 #endif 116