kms: Add kms backend module

This commit is contained in:
Victoria Brekenfeld 2022-01-20 19:51:46 +01:00
parent 2f53d25edd
commit ca32139131
5 changed files with 102 additions and 7 deletions

74
Cargo.lock generated
View file

@ -300,6 +300,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"bitflags",
"edid-rs",
"egui",
"slog",
"slog-async",
@ -371,6 +372,17 @@ dependencies = [
"syn",
]
[[package]]
name = "dbus"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de0a745c25b32caa56b82a3950f5fec7893a960f4c10ca3b02060b0c38d8c2ce"
dependencies = [
"libc",
"libdbus-sys",
"winapi",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
@ -450,6 +462,12 @@ dependencies = [
"libc",
]
[[package]]
name = "edid-rs"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab5fa33485cd85ac354df485819a63360fefa312fe04cffe65e6f175be1522c"
[[package]]
name = "egui"
version = "0.16.1"
@ -601,6 +619,27 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "input"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f95640ef27dac9b23ef1fbd760c67a88ce3cab2143a2c18390e71f39c53b815f"
dependencies = [
"bitflags",
"input-sys",
"libc",
"udev",
]
[[package]]
name = "input-sys"
version = "1.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e09d849da95ebb5d091c600f6cdae5193077995f1e9095c16a5bb4f84b561933"
dependencies = [
"libc",
]
[[package]]
name = "instant"
version = "0.1.12"
@ -646,6 +685,15 @@ version = "0.2.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a8d982fa7a96a000f6ec4cfe966de9703eccde29750df2bb8949da91b0e818d"
[[package]]
name = "libdbus-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c185b5b7ad900923ef3a8ff594083d4d9b5aea80bb4f32b8342363138c0d456b"
dependencies = [
"pkg-config",
]
[[package]]
name = "libloading"
version = "0.7.3"
@ -656,6 +704,16 @@ dependencies = [
"winapi",
]
[[package]]
name = "libudev-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324"
dependencies = [
"libc",
"pkg-config",
]
[[package]]
name = "lock_api"
version = "0.4.5"
@ -1149,12 +1207,12 @@ checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83"
[[package]]
name = "smithay"
version = "0.3.0"
source = "git+https://github.com/Smithay/smithay.git?rev=ab89bda5#ab89bda5035ce03df42cc98d6b2ee6cd5d79862e"
dependencies = [
"appendlist",
"bitflags",
"calloop",
"cgmath",
"dbus",
"downcast-rs",
"drm",
"drm-ffi",
@ -1162,17 +1220,20 @@ dependencies = [
"gbm",
"gl_generator",
"indexmap",
"input",
"lazy_static",
"libc",
"libloading",
"nix",
"once_cell",
"pkg-config",
"rand",
"scan_fmt",
"slog",
"slog-stdlog",
"tempfile",
"thiserror",
"udev",
"wayland-commons",
"wayland-egl",
"wayland-protocols",
@ -1318,6 +1379,17 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ccbe8381883510b6a2d8f1e32905bddd178c11caef8083086d0c0c9ab0ac281"
[[package]]
name = "udev"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3193363f52bb34c6708ac2ffedcb5f7e5874f0329ef68e1315f27d8d768eb568"
dependencies = [
"libc",
"libudev-sys",
"pkg-config",
]
[[package]]
name = "unicode-xid"
version = "0.2.2"

View file

@ -14,13 +14,14 @@ slog-async = "2.7"
slog-scope = "4.4"
slog-stdlog = "4.1"
egui = { version = "0.16", optional = true }
edid-rs = { version = "0.1" }
[dependencies.smithay]
version = "0.3"
git = "https://github.com/Smithay/smithay.git"
rev = "ab89bda5"
default-features = false
features = ["backend_x11", "backend_egl", "backend_winit", "desktop", "use_system_lib", "renderer_gl", "wayland_frontend", "slog-stdlog"]
features = ["backend_drm", "backend_gbm", "backend_egl", "backend_libinput", "backend_session_logind", "backend_udev", "backend_winit", "backend_x11", "desktop", "use_system_lib", "renderer_gl", "wayland_frontend", "slog-stdlog"]
[dependencies.smithay-egui]
git = "https://github.com/Smithay/smithay-egui.git"
@ -29,4 +30,7 @@ optional = true
[features]
default = []
debug = ["egui", "smithay-egui"]
debug = ["egui", "smithay-egui"]
[patch."https://github.com/Smithay/smithay"]
smithay = { path = "../../tavern/smithay" }

11
src/backend/kms/mod.rs Normal file
View file

@ -0,0 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::state::State;
use anyhow::Result;
use smithay::reexports::calloop::EventLoop;
pub struct KmsState {}
pub fn init_backend(event_loop: &mut EventLoop<State>, state: &mut State) -> Result<()> {
unimplemented!()
}

View file

@ -4,16 +4,17 @@ use crate::state::State;
use anyhow::Result;
use smithay::reexports::calloop::EventLoop;
pub mod kms;
pub mod winit;
pub mod x11;
// TODO
// pub mod wayland; // tbd in smithay
// pub mod udev;
pub fn init_backend_auto(event_loop: &mut EventLoop<State>, state: &mut State) -> Result<()> {
match std::env::var("COSMIC_BACKEND") {
Ok(x) if x == "x11" => x11::init_backend(event_loop, state),
Ok(x) if x == "winit" => winit::init_backend(event_loop, state),
Ok(x) if x == "kms" => kms::init_backend(event_loop, state),
Ok(_) => unimplemented!("There is no backend with this identifier"),
Err(_) => {
if std::env::var_os("DISPLAY").is_some()
@ -28,7 +29,7 @@ pub fn init_backend_auto(event_loop: &mut EventLoop<State>, state: &mut State) -
}
}
} else {
unimplemented!("Currently this runs only nested")
kms::init_backend(event_loop, state)
}
}
}

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use crate::{
backend::{winit::WinitState, x11::X11State},
backend::{kms::KmsState, winit::WinitState, x11::X11State},
shell::{init_shell, workspaces::Workspaces, ShellStates},
};
use smithay::{
@ -60,13 +60,20 @@ pub struct Fps {
pub enum BackendData {
X11(X11State),
Winit(WinitState),
Kms(KmsState),
// TODO
// Wayland(WaylandState),
// Udev(UdevState),
Unset,
}
impl BackendData {
pub fn kms(&mut self) -> &mut KmsState {
match self {
BackendData::Kms(ref mut kms_state) => kms_state,
_ => unreachable!("Called kms in non kms backend"),
}
}
pub fn x11(&mut self) -> &mut X11State {
match self {
BackendData::X11(ref mut x11_state) => x11_state,