VirtualBox

Ignore:
Timestamp:
Sep 7, 2012 2:48:54 PM (12 years ago)
Author:
vboxsync
Message:

Additions/x11/vboxvideo: clean up sanity handling for mode switches when we do not own the virtual terminal.

Location:
trunk/src/VBox/Additions/x11/vboxvideo
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/vboxvideo/setmode.c

    r43082 r43245  
    104104    TRACE_LOG("cDisplay=%u, cWidth=%u, cHeight=%u, x=%d, y=%d, displayWidth=%d\n",
    105105              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;
    110106    offStart = y * pVBox->cbLine + x * vboxBPP(pScrn) / 8;
    111107    /* Deactivate the screen if the mode - specifically the virtual width - is
     
    121117    else
    122118        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]);
    129121    if (cDisplay == 0)
    130122        VBoxVideoSetModeRegisters(cwReal, cHeight, pScrn->displayWidth,
     
    155147
    156148    TRACE_LOG("width=%d, height=%d\n", width, height);
     149    if (width == pScrn->virtualX && height == pScrn->virtualY)
     150        return TRUE;
    157151    if (!pPixmap) {
    158152        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.c

    r43108 r43245  
    1717 * --------------------------------------------------------------------
    1818 *
    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:
    2220 *
    2321 * 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):
    2427 *
    2528 * Permission is hereby granted, free of charge, to any person obtaining a
     
    4750 *
    4851 * Authors: Paulo César Pereira de Andrade <[email protected]>
     52 *          David Dawes <[email protected]>
     53 *          Adam Jackson <[email protected]>
     54 *          Dave Airlie <[email protected]>
    4955 */
    5056
     
    243249   X.Org source tree. */
    244250
     251static 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
    245268static const xf86CrtcConfigFuncsRec VBOXCrtcConfigFuncs = {
    246     VBOXAdjustScreenPixmap
     269    vbox_config_resize
    247270};
    248271
     
    254277    TRACE_LOG("cDisplay=%u, mode=%i\n", cDisplay, mode);
    255278    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    }
    256286    if (   pVBox->aScreenLocation[cDisplay].cx
    257287        && pVBox->aScreenLocation[cDisplay].cy)
     
    267297{ (void) crtc; return FALSE; }
    268298
     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. */
    269306static Bool
    270307vbox_crtc_mode_fixup (xf86CrtcPtr crtc, DisplayModePtr mode,
     
    287324           adjusted_mode->HDisplay, adjusted_mode->VDisplay, x, y);
    288325    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;
    291330    /* Don't remember any modes set while we are seamless, as they are
    292331     * just temporary. */
     
    294333        vboxSaveVideoMode(crtc->scrn, adjusted_mode->HDisplay,
    295334                          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);
    296345}
    297346
     
    691740#endif
    692741
    693 /**
    694  * This function hooks into the chain that is called when framebuffer access
    695  * is allowed or disallowed by a call to EnableDisableFBAccess in the server.
    696  * In other words, it observes when the server wishes access to the
    697  * framebuffer to be enabled and when it should be disabled.  We need to know
    698  * this because we disable access ourselves during mode switches (presumably
    699  * the server should do this but it doesn't) and want to know whether to
    700  * restore it or not afterwards.
    701  */
    702 static void
    703 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 }
    715742
    716743/*
     
    9881015
    9891016    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;
    9951018
    9961019    if (vbox_open (pScrn, pScreen, pVBox)) {
     
    10861109        return (FALSE);
    10871110
    1088     /* Hook our observer function ito the chain which is called when
    1089      * framebuffer access is enabled or disabled in the server, and
    1090      * assume an initial state of enabled. */
    1091     pVBox->accessEnabled = TRUE;
    1092     pVBox->EnableDisableFBAccess = pScrn->EnableDisableFBAccess;
    1093     pScrn->EnableDisableFBAccess = vboxEnableDisableFBAccess;
    1094 
    10951111    pVBox->CloseScreen = pScreen->CloseScreen;
    10961112    pScreen->CloseScreen = VBOXCloseScreen;
     
    11341150    if (pVBox->fHaveHGSMI)
    11351151        vboxEnableVbva(pScrn);
    1136     pVBox->vtSwitch = FALSE;
    11371152#ifdef VBOX_DRI
    11381153    if (pVBox->useDRI)
    11391154        DRIUnlock(screenInfo.screens[scrnIndex]);
    11401155#endif
     1156    /* Re-assert this in case we had a change request while switched out. */
     1157    VBOXAdjustScreenPixmap(pScrn, pVBox->FBSize.cx, pVBox->FBSize.cy);
    11411158#ifdef VBOXVIDEO_13
    11421159    if (!xf86SetDesiredModes(pScrn))
     
    11581175
    11591176    TRACE_ENTRY();
    1160     pVBox->vtSwitch = TRUE;
    11611177    if (pVBox->fHaveHGSMI)
    11621178        vboxDisableVbva(pScrn);
     
    11771193    VBOXPtr pVBox = VBOXGetRec(pScrn);
    11781194
    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    }
    11831203#ifdef VBOX_DRI
    11841204    if (pVBox->useDRI)
     
    11961216    vbox_close(pScrn, pVBox);
    11971217
    1198     /* Remove our observer functions from the X server call chains. */
    1199     pScrn->EnableDisableFBAccess = pVBox->EnableDisableFBAccess;
    12001218    pScreen->CloseScreen = pVBox->CloseScreen;
    12011219    return pScreen->CloseScreen(scrnIndex, pScreen);
     
    12111229    TRACE_LOG("HDisplay=%d, VDisplay=%d\n", pMode->HDisplay, pMode->VDisplay);
    12121230    pScrn = xf86Screens[scrnIndex];  /* Why does X have three ways of referring to the screen? */
     1231#ifndef VBOXVIDEO_13
    12131232    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    }
    12181255#ifdef VBOXVIDEO_13
    12191256    rc = xf86SetSingleMode(pScrn, pMode, 0);
     
    12221259    rc = VBOXSetMode(pScrn, 0, pMode->HDisplay, pMode->VDisplay,
    12231260                     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
    12351262    TRACE_LOG("returning %s\n", rc ? "TRUE" : "FALSE");
    12361263    return rc;
     
    12441271
    12451272    TRACE_ENTRY();
     1273    pVBox->aScreenLocation[0].x = x;
     1274    pVBox->aScreenLocation[0].y = y;
    12461275    /* Don't fiddle with the hardware if we are switched
    12471276     * 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    }
    12481283    VBOXSetMode(pScrn, 0, pVBox->aScreenLocation[0].cx,
    12491284                pVBox->aScreenLocation[0].cy, x, y);
  • trunk/src/VBox/Additions/x11/vboxvideo/vboxvideo.h

    r43108 r43245  
    160160    /** Default X server procedure for enabling and disabling framebuffer access */
    161161    xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
    162     /** Is access to the framebuffer currently allowed? */
    163     Bool accessEnabled;
    164162    OptionInfoPtr Options;
    165163    /** @todo we never actually free this */
     
    169167    /** Do we know that the guest can handle absolute co-ordinates? */
    170168    Bool guestCanAbsolute;
    171     /** Are we currently switched to a virtual terminal?  If so, it is not
    172      * safe to touch the hardware. */
    173     Bool vtSwitch;
    174169    /** Does this host support sending graphics commands using HGSMI? */
    175170    Bool fHaveHGSMI;
     
    179174     * sending dirty rectangle information to the right one. */
    180175    RTRECT2 aScreenLocation[VBOX_VIDEO_MAX_SCREENS];
     176    /** The last requested framebuffer size. */
     177    RTRECTSIZE FBSize;
    181178    /** Has this screen been disabled by the guest? */
    182179    Bool afDisabled[VBOX_VIDEO_MAX_SCREENS];
  • trunk/src/VBox/Additions/x11/vboxvideo/vbva.c

    r43081 r43245  
    5656
    5757    pVBox = pScrn->driverPrivate;
    58     if (pVBox->fHaveHGSMI == FALSE || pVBox->vtSwitch)
     58    if (pVBox->fHaveHGSMI == FALSE || !pScrn->vtSema)
    5959        return;
    6060
Note: See TracChangeset for help on using the changeset viewer.

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