kms: Fix remaining hot-plugging issue

This commit is contained in:
Victoria Brekenfeld 2022-08-11 17:13:56 +02:00
parent f7a04024ba
commit 6fd29784d2
4 changed files with 33 additions and 30 deletions

25
Cargo.lock generated
View file

@ -569,23 +569,21 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "drm"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "408e87132bd0d8a13a3b418b9d51fb92973b764d1d40785947d233ab2945fd27"
source = "git+https://github.com/Smithay/drm-rs.git?rev=6d34866#6d348667fee897442672f15ce480676d47ce58aa"
dependencies = [
"bitflags",
"drm-ffi",
"drm-fourcc",
"nix 0.22.3",
"nix 0.24.2",
]
[[package]]
name = "drm-ffi"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "198d1b7fdb33b75e9bd08ba6842ddb730760f7eeea25552acc88c5403c4f0652"
source = "git+https://github.com/Smithay/drm-rs.git?rev=6d34866#6d348667fee897442672f15ce480676d47ce58aa"
dependencies = [
"drm-sys",
"nix 0.22.3",
"nix 0.24.2",
]
[[package]]
@ -597,8 +595,7 @@ checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4"
[[package]]
name = "drm-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5f45fcdd3b2f3c13fadea11b2a4eda2023e7de55021da039eac4a3beecfe91c"
source = "git+https://github.com/Smithay/drm-rs.git?rev=6d34866#6d348667fee897442672f15ce480676d47ce58aa"
dependencies = [
"libc",
]
@ -693,9 +690,8 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "gbm"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06678321b809dfa34ca3be8ac2cb91b22116f86ba37b1610a752eaf90594c450"
version = "0.9.0"
source = "git+https://github.com/Smithay/gbm.rs?rev=b35994d#b35994de29098415cf53a45482276d3b8b658cfc"
dependencies = [
"bitflags",
"drm",
@ -707,8 +703,7 @@ dependencies = [
[[package]]
name = "gbm-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1e3b363aeecb97d9f246e810af154a02701c80008f4da39f0c57740513102de"
source = "git+https://github.com/Smithay/gbm.rs?rev=b35994d#b35994de29098415cf53a45482276d3b8b658cfc"
dependencies = [
"libc",
]
@ -1592,7 +1587,7 @@ checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1"
[[package]]
name = "smithay"
version = "0.3.0"
source = "git+https://github.com/Smithay/smithay.git?rev=606d2d5c#606d2d5c75d738c907e2db63c919f2949a1d06f0"
source = "git+https://github.com/Smithay//smithay?rev=4b927c32df#4b927c32dfdbfa4006cd605d7738c098c0e9b0fd"
dependencies = [
"appendlist",
"bitflags",
@ -1610,7 +1605,7 @@ dependencies = [
"libc",
"libloading",
"libseat",
"nix 0.22.3",
"nix 0.24.2",
"once_cell",
"rand",
"scan_fmt",

View file

@ -59,4 +59,7 @@ inherits = "release"
debug = true
[profile.release]
lto = "fat"
lto = "fat"
[patch."https://github.com/Smithay/smithay.git"]
smithay = { git = "https://github.com/Smithay//smithay", rev = "4b927c32df" }

View file

@ -24,7 +24,7 @@ pub fn display_configuration(
// That means, to reduce flickering, we try to keep an established mapping.
for conn in connectors
.iter()
.flat_map(|conn| device.get_connector(*conn).ok())
.flat_map(|conn| device.get_connector(*conn, true).ok())
{
if let Some(enc) = conn.current_encoder() {
if let Some(crtc) = device.get_encoder(enc)?.crtc() {
@ -43,7 +43,7 @@ pub fn display_configuration(
// But just in case we try to match all remaining connectors.
for conn in connectors
.iter()
.flat_map(|conn| device.get_connector(*conn).ok())
.flat_map(|conn| device.get_connector(*conn, false).ok())
.filter(|conn| conn.state() == ConnectorState::Connected)
.filter(|conn| !map.contains_key(&conn.handle()))
.collect::<Vec<_>>()
@ -52,8 +52,7 @@ pub fn display_configuration(
'outer: for encoder_info in conn
.encoders()
.iter()
.filter_map(|e| *e)
.flat_map(|encoder_handle| device.get_encoder(encoder_handle))
.flat_map(|encoder_handle| device.get_encoder(*encoder_handle))
{
for crtc in res_handles.filter_crtcs(encoder_info.possible_crtcs()) {
if !map.values().any(|v| *v == crtc) {
@ -71,7 +70,7 @@ pub fn display_configuration(
for conn in connectors
.iter()
.flat_map(|conn| device.get_connector(*conn).ok())
.flat_map(|conn| device.get_connector(*conn, false).ok())
.filter(|conn| {
if let Some(enc) = conn.current_encoder() {
if let Some(enc) = device.get_encoder(enc).ok() {
@ -90,14 +89,14 @@ pub fn display_configuration(
// We cannot just shortcut and use the legacy api for all cleanups because of this.
// (Technically a device does not need to be atomic for planes to be used, but nobody does this otherwise.)
for plane in plane_handles.planes() {
let info = device.get_plane(*plane)?;
for plane in plane_handles {
let info = device.get_plane(plane)?;
if let Some(crtc) = info.crtc() {
if cleanup.contains(&crtc) {
let crtc_id = get_prop(device, *plane, "CRTC_ID")?;
let fb_id = get_prop(device, *plane, "FB_ID")?;
req.add_property(*plane, crtc_id, property::Value::CRTC(None));
req.add_property(*plane, fb_id, property::Value::Framebuffer(None));
let crtc_id = get_prop(device, plane, "CRTC_ID")?;
let fb_id = get_prop(device, plane, "FB_ID")?;
req.add_property(plane, crtc_id, property::Value::CRTC(None));
req.add_property(plane, fb_id, property::Value::Framebuffer(None));
}
}
}
@ -123,7 +122,7 @@ pub fn display_configuration(
}
pub fn interface_name(device: &impl ControlDevice, connector: connector::Handle) -> Result<String> {
let conn_info = device.get_connector(connector)?;
let conn_info = device.get_connector(connector, false)?;
let other_short_name;
let interface_short_name = match conn_info.interface() {

View file

@ -520,6 +520,9 @@ impl State {
slog_scope::warn!("Failed to initialize output: {}", err);
}
}
for output in outputs_removed {
self.common.shell.remove_output(&output);
}
self.common.output_configuration_state.update();
self.common.config.read_outputs(
self.common.output_configuration_state.outputs(),
@ -562,6 +565,9 @@ impl State {
self.common.output_configuration_state.update();
if self.backend.kms().session.is_active() {
for output in outputs_removed {
self.common.shell.remove_output(&output);
}
self.common.config.read_outputs(
self.common.output_configuration_state.outputs(),
&mut self.backend,
@ -619,7 +625,7 @@ impl Device {
) -> Result<Output> {
let drm = &mut *self.drm.as_source_mut();
let crtc_info = drm.get_crtc(crtc)?;
let conn_info = drm.get_connector(conn)?;
let conn_info = drm.get_connector(conn, false)?;
let vrr = drm_helpers::set_vrr(drm, crtc, conn, true).unwrap_or(false);
let interface = drm_helpers::interface_name(drm, conn)?;
let edid_info = drm_helpers::edid_info(drm, conn)?;
@ -824,7 +830,7 @@ impl KmsState {
} else {
let drm = &mut *device.drm.as_source_mut();
let conn = surface.connector;
let conn_info = drm.get_connector(conn)?;
let conn_info = drm.get_connector(conn, false)?;
let mode = conn_info
.modes()
.iter()