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