Skip to content

Commit 0b1bf8d

Browse files
committed
Remove switchable graphics
1 parent 2ebd0d2 commit 0b1bf8d

File tree

7 files changed

+42
-638
lines changed

7 files changed

+42
-638
lines changed

data/com.system76.PowerDaemon.xml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,6 @@
2828
<arg name="profiles" type="aa{sv}" direction="out"/>
2929
</method>
3030

31-
<method name="GetDefaultGraphics">
32-
<arg name="vendor" type="s" direction="out"/>
33-
</method>
34-
35-
<method name="GetGraphics">
36-
<arg name="vendor" type="s" direction="out"/>
37-
</method>
38-
39-
<method name="SetGraphics">
40-
<arg name="vendor" type="s" direction="in"/>
41-
</method>
42-
43-
<method name="GetGraphicsPower">
44-
<arg name="power" type="b" direction="out"/>
45-
</method>
46-
47-
<method name="SetGraphicsPower">
48-
<arg name="power" type="b" direction="in"/>
49-
</method>
50-
51-
<method name="GetSwitchable">
52-
<arg name="switchable" type="b" direction="out"/>
53-
</method>
54-
5531
<method name="GetDesktop">
5632
<arg name="desktop" type="b" direction="out"/>
5733
</method>

src/args.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,6 @@
44

55
use clap::{builder::PossibleValuesParser, Parser};
66

7-
#[derive(Parser)]
8-
#[clap(
9-
about = "Query or set the graphics mode",
10-
long_about = "Query or set the graphics mode.\n\n - If an argument is not provided, the \
11-
graphics profile will be queried\n - Otherwise, that profile will be set, if it \
12-
is a valid profile\n\nA reboot is required after switching modes."
13-
)]
14-
pub enum GraphicsArgs {
15-
#[clap(about = "Like integrated, but the dGPU is available for compute")]
16-
Compute,
17-
#[clap(about = "Set the graphics mode to Hybrid (PRIME)")]
18-
Hybrid,
19-
#[clap(about = "Set the graphics mode to integrated")]
20-
Integrated,
21-
#[clap(about = "Set the graphics mode to NVIDIA")]
22-
Nvidia,
23-
#[clap(about = "Determines if the system has switchable graphics")]
24-
Switchable,
25-
#[clap(about = "Query or set the discrete graphics power state")]
26-
Power {
27-
#[clap(help = "Set whether discrete graphics should be on or off")]
28-
#[arg(
29-
value_parser = PossibleValuesParser::new(["auto", "off", "on"])
30-
)]
31-
state: Option<String>,
32-
},
33-
}
34-
357
#[derive(Parser)]
368
#[clap(
379
name = "system76-power",
@@ -78,10 +50,6 @@ pub enum Args {
7850
)]
7951
profile: Option<String>,
8052
},
81-
Graphics {
82-
#[clap(subcommand)]
83-
cmd: Option<GraphicsArgs>,
84-
},
8553
#[clap(
8654
about = "Set thresholds for battery charging",
8755
// Autogenerated usage seemed to have issues

src/client.rs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// SPDX-License-Identifier: GPL-3.0-only
44

