mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fixes
- Adjust gfx controller to assume that the graphics driver is loaded if the mode is set for nvidia/hybrid - Small code adjustments for error handling
This commit is contained in:
@@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Changed
|
||||||
|
- Adjust gfx controller to assume that the graphics driver is loaded if the
|
||||||
|
mode is set for nvidia/hybrid
|
||||||
|
|
||||||
# [2.1.0] - 2021-01-09
|
# [2.1.0] - 2021-01-09
|
||||||
### Changed
|
### Changed
|
||||||
- Updates to dependencies
|
- Updates to dependencies
|
||||||
|
|||||||
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -29,7 +29,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asus-nb"
|
name = "asus-nb"
|
||||||
version = "2.1.1"
|
version = "2.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctrl-gfx",
|
"ctrl-gfx",
|
||||||
"dbus",
|
"dbus",
|
||||||
@@ -46,7 +46,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "asus-nb-ctrl"
|
name = "asus-nb-ctrl"
|
||||||
version = "2.1.1"
|
version = "2.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asus-nb",
|
"asus-nb",
|
||||||
"ctrl-gfx",
|
"ctrl-gfx",
|
||||||
@@ -232,7 +232,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctrl-gfx"
|
name = "ctrl-gfx"
|
||||||
version = "2.1.3"
|
version = "2.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"sysfs-class",
|
"sysfs-class",
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -31,7 +31,7 @@ ifeq ($(VENDORED),1)
|
|||||||
ARGS += --frozen
|
ARGS += --frozen
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: build install
|
all: build
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
cargo clean
|
cargo clean
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asus-nb-ctrl"
|
name = "asus-nb-ctrl"
|
||||||
version = "2.1.1"
|
version = "2.1.2"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ impl CtrlCharge {
|
|||||||
Ok(BAT_CHARGE_PATH)
|
Ok(BAT_CHARGE_PATH)
|
||||||
} else {
|
} else {
|
||||||
Err(RogError::MissingFunction(
|
Err(RogError::MissingFunction(
|
||||||
"Charge control not available".into(),
|
"Charge control not available, you may require a v5.8.10 series kernel or newer"
|
||||||
|
.into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ impl CtrlFanAndCPU {
|
|||||||
Ok(FAN_TYPE_2_PATH)
|
Ok(FAN_TYPE_2_PATH)
|
||||||
} else {
|
} else {
|
||||||
Err(RogError::MissingFunction(
|
Err(RogError::MissingFunction(
|
||||||
"Fan mode not available, you may require a v5.8 series kernel or newer".into(),
|
"Fan mode not available, you may require a v5.8.10 series kernel or newer".into(),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,16 @@
|
|||||||
static LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
static LED_APPLY: [u8; 17] = [0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
static LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
static LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
|
static KBD_BRIGHT_PATH: &str = "/sys/class/leds/asus::kbd_backlight/brightness";
|
||||||
|
|
||||||
use crate::{config::Config, error::RogError, laptops::HELP_ADDRESS};
|
use crate::{config::Config, error::RogError, laptops::HELP_ADDRESS};
|
||||||
use asus_nb::{aura_brightness_bytes, aura_modes::AuraModes, fancy::KeyColourArray, LED_MSG_LEN};
|
use asus_nb::{aura_brightness_bytes, aura_modes::AuraModes, fancy::KeyColourArray, LED_MSG_LEN};
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use std::convert::TryInto;
|
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
use std::{convert::TryInto, path::Path};
|
||||||
use zbus::dbus_interface;
|
use zbus::dbus_interface;
|
||||||
|
|
||||||
pub struct CtrlKbdBacklight {
|
pub struct CtrlKbdBacklight {
|
||||||
@@ -227,16 +229,29 @@ impl CtrlKbdBacklight {
|
|||||||
condev_iface: Option<&String>,
|
condev_iface: Option<&String>,
|
||||||
supported_modes: Vec<u8>,
|
supported_modes: Vec<u8>,
|
||||||
config: Arc<Mutex<Config>>,
|
config: Arc<Mutex<Config>>,
|
||||||
) -> Self {
|
) -> Result<Self, RogError> {
|
||||||
// TODO: return error if *all* nodes are None
|
// TODO: return error if *all* nodes are None
|
||||||
CtrlKbdBacklight {
|
let ctrl = CtrlKbdBacklight {
|
||||||
|
// Using `ok` here so we can continue without keyboard features but
|
||||||
|
// still get brightness control at least... maybe...
|
||||||
led_node: Self::get_node_failover(id_product, None, Self::scan_led_node).ok(),
|
led_node: Self::get_node_failover(id_product, None, Self::scan_led_node).ok(),
|
||||||
kbd_node: Self::get_node_failover(id_product, condev_iface, Self::scan_kbd_node).ok(),
|
kbd_node: Self::get_node_failover(id_product, condev_iface, Self::scan_kbd_node).ok(),
|
||||||
// TODO: Check for existance
|
// TODO: Check for existance
|
||||||
bright_node: "/sys/class/leds/asus::kbd_backlight/brightness".to_string(),
|
bright_node: Self::get_kbd_bright_path()?.to_owned(),
|
||||||
supported_modes,
|
supported_modes,
|
||||||
flip_effect_write: false,
|
flip_effect_write: false,
|
||||||
config,
|
config,
|
||||||
|
};
|
||||||
|
Ok(ctrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_kbd_bright_path() -> Result<&'static str, RogError> {
|
||||||
|
if Path::new(KBD_BRIGHT_PATH).exists() {
|
||||||
|
Ok(KBD_BRIGHT_PATH)
|
||||||
|
} else {
|
||||||
|
Err(RogError::MissingFunction(
|
||||||
|
"Keyboard features missing, you may require a v5.11 series kernel or newer".into(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,6 +260,8 @@ impl CtrlKbdBacklight {
|
|||||||
iface: Option<&String>,
|
iface: Option<&String>,
|
||||||
fun: fn(&str, Option<&String>) -> Result<String, RogError>,
|
fun: fn(&str, Option<&String>) -> Result<String, RogError>,
|
||||||
) -> Result<String, RogError> {
|
) -> Result<String, RogError> {
|
||||||
|
// We do three tries here just to be certain that we avoid systemd unit
|
||||||
|
// load order issues
|
||||||
for n in 0..=2 {
|
for n in 0..=2 {
|
||||||
// 0,1,2 inclusive
|
// 0,1,2 inclusive
|
||||||
match fun(id_product, iface) {
|
match fun(id_product, iface) {
|
||||||
|
|||||||
@@ -96,29 +96,30 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
|
|||||||
// Collect tasks for task thread
|
// Collect tasks for task thread
|
||||||
let mut tasks: Vec<Arc<Mutex<dyn CtrlTask + Send>>> = Vec::new();
|
let mut tasks: Vec<Arc<Mutex<dyn CtrlTask + Send>>> = Vec::new();
|
||||||
|
|
||||||
match CtrlFanAndCPU::new(config.clone()) {
|
if let Ok(mut ctrl) = CtrlFanAndCPU::new(config.clone()).map_err(|err| {
|
||||||
Ok(mut ctrl) => {
|
error!("Profile control: {}", err);
|
||||||
ctrl.reload()
|
}) {
|
||||||
.unwrap_or_else(|err| warn!("Profile control: {}", err));
|
ctrl.reload()
|
||||||
let tmp = Arc::new(Mutex::new(ctrl));
|
.unwrap_or_else(|err| warn!("Profile control: {}", err));
|
||||||
DbusFanAndCpu::new(tmp.clone()).add_to_server(&mut object_server);
|
let tmp = Arc::new(Mutex::new(ctrl));
|
||||||
tasks.push(tmp);
|
DbusFanAndCpu::new(tmp.clone()).add_to_server(&mut object_server);
|
||||||
}
|
tasks.push(tmp);
|
||||||
Err(err) => {
|
|
||||||
error!("Profile control: {}", err);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(laptop) = laptop {
|
if let Some(laptop) = laptop {
|
||||||
let ctrl = CtrlKbdBacklight::new(
|
if let Ok(ctrl) = CtrlKbdBacklight::new(
|
||||||
laptop.usb_product(),
|
laptop.usb_product(),
|
||||||
laptop.condev_iface(),
|
laptop.condev_iface(),
|
||||||
laptop.supported_modes().to_owned(),
|
laptop.supported_modes().to_owned(),
|
||||||
config,
|
config,
|
||||||
);
|
)
|
||||||
let tmp = Arc::new(Mutex::new(ctrl));
|
.map_err(|err| {
|
||||||
DbusKbdBacklight::new(tmp.clone()).add_to_server(&mut object_server);
|
error!("Keyboard control: {}", err);
|
||||||
tasks.push(tmp);
|
}) {
|
||||||
|
let tmp = Arc::new(Mutex::new(ctrl));
|
||||||
|
DbusKbdBacklight::new(tmp.clone()).add_to_server(&mut object_server);
|
||||||
|
tasks.push(tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement messaging between threads to check fails
|
// TODO: implement messaging between threads to check fails
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "asus-nb"
|
name = "asus-nb"
|
||||||
version = "2.1.1"
|
version = "2.1.2"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ctrl-gfx"
|
name = "ctrl-gfx"
|
||||||
version = "2.1.3"
|
version = "2.1.4"
|
||||||
license = "MPL-2.0"
|
license = "MPL-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["Luke <luke@ljones.dev>"]
|
authors = ["Luke <luke@ljones.dev>"]
|
||||||
|
|||||||
@@ -178,27 +178,36 @@ impl CtrlGraphics {
|
|||||||
|
|
||||||
/// Associated method to get which vendor mode is set
|
/// Associated method to get which vendor mode is set
|
||||||
pub fn get_vendor() -> Result<String, GfxError> {
|
pub fn get_vendor() -> Result<String, GfxError> {
|
||||||
|
let mode = match Self::get_prime_discrete() {
|
||||||
|
Ok(m) => m,
|
||||||
|
Err(_) => "nvidia".to_string(),
|
||||||
|
};
|
||||||
let modules = Module::all().map_err(|err| GfxError::Read("get_vendor".into(), err))?;
|
let modules = Module::all().map_err(|err| GfxError::Read("get_vendor".into(), err))?;
|
||||||
let vendor = if modules
|
|
||||||
|
let driver_loaded = if modules
|
||||||
.iter()
|
.iter()
|
||||||
.any(|module| module.name == "nouveau" || module.name == "nvidia")
|
.any(|module| module.name == "nouveau" || module.name == "nvidia")
|
||||||
{
|
{
|
||||||
info!("nvidia or nouveau module found");
|
true
|
||||||
let mode = match Self::get_prime_discrete() {
|
} else {
|
||||||
Ok(m) => m,
|
false
|
||||||
Err(_) => "nvidia".to_string(),
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
let vendor = if mode == "off" {
|
||||||
|
if driver_loaded {
|
||||||
|
info!("dGPU driver loaded for compute mode");
|
||||||
|
"compute".to_string()
|
||||||
|
} else {
|
||||||
|
info!("No dGPU driver loaded");
|
||||||
|
"integrated".to_string()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info!("Assuming dGPU driver loaded");
|
||||||
if mode == "on-demand" {
|
if mode == "on-demand" {
|
||||||
"hybrid".to_string()
|
"hybrid".to_string()
|
||||||
} else if mode == "off" {
|
|
||||||
"compute".to_string()
|
|
||||||
} else {
|
} else {
|
||||||
"nvidia".to_string()
|
"nvidia".to_string()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
info!("No dGPU driver (nouveau or nvidia) loaded");
|
|
||||||
"integrated".to_string()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(vendor)
|
Ok(vendor)
|
||||||
|
|||||||
Reference in New Issue
Block a user