So I have an Acer 7551g, and i’m using this utlity for to control the fan speed because acer sucks.
This works really well and keeps the laptop from overheating and shutting down. However, i’m not a fan of windows and have my laptop setup to dual boot into Arch and have all of my development stuff setup just the way I like it. I decided to try to port the windows fan control util into linux in the form of a kernel module. I have the code written, but it’s not working like I thought it might.
Could someone with linux kernel chops take a look at my code below and compare it to the code referenced above and see what I am missing?? Full disclosure, I am not a C programmer, this is based on the tutorials in the linux kernel module developers guide.
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/io.h>
#define EC_VAL 0x62
#define EC_CMD 0x66
static void wait_write_ec(void)
{
while((inb(EC_CMD) & 0x02) != 0) {
}
}
static void wait_read_ec(void)
{
while ((inb(EC_CMD) & 0x01) == 0) {
}
}
static void write_ec(short addr, short value)
{
wait_write_ec();
outb(EC_CMD,0x81);
wait_write_ec();
outb(EC_VAL,addr);
wait_write_ec();
outb(EC_VAL,value);
}
static int read_ec(short addr)
{
wait_write_ec();
outb(EC_CMD,0x80);
wait_write_ec();
outb(EC_VAL,addr);
wait_read_ec();
return inb(EC_VAL);
}
static void set_speed(short speed)
{
write_ec(0x94, (255-(speed * 135) / 100));
}
static int __init hello_2_init_module(void)
{
printk(KERN_INFO "Fan control init.\n");
short temp = 0;
temp = read_ec(0xA8);
write_ec(0x93, 0x14); // this should be turning BIOS fan control off
set_speed(100);
printk(KERN_INFO "temp: %d", temp);
return 0;
}
static void __exit hello_2_exit(void)
{
printk(KERN_INFO "Fan control cleanup.\n");
}
module_init(hello_2_init_module);
module_exit(hello_2_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Jason Miesionczek");
MODULE_DESCRIPTION("Control fan speed for Acer 7551g Notebooks");