anvil: use atomic modesetting

This commit is contained in:
Victor Brekenfeld 2020-04-19 01:39:56 +02:00
parent 365b7e6496
commit d30bd4555e
4 changed files with 30 additions and 6 deletions

View File

@ -29,5 +29,5 @@ gl_generator = "0.14"
default = [ "winit", "egl", "udev", "logind" ] default = [ "winit", "egl", "udev", "logind" ]
egl = [ "smithay/use_system_lib" ] egl = [ "smithay/use_system_lib" ]
winit = [ "smithay/backend_winit" ] winit = [ "smithay/backend_winit" ]
udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm_legacy", "smithay/backend_drm_gbm", "smithay/backend_drm_egl", "smithay/backend_session", "input" ] udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm_atomic", "smithay/backend_drm_gbm", "smithay/backend_drm_egl", "smithay/backend_session", "input" ]
logind = [ "smithay/backend_session_logind" ] logind = [ "smithay/backend_session_logind" ]

View File

@ -22,8 +22,12 @@ use smithay::{
device_bind, device_bind,
egl::{EglDevice, EglSurface}, egl::{EglDevice, EglSurface},
gbm::{egl::Gbm as EglGbmBackend, GbmDevice}, gbm::{egl::Gbm as EglGbmBackend, GbmDevice},
legacy::LegacyDrmDevice, atomic::AtomicDrmDevice,
DevPath, Device, DeviceHandler, Surface, //legacy::LegacyDrmDevice,
DevPath,
Device,
DeviceHandler,
Surface,
}, },
graphics::CursorBackend, graphics::CursorBackend,
input::InputBackend, input::InputBackend,
@ -76,8 +80,9 @@ impl AsRawFd for SessionFd {
} }
type RenderDevice = type RenderDevice =
EglDevice<EglGbmBackend<LegacyDrmDevice<SessionFd>>, GbmDevice<LegacyDrmDevice<SessionFd>>>; EglDevice<EglGbmBackend<AtomicDrmDevice<SessionFd>>, GbmDevice<AtomicDrmDevice<SessionFd>>>;
type RenderSurface = EglSurface<GbmSurface<LegacyDrmDevice<SessionFd>>>; type RenderSurface =
EglSurface<GbmSurface<AtomicDrmDevice<SessionFd>>>;
pub fn run_udev(mut display: Display, mut event_loop: EventLoop<AnvilState>, log: Logger) -> Result<(), ()> { pub fn run_udev(mut display: Display, mut event_loop: EventLoop<AnvilState>, log: Logger) -> Result<(), ()> {
let name = display.add_socket_auto().unwrap().into_string().unwrap(); let name = display.add_socket_auto().unwrap().into_string().unwrap();
@ -412,7 +417,7 @@ impl<S: SessionNotifier, Data: 'static> UdevHandler for UdevHandlerImpl<S, Data>
) )
.ok() .ok()
.and_then( .and_then(
|fd| match LegacyDrmDevice::new(SessionFd(fd), self.logger.clone()) { |fd| match AtomicDrmDevice::new(SessionFd(fd), self.logger.clone()) {
Ok(drm) => Some(drm), Ok(drm) => Some(drm),
Err(err) => { Err(err) => {
error!(self.logger, "Skipping drm device, because of error: {}", err); error!(self.logger, "Skipping drm device, because of error: {}", err);

View File

@ -1,3 +1,13 @@
//!
//! [`RawDevice`](RawDevice) and [`RawSurface`](RawSurface)
//! implementations using the atomic mode-setting infrastructure.
//!
//! Usually this implementation will wrapped into a [`GbmDevice`](::backend::drm::gbm::GbmDevice).
//! Take a look at `anvil`s source code for an example of this.
//!
//! For an example how to use this standalone, take a look at the raw_atomic_drm example.
//!
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::io::{AsRawFd, RawFd};
@ -26,6 +36,7 @@ use self::surface::AtomicDrmSurfaceInternal;
#[cfg(feature = "backend_session")] #[cfg(feature = "backend_session")]
pub mod session; pub mod session;
/// Open raw drm device utilizing atomic mode-setting
pub struct AtomicDrmDevice<A: AsRawFd + 'static> { pub struct AtomicDrmDevice<A: AsRawFd + 'static> {
dev: Rc<Dev<A>>, dev: Rc<Dev<A>>,
dev_id: dev_t, dev_id: dev_t,

View File

@ -1,3 +1,8 @@
//!
//! Support to register an open [`AtomicDrmDevice`](AtomicDrmDevice)
//! to an open [`Session`](::backend::session::Session).
//!
use drm::control::crtc; use drm::control::crtc;
use drm::Device as BasicDevice; use drm::Device as BasicDevice;
use nix::libc::dev_t; use nix::libc::dev_t;
@ -12,6 +17,9 @@ use std::sync::Arc;
use super::{AtomicDrmDevice, AtomicDrmSurfaceInternal, Dev}; use super::{AtomicDrmDevice, AtomicDrmSurfaceInternal, Dev};
use crate::backend::session::{AsSessionObserver, SessionObserver}; use crate::backend::session::{AsSessionObserver, SessionObserver};
/// [`SessionObserver`](SessionObserver)
/// linked to the [`AtomicDrmDevice`](AtomicDrmDevice)
/// it was created from.
pub struct AtomicDrmDeviceObserver<A: AsRawFd + 'static> { pub struct AtomicDrmDeviceObserver<A: AsRawFd + 'static> {
dev: Weak<Dev<A>>, dev: Weak<Dev<A>>,
dev_id: dev_t, dev_id: dev_t,