diff --git a/src/tuxedo_io/tongfang_wmi.h b/src/tuxedo_io/tongfang_wmi.h index deb488c..1da271e 100644 --- a/src/tuxedo_io/tongfang_wmi.h +++ b/src/tuxedo_io/tongfang_wmi.h @@ -309,7 +309,7 @@ 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 bit set) switch to it (required for fancontrol) + // 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"); @@ -326,3 +326,28 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed) return 0; } + +static u32 uw_set_fan_auto() +{ + u8 reg_high = 0x18; + u32 i; + union uw_ec_read_return reg_read_return; + union uw_ec_write_return reg_write_return; + u8 low_reg_fan0 = 0x04; + u8 low_reg_fan1 = 0x09; + + // Check current mode + uw_ec_read_addr(0x51, 0x07, ®_read_return); + if (reg_read_return.bytes.data_low & 0x40) { + // If "full fan mode" (i.e. 0x40 bit set) switch it off + uw_ec_write_addr(0x51, 0x07, reg_read_return.bytes.data_low & 0xbf, 0x00, ®_write_return); + // Attempt to write both fans to 100% to restore default "full fan mode" + for (i = 0; i < 10; ++i) { + uw_ec_write_addr(low_reg_fan0, reg_high, 0xc8, 0x00, ®_write_return); + uw_ec_write_addr(low_reg_fan1, reg_high, 0xc8, 0x00, ®_write_return); + msleep(10); + } + } + + return 0; +} diff --git a/src/tuxedo_io/tuxedo_io.c b/src/tuxedo_io/tuxedo_io.c index 032cd10..268410d 100644 --- a/src/tuxedo_io/tuxedo_io.c +++ b/src/tuxedo_io/tuxedo_io.c @@ -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..1af3ae4 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 _IOW(MAGIC_WRITE_UW, 0x14) // undo all previous calls of W_UW_FANSPEED and W_UW_FANSPEED2 #endif