negative voltages
Quoting Jean Delvare <[email protected]>:
Quoted 5 lines
The problem is, I couldn't find in the 2.4 w83781d driver, nor in libsensors, nor in sensors, where the min and max are swapped, although the values are swapped in sensors.conf and it *does* work correctly with this combination of driver and user-space stuff. Can anyone point me to the place where the swapping is done?
I must have been sleeping or something last time I took a look. Swaps are clearly documented in lib/chips.c for lm78, lm78-j, lm79, w83781d and as99127f (list #1 in ticket 800).
This begins to make sense to me now. Sticking to the min and max as defined inside the chips means that for chips in list #1 we'll have min
Quoted 1 line
max (but |min| < |max|), while for chips in list #2 we'll have min <
max. I guess that the decision to swap things was meant to have all chips look the same.
I still don't get why 2.6 drivers don't work correctly, since the swappings occur in libsensors and sensors.conf, not in the drivers themselves. I guess that maybe some more exceptions hard-coded into libsensors are required, will look into it. This probably means that we could keep the swapping logic the way it is now.
Still my (slightly less strong now) opinion is that having min > max for
negative voltages does make as much sense as the contrary, so I wouldn't be against a massive cleanup. However, I'm not sure I fully undertstand wether such a change would cause trouble to third-party apps using libsensors or parsing the output of sensors. The fact that limits order would become chip-dependant doesn't sound very well.
On the other hand, I dream of libsensors2 not containing any chip-dependant code either, so we might have to learn how to live in a limits-order-depend-on-chip world someday anyway.
Just some random thoughts about it all, add your owns if you wish :)
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Quoting Mark Studebaker <[email protected]>:
Quoted 3 lines
As you have said, the /sys or /proc values are raw values. So min < max.
If you don't do it that way, the alarms won't work.
Agreed.
Quoted 4 lines
So if (and only if) you have an inverting compute line in userspace, then you MUST flip the limits for userspace. Somewhere it has to be done, I think you'll agree. That's what was done in
lib/chips.cfor 2.4.
This is where I don't fully agree. I understand pretty well how things have been done and I agree that it works. I also admit that it keeps min < max for the user whatever the chip, which can be considered nice.
But this also introduce more chip-dependant code in the library. Remember that the sysfs interface was meant to be self explanatory. This should allow one to write a library with no chip-dependant code in it. All chip-dependant information would belong to sensors.conf.
You will object that this won't allow us to keep the "min < max" assertion true for all chips. I have a trick in mind to workaround the problem (if it is a problem, which I'm still not sure of, BTW). The library can test each formula and detect if it is inverting, providing the function is monotonic around the current value (simply test the sign of f(x+d)-f(x-d) where x is the current value and d a relatively small positive delta). Another possibility is to add a new syntax to the configuration as MMH proposed, but I would prefer to avoid it if possible.
Anyway, I'd still like to know if there are real problems having min > max for negative voltages of some chips (i.e. keep the min and max semantics in line with the chip internals even if there are inverting formulas). I don't really see the problem with sensors, as long as sensors.conf matches with that choice. But maybe it would cause third-party apps trouble?
We better think twice before breaking something that works, even if the change simplifies the (new) library.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
Hi all,
I've made the necessary fixes to libsensors. This is the way that requires the less changes and it doesn't break 2.4 drivers so I suggest we stick to it for now.
Tested to work with my AS99127F rev.1 (driver w83781d). More testers welcome.
That said and done, the question is still opened how we will handle the negative voltage limits in libsensors2. Since I believe we want a chip-independant library, which means that some chips would have min < max and some others would have the contrary, and userspace apps would have to cope with it. I don't really see major problems doing this.
Signature · 2 lines
Jean Delvare http://www.ensicaen.ismra.fr/~delvare/
I didn't understand what was going on either, until I saw your fix to lib/chips.c. Sorry I was no help.
You did it right.
As you have said, the /sys or /proc values are raw values. So min < max.
If you don't do it that way, the alarms won't work.
So if (and only if) you have an inverting compute line in userspace,
then you MUST flip the limits for userspace.
Somewhere it has to be done, I think you'll agree.
That's what was done in lib/chips.c for 2.4.
So for those sensors, rather than the /proc values being mapped to min/max/reading, they are mapped to max/min/reading. This was done by substituting VALUE(1) for VALUE(2), etc.
Chips that use external resistors for level shifting don't
need inverting compute lines and don't need anything swapped
Think about it. (simplification) If I add 6 volts externally to
my -5V signal, that doesn't change which is min and which is max.
But if I multiply the -5V signal externally by -1, then min and max must be swapped.
Since 2.6 used the names (in1_max -> in_max1), the lib/chips.c swapping that was implemented for 2.4 didn't happen any more.
Your change today fixes that.
All the chips referred to in Ticket #800 (both "classes") had bad compute lines in sensors.conf.eg at the time, for example:
set in5_min -12 * 0.95 set in5_max -12 * 1.05
which was clearly wrong.
But also, at the time, there was no swapping in libsensors. So as ticket 800 says, it was somewhat confusing at the time and it was a 2-part fix.
mds
Quoted 15 lines · Jean Delvare
Hi all,
I've made the necessary fixes to libsensors. This is the way that requires the less changes and it doesn't break 2.4 drivers so I suggest we stick to it for now.
Tested to work with my AS99127F rev.1 (driver w83781d). More testers welcome.
That said and done, the question is still opened how we will handle the negative voltage limits in libsensors2. Since I believe we want a chip-independant library, which means that some chips would have min < max and some others would have the contrary, and userspace apps would have to cope with it. I don't really see major problems doing this.