mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-07 23:20:31 -04:00
Add gpu power profile(s) properties.
Add profiles property to give back available profiles on this device. Add profile property to get and set current gpu power profile. Filter possible properties when on deck. Get current profile based on position of * character. Get card0 path based on which cardX has vendor 0x1002 Add some basic tests. TODO: Possibly cache available properties instead of fetching repeatedly.
This commit is contained in:
parent
8c1baa152b
commit
0759ff7077
6 changed files with 261 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
use anyhow::Result;
|
||||
use std::collections::HashMap;
|
||||
use tracing::error;
|
||||
use zbus::proxy::Builder;
|
||||
use zbus::zvariant::Fd;
|
||||
|
@ -15,7 +16,10 @@ use zbus::{fdo, interface, Connection, Proxy, SignalContext};
|
|||
use crate::cec::{HdmiCecControl, HdmiCecState};
|
||||
use crate::error::{to_zbus_error, to_zbus_fdo_error, zbus_to_zbus_fdo};
|
||||
use crate::hardware::check_support;
|
||||
use crate::power::{get_gpu_clocks, get_gpu_performance_level, get_tdp_limit};
|
||||
use crate::power::{
|
||||
get_gpu_clocks, get_gpu_performance_level, get_gpu_power_profile, get_gpu_power_profiles,
|
||||
get_tdp_limit,
|
||||
};
|
||||
use crate::wifi::{get_wifi_backend, get_wifi_power_management_state};
|
||||
use crate::API_VERSION;
|
||||
|
||||
|
@ -178,6 +182,30 @@ impl SteamOSManager {
|
|||
method!(self, "FormatDevice", device, label, validate)
|
||||
}
|
||||
|
||||
#[zbus(property(emits_changed_signal = "false"))]
|
||||
async fn gpu_power_profiles(&self) -> fdo::Result<HashMap<u32, String>> {
|
||||
get_gpu_power_profiles().await.map_err(to_zbus_fdo_error)
|
||||
}
|
||||
|
||||
#[zbus(property(emits_changed_signal = "false"))]
|
||||
async fn gpu_power_profile(&self) -> fdo::Result<u32> {
|
||||
match get_gpu_power_profile().await {
|
||||
Ok(profile) => Ok(profile as u32),
|
||||
Err(e) => {
|
||||
error!("Error getting GPU power profile: {e}");
|
||||
Err(to_zbus_fdo_error(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[zbus(property)]
|
||||
async fn set_gpu_power_profile(&self, profile: u32) -> zbus::Result<()> {
|
||||
self.proxy
|
||||
.call("SetGpuPowerProfile", &(profile))
|
||||
.await
|
||||
.map_err(to_zbus_error)
|
||||
}
|
||||
|
||||
#[zbus(property(emits_changed_signal = "false"))]
|
||||
async fn gpu_performance_level(&self) -> fdo::Result<u32> {
|
||||
match get_gpu_performance_level().await {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue