DoF values and other related items - page 3 - General Discussion and Assistance - CHDK Forum

DoF values and other related items

  • 50 Replies
  • 27570 Views
Re: DoF values and other related items
« Reply #20 on: 22 / November / 2009, 09:33:18 »
Advertisements
hopefully it should work


Yes it does, thanks.

I guess someone should correct the trunk version.

I'm working getting the signature files put togther for this.  By the looks of it, I may look at removing GetCurrentTargetDistance completely as the reference dumps don't have an equivalent and GetFocusLensSubjectDistance does the same anyways.

Re: DoF values and other related items
« Reply #21 on: 22 / November / 2009, 15:25:33 »
reyalp:  Here are my updated signature files for dumps 1 & 3 for GetFocusLensSubjectDistance and GetFocusLensSubjectDistanceFromLens.  I actually ended up leaving GetCurrentTargetDistance as it was already, so it points to the same entry point as GetFocusLensSubjectDistance for now.

*

Offline reyalp

  • ******
  • 14128
Re: DoF values and other related items
« Reply #22 on: 22 / November / 2009, 20:25:13 »
OK, let me see if I understand this correctly.

lens_get_focus_pos:
On vxworks, calls GetFocusLensSubjectDistance. On dryos calls a function which is named GetCurrentTargetDistance but is functionally equivalent to GetFocusLensSubjectDistance.
Sig update gives makes an alias for this on dryos so the wrapper can be generic. Actual behavior is not changed.

lens_get_focus_pos_from_lense:
On vxworks, calls GetFocusLensSubjectDistanceFromLens.
On dryos used to call GetCurrentTargetDistance, which is not a compatible value.
Patch adds the correct function, meaning this function can be generic
Bonus question: what's a lense ?
edit:
GetFocusLensSubjectDistanceFromLens existed in previous dryos ports, but referred to an eventproc function that printed the value rather than returning it.

