Skip to content

Commit

Permalink
Wait for pending pageflip to finish before resetting CRTC
Browse files Browse the repository at this point in the history
  • Loading branch information
ehopperdietzel committed Feb 8, 2024
1 parent 2613ea4 commit b5928fc
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/lib/private/modes/SRMRenderModeCommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,11 @@ UInt8 srmRenderModeCommonWaitRepaintRequest(SRMConnector *connector)
if (connector->state == SRM_CONNECTOR_STATE_UNINITIALIZING)
{
pthread_mutex_unlock(&connector->stateMutex);
connector->interface->uninitializeGL(connector, connector->interfaceData);
connector->renderInterface.uninitialize(connector);

// Wait up to 1.5 sec for any pending pageflip event
connector->pendingPageFlip = 1;
srmRenderModeCommonWaitPageFlip(connector, 3);
connector->interface->uninitializeGL(connector, connector->interfaceData);
connector->renderInterface.uninitialize(connector);
eglReleaseThread();
connector->state = SRM_CONNECTOR_STATE_UNINITIALIZED;
return 0;
Expand Down Expand Up @@ -603,6 +602,10 @@ Int32 srmRenderModeCommonUpdateMode(SRMConnector *connector, UInt32 fb)
}
else
{
connector->pendingPageFlip = 1;
srmRenderModeCommonWaitPageFlip(connector, 3);
connector->pendingPageFlip = 0;

int ret;

drmModeSetCrtc(connector->device->fd,
Expand Down Expand Up @@ -653,6 +656,10 @@ Int32 srmRenderModeCommonUpdateMode(SRMConnector *connector, UInt32 fb)
}
else
{
connector->pendingPageFlip = 1;
srmRenderModeCommonWaitPageFlip(connector, 3);
connector->pendingPageFlip = 0;

ret = drmModeSetCrtc(connector->device->fd,
connector->currentCrtc->id,
0,
Expand Down Expand Up @@ -1197,7 +1204,7 @@ void srmRenderModeCommonWaitPageFlip(SRMConnector *connector, Int32 iterLimit)
break;
}

if (poll(&fds, 1, 500) > 0 && (fds.revents & POLLIN))
if (poll(&fds, 1, 10) > 0 && (fds.revents & POLLIN))
drmHandleEvent(fds.fd, &connector->drmEventCtx);
else if (iterLimit > 0)
iterLimit--;
Expand All @@ -1208,6 +1215,10 @@ void srmRenderModeCommonWaitPageFlip(SRMConnector *connector, Int32 iterLimit)

Int32 srmRenderModeAtomicResetConnectorProps(SRMConnector *connector)
{
connector->pendingPageFlip = 1;
srmRenderModeCommonWaitPageFlip(connector, 3);
connector->pendingPageFlip = 0;

Int32 ret;
drmModeAtomicReqPtr req;
req = drmModeAtomicAlloc();
Expand Down

0 comments on commit b5928fc

Please sign in to comment.