Set default output transform based on DRM panel orientation (#901)
This commit is contained in:
parent
a96394f7a6
commit
15a6425836
6 changed files with 40 additions and 19 deletions
|
|
@ -1,13 +1,16 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use smithay::reexports::drm::control::{
|
||||
atomic::AtomicModeReq,
|
||||
connector::{self, State as ConnectorState},
|
||||
crtc,
|
||||
dumbbuffer::DumbBuffer,
|
||||
property, AtomicCommitFlags, Device as ControlDevice, Mode, ModeFlags, PlaneType,
|
||||
ResourceHandle,
|
||||
use smithay::{
|
||||
reexports::drm::control::{
|
||||
atomic::AtomicModeReq,
|
||||
connector::{self, State as ConnectorState},
|
||||
crtc,
|
||||
dumbbuffer::DumbBuffer,
|
||||
property, AtomicCommitFlags, Device as ControlDevice, Mode, ModeFlags, PlaneType,
|
||||
ResourceHandle,
|
||||
},
|
||||
utils::Transform,
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
|
|
@ -419,3 +422,21 @@ pub fn set_max_bpc(dev: &impl ControlDevice, conn: connector::Handle, bpc: u32)
|
|||
_ => unreachable!(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn panel_orientation(dev: &impl ControlDevice, conn: connector::Handle) -> Result<Transform> {
|
||||
let (val_type, val) = get_property_val(dev, conn, "panel orientation")?;
|
||||
match val_type.convert_value(val) {
|
||||
property::Value::Enum(Some(val)) => match val.value() {
|
||||
// "Normal"
|
||||
0 => Ok(Transform::Normal),
|
||||
// "Upside Down"
|
||||
1 => Ok(Transform::_180),
|
||||
// "Left Side Up"
|
||||
2 => Ok(Transform::_90),
|
||||
// "Right Side Up"
|
||||
3 => Ok(Transform::_270),
|
||||
_ => Err(anyhow!("panel orientation has invalid value '{:?}'", val)),
|
||||
},
|
||||
_ => Err(anyhow!("panel orientation has wrong value type")),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue