drm: reformat

This commit is contained in:
Drakulix 2017-09-15 15:57:30 +02:00
parent ab77a87725
commit 67b3621be3
1 changed files with 20 additions and 4 deletions

View File

@ -366,17 +366,33 @@ 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 // get all encoders supported by this device
let mut set = self.context.head().head().resource_handles()?.encoders().iter().cloned().collect::<HashSet<encoder::Handle>>(); let mut set = self.context
.head()
.head()
.resource_handles()?
.encoders()
.iter()
.cloned()
.collect::<HashSet<encoder::Handle>>();
for connector in connectors.iter() { for connector in connectors.iter() {
let info = connector::Info::load_from_device(self.context.head().head(), *connector)?; let info = connector::Info::load_from_device(self.context.head().head(), *connector)?;
// then check for every connector which encoders it does support // then check for every connector which encoders it does support
let conn_set = info.encoders().iter().cloned().collect::<HashSet<encoder::Handle>>(); let conn_set = info.encoders()
.iter()
.cloned()
.collect::<HashSet<encoder::Handle>>();
// and update the list of supported encoders for this combination // and update the list of supported encoders for this combination
set = set.intersection(&conn_set).cloned().collect::<HashSet<encoder::Handle>>(); set = set.intersection(&conn_set)
.cloned()
.collect::<HashSet<encoder::Handle>>();
} }
// check if there is any encoder left that can be connected to the crtc // 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>>()?; 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)) { if !encoders.iter().any(|enc| enc.supports_crtc(crtc)) {
return Err(DrmError::Crtc(CrtcError::NoSuitableEncoder)); return Err(DrmError::Crtc(CrtcError::NoSuitableEncoder));
} }