drm: trigger vblank on commit

This commit is contained in:
Victor Brekenfeld 2020-04-19 01:35:04 +02:00
parent 74187f55fc
commit 41696f5364
3 changed files with 23 additions and 6 deletions

View File

@ -75,13 +75,16 @@ impl<D: RawDevice + 'static> GbmSurfaceInternal<D> {
if self.recreated.get() {
debug!(self.logger, "Commiting new state");
self.crtc.commit(fb).map_err(|_| SwapBuffersError::ContextLost)?;
if let Err(err) = self.crtc.commit(fb) {
error!(self.logger, "Error commiting crtc: {}", err);
return Err(SwapBuffersError::ContextLost);
}
self.recreated.set(false);
} else {
trace!(self.logger, "Queueing Page flip");
RawSurface::page_flip(&self.crtc, fb)?;
}
trace!(self.logger, "Queueing Page flip");
RawSurface::page_flip(&self.crtc, fb)?;
self.current_frame_buffer.set(Some(fb));
Ok(())

View File

@ -251,7 +251,18 @@ impl<A: AsRawFd + 'static> RawSurface for LegacyDrmSurfaceInternal<A> {
*current = pending.clone();
Ok(())
ControlDevice::page_flip(
self,
self.crtc,
framebuffer,
&[PageFlipFlags::PageFlipEvent],
None,
)
.map_err(|source| Error::Access {
errmsg: "Failed to queue page flip",
dev: self.dev_path(),
source: source.compat(),
})
}
fn page_flip(&self, framebuffer: framebuffer::Handle) -> ::std::result::Result<(), SwapBuffersError> {

View File

@ -205,7 +205,10 @@ pub trait RawSurface: Surface + ControlDevice + BasicDevice {
/// potentially causing some flickering. Check before performing this
/// operation if a commit really is necessary using [`commit_pending`](RawSurface::commit_pending).
///
/// This operation is blocking until the crtc is in the desired state.
/// This operation is not necessarily blocking until the crtc is in the desired state,
/// but will trigger a `vblank` event once done.
/// Make sure to [set a `DeviceHandler`](Device::set_handler) and
/// [register the belonging `Device`](device_bind) before to receive the event in time.
fn commit(&self, framebuffer: framebuffer::Handle) -> Result<(), <Self as Surface>::Error>;
/// Page-flip the underlying [`crtc`](drm::control::crtc)
/// to a new given [`framebuffer`].