Clevo fan control use NBFC (NoteBook FanControl) utility

Discussion in 'Sager and Clevo' started by habl, Dec 11, 2019.

  1. habl

    habl Newbie

    Reputations:
    5
    Messages:
    2
    Likes Received:
    3
    Trophy Points:
    6
    Hi all! On Clevo based laptops can control CPU, GPU1 and GPU2 fan from EC registers. It confirms Linux utility https://github.com/tuxedocomputers/tuxedo-fan-control and Windows utility https://github.com/duguzuyang/RLECViewer (I tested it on my Clevo P157SM - it fully works). There is also a working paid Windows utility https://code.obsidian-pc.com/clevo-software/fan-control/.

    There is free fan control utility for laptops NBFC (NoteBook FanControl) that control FAN from direct control EC registers https://github.com/hirschmann/nbfc

    On NBFC Wiki describes how can create profile for concrete laptop https://github.com/hirschmann/nbfc/wiki. To create a configuration, we need to know which registers in Clevo are responsible for the manual control of fans. We can see it in code https://github.com/tuxedocomputers/tuxedo-fan-control/blob/master/native/ec_access.cc.
    Code:
    #define EC_COMMAND_PORT         0x66
    #define EC_DATA_PORT            0x62
    
    static void SendCommand(int command)
    {
       int tt = 0;
        while((inb(EC_COMMAND_PORT) & 2))
        {
            tt++;
            if(tt>30000)
            {
                break;
            }
        }
    
        outb(command, EC_COMMAND_PORT);
    }
    
    static void WriteData(int data)
    {
        while((inb(EC_COMMAND_PORT) & 2));
    
        outb(data, EC_DATA_PORT);
    }
    
    Napi::Boolean SetFanDuty(const Napi::CallbackInfo& info)
    {
        EcInit();
        SendCommand(0x99); //in 0x66=102 port command 0x99=153
    
        switch(index)
        {
            case 1:
                WriteData(0x01); //in 0x62=98 port command 0x1=1
                break;
            case 2:
                WriteData(0x02);
                break;
            case 3:
                WriteData(0x03);
                break;
            default:
                return Napi::Boolean::New(env, false);
        }
    
        WriteData(fanDuty); //in 0x62 port fan speed
        return Napi::Boolean::New(env, true);
    }
    
    I analyzed this code and realized this.

    From this code it is clear that for manual control of the fan speed we need:
    1) send in 0x66 port command 0x99
    2) for the case of CPU FAN in 0x62 port send command 0x1
    3) then sent hex data FAN speed to 0x62 port

    It seems I made a mistake somewhere because in RW utility (Read Write everything) http://rweverything.phpnet.us/download.html this sequence does not work. But the code is working, because tuxedo-fan-control works on my laptop.

    To test our guess we need RW utility http://rweverything.phpnet.us/download.html First click on the EC at the top of the screen, then you can manually enter the values of EC registers.

    [​IMG]

    I changed registry 0x62 and 0x66, but data 0xCE dont changed.

    Please point me to my mistake in the code analysis and help me make a working algorithm for manually changing the fan speed
     
    Last edited: Dec 11, 2019
  2. Dr. AMK

    Dr. AMK Living with Hope

    Reputations:
    3,029
    Messages:
    1,950
    Likes Received:
    4,133
    Trophy Points:
    281
    Nice finding, but I have no idea if it's safe to play with those codes.
    Good luck.
     
    Vasudev likes this.
Loading...

Share This Page