UraniumDonut / nbfc-revive

NoteBook FanControl
Other
161 stars 24 forks source link

Support for multi fan laptops #45

Open Foosec opened 2 years ago

Foosec commented 2 years ago

Describe the solution you'd like The ability to add multiple fan control, or atleast treat them as a single one (But actually control both of them).

Additional context I made a fork of this a year or so ago, for my thinkpad P1 gen2 but had major stability issues so i decided to not pursue it further due to lack of time. (I did manage to spin both fans up tho)

A good resource is https://github.com/torvalds/linux/blob/9e723c5380c6e14fb91a8b6950563d040674afdb/drivers/platform/x86/thinkpad_acpi.c

if you implement a generalized solution for this this, many thanks as lenovos automatic fan control is absolute garbage.

jwhendy commented 2 years ago

Could you mock up what a config would look like? Or explain the fundamental difference you see between current nbfc behavior and what you propose?

For example: I have two physical fans, they are both defined in the same nbfc config via two corresponding pairs of read/write registers, and nbfc controls them at the same time. I could even have independent temp thresholds and speeds if I wanted (though I have them matched).

In reading your description and from my experience poking around with nbfc over the past ~month, it's not obvious what functionality is missing.

Foosec commented 2 years ago

If i remember correctly, it uses a seperate register as fan select. (I don't remember if its for speed control or only for tach reading) Seems to be a thinkpad thing. I'll have a look through the linux code to see what exactly was the problem.

Thanks

jwhendy commented 2 years ago

Interesting, I did expect to see a 2-fan config somewhere among the Thinkpad ones, but see none. Either none of the models with configs actually have a second fan, or there indeed is a barrier on implementing multiple fans?

Foosec commented 2 years ago

I checked and confirmed on my model (p1 gen2).

The 0x2f register sets the speed, but the 0x31 register selects which fan you are setting. As to how the solution might look, maybe make the "Register write configuration" per fan instead of global. Then you could do OnWrite and set the 0x31 register correctly before writing to the 0x2f per fan.

Foosec commented 2 years ago

I found my old fork and looks like i got it to work. Im still stability testing it for now, and then i will clean it up a bit and PR it. image

This was my idea for the interface at the time. Perhaps someone has a better idea?

Foosec commented 2 years ago

Just an update on this situation, i lost some time in between but anyway, the fan control works, however. I keep getting weird behaviour like my battery suddenly not being recognized, or just suddent shutdowns. No idea whats causing it, information on the EC regs is scarce, but from what i could gather from linux kernel and tpfancontrol, i should be doing everything fine.

The only thing that might happen is the value of 0x31 register changing from between when i read it and change that 1 bit of it, to when i write it. I tried putting in ec.AcquireLock and releaseLock in appropriate locations but to no avail. Information would be apriciated. thanks