<html><body><div style="font-family: times new roman, new york, times, serif; font-size: 12pt; color: #000000"><div><br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;" data-mce-style="border-left: 2px solid #1010FF; margin-left: 5px; padding-left: 5px; color: #000; font-weight: normal; font-style: normal; text-decoration: none; font-family: Helvetica,Arial,sans-serif; font-size: 12pt;"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Sep 26, 2016 at 7:15 PM, Frediano Ziglio <span dir="ltr"><<a href="mailto:fziglio@redhat.com" target="_blank" data-mce-href="mailto:fziglio@redhat.com">fziglio@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><div class="HOEnZb"><div class="h5">><br> > This patch fixes 2 issues:<br> ><br> >   1. Framebuffer should only be used in vga mode,<br> >      therefore when QxlDevice is active<br> >      FrameBufferIsActive flag shouldn't be checked;<br> >   2. FrameBufferIsActive flag should be set true<br> >      on successfull frame buffer allocation only.<br> ><br> > Signed-off-by: Dmitry Fleytman <<a href="mailto:dmitry@daynix.com" target="_blank" data-mce-href="mailto:dmitry@daynix.com">dmitry@daynix.com</a>><br> > Signed-off-by: Sameeh Jubran <<a href="mailto:sameeh@daynix.com" target="_blank" data-mce-href="mailto:sameeh@daynix.com">sameeh@daynix.com</a>><br> > ---<br> >  qxldod/QxlDod.cpp | 116<br> >  +++++++++++++++++++++++++++---------------------------<br> >  1 file changed, 58 insertions(+), 58 deletions(-)<br> ><br> > diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp<br> > index 85d6d94..ca3f8a3 100755<br> > --- a/qxldod/QxlDod.cpp<br> > +++ b/qxldod/QxlDod.cpp<br> > @@ -523,40 +523,37 @@ NTSTATUS QxlDod::PresentDisplayOnly(_In_ CONST<br> > DXGKARG_PRESENT_DISPLAYONLY* pPre<br> >          return STATUS_SUCCESS;<br> >      }<br> ><br> > -    if<br> > (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Flags.FrameBufferIsActive)<br> > -    {<br> > -<br> > -        // If actual pixels are coming through, will need to completely zero<br> > out physical address next time in BlackOutScreen<br> > -<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].ZeroedOutStart.QuadPart<br> > = 0;<br> > -<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].ZeroedOutEnd.QuadPart<br> > = 0;<br> ><br> > -<br> > -        D3DKMDT_VIDPN_PRESENT_PATH_ROTATION RotationNeededByFb =<br> > pPresentDisplayOnly->Flags.Rotate ?<br> > -<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Rotation<br> > :<br> > -<br> > D3DKMDT_VPPR_IDENTITY;<br> > -        BYTE* pDst =<br> > (BYTE*)m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].FrameBuffer.Ptr;<br> > -        UINT DstBitPerPixel =<br> > BPPFromPixelFormat(m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.ColorFormat);<br> > -        if (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Scaling ==<br> > D3DKMDT_VPPS_CENTERED)<br> > -        {<br> > -            UINT CenterShift =<br> > (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Height -<br> > -<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].SrcModeHeight)*m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Pitch;<br> > -            CenterShift +=<br> > (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Width -<br> > -<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].SrcModeWidth)*DstBitPerPixel/8;<br> > -            pDst += (int)CenterShift/2;<br> > -        }<br> > -        Status = m_pHWDevice->ExecutePresentDisplayOnly(<br> > -                            pDst,<br> > -                            DstBitPerPixel,<br> > -                            (BYTE*)pPresentDisplayOnly->pSource,<br> > -                            pPresentDisplayOnly->BytesPerPixel,<br> > -                            pPresentDisplayOnly->Pitch,<br> > -                            pPresentDisplayOnly->NumMoves,<br> > -                            pPresentDisplayOnly->pMoves,<br> > -                            pPresentDisplayOnly->NumDirtyRects,<br> > -                            pPresentDisplayOnly->pDirtyRect,<br> > -                            RotationNeededByFb,<br> > -                            &m_CurrentModes[0]);<br> > -    }<br> > +    // If actual pixels are coming through, will need to completely zero out<br> > physical address next time in BlackOutScreen<br> > +<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].ZeroedOutStart.QuadPart<br> > = 0;<br> > +    m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].ZeroedOutEnd.QuadPart<br> > = 0;<br> > +<br> > +<br> > +    D3DKMDT_VIDPN_PRESENT_PATH_ROTATION RotationNeededByFb =<br> > pPresentDisplayOnly->Flags.Rotate ?<br> > +<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Rotation<br> > :<br> > +<br> > D3DKMDT_VPPR_IDENTITY;<br> > +    BYTE* pDst =<br> > (BYTE*)m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].FrameBuffer.Ptr;<br> > +    UINT DstBitPerPixel =<br> > BPPFromPixelFormat(m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.ColorFormat);<br> > +    if (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].Scaling ==<br> > D3DKMDT_VPPS_CENTERED)<br> > +    {<br> > +        UINT CenterShift =<br> > (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Height -<br> > +<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].SrcModeHeight)*m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Pitch;<br> > +        CenterShift +=<br> > (m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].DispInfo.Width -<br> > +<br> > m_CurrentModes[pPresentDisplayOnly->VidPnSourceId].SrcModeWidth)*DstBitPerPixel/8;<br> > +        pDst += (int)CenterShift/2;<br> > +    }<br> > +    Status = m_pHWDevice->ExecutePresentDisplayOnly(<br> > +                        pDst,<br> > +                        DstBitPerPixel,<br> > +                        (BYTE*)pPresentDisplayOnly->pSource,<br> > +                        pPresentDisplayOnly->BytesPerPixel,<br> > +                        pPresentDisplayOnly->Pitch,<br> > +                        pPresentDisplayOnly->NumMoves,<br> > +                        pPresentDisplayOnly->pMoves,<br> > +                        pPresentDisplayOnly->NumDirtyRects,<br> > +                        pPresentDisplayOnly->pDirtyRect,<br> > +                        RotationNeededByFb,<br> > +                        &m_CurrentModes[0]);<br> >      DbgPrint(TRACE_LEVEL_VERBOSE, ("<--- %s\n", __FUNCTION__));<br> >      return Status;<br> >  }<br> > @@ -1542,12 +1539,11 @@ NTSTATUS QxlDod::SetSourceModeAndPath(CONST<br> > D3DKMDT_VIDPN_SOURCE_MODE* pSourceMo<br> >      pCurrentBddMode->DispInfo.Height =<br> >      pSourceMode-><a href="http://Format.Graphics.PrimSurfSize.cy" rel="noreferrer" target="_blank" data-mce-href="http://Format.Graphics.PrimSurfSize.cy">Format.Graphics.PrimSurfSize.cy</a>;<br> >      pCurrentBddMode->DispInfo.Pitch =<br> >      pSourceMode-><a href="http://Format.Graphics.PrimSurfSize.cx" rel="noreferrer" target="_blank" data-mce-href="http://Format.Graphics.PrimSurfSize.cx">Format.Graphics.PrimSurfSize.cx</a> *<br> >      BPPFromPixelFormat(pCurrentBddMode->DispInfo.ColorFormat) /<br> >      BITS_PER_BYTE;<br> ><br> > -    Status = m_pHWDevice->AcquireFrameBuffer(pCurrentBddMode);<br> > +        Status = m_pHWDevice->AcquireFrameBuffer(pCurrentBddMode);<br> ><br><br></div></div>Here I think it's just a small mistake, no reason to indent more.<br><span class=""><br> >      if (NT_SUCCESS(Status))<br> >      {<br> ><br> > -        pCurrentBddMode->Flags.FrameBufferIsActive = TRUE;<br> <br> </span>I would remove the empty line above<br><div><div class="h5"><br> >          m_pHWDevice->BlackOutScreen(&m_CurrentModes[pPath->VidPnSourceId]);<br> ><br> >          // Mark that the next present should be fullscreen so the screen<br> >          doesn't go from black to actual pixels one dirty rect at a time.<br> > @@ -2979,11 +2975,18 @@ VOID VgaDevice::ResetDevice(VOID)<br> ><br> >  NTSTATUS VgaDevice::AcquireFrameBuffer(CURRENT_BDD_MODE* pCurrentBddMode)<br> >  {<br> > -    // Map the new frame buffer<br> > -    QXL_ASSERT(pCurrentBddMode->FrameBuffer.Ptr == NULL);<br> > -    NTSTATUS status =<br> > MapFrameBuffer(pCurrentBddMode->DispInfo.PhysicAddress,<br> > -        pCurrentBddMode->DispInfo.Pitch * pCurrentBddMode->DispInfo.Height,<br> > -        &(pCurrentBddMode->FrameBuffer.Ptr));<br> > +    NTSTATUS status = STATUS_UNSUCCESSFUL;<br> > +    if (!pCurrentBddMode->Flags.DoNotMapOrUnmap) {<br> > +        // Map the new frame buffer<br> > +        QXL_ASSERT(pCurrentBddMode->FrameBuffer.Ptr == NULL);<br> > +        status = MapFrameBuffer(pCurrentBddMode->DispInfo.PhysicAddress,<br> > +            pCurrentBddMode->DispInfo.Pitch *<br> > pCurrentBddMode->DispInfo.Height,<br> > +            &(pCurrentBddMode->FrameBuffer.Ptr));<br> > +        if (NT_SUCCESS(status))<br> > +        {<br> > +            pCurrentBddMode->Flags.FrameBufferIsActive = TRUE;<br> > +        }<br> > +    }<br> >      return status;<br> >  }<br> ><br><br></div></div>Here I would just add a<br><br>     if (!pCurrentBddMode->Flags.DoNotMapOrUnmap) {<br>         return STATUS_UNSUCCESSFUL;<br>     }<br><br> just after the function starts.<br><div><div class="h5"><br> > @@ -4501,26 +4504,23 @@ VOID QxlDevice::BlackOutScreen(CURRENT_BDD_MODE*<br> > pCurrentBddMod)<br> >      QXLDrawable *drawable;<br> >      RECT Rect;<br> >      PAGED_CODE();<br> > -    if (pCurrentBddMod->Flags.FrameBufferIsActive)<br> > +    Rect.bottom = pCurrentBddMod->SrcModeHeight;<br> > +    Rect.top = 0;<br> > +    Rect.left = 0;<br> > +    Rect.right = pCurrentBddMod->SrcModeWidth;<br> > +    if (!(drawable = Drawable(QXL_DRAW_FILL, &Rect, NULL, 0)))<br> >      {<br> > -        Rect.bottom = pCurrentBddMod->SrcModeHeight;<br> > -        Rect.top = 0;<br> > -        Rect.left = 0;<br> > -        Rect.right = pCurrentBddMod->SrcModeWidth;<br> > -        if (!(drawable = Drawable(QXL_DRAW_FILL, &Rect, NULL, 0)))<br> > -        {<br> > -            DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n"));<br> > -            return;<br> > -        }<br> > -        drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;<br> > -        drawable->u.fill.brush.u.color = 0;<br> > -        drawable->u.fill.rop_descriptor = SPICE_ROPD_OP_PUT;<br> > -        drawable->u.fill.mask.flags = 0;<br> > -        drawable->u.fill.mask.pos.x = 0;<br> > -        drawable->u.fill.mask.pos.y = 0;<br> > -        drawable->u.fill.mask.bitmap = 0;<br> > -        PushDrawable(drawable);<br> > +        DbgPrint(TRACE_LEVEL_ERROR, ("Cannot get Drawable.\n"));<br> > +        return;<br> >      }<br> > +    drawable->u.fill.brush.type = SPICE_BRUSH_TYPE_SOLID;<br> > +    drawable->u.fill.brush.u.color = 0;<br> > +    drawable->u.fill.rop_descriptor = SPICE_ROPD_OP_PUT;<br> > +    drawable->u.fill.mask.flags = 0;<br> > +    drawable->u.fill.mask.pos.x = 0;<br> > +    drawable->u.fill.mask.pos.y = 0;<br> > +    drawable->u.fill.mask.bitmap = 0;<br> > +    PushDrawable(drawable);<br> >  }<br> ><br> >  __declspec(code_seg("PAGE"))<br><br></div></div>All changes I commented are mainly spaces and small style, if you<br> agree I can change them, if not reply.<br></blockquote><div>Yes, go ahead. </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" data-mce-style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;"><br> Acked-by: Frediano Ziglio <<a href="mailto:fziglio@redhat.com" target="_blank" data-mce-href="mailto:fziglio@redhat.com">fziglio@redhat.com</a>><br></blockquote></div></div></div></blockquote><div><br></div><div>Merged<br></div><div><br></div><div>Frediano</div><div><br></div></div></body></html>