VBoxGuestR3LibVideo.cpp revision 5c320d1b52e5e4ae280cd680c2c64de5f5f13d22
52f16f53a955f5b24bc2132c418a5fffb700f089vboxsync/* $Id$ */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/** @file
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Video.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/*
d6aa6429f99fb7648883eb612f8a52b9aaf3bff4vboxsync * Copyright (C) 2007-2009 Sun Microsystems, Inc.
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.
aba0e602e244ae7c4f11b50fc6d2440f5a762038vboxsync *
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * additional information or have any questions.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/*******************************************************************************
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync* Header Files *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync*******************************************************************************/
64e0c74b525c440a571ce06f3eb6234d75913d76vboxsync#include <iprt/assert.h>
d6aa6429f99fb7648883eb612f8a52b9aaf3bff4vboxsync#include <iprt/mem.h>
d6aa6429f99fb7648883eb612f8a52b9aaf3bff4vboxsync#include <iprt/string.h>
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync#include <VBox/log.h>
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync#include <VBox/HostServices/GuestPropertySvc.h> /* For Save and RetrieveVideoMode */
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
c312e1b81dffe42e0fb766020fb8defaeade05d6vboxsync#include "VBGLR3Internal.h"
c312e1b81dffe42e0fb766020fb8defaeade05d6vboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync#define VIDEO_PROP_PREFIX "/VirtualBox/GuestAdd/Vbgl/Video/"
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync/**
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * Enable or disable video acceleration.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @returns VBox status code.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync *
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync * @param fEnable Pass zero to disable, any other value to enable.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
50f0e2e83362e100d306a411980d555d46aa00a8vboxsyncVBGLR3DECL(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;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync 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.
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync * @param cx Pointer width.
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync * @param cy Pointer height.
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync * @param pvImg Pointer to the image data (can be NULL).
54828795a553ed0731f308ebda81675ad2c39d58vboxsync * @param cbImg Size of the image data pointed to by pvImg.
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync */
54828795a553ed0731f308ebda81675ad2c39d58vboxsyncVBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvImg, size_t cbImg)
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync{
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync VMMDevReqMousePointer *pReq;
54828795a553ed0731f308ebda81675ad2c39d58vboxsync int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, RT_OFFSETOF(VMMDevReqMousePointer, pointerData) + cbImg, VMMDevReq_SetPointerShape);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync if (RT_SUCCESS(rc))
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync {
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->fFlags = fFlags;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->xHot = xHot;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync pReq->yHot = yHot;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync pReq->width = cx;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync pReq->height = cy;
50f0e2e83362e100d306a411980d555d46aa00a8vboxsync if (pvImg)
54828795a553ed0731f308ebda81675ad2c39d58vboxsync memcpy(pReq->pointerData, pvImg, cbImg);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync rc = vbglR3GRPerform(&pReq->header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync vbglR3GRFree(&pReq->header);
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync if (RT_SUCCESS(rc))
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync rc = pReq->header.rc;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync }
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync return rc;
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync}
b0dfb334954c0552bb583967a3077ec88fd00471vboxsync
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync/**
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * Send mouse pointer shape information to the host.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * This version of the function accepts a request for clients that
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * already allocate and manipulate the request structure directly.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync *
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @returns VBox status code.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync *
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync * @param pReq Pointer to the VMMDevReqMousePointer structure.
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync */
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsyncVBGLR3DECL(int) VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq)
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync{
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync int rc = vbglR3GRPerform(&pReq->header);
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync if (RT_SUCCESS(rc))
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync rc = pReq->header.rc;
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync return rc;
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync}
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync
80523be8dba75b5eb32569fd72ddf54f3b009025vboxsync
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync/**
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * Query the last display change request sent from the host to the guest.
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync * @returns iprt status value
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcx Where to store the horizontal pixel resolution
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * requested (a value of zero means do not change).
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcy Where to store the vertical pixel resolution
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * requested (a value of zero means do not change).
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param pcBits Where to store the bits per pixel requested (a value
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * of zero means do not change).
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param iDisplay Where to store the display number the request was for
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * - 0 for the primary display, 1 for the first
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * secondary display, etc.
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * @param fAck whether or not to acknowlege the newest request sent by
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * the host. If this is set, the function will return the
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * most recent host request, otherwise it will return the
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync * last request to be acknowleged.
2084a447d1acb619df7c393fac41b79d517e4b3dvboxsync *
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync */
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsyncVBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits, uint32_t *piDisplay, bool fAck)
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync{
5c320d1b52e5e4ae280cd680c2c64de5f5f13d22vboxsync VMMDevDisplayChangeRequest2 Req;
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync#ifndef VBOX_VBGLR3_XFREE86
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync#endif
5c320d1b52e5e4ae280cd680c2c64de5f5f13d22vboxsync RT_ZERO(Req);
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync if (fAck)
b3d4b85739cf74a503b1f8bbb7c7f4de26c1c09fvboxsync Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync int rc = vbglR3GRPerform(&Req.header);
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync if (RT_SUCCESS(rc))
b60e4b0625949fd68ed97f1353e2174c5b3192e5vboxsync rc = Req.header.rc;
b60e4b0625949fd68ed97f1353e2174c5b3192e5vboxsync if (RT_SUCCESS(rc))
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync {
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *pcx = Req.xres;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *pcy = Req.yres;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync *pcBits = Req.bpp;
5d05aa26ae1949e6f0bbc149d8b8e39495710ac7vboxsync *piDisplay = Req.display;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync }
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync return rc;
8d29e9dc0d280b7b26834132b9ce14a3a845a7fdvboxsync}
64e0c74b525c440a571ce06f3eb6234d75913d76vboxsync
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync/**
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * Query the host as to whether it likes a specific video mode.
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync *
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @returns the result of the query
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @param cx the width of the mode being queried
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @param cy the height of the mode being queried
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync * @param cBits the bpp of the mode being queried
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync */
052deaa01d8fcd5cec4dff857833538940b751c3vboxsyncVBGLR3DECL(bool) VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits)
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync{
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync bool fRc = true; /* If for some reason we can't contact the host then
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync * we like everything. */
26bef2fb65df80a28b9972e0a43a92be367417d9vboxsync int rc;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync VMMDevVideoModeSupportedRequest req;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync vmmdevInitRequest(&req.header, VMMDevReq_VideoModeSupported);
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync req.width = cx;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync req.height = cy;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync req.bpp = cBits;
39a628c9e979cb2355caa57eb099b13cb922783cvboxsync req.fSupported = true;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync rc = vbglR3GRPerform(&req.header);
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync if (RT_SUCCESS(rc) && RT_SUCCESS(req.header.rc))
d308e8fdb9e4d827ed10d26d1581d265602f6f46vboxsync fRc = req.fSupported;
d308e8fdb9e4d827ed10d26d1581d265602f6f46vboxsync return fRc;
1e2bc03fd1fc133bd3a066b1557471e157df78f6vboxsync}
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync/**
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * Save video mode parameters to the registry.
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync *
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @returns iprt status value
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param pszName the name to save the mode parameters under
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param cx mode width
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param cy mode height
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param cBits bits per pixel for the mode
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync */
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsyncVBGLR3DECL(int) VbglR3SaveVideoMode(const char *pszName, uint32_t cx, uint32_t cy, uint32_t cBits)
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync{
2077a9092ce42fb009a3ab89b095ec02af18213evboxsync#if defined(VBOX_WITH_GUEST_PROPS) && !defined(VBOX_VBGLR3_XFREE86)
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync using namespace guestProp;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
2673f120424ba2bb67c6da0eb851b65b22b0cba4vboxsync char szModeName[MAX_NAME_LEN];
2673f120424ba2bb67c6da0eb851b65b22b0cba4vboxsync char szModeParms[MAX_VALUE_LEN];
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync uint32_t u32ClientId = 0;
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%s", pszName);
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync RTStrPrintf(szModeParms, sizeof(szModeParms), "%dx%dx%d", cx, cy, cBits);
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync int rc = VbglR3GuestPropConnect(&u32ClientId);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync rc = VbglR3GuestPropWriteValue(u32ClientId, szModeName, szModeParms);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (u32ClientId != 0)
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync VbglR3GuestPropDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync return rc;
2077a9092ce42fb009a3ab89b095ec02af18213evboxsync#else /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
b83d9b1072dd8491c7ffe37830e8fd10f2dba561vboxsync return VERR_NOT_IMPLEMENTED;
2077a9092ce42fb009a3ab89b095ec02af18213evboxsync#endif /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync}
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync/**
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * Retrieve video mode parameters from the guest property store.
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync *
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @returns iprt status value
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param pszName the name under which the mode parameters are saved
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param pcx where to store the mode width
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param pcy where to store the mode height
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync * @param pcBits where to store the bits per pixel for the mode
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync */
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsyncVBGLR3DECL(int) VbglR3RetrieveVideoMode(const char *pszName, uint32_t *pcx, uint32_t *pcy, uint32_t *pcBits)
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync{
2077a9092ce42fb009a3ab89b095ec02af18213evboxsync#if defined(VBOX_WITH_GUEST_PROPS) && !defined(VBOX_VBGLR3_XFREE86)
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync using namespace guestProp;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync/*
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * First we retreive the video mode which is saved as a string in the
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * guest property store.
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync */
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync /* The buffer for VbglR3GuestPropReadValue. If this is too small then
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * something is wrong with the data stored in the property. */
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync char szModeParms[1024];
6c09ee027ad80a5fe6b70ad652253ae6edd09121vboxsync uint32_t u32ClientId = 0;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync uint32_t cx, cy, cBits;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync int rc = VbglR3GuestPropConnect(&u32ClientId);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync {
2673f120424ba2bb67c6da0eb851b65b22b0cba4vboxsync char szModeName[MAX_NAME_LEN];
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX"%s", pszName);
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync /** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync rc = VbglR3GuestPropReadValue(u32ClientId, szModeName, szModeParms,
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync sizeof(szModeParms), NULL);
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync }
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync/*
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * Now we convert the string returned to numeric values.
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync */
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync char *pszNext;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync /* Extract the width from the string */
7dbde0174637fbfd00c50b383f654e46878eaa8evboxsync rc = RTStrToUInt32Ex(szModeParms, &pszNext, 10, &cx);
846739bf4fe90231599e8de3a8c792ae2851b1d1vboxsync if ((rc != VWRN_TRAILING_CHARS) || (*pszNext != 'x'))
5b5f34343f19663d77572b58d4cc70bf57e64b51vboxsync rc = VERR_PARSE_ERROR;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync {
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync /* Extract the height from the string */
846739bf4fe90231599e8de3a8c792ae2851b1d1vboxsync ++pszNext;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync rc = RTStrToUInt32Ex(pszNext, &pszNext, 10, &cy);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync }
846739bf4fe90231599e8de3a8c792ae2851b1d1vboxsync if ((rc != VWRN_TRAILING_CHARS) || (*pszNext != 'x'))
5b5f34343f19663d77572b58d4cc70bf57e64b51vboxsync rc = VERR_PARSE_ERROR;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync {
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync /* Extract the bpp from the string */
846739bf4fe90231599e8de3a8c792ae2851b1d1vboxsync ++pszNext;
846739bf4fe90231599e8de3a8c792ae2851b1d1vboxsync rc = RTStrToUInt32Full(pszNext, 10, &cBits);
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync }
846739bf4fe90231599e8de3a8c792ae2851b1d1vboxsync if (rc != VINF_SUCCESS)
5b5f34343f19663d77572b58d4cc70bf57e64b51vboxsync rc = VERR_PARSE_ERROR;
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync/*
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync * And clean up and return the values if we successfully obtained them.
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (u32ClientId != 0)
3c3a5ab35783f4d31cb5d3a15db9daadeb804daavboxsync VbglR3GuestPropDisconnect(u32ClientId); /* Return value ignored, because what can we do anyway? */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync if (RT_SUCCESS(rc))
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync {
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync *pcx = cx;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync *pcy = cy;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync *pcBits = cBits;
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync }
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync return rc;
2077a9092ce42fb009a3ab89b095ec02af18213evboxsync#else /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
b83d9b1072dd8491c7ffe37830e8fd10f2dba561vboxsync return VERR_NOT_IMPLEMENTED;
2077a9092ce42fb009a3ab89b095ec02af18213evboxsync#endif /* !VBOX_WITH_GUEST_PROPS || VBOX_VBGLR3_XFREE86 */
5bcfdf9ef0306239498361e5021d008ad77bf539vboxsync}