anvil: use fallback-device for gbm/nvidia

This commit is contained in:
Victor Brekenfeld 2020-05-22 23:15:07 +02:00
parent 9acd109a04
commit 0c19a461b6
2 changed files with 33 additions and 17 deletions

View File

@ -29,5 +29,5 @@ gl_generator = "0.14"
default = [ "winit", "egl", "udev", "logind" ]
egl = [ "smithay/use_system_lib" ]
winit = [ "smithay/backend_winit" ]
udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm_atomic", "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_legacy", "smithay/backend_drm_gbm", "smithay/backend_drm_eglstream", "smithay/backend_drm_egl", "smithay/backend_session", "input" ]
logind = [ "smithay/backend_session_logind" ]

View File

@ -18,9 +18,10 @@ use smithay::{
backend::{
drm::{
atomic::AtomicDrmDevice,
common::fallback::FallbackDevice,
common::fallback::{FallbackDevice, FallbackSurface},
device_bind,
egl::{EglDevice, EglSurface},
eglstream::{egl::EglStreamDeviceBackend, EglStreamDevice, EglStreamSurface},
gbm::{egl::Gbm as EglGbmBackend, GbmDevice, GbmSurface},
legacy::LegacyDrmDevice,
DevPath, Device, DeviceHandler, Surface,
@ -76,12 +77,20 @@ impl AsRawFd for SessionFd {
}
}
type RenderDevice = EglDevice<
type RenderDevice = FallbackDevice<
EglDevice<
EglGbmBackend<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
GbmDevice<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
>,
EglDevice<
EglStreamDeviceBackend<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
EglStreamDevice<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>,
>,
>;
type RenderSurface = FallbackSurface<
EglSurface<GbmSurface<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>>,
EglSurface<EglStreamSurface<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>>,
>;
type RenderSurface =
EglSurface<GbmSurface<FallbackDevice<AtomicDrmDevice<SessionFd>, LegacyDrmDevice<SessionFd>>>>;
pub fn run_udev(
display: Rc<RefCell<Display>>,
@ -376,23 +385,29 @@ impl<S: SessionNotifier, Data: 'static> UdevHandlerImpl<S, Data> {
OFlag::O_RDWR | OFlag::O_CLOEXEC | OFlag::O_NOCTTY | OFlag::O_NONBLOCK,
)
.ok()
.and_then(
|fd| match FallbackDevice::new(SessionFd(fd), true, self.logger.clone()) {
.and_then(|fd| {
match FallbackDevice::<AtomicDrmDevice<_>, LegacyDrmDevice<_>>::new(
SessionFd(fd),
true,
self.logger.clone(),
) {
Ok(drm) => Some(drm),
Err(err) => {
warn!(self.logger, "Skipping drm device, because of error: {}", err);
None
}
},
)
.and_then(|drm| match GbmDevice::new(drm, self.logger.clone()) {
Ok(gbm) => Some(gbm),
Err(err) => {
warn!(self.logger, "Skipping gbm device, because of error: {}", err);
None
}
})
.and_then(|gbm| match EglDevice::new(gbm, self.logger.clone()) {
.and_then(|drm| {
match FallbackDevice::<GbmDevice<_>, EglStreamDevice<_>>::new(drm, self.logger.clone()) {
Ok(dev) => Some(dev),
Err(err) => {
warn!(self.logger, "Skipping device, because of error: {}", err);
None
}
}
})
.and_then(|dev| match FallbackDevice::new_egl(dev, self.logger.clone()) {
Ok(egl) => Some(egl),
Err(err) => {
warn!(self.logger, "Skipping egl device, because of error: {}", err);
@ -657,6 +672,7 @@ impl DrmRenderer {
};
if reschedule {
debug!(self.logger, "Rescheduling");
match (timer, evt_handle) {
(Some(handle), _) => {
let _ = handle.add_timeout(