From 2d33628610302171e7d5082217f384d091a05ff2 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Mon, 15 Feb 2021 22:01:13 +0100 Subject: [PATCH] Proof of concept initialization of manual-mode fan-curve --- src/tuxedo_io/tongfang_wmi.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/tuxedo_io/tongfang_wmi.h b/src/tuxedo_io/tongfang_wmi.h index 001413f..7160c34 100644 --- a/src/tuxedo_io/tongfang_wmi.h +++ b/src/tuxedo_io/tongfang_wmi.h @@ -16,6 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this software. If not, see . */ +#pragma once + #include #include #include @@ -273,7 +275,26 @@ static u32 uniwill_identify(void) static void uniwill_init(void) { + u32 i; + u8 uninitialized; + union uw_ec_read_return reg_read_return; union uw_ec_write_return reg_write_return; + // default fan-curve set by Tongfang Windows OSD-driver on Tuxedo Book BA15 + u8 default_fan_curve[5] = {0x32, 0x5a, 0x64, 0x6e, 0x78}; + + // Set manual-mode fan-curve if uninitialized + uninitialized = 1; + for (i = 0; i < 5; ++i) { + uw_ec_read_addr(0x43 + i, 0x07, ®_read_return); + if (reg_read_return.bytes.data_low != 0x00) { + uninitialized = 0; + } + } + if (uninitialized) { + for (i = 0; i < 5; ++i) { + uw_ec_write_addr(0x43 + i, 0x07, default_fan_curve[i], 0x00, ®_write_return); + } + } // Enable manual mode uw_ec_write_addr(0x41, 0x07, 0x01, 0x00, ®_write_return);