Drop sysfs_class and create dmi_id for getting identifying info with udev

This commit is contained in:
Luke D. Jones
2023-10-30 14:46:36 +13:00
parent 4c50dc259c
commit 35c7fd10b3
14 changed files with 54 additions and 65 deletions

View File

@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Support for G513RW LED modes
- Support Rog Ally LED modes (basic)
### Changed
- rog-control-center: ensure brightness slider works correctly
@@ -17,7 +18,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Support for G733PZ LED modes
- Support for G713RC LED modes
- Support Rog Ally LED modes (basic)
### Changed
- Fix loading of fan curves from stored settings

36
Cargo.lock generated
View File

@@ -202,6 +202,7 @@ version = "4.7.2"
dependencies = [
"asusd",
"cargo-husky",
"dmi_id",
"gif",
"glam",
"gumdrop",
@@ -210,7 +211,6 @@ dependencies = [
"rog_dbus",
"rog_platform",
"rog_profiles",
"sysfs-class",
"tinybmp",
"toml 0.5.11",
]
@@ -223,6 +223,7 @@ dependencies = [
"cargo-husky",
"concat-idents",
"config-traits",
"dmi_id",
"env_logger",
"log",
"logind-zbus",
@@ -233,7 +234,6 @@ dependencies = [
"rog_profiles",
"serde",
"serde_derive",
"sysfs-class",
"systemd-zbus",
"tokio",
"zbus",
@@ -835,6 +835,10 @@ dependencies = [
"libc",
]
[[package]]
name = "cpuctl"
version = "4.7.2"
[[package]]
name = "cpufeatures"
version = "0.2.9"
@@ -955,6 +959,14 @@ dependencies = [
"libloading",
]
[[package]]
name = "dmi_id"
version = "4.7.2"
dependencies = [
"log",
"udev",
]
[[package]]
name = "downcast-rs"
version = "1.2.0"
@@ -2275,12 +2287,6 @@ dependencies = [
"syn 2.0.31",
]
[[package]]
name = "numtoa"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
[[package]]
name = "objc"
version = "0.2.7"
@@ -2714,6 +2720,7 @@ name = "rog_anime"
version = "4.7.2"
dependencies = [
"cargo-husky",
"dmi_id",
"gif",
"glam",
"log",
@@ -2721,7 +2728,6 @@ dependencies = [
"png_pong",
"serde",
"serde_derive",
"sysfs-class",
"typeshare",
"zbus",
]
@@ -2731,11 +2737,11 @@ name = "rog_aura"
version = "4.7.2"
dependencies = [
"cargo-husky",
"dmi_id",
"log",
"ron",
"serde",
"serde_derive",
"sysfs-class",
"typeshare",
"zbus",
]
@@ -2765,7 +2771,6 @@ dependencies = [
"rusb",
"serde",
"serde_derive",
"sysfs-class",
"typeshare",
"udev",
"zbus",
@@ -3172,15 +3177,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "sysfs-class"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e1bbcf869732c45a77898f7f61ed6d411dfc37613517e444842f58d428856d1"
dependencies = [
"numtoa",
]
[[package]]
name = "system-deps"
version = "6.1.1"

View File

@@ -1,6 +1,6 @@
[workspace]
members = ["asusctl", "asusd", "asusd-user", "config-traits", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center", "simulators"]
default-members = ["asusctl", "asusd", "asusd-user", "rog-control-center"]
members = ["asusctl", "asusd", "asusd-user", "config-traits", "cpuctl", "dmi-id", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center", "simulators"]
default-members = ["asusctl", "asusd", "asusd-user", "cpuctl", "rog-control-center"]
resolver = "2"
[workspace.package]
@@ -30,7 +30,6 @@ glam = { version = "^0.22", features = ["serde"] }
gumdrop = "^0.8"
udev = "^0.7"
rusb = "^0.9"
sysfs-class = "^0.1.3"
inotify = "^0.10.0"
png_pong = "^0.8"

View File

@@ -12,10 +12,10 @@ rog_dbus = { path = "../rog-dbus" }
rog_profiles = { path = "../rog-profiles" }
rog_platform = { path = "../rog-platform" }
asusd = { path = "../asusd" }
dmi_id = { path = "../dmi-id" }
gumdrop.workspace = true
toml.workspace = true
sysfs-class.workspace = true
[dev-dependencies]
gif.workspace = true

View File

@@ -6,6 +6,7 @@ use std::thread::sleep;
use anime_cli::{AnimeActions, AnimeCommand};
use aura_cli::{LedPowerCommand1, LedPowerCommand2};
use dmi_id::DMIID;
use gumdrop::{Opt, Options};
use profiles_cli::{FanCurveCommand, ProfileCommand};
use rog_anime::usb::get_anime_type;
@@ -77,9 +78,9 @@ fn print_error_help(err: &dyn std::error::Error, supported: Option<&SupportedFun
}
fn print_info() {
let dmi = sysfs_class::DmiId::default();
let board_name = dmi.board_name().expect("Could not get board_name");
let prod_family = dmi.product_family().expect("Could not get product_family");
let dmi = DMIID::new().unwrap_or_default();
let board_name = dmi.board_name;
let prod_family = dmi.product_family;
println!("asusctl version: {}", env!("CARGO_PKG_VERSION"));
println!(" Product family: {}", prod_family.trim());
println!(" Board name: {}", board_name.trim());

View File

@@ -20,6 +20,7 @@ rog_aura = { path = "../rog-aura", features = ["dbus"] }
rog_platform = { path = "../rog-platform" }
rog_profiles = { path = "../rog-profiles" }
rog_dbus = { path = "../rog-dbus" }
dmi_id = { path = "../dmi-id" }
async-trait.workspace = true
tokio.workspace = true
@@ -35,9 +36,6 @@ logind-zbus.workspace = true
serde.workspace = true
serde_derive.workspace = true
# Device control
sysfs-class.workspace = true # used for backlight control and baord ID
concat-idents.workspace = true
systemd-zbus = "*"

View File

@@ -1,6 +1,7 @@
use std::collections::BTreeMap;
use config_traits::{StdConfig, StdConfigLoad};
use dmi_id::DMIID;
use log::{info, warn};
use rog_aura::advanced::{LedUsbPackets, UsbPackets};
use rog_aura::aura_detection::{LaptopLedData, ASUS_KEYBOARD_DEVICES};
@@ -90,14 +91,12 @@ impl CtrlKbdLed {
let rgb_led = KeyboardLed::new()?;
if usb_node.is_none() && !rgb_led.has_kbd_rgb_mode() {
let dmi = sysfs_class::DmiId::default();
if let Ok(prod_family) = dmi.product_family() {
if prod_family.contains("TUF") {
warn!(
"kbd_rgb_mode was not found in the /sys/. You require a minimum 6.1 \
kernel and a supported TUF laptop"
);
}
let dmi = DMIID::new().unwrap_or_default();
if dmi.dmi_family.contains("TUF") {
warn!(
"kbd_rgb_mode was not found in the /sys/. You require a minimum 6.1 kernel \
and a supported TUF laptop"
);
}
return Err(RogError::NoAuraKeyboard);
}

View File

@@ -20,6 +20,7 @@ pub mod error;
use std::future::Future;
use async_trait::async_trait;
use dmi_id::DMIID;
use log::{debug, info, warn};
use logind_zbus::manager::ManagerProxy;
use zbus::export::futures_util::StreamExt;
@@ -88,12 +89,9 @@ macro_rules! task_watch_item {
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub fn print_board_info() {
let dmi = sysfs_class::DmiId::default();
let board_name = dmi.board_name().expect("Could not get board_name");
let prod_family = dmi.product_family().expect("Could not get product_family");
info!("Product family: {}", prod_family.trim());
info!("Board name: {}", board_name.trim());
let dmi = DMIID::new().unwrap_or_default();
info!("Product family: {}", dmi.product_family);
info!("Board name: {}", dmi.board_name);
}
#[async_trait]

View File

@@ -15,7 +15,7 @@ exclude = ["data"]
[features]
default = ["dbus", "detect"]
dbus = ["zbus"]
detect = ["sysfs-class"]
detect = ["dmi_id"]
[lib]
name = "rog_anime"
@@ -35,7 +35,7 @@ typeshare.workspace = true
zbus = { workspace = true, optional = true }
sysfs-class = { workspace = true, optional = true }
dmi_id = { path = "../dmi-id", optional = true }
[dev-dependencies]
cargo-husky.workspace = true

View File

@@ -10,6 +10,7 @@
use std::str::FromStr;
use dmi_id::DMIID;
use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare;
#[cfg(feature = "dbus")]
@@ -151,8 +152,8 @@ impl FromStr for AnimShutdown {
/// The currently known USB device is `19b6`.
#[inline]
pub fn get_anime_type() -> Result<AnimeType, AnimeError> {
let dmi = sysfs_class::DmiId::default();
let board_name = dmi.board_name()?;
let dmi = DMIID::new().map_err(|_| AnimeError::NoDevice)?; // TODO: better error
let board_name = dmi.board_name;
if board_name.contains("GA401I") || board_name.contains("GA401Q") {
return Ok(AnimeType::GA401);

View File

@@ -20,14 +20,12 @@ dbus = ["zbus"]
serde.workspace = true
serde_derive.workspace = true
zbus = { workspace = true, optional = true }
dmi_id = { path = "../dmi-id" }
# cli and logging
log.workspace = true
typeshare.workspace = true
# Device control
sysfs-class.workspace = true # used for backlight control and baord ID
ron = { version = "*", optional = true }
[dev-dependencies]

View File

@@ -1,3 +1,4 @@
use dmi_id::DMIID;
use log::{error, info, warn};
use serde_derive::{Deserialize, Serialize};
use typeshare::typeshare;
@@ -59,13 +60,12 @@ pub struct LaptopLedData {
impl LaptopLedData {
pub fn get_data() -> Self {
let dmi = sysfs_class::DmiId::default();
let board_name = dmi.board_name().expect("Could not get board_name");
let dmi = DMIID::new().unwrap_or_default();
// let prod_family = dmi.product_family().expect("Could not get
// product_family");
if let Some(modes) = LedSupportFile::load_from_supoprt_db() {
if let Some(data) = modes.matcher(&board_name) {
if let Some(data) = modes.matcher(&dmi.board_name) {
return data;
}
}

View File

@@ -39,15 +39,15 @@ impl RogApp {
}
// TODO: Anime page is not complete
// if self.supported.anime_ctrl.0 {
// ui.separator();
// if ui
// .selectable_value(page, Page::AnimeMatrix, "AniMe Matrix")
// .clicked()
// {
// *page = Page::AnimeMatrix;
// }
// }
if self.supported.anime_ctrl.0 {
ui.separator();
if ui
.selectable_value(page, Page::AnimeMatrix, "AniMe Matrix")
.clicked()
{
*page = Page::AnimeMatrix;
}
}
ui.separator();
if ui

View File

@@ -11,7 +11,6 @@ rog_profiles = { path = "../rog-profiles" }
serde.workspace = true
serde_derive.workspace = true
zbus.workspace = true
sysfs-class.workspace = true
concat-idents.workspace = true
udev.workspace = true
inotify.workspace = true