5-
use crate::args::{Args, GraphicsArgs};
5+
use crate::args::Args;
66
use anyhow::Context;
77
use intel_pstate::PState;
88
use std::io;
@@ -75,53 +75,6 @@ Battery power profile is not supported on desktop computers.
7575
Some("performance") => client.performance().await.map_err(zbus_error),
7676
_ => profile(&mut client).await.context("failed to get power profile"),
7777
},
78-
Args::Graphics { cmd } => {
79-
if !client.get_switchable().await? {
80-
return Err(anyhow::anyhow!(
81-
r#"
82-
Graphics switching is not supported on this device, because
83-
this device is either a desktop or doesn't have both an iGPU and dGPU.
84-
"#,
85-
));
86-
}
87-
88-
match cmd.as_ref() {
89-
Some(GraphicsArgs::Compute) => {
90-
client.set_graphics("compute").await.map_err(zbus_error)
91-
}
92-
Some(GraphicsArgs::Hybrid) => {
93-
client.set_graphics("hybrid").await.map_err(zbus_error)
94-
}
95-
Some(GraphicsArgs::Integrated) => {
96-
client.set_graphics("integrated").await.map_err(zbus_error)
97-
}
98-
Some(GraphicsArgs::Nvidia) => {
99-
client.set_graphics("nvidia").await.map_err(zbus_error)
100-
}
101-
Some(GraphicsArgs::Switchable) => client
102-
.get_switchable()
103-
.await
104-
.map_err(zbus_error)
105-
.map(|b| println!("{}", if b { "switchable" } else { "not switchable" })),
106-
Some(GraphicsArgs::Power { state }) => match state.as_deref() {
107-
Some("auto") => client.auto_graphics_power().await.map_err(zbus_error),
108-
Some("off") => client.set_graphics_power(false).await.map_err(zbus_error),
109-
Some("on") => client.set_graphics_power(true).await.map_err(zbus_error),
110-
_ => {
111-
if client.get_graphics_power().await.map_err(zbus_error)? {
112-
println!("on (discrete)");
113-
} else {
114-
println!("off (discrete)");
115-
}
116-
Ok(())
117-
}
118-
},
119-
None => {
120-
println!("{}", client.get_graphics().await.map_err(zbus_error)?);
121-
Ok(())
122-
}
123-
}
124-
}
12578
Args::ChargeThresholds { profile, list_profiles, thresholds } => {
12679
if client.get_desktop().await.map_err(zbus_error)? {
12780
return Err(anyhow::anyhow!(

src/daemon/mod.rs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::{
2525
charge_thresholds::{get_charge_profiles, get_charge_thresholds, set_charge_thresholds},
2626
errors::ProfileError,
2727
fan::FanDaemon,
28-
graphics::{Graphics, GraphicsMode},
28+
graphics::Graphics,
2929
hid_backlight,
3030
hotplug::{mux, Detect, HotPlugDetect},
3131
kernel_parameters::{KernelParameter, NmiWatchdog},
@@ -238,60 +238,11 @@ impl System76Power {
238238
.map_err(zbus_error_from_display)
239239
}
240240

241-
#[dbus_interface(out_args("vendor"))]
242-
async fn get_default_graphics(&self) -> zbus::fdo::Result<String> {
243-
self.0
244-
.lock()
245-
.await
246-
.graphics
247-
.get_default_graphics()
248-
.map_err(zbus_error_from_display)
249-
.map(|mode| <&'static str>::from(mode).to_owned())
250-
}
251-
252-
#[dbus_interface(out_args("vendor"))]
253-
async fn get_graphics(&self) -> zbus::fdo::Result<String> {
254-
self.0
255-
.lock()
256-
.await
257-
.graphics
258-
.get_vendor()
259-
.map_err(zbus_error_from_display)
260-
.map(|mode| <&'static str>::from(mode).to_owned())
261-
}
262-
263-
async fn set_graphics(&mut self, vendor: &str) -> zbus::fdo::Result<()> {
264-
self.0
265-
.lock()
266-
.await
267-
.graphics
268-
.set_vendor(GraphicsMode::from(vendor))
269-
.map_err(zbus_error_from_display)
270-
}
271-
272241
#[dbus_interface(out_args("desktop"))]
273242
async fn get_desktop(&mut self) -> zbus::fdo::Result<bool> {
274243
Ok(self.0.lock().await.graphics.is_desktop())
275244
}
276245

277-
#[dbus_interface(out_args("switchable"))]
278-
async fn get_switchable(&mut self) -> zbus::fdo::Result<bool> {
279-
Ok(self.0.lock().await.graphics.can_switch())
280-
}
281-
282-
#[dbus_interface(out_args("power"))]
283-
async fn get_graphics_power(&mut self) -> zbus::fdo::Result<bool> {
284-
self.0.lock().await.graphics.get_power().map_err(zbus_error_from_display)
285-
}
286-
287-
async fn set_graphics_power(&mut self, power: bool) -> zbus::fdo::Result<()> {
288-
self.0.lock().await.graphics.set_power(power).map_err(zbus_error_from_display)
289-
}
290-
291-
async fn auto_graphics_power(&mut self) -> zbus::fdo::Result<()> {
292-
self.0.lock().await.graphics.auto_power().map_err(zbus_error_from_display)
293-
}
294-
295246
#[dbus_interface(out_args("start", "end"))]
296247
async fn get_charge_thresholds(&mut self) -> zbus::fdo::Result<(u8, u8)> {
297248
get_charge_thresholds().map_err(zbus_error_from_display)
@@ -532,13 +483,6 @@ pub async fn daemon() -> anyhow::Result<()> {
532483
let daemon = Arc::new(Mutex::new(daemon));
533484
let mut system76_daemon = System76Power(daemon.clone());
534485

535-
match system76_daemon.auto_graphics_power().await {
536-
Ok(()) => (),
537-
Err(err) => {
538-
log::warn!("Failed to set automatic graphics power: {}", err);
539-
}
540-
}
541-
542486
let vendor = fs::read_to_string("/sys/class/dmi/id/sys_vendor")?;
543487
let model = fs::read_to_string("/sys/class/dmi/id/product_version")?;
544488
match runtime_pm_quirks(&vendor, &model) {

0 commit comments

Comments
 (0)