manager/user: Move relevant methods to GpuTdpLimit1, update as specified

This commit is contained in:
Vicki Pfau 2024-07-31 22:40:52 -07:00
parent 576135cd7a
commit 5e828efdfa
4 changed files with 54 additions and 55 deletions

View file

@ -31,36 +31,15 @@
-->
<property name="Version" type="u" access="read"/>
<!--
TdpLimit:
Controls the GPU TDP limit.
Valid states: In range of [ TdpLimitMin, TdpLimitMax ]
Since: 7
-->
<property name="TdpLimit" type="u" access="readwrite"/>
<!--
TdpLimitMin:
Minimum allowed TDP Limit.
This is a dummy function. Use the GpuTdpLimit1 interface instead.
Since: 7
-->
<property name="TdpLimitMin" type="u" access="read"/>
<!--
TdpLimitMax:
Maximum allowed TDP Limit.
Since: 7
-->
<property name="TdpLimitMax" type="u" access="read"/>
<!--
WifiDebugModeState:

View file

@ -15,8 +15,9 @@ use steamos_manager::hardware::FanControlState;
use steamos_manager::power::{CPUScalingGovernor, GPUPerformanceLevel, GPUPowerProfile};
use steamos_manager::proxy::{
AmbientLightSensor1Proxy, CpuScaling1Proxy, FactoryReset1Proxy, FanControl1Proxy,
GpuPerformanceLevel1Proxy, GpuPowerProfile1Proxy, HdmiCec1Proxy, Manager2Proxy, ManagerProxy,
Storage1Proxy, UpdateBios1Proxy, UpdateDock1Proxy, WifiDebug1Proxy, WifiPowerManagement1Proxy,
GpuPerformanceLevel1Proxy, GpuPowerProfile1Proxy, GpuTdpLimit1Proxy, HdmiCec1Proxy,
Manager2Proxy, ManagerProxy, Storage1Proxy, UpdateBios1Proxy, UpdateDock1Proxy,
WifiDebug1Proxy, WifiPowerManagement1Proxy,
};
use steamos_manager::wifi::{WifiBackend, WifiDebugMode, WifiPowerManagement};
use zbus::fdo::PropertiesProxy;
@ -312,17 +313,21 @@ async fn main() -> Result<()> {
println!("Manual GPU Clock Min: {value}");
}
Commands::SetTDPLimit { limit } => {
let proxy = GpuTdpLimit1Proxy::new(&conn).await?;
proxy.set_tdp_limit(*limit).await?;
}
Commands::GetTDPLimit => {
let proxy = GpuTdpLimit1Proxy::new(&conn).await?;
let limit = proxy.tdp_limit().await?;
println!("TDP limit: {limit}");
}
Commands::GetTDPLimitMax => {
let proxy = GpuTdpLimit1Proxy::new(&conn).await?;
let value = proxy.tdp_limit_max().await?;
println!("TDP limit max: {value}");
}
Commands::GetTDPLimitMin => {
let proxy = GpuTdpLimit1Proxy::new(&conn).await?;
let value = proxy.tdp_limit_min().await?;
println!("TDP limit min: {value}");
}

View file

@ -119,6 +119,10 @@ struct GpuPowerProfile1 {
proxy: Proxy<'static>,
}
struct GpuTdpLimit1 {
proxy: Proxy<'static>,
}
struct HdmiCec1 {
hdmi_cec: HdmiCecControl<'static>,
}
@ -169,29 +173,9 @@ impl SteamOSManager {
API_VERSION
}
#[zbus(property(emits_changed_signal = "false"))]
async fn tdp_limit(&self) -> fdo::Result<u32> {
get_tdp_limit().await.map_err(to_zbus_fdo_error)
}
#[zbus(property)]
async fn set_tdp_limit(&self, limit: u32) -> zbus::Result<()> {
self.proxy
.call("SetTdpLimit", &(limit))
.await
.map_err(to_zbus_error)
}
#[zbus(property(emits_changed_signal = "const"))]
async fn tdp_limit_min(&self) -> u32 {
// TODO: Can this be queried from somewhere?
3
}
#[zbus(property(emits_changed_signal = "const"))]
async fn tdp_limit_max(&self) -> u32 {
// TODO: Can this be queried from somewhere?
15
0
}
#[zbus(property)]
@ -386,6 +370,34 @@ impl GpuPowerProfile1 {
}
}
#[interface(name = "com.steampowered.SteamOSManager1.GpuTdpLimit1")]
impl GpuTdpLimit1 {
#[zbus(property(emits_changed_signal = "false"))]
async fn tdp_limit(&self) -> fdo::Result<u32> {
get_tdp_limit().await.map_err(to_zbus_fdo_error)
}
#[zbus(property)]
async fn set_tdp_limit(&self, limit: u32) -> zbus::Result<()> {
self.proxy
.call("SetTdpLimit", &(limit))
.await
.map_err(to_zbus_error)
}
#[zbus(property(emits_changed_signal = "const"))]
async fn tdp_limit_min(&self) -> u32 {
// TODO: Can this be queried from somewhere?
3
}
#[zbus(property(emits_changed_signal = "const"))]
async fn tdp_limit_max(&self) -> u32 {
// TODO: Can this be queried from somewhere?
15
}
}
impl HdmiCec1 {
async fn new(connection: &Connection) -> Result<HdmiCec1> {
let hdmi_cec = HdmiCecControl::new(connection).await?;
@ -557,6 +569,9 @@ pub(crate) async fn create_interfaces(
let gpu_power_profile = GpuPowerProfile1 {
proxy: proxy.clone(),
};
let gpu_tdp_limit = GpuTdpLimit1 {
proxy: proxy.clone(),
};
let hdmi_cec = HdmiCec1::new(&session).await?;
let manager2 = Manager2 {
proxy: proxy.clone(),
@ -591,6 +606,7 @@ pub(crate) async fn create_interfaces(
.at(MANAGER_PATH, gpu_performance_level)
.await?;
object_server.at(MANAGER_PATH, gpu_power_profile).await?;
object_server.at(MANAGER_PATH, gpu_tdp_limit).await?;
object_server.at(MANAGER_PATH, hdmi_cec).await?;
object_server.at(MANAGER_PATH, manager2).await?;
object_server.at(MANAGER_PATH, storage).await?;
@ -724,6 +740,15 @@ mod test {
.unwrap());
}
#[tokio::test]
async fn interface_matches_gpu_tdp_limit1() {
let test = start().await.expect("start");
assert!(test_interface_matches::<GpuTdpLimit1>(&test.connection)
.await
.unwrap());
}
#[tokio::test]
async fn interface_matches_hdmi_cec1() {
let test = start().await.expect("start");

View file

@ -22,16 +22,6 @@ trait Manager {
/// SetWifiDebugMode method
fn set_wifi_debug_mode(&self, mode: u32, buffer_size: u32) -> zbus::Result<()>;
/// TdpLimit property
#[zbus(property)]
fn tdp_limit(&self) -> zbus::Result<u32>;
#[zbus(property)]
fn set_tdp_limit(&self, value: u32) -> zbus::Result<()>;
/// TdpLimitMax property
#[zbus(property)]
fn tdp_limit_max(&self) -> zbus::Result<u32>;
/// TdpLimitMin property
#[zbus(property)]
fn tdp_limit_min(&self) -> zbus::Result<u32>;