VirtualBox

Changeset 2106 in vbox for trunk/src/VBox/Devices/Graphics


Ignore:
Timestamp:
Apr 16, 2007 3:25:48 PM (18 years ago)
Author:
vboxsync
Message:

Do not block EMT while resizing the framebuffer.

Location:
trunk/src/VBox/Devices/Graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA.cpp

    r2079 r2106  
    14061406 * - flashing
    14071407 */
     1408#ifndef VBOX
    14081409static void vga_draw_text(VGAState *s, int full_update)
     1410#else
     1411static int vga_draw_text(VGAState *s, int full_update)
     1412#endif /* !VBOX */
    14091413{
    14101414    int cx, cy, cheight, cw, ch, cattr, height, width, ch_attr;
     
    14841488    if ((height * width) > CH_ATTR_SIZE) {
    14851489        /* better than nothing: exit if transient size is too big */
     1490#ifndef VBOX
    14861491        return;
     1492#else
     1493        return VINF_SUCCESS;
     1494#endif /* VBOX */
    14871495    }
    14881496
     
    14931501#ifndef VBOX
    14941502        dpy_resize(s->ds, s->last_scr_width, s->last_scr_height);
    1495 #else /* VBOX */
    1496         /* For text modes the external memory buffer can not be used, so bpp and cbLine are 0 here. */
    1497         s->pDrv->pfnResize(s->pDrv, 0, NULL, 0, s->last_scr_width, s->last_scr_height);
    1498 #endif /* VBOX */
    14991503        s->last_width = width;
    15001504        s->last_height = height;
     
    15021506        s->last_cw = cw;
    15031507        full_update = 1;
     1508#else /* VBOX */
     1509        /* For text modes the direct use of guest VRAM is not implemented, so bpp and cbLine are 0 here. */
     1510        int rc = s->pDrv->pfnResize(s->pDrv, 0, NULL, 0, s->last_scr_width, s->last_scr_height);
     1511        s->last_width = width;
     1512        s->last_height = height;
     1513        s->last_ch = cheight;
     1514        s->last_cw = cw;
     1515        full_update = 1;
     1516        if (rc == VINF_VGA_RESIZE_IN_PROGRESS)
     1517            return rc;
     1518        AssertRC(rc);
     1519#endif /* VBOX */
    15041520    }
    15051521    cursor_offset = ((s->cr[0x0e] << 8) | s->cr[0x0f]) - s->start_addr;
     
    16121628        s1 += line_offset;
    16131629    }
     1630#ifdef VBOX
     1631        return VINF_SUCCESS;
     1632#endif /* VBOX */
    16141633}
    16151634
     
    17441763{
    17451764    const unsigned cBits = s->get_bpp(s);
    1746 #if 0 /** @todo kill the nasty resize deadlocks! */
    1747     int rc = s->pDrv->pfnResize(s->pDrv, cBits, s->CTXSUFF(vram_ptr), s->line_offset, cx, cy);
    1748     if (rc == VINF_VGA_RESIZE_IN_PROGRESS)
    1749         return rc;
    1750     AssertRC(rc);
    1751 #else
    17521765    /** @todo r=sunlover: If the guest changes VBE_DISPI_INDEX_X_OFFSET, VBE_DISPI_INDEX_Y_OFFSET
    17531766     *                    registers, then the third parameter of the following call should be
    17541767     *                    probably 's->CTXSUFF(vram_ptr) + s->vbe_start_addr'.
    17551768     */
    1756     s->pDrv->pfnResize(s->pDrv, cBits, s->CTXSUFF(vram_ptr), s->line_offset, cx, cy);
    1757 #endif
     1769    int rc = s->pDrv->pfnResize(s->pDrv, cBits, s->CTXSUFF(vram_ptr), s->line_offset, cx, cy);
    17581770
    17591771    /* last stuff */
     
    17641776    s->last_height = cy;
    17651777
     1778    if (rc == VINF_VGA_RESIZE_IN_PROGRESS)
     1779        return rc;
     1780    AssertRC(rc);
     1781
    17661782    /* update palette */
    17671783    switch (s->pDrv->cBits)
     
    17841800 * graphic modes
    17851801 */
     1802#ifndef VBOX
    17861803static void vga_draw_graphic(VGAState *s, int full_update)
     1804#else
     1805static int vga_draw_graphic(VGAState *s, int full_update)
     1806#endif /* !VBOX */
    17871807{
    17881808    int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask;
     
    18751895        ||  height         != (int)s->last_height
    18761896        ||  s->get_bpp(s)  != (int)s->last_bpp
    1877         ||  offsets_changed) {
    1878         if (vga_resize_graphic(s, disp_width, height, v) != VINF_SUCCESS)
    1879             return;
     1897        ||  offsets_changed)
     1898    {
     1899        int rc = vga_resize_graphic(s, disp_width, height, v);
     1900        if (rc != VINF_SUCCESS)  /* Return any rc, particularly VINF_VGA_RESIZE_IN_PROGRESS, to the caller. */
     1901            return rc;
    18801902        full_update = 1;
    18811903    }
     
    19001922     * programming of the virtual hardware ports. Just return.
    19011923     */
    1902     if (bwidth == 0) return;
     1924    if (bwidth == 0) return VINF_SUCCESS;
    19031925#endif /* VBOX */
    19041926    y_start = -1;
     
    19571979            vga_draw_line(s, d, s->vram_ptr + addr, width);
    19581980#else /* VBOX */
    1959             if (s->pvExtVRAMHC != s->pDrv->pu8Data) /* Only if external VRAM was not setup. */
     1981            if (s->fRenderVRAM)
    19601982                vga_draw_line(s, d, s->CTXSUFF(vram_ptr) + addr, width);
    19611983#endif /* VBOX */
     
    20072029    }
    20082030    memset(s->invalidated_y_table, 0, ((height + 31) >> 5) * 4);
     2031#ifdef VBOX
     2032    return VINF_SUCCESS;
     2033#endif /* VBOX */
    20092034}
    20102035
     
    20622087void vga_update_display(void)
    20632088{
    2064 #ifdef DEBUG_sunlover
    2065     LogFlow(("vga_update_display"));
    2066 #endif /* DEBUG_sunlover */
    2067 
    20682089    VGAState *s = vga_state;
    20692090#else /* VBOX */
    2070 static void vga_update_display(PVGASTATE s)
    2071 {
     2091static int vga_update_display(PVGASTATE s)
     2092{
     2093    int rc = VINF_SUCCESS;
    20722094#endif /* VBOX */
    20732095    int full_update, graphic_mode;
     
    21122134        switch(graphic_mode) {
    21132135        case GMODE_TEXT:
     2136#ifdef VBOX
     2137            rc =
     2138#endif /* VBOX */
    21142139            vga_draw_text(s, full_update);
    21152140            break;
    21162141        case GMODE_GRAPH:
     2142#ifdef VBOX
     2143            rc =
     2144#endif /* VBOX */
    21172145            vga_draw_graphic(s, full_update);
    21182146            break;
     
    21232151        }
    21242152    }
     2153#ifdef VBOX
     2154    return rc;
     2155#endif /* VBOX */
    21252156}
    21262157
     
    35223553 * @thread  The emulation thread.
    35233554 */
    3524 static DECLCALLBACK(void) vgaDummyResize(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy)
    3525 {
     3555static DECLCALLBACK(int) vgaDummyResize(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy)
     3556{
     3557    return VINF_SUCCESS;
    35263558}
    35273559
     
    35723604 * @see     PDMIKEYBOARDPORT::pfnUpdateDisplay() for details.
    35733605 */
    3574 static DECLCALLBACK(void) vgaPortUpdateDisplay(PPDMIDISPLAYPORT pInterface)
     3606static DECLCALLBACK(int) vgaPortUpdateDisplay(PPDMIDISPLAYPORT pInterface)
    35753607{
    35763608    PVGASTATE pData = IDISPLAYPORT_2_VGASTATE(pInterface);
     
    35833615    /* This should be called only in non VBVA mode. */
    35843616
    3585     vga_update_display(pData);
     3617    int rc = vga_update_display(pData);
     3618    if (rc != VINF_SUCCESS)
     3619        return rc;
    35863620
    35873621    if (pData->fHaveDirtyBits)
     
    35913625        pData->fHaveDirtyBits = false;
    35923626    }
     3627
     3628    return VINF_SUCCESS;
    35933629}
    35943630
     
    36003636 * @see     PDMIKEYBOARDPORT::pfnUpdateDisplayAll() for details.
    36013637 */
    3602 static DECLCALLBACK(void) vgaPortUpdateDisplayAll(PPDMIDISPLAYPORT pInterface)
     3638static DECLCALLBACK(int) vgaPortUpdateDisplayAll(PPDMIDISPLAYPORT pInterface)
    36033639{
    36043640    PVGASTATE pData = IDISPLAYPORT_2_VGASTATE(pInterface);
     
    36123648
    36133649    pData->graphic_mode = -1; /* force full update */
    3614     vga_update_display(pData);
     3650    return vga_update_display(pData);
    36153651}
    36163652
     
    36603696static DECLCALLBACK(int) vgaPortSnapshot(PPDMIDISPLAYPORT pInterface, void *pvData, size_t cbData, uint32_t *pcx, uint32_t *pcy, size_t *pcbData)
    36613697{
     3698    /* @todo r=sunlover: replace the method with a direct VRAM rendering like in vgaPortUpdateDisplayRect.  */
    36623699    PPDMIDISPLAYCONNECTOR   pConnector;
    36633700    PDMIDISPLAYCONNECTOR    Connector;
     
    37133750
    37143751    /* make the snapshot. */
    3715     vga_update_display(pData);
     3752    int rc = vga_update_display(pData);
     3753    if (rc != VINF_SUCCESS)
     3754        return rc;
    37163755
    37173756    /* restore */
     
    38433882
    38443883    /* Check if there is something to do at all. */
    3845     if (s->pvExtVRAMHC == s->pDrv->pu8Data)
     3884    if (!s->fRenderVRAM)
    38463885    {
    38473886        /* The framebuffer uses the guest VRAM directly. */
    38483887#ifdef DEBUG_sunlover
    3849         LogFlow(("vgaPortUpdateDisplayRect: nothing to do: s->pvExtVRAMHC %p, s->pDrv->pu8Data %p\n", s->pvExtVRAMHC, s->pDrv->pu8Data));
     3888        LogFlow(("vgaPortUpdateDisplayRect: nothing to do fRender is false.\n"));
    38503889#endif /* DEBUG_sunlover */
    38513890        return;
     
    39443983     * This is true because coordinates were verified.
    39453984     */
    3946     pu8Src = s->pvExtVRAMHC? (uint8_t *)s->pvExtVRAMHC: s->vram_ptrHC;
     3985    pu8Src = s->vram_ptrHC;
    39473986    pu8Src += u32OffsetSrc + y * cbLineSrc + x * cbPixelSrc;
    39483987
     
    39654004}
    39664005
    3967 static DECLCALLBACK(int) vgaPortSetupVRAM (PPDMIDISPLAYPORT pInterface, void *pvBuffer, uint32_t cbBuffer)
    3968 {
    3969     int rc = VINF_SUCCESS;
     4006static DECLCALLBACK(void) vgaPortSetRenderVRAM(PPDMIDISPLAYPORT pInterface, bool fRender)
     4007{
    39704008    PVGASTATE s = IDISPLAYPORT_2_VGASTATE(pInterface);
    3971     PPDMDEVINS pDevIns;
    3972     PVM pVM;
    3973 
    3974     uint32_t u32OverlayOffset = 0;
    3975 
    3976     LogFlow(("vgaPortSetupVRAM: pvBuffer = %p, cbBuffer = 0x%08X, s->vram_ptrHC = %p\n", pvBuffer, cbBuffer, s->vram_ptrHC));
    3977 
    3978     /* Check input values, Main::Display rely on that. */
    3979     if (ALIGNP(pvBuffer, PAGE_SIZE) != pvBuffer)
    3980     {
    3981         LogFlow(("vgaPortSetupVRAM: Not aligned address.\n"));
    3982         return VERR_INVALID_PARAMETER;
    3983     }
    3984 
    3985     pDevIns = s->pDevInsHC;
    3986     Assert(pDevIns);
    3987 
    3988     pVM = PDMDevHlpGetVM(pDevIns);
    3989     Assert(pVM);
    3990 
    3991     if (s->pvExtVRAMHC != NULL)
    3992     {
    3993         if (s->pvExtVRAMHC != s->vram_ptrHC)
    3994         {
    3995             /* @todo */
    3996             AssertMsgFailed(("Too early to call SetupVRAM with external VRAM\n"));
    3997 
    3998             /* Remove existing overlay mapping. */
    3999 //            MMR3PPhysUnregisterOverlay (pVM, s->GCPhysVRAM, u32OverlayOffset, s->pvExtVRAMHC, s->cbExtVRAM);
    4000 
    4001             /* Copy the content of the external VRAM to the device VRAM. */
    4002             memcpy (s->vram_ptrHC + u32OverlayOffset, s->pvExtVRAMHC, s->cbExtVRAM);
    4003         }
    4004 
    4005         s->pvExtVRAMHC = NULL;
    4006         s->cbExtVRAM = 0;
    4007     }
    4008 
    4009     if (pvBuffer == NULL)
    4010     {
    4011         /* Resetting VRAM to use only vga device allocated memory. */
    4012         Assert (cbBuffer == 0);
    4013         return VINF_SUCCESS;
    4014     }
    4015 
    4016     if (pvBuffer == s->vram_ptrHC)
    4017     {
    4018         /* Caller will use the guest VRAM directly. Do nothing. Ignore cbBuffer. */
    4019         cbBuffer = 0;
    4020         rc = VINF_SUCCESS;
    4021     }
    4022     else
    4023     {
    4024         /* Register new overlay. */
    4025 
    4026         /* @todo */
    4027         AssertMsgFailed(("Too early to call SetupVRAM with external VRAM\n"));
    4028 
    4029         cbBuffer = RT_ALIGN_32(cbBuffer, PAGE_SIZE);
    4030 
    4031 //        rc = MMR3PhysRegisterOverlay(pVM, s->GCPhysVRAM, u32OverlayOffset, pvBuffer, cbBuffer, "FBVRam");
    4032     }
    4033 
    4034     if (VBOX_SUCCESS (rc))
    4035     {
    4036         s->pvExtVRAMHC = pvBuffer;
    4037         s->cbExtVRAM = cbBuffer;
    4038     }
    4039 
    4040     return rc;
     4009
     4010    LogFlow(("vgaPortSetRenderVRAM: fRender = %d\n", fRender));
     4011
     4012    s->fRenderVRAM = fRender;
    40414013}
    40424014
     
    45754547    pData->Port.pfnDisplayBlt       = vgaPortDisplayBlt;
    45764548    pData->Port.pfnUpdateDisplayRect= vgaPortUpdateDisplayRect;
    4577     pData->Port.pfnSetupVRAM        = vgaPortSetupVRAM;
     4549    pData->Port.pfnSetRenderVRAM    = vgaPortSetRenderVRAM;
    45784550
    45794551
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r2079 r2106  
    281281    uint32_t                    Padding0;   /* May be removed if more data is added */
    282282
    283     /** Size of the buffer*/
    284     uint32_t                    cbExtVRAM;
    285     /** Address of external video memory buffer overlaying VRAM. */
    286     R3PTRTYPE(void *)           pvExtVRAMHC;
    287 #if HC_ARCH_BITS ==32
    288     uint32_t                    Alignment0;
    289 #endif
     283    /** Whether to render the guest VRAM to the framebuffer memory. False only for some LFB modes. */
     284    uint32_t                    fRenderVRAM;
    290285
    291286    /** The PCI device. */
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