Compare commits

...

3 Commits
2.1.1 ... 2.1.2

Author SHA1 Message Date
Luke
703bba9ffd Correct changelog 2021-01-10 22:34:45 +13:00
Luke Jones
73706154a4 Merge branch 'fluke/fixes' into 'next'
Fixes

See merge request asus-linux/asus-nb-ctrl!14
2021-01-10 09:31:46 +00:00
Luke
c9b2a0c777 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
2021-01-10 22:27:56 +13:00
11 changed files with 75 additions and 41 deletions

View File

@@ -5,7 +5,13 @@ 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).
## [Unreleased]
# [2.1.0] - 2021-01-09
# [2.1.2] - 2021-01-10
### Changed
- Adjust gfx controller to assume that the graphics driver is loaded if the
mode is set for nvidia/hybrid
# [2.1.1] - 2021-01-09
### Changed
- Updates to dependencies

6
Cargo.lock generated
View File

@@ -29,7 +29,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "asus-nb"
version = "2.1.1"
version = "2.1.2"
dependencies = [
"ctrl-gfx",
"dbus",
@@ -46,7 +46,7 @@ dependencies = [
[[package]]
name = "asus-nb-ctrl"
version = "2.1.1"
version = "2.1.2"
dependencies = [
"asus-nb",
"ctrl-gfx",
@@ -232,7 +232,7 @@ dependencies = [
[[package]]
name = "ctrl-gfx"
version = "2.1.3"
version = "2.1.4"
dependencies = [
"log",
"sysfs-class",

View File

@@ -31,7 +31,7 @@ ifeq ($(VENDORED),1)
ARGS += --frozen
endif
all: build install
all: build
clean:
cargo clean

View File

@@ -1,6 +1,6 @@
[package]
name = "asus-nb-ctrl"
version = "2.1.1"
version = "2.1.2"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]

View File

@@ -81,7 +81,8 @@ impl CtrlCharge {
Ok(BAT_CHARGE_PATH)
} else {
Err(RogError::MissingFunction(
"Charge control not available".into(),
"Charge control not available, you may require a v5.8.10 series kernel or newer"
.into(),
))
}
}

View File

@@ -192,7 +192,7 @@ impl CtrlFanAndCPU {
Ok(FAN_TYPE_2_PATH)
} else {
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(),
))
}
}

View File

@@ -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_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 asus_nb::{aura_brightness_bytes, aura_modes::AuraModes, fancy::KeyColourArray, LED_MSG_LEN};
use log::{info, warn};
use std::convert::TryInto;
use std::fs::OpenOptions;
use std::io::{Read, Write};
use std::sync::Arc;
use std::sync::Mutex;
use std::{convert::TryInto, path::Path};
use zbus::dbus_interface;
pub struct CtrlKbdBacklight {
@@ -227,16 +229,29 @@ impl CtrlKbdBacklight {
condev_iface: Option<&String>,
supported_modes: Vec<u8>,
config: Arc<Mutex<Config>>,
) -> Self {
) -> Result<Self, RogError> {
// 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(),
kbd_node: Self::get_node_failover(id_product, condev_iface, Self::scan_kbd_node).ok(),
// 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,
flip_effect_write: false,
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>,
fun: fn(&str, Option<&String>) -> 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 {
// 0,1,2 inclusive
match fun(id_product, iface) {

View File

@@ -96,29 +96,30 @@ fn start_daemon() -> Result<(), Box<dyn Error>> {
// Collect tasks for task thread
let mut tasks: Vec<Arc<Mutex<dyn CtrlTask + Send>>> = Vec::new();
match CtrlFanAndCPU::new(config.clone()) {
Ok(mut ctrl) => {
ctrl.reload()
.unwrap_or_else(|err| warn!("Profile control: {}", err));
let tmp = Arc::new(Mutex::new(ctrl));
DbusFanAndCpu::new(tmp.clone()).add_to_server(&mut object_server);
tasks.push(tmp);
}
Err(err) => {
error!("Profile control: {}", err);
}
if let Ok(mut ctrl) = CtrlFanAndCPU::new(config.clone()).map_err(|err| {
error!("Profile control: {}", err);
}) {
ctrl.reload()
.unwrap_or_else(|err| warn!("Profile control: {}", err));
let tmp = Arc::new(Mutex::new(ctrl));
DbusFanAndCpu::new(tmp.clone()).add_to_server(&mut object_server);
tasks.push(tmp);
};
if let Some(laptop) = laptop {
let ctrl = CtrlKbdBacklight::new(
if let Ok(ctrl) = CtrlKbdBacklight::new(
laptop.usb_product(),
laptop.condev_iface(),
laptop.supported_modes().to_owned(),
config,
);
let tmp = Arc::new(Mutex::new(ctrl));
DbusKbdBacklight::new(tmp.clone()).add_to_server(&mut object_server);
tasks.push(tmp);
)
.map_err(|err| {
error!("Keyboard control: {}", err);
}) {
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

View File

@@ -1,6 +1,6 @@
[package]
name = "asus-nb"
version = "2.1.1"
version = "2.1.2"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]

View File

@@ -1,6 +1,6 @@
[package]
name = "ctrl-gfx"
version = "2.1.3"
version = "2.1.4"
license = "MPL-2.0"
readme = "README.md"
authors = ["Luke <luke@ljones.dev>"]

View File

@@ -178,27 +178,36 @@ impl CtrlGraphics {
/// Associated method to get which vendor mode is set
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 vendor = if modules
let driver_loaded = if modules
.iter()
.any(|module| module.name == "nouveau" || module.name == "nvidia")
{
info!("nvidia or nouveau module found");
let mode = match Self::get_prime_discrete() {
Ok(m) => m,
Err(_) => "nvidia".to_string(),
};
true
} else {
false
};
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" {
"hybrid".to_string()
} else if mode == "off" {
"compute".to_string()
} else {
"nvidia".to_string()
}
} else {
info!("No dGPU driver (nouveau or nvidia) loaded");
"integrated".to_string()
};
Ok(vendor)