VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxCrHgsmi.cpp@ 64186

Last change on this file since 64186 was 62856, checked in by vboxsync, 8 years ago

warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: VBoxCrHgsmi.cpp 62856 2016-08-01 22:36:28Z vboxsync $ */
2
3/** @file
4 * VBoxVideo Display D3D User mode dll
5 */
6
7/*
8 * Copyright (C) 2011-2016 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.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#include <VBox/VBoxCrHgsmi.h>
20#include <iprt/err.h>
21
22#include "VBoxUhgsmiKmt.h"
23
24static VBOXDISPKMT_CALLBACKS g_VBoxCrHgsmiKmtCallbacks;
25static int g_bVBoxKmtCallbacksInited = 0;
26
27static int vboxCrHgsmiInitPerform(VBOXDISPKMT_CALLBACKS *pCallbacks)
28{
29 HRESULT hr = vboxDispKmtCallbacksInit(pCallbacks);
30 /*Assert(hr == S_OK);*/
31 if (hr == S_OK)
32 {
33 /* check if we can create the hgsmi */
34 PVBOXUHGSMI pHgsmi = VBoxCrHgsmiCreate();
35 if (pHgsmi)
36 {
37 /* yes, we can, so this is wddm mode */
38 VBoxCrHgsmiDestroy(pHgsmi);
39 Log(("CrHgsmi: WDDM mode supported\n"));
40 return 1;
41 }
42 vboxDispKmtCallbacksTerm(pCallbacks);
43 }
44 Log(("CrHgsmi: unsupported\n"));
45 return -1;
46}
47
48VBOXCRHGSMI_DECL(int) VBoxCrHgsmiInit(void)
49{
50 if (!g_bVBoxKmtCallbacksInited)
51 {
52 g_bVBoxKmtCallbacksInited = vboxCrHgsmiInitPerform(&g_VBoxCrHgsmiKmtCallbacks);
53 Assert(g_bVBoxKmtCallbacksInited);
54 }
55
56 return g_bVBoxKmtCallbacksInited > 0 ? VINF_SUCCESS : VERR_NOT_SUPPORTED;
57}
58
59VBOXCRHGSMI_DECL(PVBOXUHGSMI) VBoxCrHgsmiCreate()
60{
61 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = (PVBOXUHGSMI_PRIVATE_KMT)RTMemAllocZ(sizeof (*pHgsmiGL));
62 if (pHgsmiGL)
63 {
64 HRESULT hr = vboxUhgsmiKmtCreate(pHgsmiGL, TRUE /* bD3D tmp for injection thread*/);
65 Log(("CrHgsmi: faled to create KmtEsc VBOXUHGSMI instance, hr (0x%x)\n", hr));
66 if (hr == S_OK)
67 {
68 return &pHgsmiGL->BasePrivate.Base;
69 }
70 RTMemFree(pHgsmiGL);
71 }
72
73 return NULL;
74}
75
76VBOXCRHGSMI_DECL(void) VBoxCrHgsmiDestroy(PVBOXUHGSMI pHgsmi)
77{
78 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = VBOXUHGSMIKMT_GET(pHgsmi);
79 HRESULT hr = vboxUhgsmiKmtDestroy(pHgsmiGL);
80 Assert(hr == S_OK);
81 if (hr == S_OK)
82 {
83 RTMemFree(pHgsmiGL);
84 }
85}
86
87VBOXCRHGSMI_DECL(int) VBoxCrHgsmiTerm()
88{
89#if 0
90 PVBOXUHGSMI_PRIVATE_KMT pHgsmiGL = gt_pHgsmiGL;
91 if (pHgsmiGL)
92 {
93 g_VBoxCrHgsmiCallbacks.pfnClientDestroy(pHgsmiGL->BasePrivate.hClient);
94 vboxUhgsmiKmtDestroy(pHgsmiGL);
95 gt_pHgsmiGL = NULL;
96 }
97
98 if (g_pfnVBoxDispCrHgsmiTerm)
99 g_pfnVBoxDispCrHgsmiTerm();
100#endif
101 if (g_bVBoxKmtCallbacksInited > 0)
102 {
103 vboxDispKmtCallbacksTerm(&g_VBoxCrHgsmiKmtCallbacks);
104 }
105 return VINF_SUCCESS;
106}
107
108VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCtlConGetClientID(PVBOXUHGSMI pHgsmi, uint32_t *pu32ClientID)
109{
110 PVBOXUHGSMI_PRIVATE_BASE pHgsmiPrivate = (PVBOXUHGSMI_PRIVATE_BASE)pHgsmi;
111 int rc = vboxCrHgsmiPrivateCtlConGetClientID(pHgsmiPrivate, pu32ClientID);
112 if (!RT_SUCCESS(rc))
113 {
114 WARN(("vboxCrHgsmiPrivateCtlConGetClientID failed with rc (%d)", rc));
115 }
116 return rc;
117}
118
119VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCtlConGetHostCaps(PVBOXUHGSMI pHgsmi, uint32_t *pu32HostCaps)
120{
121 PVBOXUHGSMI_PRIVATE_BASE pHgsmiPrivate = (PVBOXUHGSMI_PRIVATE_BASE)pHgsmi;
122 int rc = vboxCrHgsmiPrivateCtlConGetHostCaps(pHgsmiPrivate, pu32HostCaps);
123 if (!RT_SUCCESS(rc))
124 {
125 WARN(("vboxCrHgsmiPrivateCtlConGetHostCaps failed with rc (%d)", rc));
126 }
127 return rc;
128}
129
130VBOXCRHGSMI_DECL(int) VBoxCrHgsmiCtlConCall(PVBOXUHGSMI pHgsmi, struct VBoxGuestHGCMCallInfo *pCallInfo, int cbCallInfo)
131{
132 PVBOXUHGSMI_PRIVATE_BASE pHgsmiPrivate = (PVBOXUHGSMI_PRIVATE_BASE)pHgsmi;
133 int rc = vboxCrHgsmiPrivateCtlConCall(pHgsmiPrivate, pCallInfo, cbCallInfo);
134 if (!RT_SUCCESS(rc))
135 {
136 WARN(("VBoxCrHgsmiPrivateCtlConCall failed with rc (%d)", rc));
137 }
138 return rc;
139}
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