mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Add ioctl to reset fanspeed to auto
This commit is contained in:
parent
4306a80513
commit
5b99255be8
|
@ -309,7 +309,7 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed)
|
||||||
// Check current mode
|
// Check current mode
|
||||||
uw_ec_read_addr(0x51, 0x07, ®_read_return);
|
uw_ec_read_addr(0x51, 0x07, ®_read_return);
|
||||||
if (!(reg_read_return.bytes.data_low & 0x40)) {
|
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);
|
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
|
// Attempt to write both fans as quick as possible before complete ramp-up
|
||||||
pr_debug("prevent ramp-up start\n");
|
pr_debug("prevent ramp-up start\n");
|
||||||
|
@ -326,3 +326,28 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed)
|
||||||
|
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -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);
|
uw_ec_write_addr(0x41, 0x07, argument & 0x01, 0x00, ®_write_return);
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
|
case W_UW_FANAUTO:
|
||||||
|
uw_set_fan_auto();
|
||||||
|
break;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
case W_TF_BC:
|
case W_TF_BC:
|
||||||
copy_result = copy_from_user(&uw_arg, (void *) arg, sizeof(uw_arg));
|
copy_result = copy_from_user(&uw_arg, (void *) arg, sizeof(uw_arg));
|
||||||
|
|
|
@ -83,5 +83,6 @@
|
||||||
#define W_UW_FANSPEED2 _IOW(MAGIC_WRITE_UW, 0x11, int32_t*)
|
#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 _IOW(MAGIC_WRITE_UW, 0x12, int32_t*)
|
||||||
#define W_UW_MODE_ENABLE _IOW(MAGIC_WRITE_UW, 0x13, 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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue