Alex,
I added logic for the 5DM3's unique wide/tele AFMA support. The source is below. When DotTuning a zoom and specifying a wide vs tele value (instead of "both"), the user needs to make sure he sets his lens focal length to match where he'll be storing his wide/tele tune value before starting the DotTune, because otherwise the 5DM3's firmware will interpolate AF tune values between the wide and tele settings and this is not desirable when tunning. For example, when focusing (or evaluating focus via the VF confirmation), if AFMA is -5 for wide and -10 for tele on a 70-200mm lens, @ 70mm the 5DM3 firmware will use -5, @ 200mm it will use -10, and for any focal length in between it will use a scaled value between -5 and -10, per Canon's 5DM3 manual and my observations as well.
Here's the source. Again I'm new to ML so this might require some modification as you see fit. Thanks!
src/dryos.h:
/** AF microadjustment **/
int get_afma(int mode, int focalVal);
void set_afma(int value, int mode, int focalVal);
#define AFMA_MODE_AUTODETECT -1
#define AFMA_MODE_DISABLED 0
#define AFMA_MODE_ALL_LENSES 1
#define AFMA_MODE_PER_LENS 2
#define AFMA_FOCAL_VAL_BOTH 0
#define AFMA_FOCAL_VAL_WIDE 1
#define AFMA_FOCAL_VAL_TELE 2
platform/5D3 cfn.c:
// 5D3 only; other cameras have different offsets, buffer size etc
#define PROP_AFMA_CFN 0x80040027
static int8_t afma_buf[0x10];
#define AFMA_MODE afma_buf[0x0]
#define AFMA_PER_LENS_WIDE afma_buf[0x2]
#define AFMA_PER_LENS_TELE afma_buf[0x3]
#define AFMA_ALL_LENSES afma_buf[0x5]
int get_afma(int mode, int focalVal)
{
if (mode == AFMA_MODE_AUTODETECT) mode = AFMA_MODE;
if (mode == AFMA_MODE_PER_LENS)
// for AFMA_FOCAL_VAL_BOTH, return AFMA_PER_LENS_WIDE
return (focalVal <= AFMA_FOCAL_VAL_WIDE ? AFMA_PER_LENS_WIDE : AFMA_PER_LENS_TELE);
else if (mode == AFMA_MODE_ALL_LENSES)
return AFMA_ALL_LENSES;
return 0;
}
void set_afma(int value, int mode, int focalVal)
{
if (ml_shutdown_requested) return;
value = COERCE(value, -AFMA_MAX, AFMA_MAX);
if (mode == AFMA_MODE_AUTODETECT) mode = AFMA_MODE;
if (mode == AFMA_MODE_DISABLED) mode = AFMA_MODE_ALL_LENSES;
if (mode == AFMA_MODE_PER_LENS) {
if (focalVal == AFMA_FOCAL_VAL_BOTH)
AFMA_PER_LENS_WIDE = AFMA_PER_LENS_TELE = value;
else if (focalVal == AFMA_FOCAL_VAL_WIDE)
AFMA_PER_LENS_WIDE = value;
else if (focalVal == AFMA_FOCAL_VAL_TELE)
AFMA_PER_LENS_TELE = value;
else return; // bad arguments
}
else if (mode == AFMA_MODE_ALL_LENSES)
AFMA_ALL_LENSES = value;
else return; // bad arguments
AFMA_MODE = mode;
prop_request_change(PROP_AFMA_CFN, afma_buf, sizeof(afma_buf));
}
platform/5D2 cfn.c:
int get_afma(int mode, int focalVal /* not supported on 5D2 */)
{
if (mode == AFMA_MODE_AUTODETECT) mode = AFMA_MODE;
if (mode == AFMA_MODE_PER_LENS)
return AFMA_PER_LENS;
else if (mode == AFMA_MODE_ALL_LENSES)
return AFMA_ALL_LENSES;
return 0;
}
void set_afma(int value, int mode, int focalVal /* not supported on 5D2 */)
{
if (ml_shutdown_requested) return;
value = COERCE(value, -AFMA_MAX, AFMA_MAX);
if (mode == AFMA_MODE_AUTODETECT) mode = AFMA_MODE;
if (mode == AFMA_MODE_DISABLED) mode = AFMA_MODE_ALL_LENSES;
if (mode == AFMA_MODE_PER_LENS)
AFMA_PER_LENS = value;
else if (mode == AFMA_MODE_ALL_LENSES)
AFMA_ALL_LENSES = value;
else return; // bad arguments
AFMA_MODE = mode;
prop_request_change(PROP_AFMA_CFN, afma_buf, sizeof(afma_buf));
}
src/focus.c:
#ifdef FEATURE_AFMA_TUNING
CONFIG_INT( "focal_afma_value_select", focal_afma_value_select, AFMA_FOCAL_VAL_BOTH);
static void afma_print_status(int8_t* score, int range_expand_factor)
{
Changed all get_afma() and set_afma() calls in focus.c to pass "focal_afma_value_select" as final argument, which includes afma_print_status(), afma_auto_tune(), MENU_UPDATE_FUNC(afma_display), and MENU_SELECT_FUNC(afma_toggle)
{
.name = "AF microadjust",
.update = afma_display,
.select = afma_toggle,
#ifdef CONFIG_AFMA_EXTENDED
.help = "Adjust AFMA value manually. Range: -100...+100.",
#else
.help = "Adjust AFMA value manually. Range: -20...+20.",
#endif
.edit_mode = EM_MANY_VALUES,
},
#if defined(CONFIG_5D3)
{
.name = "Wide/Tele Select",
.priv = &focal_afma_value_select,
.max = 2,
.choices = (const char *[]) {"Both/Prime", "Wide(Zoom)", "Tele(Zoom)"},
.help = "Body supports two AFMA values for zoom lenses.",
},
#endif
MENU_EOL
},
},
};