The 'mecha' values being logged might hold a clue - if I understand correctly these are the focus position values. My understanding is this would be the position of the focus stepper motor, not the subject distance.
Yes - that's been the assumption. What the actual numbers mean is unclear - they never go to zero for example and seem to be different with different camera models for the same SD setting.
The close values are consistently larger for the out of focus images - this is consistent with the 'adjustment' factor being applied by CHDK to compensate for the sensor to lens distance. The mecha values for infinity are consistently lower in the out of focus shots logged (if I'm reading the logs correctly). So the focus position used when CHDK selects infinity focus is closer than the one chosen by the camera.
Yea - that's pretty much where this is going so far. Although lower mecha value imply farther SD points. So the CHDK set_focus(65535) mecha value might actually be out past infinity (and thus out of focus).
Which implies that using something like set_focus(20000) for infinity (given the depth of field of the lens and the fact that is still past the hyperfocal limit) should give better results. I think fabri22 tried that with his camera without much success.
Also, very detailed testing that was done with a couple of misbehaving S100's that had the focus going bad once the value passed to set_focus() was more than a meter or two. And at that point, nothing was in focus ( near, mid, far objects all bad in the images). I bought an S100 to work on that problem, but Mr Murphy selected mine and it works prefectly with set_focus() and I could not reproduce the issue. I've pinged the original testers hoping for some new data.