backend: take initial backend state from backend
This commit is contained in:
parent
1a9753847a
commit
d321e888be
8 changed files with 88 additions and 71 deletions
|
|
@ -141,6 +141,7 @@ pub trait Connector: Any {
|
||||||
fn damage(&self);
|
fn damage(&self);
|
||||||
fn drm_dev(&self) -> Option<DrmDeviceId>;
|
fn drm_dev(&self) -> Option<DrmDeviceId>;
|
||||||
fn effectively_locked(&self) -> bool;
|
fn effectively_locked(&self) -> bool;
|
||||||
|
fn state(&self) -> BackendConnectorState;
|
||||||
fn caps(&self) -> ConnectorCaps {
|
fn caps(&self) -> ConnectorCaps {
|
||||||
ConnectorCaps::none()
|
ConnectorCaps::none()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
async_engine::SpawnedFuture,
|
async_engine::SpawnedFuture,
|
||||||
backend::{
|
backend::{
|
||||||
Backend, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
self, Backend, BackendConnectorState, BackendConnectorStateSerial, Connector,
|
||||||
|
ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
||||||
},
|
},
|
||||||
|
format::XRGB8888,
|
||||||
video::drm::ConnectorType,
|
video::drm::ConnectorType,
|
||||||
},
|
},
|
||||||
std::{error::Error, rc::Rc},
|
std::{error::Error, rc::Rc},
|
||||||
|
|
@ -52,4 +54,25 @@ impl Connector for DummyOutput {
|
||||||
fn effectively_locked(&self) -> bool {
|
fn effectively_locked(&self) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn state(&self) -> BackendConnectorState {
|
||||||
|
let mode = backend::Mode {
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
refresh_rate_millihz: 40_000,
|
||||||
|
};
|
||||||
|
BackendConnectorState {
|
||||||
|
serial: BackendConnectorStateSerial::from_raw(0),
|
||||||
|
enabled: true,
|
||||||
|
active: false,
|
||||||
|
mode,
|
||||||
|
non_desktop_override: None,
|
||||||
|
vrr: false,
|
||||||
|
tearing: false,
|
||||||
|
format: XRGB8888,
|
||||||
|
color_space: Default::default(),
|
||||||
|
eotf: Default::default(),
|
||||||
|
gamma_lut: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -867,6 +867,10 @@ impl Connector for MetalConnector {
|
||||||
fb.locked
|
fb.locked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn state(&self) -> BackendConnectorState {
|
||||||
|
self.display.borrow().persistent.state.borrow().clone()
|
||||||
|
}
|
||||||
|
|
||||||
fn caps(&self) -> ConnectorCaps {
|
fn caps(&self) -> ConnectorCaps {
|
||||||
CONCAP_CONNECTOR | CONCAP_MODE_SETTING | CONCAP_PHYSICAL_DISPLAY
|
CONCAP_CONNECTOR | CONCAP_MODE_SETTING | CONCAP_PHYSICAL_DISPLAY
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1113,6 +1113,10 @@ impl Connector for XOutput {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn state(&self) -> BackendConnectorState {
|
||||||
|
self.state.borrow().clone()
|
||||||
|
}
|
||||||
|
|
||||||
fn transaction_type(&self) -> Box<dyn BackendConnectorTransactionTypeDyn> {
|
fn transaction_type(&self) -> Box<dyn BackendConnectorTransactionTypeDyn> {
|
||||||
Box::new(XTransactionType)
|
Box::new(XTransactionType)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
acceptor::{Acceptor, AcceptorError},
|
acceptor::{Acceptor, AcceptorError},
|
||||||
async_engine::{AsyncEngine, Phase, SpawnedFuture},
|
async_engine::{AsyncEngine, Phase, SpawnedFuture},
|
||||||
backend::{self, Backend, BackendConnectorState, BackendConnectorStateSerial, Connector},
|
backend::{Backend, Connector},
|
||||||
backends::{
|
backends::{
|
||||||
dummy::{DummyBackend, DummyOutput},
|
dummy::{DummyBackend, DummyOutput},
|
||||||
metal, x,
|
metal, x,
|
||||||
|
|
@ -675,26 +675,9 @@ fn create_dummy_output(state: &Rc<State>) {
|
||||||
serial_number: "".to_string(),
|
serial_number: "".to_string(),
|
||||||
});
|
});
|
||||||
let persistent_state = Rc::new(PersistentOutputState::default());
|
let persistent_state = Rc::new(PersistentOutputState::default());
|
||||||
let mode = backend::Mode {
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
refresh_rate_millihz: 40_000,
|
|
||||||
};
|
|
||||||
let backend_state = BackendConnectorState {
|
|
||||||
serial: BackendConnectorStateSerial::from_raw(0),
|
|
||||||
enabled: true,
|
|
||||||
active: false,
|
|
||||||
mode,
|
|
||||||
non_desktop_override: None,
|
|
||||||
vrr: false,
|
|
||||||
tearing: false,
|
|
||||||
format: XRGB8888,
|
|
||||||
color_space: Default::default(),
|
|
||||||
eotf: Default::default(),
|
|
||||||
gamma_lut: Default::default(),
|
|
||||||
};
|
|
||||||
let id = state.connector_ids.next();
|
let id = state.connector_ids.next();
|
||||||
let connector = Rc::new(DummyOutput { id }) as Rc<dyn Connector>;
|
let connector = Rc::new(DummyOutput { id }) as Rc<dyn Connector>;
|
||||||
|
let backend_state = connector.state();
|
||||||
let name = Rc::new("Dummy".to_string());
|
let name = Rc::new("Dummy".to_string());
|
||||||
let head_name = state.head_names.next();
|
let head_name = state.head_names.next();
|
||||||
let head_state = HeadState {
|
let head_state = HeadState {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,15 @@ use {
|
||||||
},
|
},
|
||||||
ahash::AHashMap,
|
ahash::AHashMap,
|
||||||
bstr::ByteSlice,
|
bstr::ByteSlice,
|
||||||
std::{any::Any, cell::Cell, error::Error, io, os::unix::ffi::OsStrExt, pin::Pin, rc::Rc},
|
std::{
|
||||||
|
any::Any,
|
||||||
|
cell::{Cell, RefCell},
|
||||||
|
error::Error,
|
||||||
|
io,
|
||||||
|
os::unix::ffi::OsStrExt,
|
||||||
|
pin::Pin,
|
||||||
|
rc::Rc,
|
||||||
|
},
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
uapi::c,
|
uapi::c,
|
||||||
};
|
};
|
||||||
|
|
@ -75,6 +83,24 @@ pub struct TestBackend {
|
||||||
impl TestBackend {
|
impl TestBackend {
|
||||||
pub fn new(state: &Rc<State>, future: TestFuture) -> Self {
|
pub fn new(state: &Rc<State>, future: TestFuture) -> Self {
|
||||||
state.set_backend_idle(false);
|
state.set_backend_idle(false);
|
||||||
|
let mode = Mode {
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
refresh_rate_millihz: 60_000,
|
||||||
|
};
|
||||||
|
let bcs = BackendConnectorState {
|
||||||
|
serial: state.backend_connector_state_serials.next(),
|
||||||
|
enabled: true,
|
||||||
|
active: true,
|
||||||
|
mode,
|
||||||
|
non_desktop_override: None,
|
||||||
|
vrr: false,
|
||||||
|
tearing: false,
|
||||||
|
format: XRGB8888,
|
||||||
|
color_space: Default::default(),
|
||||||
|
eotf: Default::default(),
|
||||||
|
gamma_lut: Default::default(),
|
||||||
|
};
|
||||||
let default_connector = Rc::new(TestConnector {
|
let default_connector = Rc::new(TestConnector {
|
||||||
id: state.connector_ids.next(),
|
id: state.connector_ids.next(),
|
||||||
kernel_id: ConnectorKernelId {
|
kernel_id: ConnectorKernelId {
|
||||||
|
|
@ -85,6 +111,7 @@ impl TestBackend {
|
||||||
feedback: Default::default(),
|
feedback: Default::default(),
|
||||||
idle: Default::default(),
|
idle: Default::default(),
|
||||||
damage_calls: NumCell::new(0),
|
damage_calls: NumCell::new(0),
|
||||||
|
state: RefCell::new(bcs.clone()),
|
||||||
});
|
});
|
||||||
let default_mouse = Rc::new(TestBackendMouse {
|
let default_mouse = Rc::new(TestBackendMouse {
|
||||||
common: TestInputDeviceCommon {
|
common: TestInputDeviceCommon {
|
||||||
|
|
@ -120,11 +147,6 @@ impl TestBackend {
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
let mode = Mode {
|
|
||||||
width: 800,
|
|
||||||
height: 600,
|
|
||||||
refresh_rate_millihz: 60_000,
|
|
||||||
};
|
|
||||||
let default_monitor_info = MonitorInfo {
|
let default_monitor_info = MonitorInfo {
|
||||||
modes: Some(vec![mode]),
|
modes: Some(vec![mode]),
|
||||||
output_id: Rc::new(OutputId {
|
output_id: Rc::new(OutputId {
|
||||||
|
|
@ -142,19 +164,7 @@ impl TestBackend {
|
||||||
color_spaces: vec![],
|
color_spaces: vec![],
|
||||||
primaries: Primaries::SRGB,
|
primaries: Primaries::SRGB,
|
||||||
luminance: None,
|
luminance: None,
|
||||||
state: BackendConnectorState {
|
state: bcs,
|
||||||
serial: state.backend_connector_state_serials.next(),
|
|
||||||
enabled: true,
|
|
||||||
active: true,
|
|
||||||
mode,
|
|
||||||
non_desktop_override: None,
|
|
||||||
vrr: false,
|
|
||||||
tearing: false,
|
|
||||||
format: XRGB8888,
|
|
||||||
color_space: Default::default(),
|
|
||||||
eotf: Default::default(),
|
|
||||||
gamma_lut: Default::default(),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
|
|
@ -325,6 +335,7 @@ pub struct TestConnector {
|
||||||
pub feedback: CloneCell<Option<Rc<DrmFeedback>>>,
|
pub feedback: CloneCell<Option<Rc<DrmFeedback>>>,
|
||||||
pub idle: TEEH<bool>,
|
pub idle: TEEH<bool>,
|
||||||
pub damage_calls: NumCell<u32>,
|
pub damage_calls: NumCell<u32>,
|
||||||
|
pub state: RefCell<BackendConnectorState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connector for TestConnector {
|
impl Connector for TestConnector {
|
||||||
|
|
@ -357,6 +368,10 @@ impl Connector for TestConnector {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn state(&self) -> BackendConnectorState {
|
||||||
|
self.state.borrow().clone()
|
||||||
|
}
|
||||||
|
|
||||||
fn drm_feedback(&self) -> Option<Rc<DrmFeedback>> {
|
fn drm_feedback(&self) -> Option<Rc<DrmFeedback>> {
|
||||||
self.feedback.get()
|
self.feedback.get()
|
||||||
}
|
}
|
||||||
|
|
@ -404,6 +419,7 @@ impl BackendPreparedConnectorTransaction for TestBackendTransaction {
|
||||||
self: Box<Self>,
|
self: Box<Self>,
|
||||||
) -> Result<Box<dyn BackendAppliedConnectorTransaction>, BackendConnectorTransactionError> {
|
) -> Result<Box<dyn BackendAppliedConnectorTransaction>, BackendConnectorTransactionError> {
|
||||||
for (c, s) in self.connectors.values() {
|
for (c, s) in self.connectors.values() {
|
||||||
|
*c.state.borrow_mut() = s.clone();
|
||||||
c.idle.push(!s.active);
|
c.idle.push(!s.active);
|
||||||
}
|
}
|
||||||
Ok(self)
|
Ok(self)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use {
|
||||||
utils::numcell::NumCell,
|
utils::numcell::NumCell,
|
||||||
video::drm::ConnectorType,
|
video::drm::ConnectorType,
|
||||||
},
|
},
|
||||||
std::rc::Rc,
|
std::{cell::RefCell, rc::Rc},
|
||||||
};
|
};
|
||||||
|
|
||||||
testcase!();
|
testcase!();
|
||||||
|
|
@ -27,6 +27,19 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
||||||
bail!("no dummy output");
|
bail!("no dummy output");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let bcs = BackendConnectorState {
|
||||||
|
serial: run.state.backend_connector_state_serials.next(),
|
||||||
|
enabled: true,
|
||||||
|
active: true,
|
||||||
|
mode: Default::default(),
|
||||||
|
non_desktop_override: None,
|
||||||
|
vrr: false,
|
||||||
|
tearing: false,
|
||||||
|
format: XRGB8888,
|
||||||
|
color_space: Default::default(),
|
||||||
|
eotf: Default::default(),
|
||||||
|
gamma_lut: Default::default(),
|
||||||
|
};
|
||||||
let new_connector = Rc::new(TestConnector {
|
let new_connector = Rc::new(TestConnector {
|
||||||
id: run.state.connector_ids.next(),
|
id: run.state.connector_ids.next(),
|
||||||
kernel_id: ConnectorKernelId {
|
kernel_id: ConnectorKernelId {
|
||||||
|
|
@ -37,6 +50,7 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
||||||
feedback: Default::default(),
|
feedback: Default::default(),
|
||||||
idle: Default::default(),
|
idle: Default::default(),
|
||||||
damage_calls: NumCell::new(0),
|
damage_calls: NumCell::new(0),
|
||||||
|
state: RefCell::new(bcs.clone()),
|
||||||
});
|
});
|
||||||
let new_monitor_info = MonitorInfo {
|
let new_monitor_info = MonitorInfo {
|
||||||
modes: Some(vec![]),
|
modes: Some(vec![]),
|
||||||
|
|
@ -55,19 +69,7 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
||||||
color_spaces: vec![],
|
color_spaces: vec![],
|
||||||
primaries: Primaries::SRGB,
|
primaries: Primaries::SRGB,
|
||||||
luminance: None,
|
luminance: None,
|
||||||
state: BackendConnectorState {
|
state: bcs,
|
||||||
serial: run.state.backend_connector_state_serials.next(),
|
|
||||||
enabled: true,
|
|
||||||
active: true,
|
|
||||||
mode: Default::default(),
|
|
||||||
non_desktop_override: None,
|
|
||||||
vrr: false,
|
|
||||||
tearing: false,
|
|
||||||
format: XRGB8888,
|
|
||||||
color_space: Default::default(),
|
|
||||||
eotf: Default::default(),
|
|
||||||
gamma_lut: Default::default(),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
run.backend
|
run.backend
|
||||||
.state
|
.state
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::{
|
backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo},
|
||||||
BackendConnectorState, BackendConnectorStateSerial, Connector, ConnectorEvent,
|
|
||||||
ConnectorId, MonitorInfo,
|
|
||||||
},
|
|
||||||
control_center::CCI_OUTPUTS,
|
control_center::CCI_OUTPUTS,
|
||||||
format::XRGB8888,
|
|
||||||
globals::GlobalName,
|
globals::GlobalName,
|
||||||
ifs::{
|
ifs::{
|
||||||
head_management::{HeadManagers, HeadState},
|
head_management::{HeadManagers, HeadState},
|
||||||
|
|
@ -35,19 +31,7 @@ pub fn handle(state: &Rc<State>, connector: &Rc<dyn Connector>) {
|
||||||
_ => panic!("connector's drm device does not exist"),
|
_ => panic!("connector's drm device does not exist"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let backend_state = BackendConnectorState {
|
let backend_state = connector.state();
|
||||||
serial: BackendConnectorStateSerial::from_raw(0),
|
|
||||||
enabled: true,
|
|
||||||
active: false,
|
|
||||||
mode: Default::default(),
|
|
||||||
non_desktop_override: None,
|
|
||||||
vrr: false,
|
|
||||||
tearing: false,
|
|
||||||
format: XRGB8888,
|
|
||||||
color_space: Default::default(),
|
|
||||||
eotf: Default::default(),
|
|
||||||
gamma_lut: None,
|
|
||||||
};
|
|
||||||
let id = connector.id();
|
let id = connector.id();
|
||||||
let name = Rc::new(connector.kernel_id().to_string());
|
let name = Rc::new(connector.kernel_id().to_string());
|
||||||
let head_state = HeadState {
|
let head_state = HeadState {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue