Fix encoder detection
This commit is contained in:
parent
d3fca34475
commit
174e4b9d0b
|
@ -398,8 +398,6 @@ impl<H: DrmHandler + 'static> DrmDevice<H> {
|
|||
where
|
||||
I: Into<Vec<connector::Handle>>,
|
||||
{
|
||||
use std::collections::hash_set::HashSet;
|
||||
|
||||
for backend in self.backends.iter() {
|
||||
if let Some(backend) = backend.upgrade() {
|
||||
if backend.borrow().is_crtc(crtc) {
|
||||
|
@ -410,36 +408,25 @@ impl<H: DrmHandler + 'static> DrmDevice<H> {
|
|||
|
||||
// check if the given connectors and crtc match
|
||||
let connectors = connectors.into();
|
||||
// get all encoders supported by this device
|
||||
let mut set = self.context
|
||||
.head()
|
||||
.head()
|
||||
.resource_handles()?
|
||||
.encoders()
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<HashSet<encoder::Handle>>();
|
||||
for connector in connectors.iter() {
|
||||
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>>()?;
|
||||
if !encoders.iter().any(|enc| enc.supports_crtc(crtc)) {
|
||||
return Err(DrmError::Crtc(CrtcError::NoSuitableEncoder));
|
||||
// check if we have an encoder for every connector
|
||||
for connector in connectors.iter() {
|
||||
let con_info = connector::Info::load_from_device(self.context.head().head(), *connector)?;
|
||||
|
||||
// then check for every connector which encoders it does support
|
||||
let encoders = con_info
|
||||
.encoders()
|
||||
.iter()
|
||||
.map(|encoder| {
|
||||
encoder::Info::load_from_device(self.context.head().head(), *encoder)
|
||||
.map_err(DrmError::from)
|
||||
})
|
||||
.collect::<Result<Vec<encoder::Info>, DrmError>>()?;
|
||||
|
||||
// and if any encoder supports the selected crtc
|
||||
if !encoders.iter().any(|encoder| encoder.supports_crtc(crtc)) {
|
||||
return Err(DrmError::Crtc(CrtcError::NoSuitableEncoder));
|
||||
}
|
||||
}
|
||||
|
||||
// configuration is valid, the kernel will figure out the rest
|
||||
|
|
Loading…
Reference in New Issue