Fix encoder detection

This commit is contained in:
Drakulix 2017-09-17 22:54:36 +02:00
parent d3fca34475
commit 174e4b9d0b
1 changed files with 18 additions and 31 deletions

View File

@ -398,8 +398,6 @@ impl<H: DrmHandler + 'static> DrmDevice<H> {
where where
I: Into<Vec<connector::Handle>>, I: Into<Vec<connector::Handle>>,
{ {
use std::collections::hash_set::HashSet;
for backend in self.backends.iter() { for backend in self.backends.iter() {
if let Some(backend) = backend.upgrade() { if let Some(backend) = backend.upgrade() {
if backend.borrow().is_crtc(crtc) { if backend.borrow().is_crtc(crtc) {
@ -410,37 +408,26 @@ impl<H: DrmHandler + 'static> DrmDevice<H> {
// check if the given connectors and crtc match // check if the given connectors and crtc match
let connectors = connectors.into(); let connectors = connectors.into();
// get all encoders supported by this device
let mut set = self.context // check if we have an encoder for every connector
.head() for connector in connectors.iter() {
.head() let con_info = connector::Info::load_from_device(self.context.head().head(), *connector)?;
.resource_handles()?
// then check for every connector which encoders it does support
let encoders = con_info
.encoders() .encoders()
.iter() .iter()
.cloned() .map(|encoder| {
.collect::<HashSet<encoder::Handle>>(); encoder::Info::load_from_device(self.context.head().head(), *encoder)
for connector in connectors.iter() { .map_err(DrmError::from)
let info = connector::Info::load_from_device(self.context.head().head(), *connector)?;
// then check for every connector which encoders it does support
let conn_set = info.encoders()
.iter()
.cloned()
.collect::<HashSet<encoder::Handle>>();
// and update the list of supported encoders for this combination
set = set.intersection(&conn_set)
.cloned()
.collect::<HashSet<encoder::Handle>>();
}
// check if there is any encoder left that can be connected to the crtc
let encoders: Vec<encoder::Info> = set.iter()
.map(|handle| {
encoder::Info::load_from_device(self.context.head().head(), *handle).map_err(DrmError::from)
}) })
.collect::<Result<Vec<encoder::Info>, DrmError>>()?; .collect::<Result<Vec<encoder::Info>, DrmError>>()?;
if !encoders.iter().any(|enc| enc.supports_crtc(crtc)) {
// and if any encoder supports the selected crtc
if !encoders.iter().any(|encoder| encoder.supports_crtc(crtc)) {
return Err(DrmError::Crtc(CrtcError::NoSuitableEncoder)); return Err(DrmError::Crtc(CrtcError::NoSuitableEncoder));
} }
}
// configuration is valid, the kernel will figure out the rest // configuration is valid, the kernel will figure out the rest