VBoxGuestR3LibVideo.cpp revision a34996f4849a881e4112ba993984dcd2388b8bf2
52f16f53a955f5b24bc2132c418a5fffb700f089vboxsync/* $Id$ */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/** @file
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Video.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/*
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * Copyright (C) 2007-2009 Oracle Corporation
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * available from http://www.virtualbox.org. This file is free software;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * General Public License (GPL) as published by the Free Software
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync *
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * The contents of this file may alternatively be used under the terms
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * of the Common Development and Distribution License Version 1.0
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * VirtualBox OSE distribution, in which case the provisions of the
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * CDDL are applicable instead of those of the GPL.
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync *
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * You may elect to license modified versions of this file under the
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync * terms and conditions of either the GPL or the CDDL or both.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/*******************************************************************************
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync* Header Files *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync*******************************************************************************/
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include <iprt/assert.h>
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include <iprt/mem.h>
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include <iprt/string.h>
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync#include <VBox/log.h>
64e0c74b525c440a571ce06f3eb6234d75913d76vboxsync#include <VBox/HostServices/GuestPropertySvc.h> /* For Save and RetrieveVideoMode */
95f49f3cab4060d4c9b53703d32f51a7f1a3ece6vboxsync
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync#include "VBGLR3Internal.h"
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync
d6aa6429f99fb7648883eb612f8a52b9aaf3bff4vboxsync#ifdef VBOX_VBGLR3_XFREE86
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/* Rather than try to resolve all the header file conflicts, I will just
ab0fa8b1fefba60f43cfd2104a7939944da28b86vboxsync prototype what we need here. */
c312e1b81dffe42e0fb766020fb8defaeade05d6vboxsyncextern "C" void* xf86memcpy(void*,const void*,xf86size_t);
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync# undef memcpy
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync# define memcpy xf86memcpy
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync#endif /* VBOX_VBGLR3_XFREE86 */
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync#define VIDEO_PROP_PREFIX "/VirtualBox/GuestAdd/Vbgl/Video/"
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync/**
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync * Enable or disable video acceleration.
64241796dca8fa36d3fca205e01b4320193a36b7vboxsync *
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync * @returns VBox status code.
a34996f4849a881e4112ba993984dcd2388b8bf2vboxsync *
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * @param fEnable Pass zero to disable, any other value to enable.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsyncVBGLR3DECL(int) VbglR3VideoAccelEnable(bool fEnable)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync VMMDevVideoAccelEnable Req;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelEnable);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync Req.u32Enable = fEnable;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync Req.cbRingBuffer = VBVA_RING_BUFFER_SIZE;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync Req.fu32Status = 0;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync return vbglR3GRPerform(&Req.header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync}
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/**
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Flush the video buffer.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @returns VBox status code.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsyncVBGLR3DECL(int) VbglR3VideoAccelFlush(void)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync VMMDevVideoAccelFlush Req;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelFlush);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync return vbglR3GRPerform(&Req.header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync}
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/**
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Send mouse pointer shape information to the host.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @returns VBox status code.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param fFlags Mouse pointer flags.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param xHot X coordinate of hot spot.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param yHot Y coordinate of hot spot.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param cx Pointer width.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param cy Pointer height.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param pvImg Pointer to the image data (can be NULL).
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param cbImg Size of the image data pointed to by pvImg.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsyncVBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync VMMDevReqMousePointer *pReq;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, RT_OFFSETOF(VMMDevReqMousePointer, pointerData) + cbImg, VMMDevReq_SetPointerShape);
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync if (RT_SUCCESS(rc))
54828795a553ed0731f308ebda81675ad2c39d58vboxsync {
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->fFlags = fFlags;
54828795a553ed0731f308ebda81675ad2c39d58vboxsync pReq->xHot = xHot;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->yHot = yHot;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->width = cx;
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync pReq->height = cy;
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync if (pvImg)
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync memcpy(pReq->pointerData, pvImg, cbImg);
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync rc = vbglR3GRPerform(&pReq->header);
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync vbglR3GRFree(&pReq->header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync if (RT_SUCCESS(rc))
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync rc = pReq->header.rc;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync }
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync return rc;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync}
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync/**
54828795a553ed0731f308ebda81675ad2c39d58vboxsync * Send mouse pointer shape information to the host.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * This version of the function accepts a request for clients that
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * already allocate and manipulate the request structure directly.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @returns VBox status code.
2f0ff8eed7f73f05b9af49aff1b6c213cf4c80a8vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param pReq Pointer to the VMMDevReqMousePointer structure.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsyncVBGLR3DECL(int) VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync int rc = vbglR3GRPerform(&pReq->header);
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync if (RT_SUCCESS(rc))
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync rc = pReq->header.rc;
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync return rc;
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync}
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync/**
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * Query the last display change request sent from the host to the guest.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync *
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @returns iprt status value
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @param pcx Where to store the horizontal pixel resolution
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * requested (a value of zero means do not change).
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @param pcy Where to store the vertical pixel resolution
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * requested (a value of zero means do not change).
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @param pcBits Where to store the bits per pixel requested (a value
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * of zero means do not change).
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param iDisplay Where to store the display number the request was for
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * - 0 for the primary display, 1 for the first
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * secondary display, etc.
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param fAck whether or not to acknowlege the newest request sent by
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * the host. If this is set, the function will return the
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * most recent host request, otherwise it will return the
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * last request to be acknowleged.
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync */
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsyncVBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay, bool fAck)
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync{
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync VMMDevDisplayChangeRequest2 Req;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync RT_ZERO(Req);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync if (fAck)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync int rc = vbglR3GRPerform(&Req.header);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (RT_SUCCESS(rc))
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync rc = Req.header.rc;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (RT_SUCCESS(rc))
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync {
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *pcx = Req.xres;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *pcy = Req.yres;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *pcBits = Req.bpp;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *piDisplay = Req.display;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync }
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync return rc;
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync}
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync/**
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * Query the host as to whether it likes a specific video mode.
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync *
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @returns the result of the query
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param cx the width of the mode being queried
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param cy the height of the mode being queried
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync * @param cBits the bpp of the mode being queried
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync */
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsyncVBGLR3DECL(bool) VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits)
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync{
0defe73e08f591e32e92dfeb3de18ee84a180d2avboxsync bool fRc = true; /* If for some reason we can't contact the host then
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * we like everything. */
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync int rc;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync VMMDevVideoModeSupportedRequest req;
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync vmmdevInitRequest(&req.header, VMMDevReq_VideoModeSupported);
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync req.width = cx;
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync req.height = cy;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync req.bpp = cBits;
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync req.fSupported = true;
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync rc = vbglR3GRPerform(&req.header);
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync if (RT_SUCCESS(rc) && RT_SUCCESS(req.header.rc))
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync fRc = req.fSupported;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync return fRc;
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync}
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync/**
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * Save video mode parameters to the registry.
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync *
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * @returns iprt status value
2084a447d1acb619df7c393fac41b79d517e4b3dvboxsync * @param pszName the name to save the mode parameters under
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param cx mode width
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param cy mode height
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param cBits bits per pixel for the mode
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsyncVBGLR3DECL(int) VbglR3SaveVideoMode(const char *pszName, uint32_t cx, uint32_t cy, uint32_t cBits)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync{
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync#if defined(VBOX_WITH_GUEST_PROPS)
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync using namespace guestProp;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync char szModeName[MAX_NAME_LEN];
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync char szModeParms[MAX_VALUE_LEN];
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync uint32_t u32ClientId = 0;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%s", pszName);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync RTStrPrintf(szModeParms, sizeof(szModeParms), "%dx%dx%d", cx, cy, cBits);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync int rc = VbglR3GuestPropConnect(&u32ClientId);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (RT_SUCCESS(rc))
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync rc = VbglR3GuestPropWriteValue(u32ClientId, szModeName, szModeParms);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (u32ClientId != 0)
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync VbglR3GuestPropDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync return rc;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync#else /* !VBOX_WITH_GUEST_PROPS */
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync return VERR_NOT_IMPLEMENTED;
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync#endif /* !VBOX_WITH_GUEST_PROPS */
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync}
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync/**
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * Retrieve video mode parameters from the guest property store.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync *
5c320d1b52e5e4ae280cd680c2c64de5f5f13d22vboxsync * @returns iprt status value
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param pszName the name under which the mode parameters are saved
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * @param pcx where to store the mode width
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcy where to store the mode height
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcBits where to store the bits per pixel for the mode
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync */
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsyncVBGLR3DECL(int) VbglR3RetrieveVideoMode(const char *pszName, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits)
b60e4b0625949fd68ed97f1353e2174c5b3192e5vboxsync{
b60e4b0625949fd68ed97f1353e2174c5b3192e5vboxsync#if defined(VBOX_WITH_GUEST_PROPS)
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync using namespace guestProp;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync/*
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync * First we retreive the video mode which is saved as a string in the
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync * guest property store.
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync /* The buffer for VbglR3GuestPropReadValue. If this is too small then
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync * something is wrong with the data stored in the property. */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync char szModeParms[1024];
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync uint32_t u32ClientId = 0;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync uint32_t cx, cy, cBits;
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync int rc = VbglR3GuestPropConnect(&u32ClientId);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync if (RT_SUCCESS(rc))
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync {
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync char szModeName[MAX_NAME_LEN];
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%s", pszName);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync /** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync rc = VbglR3GuestPropReadValue(u32ClientId, szModeName, szModeParms,
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync sizeof(szModeParms), NULL);
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync }
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync
9fc58edfe4464fca24d4a064b9d3fe2ed173a71avboxsync/*
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync * Now we convert the string returned to numeric values.
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync */
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync char *pszNext;
64e0c74b525c440a571ce06f3eb6234d75913d76vboxsync if (RT_SUCCESS(rc))
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync /* Extract the width from the string */
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync rc = RTStrToUInt32Ex(szModeParms, &pszNext, 10, &cx);
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync if ((rc != VWRN_TRAILING_CHARS) || (*pszNext != 'x'))
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync rc = VERR_PARSE_ERROR;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync if (RT_SUCCESS(rc))
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync {
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync /* Extract the height from the string */
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync ++pszNext;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync rc = RTStrToUInt32Ex(pszNext, &pszNext, 10, &cy);
052deaa01d8fcd5cec4dff857833538940b751c3vboxsync }
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync if ((rc != VWRN_TRAILING_CHARS) || (*pszNext != 'x'))
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync rc = VERR_PARSE_ERROR;
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync if (RT_SUCCESS(rc))
26bef2fb65df80a28b9972e0a43a92be367417d9vboxsync {
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync /* Extract the bpp from the string */
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync ++pszNext;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync rc = RTStrToUInt32Full(pszNext, 10, &cBits);
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync }
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync if (rc != VINF_SUCCESS)
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync rc = VERR_PARSE_ERROR;
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync/*
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * And clean up and return the values if we successfully obtained them.
d308e8fdb9e4d827ed10d26d1581d265602f6f46vboxsync */
d308e8fdb9e4d827ed10d26d1581d265602f6f46vboxsync if (u32ClientId != 0)
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync VbglR3GuestPropDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync {
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync *pcx = cx;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync *pcy = cy;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync *pcBits = cBits;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync }
16055a5d4275e7b50ed0a51b37cce77ac07e2c57vboxsync return rc;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync#else /* !VBOX_WITH_GUEST_PROPS */
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync return VERR_NOT_IMPLEMENTED;
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync#endif /* !VBOX_WITH_GUEST_PROPS */
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync}
dd6994667c4e2ebd8f1f01a1d29f5c0491f82603vboxsync