VirtualBox

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

最後變更 在這個檔案從72634是 69346,由 vboxsync 提交於 7 年 前

vboxvideo: scm updates (mit license formatting, 'this file is based on' instead of 'this code is based on').

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette