Merge branch 'set_full_fan_mode_less_intrusive' into 'master'

Set full fan mode less intrusive

See merge request tuxedocomputers/development/packages/tuxedo-keyboard!18
This commit is contained in:
Christoffer 2021-03-19 13:46:51 +00:00
commit 2e8e9d9195
4 changed files with 32 additions and 5 deletions

3
.gitignore vendored
View file

@ -18,9 +18,10 @@ Mkfile.old
*.mk *.mk
.vscode/ .vscode/
*.kdev4
# Packaging # Packaging
rpm rpm
deb/tuxedo-keyboard-* deb/tuxedo-keyboard-*
*.deb *.deb
*.rpm *.rpm

View file

@ -16,6 +16,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this software. If not, see <https://www.gnu.org/licenses/>. * along with this software. If not, see <https://www.gnu.org/licenses/>.
*/ */
#ifndef TONGFANG_WMI_H
#define TONGFANG_WMI_H
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/wmi.h> #include <linux/wmi.h>
#include <linux/mutex.h> #include <linux/mutex.h>
@ -274,6 +277,10 @@ static u32 uniwill_identify(void)
static void uniwill_init(void) static void uniwill_init(void)
{ {
union uw_ec_write_return reg_write_return; 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, &reg_write_return);
// Enable manual mode // Enable manual mode
uw_ec_write_addr(0x41, 0x07, 0x01, 0x00, &reg_write_return); uw_ec_write_addr(0x41, 0x07, 0x01, 0x00, &reg_write_return);
@ -308,9 +315,9 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed)
// Check current mode // Check current mode
uw_ec_read_addr(0x51, 0x07, &reg_read_return); uw_ec_read_addr(0x51, 0x07, &reg_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) 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, 0x40, 0x00, &reg_write_return); uw_ec_write_addr(0x51, 0x07, reg_read_return.bytes.data_low | 0x40, 0x00, &reg_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");
for (i = 0; i < 10; ++i) { for (i = 0; i < 10; ++i) {
@ -326,3 +333,18 @@ static u32 uw_set_fan(u32 fan_index, u8 fan_speed)
return 0; 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, &reg_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, &reg_write_return);
return 0;
}
#endif

View file

@ -32,7 +32,7 @@
MODULE_DESCRIPTION("Hardware interface for TUXEDO laptops"); MODULE_DESCRIPTION("Hardware interface for TUXEDO laptops");
MODULE_AUTHOR("TUXEDO Computers GmbH <tux@tuxedocomputers.com>"); MODULE_AUTHOR("TUXEDO Computers GmbH <tux@tuxedocomputers.com>");
MODULE_VERSION("0.2.1"); MODULE_VERSION("0.2.2");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_CLEVO_INTERFACES(); 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, &reg_write_return); uw_ec_write_addr(0x41, 0x07, argument & 0x01, 0x00, &reg_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));

View file

@ -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 _IO(MAGIC_WRITE_UW, 0x14) // undo all previous calls of W_UW_FANSPEED and W_UW_FANSPEED2
#endif #endif