lens_get_target_distance:
currently unused.
On vxworks it calls GetCurrentTargetDistance, which is not the same as GetFocusLensSubjectDistance (what's the difference ?)
On dryos, it calls the a function equivalent to vxworks GetFocusLensSubjectDistance
The patch keeps the existing behavior. These already used the same name on vx and dryos, so can be generic too. If the actual function needs to be corrected, the alias to GetFocusLensSubjectDistance can be removed.
« Last Edit: 22 / November / 2009, 20:50:28 by reyalp »
Don't forget what the H stands for.

Re: DoF values and other related items
« Reply #23 on: 22 / November / 2009, 22:43:05 »
OK, let me see if I understand this correctly.

lens_get_focus_pos:
On vxworks, calls GetFocusLensSubjectDistance. On dryos calls a function which is named GetCurrentTargetDistance but is functionally equivalent to GetFocusLensSubjectDistance.
Sig update gives makes an alias for this on dryos so the wrapper can be generic. Actual behavior is not changed.
Yes.

Quote
lens_get_focus_pos_from_lense:
On vxworks, calls GetFocusLensSubjectDistanceFromLens.
On dryos used to call GetCurrentTargetDistance, which is not a compatible value.
Patch adds the correct function, meaning this function can be generic
Yes, on DryOS, this function wasn't previously identified, so I suppose GetCurrentTargetDistance was substituted (which basically give a lens to focal plane distance of 0)

If the patch can find the function for all DryOS dumps, then it can be made generic. I did find it for all three reference dumps.


Quote
Bonus question: what's a lense ?
Yes I noticed that.  Just left as is for now.  But can correct for a diff patch...

Quote
edit:
GetFocusLensSubjectDistanceFromLens existed in previous dryos ports, but referred to an eventproc function that printed the value rather than returning it.
I'm not sure actually the function actually returned, I didn't check too deep.  This function does exist in VXWorks as well, it is actually what helped me find the real function entry points.


Quote
lens_get_target_distance:
currently unused.
On vxworks it calls GetCurrentTargetDistance, which is not the same as GetFocusLensSubjectDistance (what's the difference ?)
It's similar. 
All GetCurrentDistance does in VXWorks is call GetFocusLensSubjectDistance and do a left/right logical shift operation:
Code: [Select]
From A570 101A
FFE083E8: E52DE004 STM {LR} FD SP!, ; (STR LR, [SP, #-4]!)
FFE083EC: EB01A603 BL FFE71C00 (-----> GetFocusLensSubjectDistance )
FFE083F0: E1A00800 LSL R0, R0, #0x10
FFE083F4: E1A00820 LSR R0, R0, #0x10
FFE083F8: E49DF004 LDM {PC} FD SP!, ; (LDR PC, [SP], #4)

Quote
On dryos, it calls the a function equivalent to vxworks GetFocusLensSubjectDistance
The patch keeps the existing behavior. These already used the same name on vx and dryos, so can be generic too. If the actual function needs to be corrected, the alias to GetFocusLensSubjectDistance can be removed.
The sigs I submitted will keep the existing behavior as I have basically duplicated the entry point for both.
To be truly generic, the best option would be to use GetFocusLensSubjectDistance for both VXWorks and Dryos and drop GetCurrentTargetDistance (or rename GetFocusLensSubjectDistance to GetCurrentTargetDistance in VXWorks if we like the name).  There wouldn't be much work to do this and would mean largely cleaning out a lot of the current model-level wrappers.c for a unified function in the generic wrappers.c. (there are a few additional items in some of the model-level wrappers still, so they can't be cleaned out completely yet.)

*

Offline reyalp

  • ******
  • 14128
Re: DoF values and other related items
« Reply #24 on: 24 / November / 2009, 21:03:04 »
Another wrinkle. It appears that on many cameras, GetFocusLensSubjectDistanceFromLens is not referenced anywhere by the canon firmware. From a quick look, this appears to be cameras that don't have native MF.

Some examples are
a470
a2000
ixus80_sd1100

I can make test builds for any camera.

Before implementing this globally, we need to know if the function works correctly on these cameras. If it doesn't, we can change lens_get_focus_pos_from_lense based on CAM_HAS_MANUAL_FOCUS or something (although I note that a2000 doesn't set this correctly)
Don't forget what the H stands for.

Re: DoF values and other related items
« Reply #25 on: 25 / November / 2009, 09:22:50 »
Another wrinkle. It appears that on many cameras, GetFocusLensSubjectDistanceFromLens is not referenced anywhere by the canon firmware. From a quick look, this appears to be cameras that don't have native MF.

Some examples are
a470
a2000
ixus80_sd1100

I can make test builds for any camera.

Before implementing this globally, we need to know if the function works correctly on these cameras. If it doesn't, we can change lens_get_focus_pos_from_lense based on CAM_HAS_MANUAL_FOCUS or something (although I note that a2000 doesn't set this correctly)
I'm not sure what you mean.  Do you meant that the signatures can't be found?
The function is there, for example, in the SD1100[100c] the entry is FF92B824, for A470[102c] the entry is FFD03128.  Both of these functions are identical to the A720 reference dump.  There is only a couple minro differences with the SD980 reference and the SX10 (which I know does work).

Or are you referring to that the function is there but not used?  In which case it may either a) be functional, b)not work or return incorrect values.  Hopefully it would be a) but testing would need to be done on one of these camera models (which I don't have).

If the function is found and does work (or at least returns a 0 value), then it can be inplemented along with the other cams globally.
If it returns an error or an incorrect/unusable value, then a workaround would be needed.  If it is for only cameras without MF as you suspect then CAM_HAS_MANUAL_FOCUS can be used to toggle the behaviour (either default to GetFocusLensSubjectDistance: plane to lens distance = 0, or disable displaying DoF values relative to the front lens).

*

Offline reyalp

  • ******
  • 14128
Re: DoF values and other related items
« Reply #26 on: 25 / November / 2009, 21:21:28 »
Or are you referring to that the function is there but not used?  In which case it may either a) be functional, b)not work or return incorrect values.  Hopefully it would be a) but testing would need to be done on one of these camera models (which I don't have).
The function is there but does not appear to be used by the canon firmware. Because of that, I want to know if it works as expected.

FWIW, we can't make these functions entirely generic anyway. The older vxworks cameras (ixus40_sd300 ixus50_sd400 ixus700_sd500 s2is s3is) all have some extra code in the wrappers.

In addition to the ones I mentioned earlier, the following cameras have GetFocusLensSubjectDistanceFromLens but do not use it (and AFAIK all do not have MF).
ixus860_sd870 ixus870_sd880 ixus970_sd890

ixus950_sd960 appears not to have all the normal MF stuff (and doesn't have CAM_MANUAL_FOCUS defined), but does use the function.
ixus980_sd990 actually has MF, and the function is used similar to other MF cams.

I checked a couple of VxWorks ixus cameras (which I assume don't have MF), and they do reference this function.

Good news is the sigs seem to work as expected.
Don't forget what the H stands for.

Re: DoF values and other related items
« Reply #27 on: 25 / November / 2009, 22:54:12 »
Quote
FWIW, we can't make these functions entirely generic anyway. The older vxworks cameras (ixus40_sd300 ixus50_sd400 ixus700_sd500 s2is s3is) all have some extra code in the wrappers.
I see that, but the extra code isn't related to these functions from what I could see.  At least these 2 (or 3) functions could be removed up to the generic wrappers to remove the redundancy I would think.

Quote
In addition to the ones I mentioned earlier, the following cameras have GetFocusLensSubjectDistanceFromLens but do not use it (and AFAIK all do not have MF).
ixus860_sd870 ixus870_sd880 ixus970_sd890

ixus950_sd960 appears not to have all the normal MF stuff (and doesn't have CAM_MANUAL_FOCUS defined), but does use the function.
ixus980_sd990 actually has MF, and the function is used similar to other MF cams.

I checked a couple of VxWorks ixus cameras (which I assume don't have MF), and they do reference this function.

Good news is the sigs seem to work as expected.
That's good.  Does this mean that the functions were successfully found in all cameras?  Or have you been able to verify that yet.
I won't be able to test any of the cams, all I have access to at present are my S2, A570 and SX10.

*

Offline reyalp

  • ******
  • 14128
Re: DoF values and other related items
« Reply #28 on: 25 / November / 2009, 23:12:44 »
That's good.  Does this mean that the functions were successfully found in all cameras?  Or have you been able to verify that yet.
I verified them all by inspection, after a couple of iterations of tweaking the sigs*. GetCurrentTargetDistance/GetFocusLensSubjectDistance is not found correctly on sx200is, but it was already in stubs_entry_2.S

* There are some quirks in sig finding:
- For short functions like GetCurrentTargetDistance you tend to get a lot of alts/bad matches. In this case it is frequently better not to specify the length of the function. As long as the surrounding code doesn't change much (and it usually doesn't) you get a better match, even though half the code is from a totally different function.
- The "best match" algorithm is kind of messed up. If there are two sigs with different lengths, the one with more matches will be chosen as the "best match" even if it is a lower percentage. So you can have a 100% match for the shorter sig, and the longer one will be selected even though it's a bad match. But we can't just "fix" this because it would affect all the existing stubs. Edit: to make it even more confusing, the matches are only done against some instructions, so the specified length in the sig file does not reflect the number of instructions checked.
« Last Edit: 26 / November / 2009, 01:33:40 by reyalp »
Don't forget what the H stands for.

Re: DoF values and other related items
« Reply #29 on: 26 / November / 2009, 13:02:19 »


I verified them all by inspection, after a couple of iterations of tweaking the sigs*. GetCurrentTargetDistance/GetFocusLensSubjectDistance is not found correctly on sx200is, but it was already in stubs_entry_2.S

Really?  I had manually found this one before.  It is virtually identical to the 720 reference dump.
What changes did you make to the reference?  I just ran a build for the 100C build using the signature files I posted before and found them successfully:

NSTUB(GetCurrentTargetDistance, 0xff92f7e4)
NSTUB(GetFocusLensSubjectDistance, 0xff92f7e4)
NSTUB(GetFocusLensSubjectDistanceFromLens, 0xff92fbc0)

These are all the same functions I found manually.

However it does report 4 other locations (which have the same structure).  Not sure what these ones are for, but the one selected is the one referenced in GetFocusLensSubjectDistanceFromLens.
I suppose that this is where not limiting the signature length can help in differentiating the correct one.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal