VirtualBox

source: vbox/trunk/src/VBox/Main/DisplayImpl.cpp@ 26173

Last change on this file since 26173 was 26173, checked in by vboxsync, 15 years ago

PDM: s/pCfgHandle/pCfg/g - part 2.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 109.9 KB
Line 
1/* $Id: DisplayImpl.cpp 26173 2010-02-02 21:11:09Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include "DisplayImpl.h"
23#include "ConsoleImpl.h"
24#include "ConsoleVRDPServer.h"
25#include "VMMDev.h"
26
27#include "AutoCaller.h"
28#include "Logging.h"
29
30#include <iprt/semaphore.h>
31#include <iprt/thread.h>
32#include <iprt/asm.h>
33
34#include <VBox/pdmdrv.h>
35#ifdef DEBUG /* for VM_ASSERT_EMT(). */
36# include <VBox/vm.h>
37#endif
38
39#ifdef VBOX_WITH_VIDEOHWACCEL
40# include <VBox/VBoxVideo.h>
41#endif
42
43#include <VBox/com/array.h>
44#include <png.h>
45
46/**
47 * Display driver instance data.
48 *
49 * @implements PDMIDISPLAYCONNECTOR
50 */
51typedef struct DRVMAINDISPLAY
52{
53 /** Pointer to the display object. */
54 Display *pDisplay;
55 /** Pointer to the driver instance structure. */
56 PPDMDRVINS pDrvIns;
57 /** Pointer to the keyboard port interface of the driver/device above us. */
58 PPDMIDISPLAYPORT pUpPort;
59 /** Our display connector interface. */
60 PDMIDISPLAYCONNECTOR IConnector;
61#if defined(VBOX_WITH_VIDEOHWACCEL)
62 /** VBVA callbacks */
63 PPDMIDISPLAYVBVACALLBACKS pVBVACallbacks;
64#endif
65} DRVMAINDISPLAY, *PDRVMAINDISPLAY;
66
67/** Converts PDMIDISPLAYCONNECTOR pointer to a DRVMAINDISPLAY pointer. */
68#define PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface) RT_FROM_MEMBER(pInterface, DRVMAINDISPLAY, IConnector)
69
70#ifdef DEBUG_sunlover
71static STAMPROFILE StatDisplayRefresh;
72static int stam = 0;
73#endif /* DEBUG_sunlover */
74
75// constructor / destructor
76/////////////////////////////////////////////////////////////////////////////
77
78DEFINE_EMPTY_CTOR_DTOR(Display)
79
80HRESULT Display::FinalConstruct()
81{
82 mpVbvaMemory = NULL;
83 mfVideoAccelEnabled = false;
84 mfVideoAccelVRDP = false;
85 mfu32SupportedOrders = 0;
86 mcVideoAccelVRDPRefs = 0;
87
88 mpPendingVbvaMemory = NULL;
89 mfPendingVideoAccelEnable = false;
90
91 mfMachineRunning = false;
92
93 mpu8VbvaPartial = NULL;
94 mcbVbvaPartial = 0;
95
96 mpDrv = NULL;
97 mpVMMDev = NULL;
98 mfVMMDevInited = false;
99
100 mLastAddress = NULL;
101 mLastBytesPerLine = 0;
102 mLastBitsPerPixel = 0,
103 mLastWidth = 0;
104 mLastHeight = 0;
105
106#ifdef VBOX_WITH_OLD_VBVA_LOCK
107 int rc = RTCritSectInit (&mVBVALock);
108 AssertRC (rc);
109 mfu32PendingVideoAccelDisable = false;
110#endif /* VBOX_WITH_OLD_VBVA_LOCK */
111
112#ifdef VBOX_WITH_HGSMI
113 mu32UpdateVBVAFlags = 0;
114#endif
115
116 return S_OK;
117}
118
119void Display::FinalRelease()
120{
121 uninit();
122
123#ifdef VBOX_WITH_OLD_VBVA_LOCK
124 if (RTCritSectIsInitialized (&mVBVALock))
125 {
126 RTCritSectDelete (&mVBVALock);
127 memset (&mVBVALock, 0, sizeof (mVBVALock));
128 }
129#endif /* VBOX_WITH_OLD_VBVA_LOCK */
130}
131
132// public initializer/uninitializer for internal purposes only
133/////////////////////////////////////////////////////////////////////////////
134
135#define sSSMDisplayScreenshotVer 0x00010001
136#define sSSMDisplayVer 0x00010001
137
138#define kMaxSizePNG 1024
139#define kMaxSizeThumbnail 64
140
141/**
142 * Save thumbnail and screenshot of the guest screen.
143 */
144static int displayMakeThumbnail(uint8_t *pu8Data, uint32_t cx, uint32_t cy,
145 uint8_t **ppu8Thumbnail, uint32_t *pcbThumbnail, uint32_t *pcxThumbnail, uint32_t *pcyThumbnail)
146{
147 int rc = VINF_SUCCESS;
148
149 uint8_t *pu8Thumbnail = NULL;
150 uint32_t cbThumbnail = 0;
151 uint32_t cxThumbnail = 0;
152 uint32_t cyThumbnail = 0;
153
154 if (cx > cy)
155 {
156 cxThumbnail = kMaxSizeThumbnail;
157 cyThumbnail = (kMaxSizeThumbnail * cy) / cx;
158 }
159 else
160 {
161 cyThumbnail = kMaxSizeThumbnail;
162 cxThumbnail = (kMaxSizeThumbnail * cx) / cy;
163 }
164
165 LogFlowFunc(("%dx%d -> %dx%d\n", cx, cy, cxThumbnail, cyThumbnail));
166
167 cbThumbnail = cxThumbnail * 4 * cyThumbnail;
168 pu8Thumbnail = (uint8_t *)RTMemAlloc(cbThumbnail);
169
170 if (pu8Thumbnail)
171 {
172 uint8_t *dst = pu8Thumbnail;
173 uint8_t *src = pu8Data;
174 int dstX = 0;
175 int dstY = 0;
176 int srcX = 0;
177 int srcY = 0;
178 int dstW = cxThumbnail;
179 int dstH = cyThumbnail;
180 int srcW = cx;
181 int srcH = cy;
182 gdImageCopyResampled (dst,
183 src,
184 dstX, dstY,
185 srcX, srcY,
186 dstW, dstH, srcW, srcH);
187
188 *ppu8Thumbnail = pu8Thumbnail;
189 *pcbThumbnail = cbThumbnail;
190 *pcxThumbnail = cxThumbnail;
191 *pcyThumbnail = cyThumbnail;
192 }
193 else
194 {
195 rc = VERR_NO_MEMORY;
196 }
197
198 return rc;
199}
200
201typedef struct PNGWriteCtx
202{
203 uint8_t *pu8PNG;
204 uint32_t cbPNG;
205 uint32_t cbAllocated;
206 int rc;
207} PNGWriteCtx;
208
209static void PNGAPI png_write_data_fn(png_structp png_ptr, png_bytep p, png_size_t cb)
210{
211 PNGWriteCtx *pCtx = (PNGWriteCtx *)png_get_io_ptr(png_ptr);
212 LogFlowFunc(("png_ptr %p, p %p, cb %d, pCtx %p\n", png_ptr, p, cb, pCtx));
213
214 if (pCtx && RT_SUCCESS(pCtx->rc))
215 {
216 if (pCtx->cbAllocated - pCtx->cbPNG < cb)
217 {
218 uint32_t cbNew = pCtx->cbPNG + (uint32_t)cb;
219 AssertReturnVoidStmt(cbNew > pCtx->cbPNG && cbNew <= _1G, pCtx->rc = VERR_TOO_MUCH_DATA);
220 cbNew = RT_ALIGN_32(cbNew, 4096) + 4096;
221
222 void *pNew = RTMemRealloc(pCtx->pu8PNG, cbNew);
223 if (!pNew)
224 {
225 pCtx->rc = VERR_NO_MEMORY;
226 return;
227 }
228
229 pCtx->pu8PNG = (uint8_t *)pNew;
230 pCtx->cbAllocated = cbNew;
231 }
232
233 memcpy(pCtx->pu8PNG + pCtx->cbPNG, p, cb);
234 pCtx->cbPNG += (uint32_t)cb;
235 }
236}
237
238static void PNGAPI png_output_flush_fn(png_structp png_ptr)
239{
240 NOREF(png_ptr);
241 /* Do nothing. */
242}
243
244static int displayMakePNG(uint8_t *pu8Data, uint32_t cx, uint32_t cy,
245 uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG)
246{
247 int rc = VINF_SUCCESS;
248
249 uint8_t * volatile pu8Bitmap = NULL; /* gcc setjmp warning */
250 uint32_t volatile cbBitmap = 0; /* gcc setjmp warning */
251 uint32_t volatile cxBitmap = 0; /* gcc setjmp warning */
252 uint32_t volatile cyBitmap = 0; /* gcc setjmp warning */
253
254 if (cx < kMaxSizePNG && cy < kMaxSizePNG)
255 {
256 /* Save unscaled screenshot. */
257 pu8Bitmap = pu8Data;
258 cbBitmap = cx * 4 * cy;
259 cxBitmap = cx;
260 cyBitmap = cy;
261 }
262 else
263 {
264 /* Large screenshot, scale. */
265 if (cx > cy)
266 {
267 cxBitmap = kMaxSizePNG;
268 cyBitmap = (kMaxSizePNG * cy) / cx;
269 }
270 else
271 {
272 cyBitmap = kMaxSizePNG;
273 cxBitmap = (kMaxSizePNG * cx) / cy;
274 }
275
276 cbBitmap = cxBitmap * 4 * cyBitmap;
277
278 pu8Bitmap = (uint8_t *)RTMemAlloc(cbBitmap);
279
280 if (pu8Bitmap)
281 {
282 uint8_t *dst = pu8Bitmap;
283 uint8_t *src = pu8Data;
284 int dstX = 0;
285 int dstY = 0;
286 int srcX = 0;
287 int srcY = 0;
288 int dstW = cxBitmap;
289 int dstH = cyBitmap;
290 int srcW = cx;
291 int srcH = cy;
292 gdImageCopyResampled (dst,
293 src,
294 dstX, dstY,
295 srcX, srcY,
296 dstW, dstH, srcW, srcH);
297 }
298 else
299 {
300 rc = VERR_NO_MEMORY;
301 }
302 }
303
304 LogFlowFunc(("%dx%d -> %dx%d\n", cx, cy, cxBitmap, cyBitmap));
305
306 if (RT_SUCCESS(rc))
307 {
308 png_bytep *row_pointers = (png_bytep *)RTMemAlloc(cyBitmap * sizeof(png_bytep));
309 if (row_pointers)
310 {
311 png_infop info_ptr = NULL;
312 png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
313 (png_voidp)NULL, /* error/warning context pointer */
314 (png_error_ptr)NULL, /* error function */
315 (png_error_ptr)NULL /* warning function */);
316 if (png_ptr)
317 {
318 info_ptr = png_create_info_struct(png_ptr);
319 if (info_ptr)
320 {
321 if (!setjmp(png_jmpbuf(png_ptr)))
322 {
323 PNGWriteCtx ctx;
324 ctx.pu8PNG = NULL;
325 ctx.cbPNG = 0;
326 ctx.cbAllocated = 0;
327 ctx.rc = VINF_SUCCESS;
328
329 png_set_write_fn(png_ptr,
330 (voidp)&ctx,
331 png_write_data_fn,
332 png_output_flush_fn);
333
334 png_set_IHDR(png_ptr, info_ptr,
335 cxBitmap, cyBitmap,
336 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
337 PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
338
339 png_bytep row_pointer = (png_bytep)pu8Bitmap;
340 unsigned i = 0;
341 for (; i < cyBitmap; i++, row_pointer += cxBitmap * 4)
342 {
343 row_pointers[i] = row_pointer;
344 }
345 png_set_rows(png_ptr, info_ptr, &row_pointers[0]);
346
347 png_write_info(png_ptr, info_ptr);
348 png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
349 png_set_bgr(png_ptr);
350
351 if (info_ptr->valid & PNG_INFO_IDAT)
352 png_write_image(png_ptr, info_ptr->row_pointers);
353
354 png_write_end(png_ptr, info_ptr);
355
356 rc = ctx.rc;
357
358 if (RT_SUCCESS(rc))
359 {
360 *ppu8PNG = ctx.pu8PNG;
361 *pcbPNG = ctx.cbPNG;
362 *pcxPNG = cxBitmap;
363 *pcyPNG = cyBitmap;
364 LogFlowFunc(("PNG %d bytes, bitmap %d bytes\n", ctx.cbPNG, cbBitmap));
365 }
366 }
367 else
368 {
369 rc = VERR_GENERAL_FAILURE; /* Something within libpng. */
370 }
371 }
372 else
373 {
374 rc = VERR_NO_MEMORY;
375 }
376
377 png_destroy_write_struct(&png_ptr, info_ptr ? &info_ptr
378 : (png_infopp)NULL);
379 }
380 else
381 {
382 rc = VERR_NO_MEMORY;
383 }
384
385 RTMemFree(row_pointers);
386 }
387 else
388 {
389 rc = VERR_NO_MEMORY;
390 }
391 }
392
393 if (pu8Bitmap && pu8Bitmap != pu8Data)
394 {
395 RTMemFree(pu8Bitmap);
396 }
397
398 return rc;
399
400}
401
402DECLCALLBACK(void)
403Display::displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser)
404{
405 Display *that = static_cast<Display*>(pvUser);
406
407 /* 32bpp small RGB image. */
408 uint8_t *pu8Thumbnail = NULL;
409 uint32_t cbThumbnail = 0;
410 uint32_t cxThumbnail = 0;
411 uint32_t cyThumbnail = 0;
412
413 /* PNG screenshot. */
414 uint8_t *pu8PNG = NULL;
415 uint32_t cbPNG = 0;
416 uint32_t cxPNG = 0;
417 uint32_t cyPNG = 0;
418
419 Console::SafeVMPtr pVM (that->mParent);
420 if (SUCCEEDED(pVM.rc()))
421 {
422 /* Query RGB bitmap. */
423 uint8_t *pu8Data = NULL;
424 size_t cbData = 0;
425 uint32_t cx = 0;
426 uint32_t cy = 0;
427
428 /* SSM code is executed on EMT(0), therefore no need to use VMR3ReqCallWait. */
429#ifdef VBOX_WITH_OLD_VBVA_LOCK
430 int rc = Display::displayTakeScreenshotEMT(that, &pu8Data, &cbData, &cx, &cy);
431#else
432 int rc = that->mpDrv->pUpPort->pfnTakeScreenshot (that->mpDrv->pUpPort, &pu8Data, &cbData, &cx, &cy);
433#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
434
435 if (RT_SUCCESS(rc))
436 {
437 /* Prepare a small thumbnail and a PNG screenshot. */
438 displayMakeThumbnail(pu8Data, cx, cy, &pu8Thumbnail, &cbThumbnail, &cxThumbnail, &cyThumbnail);
439 displayMakePNG(pu8Data, cx, cy, &pu8PNG, &cbPNG, &cxPNG, &cyPNG);
440
441 /* This can be called from any thread. */
442 that->mpDrv->pUpPort->pfnFreeScreenshot (that->mpDrv->pUpPort, pu8Data);
443 }
444 }
445 else
446 {
447 LogFunc(("Failed to get VM pointer 0x%x\n", pVM.rc()));
448 }
449
450 /* Regardless of rc, save what is available:
451 * Data format:
452 * uint32_t cBlocks;
453 * [blocks]
454 *
455 * Each block is:
456 * uint32_t cbBlock; if 0 - no 'block data'.
457 * uint32_t typeOfBlock; 0 - 32bpp RGB bitmap, 1 - PNG, ignored if 'cbBlock' is 0.
458 * [block data]
459 *
460 * Block data for bitmap and PNG:
461 * uint32_t cx;
462 * uint32_t cy;
463 * [image data]
464 */
465 SSMR3PutU32(pSSM, 2); /* Write thumbnail and PNG screenshot. */
466
467 /* First block. */
468 SSMR3PutU32(pSSM, cbThumbnail + 2 * sizeof (uint32_t));
469 SSMR3PutU32(pSSM, 0); /* Block type: thumbnail. */
470
471 if (cbThumbnail)
472 {
473 SSMR3PutU32(pSSM, cxThumbnail);
474 SSMR3PutU32(pSSM, cyThumbnail);
475 SSMR3PutMem(pSSM, pu8Thumbnail, cbThumbnail);
476 }
477
478 /* Second block. */
479 SSMR3PutU32(pSSM, cbPNG + 2 * sizeof (uint32_t));
480 SSMR3PutU32(pSSM, 1); /* Block type: png. */
481
482 if (cbPNG)
483 {
484 SSMR3PutU32(pSSM, cxPNG);
485 SSMR3PutU32(pSSM, cyPNG);
486 SSMR3PutMem(pSSM, pu8PNG, cbPNG);
487 }
488
489 RTMemFree(pu8PNG);
490 RTMemFree(pu8Thumbnail);
491}
492
493DECLCALLBACK(int)
494Display::displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
495{
496 Display *that = static_cast<Display*>(pvUser);
497
498 if (uVersion != sSSMDisplayScreenshotVer)
499 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
500 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
501
502 /* Skip data. */
503 uint32_t cBlocks;
504 int rc = SSMR3GetU32(pSSM, &cBlocks);
505 AssertRCReturn(rc, rc);
506
507 for (uint32_t i = 0; i < cBlocks; i++)
508 {
509 uint32_t cbBlock;
510 rc = SSMR3GetU32(pSSM, &cbBlock);
511 AssertRCBreak(rc);
512
513 uint32_t typeOfBlock;
514 rc = SSMR3GetU32(pSSM, &typeOfBlock);
515 AssertRCBreak(rc);
516
517 LogFlowFunc(("[%d] type %d, size %d bytes\n", i, typeOfBlock, cbBlock));
518
519 if (cbBlock != 0)
520 {
521 rc = SSMR3Skip(pSSM, cbBlock);
522 AssertRCBreak(rc);
523 }
524 }
525
526 return rc;
527}
528
529/**
530 * Save/Load some important guest state
531 */
532DECLCALLBACK(void)
533Display::displaySSMSave(PSSMHANDLE pSSM, void *pvUser)
534{
535 Display *that = static_cast<Display*>(pvUser);
536
537 SSMR3PutU32(pSSM, that->mcMonitors);
538 for (unsigned i = 0; i < that->mcMonitors; i++)
539 {
540 SSMR3PutU32(pSSM, that->maFramebuffers[i].u32Offset);
541 SSMR3PutU32(pSSM, that->maFramebuffers[i].u32MaxFramebufferSize);
542 SSMR3PutU32(pSSM, that->maFramebuffers[i].u32InformationSize);
543 }
544}
545
546DECLCALLBACK(int)
547Display::displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
548{
549 Display *that = static_cast<Display*>(pvUser);
550
551 if (uVersion != sSSMDisplayVer)
552 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
553 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
554
555 uint32_t cMonitors;
556 int rc = SSMR3GetU32(pSSM, &cMonitors);
557 if (cMonitors != that->mcMonitors)
558 return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Number of monitors changed (%d->%d)!"), cMonitors, that->mcMonitors);
559
560 for (uint32_t i = 0; i < cMonitors; i++)
561 {
562 SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32Offset);
563 SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32MaxFramebufferSize);
564 SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32InformationSize);
565 }
566
567 return VINF_SUCCESS;
568}
569
570/**
571 * Initializes the display object.
572 *
573 * @returns COM result indicator
574 * @param parent handle of our parent object
575 * @param qemuConsoleData address of common console data structure
576 */
577HRESULT Display::init (Console *aParent)
578{
579 LogFlowThisFunc(("aParent=%p\n", aParent));
580
581 ComAssertRet (aParent, E_INVALIDARG);
582
583 /* Enclose the state transition NotReady->InInit->Ready */
584 AutoInitSpan autoInitSpan(this);
585 AssertReturn(autoInitSpan.isOk(), E_FAIL);
586
587 unconst(mParent) = aParent;
588
589 // by default, we have an internal framebuffer which is
590 // NULL, i.e. a black hole for no display output
591 mFramebufferOpened = false;
592
593 ULONG ul;
594 mParent->machine()->COMGETTER(MonitorCount)(&ul);
595 mcMonitors = ul;
596
597 for (ul = 0; ul < mcMonitors; ul++)
598 {
599 maFramebuffers[ul].u32Offset = 0;
600 maFramebuffers[ul].u32MaxFramebufferSize = 0;
601 maFramebuffers[ul].u32InformationSize = 0;
602
603 maFramebuffers[ul].pFramebuffer = NULL;
604
605 maFramebuffers[ul].xOrigin = 0;
606 maFramebuffers[ul].yOrigin = 0;
607
608 maFramebuffers[ul].w = 0;
609 maFramebuffers[ul].h = 0;
610
611 maFramebuffers[ul].pHostEvents = NULL;
612
613 maFramebuffers[ul].u32ResizeStatus = ResizeStatus_Void;
614
615 maFramebuffers[ul].fDefaultFormat = false;
616
617 memset (&maFramebuffers[ul].dirtyRect, 0 , sizeof (maFramebuffers[ul].dirtyRect));
618 memset (&maFramebuffers[ul].pendingResize, 0 , sizeof (maFramebuffers[ul].pendingResize));
619#ifdef VBOX_WITH_HGSMI
620 maFramebuffers[ul].fVBVAEnabled = false;
621 maFramebuffers[ul].cVBVASkipUpdate = 0;
622 memset (&maFramebuffers[ul].vbvaSkippedRect, 0, sizeof (maFramebuffers[ul].vbvaSkippedRect));
623 maFramebuffers[ul].pVBVAHostFlags = NULL;
624#endif /* VBOX_WITH_HGSMI */
625 }
626
627 mParent->RegisterCallback (this);
628
629 /* Confirm a successful initialization */
630 autoInitSpan.setSucceeded();
631
632 return S_OK;
633}
634
635/**
636 * Uninitializes the instance and sets the ready flag to FALSE.
637 * Called either from FinalRelease() or by the parent when it gets destroyed.
638 */
639void Display::uninit()
640{
641 LogFlowThisFunc(("\n"));
642
643 /* Enclose the state transition Ready->InUninit->NotReady */
644 AutoUninitSpan autoUninitSpan(this);
645 if (autoUninitSpan.uninitDone())
646 return;
647
648 ULONG ul;
649 for (ul = 0; ul < mcMonitors; ul++)
650 maFramebuffers[ul].pFramebuffer = NULL;
651
652 if (mParent)
653 mParent->UnregisterCallback (this);
654
655 unconst(mParent).setNull();
656
657 if (mpDrv)
658 mpDrv->pDisplay = NULL;
659
660 mpDrv = NULL;
661 mpVMMDev = NULL;
662 mfVMMDevInited = true;
663}
664
665/**
666 * Register the SSM methods. Called by the power up thread to be able to
667 * pass pVM
668 */
669int Display::registerSSM(PVM pVM)
670{
671 int rc = SSMR3RegisterExternal(pVM, "DisplayData", 0, sSSMDisplayVer,
672 mcMonitors * sizeof(uint32_t) * 3 + sizeof(uint32_t),
673 NULL, NULL, NULL,
674 NULL, displaySSMSave, NULL,
675 NULL, displaySSMLoad, NULL, this);
676
677 AssertRCReturn(rc, rc);
678
679 /*
680 * Register loaders for old saved states where iInstance was 3 * sizeof(uint32_t *).
681 */
682 rc = SSMR3RegisterExternal(pVM, "DisplayData", 12 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
683 NULL, NULL, NULL,
684 NULL, NULL, NULL,
685 NULL, displaySSMLoad, NULL, this);
686 AssertRCReturn(rc, rc);
687
688 rc = SSMR3RegisterExternal(pVM, "DisplayData", 24 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
689 NULL, NULL, NULL,
690 NULL, NULL, NULL,
691 NULL, displaySSMLoad, NULL, this);
692 AssertRCReturn(rc, rc);
693
694 /* uInstance is an arbitrary value greater than 1024. Such a value will ensure a quick seek in saved state file. */
695 rc = SSMR3RegisterExternal(pVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
696 NULL, NULL, NULL,
697 NULL, displaySSMSaveScreenshot, NULL,
698 NULL, displaySSMLoadScreenshot, NULL, this);
699
700 AssertRCReturn(rc, rc);
701
702 return VINF_SUCCESS;
703}
704
705// IConsoleCallback method
706STDMETHODIMP Display::OnStateChange(MachineState_T machineState)
707{
708 if ( machineState == MachineState_Running
709 || machineState == MachineState_Teleporting
710 || machineState == MachineState_LiveSnapshotting
711 )
712 {
713 LogFlowFunc(("Machine is running.\n"));
714
715 mfMachineRunning = true;
716 }
717 else
718 mfMachineRunning = false;
719
720 return S_OK;
721}
722
723// public methods only for internal purposes
724/////////////////////////////////////////////////////////////////////////////
725
726/**
727 * @thread EMT
728 */
729static int callFramebufferResize (IFramebuffer *pFramebuffer, unsigned uScreenId,
730 ULONG pixelFormat, void *pvVRAM,
731 uint32_t bpp, uint32_t cbLine,
732 int w, int h)
733{
734 Assert (pFramebuffer);
735
736 /* Call the framebuffer to try and set required pixelFormat. */
737 BOOL finished = TRUE;
738
739 pFramebuffer->RequestResize (uScreenId, pixelFormat, (BYTE *) pvVRAM,
740 bpp, cbLine, w, h, &finished);
741
742 if (!finished)
743 {
744 LogFlowFunc (("External framebuffer wants us to wait!\n"));
745 return VINF_VGA_RESIZE_IN_PROGRESS;
746 }
747
748 return VINF_SUCCESS;
749}
750
751/**
752 * Handles display resize event.
753 * Disables access to VGA device;
754 * calls the framebuffer RequestResize method;
755 * if framebuffer resizes synchronously,
756 * updates the display connector data and enables access to the VGA device.
757 *
758 * @param w New display width
759 * @param h New display height
760 *
761 * @thread EMT
762 */
763int Display::handleDisplayResize (unsigned uScreenId, uint32_t bpp, void *pvVRAM,
764 uint32_t cbLine, int w, int h)
765{
766 LogRel (("Display::handleDisplayResize(): uScreenId = %d, pvVRAM=%p "
767 "w=%d h=%d bpp=%d cbLine=0x%X\n",
768 uScreenId, pvVRAM, w, h, bpp, cbLine));
769
770 /* If there is no framebuffer, this call is not interesting. */
771 if ( uScreenId >= mcMonitors
772 || maFramebuffers[uScreenId].pFramebuffer.isNull())
773 {
774 return VINF_SUCCESS;
775 }
776
777 mLastAddress = pvVRAM;
778 mLastBytesPerLine = cbLine;
779 mLastBitsPerPixel = bpp,
780 mLastWidth = w;
781 mLastHeight = h;
782
783 ULONG pixelFormat;
784
785 switch (bpp)
786 {
787 case 32:
788 case 24:
789 case 16:
790 pixelFormat = FramebufferPixelFormat_FOURCC_RGB;
791 break;
792 default:
793 pixelFormat = FramebufferPixelFormat_Opaque;
794 bpp = cbLine = 0;
795 break;
796 }
797
798 /* Atomically set the resize status before calling the framebuffer. The new InProgress status will
799 * disable access to the VGA device by the EMT thread.
800 */
801 bool f = ASMAtomicCmpXchgU32 (&maFramebuffers[uScreenId].u32ResizeStatus,
802 ResizeStatus_InProgress, ResizeStatus_Void);
803 if (!f)
804 {
805 /* This could be a result of the screenshot taking call Display::TakeScreenShot:
806 * if the framebuffer is processing the resize request and GUI calls the TakeScreenShot
807 * and the guest has reprogrammed the virtual VGA devices again so a new resize is required.
808 *
809 * Save the resize information and return the pending status code.
810 *
811 * Note: the resize information is only accessed on EMT so no serialization is required.
812 */
813 LogRel (("Display::handleDisplayResize(): Warning: resize postponed.\n"));
814
815 maFramebuffers[uScreenId].pendingResize.fPending = true;
816 maFramebuffers[uScreenId].pendingResize.pixelFormat = pixelFormat;
817 maFramebuffers[uScreenId].pendingResize.pvVRAM = pvVRAM;
818 maFramebuffers[uScreenId].pendingResize.bpp = bpp;
819 maFramebuffers[uScreenId].pendingResize.cbLine = cbLine;
820 maFramebuffers[uScreenId].pendingResize.w = w;
821 maFramebuffers[uScreenId].pendingResize.h = h;
822
823 return VINF_VGA_RESIZE_IN_PROGRESS;
824 }
825
826 int rc = callFramebufferResize (maFramebuffers[uScreenId].pFramebuffer, uScreenId,
827 pixelFormat, pvVRAM, bpp, cbLine, w, h);
828 if (rc == VINF_VGA_RESIZE_IN_PROGRESS)
829 {
830 /* Immediately return to the caller. ResizeCompleted will be called back by the
831 * GUI thread. The ResizeCompleted callback will change the resize status from
832 * InProgress to UpdateDisplayData. The latter status will be checked by the
833 * display timer callback on EMT and all required adjustments will be done there.
834 */
835 return rc;
836 }
837
838 /* Set the status so the 'handleResizeCompleted' would work. */
839 f = ASMAtomicCmpXchgU32 (&maFramebuffers[uScreenId].u32ResizeStatus,
840 ResizeStatus_UpdateDisplayData, ResizeStatus_InProgress);
841 AssertRelease(f);NOREF(f);
842
843 AssertRelease(!maFramebuffers[uScreenId].pendingResize.fPending);
844
845 /* The method also unlocks the framebuffer. */
846 handleResizeCompletedEMT();
847
848 return VINF_SUCCESS;
849}
850
851/**
852 * Framebuffer has been resized.
853 * Read the new display data and unlock the framebuffer.
854 *
855 * @thread EMT
856 */
857void Display::handleResizeCompletedEMT (void)
858{
859 LogFlowFunc(("\n"));
860
861 unsigned uScreenId;
862 for (uScreenId = 0; uScreenId < mcMonitors; uScreenId++)
863 {
864 DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId];
865
866 /* Try to into non resizing state. */
867 bool f = ASMAtomicCmpXchgU32 (&pFBInfo->u32ResizeStatus, ResizeStatus_Void, ResizeStatus_UpdateDisplayData);
868
869 if (f == false)
870 {
871 /* This is not the display that has completed resizing. */
872 continue;
873 }
874
875 /* Check whether a resize is pending for this framebuffer. */
876 if (pFBInfo->pendingResize.fPending)
877 {
878 /* Reset the condition, call the display resize with saved data and continue.
879 *
880 * Note: handleDisplayResize can call handleResizeCompletedEMT back,
881 * but infinite recursion is not possible, because when the handleResizeCompletedEMT
882 * is called, the pFBInfo->pendingResize.fPending is equal to false.
883 */
884 pFBInfo->pendingResize.fPending = false;
885 handleDisplayResize (uScreenId, pFBInfo->pendingResize.bpp, pFBInfo->pendingResize.pvVRAM,
886 pFBInfo->pendingResize.cbLine, pFBInfo->pendingResize.w, pFBInfo->pendingResize.h);
887 continue;
888 }
889
890 if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN && !pFBInfo->pFramebuffer.isNull())
891 {
892 /* Primary framebuffer has completed the resize. Update the connector data for VGA device. */
893 updateDisplayData();
894
895 /* Check the framebuffer pixel format to setup the rendering in VGA device. */
896 BOOL usesGuestVRAM = FALSE;
897 pFBInfo->pFramebuffer->COMGETTER(UsesGuestVRAM) (&usesGuestVRAM);
898
899 pFBInfo->fDefaultFormat = (usesGuestVRAM == FALSE);
900
901 mpDrv->pUpPort->pfnSetRenderVRAM (mpDrv->pUpPort, pFBInfo->fDefaultFormat);
902 }
903
904#ifdef DEBUG_sunlover
905 if (!stam)
906 {
907 /* protect mpVM */
908 Console::SafeVMPtr pVM (mParent);
909 AssertComRC (pVM.rc());
910
911 STAM_REG(pVM, &StatDisplayRefresh, STAMTYPE_PROFILE, "/PROF/Display/Refresh", STAMUNIT_TICKS_PER_CALL, "Time spent in EMT for display updates.");
912 stam = 1;
913 }
914#endif /* DEBUG_sunlover */
915
916 /* Inform VRDP server about the change of display parameters. */
917 LogFlowFunc (("Calling VRDP\n"));
918 mParent->consoleVRDPServer()->SendResize();
919 }
920}
921
922static void checkCoordBounds (int *px, int *py, int *pw, int *ph, int cx, int cy)
923{
924 /* Correct negative x and y coordinates. */
925 if (*px < 0)
926 {
927 *px += *pw; /* Compute xRight which is also the new width. */
928
929 *pw = (*px < 0)? 0: *px;
930
931 *px = 0;
932 }
933
934 if (*py < 0)
935 {
936 *py += *ph; /* Compute xBottom, which is also the new height. */
937
938 *ph = (*py < 0)? 0: *py;
939
940 *py = 0;
941 }
942
943 /* Also check if coords are greater than the display resolution. */
944 if (*px + *pw > cx)
945 {
946 *pw = cx > *px? cx - *px: 0;
947 }
948
949 if (*py + *ph > cy)
950 {
951 *ph = cy > *py? cy - *py: 0;
952 }
953}
954
955unsigned mapCoordsToScreen(DISPLAYFBINFO *pInfos, unsigned cInfos, int *px, int *py, int *pw, int *ph)
956{
957 DISPLAYFBINFO *pInfo = pInfos;
958 unsigned uScreenId;
959 LogSunlover (("mapCoordsToScreen: %d,%d %dx%d\n", *px, *py, *pw, *ph));
960 for (uScreenId = 0; uScreenId < cInfos; uScreenId++, pInfo++)
961 {
962 LogSunlover ((" [%d] %d,%d %dx%d\n", uScreenId, pInfo->xOrigin, pInfo->yOrigin, pInfo->w, pInfo->h));
963 if ( (pInfo->xOrigin <= *px && *px < pInfo->xOrigin + (int)pInfo->w)
964 && (pInfo->yOrigin <= *py && *py < pInfo->yOrigin + (int)pInfo->h))
965 {
966 /* The rectangle belongs to the screen. Correct coordinates. */
967 *px -= pInfo->xOrigin;
968 *py -= pInfo->yOrigin;
969 LogSunlover ((" -> %d,%d", *px, *py));
970 break;
971 }
972 }
973 if (uScreenId == cInfos)
974 {
975 /* Map to primary screen. */
976 uScreenId = 0;
977 }
978 LogSunlover ((" scr %d\n", uScreenId));
979 return uScreenId;
980}
981
982
983/**
984 * Handles display update event.
985 *
986 * @param x Update area x coordinate
987 * @param y Update area y coordinate
988 * @param w Update area width
989 * @param h Update area height
990 *
991 * @thread EMT
992 */
993void Display::handleDisplayUpdate (int x, int y, int w, int h)
994{
995#ifdef VBOX_WITH_OLD_VBVA_LOCK
996 /*
997 * Always runs under either VBVA lock or, for HGSMI, DevVGA lock.
998 * Safe to use VBVA vars and take the framebuffer lock.
999 */
1000#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1001
1002#ifdef DEBUG_sunlover
1003 LogFlowFunc (("%d,%d %dx%d (%d,%d)\n",
1004 x, y, w, h, mpDrv->IConnector.cx, mpDrv->IConnector.cy));
1005#endif /* DEBUG_sunlover */
1006
1007 unsigned uScreenId = mapCoordsToScreen(maFramebuffers, mcMonitors, &x, &y, &w, &h);
1008
1009#ifdef DEBUG_sunlover
1010 LogFlowFunc (("%d,%d %dx%d (checked)\n", x, y, w, h));
1011#endif /* DEBUG_sunlover */
1012
1013 IFramebuffer *pFramebuffer = maFramebuffers[uScreenId].pFramebuffer;
1014
1015 // if there is no framebuffer, this call is not interesting
1016 if (pFramebuffer == NULL)
1017 return;
1018
1019 pFramebuffer->Lock();
1020
1021 if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
1022 checkCoordBounds (&x, &y, &w, &h, mpDrv->IConnector.cx, mpDrv->IConnector.cy);
1023 else
1024 checkCoordBounds (&x, &y, &w, &h, maFramebuffers[uScreenId].w,
1025 maFramebuffers[uScreenId].h);
1026
1027 if (w != 0 && h != 0)
1028 pFramebuffer->NotifyUpdate(x, y, w, h);
1029
1030 pFramebuffer->Unlock();
1031
1032#ifndef VBOX_WITH_HGSMI
1033 if (!mfVideoAccelEnabled)
1034 {
1035#else
1036 if (!mfVideoAccelEnabled && !maFramebuffers[uScreenId].fVBVAEnabled)
1037 {
1038#endif /* VBOX_WITH_HGSMI */
1039 /* When VBVA is enabled, the VRDP server is informed in the VideoAccelFlush.
1040 * Inform the server here only if VBVA is disabled.
1041 */
1042 if (maFramebuffers[uScreenId].u32ResizeStatus == ResizeStatus_Void)
1043 mParent->consoleVRDPServer()->SendUpdateBitmap(uScreenId, x, y, w, h);
1044 }
1045}
1046
1047typedef struct _VBVADIRTYREGION
1048{
1049 /* Copies of object's pointers used by vbvaRgn functions. */
1050 DISPLAYFBINFO *paFramebuffers;
1051 unsigned cMonitors;
1052 Display *pDisplay;
1053 PPDMIDISPLAYPORT pPort;
1054
1055} VBVADIRTYREGION;
1056
1057static void vbvaRgnInit (VBVADIRTYREGION *prgn, DISPLAYFBINFO *paFramebuffers, unsigned cMonitors, Display *pd, PPDMIDISPLAYPORT pp)
1058{
1059 prgn->paFramebuffers = paFramebuffers;
1060 prgn->cMonitors = cMonitors;
1061 prgn->pDisplay = pd;
1062 prgn->pPort = pp;
1063
1064 unsigned uScreenId;
1065 for (uScreenId = 0; uScreenId < cMonitors; uScreenId++)
1066 {
1067 DISPLAYFBINFO *pFBInfo = &prgn->paFramebuffers[uScreenId];
1068
1069 memset (&pFBInfo->dirtyRect, 0, sizeof (pFBInfo->dirtyRect));
1070 }
1071}
1072
1073static void vbvaRgnDirtyRect (VBVADIRTYREGION *prgn, unsigned uScreenId, VBVACMDHDR *phdr)
1074{
1075 LogSunlover (("x = %d, y = %d, w = %d, h = %d\n",
1076 phdr->x, phdr->y, phdr->w, phdr->h));
1077
1078 /*
1079 * Here update rectangles are accumulated to form an update area.
1080 * @todo
1081 * Now the simpliest method is used which builds one rectangle that
1082 * includes all update areas. A bit more advanced method can be
1083 * employed here. The method should be fast however.
1084 */
1085 if (phdr->w == 0 || phdr->h == 0)
1086 {
1087 /* Empty rectangle. */
1088 return;
1089 }
1090
1091 int32_t xRight = phdr->x + phdr->w;
1092 int32_t yBottom = phdr->y + phdr->h;
1093
1094 DISPLAYFBINFO *pFBInfo = &prgn->paFramebuffers[uScreenId];
1095
1096 if (pFBInfo->dirtyRect.xRight == 0)
1097 {
1098 /* This is the first rectangle to be added. */
1099 pFBInfo->dirtyRect.xLeft = phdr->x;
1100 pFBInfo->dirtyRect.yTop = phdr->y;
1101 pFBInfo->dirtyRect.xRight = xRight;
1102 pFBInfo->dirtyRect.yBottom = yBottom;
1103 }
1104 else
1105 {
1106 /* Adjust region coordinates. */
1107 if (pFBInfo->dirtyRect.xLeft > phdr->x)
1108 {
1109 pFBInfo->dirtyRect.xLeft = phdr->x;
1110 }
1111
1112 if (pFBInfo->dirtyRect.yTop > phdr->y)
1113 {
1114 pFBInfo->dirtyRect.yTop = phdr->y;
1115 }
1116
1117 if (pFBInfo->dirtyRect.xRight < xRight)
1118 {
1119 pFBInfo->dirtyRect.xRight = xRight;
1120 }
1121
1122 if (pFBInfo->dirtyRect.yBottom < yBottom)
1123 {
1124 pFBInfo->dirtyRect.yBottom = yBottom;
1125 }
1126 }
1127
1128 if (pFBInfo->fDefaultFormat)
1129 {
1130 //@todo pfnUpdateDisplayRect must take the vram offset parameter for the framebuffer
1131 prgn->pPort->pfnUpdateDisplayRect (prgn->pPort, phdr->x, phdr->y, phdr->w, phdr->h);
1132 prgn->pDisplay->handleDisplayUpdate (phdr->x + pFBInfo->xOrigin,
1133 phdr->y + pFBInfo->yOrigin, phdr->w, phdr->h);
1134 }
1135
1136 return;
1137}
1138
1139static void vbvaRgnUpdateFramebuffer (VBVADIRTYREGION *prgn, unsigned uScreenId)
1140{
1141 DISPLAYFBINFO *pFBInfo = &prgn->paFramebuffers[uScreenId];
1142
1143 uint32_t w = pFBInfo->dirtyRect.xRight - pFBInfo->dirtyRect.xLeft;
1144 uint32_t h = pFBInfo->dirtyRect.yBottom - pFBInfo->dirtyRect.yTop;
1145
1146 if (!pFBInfo->fDefaultFormat && pFBInfo->pFramebuffer && w != 0 && h != 0)
1147 {
1148 //@todo pfnUpdateDisplayRect must take the vram offset parameter for the framebuffer
1149 prgn->pPort->pfnUpdateDisplayRect (prgn->pPort, pFBInfo->dirtyRect.xLeft, pFBInfo->dirtyRect.yTop, w, h);
1150 prgn->pDisplay->handleDisplayUpdate (pFBInfo->dirtyRect.xLeft + pFBInfo->xOrigin,
1151 pFBInfo->dirtyRect.yTop + pFBInfo->yOrigin, w, h);
1152 }
1153}
1154
1155static void vbvaSetMemoryFlags (VBVAMEMORY *pVbvaMemory,
1156 bool fVideoAccelEnabled,
1157 bool fVideoAccelVRDP,
1158 uint32_t fu32SupportedOrders,
1159 DISPLAYFBINFO *paFBInfos,
1160 unsigned cFBInfos)
1161{
1162 if (pVbvaMemory)
1163 {
1164 /* This called only on changes in mode. So reset VRDP always. */
1165 uint32_t fu32Flags = VBVA_F_MODE_VRDP_RESET;
1166
1167 if (fVideoAccelEnabled)
1168 {
1169 fu32Flags |= VBVA_F_MODE_ENABLED;
1170
1171 if (fVideoAccelVRDP)
1172 {
1173 fu32Flags |= VBVA_F_MODE_VRDP | VBVA_F_MODE_VRDP_ORDER_MASK;
1174
1175 pVbvaMemory->fu32SupportedOrders = fu32SupportedOrders;
1176 }
1177 }
1178
1179 pVbvaMemory->fu32ModeFlags = fu32Flags;
1180 }
1181
1182 unsigned uScreenId;
1183 for (uScreenId = 0; uScreenId < cFBInfos; uScreenId++)
1184 {
1185 if (paFBInfos[uScreenId].pHostEvents)
1186 {
1187 paFBInfos[uScreenId].pHostEvents->fu32Events |= VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET;
1188 }
1189 }
1190}
1191
1192#ifdef VBOX_WITH_HGSMI
1193static void vbvaSetMemoryFlagsHGSMI (unsigned uScreenId,
1194 uint32_t fu32SupportedOrders,
1195 bool fVideoAccelVRDP,
1196 DISPLAYFBINFO *pFBInfo)
1197{
1198 LogFlowFunc(("HGSMI[%d]: %p\n", uScreenId, pFBInfo->pVBVAHostFlags));
1199
1200 if (pFBInfo->pVBVAHostFlags)
1201 {
1202 uint32_t fu32HostEvents = VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET;
1203
1204 if (pFBInfo->fVBVAEnabled)
1205 {
1206 fu32HostEvents |= VBVA_F_MODE_ENABLED;
1207
1208 if (fVideoAccelVRDP)
1209 {
1210 fu32HostEvents |= VBVA_F_MODE_VRDP;
1211 }
1212 }
1213
1214 ASMAtomicOrU32(&pFBInfo->pVBVAHostFlags->u32HostEvents, fu32HostEvents);
1215 ASMAtomicWriteU32(&pFBInfo->pVBVAHostFlags->u32SupportedOrders, fu32SupportedOrders);
1216
1217 LogFlowFunc((" fu32HostEvents = 0x%08X, fu32SupportedOrders = 0x%08X\n", fu32HostEvents, fu32SupportedOrders));
1218 }
1219}
1220
1221static void vbvaSetMemoryFlagsAllHGSMI (uint32_t fu32SupportedOrders,
1222 bool fVideoAccelVRDP,
1223 DISPLAYFBINFO *paFBInfos,
1224 unsigned cFBInfos)
1225{
1226 unsigned uScreenId;
1227
1228 for (uScreenId = 0; uScreenId < cFBInfos; uScreenId++)
1229 {
1230 vbvaSetMemoryFlagsHGSMI(uScreenId, fu32SupportedOrders, fVideoAccelVRDP, &paFBInfos[uScreenId]);
1231 }
1232}
1233#endif /* VBOX_WITH_HGSMI */
1234
1235bool Display::VideoAccelAllowed (void)
1236{
1237 return true;
1238}
1239
1240#ifdef VBOX_WITH_OLD_VBVA_LOCK
1241int Display::vbvaLock(void)
1242{
1243 return RTCritSectEnter(&mVBVALock);
1244}
1245
1246void Display::vbvaUnlock(void)
1247{
1248 RTCritSectLeave(&mVBVALock);
1249}
1250#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1251
1252/**
1253 * @thread EMT
1254 */
1255#ifdef VBOX_WITH_OLD_VBVA_LOCK
1256int Display::VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory)
1257{
1258 int rc;
1259 vbvaLock();
1260 rc = videoAccelEnable (fEnable, pVbvaMemory);
1261 vbvaUnlock();
1262 return rc;
1263}
1264#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1265
1266#ifdef VBOX_WITH_OLD_VBVA_LOCK
1267int Display::videoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory)
1268#else
1269int Display::VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory)
1270#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
1271{
1272 int rc = VINF_SUCCESS;
1273
1274 /* Called each time the guest wants to use acceleration,
1275 * or when the VGA device disables acceleration,
1276 * or when restoring the saved state with accel enabled.
1277 *
1278 * VGA device disables acceleration on each video mode change
1279 * and on reset.
1280 *
1281 * Guest enabled acceleration at will. And it has to enable
1282 * acceleration after a mode change.
1283 */
1284 LogFlowFunc (("mfVideoAccelEnabled = %d, fEnable = %d, pVbvaMemory = %p\n",
1285 mfVideoAccelEnabled, fEnable, pVbvaMemory));
1286
1287 /* Strictly check parameters. Callers must not pass anything in the case. */
1288 Assert((fEnable && pVbvaMemory) || (!fEnable && pVbvaMemory == NULL));
1289
1290 if (!VideoAccelAllowed ())
1291 {
1292 return VERR_NOT_SUPPORTED;
1293 }
1294
1295 /*
1296 * Verify that the VM is in running state. If it is not,
1297 * then this must be postponed until it goes to running.
1298 */
1299 if (!mfMachineRunning)
1300 {
1301 Assert (!mfVideoAccelEnabled);
1302
1303 LogFlowFunc (("Machine is not yet running.\n"));
1304
1305 if (fEnable)
1306 {
1307 mfPendingVideoAccelEnable = fEnable;
1308 mpPendingVbvaMemory = pVbvaMemory;
1309 }
1310
1311 return rc;
1312 }
1313
1314 /* Check that current status is not being changed */
1315 if (mfVideoAccelEnabled == fEnable)
1316 {
1317 return rc;
1318 }
1319
1320 if (mfVideoAccelEnabled)
1321 {
1322 /* Process any pending orders and empty the VBVA ring buffer. */
1323#ifdef VBOX_WITH_OLD_VBVA_LOCK
1324 videoAccelFlush ();
1325#else
1326 VideoAccelFlush ();
1327#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
1328 }
1329
1330 if (!fEnable && mpVbvaMemory)
1331 {
1332 mpVbvaMemory->fu32ModeFlags &= ~VBVA_F_MODE_ENABLED;
1333 }
1334
1335 /* Safety precaution. There is no more VBVA until everything is setup! */
1336 mpVbvaMemory = NULL;
1337 mfVideoAccelEnabled = false;
1338
1339 /* Update entire display. */
1340 if (maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].u32ResizeStatus == ResizeStatus_Void)
1341 {
1342 mpDrv->pUpPort->pfnUpdateDisplayAll(mpDrv->pUpPort);
1343 }
1344
1345 /* Everything OK. VBVA status can be changed. */
1346
1347 /* Notify the VMMDev, which saves VBVA status in the saved state,
1348 * and needs to know current status.
1349 */
1350 PPDMIVMMDEVPORT pVMMDevPort = mParent->getVMMDev()->getVMMDevPort ();
1351
1352 if (pVMMDevPort)
1353 {
1354 pVMMDevPort->pfnVBVAChange (pVMMDevPort, fEnable);
1355 }
1356
1357 if (fEnable)
1358 {
1359 mpVbvaMemory = pVbvaMemory;
1360 mfVideoAccelEnabled = true;
1361
1362 /* Initialize the hardware memory. */
1363 vbvaSetMemoryFlags (mpVbvaMemory, mfVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders, maFramebuffers, mcMonitors);
1364 mpVbvaMemory->off32Data = 0;
1365 mpVbvaMemory->off32Free = 0;
1366
1367 memset (mpVbvaMemory->aRecords, 0, sizeof (mpVbvaMemory->aRecords));
1368 mpVbvaMemory->indexRecordFirst = 0;
1369 mpVbvaMemory->indexRecordFree = 0;
1370
1371#ifdef VBOX_WITH_OLD_VBVA_LOCK
1372 mfu32PendingVideoAccelDisable = false;
1373#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1374
1375 LogRel(("VBVA: Enabled.\n"));
1376 }
1377 else
1378 {
1379 LogRel(("VBVA: Disabled.\n"));
1380 }
1381
1382 LogFlowFunc (("VideoAccelEnable: rc = %Rrc.\n", rc));
1383
1384 return rc;
1385}
1386
1387#ifdef VBOX_WITH_VRDP
1388/* Called always by one VRDP server thread. Can be thread-unsafe.
1389 */
1390void Display::VideoAccelVRDP (bool fEnable)
1391{
1392 LogFlowFunc(("fEnable = %d\n", fEnable));
1393
1394#ifdef VBOX_WITH_OLD_VBVA_LOCK
1395 vbvaLock();
1396#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1397
1398 int c = fEnable?
1399 ASMAtomicIncS32 (&mcVideoAccelVRDPRefs):
1400 ASMAtomicDecS32 (&mcVideoAccelVRDPRefs);
1401
1402 Assert (c >= 0);
1403
1404 if (c == 0)
1405 {
1406 /* The last client has disconnected, and the accel can be
1407 * disabled.
1408 */
1409 Assert (fEnable == false);
1410
1411 mfVideoAccelVRDP = false;
1412 mfu32SupportedOrders = 0;
1413
1414 vbvaSetMemoryFlags (mpVbvaMemory, mfVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders, maFramebuffers, mcMonitors);
1415#ifdef VBOX_WITH_HGSMI
1416 /* Here is VRDP-IN thread. Process the request in vbvaUpdateBegin under DevVGA lock on an EMT. */
1417 ASMAtomicIncU32(&mu32UpdateVBVAFlags);
1418#endif /* VBOX_WITH_HGSMI */
1419
1420 LogRel(("VBVA: VRDP acceleration has been disabled.\n"));
1421 }
1422 else if ( c == 1
1423 && !mfVideoAccelVRDP)
1424 {
1425 /* The first client has connected. Enable the accel.
1426 */
1427 Assert (fEnable == true);
1428
1429 mfVideoAccelVRDP = true;
1430 /* Supporting all orders. */
1431 mfu32SupportedOrders = ~0;
1432
1433 vbvaSetMemoryFlags (mpVbvaMemory, mfVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders, maFramebuffers, mcMonitors);
1434#ifdef VBOX_WITH_HGSMI
1435 /* Here is VRDP-IN thread. Process the request in vbvaUpdateBegin under DevVGA lock on an EMT. */
1436 ASMAtomicIncU32(&mu32UpdateVBVAFlags);
1437#endif /* VBOX_WITH_HGSMI */
1438
1439 LogRel(("VBVA: VRDP acceleration has been requested.\n"));
1440 }
1441 else
1442 {
1443 /* A client is connected or disconnected but there is no change in the
1444 * accel state. It remains enabled.
1445 */
1446 Assert (mfVideoAccelVRDP == true);
1447 }
1448#ifdef VBOX_WITH_OLD_VBVA_LOCK
1449 vbvaUnlock();
1450#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1451}
1452#endif /* VBOX_WITH_VRDP */
1453
1454static bool vbvaVerifyRingBuffer (VBVAMEMORY *pVbvaMemory)
1455{
1456 return true;
1457}
1458
1459static void vbvaFetchBytes (VBVAMEMORY *pVbvaMemory, uint8_t *pu8Dst, uint32_t cbDst)
1460{
1461 if (cbDst >= VBVA_RING_BUFFER_SIZE)
1462 {
1463 AssertMsgFailed (("cbDst = 0x%08X, ring buffer size 0x%08X", cbDst, VBVA_RING_BUFFER_SIZE));
1464 return;
1465 }
1466
1467 uint32_t u32BytesTillBoundary = VBVA_RING_BUFFER_SIZE - pVbvaMemory->off32Data;
1468 uint8_t *src = &pVbvaMemory->au8RingBuffer[pVbvaMemory->off32Data];
1469 int32_t i32Diff = cbDst - u32BytesTillBoundary;
1470
1471 if (i32Diff <= 0)
1472 {
1473 /* Chunk will not cross buffer boundary. */
1474 memcpy (pu8Dst, src, cbDst);
1475 }
1476 else
1477 {
1478 /* Chunk crosses buffer boundary. */
1479 memcpy (pu8Dst, src, u32BytesTillBoundary);
1480 memcpy (pu8Dst + u32BytesTillBoundary, &pVbvaMemory->au8RingBuffer[0], i32Diff);
1481 }
1482
1483 /* Advance data offset. */
1484 pVbvaMemory->off32Data = (pVbvaMemory->off32Data + cbDst) % VBVA_RING_BUFFER_SIZE;
1485
1486 return;
1487}
1488
1489
1490static bool vbvaPartialRead (uint8_t **ppu8, uint32_t *pcb, uint32_t cbRecord, VBVAMEMORY *pVbvaMemory)
1491{
1492 uint8_t *pu8New;
1493
1494 LogFlow(("MAIN::DisplayImpl::vbvaPartialRead: p = %p, cb = %d, cbRecord 0x%08X\n",
1495 *ppu8, *pcb, cbRecord));
1496
1497 if (*ppu8)
1498 {
1499 Assert (*pcb);
1500 pu8New = (uint8_t *)RTMemRealloc (*ppu8, cbRecord);
1501 }
1502 else
1503 {
1504 Assert (!*pcb);
1505 pu8New = (uint8_t *)RTMemAlloc (cbRecord);
1506 }
1507
1508 if (!pu8New)
1509 {
1510 /* Memory allocation failed, fail the function. */
1511 Log(("MAIN::vbvaPartialRead: failed to (re)alocate memory for partial record!!! cbRecord 0x%08X\n",
1512 cbRecord));
1513
1514 if (*ppu8)
1515 {
1516 RTMemFree (*ppu8);
1517 }
1518
1519 *ppu8 = NULL;
1520 *pcb = 0;
1521
1522 return false;
1523 }
1524
1525 /* Fetch data from the ring buffer. */
1526 vbvaFetchBytes (pVbvaMemory, pu8New + *pcb, cbRecord - *pcb);
1527
1528 *ppu8 = pu8New;
1529 *pcb = cbRecord;
1530
1531 return true;
1532}
1533
1534/* For contiguous chunks just return the address in the buffer.
1535 * For crossing boundary - allocate a buffer from heap.
1536 */
1537bool Display::vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd)
1538{
1539 uint32_t indexRecordFirst = mpVbvaMemory->indexRecordFirst;
1540 uint32_t indexRecordFree = mpVbvaMemory->indexRecordFree;
1541
1542#ifdef DEBUG_sunlover
1543 LogFlowFunc (("first = %d, free = %d\n",
1544 indexRecordFirst, indexRecordFree));
1545#endif /* DEBUG_sunlover */
1546
1547 if (!vbvaVerifyRingBuffer (mpVbvaMemory))
1548 {
1549 return false;
1550 }
1551
1552 if (indexRecordFirst == indexRecordFree)
1553 {
1554 /* No records to process. Return without assigning output variables. */
1555 return true;
1556 }
1557
1558 VBVARECORD *pRecord = &mpVbvaMemory->aRecords[indexRecordFirst];
1559
1560#ifdef DEBUG_sunlover
1561 LogFlowFunc (("cbRecord = 0x%08X\n", pRecord->cbRecord));
1562#endif /* DEBUG_sunlover */
1563
1564 uint32_t cbRecord = pRecord->cbRecord & ~VBVA_F_RECORD_PARTIAL;
1565
1566 if (mcbVbvaPartial)
1567 {
1568 /* There is a partial read in process. Continue with it. */
1569
1570 Assert (mpu8VbvaPartial);
1571
1572 LogFlowFunc (("continue partial record mcbVbvaPartial = %d cbRecord 0x%08X, first = %d, free = %d\n",
1573 mcbVbvaPartial, pRecord->cbRecord, indexRecordFirst, indexRecordFree));
1574
1575 if (cbRecord > mcbVbvaPartial)
1576 {
1577 /* New data has been added to the record. */
1578 if (!vbvaPartialRead (&mpu8VbvaPartial, &mcbVbvaPartial, cbRecord, mpVbvaMemory))
1579 {
1580 return false;
1581 }
1582 }
1583
1584 if (!(pRecord->cbRecord & VBVA_F_RECORD_PARTIAL))
1585 {
1586 /* The record is completed by guest. Return it to the caller. */
1587 *ppHdr = (VBVACMDHDR *)mpu8VbvaPartial;
1588 *pcbCmd = mcbVbvaPartial;
1589
1590 mpu8VbvaPartial = NULL;
1591 mcbVbvaPartial = 0;
1592
1593 /* Advance the record index. */
1594 mpVbvaMemory->indexRecordFirst = (indexRecordFirst + 1) % VBVA_MAX_RECORDS;
1595
1596#ifdef DEBUG_sunlover
1597 LogFlowFunc (("partial done ok, data = %d, free = %d\n",
1598 mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
1599#endif /* DEBUG_sunlover */
1600 }
1601
1602 return true;
1603 }
1604
1605 /* A new record need to be processed. */
1606 if (pRecord->cbRecord & VBVA_F_RECORD_PARTIAL)
1607 {
1608 /* Current record is being written by guest. '=' is important here. */
1609 if (cbRecord >= VBVA_RING_BUFFER_SIZE - VBVA_RING_BUFFER_THRESHOLD)
1610 {
1611 /* Partial read must be started. */
1612 if (!vbvaPartialRead (&mpu8VbvaPartial, &mcbVbvaPartial, cbRecord, mpVbvaMemory))
1613 {
1614 return false;
1615 }
1616
1617 LogFlowFunc (("started partial record mcbVbvaPartial = 0x%08X cbRecord 0x%08X, first = %d, free = %d\n",
1618 mcbVbvaPartial, pRecord->cbRecord, indexRecordFirst, indexRecordFree));
1619 }
1620
1621 return true;
1622 }
1623
1624 /* Current record is complete. If it is not empty, process it. */
1625 if (cbRecord)
1626 {
1627 /* The size of largest contiguos chunk in the ring biffer. */
1628 uint32_t u32BytesTillBoundary = VBVA_RING_BUFFER_SIZE - mpVbvaMemory->off32Data;
1629
1630 /* The ring buffer pointer. */
1631 uint8_t *au8RingBuffer = &mpVbvaMemory->au8RingBuffer[0];
1632
1633 /* The pointer to data in the ring buffer. */
1634 uint8_t *src = &au8RingBuffer[mpVbvaMemory->off32Data];
1635
1636 /* Fetch or point the data. */
1637 if (u32BytesTillBoundary >= cbRecord)
1638 {
1639 /* The command does not cross buffer boundary. Return address in the buffer. */
1640 *ppHdr = (VBVACMDHDR *)src;
1641
1642 /* Advance data offset. */
1643 mpVbvaMemory->off32Data = (mpVbvaMemory->off32Data + cbRecord) % VBVA_RING_BUFFER_SIZE;
1644 }
1645 else
1646 {
1647 /* The command crosses buffer boundary. Rare case, so not optimized. */
1648 uint8_t *dst = (uint8_t *)RTMemAlloc (cbRecord);
1649
1650 if (!dst)
1651 {
1652 LogFlowFunc (("could not allocate %d bytes from heap!!!\n", cbRecord));
1653 mpVbvaMemory->off32Data = (mpVbvaMemory->off32Data + cbRecord) % VBVA_RING_BUFFER_SIZE;
1654 return false;
1655 }
1656
1657 vbvaFetchBytes (mpVbvaMemory, dst, cbRecord);
1658
1659 *ppHdr = (VBVACMDHDR *)dst;
1660
1661#ifdef DEBUG_sunlover
1662 LogFlowFunc (("Allocated from heap %p\n", dst));
1663#endif /* DEBUG_sunlover */
1664 }
1665 }
1666
1667 *pcbCmd = cbRecord;
1668
1669 /* Advance the record index. */
1670 mpVbvaMemory->indexRecordFirst = (indexRecordFirst + 1) % VBVA_MAX_RECORDS;
1671
1672#ifdef DEBUG_sunlover
1673 LogFlowFunc (("done ok, data = %d, free = %d\n",
1674 mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
1675#endif /* DEBUG_sunlover */
1676
1677 return true;
1678}
1679
1680void Display::vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd)
1681{
1682 uint8_t *au8RingBuffer = mpVbvaMemory->au8RingBuffer;
1683
1684 if ( (uint8_t *)pHdr >= au8RingBuffer
1685 && (uint8_t *)pHdr < &au8RingBuffer[VBVA_RING_BUFFER_SIZE])
1686 {
1687 /* The pointer is inside ring buffer. Must be continuous chunk. */
1688 Assert (VBVA_RING_BUFFER_SIZE - ((uint8_t *)pHdr - au8RingBuffer) >= cbCmd);
1689
1690 /* Do nothing. */
1691
1692 Assert (!mpu8VbvaPartial && mcbVbvaPartial == 0);
1693 }
1694 else
1695 {
1696 /* The pointer is outside. It is then an allocated copy. */
1697
1698#ifdef DEBUG_sunlover
1699 LogFlowFunc (("Free heap %p\n", pHdr));
1700#endif /* DEBUG_sunlover */
1701
1702 if ((uint8_t *)pHdr == mpu8VbvaPartial)
1703 {
1704 mpu8VbvaPartial = NULL;
1705 mcbVbvaPartial = 0;
1706 }
1707 else
1708 {
1709 Assert (!mpu8VbvaPartial && mcbVbvaPartial == 0);
1710 }
1711
1712 RTMemFree (pHdr);
1713 }
1714
1715 return;
1716}
1717
1718
1719/**
1720 * Called regularly on the DisplayRefresh timer.
1721 * Also on behalf of guest, when the ring buffer is full.
1722 *
1723 * @thread EMT
1724 */
1725#ifdef VBOX_WITH_OLD_VBVA_LOCK
1726void Display::VideoAccelFlush (void)
1727{
1728 vbvaLock();
1729 videoAccelFlush();
1730 vbvaUnlock();
1731}
1732#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1733
1734#ifdef VBOX_WITH_OLD_VBVA_LOCK
1735/* Under VBVA lock. DevVGA is not taken. */
1736void Display::videoAccelFlush (void)
1737#else
1738void Display::VideoAccelFlush (void)
1739#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
1740{
1741#ifdef DEBUG_sunlover_2
1742 LogFlowFunc (("mfVideoAccelEnabled = %d\n", mfVideoAccelEnabled));
1743#endif /* DEBUG_sunlover_2 */
1744
1745 if (!mfVideoAccelEnabled)
1746 {
1747 Log(("Display::VideoAccelFlush: called with disabled VBVA!!! Ignoring.\n"));
1748 return;
1749 }
1750
1751 /* Here VBVA is enabled and we have the accelerator memory pointer. */
1752 Assert(mpVbvaMemory);
1753
1754#ifdef DEBUG_sunlover_2
1755 LogFlowFunc (("indexRecordFirst = %d, indexRecordFree = %d, off32Data = %d, off32Free = %d\n",
1756 mpVbvaMemory->indexRecordFirst, mpVbvaMemory->indexRecordFree, mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
1757#endif /* DEBUG_sunlover_2 */
1758
1759 /* Quick check for "nothing to update" case. */
1760 if (mpVbvaMemory->indexRecordFirst == mpVbvaMemory->indexRecordFree)
1761 {
1762 return;
1763 }
1764
1765 /* Process the ring buffer */
1766 unsigned uScreenId;
1767#ifndef VBOX_WITH_OLD_VBVA_LOCK
1768 for (uScreenId = 0; uScreenId < mcMonitors; uScreenId++)
1769 {
1770 if (!maFramebuffers[uScreenId].pFramebuffer.isNull())
1771 {
1772 maFramebuffers[uScreenId].pFramebuffer->Lock ();
1773 }
1774 }
1775#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
1776
1777 /* Initialize dirty rectangles accumulator. */
1778 VBVADIRTYREGION rgn;
1779 vbvaRgnInit (&rgn, maFramebuffers, mcMonitors, this, mpDrv->pUpPort);
1780
1781 for (;;)
1782 {
1783 VBVACMDHDR *phdr = NULL;
1784 uint32_t cbCmd = ~0;
1785
1786 /* Fetch the command data. */
1787 if (!vbvaFetchCmd (&phdr, &cbCmd))
1788 {
1789 Log(("Display::VideoAccelFlush: unable to fetch command. off32Data = %d, off32Free = %d. Disabling VBVA!!!\n",
1790 mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
1791
1792 /* Disable VBVA on those processing errors. */
1793#ifdef VBOX_WITH_OLD_VBVA_LOCK
1794 videoAccelEnable (false, NULL);
1795#else
1796 VideoAccelEnable (false, NULL);
1797#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
1798
1799 break;
1800 }
1801
1802 if (cbCmd == uint32_t(~0))
1803 {
1804 /* No more commands yet in the queue. */
1805 break;
1806 }
1807
1808 if (cbCmd != 0)
1809 {
1810#ifdef DEBUG_sunlover
1811 LogFlowFunc (("hdr: cbCmd = %d, x=%d, y=%d, w=%d, h=%d\n",
1812 cbCmd, phdr->x, phdr->y, phdr->w, phdr->h));
1813#endif /* DEBUG_sunlover */
1814
1815 VBVACMDHDR hdrSaved = *phdr;
1816
1817 int x = phdr->x;
1818 int y = phdr->y;
1819 int w = phdr->w;
1820 int h = phdr->h;
1821
1822 uScreenId = mapCoordsToScreen(maFramebuffers, mcMonitors, &x, &y, &w, &h);
1823
1824 phdr->x = (int16_t)x;
1825 phdr->y = (int16_t)y;
1826 phdr->w = (uint16_t)w;
1827 phdr->h = (uint16_t)h;
1828
1829 DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId];
1830
1831 if (pFBInfo->u32ResizeStatus == ResizeStatus_Void)
1832 {
1833 /* Handle the command.
1834 *
1835 * Guest is responsible for updating the guest video memory.
1836 * The Windows guest does all drawing using Eng*.
1837 *
1838 * For local output, only dirty rectangle information is used
1839 * to update changed areas.
1840 *
1841 * Dirty rectangles are accumulated to exclude overlapping updates and
1842 * group small updates to a larger one.
1843 */
1844
1845 /* Accumulate the update. */
1846 vbvaRgnDirtyRect (&rgn, uScreenId, phdr);
1847
1848 /* Forward the command to VRDP server. */
1849 mParent->consoleVRDPServer()->SendUpdate (uScreenId, phdr, cbCmd);
1850
1851 *phdr = hdrSaved;
1852 }
1853 }
1854
1855 vbvaReleaseCmd (phdr, cbCmd);
1856 }
1857
1858 for (uScreenId = 0; uScreenId < mcMonitors; uScreenId++)
1859 {
1860#ifndef VBOX_WITH_OLD_VBVA_LOCK
1861 if (!maFramebuffers[uScreenId].pFramebuffer.isNull())
1862 {
1863 maFramebuffers[uScreenId].pFramebuffer->Unlock ();
1864 }
1865#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
1866
1867 if (maFramebuffers[uScreenId].u32ResizeStatus == ResizeStatus_Void)
1868 {
1869 /* Draw the framebuffer. */
1870 vbvaRgnUpdateFramebuffer (&rgn, uScreenId);
1871 }
1872 }
1873}
1874
1875#ifdef VBOX_WITH_OLD_VBVA_LOCK
1876int Display::videoAccelRefreshProcess(void)
1877{
1878 int rc = VWRN_INVALID_STATE; /* Default is to do a display update in VGA device. */
1879
1880 vbvaLock();
1881
1882 if (ASMAtomicCmpXchgU32(&mfu32PendingVideoAccelDisable, false, true))
1883 {
1884 videoAccelEnable (false, NULL);
1885 }
1886 else if (mfPendingVideoAccelEnable)
1887 {
1888 /* Acceleration was enabled while machine was not yet running
1889 * due to restoring from saved state. Update entire display and
1890 * actually enable acceleration.
1891 */
1892 Assert(mpPendingVbvaMemory);
1893
1894 /* Acceleration can not be yet enabled.*/
1895 Assert(mpVbvaMemory == NULL);
1896 Assert(!mfVideoAccelEnabled);
1897
1898 if (mfMachineRunning)
1899 {
1900 videoAccelEnable (mfPendingVideoAccelEnable,
1901 mpPendingVbvaMemory);
1902
1903 /* Reset the pending state. */
1904 mfPendingVideoAccelEnable = false;
1905 mpPendingVbvaMemory = NULL;
1906 }
1907
1908 rc = VINF_TRY_AGAIN;
1909 }
1910 else
1911 {
1912 Assert(mpPendingVbvaMemory == NULL);
1913
1914 if (mfVideoAccelEnabled)
1915 {
1916 Assert(mpVbvaMemory);
1917 videoAccelFlush ();
1918
1919 rc = VINF_SUCCESS; /* VBVA processed, no need to a display update. */
1920 }
1921 }
1922
1923 vbvaUnlock();
1924
1925 return rc;
1926}
1927#endif /* VBOX_WITH_OLD_VBVA_LOCK */
1928
1929
1930// IDisplay properties
1931/////////////////////////////////////////////////////////////////////////////
1932
1933/**
1934 * Returns the current display width in pixel
1935 *
1936 * @returns COM status code
1937 * @param width Address of result variable.
1938 */
1939STDMETHODIMP Display::COMGETTER(Width) (ULONG *width)
1940{
1941 CheckComArgNotNull(width);
1942
1943 AutoCaller autoCaller(this);
1944 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1945
1946 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1947
1948 CHECK_CONSOLE_DRV (mpDrv);
1949
1950 *width = mpDrv->IConnector.cx;
1951
1952 return S_OK;
1953}
1954
1955/**
1956 * Returns the current display height in pixel
1957 *
1958 * @returns COM status code
1959 * @param height Address of result variable.
1960 */
1961STDMETHODIMP Display::COMGETTER(Height) (ULONG *height)
1962{
1963 CheckComArgNotNull(height);
1964
1965 AutoCaller autoCaller(this);
1966 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1967
1968 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1969
1970 CHECK_CONSOLE_DRV (mpDrv);
1971
1972 *height = mpDrv->IConnector.cy;
1973
1974 return S_OK;
1975}
1976
1977/**
1978 * Returns the current display color depth in bits
1979 *
1980 * @returns COM status code
1981 * @param bitsPerPixel Address of result variable.
1982 */
1983STDMETHODIMP Display::COMGETTER(BitsPerPixel) (ULONG *bitsPerPixel)
1984{
1985 if (!bitsPerPixel)
1986 return E_INVALIDARG;
1987
1988 AutoCaller autoCaller(this);
1989 if (FAILED(autoCaller.rc())) return autoCaller.rc();
1990
1991 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1992
1993 CHECK_CONSOLE_DRV (mpDrv);
1994
1995 uint32_t cBits = 0;
1996 int rc = mpDrv->pUpPort->pfnQueryColorDepth(mpDrv->pUpPort, &cBits);
1997 AssertRC(rc);
1998 *bitsPerPixel = cBits;
1999
2000 return S_OK;
2001}
2002
2003
2004// IDisplay methods
2005/////////////////////////////////////////////////////////////////////////////
2006
2007STDMETHODIMP Display::SetFramebuffer (ULONG aScreenId,
2008 IFramebuffer *aFramebuffer)
2009{
2010 LogFlowFunc (("\n"));
2011
2012 if (aFramebuffer != NULL)
2013 CheckComArgOutPointerValid(aFramebuffer);
2014
2015 AutoCaller autoCaller(this);
2016 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2017
2018 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2019
2020 Console::SafeVMPtrQuiet pVM (mParent);
2021 if (pVM.isOk())
2022 {
2023 /* Must leave the lock here because the changeFramebuffer will
2024 * also obtain it. */
2025 alock.leave ();
2026
2027 /* send request to the EMT thread */
2028 int vrc = VMR3ReqCallWait (pVM, VMCPUID_ANY,
2029 (PFNRT) changeFramebuffer, 3, this, aFramebuffer, aScreenId);
2030
2031 alock.enter ();
2032
2033 ComAssertRCRet (vrc, E_FAIL);
2034 }
2035 else
2036 {
2037 /* No VM is created (VM is powered off), do a direct call */
2038 int vrc = changeFramebuffer (this, aFramebuffer, aScreenId);
2039 ComAssertRCRet (vrc, E_FAIL);
2040 }
2041
2042 return S_OK;
2043}
2044
2045STDMETHODIMP Display::GetFramebuffer (ULONG aScreenId,
2046 IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin)
2047{
2048 LogFlowFunc (("aScreenId = %d\n", aScreenId));
2049
2050 CheckComArgOutPointerValid(aFramebuffer);
2051
2052 AutoCaller autoCaller(this);
2053 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2054
2055 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2056
2057 /* @todo this should be actually done on EMT. */
2058 DISPLAYFBINFO *pFBInfo = &maFramebuffers[aScreenId];
2059
2060 *aFramebuffer = pFBInfo->pFramebuffer;
2061 if (*aFramebuffer)
2062 (*aFramebuffer)->AddRef ();
2063 if (aXOrigin)
2064 *aXOrigin = pFBInfo->xOrigin;
2065 if (aYOrigin)
2066 *aYOrigin = pFBInfo->yOrigin;
2067
2068 return S_OK;
2069}
2070
2071STDMETHODIMP Display::SetVideoModeHint(ULONG aWidth, ULONG aHeight,
2072 ULONG aBitsPerPixel, ULONG aDisplay)
2073{
2074 AutoCaller autoCaller(this);
2075 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2076
2077 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2078
2079 CHECK_CONSOLE_DRV (mpDrv);
2080
2081 /*
2082 * Do some rough checks for valid input
2083 */
2084 ULONG width = aWidth;
2085 if (!width)
2086 width = mpDrv->IConnector.cx;
2087 ULONG height = aHeight;
2088 if (!height)
2089 height = mpDrv->IConnector.cy;
2090 ULONG bpp = aBitsPerPixel;
2091 if (!bpp)
2092 {
2093 uint32_t cBits = 0;
2094 int rc = mpDrv->pUpPort->pfnQueryColorDepth(mpDrv->pUpPort, &cBits);
2095 AssertRC(rc);
2096 bpp = cBits;
2097 }
2098 ULONG cMonitors;
2099 mParent->machine()->COMGETTER(MonitorCount)(&cMonitors);
2100 if (cMonitors == 0 && aDisplay > 0)
2101 return E_INVALIDARG;
2102 if (aDisplay >= cMonitors)
2103 return E_INVALIDARG;
2104
2105// sunlover 20070614: It is up to the guest to decide whether the hint is valid.
2106// ULONG vramSize;
2107// mParent->machine()->COMGETTER(VRAMSize)(&vramSize);
2108// /* enough VRAM? */
2109// if ((width * height * (bpp / 8)) > (vramSize * 1024 * 1024))
2110// return setError(E_FAIL, tr("Not enough VRAM for the selected video mode"));
2111
2112 /* Have to leave the lock because the pfnRequestDisplayChange
2113 * will call EMT. */
2114 alock.leave ();
2115 if (mParent->getVMMDev())
2116 mParent->getVMMDev()->getVMMDevPort()->
2117 pfnRequestDisplayChange (mParent->getVMMDev()->getVMMDevPort(),
2118 aWidth, aHeight, aBitsPerPixel, aDisplay);
2119 return S_OK;
2120}
2121
2122STDMETHODIMP Display::SetSeamlessMode (BOOL enabled)
2123{
2124 AutoCaller autoCaller(this);
2125 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2126
2127 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2128
2129 /* Have to leave the lock because the pfnRequestSeamlessChange will call EMT. */
2130 alock.leave ();
2131 if (mParent->getVMMDev())
2132 mParent->getVMMDev()->getVMMDevPort()->
2133 pfnRequestSeamlessChange (mParent->getVMMDev()->getVMMDevPort(),
2134 !!enabled);
2135 return S_OK;
2136}
2137
2138#ifdef VBOX_WITH_OLD_VBVA_LOCK
2139int Display::displayTakeScreenshotEMT(Display *pDisplay, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height)
2140{
2141 int rc;
2142 pDisplay->vbvaLock();
2143 rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppu8Data, pcbData, pu32Width, pu32Height);
2144 pDisplay->vbvaUnlock();
2145 return rc;
2146}
2147#endif /* VBOX_WITH_OLD_VBVA_LOCK */
2148
2149#ifdef VBOX_WITH_OLD_VBVA_LOCK
2150static int displayTakeScreenshot(PVM pVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height)
2151#else
2152static int displayTakeScreenshot(PVM pVM, struct DRVMAINDISPLAY *pDrv, BYTE *address, ULONG width, ULONG height)
2153#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2154{
2155 uint8_t *pu8Data = NULL;
2156 size_t cbData = 0;
2157 uint32_t cx = 0;
2158 uint32_t cy = 0;
2159
2160#ifdef VBOX_WITH_OLD_VBVA_LOCK
2161 int vrc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::displayTakeScreenshotEMT, 5,
2162 pDisplay, &pu8Data, &cbData, &cx, &cy);
2163#else
2164 /* @todo pfnTakeScreenshot is probably callable from any thread, because it uses the VGA device lock. */
2165 int vrc = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)pDrv->pUpPort->pfnTakeScreenshot, 5,
2166 pDrv->pUpPort, &pu8Data, &cbData, &cx, &cy);
2167#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2168
2169 if (RT_SUCCESS(vrc))
2170 {
2171 if (cx == width && cy == height)
2172 {
2173 /* No scaling required. */
2174 memcpy(address, pu8Data, cbData);
2175 }
2176 else
2177 {
2178 /* Scale. */
2179 LogFlowFunc(("SCALE: %dx%d -> %dx%d\n", cx, cy, width, height));
2180
2181 uint8_t *dst = address;
2182 uint8_t *src = pu8Data;
2183 int dstX = 0;
2184 int dstY = 0;
2185 int srcX = 0;
2186 int srcY = 0;
2187 int dstW = width;
2188 int dstH = height;
2189 int srcW = cx;
2190 int srcH = cy;
2191 gdImageCopyResampled (dst,
2192 src,
2193 dstX, dstY,
2194 srcX, srcY,
2195 dstW, dstH, srcW, srcH);
2196 }
2197
2198 /* This can be called from any thread. */
2199 pDrv->pUpPort->pfnFreeScreenshot (pDrv->pUpPort, pu8Data);
2200 }
2201
2202 return vrc;
2203}
2204
2205STDMETHODIMP Display::TakeScreenShot (BYTE *address, ULONG width, ULONG height)
2206{
2207 /// @todo (r=dmik) this function may take too long to complete if the VM
2208 // is doing something like saving state right now. Which, in case if it
2209 // is called on the GUI thread, will make it unresponsive. We should
2210 // check the machine state here (by enclosing the check and VMRequCall
2211 // within the Console lock to make it atomic).
2212
2213 LogFlowFuncEnter();
2214 LogFlowFunc (("address=%p, width=%d, height=%d\n",
2215 address, width, height));
2216
2217 CheckComArgNotNull(address);
2218 CheckComArgExpr(width, width != 0);
2219 CheckComArgExpr(height, height != 0);
2220
2221 AutoCaller autoCaller(this);
2222 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2223
2224 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2225
2226 CHECK_CONSOLE_DRV (mpDrv);
2227
2228 Console::SafeVMPtr pVM(mParent);
2229 if (FAILED(pVM.rc())) return pVM.rc();
2230
2231 HRESULT rc = S_OK;
2232
2233 LogFlowFunc (("Sending SCREENSHOT request\n"));
2234
2235 /* Leave lock because other thread (EMT) is called and it may initiate a resize
2236 * which also needs lock.
2237 *
2238 * This method does not need the lock anymore.
2239 */
2240 alock.leave();
2241
2242#ifdef VBOX_WITH_OLD_VBVA_LOCK
2243 int vrc = displayTakeScreenshot(pVM, this, mpDrv, address, width, height);
2244#else
2245 int vrc = displayTakeScreenshot(pVM, mpDrv, address, width, height);
2246#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2247
2248 if (vrc == VERR_NOT_IMPLEMENTED)
2249 rc = setError (E_NOTIMPL,
2250 tr ("This feature is not implemented"));
2251 else if (RT_FAILURE(vrc))
2252 rc = setError (VBOX_E_IPRT_ERROR,
2253 tr ("Could not take a screenshot (%Rrc)"), vrc);
2254
2255 LogFlowFunc (("rc=%08X\n", rc));
2256 LogFlowFuncLeave();
2257 return rc;
2258}
2259
2260STDMETHODIMP Display::TakeScreenShotSlow (ULONG width, ULONG height,
2261 ComSafeArrayOut(BYTE, aScreenData))
2262{
2263 LogFlowFuncEnter();
2264 LogFlowFunc (("width=%d, height=%d\n",
2265 width, height));
2266
2267 CheckComArgSafeArrayNotNull(aScreenData);
2268 CheckComArgExpr(width, width != 0);
2269 CheckComArgExpr(height, height != 0);
2270
2271 AutoCaller autoCaller(this);
2272 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2273
2274 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2275
2276 CHECK_CONSOLE_DRV (mpDrv);
2277
2278 Console::SafeVMPtr pVM(mParent);
2279 if (FAILED(pVM.rc())) return pVM.rc();
2280
2281 HRESULT rc = S_OK;
2282
2283 LogFlowFunc (("Sending SCREENSHOT request\n"));
2284
2285 /* Leave lock because other thread (EMT) is called and it may initiate a resize
2286 * which also needs lock.
2287 *
2288 * This method does not need the lock anymore.
2289 */
2290 alock.leave();
2291
2292 size_t cbData = width * 4 * height;
2293 uint8_t *pu8Data = (uint8_t *)RTMemAlloc(cbData);
2294
2295 if (!pu8Data)
2296 return E_OUTOFMEMORY;
2297
2298#ifdef VBOX_WITH_OLD_VBVA_LOCK
2299 int vrc = displayTakeScreenshot(pVM, this, mpDrv, pu8Data, width, height);
2300#else
2301 int vrc = displayTakeScreenshot(pVM, mpDrv, pu8Data, width, height);
2302#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2303
2304 if (RT_SUCCESS(vrc))
2305 {
2306 /* Convert pixels to format expected by the API caller: [0] R, [1] G, [2] B, [3] A. */
2307 uint8_t *pu8 = pu8Data;
2308 unsigned cPixels = width * height;
2309 while (cPixels)
2310 {
2311 uint8_t u8 = pu8[0];
2312 pu8[0] = pu8[2];
2313 pu8[2] = u8;
2314 pu8[3] = 0xff;
2315 cPixels--;
2316 pu8 += 4;
2317 }
2318
2319 com::SafeArray<BYTE> screenData (cbData);
2320 for (unsigned i = 0; i < cbData; i++)
2321 screenData[i] = pu8Data[i];
2322 screenData.detachTo(ComSafeArrayOutArg(aScreenData));
2323 }
2324 else if (vrc == VERR_NOT_IMPLEMENTED)
2325 rc = setError (E_NOTIMPL,
2326 tr ("This feature is not implemented"));
2327 else
2328 rc = setError (VBOX_E_IPRT_ERROR,
2329 tr ("Could not take a screenshot (%Rrc)"), vrc);
2330
2331 LogFlowFunc (("rc=%08X\n", rc));
2332 LogFlowFuncLeave();
2333 return rc;
2334}
2335
2336#ifdef VBOX_WITH_OLD_VBVA_LOCK
2337int Display::DrawToScreenEMT(Display *pDisplay, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height)
2338{
2339 int rc;
2340 pDisplay->vbvaLock();
2341 rc = pDisplay->mpDrv->pUpPort->pfnDisplayBlt(pDisplay->mpDrv->pUpPort, address, x, y, width, height);
2342 pDisplay->vbvaUnlock();
2343 return rc;
2344}
2345#endif /* VBOX_WITH_OLD_VBVA_LOCK */
2346
2347STDMETHODIMP Display::DrawToScreen (BYTE *address, ULONG x, ULONG y,
2348 ULONG width, ULONG height)
2349{
2350 /// @todo (r=dmik) this function may take too long to complete if the VM
2351 // is doing something like saving state right now. Which, in case if it
2352 // is called on the GUI thread, will make it unresponsive. We should
2353 // check the machine state here (by enclosing the check and VMRequCall
2354 // within the Console lock to make it atomic).
2355
2356 LogFlowFuncEnter();
2357 LogFlowFunc (("address=%p, x=%d, y=%d, width=%d, height=%d\n",
2358 (void *)address, x, y, width, height));
2359
2360 CheckComArgNotNull(address);
2361 CheckComArgExpr(width, width != 0);
2362 CheckComArgExpr(height, height != 0);
2363
2364 AutoCaller autoCaller(this);
2365 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2366
2367 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2368
2369 CHECK_CONSOLE_DRV (mpDrv);
2370
2371 Console::SafeVMPtr pVM(mParent);
2372 if (FAILED(pVM.rc())) return pVM.rc();
2373
2374 /*
2375 * Again we're lazy and make the graphics device do all the
2376 * dirty conversion work.
2377 */
2378#ifdef VBOX_WITH_OLD_VBVA_LOCK
2379 int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)Display::DrawToScreenEMT, 6,
2380 this, address, x, y, width, height);
2381#else
2382 int rcVBox = VMR3ReqCallWait(pVM, VMCPUID_ANY, (PFNRT)mpDrv->pUpPort->pfnDisplayBlt, 6,
2383 mpDrv->pUpPort, address, x, y, width, height);
2384#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2385
2386 /*
2387 * If the function returns not supported, we'll have to do all the
2388 * work ourselves using the framebuffer.
2389 */
2390 HRESULT rc = S_OK;
2391 if (rcVBox == VERR_NOT_SUPPORTED || rcVBox == VERR_NOT_IMPLEMENTED)
2392 {
2393 /** @todo implement generic fallback for screen blitting. */
2394 rc = E_NOTIMPL;
2395 }
2396 else if (RT_FAILURE(rcVBox))
2397 rc = setError (VBOX_E_IPRT_ERROR,
2398 tr ("Could not draw to the screen (%Rrc)"), rcVBox);
2399//@todo
2400// else
2401// {
2402// /* All ok. Redraw the screen. */
2403// handleDisplayUpdate (x, y, width, height);
2404// }
2405
2406 LogFlowFunc (("rc=%08X\n", rc));
2407 LogFlowFuncLeave();
2408 return rc;
2409}
2410
2411#ifdef VBOX_WITH_OLD_VBVA_LOCK
2412void Display::InvalidateAndUpdateEMT(Display *pDisplay)
2413{
2414 pDisplay->vbvaLock();
2415 pDisplay->mpDrv->pUpPort->pfnUpdateDisplayAll(pDisplay->mpDrv->pUpPort);
2416 pDisplay->vbvaUnlock();
2417}
2418#endif /* VBOX_WITH_OLD_VBVA_LOCK */
2419
2420/**
2421 * Does a full invalidation of the VM display and instructs the VM
2422 * to update it immediately.
2423 *
2424 * @returns COM status code
2425 */
2426STDMETHODIMP Display::InvalidateAndUpdate()
2427{
2428 LogFlowFuncEnter();
2429
2430 AutoCaller autoCaller(this);
2431 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2432
2433 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
2434
2435 CHECK_CONSOLE_DRV (mpDrv);
2436
2437 Console::SafeVMPtr pVM(mParent);
2438 if (FAILED(pVM.rc())) return pVM.rc();
2439
2440 HRESULT rc = S_OK;
2441
2442 LogFlowFunc (("Sending DPYUPDATE request\n"));
2443
2444 /* Have to leave the lock when calling EMT. */
2445 alock.leave ();
2446
2447 /* pdm.h says that this has to be called from the EMT thread */
2448#ifdef VBOX_WITH_OLD_VBVA_LOCK
2449 int rcVBox = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY, (PFNRT)Display::InvalidateAndUpdateEMT,
2450 1, this);
2451#else
2452 int rcVBox = VMR3ReqCallVoidWait(pVM, VMCPUID_ANY,
2453 (PFNRT)mpDrv->pUpPort->pfnUpdateDisplayAll, 1, mpDrv->pUpPort);
2454#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2455 alock.enter ();
2456
2457 if (RT_FAILURE(rcVBox))
2458 rc = setError (VBOX_E_IPRT_ERROR,
2459 tr ("Could not invalidate and update the screen (%Rrc)"), rcVBox);
2460
2461 LogFlowFunc (("rc=%08X\n", rc));
2462 LogFlowFuncLeave();
2463 return rc;
2464}
2465
2466/**
2467 * Notification that the framebuffer has completed the
2468 * asynchronous resize processing
2469 *
2470 * @returns COM status code
2471 */
2472STDMETHODIMP Display::ResizeCompleted(ULONG aScreenId)
2473{
2474 LogFlowFunc (("\n"));
2475
2476 /// @todo (dmik) can we AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); here?
2477 // do it when we switch this class to VirtualBoxBase_NEXT.
2478 // This will require general code review and may add some details.
2479 // In particular, we may want to check whether EMT is really waiting for
2480 // this notification, etc. It might be also good to obey the caller to make
2481 // sure this method is not called from more than one thread at a time
2482 // (and therefore don't use Display lock at all here to save some
2483 // milliseconds).
2484 AutoCaller autoCaller(this);
2485 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2486
2487 /* this is only valid for external framebuffers */
2488 if (maFramebuffers[aScreenId].pFramebuffer == NULL)
2489 return setError (VBOX_E_NOT_SUPPORTED,
2490 tr ("Resize completed notification is valid only "
2491 "for external framebuffers"));
2492
2493 /* Set the flag indicating that the resize has completed and display
2494 * data need to be updated. */
2495 bool f = ASMAtomicCmpXchgU32 (&maFramebuffers[aScreenId].u32ResizeStatus,
2496 ResizeStatus_UpdateDisplayData, ResizeStatus_InProgress);
2497 AssertRelease(f);NOREF(f);
2498
2499 return S_OK;
2500}
2501
2502/**
2503 * Notification that the framebuffer has completed the
2504 * asynchronous update processing
2505 *
2506 * @returns COM status code
2507 */
2508STDMETHODIMP Display::UpdateCompleted()
2509{
2510 LogFlowFunc (("\n"));
2511
2512 /// @todo (dmik) can we AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); here?
2513 // do it when we switch this class to VirtualBoxBase_NEXT.
2514 // Tthis will require general code review and may add some details.
2515 // In particular, we may want to check whether EMT is really waiting for
2516 // this notification, etc. It might be also good to obey the caller to make
2517 // sure this method is not called from more than one thread at a time
2518 // (and therefore don't use Display lock at all here to save some
2519 // milliseconds).
2520 AutoCaller autoCaller(this);
2521 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2522
2523 /* this is only valid for external framebuffers */
2524 if (maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer == NULL)
2525 return setError (VBOX_E_NOT_SUPPORTED,
2526 tr ("Resize completed notification is valid only "
2527 "for external framebuffers"));
2528
2529 return S_OK;
2530}
2531
2532STDMETHODIMP Display::CompleteVHWACommand(BYTE *pCommand)
2533{
2534#ifdef VBOX_WITH_VIDEOHWACCEL
2535 mpDrv->pVBVACallbacks->pfnVHWACommandCompleteAsynch(mpDrv->pVBVACallbacks, (PVBOXVHWACMD)pCommand);
2536 return S_OK;
2537#else
2538 return E_NOTIMPL;
2539#endif
2540}
2541
2542// private methods
2543/////////////////////////////////////////////////////////////////////////////
2544
2545/**
2546 * Helper to update the display information from the framebuffer.
2547 *
2548 * @param aCheckParams true to compare the parameters of the current framebuffer
2549 * and the new one and issue handleDisplayResize()
2550 * if they differ.
2551 * @thread EMT
2552 */
2553void Display::updateDisplayData (bool aCheckParams /* = false */)
2554{
2555 /* the driver might not have been constructed yet */
2556 if (!mpDrv)
2557 return;
2558
2559#if DEBUG
2560 /*
2561 * Sanity check. Note that this method may be called on EMT after Console
2562 * has started the power down procedure (but before our #drvDestruct() is
2563 * called, in which case pVM will aleady be NULL but mpDrv will not). Since
2564 * we don't really need pVM to proceed, we avoid this check in the release
2565 * build to save some ms (necessary to construct SafeVMPtrQuiet) in this
2566 * time-critical method.
2567 */
2568 Console::SafeVMPtrQuiet pVM (mParent);
2569 if (pVM.isOk())
2570 VM_ASSERT_EMT (pVM.raw());
2571#endif
2572
2573 /* The method is only relevant to the primary framebuffer. */
2574 IFramebuffer *pFramebuffer = maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer;
2575
2576 if (pFramebuffer)
2577 {
2578 HRESULT rc;
2579 BYTE *address = 0;
2580 rc = pFramebuffer->COMGETTER(Address) (&address);
2581 AssertComRC (rc);
2582 ULONG bytesPerLine = 0;
2583 rc = pFramebuffer->COMGETTER(BytesPerLine) (&bytesPerLine);
2584 AssertComRC (rc);
2585 ULONG bitsPerPixel = 0;
2586 rc = pFramebuffer->COMGETTER(BitsPerPixel) (&bitsPerPixel);
2587 AssertComRC (rc);
2588 ULONG width = 0;
2589 rc = pFramebuffer->COMGETTER(Width) (&width);
2590 AssertComRC (rc);
2591 ULONG height = 0;
2592 rc = pFramebuffer->COMGETTER(Height) (&height);
2593 AssertComRC (rc);
2594
2595 /*
2596 * Check current parameters with new ones and issue handleDisplayResize()
2597 * to let the new frame buffer adjust itself properly. Note that it will
2598 * result into a recursive updateDisplayData() call but with
2599 * aCheckOld = false.
2600 */
2601 if (aCheckParams &&
2602 (mLastAddress != address ||
2603 mLastBytesPerLine != bytesPerLine ||
2604 mLastBitsPerPixel != bitsPerPixel ||
2605 mLastWidth != (int) width ||
2606 mLastHeight != (int) height))
2607 {
2608 handleDisplayResize (VBOX_VIDEO_PRIMARY_SCREEN, mLastBitsPerPixel,
2609 mLastAddress,
2610 mLastBytesPerLine,
2611 mLastWidth,
2612 mLastHeight);
2613 return;
2614 }
2615
2616 mpDrv->IConnector.pu8Data = (uint8_t *) address;
2617 mpDrv->IConnector.cbScanline = bytesPerLine;
2618 mpDrv->IConnector.cBits = bitsPerPixel;
2619 mpDrv->IConnector.cx = width;
2620 mpDrv->IConnector.cy = height;
2621 }
2622 else
2623 {
2624 /* black hole */
2625 mpDrv->IConnector.pu8Data = NULL;
2626 mpDrv->IConnector.cbScanline = 0;
2627 mpDrv->IConnector.cBits = 0;
2628 mpDrv->IConnector.cx = 0;
2629 mpDrv->IConnector.cy = 0;
2630 }
2631}
2632
2633/**
2634 * Changes the current frame buffer. Called on EMT to avoid both
2635 * race conditions and excessive locking.
2636 *
2637 * @note locks this object for writing
2638 * @thread EMT
2639 */
2640/* static */
2641DECLCALLBACK(int) Display::changeFramebuffer (Display *that, IFramebuffer *aFB,
2642 unsigned uScreenId)
2643{
2644 LogFlowFunc (("uScreenId = %d\n", uScreenId));
2645
2646 AssertReturn(that, VERR_INVALID_PARAMETER);
2647 AssertReturn(uScreenId < that->mcMonitors, VERR_INVALID_PARAMETER);
2648
2649 AutoCaller autoCaller(that);
2650 if (FAILED(autoCaller.rc())) return autoCaller.rc();
2651
2652 AutoWriteLock alock(that COMMA_LOCKVAL_SRC_POS);
2653
2654 DISPLAYFBINFO *pDisplayFBInfo = &that->maFramebuffers[uScreenId];
2655 pDisplayFBInfo->pFramebuffer = aFB;
2656
2657 that->mParent->consoleVRDPServer()->SendResize ();
2658
2659 that->updateDisplayData (true /* aCheckParams */);
2660
2661 return VINF_SUCCESS;
2662}
2663
2664/**
2665 * Handle display resize event issued by the VGA device for the primary screen.
2666 *
2667 * @see PDMIDISPLAYCONNECTOR::pfnResize
2668 */
2669DECLCALLBACK(int) Display::displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface,
2670 uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy)
2671{
2672 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
2673
2674 LogFlowFunc (("bpp %d, pvVRAM %p, cbLine %d, cx %d, cy %d\n",
2675 bpp, pvVRAM, cbLine, cx, cy));
2676
2677 return pDrv->pDisplay->handleDisplayResize(VBOX_VIDEO_PRIMARY_SCREEN, bpp, pvVRAM, cbLine, cx, cy);
2678}
2679
2680/**
2681 * Handle display update.
2682 *
2683 * @see PDMIDISPLAYCONNECTOR::pfnUpdateRect
2684 */
2685DECLCALLBACK(void) Display::displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
2686 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
2687{
2688 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
2689
2690#ifdef DEBUG_sunlover
2691 LogFlowFunc (("mfVideoAccelEnabled = %d, %d,%d %dx%d\n",
2692 pDrv->pDisplay->mfVideoAccelEnabled, x, y, cx, cy));
2693#endif /* DEBUG_sunlover */
2694
2695 /* This call does update regardless of VBVA status.
2696 * But in VBVA mode this is called only as result of
2697 * pfnUpdateDisplayAll in the VGA device.
2698 */
2699
2700 pDrv->pDisplay->handleDisplayUpdate(x, y, cx, cy);
2701}
2702
2703/**
2704 * Periodic display refresh callback.
2705 *
2706 * @see PDMIDISPLAYCONNECTOR::pfnRefresh
2707 */
2708DECLCALLBACK(void) Display::displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface)
2709{
2710 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
2711
2712#ifdef DEBUG_sunlover
2713 STAM_PROFILE_START(&StatDisplayRefresh, a);
2714#endif /* DEBUG_sunlover */
2715
2716#ifdef DEBUG_sunlover_2
2717 LogFlowFunc (("pDrv->pDisplay->mfVideoAccelEnabled = %d\n",
2718 pDrv->pDisplay->mfVideoAccelEnabled));
2719#endif /* DEBUG_sunlover_2 */
2720
2721 Display *pDisplay = pDrv->pDisplay;
2722 bool fNoUpdate = false; /* Do not update the display if any of the framebuffers is being resized. */
2723 unsigned uScreenId;
2724
2725 for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
2726 {
2727 DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
2728
2729 /* Check the resize status. The status can be checked normally because
2730 * the status affects only the EMT.
2731 */
2732 uint32_t u32ResizeStatus = pFBInfo->u32ResizeStatus;
2733
2734 if (u32ResizeStatus == ResizeStatus_UpdateDisplayData)
2735 {
2736 LogFlowFunc (("ResizeStatus_UpdateDisplayData %d\n", uScreenId));
2737 fNoUpdate = true; /* Always set it here, because pfnUpdateDisplayAll can cause a new resize. */
2738 /* The framebuffer was resized and display data need to be updated. */
2739 pDisplay->handleResizeCompletedEMT ();
2740 if (pFBInfo->u32ResizeStatus != ResizeStatus_Void)
2741 {
2742 /* The resize status could be not Void here because a pending resize is issued. */
2743 continue;
2744 }
2745 /* Continue with normal processing because the status here is ResizeStatus_Void. */
2746 if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
2747 {
2748 /* Repaint the display because VM continued to run during the framebuffer resize. */
2749 if (!pFBInfo->pFramebuffer.isNull())
2750#ifdef VBOX_WITH_OLD_VBVA_LOCK
2751 {
2752 pDisplay->vbvaLock();
2753#endif /* VBOX_WITH_OLD_VBVA_LOCK */
2754 pDrv->pUpPort->pfnUpdateDisplayAll(pDrv->pUpPort);
2755#ifdef VBOX_WITH_OLD_VBVA_LOCK
2756 pDisplay->vbvaUnlock();
2757 }
2758#endif /* VBOX_WITH_OLD_VBVA_LOCK */
2759 }
2760 }
2761 else if (u32ResizeStatus == ResizeStatus_InProgress)
2762 {
2763 /* The framebuffer is being resized. Do not call the VGA device back. Immediately return. */
2764 LogFlowFunc (("ResizeStatus_InProcess\n"));
2765 fNoUpdate = true;
2766 continue;
2767 }
2768 }
2769
2770 if (!fNoUpdate)
2771 {
2772#ifdef VBOX_WITH_OLD_VBVA_LOCK
2773 int rc = pDisplay->videoAccelRefreshProcess();
2774
2775 if (rc != VINF_TRY_AGAIN) /* Means 'do nothing' here. */
2776 {
2777 if (rc == VWRN_INVALID_STATE)
2778 {
2779 /* No VBVA do a display update. */
2780 DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN];
2781 if (!pFBInfo->pFramebuffer.isNull() && pFBInfo->u32ResizeStatus == ResizeStatus_Void)
2782 {
2783 Assert(pDrv->IConnector.pu8Data);
2784 pDisplay->vbvaLock();
2785 pDrv->pUpPort->pfnUpdateDisplay(pDrv->pUpPort);
2786 pDisplay->vbvaUnlock();
2787 }
2788 }
2789
2790 /* Inform the VRDP server that the current display update sequence is
2791 * completed. At this moment the framebuffer memory contains a definite
2792 * image, that is synchronized with the orders already sent to VRDP client.
2793 * The server can now process redraw requests from clients or initial
2794 * fullscreen updates for new clients.
2795 */
2796 for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
2797 {
2798 DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
2799
2800 if (!pFBInfo->pFramebuffer.isNull() && pFBInfo->u32ResizeStatus == ResizeStatus_Void)
2801 {
2802 Assert (pDisplay->mParent && pDisplay->mParent->consoleVRDPServer());
2803 pDisplay->mParent->consoleVRDPServer()->SendUpdate (uScreenId, NULL, 0);
2804 }
2805 }
2806 }
2807#else
2808 if (pDisplay->mfPendingVideoAccelEnable)
2809 {
2810 /* Acceleration was enabled while machine was not yet running
2811 * due to restoring from saved state. Update entire display and
2812 * actually enable acceleration.
2813 */
2814 Assert(pDisplay->mpPendingVbvaMemory);
2815
2816 /* Acceleration can not be yet enabled.*/
2817 Assert(pDisplay->mpVbvaMemory == NULL);
2818 Assert(!pDisplay->mfVideoAccelEnabled);
2819
2820 if (pDisplay->mfMachineRunning)
2821 {
2822 pDisplay->VideoAccelEnable (pDisplay->mfPendingVideoAccelEnable,
2823 pDisplay->mpPendingVbvaMemory);
2824
2825 /* Reset the pending state. */
2826 pDisplay->mfPendingVideoAccelEnable = false;
2827 pDisplay->mpPendingVbvaMemory = NULL;
2828 }
2829 }
2830 else
2831 {
2832 Assert(pDisplay->mpPendingVbvaMemory == NULL);
2833
2834 if (pDisplay->mfVideoAccelEnabled)
2835 {
2836 Assert(pDisplay->mpVbvaMemory);
2837 pDisplay->VideoAccelFlush ();
2838 }
2839 else
2840 {
2841 DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN];
2842 if (!pFBInfo->pFramebuffer.isNull())
2843 {
2844 Assert(pDrv->IConnector.pu8Data);
2845 Assert(pFBInfo->u32ResizeStatus == ResizeStatus_Void);
2846 pDrv->pUpPort->pfnUpdateDisplay(pDrv->pUpPort);
2847 }
2848 }
2849
2850 /* Inform the VRDP server that the current display update sequence is
2851 * completed. At this moment the framebuffer memory contains a definite
2852 * image, that is synchronized with the orders already sent to VRDP client.
2853 * The server can now process redraw requests from clients or initial
2854 * fullscreen updates for new clients.
2855 */
2856 for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
2857 {
2858 DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
2859
2860 if (!pFBInfo->pFramebuffer.isNull() && pFBInfo->u32ResizeStatus == ResizeStatus_Void)
2861 {
2862 Assert (pDisplay->mParent && pDisplay->mParent->consoleVRDPServer());
2863 pDisplay->mParent->consoleVRDPServer()->SendUpdate (uScreenId, NULL, 0);
2864 }
2865 }
2866 }
2867#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2868 }
2869
2870#ifdef DEBUG_sunlover
2871 STAM_PROFILE_STOP(&StatDisplayRefresh, a);
2872#endif /* DEBUG_sunlover */
2873#ifdef DEBUG_sunlover_2
2874 LogFlowFunc (("leave\n"));
2875#endif /* DEBUG_sunlover_2 */
2876}
2877
2878/**
2879 * Reset notification
2880 *
2881 * @see PDMIDISPLAYCONNECTOR::pfnReset
2882 */
2883DECLCALLBACK(void) Display::displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface)
2884{
2885 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
2886
2887 LogFlowFunc (("\n"));
2888
2889 /* Disable VBVA mode. */
2890 pDrv->pDisplay->VideoAccelEnable (false, NULL);
2891}
2892
2893/**
2894 * LFBModeChange notification
2895 *
2896 * @see PDMIDISPLAYCONNECTOR::pfnLFBModeChange
2897 */
2898DECLCALLBACK(void) Display::displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled)
2899{
2900 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
2901
2902 LogFlowFunc (("fEnabled=%d\n", fEnabled));
2903
2904 NOREF(fEnabled);
2905
2906 /* Disable VBVA mode in any case. The guest driver reenables VBVA mode if necessary. */
2907#ifdef VBOX_WITH_OLD_VBVA_LOCK
2908 /* This is called under DevVGA lock. Postpone disabling VBVA, do it in the refresh timer. */
2909 ASMAtomicWriteU32(&pDrv->pDisplay->mfu32PendingVideoAccelDisable, true);
2910#else
2911 pDrv->pDisplay->VideoAccelEnable (false, NULL);
2912#endif /* !VBOX_WITH_OLD_VBVA_LOCK */
2913}
2914
2915/**
2916 * Adapter information change notification.
2917 *
2918 * @see PDMIDISPLAYCONNECTOR::pfnProcessAdapterData
2919 */
2920DECLCALLBACK(void) Display::displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize)
2921{
2922 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
2923
2924 if (pvVRAM == NULL)
2925 {
2926 unsigned i;
2927 for (i = 0; i < pDrv->pDisplay->mcMonitors; i++)
2928 {
2929 DISPLAYFBINFO *pFBInfo = &pDrv->pDisplay->maFramebuffers[i];
2930
2931 pFBInfo->u32Offset = 0;
2932 pFBInfo->u32MaxFramebufferSize = 0;
2933 pFBInfo->u32InformationSize = 0;
2934 }
2935 }
2936#ifndef VBOX_WITH_HGSMI
2937 else
2938 {
2939 uint8_t *pu8 = (uint8_t *)pvVRAM;
2940 pu8 += u32VRAMSize - VBOX_VIDEO_ADAPTER_INFORMATION_SIZE;
2941
2942 // @todo
2943 uint8_t *pu8End = pu8 + VBOX_VIDEO_ADAPTER_INFORMATION_SIZE;
2944
2945 VBOXVIDEOINFOHDR *pHdr;
2946
2947 for (;;)
2948 {
2949 pHdr = (VBOXVIDEOINFOHDR *)pu8;
2950 pu8 += sizeof (VBOXVIDEOINFOHDR);
2951
2952 if (pu8 >= pu8End)
2953 {
2954 LogRel(("VBoxVideo: Guest adapter information overflow!!!\n"));
2955 break;
2956 }
2957
2958 if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_DISPLAY)
2959 {
2960 if (pHdr->u16Length != sizeof (VBOXVIDEOINFODISPLAY))
2961 {
2962 LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "DISPLAY", pHdr->u16Length));
2963 break;
2964 }
2965
2966 VBOXVIDEOINFODISPLAY *pDisplay = (VBOXVIDEOINFODISPLAY *)pu8;
2967
2968 if (pDisplay->u32Index >= pDrv->pDisplay->mcMonitors)
2969 {
2970 LogRel(("VBoxVideo: Guest adapter information invalid display index %d!!!\n", pDisplay->u32Index));
2971 break;
2972 }
2973
2974 DISPLAYFBINFO *pFBInfo = &pDrv->pDisplay->maFramebuffers[pDisplay->u32Index];
2975
2976 pFBInfo->u32Offset = pDisplay->u32Offset;
2977 pFBInfo->u32MaxFramebufferSize = pDisplay->u32FramebufferSize;
2978 pFBInfo->u32InformationSize = pDisplay->u32InformationSize;
2979
2980 LogFlow(("VBOX_VIDEO_INFO_TYPE_DISPLAY: %d: at 0x%08X, size 0x%08X, info 0x%08X\n", pDisplay->u32Index, pDisplay->u32Offset, pDisplay->u32FramebufferSize, pDisplay->u32InformationSize));
2981 }
2982 else if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_QUERY_CONF32)
2983 {
2984 if (pHdr->u16Length != sizeof (VBOXVIDEOINFOQUERYCONF32))
2985 {
2986 LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "CONF32", pHdr->u16Length));
2987 break;
2988 }
2989
2990 VBOXVIDEOINFOQUERYCONF32 *pConf32 = (VBOXVIDEOINFOQUERYCONF32 *)pu8;
2991
2992 switch (pConf32->u32Index)
2993 {
2994 case VBOX_VIDEO_QCI32_MONITOR_COUNT:
2995 {
2996 pConf32->u32Value = pDrv->pDisplay->mcMonitors;
2997 } break;
2998
2999 case VBOX_VIDEO_QCI32_OFFSCREEN_HEAP_SIZE:
3000 {
3001 /* @todo make configurable. */
3002 pConf32->u32Value = _1M;
3003 } break;
3004
3005 default:
3006 LogRel(("VBoxVideo: CONF32 %d not supported!!! Skipping.\n", pConf32->u32Index));
3007 }
3008 }
3009 else if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_END)
3010 {
3011 if (pHdr->u16Length != 0)
3012 {
3013 LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "END", pHdr->u16Length));
3014 break;
3015 }
3016
3017 break;
3018 }
3019 else if (pHdr->u8Type != VBOX_VIDEO_INFO_TYPE_NV_HEAP) /** @todo why is Additions/WINNT/Graphics/Miniport/VBoxVideo.cpp pushing this to us? */
3020 {
3021 LogRel(("Guest adapter information contains unsupported type %d. The block has been skipped.\n", pHdr->u8Type));
3022 }
3023
3024 pu8 += pHdr->u16Length;
3025 }
3026 }
3027#endif /* !VBOX_WITH_HGSMI */
3028}
3029
3030/**
3031 * Display information change notification.
3032 *
3033 * @see PDMIDISPLAYCONNECTOR::pfnProcessDisplayData
3034 */
3035DECLCALLBACK(void) Display::displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId)
3036{
3037 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3038
3039 if (uScreenId >= pDrv->pDisplay->mcMonitors)
3040 {
3041 LogRel(("VBoxVideo: Guest display information invalid display index %d!!!\n", uScreenId));
3042 return;
3043 }
3044
3045 /* Get the display information structure. */
3046 DISPLAYFBINFO *pFBInfo = &pDrv->pDisplay->maFramebuffers[uScreenId];
3047
3048 uint8_t *pu8 = (uint8_t *)pvVRAM;
3049 pu8 += pFBInfo->u32Offset + pFBInfo->u32MaxFramebufferSize;
3050
3051 // @todo
3052 uint8_t *pu8End = pu8 + pFBInfo->u32InformationSize;
3053
3054 VBOXVIDEOINFOHDR *pHdr;
3055
3056 for (;;)
3057 {
3058 pHdr = (VBOXVIDEOINFOHDR *)pu8;
3059 pu8 += sizeof (VBOXVIDEOINFOHDR);
3060
3061 if (pu8 >= pu8End)
3062 {
3063 LogRel(("VBoxVideo: Guest display information overflow!!!\n"));
3064 break;
3065 }
3066
3067 if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_SCREEN)
3068 {
3069 if (pHdr->u16Length != sizeof (VBOXVIDEOINFOSCREEN))
3070 {
3071 LogRel(("VBoxVideo: Guest display information %s invalid length %d!!!\n", "SCREEN", pHdr->u16Length));
3072 break;
3073 }
3074
3075 VBOXVIDEOINFOSCREEN *pScreen = (VBOXVIDEOINFOSCREEN *)pu8;
3076
3077 pFBInfo->xOrigin = pScreen->xOrigin;
3078 pFBInfo->yOrigin = pScreen->yOrigin;
3079
3080 pFBInfo->w = pScreen->u16Width;
3081 pFBInfo->h = pScreen->u16Height;
3082
3083 LogFlow(("VBOX_VIDEO_INFO_TYPE_SCREEN: (%p) %d: at %d,%d, linesize 0x%X, size %dx%d, bpp %d, flags 0x%02X\n",
3084 pHdr, uScreenId, pScreen->xOrigin, pScreen->yOrigin, pScreen->u32LineSize, pScreen->u16Width, pScreen->u16Height, pScreen->bitsPerPixel, pScreen->u8Flags));
3085
3086 if (uScreenId != VBOX_VIDEO_PRIMARY_SCREEN)
3087 {
3088 /* Primary screen resize is initiated by the VGA device. */
3089 pDrv->pDisplay->handleDisplayResize(uScreenId, pScreen->bitsPerPixel, (uint8_t *)pvVRAM + pFBInfo->u32Offset, pScreen->u32LineSize, pScreen->u16Width, pScreen->u16Height);
3090 }
3091 }
3092 else if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_END)
3093 {
3094 if (pHdr->u16Length != 0)
3095 {
3096 LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "END", pHdr->u16Length));
3097 break;
3098 }
3099
3100 break;
3101 }
3102 else if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_HOST_EVENTS)
3103 {
3104 if (pHdr->u16Length != sizeof (VBOXVIDEOINFOHOSTEVENTS))
3105 {
3106 LogRel(("VBoxVideo: Guest display information %s invalid length %d!!!\n", "HOST_EVENTS", pHdr->u16Length));
3107 break;
3108 }
3109
3110 VBOXVIDEOINFOHOSTEVENTS *pHostEvents = (VBOXVIDEOINFOHOSTEVENTS *)pu8;
3111
3112 pFBInfo->pHostEvents = pHostEvents;
3113
3114 LogFlow(("VBOX_VIDEO_INFO_TYPE_HOSTEVENTS: (%p)\n",
3115 pHostEvents));
3116 }
3117 else if (pHdr->u8Type == VBOX_VIDEO_INFO_TYPE_LINK)
3118 {
3119 if (pHdr->u16Length != sizeof (VBOXVIDEOINFOLINK))
3120 {
3121 LogRel(("VBoxVideo: Guest adapter information %s invalid length %d!!!\n", "LINK", pHdr->u16Length));
3122 break;
3123 }
3124
3125 VBOXVIDEOINFOLINK *pLink = (VBOXVIDEOINFOLINK *)pu8;
3126 pu8 += pLink->i32Offset;
3127 }
3128 else
3129 {
3130 LogRel(("Guest display information contains unsupported type %d\n", pHdr->u8Type));
3131 }
3132
3133 pu8 += pHdr->u16Length;
3134 }
3135}
3136
3137#ifdef VBOX_WITH_VIDEOHWACCEL
3138
3139void Display::handleVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand)
3140{
3141 unsigned id = (unsigned)pCommand->iDisplay;
3142 int rc = VINF_SUCCESS;
3143 if(id < mcMonitors)
3144 {
3145 IFramebuffer *pFramebuffer = maFramebuffers[id].pFramebuffer;
3146
3147 if (pFramebuffer != NULL)
3148 {
3149 pFramebuffer->Lock();
3150
3151 HRESULT hr = pFramebuffer->ProcessVHWACommand((BYTE*)pCommand);
3152 if(FAILED(hr))
3153 {
3154 rc = (hr == E_NOTIMPL) ? VERR_NOT_IMPLEMENTED : VERR_GENERAL_FAILURE;
3155 }
3156
3157 pFramebuffer->Unlock();
3158 }
3159 else
3160 {
3161 rc = VERR_NOT_IMPLEMENTED;
3162 }
3163 }
3164 else
3165 {
3166 rc = VERR_INVALID_PARAMETER;
3167 }
3168
3169 if(RT_FAILURE(rc))
3170 {
3171 /* tell the guest the command is complete */
3172 pCommand->Flags &= (~VBOXVHWACMD_FLAG_HG_ASYNCH);
3173 pCommand->rc = rc;
3174 }
3175}
3176
3177DECLCALLBACK(void) Display::displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand)
3178{
3179 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3180
3181 pDrv->pDisplay->handleVHWACommandProcess(pInterface, pCommand);
3182}
3183#endif
3184
3185#ifdef VBOX_WITH_HGSMI
3186DECLCALLBACK(int) Display::displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags)
3187{
3188 LogFlowFunc(("uScreenId %d\n", uScreenId));
3189
3190 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3191 Display *pThis = pDrv->pDisplay;
3192
3193 pThis->maFramebuffers[uScreenId].fVBVAEnabled = true;
3194 pThis->maFramebuffers[uScreenId].pVBVAHostFlags = pHostFlags;
3195
3196 vbvaSetMemoryFlagsHGSMI(uScreenId, pThis->mfu32SupportedOrders, pThis->mfVideoAccelVRDP, &pThis->maFramebuffers[uScreenId]);
3197
3198 return VINF_SUCCESS;
3199}
3200
3201DECLCALLBACK(void) Display::displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId)
3202{
3203 LogFlowFunc(("uScreenId %d\n", uScreenId));
3204
3205 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3206 Display *pThis = pDrv->pDisplay;
3207
3208 pThis->maFramebuffers[uScreenId].fVBVAEnabled = false;
3209
3210 vbvaSetMemoryFlagsHGSMI(uScreenId, 0, false, &pThis->maFramebuffers[uScreenId]);
3211
3212 pThis->maFramebuffers[uScreenId].pVBVAHostFlags = NULL;
3213}
3214
3215DECLCALLBACK(void) Display::displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId)
3216{
3217 LogFlowFunc(("uScreenId %d\n", uScreenId));
3218
3219 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3220 Display *pThis = pDrv->pDisplay;
3221 DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[uScreenId];
3222
3223 if (ASMAtomicReadU32(&pThis->mu32UpdateVBVAFlags) > 0)
3224 {
3225 vbvaSetMemoryFlagsAllHGSMI(pThis->mfu32SupportedOrders, pThis->mfVideoAccelVRDP, pThis->maFramebuffers, pThis->mcMonitors);
3226 ASMAtomicDecU32(&pThis->mu32UpdateVBVAFlags);
3227 }
3228
3229 if (RT_LIKELY(pFBInfo->u32ResizeStatus == ResizeStatus_Void))
3230 {
3231 if (RT_UNLIKELY(pFBInfo->cVBVASkipUpdate != 0))
3232 {
3233 /* Some updates were skipped. Note: displayVBVAUpdate* callbacks are called
3234 * under display device lock, so thread safe.
3235 */
3236 pFBInfo->cVBVASkipUpdate = 0;
3237 pThis->handleDisplayUpdate(pFBInfo->vbvaSkippedRect.xLeft,
3238 pFBInfo->vbvaSkippedRect.yTop,
3239 pFBInfo->vbvaSkippedRect.xRight - pFBInfo->vbvaSkippedRect.xLeft,
3240 pFBInfo->vbvaSkippedRect.yBottom - pFBInfo->vbvaSkippedRect.yTop);
3241 }
3242 }
3243 else
3244 {
3245 /* The framebuffer is being resized. */
3246 pFBInfo->cVBVASkipUpdate++;
3247 }
3248}
3249
3250DECLCALLBACK(void) Display::displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, const PVBVACMDHDR pCmd, size_t cbCmd)
3251{
3252 LogFlowFunc(("uScreenId %d pCmd %p cbCmd %d\n", uScreenId, pCmd, cbCmd));
3253
3254 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3255 Display *pThis = pDrv->pDisplay;
3256 DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[uScreenId];
3257
3258 if (RT_LIKELY(pFBInfo->cVBVASkipUpdate == 0))
3259 {
3260 if (pFBInfo->fDefaultFormat)
3261 {
3262 pDrv->pUpPort->pfnUpdateDisplayRect (pDrv->pUpPort, pCmd->x, pCmd->y, pCmd->w, pCmd->h);
3263 pThis->handleDisplayUpdate (pCmd->x + pFBInfo->xOrigin,
3264 pCmd->y + pFBInfo->yOrigin, pCmd->w, pCmd->h);
3265 }
3266
3267 pThis->mParent->consoleVRDPServer()->SendUpdate (uScreenId, pCmd, cbCmd);
3268 }
3269}
3270
3271DECLCALLBACK(void) Display::displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y, uint32_t cx, uint32_t cy)
3272{
3273 LogFlowFunc(("uScreenId %d %d,%d %dx%d\n", uScreenId, x, y, cx, cy));
3274
3275 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3276 Display *pThis = pDrv->pDisplay;
3277 DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[uScreenId];
3278
3279 /* @todo handleFramebufferUpdate (uScreenId,
3280 * x - pThis->maFramebuffers[uScreenId].xOrigin,
3281 * y - pThis->maFramebuffers[uScreenId].yOrigin,
3282 * cx, cy);
3283 */
3284 if (RT_LIKELY(pFBInfo->cVBVASkipUpdate == 0))
3285 {
3286 pThis->handleDisplayUpdate(x, y, cx, cy);
3287 }
3288 else
3289 {
3290 /* Save the updated rectangle. */
3291 int32_t xRight = x + cx;
3292 int32_t yBottom = y + cy;
3293
3294 if (pFBInfo->cVBVASkipUpdate == 1)
3295 {
3296 pFBInfo->vbvaSkippedRect.xLeft = x;
3297 pFBInfo->vbvaSkippedRect.yTop = y;
3298 pFBInfo->vbvaSkippedRect.xRight = xRight;
3299 pFBInfo->vbvaSkippedRect.yBottom = yBottom;
3300 }
3301 else
3302 {
3303 if (pFBInfo->vbvaSkippedRect.xLeft > x)
3304 {
3305 pFBInfo->vbvaSkippedRect.xLeft = x;
3306 }
3307 if (pFBInfo->vbvaSkippedRect.yTop > y)
3308 {
3309 pFBInfo->vbvaSkippedRect.yTop = y;
3310 }
3311 if (pFBInfo->vbvaSkippedRect.xRight < xRight)
3312 {
3313 pFBInfo->vbvaSkippedRect.xRight = xRight;
3314 }
3315 if (pFBInfo->vbvaSkippedRect.yBottom < yBottom)
3316 {
3317 pFBInfo->vbvaSkippedRect.yBottom = yBottom;
3318 }
3319 }
3320 }
3321}
3322
3323DECLCALLBACK(int) Display::displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, const PVBVAINFOVIEW pView, const PVBVAINFOSCREEN pScreen, void *pvVRAM)
3324{
3325 LogFlowFunc(("pScreen %p, pvVRAM %p\n", pScreen, pvVRAM));
3326
3327 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3328 Display *pThis = pDrv->pDisplay;
3329
3330 DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[pScreen->u32ViewIndex];
3331
3332 pFBInfo->u32Offset = pView->u32ViewOffset; /* Not used in HGSMI. */
3333 pFBInfo->u32MaxFramebufferSize = pView->u32MaxScreenSize; /* Not used in HGSMI. */
3334 pFBInfo->u32InformationSize = 0; /* Not used in HGSMI. */
3335
3336 pFBInfo->xOrigin = pScreen->i32OriginX;
3337 pFBInfo->yOrigin = pScreen->i32OriginY;
3338
3339 pFBInfo->w = pScreen->u32Width;
3340 pFBInfo->h = pScreen->u32Height;
3341
3342 return pThis->handleDisplayResize(pScreen->u32ViewIndex, pScreen->u16BitsPerPixel,
3343 (uint8_t *)pvVRAM + pScreen->u32StartOffset,
3344 pScreen->u32LineSize, pScreen->u32Width, pScreen->u32Height);
3345}
3346
3347DECLCALLBACK(int) Display::displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
3348 uint32_t xHot, uint32_t yHot,
3349 uint32_t cx, uint32_t cy,
3350 const void *pvShape)
3351{
3352 LogFlowFunc(("\n"));
3353
3354 PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
3355 Display *pThis = pDrv->pDisplay;
3356
3357 /* Tell the console about it */
3358 pDrv->pDisplay->mParent->onMousePointerShapeChange(fVisible, fAlpha,
3359 xHot, yHot, cx, cy, (void *)pvShape);
3360
3361 return VINF_SUCCESS;
3362}
3363#endif /* VBOX_WITH_HGSMI */
3364
3365/**
3366 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
3367 */
3368DECLCALLBACK(void *) Display::drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
3369{
3370 PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
3371 PDRVMAINDISPLAY pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINDISPLAY);
3372 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
3373 PDMIBASE_RETURN_INTERFACE(pszIID, PDMIDISPLAYCONNECTOR, &pDrv->IConnector);
3374 return NULL;
3375}
3376
3377
3378/**
3379 * Destruct a display driver instance.
3380 *
3381 * @returns VBox status.
3382 * @param pDrvIns The driver instance data.
3383 */
3384DECLCALLBACK(void) Display::drvDestruct(PPDMDRVINS pDrvIns)
3385{
3386 PDRVMAINDISPLAY pData = PDMINS_2_DATA(pDrvIns, PDRVMAINDISPLAY);
3387 LogFlowFunc (("iInstance=%d\n", pDrvIns->iInstance));
3388 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
3389
3390 if (pData->pDisplay)
3391 {
3392 AutoWriteLock displayLock(pData->pDisplay COMMA_LOCKVAL_SRC_POS);
3393 pData->pDisplay->mpDrv = NULL;
3394 pData->pDisplay->mpVMMDev = NULL;
3395 pData->pDisplay->mLastAddress = NULL;
3396 pData->pDisplay->mLastBytesPerLine = 0;
3397 pData->pDisplay->mLastBitsPerPixel = 0,
3398 pData->pDisplay->mLastWidth = 0;
3399 pData->pDisplay->mLastHeight = 0;
3400 }
3401}
3402
3403
3404/**
3405 * Construct a display driver instance.
3406 *
3407 * @copydoc FNPDMDRVCONSTRUCT
3408 */
3409DECLCALLBACK(int) Display::drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
3410{
3411 PDRVMAINDISPLAY pData = PDMINS_2_DATA(pDrvIns, PDRVMAINDISPLAY);
3412 LogFlowFunc (("iInstance=%d\n", pDrvIns->iInstance));
3413 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
3414
3415 /*
3416 * Validate configuration.
3417 */
3418 if (!CFGMR3AreValuesValid(pCfg, "Object\0"))
3419 return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
3420 AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
3421 ("Configuration error: Not possible to attach anything to this driver!\n"),
3422 VERR_PDM_DRVINS_NO_ATTACH);
3423
3424 /*
3425 * Init Interfaces.
3426 */
3427 pDrvIns->IBase.pfnQueryInterface = Display::drvQueryInterface;
3428
3429 pData->IConnector.pfnResize = Display::displayResizeCallback;
3430 pData->IConnector.pfnUpdateRect = Display::displayUpdateCallback;
3431 pData->IConnector.pfnRefresh = Display::displayRefreshCallback;
3432 pData->IConnector.pfnReset = Display::displayResetCallback;
3433 pData->IConnector.pfnLFBModeChange = Display::displayLFBModeChangeCallback;
3434 pData->IConnector.pfnProcessAdapterData = Display::displayProcessAdapterDataCallback;
3435 pData->IConnector.pfnProcessDisplayData = Display::displayProcessDisplayDataCallback;
3436#ifdef VBOX_WITH_VIDEOHWACCEL
3437 pData->IConnector.pfnVHWACommandProcess = Display::displayVHWACommandProcess;
3438#endif
3439#ifdef VBOX_WITH_HGSMI
3440 pData->IConnector.pfnVBVAEnable = Display::displayVBVAEnable;
3441 pData->IConnector.pfnVBVADisable = Display::displayVBVADisable;
3442 pData->IConnector.pfnVBVAUpdateBegin = Display::displayVBVAUpdateBegin;
3443 pData->IConnector.pfnVBVAUpdateProcess = Display::displayVBVAUpdateProcess;
3444 pData->IConnector.pfnVBVAUpdateEnd = Display::displayVBVAUpdateEnd;
3445 pData->IConnector.pfnVBVAResize = Display::displayVBVAResize;
3446 pData->IConnector.pfnVBVAMousePointerShape = Display::displayVBVAMousePointerShape;
3447#endif
3448
3449
3450 /*
3451 * Get the IDisplayPort interface of the above driver/device.
3452 */
3453 pData->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIDISPLAYPORT);
3454 if (!pData->pUpPort)
3455 {
3456 AssertMsgFailed(("Configuration error: No display port interface above!\n"));
3457 return VERR_PDM_MISSING_INTERFACE_ABOVE;
3458 }
3459#if defined(VBOX_WITH_VIDEOHWACCEL)
3460 pData->pVBVACallbacks = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIDISPLAYVBVACALLBACKS);
3461 if (!pData->pVBVACallbacks)
3462 {
3463 AssertMsgFailed(("Configuration error: No VBVA callback interface above!\n"));
3464 return VERR_PDM_MISSING_INTERFACE_ABOVE;
3465 }
3466#endif
3467 /*
3468 * Get the Display object pointer and update the mpDrv member.
3469 */
3470 void *pv;
3471 int rc = CFGMR3QueryPtr(pCfg, "Object", &pv);
3472 if (RT_FAILURE(rc))
3473 {
3474 AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
3475 return rc;
3476 }
3477 pData->pDisplay = (Display *)pv; /** @todo Check this cast! */
3478 pData->pDisplay->mpDrv = pData;
3479
3480 /*
3481 * Update our display information according to the framebuffer
3482 */
3483 pData->pDisplay->updateDisplayData();
3484
3485 /*
3486 * Start periodic screen refreshes
3487 */
3488 pData->pUpPort->pfnSetRefreshRate(pData->pUpPort, 20);
3489
3490 return VINF_SUCCESS;
3491}
3492
3493
3494/**
3495 * Display driver registration record.
3496 */
3497const PDMDRVREG Display::DrvReg =
3498{
3499 /* u32Version */
3500 PDM_DRVREG_VERSION,
3501 /* szName */
3502 "MainDisplay",
3503 /* szRCMod */
3504 "",
3505 /* szR0Mod */
3506 "",
3507 /* pszDescription */
3508 "Main display driver (Main as in the API).",
3509 /* fFlags */
3510 PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
3511 /* fClass. */
3512 PDM_DRVREG_CLASS_DISPLAY,
3513 /* cMaxInstances */
3514 ~0,
3515 /* cbInstance */
3516 sizeof(DRVMAINDISPLAY),
3517 /* pfnConstruct */
3518 Display::drvConstruct,
3519 /* pfnDestruct */
3520 Display::drvDestruct,
3521 /* pfnRelocate */
3522 NULL,
3523 /* pfnIOCtl */
3524 NULL,
3525 /* pfnPowerOn */
3526 NULL,
3527 /* pfnReset */
3528 NULL,
3529 /* pfnSuspend */
3530 NULL,
3531 /* pfnResume */
3532 NULL,
3533 /* pfnAttach */
3534 NULL,
3535 /* pfnDetach */
3536 NULL,
3537 /* pfnPowerOff */
3538 NULL,
3539 /* pfnSoftReset */
3540 NULL,
3541 /* u32EndVersion */
3542 PDM_DRVREG_VERSION
3543};
3544/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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