VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/vboxvideo/setmode.c@ 55393

Last change on this file since 55393 was 55390, checked in by vboxsync, 9 years ago

Additions/x11/vboxvideo: remove old code.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: setmode.c 55390 2015-04-22 19:23:02Z vboxsync $ */
2/** @file
3 *
4 * Linux Additions X11 graphics driver, mode setting
5 */
6
7/*
8 * Copyright (C) 2006-2013 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 * --------------------------------------------------------------------
18 *
19 * This code is based on:
20 *
21 * X11 VESA driver
22 *
23 * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com)
24 *
25 * Permission is hereby granted, free of charge, to any person obtaining a
26 * copy of this software and associated documentation files (the "Software"),
27 * to deal in the Software without restriction, including without limitation
28 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
29 * and/or sell copies of the Software, and to permit persons to whom the
30 * Software is furnished to do so, subject to the following conditions:
31 *
32 * The above copyright notice and this permission notice shall be included in
33 * all copies or substantial portions of the Software.
34 *
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38 * CONECTIVA LINUX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
39 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
40 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41 * SOFTWARE.
42 *
43 * Except as contained in this notice, the name of Conectiva Linux shall
44 * not be used in advertising or otherwise to promote the sale, use or other
45 * dealings in this Software without prior written authorization from
46 * Conectiva Linux.
47 *
48 * Authors: Paulo César Pereira de Andrade <pcpa@conectiva.com.br>
49 */
50
51#ifdef XORG_7X
52/* We include <unistd.h> for Solaris below, and the ANSI C emulation layer
53 * interferes with that. */
54# define _XF86_ANSIC_H
55# define XF86_LIBC_H
56# include <string.h>
57#endif
58#include "vboxvideo.h"
59#include "version-generated.h"
60#include "product-generated.h"
61#include "xf86.h"
62
63/* VGA hardware functions for setting and restoring text mode */
64#include "vgaHW.h"
65
66#ifdef RT_OS_SOLARIS
67# include <sys/vuid_event.h>
68# include <sys/msio.h>
69# include <errno.h>
70# include <fcntl.h>
71# include <unistd.h>
72#endif
73
74/** Clear the virtual framebuffer in VRAM. Optionally also clear up to the
75 * size of a new framebuffer. Framebuffer sizes larger than available VRAM
76 * be treated as zero and passed over. */
77void vbvxClearVRAM(ScrnInfoPtr pScrn, size_t cbOldSize, size_t cbNewSize)
78{
79 VBOXPtr pVBox = VBOXGetRec(pScrn);
80
81 /* Assume 32BPP - this is just a sanity test. */
82 VBVXASSERT( cbOldSize / 4 <= VBOX_VIDEO_MAX_VIRTUAL * VBOX_VIDEO_MAX_VIRTUAL
83 && cbNewSize / 4 <= VBOX_VIDEO_MAX_VIRTUAL * VBOX_VIDEO_MAX_VIRTUAL,
84 ("cbOldSize=%llu cbNewSize=%llu, max=%u.\n", (unsigned long long)cbOldSize, (unsigned long long)cbNewSize,
85 VBOX_VIDEO_MAX_VIRTUAL * VBOX_VIDEO_MAX_VIRTUAL));
86 if (cbOldSize > (size_t)pVBox->cbFBMax)
87 cbOldSize = pVBox->cbFBMax;
88 if (cbNewSize > (size_t)pVBox->cbFBMax)
89 cbNewSize = pVBox->cbFBMax;
90 memset(pVBox->base, 0, max(cbOldSize, cbNewSize));
91}
92
93/** Set a graphics mode. Poke any required values into registers, do an HGSMI
94 * mode set and tell the host we support advanced graphics functions.
95 */
96void vbvxSetMode(ScrnInfoPtr pScrn, unsigned cDisplay, unsigned cWidth, unsigned cHeight, int x, int y, bool fEnabled,
97 bool fConnected, struct vbvxFrameBuffer *pFrameBuffer)
98{
99 VBOXPtr pVBox = VBOXGetRec(pScrn);
100 uint32_t offStart;
101 uint16_t fFlags;
102 int rc;
103 bool fEnabledAndVisible = fEnabled && x + cWidth <= pFrameBuffer->cWidth && y + cHeight <= pFrameBuffer->cHeight;
104 /* Recent host code has a flag to blank the screen; older code needs BPP set to zero. */
105 uint32_t cBPP = fEnabledAndVisible || pVBox->fHostHasScreenBlankingFlag ? pFrameBuffer->cBPP : 0;
106
107 TRACE_LOG("cDisplay=%u, cWidth=%u, cHeight=%u, x=%d, y=%d, fEnabled=%d, fConnected=%d, pFrameBuffer: { x0=%d, y0=%d, cWidth=%u, cHeight=%u, cBPP=%u }\n",
108 cDisplay, cWidth, cHeight, x, y, fEnabled, fConnected, pFrameBuffer->x0, pFrameBuffer->y0, pFrameBuffer->cWidth,
109 pFrameBuffer->cHeight, pFrameBuffer->cBPP);
110 VBVXASSERT(cWidth != 0 && cHeight != 0, ("cWidth = 0 or cHeight = 0\n"));
111 offStart = (y * pFrameBuffer->cWidth + x) * pFrameBuffer->cBPP / 8;
112 if (cDisplay == 0 && fEnabled)
113 VBoxVideoSetModeRegisters(cWidth, cHeight, pFrameBuffer->cWidth, pFrameBuffer->cBPP, 0, x, y);
114 fFlags = VBVA_SCREEN_F_ACTIVE;
115 fFlags |= (fConnected ? 0 : VBVA_SCREEN_F_DISABLED);
116 fFlags |= (!fEnabledAndVisible && pVBox->fHostHasScreenBlankingFlag ? VBVA_SCREEN_F_BLANK : 0);
117 VBoxHGSMIProcessDisplayInfo(&pVBox->guestCtx, cDisplay, x - pFrameBuffer->x0, y - pFrameBuffer->y0, offStart,
118 pFrameBuffer->cWidth * pFrameBuffer->cBPP / 8, cWidth, cHeight, cBPP, fFlags);
119 rc = VBoxHGSMIUpdateInputMapping(&pVBox->guestCtx, 0 - pFrameBuffer->x0, 0 - pFrameBuffer->y0, pFrameBuffer->cWidth,
120 pFrameBuffer->cHeight);
121 if (RT_FAILURE(rc))
122 FatalError("Failed to update the input mapping.\n");
123}
124
125/** Tell the virtual mouse device about the new virtual desktop size. */
126void vbvxSetSolarisMouseRange(int width, int height)
127{
128#ifdef RT_OS_SOLARIS
129 int rc;
130 int hMouse = open("/dev/mouse", O_RDWR);
131
132 if (hMouse >= 0)
133 {
134 do {
135 Ms_screen_resolution Res = { height, width };
136 rc = ioctl(hMouse, MSIOSRESOLUTION, &Res);
137 } while ((rc != 0) && (errno == EINTR));
138 close(hMouse);
139 }
140#else
141 (void)width; (void)height;
142#endif
143}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use