config: tell the config about drm devices
This commit is contained in:
parent
99fcd63438
commit
e27cf29693
23 changed files with 581 additions and 50 deletions
|
|
@ -183,7 +183,7 @@ impl MetalBackend {
|
|||
}
|
||||
let devnum = dev.devnum();
|
||||
let devnode = dev.devnode()?;
|
||||
let id = self.drm_ids.next();
|
||||
let id = self.state.drm_dev_ids.next();
|
||||
log::info!("Device added: {}", devnode.to_bytes().as_bstr());
|
||||
let dev = PendingDrmDevice {
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@ use {
|
|||
crate::{
|
||||
async_engine::{AsyncFd, Phase, SpawnedFuture},
|
||||
backend::{
|
||||
BackendEvent, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, MonitorInfo,
|
||||
BackendDrmDevice, BackendEvent, Connector, ConnectorEvent, ConnectorId,
|
||||
ConnectorKernelId, DrmDeviceId, MonitorInfo,
|
||||
},
|
||||
backends::metal::{DrmId, MetalBackend, MetalError},
|
||||
backends::metal::{MetalBackend, MetalError},
|
||||
edid::Descriptor,
|
||||
format::{Format, XRGB8888},
|
||||
ifs::wp_presentation_feedback::{KIND_HW_COMPLETION, KIND_VSYNC},
|
||||
|
|
@ -35,11 +36,11 @@ use {
|
|||
fmt::{Debug, Formatter},
|
||||
rc::Rc,
|
||||
},
|
||||
uapi::c,
|
||||
uapi::{c, c::dev_t},
|
||||
};
|
||||
|
||||
pub struct PendingDrmDevice {
|
||||
pub id: DrmId,
|
||||
pub id: DrmDeviceId,
|
||||
pub devnum: c::dev_t,
|
||||
pub devnode: CString,
|
||||
}
|
||||
|
|
@ -51,7 +52,7 @@ pub struct MetalRenderContext {
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct MetalDrmDeviceStatic {
|
||||
pub id: DrmId,
|
||||
pub id: DrmDeviceId,
|
||||
pub devnum: c::dev_t,
|
||||
pub devnode: CString,
|
||||
pub master: Rc<DrmMaster>,
|
||||
|
|
@ -67,6 +68,24 @@ pub struct MetalDrmDeviceStatic {
|
|||
pub handle_events: HandleEvents,
|
||||
}
|
||||
|
||||
impl BackendDrmDevice for MetalDrmDeviceStatic {
|
||||
fn id(&self) -> DrmDeviceId {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn event(&self) -> Option<crate::backend::DrmEvent> {
|
||||
None
|
||||
}
|
||||
|
||||
fn on_change(&self, _cb: Rc<dyn Fn()>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn dev_t(&self) -> dev_t {
|
||||
self.devnum
|
||||
}
|
||||
}
|
||||
|
||||
pub struct HandleEvents {
|
||||
pub handle_events: Cell<Option<SpawnedFuture<()>>>,
|
||||
}
|
||||
|
|
@ -249,6 +268,10 @@ impl Connector for MetalConnector {
|
|||
self.schedule_present();
|
||||
}
|
||||
}
|
||||
|
||||
fn drm_dev(&self) -> Option<DrmDeviceId> {
|
||||
Some(self.dev.id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -760,13 +783,17 @@ impl MetalBackend {
|
|||
let (connectors, futures) = get_connectors(&self, &dev, &resources.connectors)?;
|
||||
|
||||
let slf = Rc::new(MetalDrmDevice {
|
||||
dev,
|
||||
dev: dev.clone(),
|
||||
connectors,
|
||||
futures,
|
||||
});
|
||||
|
||||
self.init_drm_device(&slf)?;
|
||||
|
||||
self.state
|
||||
.backend_events
|
||||
.push(BackendEvent::NewDrmDevice(dev.clone()));
|
||||
|
||||
for connector in slf.connectors.values() {
|
||||
self.state
|
||||
.backend_events
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue