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
|
|
@ -1,7 +1,9 @@
|
|||
use {
|
||||
crate::{
|
||||
async_engine::SpawnedFuture,
|
||||
backend::{Backend, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId},
|
||||
backend::{
|
||||
Backend, Connector, ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId,
|
||||
},
|
||||
video::drm::ConnectorType,
|
||||
},
|
||||
std::{any::Any, error::Error, rc::Rc},
|
||||
|
|
@ -46,4 +48,8 @@ impl Connector for DummyOutput {
|
|||
fn damage(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn drm_dev(&self) -> Option<DrmDeviceId> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,8 +111,6 @@ pub enum MetalError {
|
|||
DeviceResumeSignalHandler(#[source] DbusError),
|
||||
}
|
||||
|
||||
linear_ids!(DrmIds, DrmId);
|
||||
|
||||
pub struct MetalBackend {
|
||||
state: Rc<State>,
|
||||
udev: Rc<Udev>,
|
||||
|
|
@ -122,7 +120,6 @@ pub struct MetalBackend {
|
|||
libinput_fd: AsyncFd,
|
||||
device_holder: Rc<DeviceHolder>,
|
||||
session: Session,
|
||||
drm_ids: DrmIds,
|
||||
pause_handler: Cell<Option<SignalHandler>>,
|
||||
resume_handler: Cell<Option<SignalHandler>>,
|
||||
ctx: CloneCell<Option<Rc<MetalRenderContext>>>,
|
||||
|
|
@ -252,7 +249,6 @@ pub async fn create(state: &Rc<State>) -> Result<Rc<MetalBackend>, MetalError> {
|
|||
libinput_fd,
|
||||
device_holder,
|
||||
session,
|
||||
drm_ids: Default::default(),
|
||||
pause_handler: Default::default(),
|
||||
resume_handler: Default::default(),
|
||||
ctx: Default::default(),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ use {
|
|||
async_engine::{Phase, SpawnedFuture},
|
||||
backend::{
|
||||
AxisSource, Backend, BackendEvent, Connector, ConnectorEvent, ConnectorId,
|
||||
ConnectorKernelId, InputDevice, InputDeviceAccelProfile, InputDeviceCapability,
|
||||
InputDeviceId, InputEvent, KeyState, Mode, MonitorInfo, ScrollAxis, TransformMatrix,
|
||||
ConnectorKernelId, DrmDeviceId, InputDevice, InputDeviceAccelProfile,
|
||||
InputDeviceCapability, InputDeviceId, InputEvent, KeyState, Mode, MonitorInfo,
|
||||
ScrollAxis, TransformMatrix,
|
||||
},
|
||||
fixed::Fixed,
|
||||
format::XRGB8888,
|
||||
|
|
@ -948,6 +949,10 @@ impl Connector for XOutput {
|
|||
fn damage(&self) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn drm_dev(&self) -> Option<DrmDeviceId> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
struct XSeat {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue