Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid handling of temp_table indexes in auto_mod() #4

Open
enyone opened this issue Nov 17, 2016 · 3 comments
Open

Invalid handling of temp_table indexes in auto_mod() #4

enyone opened this issue Nov 17, 2016 · 3 comments

Comments

@enyone
Copy link

enyone commented Nov 17, 2016

At line write_register(temp_table[i-1], FAN_SPEED_REG_RIGHT); shouldn't it be i+1 instead of i-1 ?

void auto_mod() {
    unsigned char temp = read_temp();
    if (temp < 0) {
        silence_mode();
        return;
    }
    for (unsigned int i = 0; i < sizeof(temp_table); i += 2) {
        if (temp < temp_table[i]) {
            write_register(temp_table[i-1], FAN_SPEED_REG_RIGHT);
            write_register(temp_table[i-1], FAN_SPEED_REG_LEFT);
            return;
        }
    }
}

As in first cycle in for loop i=0 so 0-1 would be -1. Is seems that it uses previous (in array) pwm value of temperature instead of next one (in array). Though it works as temp is newer 0 in that for loop if statement as it is checked before for loop in separate if.

unsigned char temp_table[] = {0, MIN_SPEED, 55, 0xE0, 60, 0xAF, 65, 0x7F, 70, 0x4B, 75, 0x33, 80, 0x1A, CRITICAL_TEMP, MAX_SPEED};

So temp 65 pwm value will be 0xAF instead of 0x7F.

@senior-sigan
Copy link
Owner

Hello @enyone.
Thanks for creating the issue, I really appreciate your diving into the code. Unfortunately, I can't test the changes you suggested, because I've already sold my Yoga netbook.
I will be grateful If you create pull request with this changes and test it on your notebook.
Thanks a lot.

@enyone
Copy link
Author

enyone commented Nov 18, 2016

See pull request #6 Fix: Invalid handling of temp_table indexes in auto_mod()

@enyone
Copy link
Author

enyone commented Nov 19, 2016

Also at my Lenovo you cannot set pwm value higher than 200 as it has no effect. 200 has the effect of lowest rpm you can achieve, so the scale is mostly 200-1 (0xC8-0x01). Can of course be firmware/bios version related thing.

$ sudo dmidecode
SMBIOS 2.7 present.
BIOS Information
        Vendor: LENOVO
        Version: 66CN54WW
        Release Date: 01/21/2013
        Address: 0xE0000
        Runtime Size: 128 kB
        ROM Size: 8192 kB
        BIOS Revision: 1.54
        Firmware Revision: 1.41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants