legacy: honor dev.active

This commit is contained in:
Victor Brekenfeld 2020-04-26 16:51:20 +02:00
parent 3d2e9aeff2
commit 7199640ad9
2 changed files with 29 additions and 4 deletions

View File

@ -76,9 +76,6 @@ impl<A: AsRawFd + 'static> Drop for Dev<A> {
error!(self.logger, "Failed to reset crtc ({:?}). Error: {}", handle, err); error!(self.logger, "Failed to reset crtc ({:?}). Error: {}", handle, err);
} }
} }
// turn it off, so that remaining surfaces (if any) will not change
// the state on drop
self.active.store(false, Ordering::SeqCst);
} }
if self.privileged { if self.privileged {
if let Err(err) = self.release_master_lock() { if let Err(err) = self.release_master_lock() {

View File

@ -48,6 +48,10 @@ impl<A: AsRawFd + 'static> CursorBackend for LegacyDrmSurfaceInternal<A> {
type Error = Error; type Error = Error;
fn set_cursor_position(&self, x: u32, y: u32) -> Result<(), Error> { fn set_cursor_position(&self, x: u32, y: u32) -> Result<(), Error> {
if !self.dev.active.load(Ordering::SeqCst) {
return Err(Error::DeviceInactive);
}
trace!(self.logger, "Move the cursor to {},{}", x, y); trace!(self.logger, "Move the cursor to {},{}", x, y);
self.move_cursor(self.crtc, (x as i32, y as i32)) self.move_cursor(self.crtc, (x as i32, y as i32))
.compat() .compat()
@ -63,6 +67,10 @@ impl<A: AsRawFd + 'static> CursorBackend for LegacyDrmSurfaceInternal<A> {
buffer: &Self::CursorFormat, buffer: &Self::CursorFormat,
hotspot: (u32, u32), hotspot: (u32, u32),
) -> Result<(), Error> { ) -> Result<(), Error> {
if !self.dev.active.load(Ordering::SeqCst) {
return Err(Error::DeviceInactive);
}
trace!(self.logger, "Setting the new imported cursor"); trace!(self.logger, "Setting the new imported cursor");
if self if self
@ -107,6 +115,10 @@ impl<A: AsRawFd + 'static> Surface for LegacyDrmSurfaceInternal<A> {
} }
fn add_connector(&self, conn: connector::Handle) -> Result<(), Error> { fn add_connector(&self, conn: connector::Handle) -> Result<(), Error> {
if !self.dev.active.load(Ordering::SeqCst) {
return Err(Error::DeviceInactive);
}
let mut pending = self.pending.write().unwrap(); let mut pending = self.pending.write().unwrap();
if self.check_connector(conn, &pending.mode)? { if self.check_connector(conn, &pending.mode)? {
@ -122,6 +134,10 @@ impl<A: AsRawFd + 'static> Surface for LegacyDrmSurfaceInternal<A> {
} }
fn set_connectors(&self, connectors: &[connector::Handle]) -> Result<(), Self::Error> { fn set_connectors(&self, connectors: &[connector::Handle]) -> Result<(), Self::Error> {
if !self.dev.active.load(Ordering::SeqCst) {
return Err(Error::DeviceInactive);
}
let mut pending = self.pending.write().unwrap(); let mut pending = self.pending.write().unwrap();
if connectors if connectors
@ -138,6 +154,10 @@ impl<A: AsRawFd + 'static> Surface for LegacyDrmSurfaceInternal<A> {
} }
fn use_mode(&self, mode: Mode) -> Result<(), Error> { fn use_mode(&self, mode: Mode) -> Result<(), Error> {
if !self.dev.active.load(Ordering::SeqCst) {
return Err(Error::DeviceInactive);
}
let mut pending = self.pending.write().unwrap(); let mut pending = self.pending.write().unwrap();
// check the connectors to see if this mode is supported // check the connectors to see if this mode is supported
@ -169,6 +189,10 @@ impl<A: AsRawFd + 'static> RawSurface for LegacyDrmSurfaceInternal<A> {
} }
fn commit(&self, framebuffer: framebuffer::Handle) -> Result<(), Error> { fn commit(&self, framebuffer: framebuffer::Handle) -> Result<(), Error> {
if !self.dev.active.load(Ordering::SeqCst) {
return Err(Error::DeviceInactive);
}
let mut current = self.state.write().unwrap(); let mut current = self.state.write().unwrap();
let pending = self.pending.read().unwrap(); let pending = self.pending.read().unwrap();
@ -254,6 +278,10 @@ impl<A: AsRawFd + 'static> RawSurface for LegacyDrmSurfaceInternal<A> {
fn page_flip(&self, framebuffer: framebuffer::Handle) -> ::std::result::Result<(), SwapBuffersError> { fn page_flip(&self, framebuffer: framebuffer::Handle) -> ::std::result::Result<(), SwapBuffersError> {
trace!(self.logger, "Queueing Page flip"); trace!(self.logger, "Queueing Page flip");
if !self.dev.active.load(Ordering::SeqCst) {
return Err(SwapBuffersError::AlreadySwapped);
}
ControlDevice::page_flip( ControlDevice::page_flip(
self, self,
self.crtc, self.crtc,