Changeset 43245 in vbox for trunk/src/VBox/Additions/x11/vboxvideo
- Timestamp:
- Sep 7, 2012 2:48:54 PM (12 years ago)
- Location:
- trunk/src/VBox/Additions/x11/vboxvideo
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/x11/vboxvideo/setmode.c
r43082 r43245 104 104 TRACE_LOG("cDisplay=%u, cWidth=%u, cHeight=%u, x=%d, y=%d, displayWidth=%d\n", 105 105 cDisplay, cWidth, cHeight, x, y, pScrn->displayWidth); 106 pVBox->aScreenLocation[cDisplay].cx = cWidth;107 pVBox->aScreenLocation[cDisplay].cy = cHeight;108 pVBox->aScreenLocation[cDisplay].x = x;109 pVBox->aScreenLocation[cDisplay].y = y;110 106 offStart = y * pVBox->cbLine + x * vboxBPP(pScrn) / 8; 111 107 /* Deactivate the screen if the mode - specifically the virtual width - is … … 121 117 else 122 118 cwReal = RT_MIN((int) cWidth, pScrn->displayWidth - x); 123 TRACE_LOG("pVBox->afDisabled[cDisplay]=%d\n", 124 (int)pVBox->afDisabled[cDisplay]); 125 /* Don't fiddle with the hardware if we are switched 126 * to a virtual terminal. */ 127 if (pVBox->vtSwitch) 128 return TRUE; 119 TRACE_LOG("pVBox->afDisabled[%u]=%d\n", 120 cDisplay, (int)pVBox->afDisabled[cDisplay]); 129 121 if (cDisplay == 0) 130 122 VBoxVideoSetModeRegisters(cwReal, cHeight, pScrn->displayWidth, … … 155 147 156 148 TRACE_LOG("width=%d, height=%d\n", width, height); 149 if (width == pScrn->virtualX && height == pScrn->virtualY) 150 return TRUE; 157 151 if (!pPixmap) { 158 152 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c
r43108 r43245 17 17 * -------------------------------------------------------------------- 18 18 * 19 * This code is based on: 20 * 21 * X11 VESA driver 19 * This code is based on the X.Org VESA driver with the following copyrights: 22 20 * 23 21 * Copyright (c) 2000 by Conectiva S.A. (http://www.conectiva.com) 22 * Copyright 2008 Red Hat, Inc. 23 * Copyright 2012 Red Hat, Inc. 24 * 25 * and the following permission notice (not all original sourse files include 26 * the last paragraph): 24 27 * 25 28 * Permission is hereby granted, free of charge, to any person obtaining a … … 47 50 * 48 51 * Authors: Paulo César Pereira de Andrade <[email protected]> 52 * David Dawes <[email protected]> 53 * Adam Jackson <[email protected]> 54 * Dave Airlie <[email protected]> 49 55 */ 50 56 … … 243 249 X.Org source tree. */ 244 250 251 static Bool vbox_config_resize(ScrnInfoPtr pScrn, int cw, int ch) 252 { 253 VBOXPtr pVBox = VBOXGetRec(pScrn); 254 TRACE_LOG("width=%d, height=%d\n", cw, ch); 255 /* Save the size in case we need to re-set it later. */ 256 pVBox->FBSize.cx = cw; 257 pVBox->FBSize.cy = ch; 258 /* Don't fiddle with the hardware if we are switched 259 * to a virtual terminal. */ 260 if (!pScrn->vtSema) { 261 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 262 "We do not own the active VT, exiting.\n"); 263 return TRUE; 264 } 265 return VBOXAdjustScreenPixmap(pScrn, cw, ch); 266 } 267 245 268 static const xf86CrtcConfigFuncsRec VBOXCrtcConfigFuncs = { 246 VBOXAdjustScreenPixmap269 vbox_config_resize 247 270 }; 248 271 … … 254 277 TRACE_LOG("cDisplay=%u, mode=%i\n", cDisplay, mode); 255 278 pVBox->afDisabled[cDisplay] = (mode != DPMSModeOn); 279 /* Don't fiddle with the hardware if we are switched 280 * to a virtual terminal. */ 281 if (!crtc->scrn->vtSema) { 282 xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, 283 "We do not own the active VT, exiting.\n"); 284 return; 285 } 256 286 if ( pVBox->aScreenLocation[cDisplay].cx 257 287 && pVBox->aScreenLocation[cDisplay].cy) … … 267 297 { (void) crtc; return FALSE; } 268 298 299 300 /* We use this function to check whether the X server owns the active virtual 301 * terminal before attempting a mode switch, since the RandR extension isn't 302 * very dilligent here, which can mean crashes if we are unlucky. This is 303 * not the way it the function is intended - it is meant for reporting modes 304 * which the hardware can't handle. I hope that this won't confuse any clients 305 * connecting to us. */ 269 306 static Bool 270 307 vbox_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode, … … 287 324 adjusted_mode->HDisplay, adjusted_mode->VDisplay, x, y); 288 325 pVBox->afDisabled[cDisplay] = false; 289 VBOXSetMode(crtc->scrn, cDisplay, adjusted_mode->HDisplay, 290 adjusted_mode->VDisplay, x, y); 326 pVBox->aScreenLocation[cDisplay].cx = adjusted_mode->HDisplay; 327 pVBox->aScreenLocation[cDisplay].cy = adjusted_mode->VDisplay; 328 pVBox->aScreenLocation[cDisplay].x = x; 329 pVBox->aScreenLocation[cDisplay].y = y; 291 330 /* Don't remember any modes set while we are seamless, as they are 292 331 * just temporary. */ … … 294 333 vboxSaveVideoMode(crtc->scrn, adjusted_mode->HDisplay, 295 334 adjusted_mode->VDisplay, crtc->scrn->bitsPerPixel); 335 /* Don't fiddle with the hardware if we are switched 336 * to a virtual terminal. */ 337 if (!crtc->scrn->vtSema) 338 { 339 xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR, 340 "We do not own the active VT, exiting.\n"); 341 return; 342 } 343 VBOXSetMode(crtc->scrn, cDisplay, adjusted_mode->HDisplay, 344 adjusted_mode->VDisplay, x, y); 296 345 } 297 346 … … 691 740 #endif 692 741 693 /**694 * This function hooks into the chain that is called when framebuffer access695 * is allowed or disallowed by a call to EnableDisableFBAccess in the server.696 * In other words, it observes when the server wishes access to the697 * framebuffer to be enabled and when it should be disabled. We need to know698 * this because we disable access ourselves during mode switches (presumably699 * the server should do this but it doesn't) and want to know whether to700 * restore it or not afterwards.701 */702 static void703 vboxEnableDisableFBAccess(int scrnIndex, Bool enable)704 {705 ScrnInfoPtr pScrn = xf86Screens[scrnIndex];706 707 VBOXPtr pVBox = VBOXGetRec(pScrn);708 709 TRACE_LOG("enable=%s\n", enable ? "TRUE" : "FALSE");710 VBOXSetRec(pScrn);711 pVBox->accessEnabled = enable;712 pVBox->EnableDisableFBAccess(scrnIndex, enable);713 TRACE_EXIT();714 }715 742 716 743 /* … … 988 1015 989 1016 xf86SetBlackWhitePixels(pScreen); 990 991 /* We need to keep track of whether we are currently switched to a virtual 992 * terminal to know whether a mode set operation is currently safe to do. 993 */ 994 pVBox->vtSwitch = FALSE; 1017 pScrn->vtSema = TRUE; 995 1018 996 1019 if (vbox_open (pScrn, pScreen, pVBox)) { … … 1086 1109 return (FALSE); 1087 1110 1088 /* Hook our observer function ito the chain which is called when1089 * framebuffer access is enabled or disabled in the server, and1090 * assume an initial state of enabled. */1091 pVBox->accessEnabled = TRUE;1092 pVBox->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;1093 pScrn->EnableDisableFBAccess = vboxEnableDisableFBAccess;1094 1095 1111 pVBox->CloseScreen = pScreen->CloseScreen; 1096 1112 pScreen->CloseScreen = VBOXCloseScreen; … … 1134 1150 if (pVBox->fHaveHGSMI) 1135 1151 vboxEnableVbva(pScrn); 1136 pVBox->vtSwitch = FALSE;1137 1152 #ifdef VBOX_DRI 1138 1153 if (pVBox->useDRI) 1139 1154 DRIUnlock(screenInfo.screens[scrnIndex]); 1140 1155 #endif 1156 /* Re-assert this in case we had a change request while switched out. */ 1157 VBOXAdjustScreenPixmap(pScrn, pVBox->FBSize.cx, pVBox->FBSize.cy); 1141 1158 #ifdef VBOXVIDEO_13 1142 1159 if (!xf86SetDesiredModes(pScrn)) … … 1158 1175 1159 1176 TRACE_ENTRY(); 1160 pVBox->vtSwitch = TRUE;1161 1177 if (pVBox->fHaveHGSMI) 1162 1178 vboxDisableVbva(pScrn); … … 1177 1193 VBOXPtr pVBox = VBOXGetRec(pScrn); 1178 1194 1179 if (pVBox->fHaveHGSMI) 1180 vboxDisableVbva(pScrn); 1181 vboxDisableGraphicsCap(pVBox); 1182 vboxClearVRAM(pScrn, 0, 0); 1195 if (pScrn->vtSema) 1196 { 1197 if (pVBox->fHaveHGSMI) 1198 vboxDisableVbva(pScrn); 1199 if (pScrn->vtSema) 1200 vboxDisableGraphicsCap(pVBox); 1201 vboxClearVRAM(pScrn, 0, 0); 1202 } 1183 1203 #ifdef VBOX_DRI 1184 1204 if (pVBox->useDRI) … … 1196 1216 vbox_close(pScrn, pVBox); 1197 1217 1198 /* Remove our observer functions from the X server call chains. */1199 pScrn->EnableDisableFBAccess = pVBox->EnableDisableFBAccess;1200 1218 pScreen->CloseScreen = pVBox->CloseScreen; 1201 1219 return pScreen->CloseScreen(scrnIndex, pScreen); … … 1211 1229 TRACE_LOG("HDisplay=%d, VDisplay=%d\n", pMode->HDisplay, pMode->VDisplay); 1212 1230 pScrn = xf86Screens[scrnIndex]; /* Why does X have three ways of referring to the screen? */ 1231 #ifndef VBOXVIDEO_13 1213 1232 pVBox = VBOXGetRec(pScrn); 1214 /* We want to disable access to the framebuffer before switching mode. 1215 * After doing the switch, we allow access if it was allowed before. */ 1216 if (pVBox->accessEnabled) 1217 pVBox->EnableDisableFBAccess(scrnIndex, FALSE); 1233 /* Save the size in case we need to re-set it later. */ 1234 pVBox->FBSize.cx = pMode->HDisplay; 1235 pVBox->FBSize.cy = pMode->VDisplay; 1236 pVBox->aScreenLocation[0].cx = pMode->HDisplay; 1237 pVBox->aScreenLocation[0].cy = pMode->VDisplay; 1238 pVBox->aScreenLocation[0].x = pScrn->frameX0; 1239 pVBox->aScreenLocation[0].y = pScrn->frameY0; 1240 if (rc) 1241 { 1242 vboxWriteHostModes(pScrn, pMode); 1243 xf86PrintModes(pScrn); 1244 } 1245 if (rc && !vboxGuestIsSeamless(pScrn)) 1246 vboxSaveVideoMode(pScrn, pMode->HDisplay, pMode->VDisplay, 1247 pScrn->bitsPerPixel); 1248 #endif 1249 if (!pScrn->vtSema) 1250 { 1251 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 1252 "We do not own the active VT, exiting.\n"); 1253 return TRUE; 1254 } 1218 1255 #ifdef VBOXVIDEO_13 1219 1256 rc = xf86SetSingleMode(pScrn, pMode, 0); … … 1222 1259 rc = VBOXSetMode(pScrn, 0, pMode->HDisplay, pMode->VDisplay, 1223 1260 pScrn->frameX0, pScrn->frameY0); 1224 if (rc) 1225 { 1226 vboxWriteHostModes(pScrn, pMode); 1227 xf86PrintModes(pScrn); 1228 } 1229 if (rc && !vboxGuestIsSeamless(pScrn)) 1230 vboxSaveVideoMode(pScrn, pMode->HDisplay, pMode->VDisplay, 1231 pScrn->bitsPerPixel); 1232 #endif 1233 if (pVBox->accessEnabled) 1234 pVBox->EnableDisableFBAccess(scrnIndex, TRUE); 1261 #endif 1235 1262 TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE"); 1236 1263 return rc; … … 1244 1271 1245 1272 TRACE_ENTRY(); 1273 pVBox->aScreenLocation[0].x = x; 1274 pVBox->aScreenLocation[0].y = y; 1246 1275 /* Don't fiddle with the hardware if we are switched 1247 1276 * to a virtual terminal. */ 1277 if (!pScrn->vtSema) 1278 { 1279 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, 1280 "We do not own the active VT, exiting.\n"); 1281 return; 1282 } 1248 1283 VBOXSetMode(pScrn, 0, pVBox->aScreenLocation[0].cx, 1249 1284 pVBox->aScreenLocation[0].cy, x, y); -
trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h
r43108 r43245 160 160 /** Default X server procedure for enabling and disabling framebuffer access */ 161 161 xf86EnableDisableFBAccessProc *EnableDisableFBAccess; 162 /** Is access to the framebuffer currently allowed? */163 Bool accessEnabled;164 162 OptionInfoPtr Options; 165 163 /** @todo we never actually free this */ … … 169 167 /** Do we know that the guest can handle absolute co-ordinates? */ 170 168 Bool guestCanAbsolute; 171 /** Are we currently switched to a virtual terminal? If so, it is not172 * safe to touch the hardware. */173 Bool vtSwitch;174 169 /** Does this host support sending graphics commands using HGSMI? */ 175 170 Bool fHaveHGSMI; … … 179 174 * sending dirty rectangle information to the right one. */ 180 175 RTRECT2 aScreenLocation[VBOX_VIDEO_MAX_SCREENS]; 176 /** The last requested framebuffer size. */ 177 RTRECTSIZE FBSize; 181 178 /** Has this screen been disabled by the guest? */ 182 179 Bool afDisabled[VBOX_VIDEO_MAX_SCREENS]; -
trunk/src/VBox/Additions/x11/vboxvideo/vbva.c
r43081 r43245 56 56 57 57 pVBox = pScrn->driverPrivate; 58 if (pVBox->fHaveHGSMI == FALSE || pVBox->vtSwitch)58 if (pVBox->fHaveHGSMI == FALSE || !pScrn->vtSema) 59 59 return; 60 60
Note:
See TracChangeset
for help on using the changeset viewer.