From 44f7fd0151aeb3cd96764c99535d103c781ece10 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Tue, 4 Oct 2022 13:59:13 +0200 Subject: [PATCH] Expose fan control limitations to userspace --- src/tuxedo_io/tuxedo_io.c | 22 +++++++++++++++++++++- src/tuxedo_io/tuxedo_io_ioctl.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/tuxedo_io/tuxedo_io.c b/src/tuxedo_io/tuxedo_io.c index ad84fc7..c8f087c 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.4"); +MODULE_VERSION("0.2.5"); MODULE_LICENSE("GPL"); MODULE_ALIAS_CLEVO_INTERFACES(); @@ -358,6 +358,26 @@ static long uniwill_ioctl_interface(struct file *file, unsigned int cmd, unsigne result = byte_data; copy_result = copy_to_user((void *) arg, &result, sizeof(result)); break; + case R_UW_FANS_OFF_POSSIBLE: + result = has_universal_ec_fan_control(); + if (result == 1) { + result = 0; + } + else if (result == 0) { + result = 1; + } + copy_result = copy_to_user((void *) arg, &result, sizeof(result)); + break; + case R_UW_FANSPEED_MIN: + result = has_universal_ec_fan_control(); + if (result == 1) { + result = 20; + } + else if (result == 0) { + result = 0; + } + copy_result = copy_to_user((void *) arg, &result, sizeof(result)); + break; #ifdef DEBUG case R_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 f271707..a829753 100644 --- a/src/tuxedo_io/tuxedo_io_ioctl.h +++ b/src/tuxedo_io/tuxedo_io_ioctl.h @@ -79,6 +79,8 @@ #define R_UW_MODE _IOR(MAGIC_READ_UW, 0x14, int32_t*) #define R_UW_MODE_ENABLE _IOR(MAGIC_READ_UW, 0x15, int32_t*) +#define R_UW_FANS_OFF_POSSIBLE _IOR(MAGIC_READ_UW, 0x16, int32_t*) +#define R_UW_FANSPEED_MIN _IOR(MAGIC_READ_UW, 0x17, int32_t*) // Write #define W_UW_FANSPEED _IOW(MAGIC_WRITE_UW, 0x10, int32_t*)