Fix encoder detection
@@ -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,37 +408,26 @@ 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>>();
+
+ // check if we have an encoder for every connector
for connector in connectors.iter() {
- let info = connector::Info::load_from_device(self.context.head().head(), *connector)?;
+ let con_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()
+ let encoders = con_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)
+ .map(|encoder| {
+ encoder::Info::load_from_device(self.context.head().head(), *encoder)
+ .map_err(DrmError::from)
})
.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));
}
+ }
// configuration is valid, the kernel will figure out the rest
