Changeset 55367 in vbox for trunk/src/VBox
- Timestamp:
- Apr 22, 2015 10:21:01 AM (10 years ago)
- Location:
- trunk/src/VBox/Additions/x11/vboxvideo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
r55358 r55367 1272 1272 #endif 1273 1273 1274 vbox_open (pScrn, pScreen, pVBox); 1274 if (!VBoxHGSMIIsSupported()) 1275 { 1276 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Graphics device too old to support.\n"); 1277 return FALSE; 1278 } 1279 vbvxSetUpHGSMIHeapInGuest(pVBox, pScrn->videoRam * 1024); 1280 pVBox->cScreens = VBoxHGSMIGetMonitorCount(&pVBox->guestCtx); 1281 pVBox->pScreens = xnfcalloc(pVBox->cScreens, sizeof(*pVBox->pScreens)); 1282 pVBox->paVBVAModeHints = xnfcalloc(pVBox->cScreens, sizeof(*pVBox->paVBVAModeHints)); 1283 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Requested monitor count: %u\n", pVBox->cScreens); 1275 1284 vboxEnableVbva(pScrn); 1276 1285 /* Set up the dirty rectangle handler. It will be added into a function -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h
r55358 r55367 283 283 284 284 extern Bool vbox_cursor_init (ScreenPtr pScreen); 285 extern void vbox_open (ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox);286 285 extern void vbox_close (ScrnInfoPtr pScrn, VBOXPtr pVBox); 287 286 288 287 /* vbva.c */ 289 288 extern void vbvxHandleDirtyRect(ScrnInfoPtr pScrn, int iRects, BoxPtr aRects); 289 extern void vbvxSetUpHGSMIHeapInGuest(VBOXPtr pVBox, uint32_t cbVRAM); 290 290 extern Bool vboxEnableVbva(ScrnInfoPtr pScrn); 291 291 extern void vboxDisableVbva(ScrnInfoPtr pScrn); -
trunk/src/VBox/Additions/x11/vboxvideo/vbva.c
r55358 r55367 99 99 } 100 100 101 static DECLCALLBACK(void *) hgsmiEnvAlloc(void *pvEnv, HGSMISIZE cb) 102 { 103 NOREF(pvEnv); 104 return calloc(1, cb); 105 } 106 107 static DECLCALLBACK(void) hgsmiEnvFree(void *pvEnv, void *pv) 108 { 109 NOREF(pvEnv); 110 free(pv); 111 } 112 113 static HGSMIENV g_hgsmiEnv = 114 { 115 NULL, 116 hgsmiEnvAlloc, 117 hgsmiEnvFree 118 }; 119 120 /** 121 * Calculate the location in video RAM of and initialise the heap for guest to 122 * host messages. In the VirtualBox 4.3 and earlier Guest Additions this 123 * function creates the heap structures directly in guest video RAM, so it 124 * needs to be called whenever video RAM is (re-)set-up. 125 */ 126 void vbvxSetUpHGSMIHeapInGuest(VBOXPtr pVBox, uint32_t cbVRAM) 127 { 128 int rc; 129 uint32_t offVRAMBaseMapping, offGuestHeapMemory, cbGuestHeapMemory; 130 void *pvGuestHeapMemory; 131 132 VBoxHGSMIGetBaseMappingInfo(cbVRAM, &offVRAMBaseMapping, NULL, &offGuestHeapMemory, &cbGuestHeapMemory, NULL); 133 pvGuestHeapMemory = ((uint8_t *)pVBox->base) + offVRAMBaseMapping + offGuestHeapMemory; 134 rc = VBoxHGSMISetupGuestContext(&pVBox->guestCtx, pvGuestHeapMemory, cbGuestHeapMemory, 135 offVRAMBaseMapping + offGuestHeapMemory, &g_hgsmiEnv); 136 VBVXASSERT(RT_SUCCESS(rc), ("Failed to set up the guest-to-host message buffer heap, rc=%d\n", rc)); 137 pVBox->cbView = offVRAMBaseMapping; 138 } 139 101 140 /** Callback to fill in the view structures */ 102 141 static int … … 120 159 * @returns TRUE on success, FALSE on failure 121 160 */ 122 static Bool 123 vboxInitVbva(int scrnIndex, ScreenPtr pScreen, VBOXPtr pVBox) 124 { 125 ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; 161 static Bool vboxSetupVRAMVbva(VBOXPtr pVBox) 162 { 126 163 int rc = VINF_SUCCESS; 127 128 /* Why is this here? In case things break before we have found the real 129 * count? */ 130 pVBox->cScreens = 1; 131 if (!VBoxHGSMIIsSupported()) 132 { 133 xf86DrvMsg(scrnIndex, X_ERROR, "The graphics device does not seem to support HGSMI. Disableing video acceleration.\n"); 134 return FALSE; 135 } 136 return TRUE; 137 } 138 139 static DECLCALLBACK(void *) hgsmiEnvAlloc(void *pvEnv, HGSMISIZE cb) 140 { 141 NOREF(pvEnv); 142 return calloc(1, cb); 143 } 144 145 static DECLCALLBACK(void) hgsmiEnvFree(void *pvEnv, void *pv) 146 { 147 NOREF(pvEnv); 148 free(pv); 149 } 150 151 static HGSMIENV g_hgsmiEnv = 152 { 153 NULL, 154 hgsmiEnvAlloc, 155 hgsmiEnvFree 156 }; 157 158 /** 159 * Initialise VirtualBox's accelerated video extensions. 160 * 161 * @returns TRUE on success, FALSE on failure 162 */ 163 static Bool 164 vboxSetupVRAMVbva(ScrnInfoPtr pScrn, VBOXPtr pVBox) 165 { 166 int rc = VINF_SUCCESS; 167 unsigned i; 168 uint32_t offVRAMBaseMapping, offGuestHeapMemory, cbGuestHeapMemory; 169 void *pvGuestHeapMemory; 170 171 VBoxHGSMIGetBaseMappingInfo(pScrn->videoRam * 1024, &offVRAMBaseMapping, 172 NULL, &offGuestHeapMemory, &cbGuestHeapMemory, 173 NULL); 174 pvGuestHeapMemory = ((uint8_t *)pVBox->base) + offVRAMBaseMapping 175 + offGuestHeapMemory; 176 TRACE_LOG("video RAM: %u KB, guest heap offset: 0x%x, cbGuestHeapMemory: %u\n", 177 pScrn->videoRam, offVRAMBaseMapping + offGuestHeapMemory, 178 cbGuestHeapMemory); 179 rc = VBoxHGSMISetupGuestContext(&pVBox->guestCtx, pvGuestHeapMemory, 180 cbGuestHeapMemory, 181 offVRAMBaseMapping + offGuestHeapMemory, 182 &g_hgsmiEnv); 183 if (RT_FAILURE(rc)) 184 { 185 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to set up the guest-to-host communication context, rc=%d\n", rc); 186 return FALSE; 187 } 188 pVBox->cbView = pVBox->cbFBMax = offVRAMBaseMapping; 189 pVBox->cScreens = VBoxHGSMIGetMonitorCount(&pVBox->guestCtx); 190 pVBox->pScreens = calloc(pVBox->cScreens, sizeof(*pVBox->pScreens)); 191 if (pVBox->pScreens == NULL) 192 FatalError("Failed to allocate memory for screens array.\n"); 193 #ifdef VBOXVIDEO_13 194 pVBox->paVBVAModeHints = calloc(pVBox->cScreens, 195 sizeof(*pVBox->paVBVAModeHints)); 196 if (pVBox->paVBVAModeHints == NULL) 197 FatalError("Failed to allocate memory for mode hints array.\n"); 198 #endif 199 xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Requested monitor count: %u\n", 200 pVBox->cScreens); 164 unsigned i; 165 166 pVBox->cbFBMax = pVBox->cbView; 201 167 for (i = 0; i < pVBox->cScreens; ++i) 202 168 { … … 214 180 rc = VBoxHGSMISendViewInfo(&pVBox->guestCtx, pVBox->cScreens, 215 181 vboxFillViewInfo, (void *)pVBox); 216 if (RT_FAILURE(rc)) 217 { 218 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to send the view information to the host, rc=%d\n", rc); 219 return FALSE; 220 } 182 VBVXASSERT(RT_SUCCESS(rc), ("Failed to send the view information to the host, rc=%d\n", rc)); 221 183 return TRUE; 222 }223 224 void225 vbox_open(ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox)226 {227 TRACE_ENTRY();228 229 if (!vboxInitVbva(pScrn->scrnIndex, pScreen, pVBox))230 FatalError("failed to initialise vboxvideo graphics acceleration.\n");231 184 } 232 185 … … 242 195 { 243 196 bool rc = TRUE; 244 int scrnIndex = pScrn->scrnIndex;245 197 unsigned i; 246 198 VBOXPtr pVBox = pScrn->driverPrivate; 247 199 248 200 TRACE_ENTRY(); 249 if (!vboxSetupVRAMVbva(p Scrn, pVBox))201 if (!vboxSetupVRAMVbva(pVBox)) 250 202 return FALSE; 251 203 for (i = 0; i < pVBox->cScreens; ++i) … … 259 211 rc = FALSE; 260 212 } 261 if (!rc) 262 { 263 /* Request not accepted - disable for old hosts. */ 264 xf86DrvMsg(scrnIndex, X_ERROR, 265 "Failed to enable screen update reporting for at least one virtual monitor.\n"); 266 vboxDisableVbva(pScrn); 267 } 213 VBVXASSERT(rc, ("Failed to enable screen update reporting for at least one virtual monitor.\n")); 268 214 #ifdef VBOXVIDEO_13 269 215 # ifdef RT_OS_LINUX … … 289 235 { 290 236 int rc; 291 int scrnIndex = pScrn->scrnIndex;292 237 unsigned i; 293 238 VBOXPtr pVBox = pScrn->driverPrivate;
Note:
See TracChangeset
for help on using the changeset viewer.