VirtualBox

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

Last change on this file since 93560 was 93423, checked in by vboxsync, 3 years ago

Additions: Linux: update description for guest screen resizing code, bugref:10134.

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

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