VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/VBoxClient/display-ipc.h@ 93375

最後變更 在這個檔案從93375是 93375,由 vboxsync 提交於 3 年 前

Additions: Linux: scm fixes, bugref:10134.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 7.9 KB
 
1/* $Id: display-ipc.h 93375 2022-01-20 18:11:54Z vboxsync $ */
2/** @file
3 *
4 * Definitions for IPC communication in between VBoxDRMClient and VBoxClient.
5 */
6
7/*
8 * Copyright (C) 2006-2022 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.alldomusa.eu.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef GA_INCLUDED_SRC_x11_VBoxClient_display_ipc_h
20#define GA_INCLUDED_SRC_x11_VBoxClient_display_ipc_h
21#ifndef RT_WITHOUT_PRAGMA_ONCE
22# pragma once
23#endif
24
25# include <iprt/assert.h>
26# include <iprt/localipc.h>
27# include <iprt/critsect.h>
28# include <iprt/list.h>
29
30/** Name of DRM IPC server.*/
31# define VBOX_DRMIPC_SERVER_NAME "DRMIpcServer"
32/** A user group which is allowed to connect to IPC server. */
33#define VBOX_DRMIPC_USER_GROUP "vboxdrmipc"
34/** Time in milliseconds to wait for host events. */
35#define VBOX_DRMIPC_RX_TIMEOUT_MS (500)
36/** Time in milliseconds to relax in between unsuccessful connect attempts. */
37#define VBOX_DRMIPC_RX_RELAX_MS (500)
38/** Size of RX buffer for IPC communication. */
39#define VBOX_DRMIPC_RX_BUFFER_SIZE (1024)
40/** Maximum amount of TX messages which can be queued. */
41#define VBOX_DRMIPC_TX_QUEUE_SIZE (64)
42/** Maximum number of physical monitor configurations we can process. */
43#define VBOX_DRMIPC_MONITORS_MAX (32)
44
45/** Rectangle structure for geometry of a single screen. */
46struct VBOX_DRMIPC_VMWRECT
47{
48 /** Monitor X offset. */
49 int32_t x;
50 /** Monitor Y offset. */
51 int32_t y;
52 /** Monitor width. */
53 uint32_t w;
54 /** Monitor height. */
55 uint32_t h;
56};
57AssertCompileSize(struct VBOX_DRMIPC_VMWRECT, 16);
58
59/** List of IPC commands issued by client to server. */
60typedef enum VBOXDRMIPCSRVCMD
61{
62 /** Separate server and client commands by starting index. */
63 VBOXDRMIPCSRVCMD_INVALID = 0x00,
64 /** Client reports list of current display offsets. */
65 VBOXDRMIPCSRVCMD_REPORT_DISPLAY_OFFSETS,
66 /** Termination of commands list. */
67 VBOXDRMIPCSRVCMD_MAX,
68} VBOXDRMIPCSRVCMD;
69
70/** List of IPC commands issued by server to client. */
71typedef enum VBOXDRMIPCCLTCMD
72{
73 /** Separate server and client commands by starting index. */
74 VBOXDRMIPCCLTCMD_INVALID = 0x7F,
75 /** Server requests client to set primary screen. */
76 VBOXDRMIPCCLTCMD_SET_PRIMARY_DISPLAY,
77 /** Termination of commands list. */
78 VBOXDRMIPCCLTCMD_MAX,
79} VBOXDRMIPCCLTCMD;
80
81/** IPC command header. */
82typedef struct VBOX_DRMIPC_COMMAND_HEADER
83{
84 /** IPC command structure checksum, includes header and payload. */
85 uint64_t u64Crc;
86 /** IPC command identificator (opaque). */
87 uint8_t idCmd;
88 /** Size of payload data. */
89 uint64_t cbData;
90
91} VBOX_DRMIPC_COMMAND_HEADER;
92
93/** Pointer to IPC command header. */
94typedef VBOX_DRMIPC_COMMAND_HEADER *PVBOX_DRMIPC_COMMAND_HEADER;
95
96/** IPC command VBOXDRMIPCCLTCMD_SET_PRIMARY_DISPLAY payload. */
97typedef struct VBOX_DRMIPC_COMMAND_SET_PRIMARY_DISPLAY
98{
99 /* IPC command header. */
100 VBOX_DRMIPC_COMMAND_HEADER Hdr;
101 /** ID of display to be set as primary. */
102 uint32_t idDisplay;
103
104} VBOX_DRMIPC_COMMAND_SET_PRIMARY_DISPLAY;
105
106/** Pointer to IPC command DRMIPCCOMMAND_SET_PRIMARY_DISPLAY payload. */
107typedef VBOX_DRMIPC_COMMAND_SET_PRIMARY_DISPLAY *PVBOX_DRMIPC_COMMAND_SET_PRIMARY_DISPLAY;
108
109/** IPC command VBOXDRMIPCSRVCMD_REPORT_DISPLAY_OFFSETS payload. */
110typedef struct VBOX_DRMIPC_COMMAND_REPORT_DISPLAY_OFFSETS
111{
112 /* IPC command header. */
113 VBOX_DRMIPC_COMMAND_HEADER Hdr;
114 /** Number of displays which have changed offsets. */
115 uint32_t cOffsets;
116 /** Offsets data. */
117 RTPOINT paOffsets[VBOX_DRMIPC_MONITORS_MAX];
118
119} VBOX_DRMIPC_COMMAND_REPORT_DISPLAY_OFFSETS;
120
121/** Pointer to IPC command DRMIPCCOMMAND_SET_PRIMARY_DISPLAY payload. */
122typedef VBOX_DRMIPC_COMMAND_REPORT_DISPLAY_OFFSETS *PVBOX_DRMIPC_COMMAND_REPORT_DISPLAY_OFFSETS;
123
124/** DRM IPC TX list entry. */
125typedef struct VBOX_DRMIPC_TX_LIST_ENTRY
126{
127 /** The list node. */
128 RTLISTNODE Node;
129 /* IPC command header. */
130 VBOX_DRMIPC_COMMAND_HEADER Hdr;
131} VBOX_DRMIPC_TX_LIST_ENTRY;
132
133/** Pointer to DRM IPC TX list entry. */
134typedef VBOX_DRMIPC_TX_LIST_ENTRY *PVBOX_DRMIPC_TX_LIST_ENTRY;
135
136/**
137 * A callback function which is called by IPC client session thread when new message arrives.
138 *
139 * @returns IPRT status code.
140 * @param idCmd Command ID to be executed (opaque).
141 * @param pvData Command specific argument data.
142 * @param cbData Size of command argument data as received over IPC.
143 */
144typedef DECLCALLBACKTYPE(int, FNDRMIPCRXCB, (uint8_t idCmd, void *pvData, uint32_t cbData));
145
146/** Pointer to FNDRMIPCRXCB. */
147typedef FNDRMIPCRXCB *PFNDRMIPCRXCB;
148
149/** IPC session private data. */
150typedef struct VBOX_DRMIPC_CLIENT
151{
152 /** Thread handle which dispatches this IPC client session. */
153 RTTHREAD hThread;
154 /** IPC session handle. */
155 RTLOCALIPCSESSION hClientSession;
156 /** TX message queue mutex. */
157 RTCRITSECT CritSect;
158 /** TX message queue (accessed under critsect). */
159 VBOX_DRMIPC_TX_LIST_ENTRY TxList;
160 /** Maximum number of messages which can be queued to TX message queue. */
161 uint32_t cTxListCapacity;
162 /** Actual number of messages currently queued to TX message queue (accessed under critsect). */
163 uint32_t cTxListSize;
164 /** IPC RX callback. */
165 PFNDRMIPCRXCB pfnRxCb;
166} VBOX_DRMIPC_CLIENT;
167
168/** Pointer to IPC session private data. */
169typedef VBOX_DRMIPC_CLIENT *PVBOX_DRMIPC_CLIENT;
170
171/** Static initializer for VBOX_DRMIPC_CLIENT. */
172#define VBOX_DRMIPC_CLIENT_INITIALIZER { NIL_RTTHREAD, 0, 0, 0, 0, 0, 0 }
173
174/**
175 * Initialize IPC client private data.
176 *
177 * @return IPRT status code.
178 * @param pClient IPC client private data to be initialized.
179 * @param hThread A thread which server IPC client connection.
180 * @param hClientSession IPC session handle obtained from RTLocalIpcSessionXXX().
181 * @param cTxListCapacity Maximum number of messages which can be queued for TX for this IPC session.
182 * @param pfnRxCb IPC RX callback function pointer.
183 */
184RTDECL(int) vbDrmIpcClientInit(PVBOX_DRMIPC_CLIENT pClient, RTTHREAD hThread, RTLOCALIPCSESSION hClientSession,
185 uint32_t cTxListCapacity, PFNDRMIPCRXCB pfnRxCb);
186
187/**
188 * Releases IPC client private data resources.
189 *
190 * @return IPRT status code.
191 * @param pClient IPC session private data to be initialized.
192 */
193RTDECL(int) vbDrmIpcClientReleaseResources(PVBOX_DRMIPC_CLIENT pClient);
194
195/**
196 * Verify if remote IPC peer corresponds to a process which is running
197 * from allowed user.
198 *
199 * @return IPRT status code.
200 * @param hClientSession IPC session handle.
201 */
202RTDECL(int) vbDrmIpcAuth(RTLOCALIPCSESSION hClientSession);
203
204/**
205 * Common function for both IPC server and client which is responsible
206 * for handling IPC communication flow.
207 *
208 * @return IPRT status code.
209 * @param pClient IPC connection private data.
210 */
211RTDECL(int) vbDrmIpcConnectionHandler(PVBOX_DRMIPC_CLIENT pClient);
212
213/**
214 * Request remote IPC peer to set primary display.
215 *
216 * @return IPRT status code.
217 * @param pClient IPC session private data.
218 * @param idDisplay ID of display to be set as primary.
219 */
220RTDECL(int) vbDrmIpcSetPrimaryDisplay(PVBOX_DRMIPC_CLIENT pClient, uint32_t idDisplay);
221
222/**
223 * Report to IPC server that display layout offsets have been changed (called by IPC client).
224 *
225 * @return IPRT status code.
226 * @param pClient IPC session private data.
227 * @param cOffsets Number of monitors which have offsets changed.
228 * @param paOffsets Offsets data.
229 */
230RTDECL(int) vbDrmIpcReportDisplayOffsets(PVBOX_DRMIPC_CLIENT pClient, uint32_t cOffsets, RTPOINT *paOffsets);
231
232#endif /* !GA_INCLUDED_SRC_x11_VBoxClient_display_ipc_h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette