Skip to content

Commit

Permalink
Display link for NPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
nokyan committed Feb 21, 2025
1 parent 5613f0f commit e67b758
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions data/resources/ui/pages/npu.ui
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@
<property name="title" translatable="yes">Max Power Cap</property>
</object>
</child>
<child>
<object class="AdwActionRow" id="link"><!--Translators: "Link" refers to something like "PCIe 4.0 ×16"-->
<property name="title" translatable="yes">Link</property>
<style>
<class name="property"/>
</style>
<property name="subtitle-selectable">true</property>
</object>
</child>
</object>
</child>
</object>
Expand Down
9 changes: 9 additions & 0 deletions src/ui/pages/npu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ mod imp {
pub driver_used: TemplateChild<adw::ActionRow>,
#[template_child]
pub max_power_cap: TemplateChild<adw::ActionRow>,
#[template_child]
pub link: TemplateChild<adw::ActionRow>,

#[property(get)]
uses_progress_bar: Cell<bool>,
Expand Down Expand Up @@ -99,6 +101,7 @@ mod imp {
pci_slot: Default::default(),
driver_used: Default::default(),
max_power_cap: Default::default(),
link: Default::default(),
uses_progress_bar: Cell::new(true),
main_graph_color: glib::Bytes::from_static(&super::ResNPU::MAIN_GRAPH_COLOR),
icon: RefCell::new(ThemedIcon::new("npu-symbolic").into()),
Expand Down Expand Up @@ -218,6 +221,12 @@ impl ResNPU {

imp.driver_used.set_subtitle(&npu.driver());

if let Ok(link) = npu.link() {
imp.link.set_subtitle(&link.to_string());
} else {
imp.link.set_subtitle(&i18n("N/A"));
}

if let Ok(model_name) = npu.name() {
imp.set_tab_detail_string(&model_name);
}
Expand Down
9 changes: 8 additions & 1 deletion src/utils/npu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ use crate::{

use self::{intel::IntelNpu, other::OtherNpu};

use super::pci::Vendor;
use super::{
link::{Link, LinkData},
pci::Vendor,
};

pub const VID_INTEL: u16 = 0x8086;

Expand Down Expand Up @@ -389,4 +392,8 @@ impl Npu {
Npu::Other(npu) => npu.power_cap_max(),
}
}

pub fn link(&self) -> Result<Link> {
Ok(Link::Pcie(LinkData::from_pci_slot(&self.pci_slot())?))
}
}

0 comments on commit e67b758

Please sign in to comment.