VBoxVideo.h revision 82188f85b56ece3d757973ddfdec32d124befee2
/** @file
* VirtualBox Video miniport driver
*
* Copyright (C) 2006-2007 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef VBOXVIDEO_H
#define VBOXVIDEO_H
#ifdef VBOX_WITH_HGSMI
#include "VBoxHGSMI.h"
#endif /* VBOX_WITH_HGSMI */
#ifndef VBOX_WITH_WDDM
#include "dderror.h"
#include "devioctl.h"
#include "miniport.h"
#include "ntddvdeo.h"
#include "video.h"
#else
# define VBOX_WITH_WORKAROUND_MISSING_PACK
# endif
# include <ntddk.h>
# pragma warning(default : 4163)
# pragma pack()
# pragma warning(default : 4103)
# endif
# else
# include <ntddk.h>
# endif
#include "dispmprt.h"
#include "ntddvdeo.h"
#include "dderror.h"
#endif
#define VBE_DISPI_IOPORT_INDEX 0x01CE
#define VBE_DISPI_IOPORT_DATA 0x01CF
#define VBE_DISPI_INDEX_ID 0x0
#define VBE_DISPI_INDEX_XRES 0x1
#define VBE_DISPI_INDEX_YRES 0x2
#define VBE_DISPI_INDEX_BPP 0x3
#define VBE_DISPI_INDEX_ENABLE 0x4
#define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
#define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
#define VBE_DISPI_INDEX_X_OFFSET 0x8
#define VBE_DISPI_INDEX_Y_OFFSET 0x9
#define VBE_DISPI_INDEX_VBOX_VIDEO 0xa
#define VBE_DISPI_ID2 0xB0C2
/* The VBOX interface id. Indicates support for VBE_DISPI_INDEX_VBOX_VIDEO. */
#define VBE_DISPI_ID_VBOX_VIDEO 0xBE00
#ifdef VBOX_WITH_HGSMI
#define VBE_DISPI_ID_HGSMI 0xBE01
#endif /* VBOX_WITH_HGSMI */
#define VBE_DISPI_DISABLED 0x00
#define VBE_DISPI_ENABLED 0x01
#define VBE_DISPI_LFB_ENABLED 0x40
#define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
#define VBE_DISPI_TOTAL_VIDEO_MEMORY_MB 4
#ifdef VBOX_WITH_HGSMI
#define VGA_PORT_HGSMI_HOST 0x3b0
#define VGA_PORT_HGSMI_GUEST 0x3d0
#endif /* VBOX_WITH_HGSMI */
/* common API types */
#ifndef VBOX_WITH_WDDM
typedef PEVENT VBOXVCMNEVENT;
typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;
typedef struct _DEVICE_EXTENSION * VBOXCMNREG;
#else
typedef struct _DEVICE_EXTENSION *PDEVICE_EXTENSION;
#include <VBox/VBoxVideo.h>
#include "wddm/VBoxVideoIf.h"
#include "wddm/VBoxVideoMisc.h"
#include "wddm/VBoxVideoShgsmi.h"
#include "wddm/VBoxVideoCm.h"
#include "wddm/VBoxVideoVdma.h"
#include "wddm/VBoxVideoWddm.h"
#include "wddm/VBoxVideoVidPn.h"
#ifdef VBOXWDDM_WITH_VBVA
# include "wddm/VBoxVideoVbva.h"
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
# include "wddm/VBoxVideoVhwa.h"
#endif
typedef KEVENT VBOXVCMNEVENT;
typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;
typedef HANDLE VBOXCMNREG;
, 8)
typedef struct VBOXWDDM_POINTER_INFO
{
union
{
} Attributes;
typedef struct VBOXWDDM_GLOBAL_POINTER_INFO
{
#ifdef VBOX_WITH_VIDEOHWACCEL
typedef struct VBOXWDDM_VHWA
{
volatile uint32_t cOverlaysCreated;
#endif
typedef struct VBOXWDDM_SOURCE
{
struct VBOXWDDM_ALLOCATION * pPrimaryAllocation;
#ifdef VBOXWDDM_RENDER_FROM_SHADOW
struct VBOXWDDM_ALLOCATION * pShadowAllocation;
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
/* @todo: in our case this seems more like a target property,
* but keep it here for now */
#endif
typedef struct VBOXWDDM_TARGET
{
#endif
typedef struct _DEVICE_EXTENSION
{
* The primary extension is the first one.
*/
#ifndef VBOX_WITH_WDDM
#endif
union {
/* Information that is only relevant to the primary device or is the same for all devices. */
struct {
void *pvReqFlush; /* Pointer to preallocated generic request structure for
* VMMDevReq_VideoAccelFlush. Allocated when VBVA status
* is changed. Deallocated on HwReset.
*/
BOOLEAN bVBoxVideoSupported; /* TRUE if VBoxVideo extensions, including DualView, are supported by the host. */
int cDisplays; /* Number of displays. */
* It is at offset:
* cbAdapterMemorySize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE - cbMiniportHeap
*/
* This is mapped by miniport separately.
*/
#ifdef VBOX_WITH_WDDM
# ifdef VBOXVDMA_WITH_VBVA
# endif
#endif
#ifdef VBOX_WITH_HGSMI
volatile bool bHostCmdProcessing;
#endif
* This is mapped by miniport separately.
*/
#ifndef VBOX_WITH_HGSMI
* ulFrameBufferOffset + ulMaxFrameBufferSize.
*/
#endif /* !VBOX_WITH_HGSMI */
#ifdef VBOX_WITH_HGSMI
/* The IO Port Number for host commands. */
/* The IO Port Number for guest commands. */
# ifndef VBOX_WITH_WDDM
/* Video Port API dynamically picked up at runtime for binary backwards compatibility with older NT versions */
# else
/* committed VidPn handle */
/* Display Port handle and callbacks */
# endif
#endif /* VBOX_WITH_HGSMI */
} primary;
/* Secondary device information. */
struct {
} secondary;
} u;
#ifdef VBOX_WITH_HGSMI
#endif /* VBOX_WITH_HGSMI */
#ifdef VBOX_WITH_WDDM
/* mutex for context list operations */
volatile uint32_t cContexts3D;
volatile uint32_t cDMACmdsOutstanding;
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
#endif
#ifndef VBOX_WITH_WDDM
#define DEV_SET_MOUSE_HIDDEN(dev) \
do { \
} while (0)
#define DEV_SET_MOUSE_SHOWN(dev) \
do { \
} while (0)
#else
#define DEV_SET_MOUSE_HIDDEN(dev) \
do { \
} while (0)
#define DEV_SET_MOUSE_SHOWN(dev) \
do { \
} while (0)
#endif
extern "C"
{
#ifndef VBOX_WITH_WDDM
/* XPDM-WDDM common API */
typedef PEVENT VBOXVCMNEVENT;
typedef VBOXVCMNEVENT *PVBOXVCMNEVENT;
{
}
{
}
{
}
{
return VideoPortReadPortUchar(Port);
}
{
return VideoPortReadPortUshort(Port);
}
{
return VideoPortReadPortUlong(Port);
}
{
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
{
pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLock(pDeviceExtension, *SpinLock, OldIrql);
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
pDeviceExtension->u.primary.VideoPortProcs.pfnAcquireSpinLockAtDpcLevel(pDeviceExtension, *SpinLock);
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
{
pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLock(pDeviceExtension, *SpinLock, NewIrql);
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
pDeviceExtension->u.primary.VideoPortProcs.pfnReleaseSpinLockFromDpcLevel(pDeviceExtension, *SpinLock);
}
DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
}
DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
}
DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
{
return pDeviceExtension->u.primary.VideoPortProcs.pfnSetEvent(pDeviceExtension, (VBOXPEVENT)*pEvent); /** @todo slightly bogus cast */
}
DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
{
if(bSignaled)
return pDeviceExtension->u.primary.VideoPortProcs.pfnCreateEvent(pDeviceExtension, fFlags, NULL, (VBOXPEVENT *)pEvent); /** @todo slightly bogus cast */
}
DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
{
return pDeviceExtension->u.primary.VideoPortProcs.pfnDeleteEvent(pDeviceExtension, (VBOXPEVENT)*pEvent); /** @todo slightly bogus cast */
}
DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
{
return pDeviceExtension->u.primary.VideoPortProcs.pfnAllocatePool(pDeviceExtension, (VBOXVP_POOL_TYPE)VpNonPagedPool, NumberOfBytes, Tag);
}
{
}
DECLINLINE(VP_STATUS) VBoxVideoCmnRegInit(IN PDEVICE_EXTENSION pDeviceExtension, OUT VBOXCMNREG *pReg)
{
return NO_ERROR;
}
{
return NO_ERROR;
}
/* */
#if defined(VBOX_WITH_HGSMI) && defined(VBOX_WITH_VIDEOHWACCEL)
#endif
#else
/* XPDM-WDDM common API */
{
}
{
}
{
}
{
return READ_PORT_UCHAR(Port);
}
{
return READ_PORT_USHORT(Port);
}
{
return READ_PORT_ULONG(Port);
}
{
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquire(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, OUT PVBOXVCMNIRQL OldIrql)
{
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockAcquireAtDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockRelease(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock, IN VBOXVCMNIRQL NewIrql)
{
}
DECLINLINE(VOID) VBoxVideoCmnSpinLockReleaseFromDpcLevel(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
}
DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockCreate(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
return NO_ERROR;
}
DECLINLINE(VP_STATUS) VBoxVideoCmnSpinLockDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNSPIN_LOCK SpinLock)
{
return NO_ERROR;
}
DECLINLINE(LONG) VBoxVideoCmnEventSet(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
{
}
DECLINLINE(VP_STATUS) VBoxVideoCmnEventCreateNotification(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent, IN BOOLEAN bSignaled)
{
return NO_ERROR;
}
DECLINLINE(VP_STATUS) VBoxVideoCmnEventDelete(IN PDEVICE_EXTENSION pDeviceExtension, IN PVBOXVCMNEVENT pEvent)
{
return NO_ERROR;
}
DECLINLINE(PVOID) VBoxVideoCmnMemAllocNonPaged(IN PDEVICE_EXTENSION pDeviceExtension, IN SIZE_T NumberOfBytes, IN ULONG Tag)
{
}
{
}
{
if(!Reg)
return ERROR_INVALID_PARAMETER;
}
/* */
);
typedef struct VBOXWDDM_VIDEOMODES
{
/* @return STATUS_BUFFER_TOO_SMALL - if buffer is too small, STATUS_SUCCESS - on success */
{
#ifdef VBOXWDDM_RENDER_FROM_SHADOW
/* all memory layout info should be initialized */
/* page aligned */
#else
/* all memory layout info should be initialized */
/* page aligned */
#endif
}
{
return vboxWddmVramCpuVisibleSize(pDevExt);
}
#ifdef VBOXWDDM_RENDER_FROM_SHADOW
{
return vboxWddmVramCpuVisibleSegmentSize(pDevExt);
}
DECLINLINE(bool) vboxWddmCmpSurfDescsBase(VBOXWDDM_SURFACE_DESC *pDesc1, VBOXWDDM_SURFACE_DESC *pDesc2)
{
return false;
return false;
return false;
return false;
return false;
return true;
}
DECLINLINE(void) vboxWddmAssignShadow(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
{
{
return;
}
if (pSource->pShadowAllocation)
{
/* clear the visibility info fo the current primary */
/* release the shadow surface */
}
if (pAllocation)
{
/* this check ensures the shadow is not used for other source simultaneously */
}
}
#endif
DECLINLINE(VOID) vboxWddmAssignPrimary(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_SOURCE pSource, PVBOXWDDM_ALLOCATION pAllocation, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
{
return;
if (pSource->pPrimaryAllocation)
{
/* clear the visibility info fo the current primary */
}
if (pAllocation)
{
}
}
{
if (IsListEmpty(pList))
{
}
else
{
/* pDstList->Flink & pDstList->Blink point to the "real| entries, never to pList
* since we've checked IsListEmpty(pList) above */
}
}
#endif
#ifdef VBOX_WITH_WDDM
#endif
);
void **ppv,
#ifdef VBOX_WITH_HGSMI
/*
* Host and Guest port IO helpers.
*/
{
#ifndef VBOX_WITH_WDDM
#else
#endif
}
{
#ifndef VBOX_WITH_WDDM
#else
#endif
}
{
#ifndef VBOX_WITH_WDDM
#else
#endif
}
{
#ifndef VBOX_WITH_WDDM
#else
#endif
}
#ifndef VBOX_WITH_WDDM
#endif
#ifdef VBOX_WITH_WDDM
#else
DECLCALLBACK(int) hgsmiHostCmdRequest (HVBOXVIDEOHGSMI hHGSMI, uint8_t u8Channel, struct _VBVAHOSTCMD ** ppCmd);
#endif
int iDisplay, /* negative would mean this is a miniport handler */
);
#endif /* VBOX_WITH_HGSMI */
} /* extern "C" */
#endif /* VBOXVIDEO_H */