mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2026-08-19 01:14:43 -05:00
move out clocks into a separate api call
This commit is contained in:
@@ -109,10 +109,6 @@ impl GpuController {
|
||||
let driver = self.handle.get_driver();
|
||||
let vbios_version = self.handle.get_vbios_version().ok();
|
||||
let link_info = self.get_link_info();
|
||||
let clocks_table = self.handle.get_clocks_table().ok();
|
||||
let clocks_info = clocks_table
|
||||
.as_ref()
|
||||
.map_or_else(Default::default, ClocksInfo::from);
|
||||
|
||||
DeviceInfo {
|
||||
pci_info,
|
||||
@@ -120,8 +116,6 @@ impl GpuController {
|
||||
driver,
|
||||
vbios_version,
|
||||
link_info,
|
||||
clocks_table,
|
||||
clocks_info,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,6 +172,14 @@ impl GpuController {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_clocks_info(&self) -> anyhow::Result<ClocksInfo> {
|
||||
let clocks_table = self
|
||||
.handle
|
||||
.get_clocks_table()
|
||||
.context("Clocks table not available")?;
|
||||
Ok(clocks_table.into())
|
||||
}
|
||||
|
||||
fn hw_mon_and_then<U>(&self, f: fn(&HwMon) -> Result<U, Error>) -> Option<U> {
|
||||
self.handle.hw_monitors.first().and_then(|mon| f(mon).ok())
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::gpu_controller::{fan_control::FanCurve, GpuController};
|
||||
use crate::config::{Config, FanControlSettings, GpuConfig};
|
||||
use amdgpu_sysfs::sysfs::SysFS;
|
||||
use anyhow::{anyhow, Context};
|
||||
use lact_schema::{DeviceInfo, DeviceListEntry, DeviceStats, FanCurveMap};
|
||||
use lact_schema::{ClocksInfo, DeviceInfo, DeviceListEntry, DeviceStats, FanCurveMap};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
path::PathBuf,
|
||||
@@ -149,6 +149,10 @@ impl<'a> Handler {
|
||||
self.controller_by_id(id)?.get_stats()
|
||||
}
|
||||
|
||||
pub fn get_clocks_info(&'a self, id: &str) -> anyhow::Result<ClocksInfo> {
|
||||
self.controller_by_id(id)?.get_clocks_info()
|
||||
}
|
||||
|
||||
pub async fn set_fan_control(
|
||||
&'a self,
|
||||
id: &str,
|
||||
|
||||
@@ -83,6 +83,7 @@ async fn handle_request<'a>(request: Request<'a>, handler: &'a Handler) -> anyho
|
||||
Request::ListDevices => ok_response(handler.list_devices()),
|
||||
Request::DeviceInfo { id } => ok_response(handler.get_device_info(id)?),
|
||||
Request::DeviceStats { id } => ok_response(handler.get_gpu_stats(id)?),
|
||||
Request::DeviceClocksInfo { id } => ok_response(handler.get_clocks_info(id)?),
|
||||
Request::SetFanControl { id, enabled, curve } => {
|
||||
ok_response(handler.set_fan_control(id, enabled, curve).await?)
|
||||
}
|
||||
|
||||
@@ -142,14 +142,14 @@ impl App {
|
||||
|
||||
glib::idle_add_local_once(clone!(@strong app, @strong current_gpu_id => move || {
|
||||
let gpu_id = current_gpu_id.read().unwrap();
|
||||
app.set_initial_stats(&gpu_id)
|
||||
app.set_initial(&gpu_id)
|
||||
}));
|
||||
}
|
||||
}),
|
||||
);
|
||||
app.apply_revealer.connect_reset_button_clicked(clone!(@strong app, @strong current_gpu_id => move || {
|
||||
let gpu_id = current_gpu_id.read().unwrap();
|
||||
app.set_initial_stats(&gpu_id)
|
||||
app.set_initial(&gpu_id)
|
||||
}));
|
||||
|
||||
app.start_stats_update_loop(current_gpu_id.clone());
|
||||
@@ -224,10 +224,10 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
self.set_initial_stats(gpu_id);
|
||||
self.set_initial(gpu_id);
|
||||
}
|
||||
|
||||
fn set_initial_stats(&self, gpu_id: &str) {
|
||||
fn set_initial(&self, gpu_id: &str) {
|
||||
let stats_buf = self
|
||||
.daemon_client
|
||||
.get_device_stats(gpu_id)
|
||||
@@ -337,7 +337,7 @@ impl App {
|
||||
.context("Failed to set power cap")?;
|
||||
}
|
||||
|
||||
self.set_initial_stats(&gpu_id);
|
||||
self.set_initial(&gpu_id);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -55,21 +55,24 @@ pub struct DeviceInfo<'a> {
|
||||
pub driver: &'a str,
|
||||
pub vbios_version: Option<String>,
|
||||
pub link_info: LinkInfo,
|
||||
pub clocks_table: Option<ClocksTableGen>,
|
||||
pub clocks_info: ClocksInfo,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone, Copy)]
|
||||
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
|
||||
pub struct ClocksInfo {
|
||||
pub max_sclk: Option<u32>,
|
||||
pub max_mclk: Option<u32>,
|
||||
pub table: Option<ClocksTableGen>,
|
||||
}
|
||||
|
||||
impl<T: ClocksTable> From<&T> for ClocksInfo {
|
||||
fn from(table: &T) -> Self {
|
||||
impl From<ClocksTableGen> for ClocksInfo {
|
||||
fn from(table: ClocksTableGen) -> Self {
|
||||
let max_sclk = table.get_max_sclk();
|
||||
let max_mclk = table.get_max_mclk();
|
||||
Self { max_sclk, max_mclk }
|
||||
Self {
|
||||
max_sclk,
|
||||
max_mclk,
|
||||
table: Some(table),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ pub enum Request<'a> {
|
||||
DeviceStats {
|
||||
id: &'a str,
|
||||
},
|
||||
DeviceClocksInfo {
|
||||
id: &'a str,
|
||||
},
|
||||
SetFanControl {
|
||||
id: &'a str,
|
||||
enabled: bool,
|
||||
|
||||
Reference in New Issue
Block a user