VBoxVideoGuest.h revision e07dc26b
1/*
2 * Copyright (C) 2006-2017 Oracle Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23
24#ifndef ___VBox_Graphics_VBoxVideoGuest_h___
25#define ___VBox_Graphics_VBoxVideoGuest_h___
26
27#include "VBoxVideoIPRT.h"
28#include "HGSMIBase.h"
29#include "VBoxVideo.h"
30
31RT_C_DECLS_BEGIN
32
33/**
34 * Structure grouping the context needed for sending graphics acceleration
35 * information to the host via VBVA.  Each screen has its own VBVA buffer.
36 */
37typedef struct VBVABUFFERCONTEXT
38{
39    /** Offset of the buffer in the VRAM section for the screen */
40    uint32_t    offVRAMBuffer;
41    /** Length of the buffer in bytes */
42    uint32_t    cbBuffer;
43    /** This flag is set if we wrote to the buffer faster than the host could
44     * read it. */
45    bool        fHwBufferOverflow;
46    /** The VBVA record that we are currently preparing for the host, NULL if
47     * none. */
48    struct VBVARECORD *pRecord;
49    /** Pointer to the VBVA buffer mapped into the current address space.  Will
50     * be NULL if VBVA is not enabled. */
51    struct VBVABUFFER *pVBVA;
52} VBVABUFFERCONTEXT, *PVBVABUFFERCONTEXT;
53
54/** @name Base HGSMI APIs
55 * @{ */
56
57DECLHIDDEN(bool)     VBoxHGSMIIsSupported(void);
58DECLHIDDEN(void)     VBoxHGSMIGetBaseMappingInfo(uint32_t cbVRAM,
59                                                 uint32_t *poffVRAMBaseMapping,
60                                                 uint32_t *pcbMapping,
61                                                 uint32_t *poffGuestHeapMemory,
62                                                 uint32_t *pcbGuestHeapMemory,
63                                                 uint32_t *poffHostFlags);
64DECLHIDDEN(int)      VBoxHGSMIReportFlagsLocation(PHGSMIGUESTCOMMANDCONTEXT pCtx,
65                                                  HGSMIOFFSET offLocation);
66DECLHIDDEN(int)      VBoxHGSMISendCapsInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
67                                           uint32_t fCaps);
68DECLHIDDEN(void)     VBoxHGSMIGetHostAreaMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx,
69                                                 uint32_t cbVRAM,
70                                                 uint32_t offVRAMBaseMapping,
71                                                 uint32_t *poffVRAMHostArea,
72                                                 uint32_t *pcbHostArea);
73DECLHIDDEN(int)      VBoxHGSMISendHostCtxInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
74                                              HGSMIOFFSET offVRAMFlagsLocation,
75                                              uint32_t fCaps,
76                                              uint32_t offVRAMHostArea,
77                                              uint32_t cbHostArea);
78DECLHIDDEN(int)      VBoxQueryConfHGSMI(PHGSMIGUESTCOMMANDCONTEXT pCtx,
79                                    uint32_t u32Index, uint32_t *pulValue);
80DECLHIDDEN(int)      VBoxQueryConfHGSMIDef(PHGSMIGUESTCOMMANDCONTEXT pCtx,
81                                           uint32_t u32Index, uint32_t u32DefValue, uint32_t *pulValue);
82DECLHIDDEN(int)      VBoxHGSMIUpdatePointerShape(PHGSMIGUESTCOMMANDCONTEXT pCtx,
83                                                 uint32_t fFlags,
84                                                 uint32_t cHotX,
85                                                 uint32_t cHotY,
86                                                 uint32_t cWidth,
87                                                 uint32_t cHeight,
88                                                 uint8_t *pPixels,
89                                                 uint32_t cbLength);
90DECLHIDDEN(int)      VBoxHGSMICursorPosition(PHGSMIGUESTCOMMANDCONTEXT pCtx, bool fReportPosition, uint32_t x, uint32_t y,
91                                             uint32_t *pxHost, uint32_t *pyHost);
92
93/** @}  */
94
95/** @name VBVA APIs
96 * @{ */
97DECLHIDDEN(bool) VBoxVBVAEnable(PVBVABUFFERCONTEXT pCtx,
98                                PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
99                                struct VBVABUFFER *pVBVA, int32_t cScreen);
100DECLHIDDEN(void) VBoxVBVADisable(PVBVABUFFERCONTEXT pCtx,
101                                 PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
102                                 int32_t cScreen);
103DECLHIDDEN(bool) VBoxVBVABufferBeginUpdate(PVBVABUFFERCONTEXT pCtx,
104                                           PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx);
105DECLHIDDEN(void) VBoxVBVABufferEndUpdate(PVBVABUFFERCONTEXT pCtx);
106DECLHIDDEN(bool) VBoxVBVAWrite(PVBVABUFFERCONTEXT pCtx,
107                               PHGSMIGUESTCOMMANDCONTEXT pHGSMICtx,
108                               const void *pv, uint32_t cb);
109DECLHIDDEN(bool) VBoxVBVAOrderSupported(PVBVABUFFERCONTEXT pCtx, unsigned code);
110DECLHIDDEN(void) VBoxVBVASetupBufferContext(PVBVABUFFERCONTEXT pCtx,
111                                            uint32_t offVRAMBuffer,
112                                            uint32_t cbBuffer);
113
114/** @}  */
115
116/** @name Modesetting APIs
117 * @{ */
118
119DECLHIDDEN(uint32_t) VBoxHGSMIGetMonitorCount(PHGSMIGUESTCOMMANDCONTEXT pCtx);
120DECLHIDDEN(uint32_t) VBoxVideoGetVRAMSize(void);
121DECLHIDDEN(bool)     VBoxVideoAnyWidthAllowed(void);
122DECLHIDDEN(uint16_t) VBoxHGSMIGetScreenFlags(PHGSMIGUESTCOMMANDCONTEXT pCtx);
123
124struct VBVAINFOVIEW;
125/**
126 * Callback funtion called from @a VBoxHGSMISendViewInfo to initialise
127 * the @a VBVAINFOVIEW structure for each screen.
128 *
129 * @returns  iprt status code
130 * @param  pvData  context data for the callback, passed to @a
131 *                 VBoxHGSMISendViewInfo along with the callback
132 * @param  pInfo   array of @a VBVAINFOVIEW structures to be filled in
133 * @todo  explicitly pass the array size
134 */
135typedef DECLCALLBACK(int) FNHGSMIFILLVIEWINFO(void *pvData,
136                                              struct VBVAINFOVIEW *pInfo,
137                                              uint32_t cViews);
138/** Pointer to a FNHGSMIFILLVIEWINFO callback */
139typedef FNHGSMIFILLVIEWINFO *PFNHGSMIFILLVIEWINFO;
140
141DECLHIDDEN(int)      VBoxHGSMISendViewInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
142                                           uint32_t u32Count,
143                                           PFNHGSMIFILLVIEWINFO pfnFill,
144                                           void *pvData);
145DECLHIDDEN(void)     VBoxVideoSetModeRegisters(uint16_t cWidth, uint16_t cHeight,
146                                               uint16_t cVirtWidth, uint16_t cBPP,
147                                               uint16_t fFlags,
148                                               uint16_t cx, uint16_t cy);
149DECLHIDDEN(bool)     VBoxVideoGetModeRegisters(uint16_t *pcWidth,
150                                               uint16_t *pcHeight,
151                                               uint16_t *pcVirtWidth,
152                                               uint16_t *pcBPP,
153                                               uint16_t *pfFlags);
154DECLHIDDEN(void)     VBoxVideoDisableVBE(void);
155DECLHIDDEN(void)     VBoxHGSMIProcessDisplayInfo(PHGSMIGUESTCOMMANDCONTEXT pCtx,
156                                                 uint32_t cDisplay,
157                                                 int32_t  cOriginX,
158                                                 int32_t  cOriginY,
159                                                 uint32_t offStart,
160                                                 uint32_t cbPitch,
161                                                 uint32_t cWidth,
162                                                 uint32_t cHeight,
163                                                 uint16_t cBPP,
164                                                 uint16_t fFlags);
165DECLHIDDEN(int)      VBoxHGSMIUpdateInputMapping(PHGSMIGUESTCOMMANDCONTEXT pCtx, int32_t  cOriginX, int32_t  cOriginY,
166                                                 uint32_t cWidth, uint32_t cHeight);
167DECLHIDDEN(int) VBoxHGSMIGetModeHints(PHGSMIGUESTCOMMANDCONTEXT pCtx,
168                                      unsigned cScreens, VBVAMODEHINT *paHints);
169
170/** @}  */
171
172RT_C_DECLS_END
173
174#endif
175
176