Made a couple experiments on 5D2, too. Initial notes:
- black level depends on raw type (either 1024 or 1792; need to sit down to find it)
- pink preview still stubborn
- CONFIG_EDMAC_RAW_SLURP kinda works, but gives corrupted frames
- timing for raw_lv_vsync appears to be correct
- calling raw_lv_vsync from the same place where Canon code would call it (StartImagePass x1/x5 CrawAddr / KindOfCraw), did not help
- patching the SetEDmac call from the above routine appears to work:
static void raw_lv_setedmac_patch(uint32_t* regs, uint32_t* stack, uint32_t pc)
{
/* R0: EDMAC channel */
/* R1: output buffer */
/* R2: EDMAC info (geometry) */
/* R3: flags */
int width, height;
int ok = raw_lv_get_resolution(&width, &height);
if (ok)
{
if (redirected_raw_buffer)
{
/* optionally update output buffer */
regs[1] = redirected_raw_buffer;
}
/* update EDMAC image size */
int pitch = width * raw_info.bits_per_pixel / 8;
static struct edmac_info dst_edmac_info;
dst_edmac_info.xb = pitch;
dst_edmac_info.yb = height - 1;
regs[2] = (uint32_t) &dst_edmac_info;
/* we can override this here */
EngDrvOut(RAW_TYPE_REGISTER, lv_raw_type);
}
}
static void raw_init()
{
...
/* SetEDmac from StartImagePass_x1/x5 CrawAddr / KindOfCraw */
/* FIXME: why it fails when the hook is placed on the BL instruction?! */
patch_hook_function(0xFFA08B20, MEM(0xFFA08B20), raw_lv_setedmac_patch, "RAW LV x5");
patch_hook_function(0xFFA08008, MEM(0xFFA08008), raw_lv_setedmac_patch, "RAW LV x1");
}
Still need to figure out why our code called from the same place doesn't work well, but the patched one does.
Now, adtg_gui stuff. FPS timer A has a small quirk - one unit means 4 pixels on this camera, but one unit of C0F06088 means 2 pixels. So, the easiest experiment is:
- enable ADTG registers and (in the advanced tab) ENGIO registers
- go to x5 zoom, enable mlv_rec's grayscale preview
- override FPS timer A (C0F06008) from 0x2770277 to 0x2770377 (increase X by 0x100)
- this change lets you increase raw resolution register (C0F06088) by 0x200, i.e. from 0x46A04BA to 0x46A06BA
- this gives 3168 pixels horizontally in mlv_rec: (0x6BA - 0x36)*2 = 3336, minus 160px black bar = 3176, then 3168 is multiple of 32.
Next is adjusting CMOS registers for centering the image horizontally - reply #10. Will edit later.
Part 2. Let's try to get full width LiveView.
Target values: the ones from photo mode.
x1 x5 centered photo description
C0F06084: 0x10036 0x30036 0x10037 start row/column
C0F06088: 0x4F40432 0x46A04BA 0xEDD0B87 stop row/column (column: 1 unit = 2 pixels)
C0F06008: 0x23B023B 0x2770277 0x5DB05DB FPS timer A (1 unit = 4 pixels horizontally)
C0F06014: 0x6D5 0x4FF 0xEDC FPS timer B (1 unit = 1 pixel vertically)
CMOS[1] : 0xC00 0xE6A 0xC00 vertical start/stop
CMOS[2] : 0x40E 0x10E 0x8 horizontal pos & binning mode
CMOS[3] : 0x5 0x5 0x7 ???
CMOS[4] : 0x244 0x244 0x244 ???
CMOS[5] : 0x1 0x1 0xC05 ???
CMOS[2]:
xx-- -------- binning mode (00: read every column, 01: bin every 3 columns, 10 and 11: bin even more columns?!)
--xx xxxx---- horizontal position (0: start from left, 0x2a: thin stripe of valid data, 0x2b: no more valid data)
---- ----xxxx ??? (0x8 in photo mode, 0xE in LiveView, double highlights with 0x8 in LV)
For full width LiveView:
CMOS[2] = 0x00E
C0F06008: 0x27705DB (only the lowest half appears to matter on this camera)
C0F06084: 0x30037 (copied lowest half from photo mode)
C0F06088: 0x46A0B87 (copied lowest half from photo mode)
=> 5632x1074 in mlv_rec, 12.5 FPS.
Now, to increase height.
C0F06014: 0xEDC (copied from photo mode) => 4.2 FPS, clean image, so far so good.
C0F06088: 0x56A0B87 (increase Y by 0x100). Image breaks. Undo the change and look for other registers that might be related to timer B (close to 0x4FF)
First candidates: HEAD timers. Attempting to change them results in camera lockup. Back to the drawing board.
Some success starting from vanilla x5 and adjusting just the height:
- change C0F07150 from 0x49C to 0x59C and pray it won't lock up
- change C0F0713C from 0x476 to 0x576 and pray it won't lock up
- change C0F06088 from 0x46A04BA to 0x56A04BA => mlv_rec shows 2144x1330, but image is not good on the bottom half
- try to change CMOS[1] => E69 looks better, but image stutters; F6A looks even better, also with stutter, still some image data missing
- look for powersave timing registers: ADTG1[1047] from 0x550 to 0x650 appears to do the trick. maybe not needed? go to 1x and back to x5 to refresh.
=> 2144x1330 in mlv_rec with clean preview, still with some stutter with ML grayscale preview, but looks fine with Canon preview.
Let's try some more:
- C0F07150: 0x69C
- C0F0713C: 0x676
- C0F06088 to 0x66A04BA
=> 2144x1586 apparently working just fine.
- C0F07150: 0x79C
- C0F0713C: 0x776
- C0F06088 to 0x76A04BA
=> 2144x1842 apparently working just fine.
- CMOS[1]: 0xC00
- C0F07150: 0x79C
- C0F0713C: 0x776
- C0F06088 to 0x76A04BA
=> 2144x2354 apparently working just fine.
Battery empty, will continue tomorrow.