diff --git a/.gitignore b/.gitignore index 0adeb91..ea2bea9 100644 --- a/.gitignore +++ b/.gitignore @@ -18,9 +18,10 @@ Mkfile.old *.mk .vscode/ +*.kdev4 # Packaging rpm deb/tuxedo-keyboard-* *.deb -*.rpm \ No newline at end of file +*.rpm diff --git a/src/tuxedo_io/tongfang_wmi.h b/src/tuxedo_io/tongfang_wmi.h index 001413f..b4ba64a 100644 --- a/src/tuxedo_io/tongfang_wmi.h +++ b/src/tuxedo_io/tongfang_wmi.h @@ -16,6 +16,9 @@ * You should have received a copy of the GNU General Public License * along with this software. If not, see . */ +#ifndef TONGFANG_WMI_H +#define TONGFANG_WMI_H + #include #include #include @@ -274,6 +277,10 @@ static u32 uniwill_identify(void) static void uniwill_init(void) { union uw_ec_write_return reg_write_return; + + // FIXME Hard set balanced profile until we have implemented a way to + // switch it while tuxedo_io is loaded + uw_ec_write_addr(0x51, 0x07, 0x00, 0x00, ®_write_return); // Enable manual mode uw_ec_write_addr(0x41, 0x07, 0x01, 0x00, ®_write_return); @@ -308,9 +315,9 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed) // Check current mode uw_ec_read_addr(0x51, 0x07, ®_read_return); - if (reg_read_return.bytes.data_low != 0x40) { - // If not "full fan mode" (ie. 0x40) switch to it (required for fancontrol) - uw_ec_write_addr(0x51, 0x07, 0x40, 0x00, ®_write_return); + if (!(reg_read_return.bytes.data_low & 0x40)) { + // If not "full fan mode" (i.e. 0x40 bit set) switch to it (required for fancontrol) + uw_ec_write_addr(0x51, 0x07, reg_read_return.bytes.data_low | 0x40, 0x00, ®_write_return); // Attempt to write both fans as quick as possible before complete ramp-up pr_debug("prevent ramp-up start\n"); for (i = 0; i < 10; ++i) { @@ -326,3 +333,18 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed) return 0; } + +static u32 uw_set_fan_auto(void) +{ + union uw_ec_read_return reg_read_return; + union uw_ec_write_return reg_write_return; + + // Get current mode + uw_ec_read_addr(0x51, 0x07, ®_read_return); + // Switch off "full fan mode" (i.e. unset 0x40 bit) + uw_ec_write_addr(0x51, 0x07, reg_read_return.bytes.data_low & 0xbf, 0x00, ®_write_return); + + return 0; +} + +#endif diff --git a/src/tuxedo_io/tuxedo_io.c b/src/tuxedo_io/tuxedo_io.c index 032cd10..4fbd794 100644 --- a/src/tuxedo_io/tuxedo_io.c +++ b/src/tuxedo_io/tuxedo_io.c @@ -32,7 +32,7 @@ MODULE_DESCRIPTION("Hardware interface for TUXEDO laptops"); MODULE_AUTHOR("TUXEDO Computers GmbH "); -MODULE_VERSION("0.2.1"); +MODULE_VERSION("0.2.2"); MODULE_LICENSE("GPL"); MODULE_ALIAS_CLEVO_INTERFACES(); @@ -229,6 +229,9 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne uw_ec_write_addr(0x41, 0x07, argument & 0x01, 0x00, ®_write_return); */ break; + case W_UW_FANAUTO: + uw_set_fan_auto(); + break; #ifdef DEBUG case W_TF_BC: copy_result = copy_from_user(&uw_arg, (void *) arg, sizeof(uw_arg)); diff --git a/src/tuxedo_io/tuxedo_io_ioctl.h b/src/tuxedo_io/tuxedo_io_ioctl.h index ccef035..c86edc3 100644 --- a/src/tuxedo_io/tuxedo_io_ioctl.h +++ b/src/tuxedo_io/tuxedo_io_ioctl.h @@ -83,5 +83,6 @@ #define W_UW_FANSPEED2 _IOW(MAGIC_WRITE_UW, 0x11, int32_t*) #define W_UW_MODE _IOW(MAGIC_WRITE_UW, 0x12, int32_t*) #define W_UW_MODE_ENABLE _IOW(MAGIC_WRITE_UW, 0x13, int32_t*) +#define W_UW_FANAUTO _IO(MAGIC_WRITE_UW, 0x14) // undo all previous calls of W_UW_FANSPEED and W_UW_FANSPEED2 #endif