comparing with ../tragic-lantern-6d/ searching for changes diff -r 4b3129d5a739 -r 7a5ccc6c8531 Makefile.filerules --- a/Makefile.filerules Fri Sep 20 16:56:08 2013 +0300 +++ b/Makefile.filerules Sun Sep 22 11:41:50 2013 -0500 @@ -6,8 +6,26 @@ DEPS := $(COBJS:.o=.d) -include $(DEPS) +# compile some modules with -O3 for increased speed +# probably need to add aditional modules here now +#zebra.o: $(SRC_DIR)/zebra.c +# $(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<) +#menu.o: $(SRC_DIR)/menu.c +# $(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<) +#bmp.o: $(SRC_DIR)/bmp.c +# $(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<) +#chdk-gui_draw.o: $(SRC_DIR)/chdk-gui_draw.c +# $(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<) +#shoot.o: $(SRC_DIR)/shoot.c +# $(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<) +#focus.o: $(SRC_DIR)/focus.c +# $(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<) +#vram.o: $(SRC_DIR)/vram.c +# $(call build,CC,$(CC) $(CFLAGS) -O3 -c -o $@ $<) + + + all:: - # # # file type rules @@ -18,9 +36,9 @@ %.sym: % $(call build,SYMBOLS,$(READELF) -sW $< | $(GREP) GLOBAL | $(GREP) -E 'FUNC|OBJECT|ABS' | $(AWK) '{print $$2 " " $$8;}' | $(GREP) -v '^ ' | $(GREP) -v __config_ | $(GREP) -v -E ' _[a-zA-Z]' | sort > $@) %.o: $(PLATFORM_DIR)/%.c - $(call build,CC,$(CC) $(CFLAGS) -c -o $@ $<) + $(call build,CC,$(CC) $(CFLAGS) -c -o $@ $<) %.o: $(SRC_DIR)/%.c - $(call build,CC,$(CC) $(CFLAGS) -c -o $@ $<) + $(call build,CC,$(CC) $(CFLAGS) -c -o $@ $<) %.o: $(PICOC_PATH)/%.c $(call build,CC,$(CC) $(CFLAGS) -c -mthumb -fwhole-program -o $@ $<) %.i: %.c diff -r 4b3129d5a739 -r 7a5ccc6c8531 Makefile.inc --- a/Makefile.inc Fri Sep 20 16:56:08 2013 +0300 +++ b/Makefile.inc Sun Sep 22 11:41:50 2013 -0500 @@ -48,7 +48,6 @@ $(CP) $(SCRIPT_DIR)/*.c $(INSTALL_SCRIPTS_DIR)/ $(CP) $(SCRIPT_DIR)/*.py $(INSTALL_SCRIPTS_DIR)/ - copy-autoexec: autoexec.bin $(CP) autoexec.bin $(INSTALL_DIR) $(INSTALL_FINISH) diff -r 4b3129d5a739 -r 7a5ccc6c8531 Makefile.user.default --- a/Makefile.user.default Fri Sep 20 16:56:08 2013 +0300 +++ b/Makefile.user.default Sun Sep 22 11:41:50 2013 -0500 @@ -21,8 +21,9 @@ # GCC-related stuff # for yagarto or the official ARM toolchain use ARM_ABI=none-eabi otherwise use ARM_ABI=elf ARM_ABI=none-eabi -GCC_VERSION=-4.7.3 -ARM_PATH=~/gcc-arm-none-eabi-4_7-2012q4 +GCC_VERSION=-4.7.4 +#~ ARM_PATH=~/gcc-arm-none-eabi-4_7-2012q4 +ARM_PATH=~/gcc-arm-none-eabi-4_7-2013q2 ARM_BINPATH=$(ARM_PATH)/bin CROSS_COMPILE=$(ARM_BINPATH)/arm-$(ARM_ABI)- diff -r 4b3129d5a739 -r 7a5ccc6c8531 README.md --- a/README.md Fri Sep 20 16:56:08 2013 +0300 +++ b/README.md Sun Sep 22 11:41:50 2013 -0500 @@ -1,20 +1,77 @@ -Magic Lantern -============= +----------6D/EOSM/50D Development Builds -Magic Lantern (ML) is a software enhancement that offers increased -functionality to the excellent Canon DSLR cameras. - -It's an open framework, licensed under GPL, for developing extensions to the -official firmware. +* Named Bracketing +* Bit Rate Hacks +* Most Features Working +* Asif Patched to Record +* Bottom Bar Hidden +* Full WAV recording internal/external sans Canon interferance +* LV_REC + DNG Raw pics +* Raw_Rec + Bolt_Rec +* Raw Histogram/Zebras/Spot +Known Bugs! -Magic Lantern is not a *hack*, or a modified firmware, **it is an -independent program that runs alongside Canon's own software**. -Each time you start your camera, Magic Lantern is loaded from your memory -card. Our only modification was to enable the ability to run software -from the memory card. +* Sometimes encoder doesn't write at start, camera should reboot. + Happens less now since BR active while you're in the menu. +* Headphones not working yet +* FPS override can heat sensor and has sprinkle or vertical defects. + Adjust timer B until it does not. If you find good timer values + please post them to the thread. +* New Builds are for 113. Downgrade to set the bootflag until a fir is available. + Then Upgrade to 113 and bootflag will remain. -ML is being developed by photo and video enthusiasts, adding -functionality such as: HDR images and video, timelapse, motion -detection, focus assist tools, manual audio controls much more. +6D Development Thread: -For more details on Magic Lantern please see http://www.magiclantern.fm/ +http://www.magiclantern.fm/forum/index.php?topic=3904.0 + +IVAPARAMS and what they mean: + +http://www.magiclantern.fm/forum/index.php?topic=4124.0 + +6D 112 If you Need to Downgrade +http://www.filedropper.com/6d112 + +Legend: + +[113] 6D 113 Binary +[EOSM] Eos M Binary +[50D] 50D Binary + + + + *************************************************** + * * + * THIS IS DANGEROUS AND MIGHT DAMAGE YOUR CAMERA. * + * NO WARRANTIES. NO GUARANTEES. DO NOT TAUNT. * + * * + *************************************************** + +If you are not comfortable with this, stop reading and delete the +software before you are tempted to try running it on your camera. + +Please read the user guide carefully before installing this software. + +To repeat this important point: + + *************************************************** + * * + * THIS IS DANGEROUS AND MIGHT DAMAGE YOUR CAMERA. * + * IF IT BREAKS, YOU GET TO KEEP BOTH PIECES. * + * * + *************************************************** + +IMPORTANT NOTES + +* If you have a bootable CF/SD card and have the DISKBOOT flag + set in the camera (which the installer does), and you do not + have an AUTOEXEC.BIN file on the card the camera WILL NOT BOOT. + It will hang and not wake up until the battery is removed. + +* If you encounter a "locked up" camera, quickly remove the battery. + Otherwise the ARM might be in a tight-loop and get very hot, very quickly. + Your battery will run down and your LCD might show some discoloration. + +* When in doubt, remove the battery and reboot. + +* And, remember that this software can damage or destroy your camera. + diff -r 4b3129d5a739 -r 7a5ccc6c8531 Tragic Lantern 6D.geany --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tragic Lantern 6D.geany Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,230 @@ + +[indentation] +indent_width=4 +indent_type=1 +indent_hard_tab_width=8 +detect_indent=false +detect_indent_width=false +indent_mode=2 + +[project] +name=Tragic Lantern 6D +base_path=/home/user/magic/tragic-lantern-6d +description= +file_patterns= + +[long line marker] +long_line_behaviour=1 +long_line_column=72 + +[files] +current_page=1 +FILE_NAME_0=233152;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/shoot.c;0;4 +FILE_NAME_1=28620;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/debug.c;0;4 +FILE_NAME_2=3158;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/Makefile.inc;0;4 +FILE_NAME_3=2444;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/Makefile.user.default;0;4 +FILE_NAME_4=360;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/Makefile.user;0;4 +FILE_NAME_5=985;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/README;0;4 +FILE_NAME_6=157320;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/menu.c;0;4 +FILE_NAME_7=18;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/exmem.c;0;4 +FILE_NAME_8=643;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/memcheck.c;0;4 +FILE_NAME_9=24788;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/flexinfo.c;0;4 +FILE_NAME_10=816;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/dialog_test.c;0;4 +FILE_NAME_11=18;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/beep.c;0;4 +FILE_NAME_12=312;None;0;16;1;1;0;/home/user/magic/debughelp;0;4 +FILE_NAME_13=239;None;0;16;1;1;0;/home/user/tl20notes.txt;0;4 +FILE_NAME_14=27;None;0;16;1;1;0;/home/user/30minlimit.txt;0;4 +FILE_NAME_15=0;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/config-defines.h;0;4 +FILE_NAME_16=13402;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/tasks.c;0;4 +FILE_NAME_17=2425;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/video_hacks.c;0;4 +FILE_NAME_18=21473;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/bitrate-6d.c;0;4 +FILE_NAME_19=588;None;0;16;1;1;0;/home/user/sizing.txt;0;4 +FILE_NAME_20=6691;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/state-object.c;0;4 +FILE_NAME_21=166666;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/zebra.c;0;4 +FILE_NAME_22=9;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/menu.h;0;4 +FILE_NAME_23=30710;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/movtweaks.c;0;4 +FILE_NAME_24=4745;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/lv_rec/lv_rec.c;0;4 +FILE_NAME_25=20584;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/property.h;0;4 +FILE_NAME_26=4753;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/strobo.c;0;4 +FILE_NAME_27=4681;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/strobo.h;0;4 +FILE_NAME_28=35723;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/lens.c;0;4 +FILE_NAME_29=998;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/reboot.c;0;4 +FILE_NAME_30=5769;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/consts.h;0;4 +FILE_NAME_31=5780;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/stubs.S;0;4 +FILE_NAME_32=3399;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/stubs.S;0;4 +FILE_NAME_33=2028;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/features.h;0;4 +FILE_NAME_34=1547;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/features.h;0;4 +FILE_NAME_35=4254;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/consts.h;0;4 +FILE_NAME_36=1187;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/internals.h;0;4 +FILE_NAME_37=8294;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/audio-ng.c;0;4 +FILE_NAME_38=26339;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/audio-common.c;0;4 +FILE_NAME_39=23662;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/audio.h;0;4 +FILE_NAME_40=61;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/Makefile;0;4 +FILE_NAME_41=1651;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/gui-common.c;0;4 +FILE_NAME_42=939;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/all_features.h;0;4 +FILE_NAME_43=4971;C;0;16;1;1;0;/home/user/magic/tragic-lantern/platform/600D.102/consts.h;0;4 +FILE_NAME_44=11558;None;0;16;1;1;0;/home/user/magic/tragic-lantern/platform/600D.102/stubs.S;0;4 +FILE_NAME_45=551;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D3.113/consts.h;0;4 +FILE_NAME_46=4;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/raw.h;0;4 +FILE_NAME_47=626;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/vsync-lite.c;0;4 +FILE_NAME_48=88;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D3.113/Makefile;0;4 +FILE_NAME_49=8912;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D3.113/stubs.S;0;4 +FILE_NAME_50=6439;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/bitrate-5d3.c;0;4 +FILE_NAME_51=37351;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/module.c;0;4 +FILE_NAME_52=14547;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/module.h;0;4 +FILE_NAME_53=4247;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/internals.h;0;4 +FILE_NAME_54=331;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/cfn.c;0;4 +FILE_NAME_55=836;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/bitrate.c;0;4 +FILE_NAME_56=31158;C;0;16;1;1;0;/home/user/magic/tragic-lantern/src/bitrate-600D.c;0;4 +FILE_NAME_57=10468;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/property.c;0;4 +FILE_NAME_58=18088;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/raw.c;0;4 +FILE_NAME_59=927;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/fw-signature.h;0;4 +FILE_NAME_60=9;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/reboot-all.c;0;4 +FILE_NAME_61=13958;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/lens.h;0;4 +FILE_NAME_62=97970;C;0;16;1;1;0;/home/user/magic/tragic-lantern/src/debug.c;0;4 +FILE_NAME_63=101689;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/tweaks.c;0;4 +FILE_NAME_64=36748;C;0;16;1;1;0;/home/user/magic/tragic-lantern-2.0/src/raw.c;0;4 +FILE_NAME_65=23766;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/chdk-dng.c;0;4 +FILE_NAME_66=698;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/tp-spy.c;0;4 +FILE_NAME_67=8992;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/console.c;0;4 +FILE_NAME_68=24870;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/audio-lapis.c;0;4 +FILE_NAME_69=9570;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/afma.c;0;4 +FILE_NAME_70=250;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/afma.h;0;4 +FILE_NAME_71=94;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/console.h;0;4 +FILE_NAME_72=17172;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/dryos.h;0;4 +FILE_NAME_73=4736;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D3.113/internals.h;0;4 +FILE_NAME_74=25698;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/focus.c;0;4 +FILE_NAME_75=541;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/asm.c;0;4 +FILE_NAME_76=0;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/edmac.c;0;4 +FILE_NAME_77=0;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/lv_rec/raw2dng.c;0;4 +FILE_NAME_78=9273;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/edmac-memcpy.c;0;4 +FILE_NAME_79=1037;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/raw_rec/Makefile;0;4 +FILE_NAME_80=729;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D3.113/features.h;0;4 +FILE_NAME_81=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/Makefile.filerules;0;4 +FILE_NAME_82=18808;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/audio-ak.c;0;4 +FILE_NAME_83=961;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/gui.h;0;4 +FILE_NAME_84=39;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/gui-common.h;0;4 +FILE_NAME_85=1721;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/gui.c;0;4 +FILE_NAME_86=16947;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/file_man/file_man.c;0;4 +FILE_NAME_87=11029;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/stubs.S;0;4 +FILE_NAME_88=1935;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/gui.h;0;4 +FILE_NAME_89=52;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/zebra.h;0;4 +FILE_NAME_90=1949;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/fps-engio.c;0;4 +FILE_NAME_91=78434;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/raw_rec/raw_rec.c;0;4 +FILE_NAME_92=715;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/features.h;0;4 +FILE_NAME_93=28;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/Makefile;0;4 +FILE_NAME_94=252;C;0;16;1;1;0;/home/user/magic/tragic-lantern/platform/600D.102/cfn.c;0;4 +FILE_NAME_95=1924;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/cfn.c;0;4 +FILE_NAME_96=797;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/consts.h;0;4 +FILE_NAME_97=10167;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/consts.h;0;4 +FILE_NAME_98=4172;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/internals.h;0;4 +FILE_NAME_99=4022;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/internals.h;0;4 +FILE_NAME_100=4371;C;0;16;1;1;0;/home/user/magic/tragic-lantern/src/boot-hack.c;0;4 +FILE_NAME_101=1804;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D2.212/internals.h;0;4 +FILE_NAME_102=198;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/features.h;0;4 +FILE_NAME_103=822;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D2.212/consts.h;0;4 +FILE_NAME_104=5296;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/stubs.S;0;4 +FILE_NAME_105=47949;Diff;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/contrib/patches/5D2.211-50D.108-600D.101.patch;0;4 +FILE_NAME_106=3201;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/gui.c;0;4 +FILE_NAME_107=1390;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/gui.h;0;4 +FILE_NAME_108=4768;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/tskmon.c;0;4 +FILE_NAME_109=2932;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/propvalues.c;0;4 +FILE_NAME_110=75;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/Makefile.platform.default;0;4 +FILE_NAME_111=133;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/Makefile.setup.default;0;4 +FILE_NAME_112=255;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/Makefile.platform.default;0;4 +FILE_NAME_113=2529;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/Makefile.src;0;4 +FILE_NAME_114=460;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/Makefile.platform.default;0;4 +FILE_NAME_115=114;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/Makefile.setup.default;0;4 +FILE_NAME_116=94;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/Makefile.setup.default;0;4 +FILE_NAME_117=199;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/Makefile.platform.default;0;4 +FILE_NAME_118=184;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/Makefile.setup.default;0;4 +FILE_NAME_119=1800;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/bolt_rec/bolt_rec.c;0;4 +FILE_NAME_120=1773;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/Makefile.modules;0;4 +FILE_NAME_121=728;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/Makefile;0;4 +FILE_NAME_122=139;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/Makefile.modules.default;0;4 +FILE_NAME_123=2287;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/dm-spy.c;0;4 +FILE_NAME_124=262;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/hdr.c;0;4 +FILE_NAME_125=18153;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/lv-img-engio.c;0;4 +FILE_NAME_126=297;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/600D.102/misc.c;0;4 +FILE_NAME_127=2141;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/adtg_log/adtg_log.c;0;4 +FILE_NAME_128=14560;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/trace/trace.c;0;4 +FILE_NAME_129=3684;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/trace/trace.h;0;4 +FILE_NAME_130=43445;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/gdb.c;0;4 +FILE_NAME_131=2479;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/gdb.h;0;4 +FILE_NAME_132=17746;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/vram.c;0;4 +FILE_NAME_133=2876;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/Makefile.setup;0;4 +FILE_NAME_134=3052;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/autoexpo/autoexpo.c;0;4 +FILE_NAME_135=5127;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.202/stubs.S;0;4 +FILE_NAME_136=6449;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.202/consts.h;0;4 +FILE_NAME_137=387;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/Makefile.platform.map;0;4 +FILE_NAME_138=2213;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.202/features.h;0;4 +FILE_NAME_139=254;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.202/Makefile.platform.default;0;4 +FILE_NAME_140=4233;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.202/internals.h;0;4 +FILE_NAME_141=178;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/version.c;0;4 +FILE_NAME_142=1086;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/version.h;0;4 +FILE_NAME_143=21733;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/installer.c;0;4 +FILE_NAME_144=1;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/bootflags.c;0;4 +FILE_NAME_145=0;C;0;16;1;1;0;/home/user/magic/tragic-lantern-2.0/src/video_hacks2.c;0;4 +FILE_NAME_146=2527;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/video_hacksU.c;0;4 +FILE_NAME_147=188;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.202/Makefile.setup.default;0;4 +FILE_NAME_148=6850;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/dual_iso/dual_iso.c;0;4 +FILE_NAME_149=7526;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/40D.111/init.c;0;4 +FILE_NAME_150=1022;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/40D.111/stubs.S;0;4 +FILE_NAME_151=26303;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/boot-hack.c;0;4 +FILE_NAME_152=7229;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/script/script.c;0;4 +FILE_NAME_153=14971;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/arkanoid/arkanoid.c;0;4 +FILE_NAME_154=1364;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/bmp.c;0;4 +FILE_NAME_155=479;C;0;16;1;1;0;/home/user/magic/tragic-lantern/platform/600D.102/misc.c;0;4 +FILE_NAME_156=331;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/misc.c;0;4 +FILE_NAME_157=212;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.106/misc.c;0;4 +FILE_NAME_158=276;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/EOSM.202/misc.c;0;4 +FILE_NAME_159=0;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/include/platform/state-object.h;0;4 +FILE_NAME_160=186;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/50D.109/include/platform/state-object.h;0;4 +FILE_NAME_161=3928;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/internals.h;0;4 +FILE_NAME_162=53;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D_MASTER.203/internals.h;0;4 +FILE_NAME_163=10289;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/ml_rpc.c;0;4 +FILE_NAME_164=377;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D_MASTER.203/consts.h;0;4 +FILE_NAME_165=10362;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D_MASTER.203/master_boot.c;0;4 +FILE_NAME_166=1304;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D_MASTER.203/stubs.S;0;4 +FILE_NAME_167=5544;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/stubs.S;0;4 +FILE_NAME_168=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D_MASTER.203/Makefile;0;4 +FILE_NAME_169=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D_MASTER.203/Makefile.platform.default;0;4 +FILE_NAME_170=1412;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/consts.h;0;4 +FILE_NAME_171=57;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/6D.113/Makefile;0;4 +FILE_NAME_172=35;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/installer/6D.113/Makefile;0;4 +FILE_NAME_173=489;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/installer/Makefile;0;4 +FILE_NAME_174=958;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/features.h;0;4 +FILE_NAME_175=2519;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/dual_iso/cr2hdr.c;0;4 +FILE_NAME_176=99499;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/mlv_rec/mlv_rec.c;0;4 +FILE_NAME_177=4762;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/menuhelp.c;0;4 +FILE_NAME_178=3719;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/650D.104/consts.h;0;4 +FILE_NAME_179=0;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/liveview.c;0;4 +FILE_NAME_180=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/650D.104/Makefile.platform.default;0;4 +FILE_NAME_181=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/650D.104/Makefile.setup.default;0;4 +FILE_NAME_182=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/Makefile.platform.default;0;4 +FILE_NAME_183=238;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/Makefile.setup.default;0;4 +FILE_NAME_184=84;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/include/platform/state-object.h;0;4 +FILE_NAME_185=393;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D_MASTER.203/Makefile.setup.default;0;4 +FILE_NAME_186=850;Markdown;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/README.md;0;4 +FILE_NAME_187=5227;None;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D2.212/stubs.S;0;4 +FILE_NAME_188=3181;Python;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/checkdep.py;0;4 +FILE_NAME_189=125;reStructuredText;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/bolt_rec/README.rst;0;4 +FILE_NAME_190=2216;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D2.212/gui.c;0;4 +FILE_NAME_191=1849;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/gui.c;0;4 +FILE_NAME_192=1131;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/7D.203/gui.h;0;4 +FILE_NAME_193=382;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/platform/5D2.212/features.h;0;4 +FILE_NAME_194=287;C;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/src/beep.h;0;4 +FILE_NAME_195=260;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/mlv_rec/Makefile;0;4 +FILE_NAME_196=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/file_man/Makefile;0;4 +FILE_NAME_197=0;Make;0;16;1;1;0;/home/user/magic/tragic-lantern-6d/modules/dual_iso/Makefile;0;4 + +[VTE] +last_dir=/home/user + +[build-menu] +NF_00_LB=_Make +NF_00_CM=make 6D +NF_00_WD=/home/user/magic/tragic-lantern-6d +NF_01_LB=Make Custom _Target +NF_01_CM=make %1 +NF_01_WD=/home/user/magic/tragic-lantern-6d diff -r 4b3129d5a739 -r 7a5ccc6c8531 contrib/qemu/hw/eos.c --- a/contrib/qemu/hw/eos.c Fri Sep 20 16:56:08 2013 +0300 +++ b/contrib/qemu/hw/eos.c Sun Sep 22 11:41:50 2013 -0500 @@ -1,3 +1,1637 @@ +<<<<<<< local + +#include "hw/hw.h" +#include "hw/loader.h" +#include "sysemu/sysemu.h" +#include "hw/devices.h" +#include "hw/boards.h" +#include "exec/address-spaces.h" +#include "hw/sysbus.h" +#include "qemu/thread.h" +#include "eos.h" + +EOSRegionHandler eos_handlers[] = +{ + { "RAM Trace", 0x00000000, 0x10000000, eos_handle_ram, 0 }, + { "FlashControl", 0xC0000000, 0xC0001FFF, eos_handle_flashctrl, 0 }, + { "ROM0", 0xF8000000, 0xFFFFFFFF, eos_handle_rom, 0 }, + { "ROM1", 0xF0000000, 0xF7FFFFFF, eos_handle_rom, 1 }, + { "Interrupt", 0xC0201000, 0xC0201FFF, eos_handle_intengine, 0 }, + { "Timers", 0xC0210000, 0xC0210FFF, eos_handle_timers, 0 }, + { "RTC??", 0xC0242014, 0xC0242014, eos_handle_unk, 0 }, + { "GPIO", 0xC0220000, 0xC022FFFF, eos_handle_gpio, 0 }, + { "Basic1", 0xC0400000, 0xC0400FFF, eos_handle_basic, 1 }, + { "Basic2", 0xC022F000, 0xC022FFFF, eos_handle_basic, 2 }, + { "SDIO", 0xC0C10000, 0xC0C10FFF, eos_handle_sdio, 0 }, + { "TIO", 0xC0800000, 0xC08000FF, eos_handle_tio, 0 }, + { "SIO0", 0xC0820000, 0xC08200FF, eos_handle_sio, 0 }, + { "SIO1", 0xC0820100, 0xC08201FF, eos_handle_sio, 1 }, + { "SIO2", 0xC0820200, 0xC08202FF, eos_handle_sio, 2 }, + { "SIO3", 0xC0820300, 0xC08203FF, eos_handle_sio, 3 }, + { "DMA1", 0xC0A10000, 0xC0A100FF, eos_handle_dma, 1 }, + { "DMA2", 0xC0A20000, 0xC0A200FF, eos_handle_dma, 2 }, + { "DMA3", 0xC0A30000, 0xC0A300FF, eos_handle_dma, 3 }, + { "DMA4", 0xC0A40000, 0xC0A400FF, eos_handle_dma, 4 }, + { "CARTRIDGE", 0xC0F24000, 0xC0F24FFF, eos_handle_cartridge, 0 }, +}; + +/* used to dump bmp vram */ +static int R[] = {254, 234, 0, 0, 163, 31, 0, 1, 234, 0, 185, 27, 200, 0, 201, 209, 232, 216, 0, 231, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 231, 9, 18, 27, 36, 41, 46, 50, 55, 59, 64, 69, 73, 82, 92, 101, 109, 117, 119, 124, 129, 133, 138, 142, 147, 152, 156, 161, 165, 170, 175, 179, 184, 188, 193, 198, 202, 207, 211, 216, 221, 225, 229, 220, 206, 193, 177, 162, 160, 156, 150, 140, 132, 125, 119, 106, 92, 76, 62, 49, 36, 22, 108, 101, 95, 89, 81, 72, 64, 55, 49, 42, 39, 233, 199, 192, 147, 102, 57, 16, 8, 6, 5, 6, 6, 3, 6, 3, 6, 4, 4, 2, 2, 1, 51, 48, 41, 39, 35, 31, 26, 26, 23, 18, 16, 14, 11, 221, 206, 196, 185, 173, 172, 163, 155, 146, 140, 133, 121, 108, 93, 80, 72, 60, 44, 30, 113, 108, 102, 94, 87, 78, 67, 56, 46, 37, 28, 233, 230, 222, 211, 198, 188, 174, 174, 168, 164, 152, 141, 130, 121, 109, 93, 80, 71, 62, 46, 28, 115, 106, 97, 83, 73, 62, 52, 45, 37, 24, 12, 232, 231, 192, 149, 102, 53, 8, 0, 0, 23, 24, 24, 24, 90, 72, 0, 24, 0, 0, 1, 0, 26, 23, 21, 20, 18, 17, 13, 10, 7, 4, 1, 1, 1, 25, 29, 29, 33, 35, 38, 40, 42, 43, 43, 45, 45, 54, 65, 79, 90}; +static int G[] = {254, 235, 0, 0, 56, 187, 153, 172, 0, 66, 186, 34, 0, 0, 0, 191, 0, 94, 62, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 18, 27, 36, 41, 46, 50, 55, 59, 64, 69, 73, 82, 92, 101, 110, 117, 119, 124, 129, 133, 138, 142, 147, 152, 156, 161, 165, 170, 175, 178, 184, 188, 192, 198, 202, 206, 210, 216, 221, 225, 230, 193, 148, 101, 53, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 34, 31, 29, 26, 25, 20, 17, 17, 13, 12, 1, 0, 212, 186, 164, 139, 117, 111, 107, 102, 101, 94, 87, 81, 74, 66, 60, 52, 40, 29, 20, 97, 90, 82, 74, 67, 60, 52, 47, 42, 36, 33, 220, 179, 214, 193, 172, 151, 128, 127, 119, 114, 108, 103, 99, 90, 79, 69, 59, 55, 45, 33, 24, 93, 90, 86, 80, 72, 64, 56, 47, 40, 32, 24, 230, 184, 206, 175, 141, 108, 78, 73, 71, 69, 64, 61, 55, 51, 46, 39, 34, 29, 26, 20, 11, 71, 64, 59, 50, 46, 39, 33, 28, 22, 15, 9, 140, 109, 210, 190, 165, 139, 118, 113, 110, 104, 25, 24, 24, 25, 67, 31, 24, 25, 37, 29, 23, 75, 70, 66, 60, 51, 46, 39, 31, 24, 14, 4, 222, 179, 29, 33, 35, 39, 43, 46, 48, 51, 52, 56, 57, 57, 67, 81, 95, 110}; +static int B[] = {255, 235, 0, 0, 0, 216, 0, 1, 1, 211, 139, 126, 0, 168, 154, 0, 231, 76, 75, 0, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 232, 9, 18, 27, 36, 41, 46, 50, 55, 59, 64, 69, 73, 82, 92, 101, 109, 117, 119, 124, 129, 133, 138, 142, 147, 152, 156, 161, 165, 170, 174, 178, 184, 188, 193, 198, 202, 207, 211, 216, 221, 224, 229, 195, 150, 102, 54, 10, 0, 1, 2, 1, 0, 1, 1, 0, 0, 2, 1, 1, 0, 2, 39, 34, 32, 29, 27, 25, 22, 18, 18, 15, 14, 1, 0, 227, 220, 212, 208, 202, 201, 189, 186, 181, 167, 155, 145, 132, 120, 107, 94, 74, 54, 38, 136, 126, 115, 107, 95, 83, 74, 64, 57, 52, 46, 232, 232, 193, 147, 100, 52, 6, 2, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 2, 37, 37, 35, 33, 31, 27, 23, 20, 18, 12, 10, 0, 0, 193, 148, 100, 53, 7, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 40, 35, 33, 27, 27, 23, 18, 15, 14, 10, 5, 0, 0, 192, 149, 102, 53, 8, 1, 0, 1, 151, 152, 151, 150, 85, 92, 152, 152, 1, 0, 0, 27, 24, 23, 21, 18, 16, 12, 11, 9, 7, 3, 1, 0, 38, 44, 46, 51, 56, 59, 64, 66, 69, 72, 73, 73, 86, 106, 126, 143}; + +static void eos_dump_vram(uint32_t address) +{ + FILE* f = fopen("vram.txt", "w"); + fprintf(f, "# ImageMagick pixel enumeration: 720,480,255,rgb\n"); + + int i,j; + for (i = 0; i < 480; i++) + { + for (j = 0; j < 720; j++) + { + uint8_t* b = qemu_get_ram_ptr(address); + int c = b[BM(j,i)]; + fprintf(f, "%d,%d: (%d,%d,%d)\n", j, i, R[c], G[c], B[c]); + } + } + fclose(f); +} + +/* io range access */ +static uint64_t eos_io_read(void *opaque, hwaddr addr, uint32_t size) +{ + addr += IO_MEM_START; + + uint32_t type = MODE_READ; + + switch(size) + { + case 1: + type |= WIDTH_BYTE; + break; + case 2: + type |= WIDTH_HALF; + break; + case 4: + type |= WIDTH_WORD; + break; + } + + return eos_handler ( opaque, addr, type, 0 ); +} + +static void eos_io_write(void *opaque, hwaddr addr, uint64_t val, uint32_t size) +{ + addr += IO_MEM_START; + + switch (addr) + { + case REG_PRINT_CHAR: + printf("%c", (uint8_t)val); + return; + + case REG_PRINT_NUM: + printf("%x (%d)\n", (uint32_t)val, (uint32_t)val); + return; + + case REG_DUMP_VRAM: + eos_dump_vram(val); + return; + + case REG_SHUTDOWN: + printf("Goodbye!\n"); + qemu_system_shutdown_request(); + return; + } + + uint32_t type = MODE_WRITE; + + switch(size) + { + case 1: + type |= WIDTH_BYTE; + break; + case 2: + type |= WIDTH_HALF; + break; + case 4: + type |= WIDTH_WORD; + break; + } + + eos_handler ( opaque, addr, type, val ); +} + + +static void eos_load_image(EOSState *s, const char* file, uint32_t addr) +{ + int size = get_image_size(file); + if (size < 0) + { + fprintf(stderr, "%s: file not found '%s'\n", __FUNCTION__, file); + abort(); + } + + fprintf(stderr, "[EOS] loading '%s' to 0x%08X-0x%08X\n", file, addr, size + addr - 1); + + uint8_t* buf = malloc(size); + if (!buf) + { + fprintf(stderr, "%s: malloc error loading '%s'\n", __FUNCTION__, file); + abort(); + } + + if (load_image(file, buf) != size) + { + fprintf(stderr, "%s: error loading '%s'\n", __FUNCTION__, file); + abort(); + } + + cpu_physical_memory_write_rom(addr, buf, size); + + free(buf); +} + +static const MemoryRegionOps iomem_ops = { + .read = eos_io_read, + .write = eos_io_write, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + +static void *eos_interrupt_thread(void *parm) +{ + EOSState *s = (EOSState *)parm; + + while (1) + { + uint32_t pos; + + usleep(100); + + /* go through all interrupts and check if they are pending/scheduled */ + for(pos = 0; pos < INT_ENTRIES; pos++) + { + /* it is pending, so trigger int and set to 0 */ + if(s->irq_schedule[pos] == 1) + { + /* wait, its not enabled. keep it pending */ + if(s->irq_enabled[pos] && !s->irq_id) + { + /* timer interrupt will re-fire periodically */ + if(pos == 0x0A) + { + s->irq_schedule[pos] = 100; + } + else + { + printf("[EOS] trigger int 0x%02X (delayed)\n", pos); + s->irq_schedule[pos] = 0; + } + + s->irq_id = pos; + cpu_interrupt(&(s->cpu->env), CPU_INTERRUPT_HARD); + } + } + + /* still counting down? */ + if(s->irq_schedule[pos] > 1) + { + s->irq_schedule[pos]--; + } + } + } + + return NULL; +} + +static EOSState *eos_init_cpu(void) +{ + EOSState *s = g_new(EOSState, 1); + + s->verbosity = 0xFFFFFFFF; + s->tio_rxbyte = 0x100; + + memset(s->irq_enabled, 0x00, sizeof(s->irq_enabled)); + memset(s->irq_schedule, 0x00, sizeof(s->irq_schedule)); + s->system_mem = get_system_memory(); + + //memory_region_init_ram(&s->tcm_code, "eos.tcm_code", TCM_SIZE); + //memory_region_add_subregion(s->system_mem, 0x00000000, &s->tcm_code); + //memory_region_init_ram(&s->tcm_data, "eos.tcm_data", TCM_SIZE); + //memory_region_add_subregion(s->system_mem, CACHING_BIT, &s->tcm_data); + + /* set up RAM, cached and uncached */ + #undef TCM_SIZE + #define TCM_SIZE 0 + memory_region_init_ram(&s->ram, "eos.ram", RAM_SIZE - TCM_SIZE); + memory_region_add_subregion(s->system_mem, TCM_SIZE, &s->ram); + memory_region_init_alias(&s->ram_uncached, "eos.ram_uncached", &s->ram, 0x00000000, RAM_SIZE - TCM_SIZE); + memory_region_add_subregion(s->system_mem, CACHING_BIT | TCM_SIZE, &s->ram_uncached); + + /* set up ROM0 */ + memory_region_init_ram(&s->rom0, "eos.rom0", ROM0_SIZE); + memory_region_add_subregion(s->system_mem, ROM0_ADDR, &s->rom0); + + uint64_t offset; + for(offset = ROM0_ADDR + ROM0_SIZE; offset < ROM1_ADDR; offset += ROM0_SIZE) + { + char name[32]; + MemoryRegion *image = g_new(MemoryRegion, 1); + sprintf(name, "eos.rom0_mirror_%02X", (uint32_t)offset >> 24); + + memory_region_init_alias(image, name, &s->rom0, 0x00000000, ROM0_SIZE); + memory_region_add_subregion(s->system_mem, offset, image); + } + + /* set up ROM1 */ + memory_region_init_ram(&s->rom1, "eos.rom1", ROM1_SIZE); + memory_region_add_subregion(s->system_mem, ROM1_ADDR, &s->rom1); + + // uint64_t offset; + for(offset = ROM1_ADDR + ROM1_SIZE; offset < 0x100000000; offset += ROM1_SIZE) + { + char name[32]; + MemoryRegion *image = g_new(MemoryRegion, 1); + sprintf(name, "eos.rom1_mirror_%02X", (uint32_t)offset >> 24); + + memory_region_init_alias(image, name, &s->rom1, 0x00000000, ROM1_SIZE); + memory_region_add_subregion(s->system_mem, offset, image); + } + + //memory_region_init_ram(&s->rom1, "eos.rom", 0x10000000); + //memory_region_add_subregion(s->system_mem, 0xF0000000, &s->rom1); + + /* set up io space */ + memory_region_init_io(&s->iomem, &iomem_ops, s, "eos.iomem", IO_MEM_LEN); + memory_region_add_subregion(s->system_mem, IO_MEM_START, &s->iomem); + + /*ROMState *rom0 = eos_rom_register(0xF8000000, NULL, "ROM1", ROM1_SIZE, + NULL, + 0x100, 0x100, 32, + 0, 0, 0, 0, 0); + + */ + + vmstate_register_ram_global(&s->ram); + + s->cpu = cpu_arm_init("arm946eos"); + if (!s->cpu) + { + fprintf(stderr, "Unable to find CPU definition\n"); + exit(1); + } + + s->rtc.transfer_format = 0xFF; + + qemu_thread_create(&s->interrupt_thread_id, eos_interrupt_thread, s, QEMU_THREAD_JOINABLE); + + return s; +} + +static void eos_init_common(const char *rom_filename, uint32_t rom_start) +{ + EOSState *s = eos_init_cpu(); + + eos_load_image(s, rom_filename, 0xF7000000); + + s->cpu->env.regs[15] = rom_start; +} + +static void ml_init_common(const char *rom_filename, uint32_t rom_start) +{ + EOSState *s = eos_init_cpu(); + + /* trick: loading 32MB from 0xF7000000 will populate both ROM0 and ROM1 */ + eos_load_image(s, rom_filename, 0xF7000000); + + eos_load_image(s, "autoexec.bin", 0x00800000); + + /* we will replace Canon stubs with our own implementations */ + /* see qemu-helper.c, stub_mappings[] */ + eos_load_image(s, "qemu-helper.bin", Q_HELPER_ADDR); + uint32_t magic = 0x12345678; + uint32_t addr = Q_HELPER_ADDR; + while (MEM32(addr) != magic || MEM32(addr + 4) != magic) + { + addr += 4; + if (addr > 0x30100000) { fprintf(stderr, "stub list not found\n"); abort(); } + } + uint32_t ram_offset = MEM32(addr + 8); + addr += 12; + while (MEM32(addr) != magic || MEM32(addr + 4) != magic) + { + uint32_t old = MEM32(addr); + uint32_t new = MEM32(addr + 4); + if (old < 0xFF000000) + old += ram_offset; + uint32_t jmp[] = {FAR_CALL_INSTR, new}; + printf("[QEMU_HELPER] stub %x -> %x\n", old, new); + cpu_physical_memory_write_rom(old, (uint8_t*)jmp, 8); + + addr += 8; + if (addr > 0x30100000) { fprintf(stderr, "stub list error\n"); abort(); } + } + + // set entry point + s->cpu->env.regs[15] = 0x800000; + s->cpu->env.regs[13] = 0x8000000; +} + +ML_MACHINE(50D, 0xFF010000); +ML_MACHINE(60D, 0xFF010000); +ML_MACHINE(600D, 0xFF010000); +ML_MACHINE(500D, 0xFF010000); +ML_MACHINE(5D2, 0xFF810000); +ML_MACHINE(5D3, 0xFF0C0000); +ML_MACHINE(6D, 0xFF0C0000); +ML_MACHINE(650D, 0xFF0C0000); + +EOS_MACHINE(50D, 0xFF010000); +EOS_MACHINE(60D, 0xFF010000); +EOS_MACHINE(600D, 0xFF010000); +EOS_MACHINE(500D, 0xFF010000); +EOS_MACHINE(5D2, 0xFF810000); +EOS_MACHINE(5D3, 0xFF0C0000); +EOS_MACHINE(6D, 0xFF0C0000); +EOS_MACHINE(650D, 0xFF0C0000); + +static void eos_machine_init(void) +{ + qemu_register_machine(&canon_eos_machine_ml_50D); + qemu_register_machine(&canon_eos_machine_ml_60D); + qemu_register_machine(&canon_eos_machine_ml_600D); + qemu_register_machine(&canon_eos_machine_ml_500D); + qemu_register_machine(&canon_eos_machine_ml_5D2); + qemu_register_machine(&canon_eos_machine_ml_5D3); + qemu_register_machine(&canon_eos_machine_ml_6D); + qemu_register_machine(&canon_eos_machine_ml_650D); + qemu_register_machine(&canon_eos_machine_50D); + qemu_register_machine(&canon_eos_machine_60D); + qemu_register_machine(&canon_eos_machine_600D); + qemu_register_machine(&canon_eos_machine_500D); + qemu_register_machine(&canon_eos_machine_5D2); + qemu_register_machine(&canon_eos_machine_5D3); + qemu_register_machine(&canon_eos_machine_6D); + qemu_register_machine(&canon_eos_machine_650D); +} + +machine_init(eos_machine_init); + +void eos_set_mem_w ( EOSState *ws, uint32_t addr, uint32_t val ) +{ + MEM32(addr) = val; +} + +void eos_set_mem_h ( EOSState *ws, uint32_t addr, uint16_t val ) +{ + MEM16(addr) = val; +} + +void eos_set_mem_b ( EOSState *ws, uint32_t addr, uint8_t val ) +{ + MEM8(addr) = val; +} + +uint32_t eos_get_mem_w ( EOSState *ws, uint32_t addr ) +{ + return MEM32(addr); +} + +uint16_t eos_get_mem_h ( EOSState *ws, uint32_t addr ) +{ + return MEM16(addr); +} + +uint8_t eos_get_mem_b ( EOSState *ws, uint32_t addr ) +{ + return MEM8(addr); +} + +unsigned int eos_default_handle ( EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int data = 0; + unsigned int pc = ws->cpu->env.regs[15]; + + switch ( type & WIDTH_MASK ) + { + case WIDTH_WORD: + if ( type & MODE_WRITE ) + eos_set_mem_w ( ws, address, value ); + else + data = eos_get_mem_w ( ws, address ); + break; + + case WIDTH_HALF: + if ( type & MODE_WRITE ) + eos_set_mem_h ( ws, address, value ); + else + data = eos_get_mem_h ( ws, address ); + break; + + case WIDTH_BYTE: + if ( type & MODE_WRITE ) + eos_set_mem_b ( ws, address, value ); + else + data = eos_get_mem_b ( ws, address ); + break; + } + + /* do not log ram/flash access */ + if(((address & 0xF0000000) == 0) || ((address & 0xF0000000) == 0xF0000000) || ((address & 0xF0000000) == 0x40000000)) + { + return data; + } + + if ( type & MODE_WRITE ) + { + if(ws->verbosity & 1) + { + printf("Write: at [0x%08X] [0x%08X] -> [0x%08X]\r\n", pc, value, address); + } + } + else + { + static int mod = 0; + mod++; + mod %= 2; + + if(mod) + { + data = ~data; + } + if(ws->verbosity & 1) + { + printf("Read: at [0x%08X] [0x%08X] <- [0x%08X]\r\n", pc, data, address); + } + } + return data; +} + +EOSRegionHandler *eos_find_handler( unsigned int address) +{ + int pos = 0; + for(pos = 0; pos < sizeof(eos_handlers) / sizeof(eos_handlers[0]); pos++) + { + if(eos_handlers[pos].start <= address && eos_handlers[pos].end >= address) + { + return &eos_handlers[pos]; + } + } + + return NULL; +} + +unsigned int eos_handler ( EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + EOSRegionHandler *handler = eos_find_handler(address); + + if(handler) + { + return handler->handle(handler->parm, ws, address, type, value); + } + else + { + static uint32_t last_addr = 0; + static uint32_t repeats = 0; + + if(address != last_addr || repeats < 5) + { + if(address == last_addr) + { + repeats++; + } + else + { + last_addr = address; + repeats = 0; + } + + if(type & MODE_WRITE) + { + printf("[???] [0x%08X] -> [0x%08X] PC: 0x%08X\r\n", value, address, ws->cpu->env.regs[15]); + } + else + { + printf("[???] [0x%08X] <- [0x%08X] PC: 0x%08X\r\n", value, address, ws->cpu->env.regs[15]); + } + } + } + return 0; +} + +unsigned int eos_trigger_int(EOSState *ws, unsigned int id, unsigned int delay) +{ + if(!delay && ws->irq_enabled[id] && !ws->irq_id) + { + printf("[EOS] trigger int 0x%02X\n", id); + ws->irq_id = id; + cpu_interrupt(&(ws->cpu->env), CPU_INTERRUPT_HARD); + } + else + { + printf("[EOS] trigger int 0x%02X (delayed!)\n", id); + if(!ws->irq_enabled[id]) + { + delay = 1; + } + ws->irq_schedule[id] = delay; + } + return 0; +} + +unsigned int eos_handle_intengine ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int pc = ws->cpu->env.regs[15]; + + switch(address & 0xFFF) + { + case 0x04: + if(type & MODE_WRITE) + { + printf("[Int] Wrote int reason [0x%08X] -> [0x%08X] PC: [0x%08X]\r\n", address, value, pc); + return 0; + } + else + { + if(ws->irq_id != 0x0A) + { + printf("[Int] Requested int reason [0x%08X] <- [0x%08X] PC: [0x%08X]\r\n", ws->irq_id << 2, address, pc); + } + return ws->irq_id << 2; + } + break; + + case 0x10: + if(type & MODE_WRITE) + { + if(!ws->irq_enabled[value] || (value != 0x0A && value != 0x2F && value != 0x74 && value != 0x75)) + { + printf("[Int] Enabled interrupt ID 0x%02X PC: [0x%08X]\r\n", value, pc); + } + + cpu_reset_interrupt(&(ws->cpu->env), CPU_INTERRUPT_HARD); + ws->irq_id = 0; + ws->irq_enabled[value] = 1; + return 0; + } + else + { + return 0; + } + break; + } + + if(type & MODE_WRITE) + { + printf("[Int] Write to Int space [0x%08X] -> [0x%08X] PC: [0x%08X]\r\n", value, address, pc); + } + else + { + return 0; + } + return 0; +} + +unsigned int eos_handle_timers_ ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int pc = ws->cpu->env.regs[15]; + + if(type & MODE_WRITE) + { + printf("[Timer?] at [0x%08X] [0x%08X] -> [0x%08X]\r\n", pc, value, address); + } + else + { + return 0; + } + return 0; +} + +unsigned int eos_handle_timers ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int ret = 0; + + switch(address & 0xFF) + { + case 0x00: + if(type & MODE_WRITE) + { + if(value & 1) + { + printf("[Timer] at [0x%08X] Starting triggering\r\n", ws->cpu->env.regs[15]); + eos_trigger_int(ws, 0x0A, 5000); + } + } + else + { + ret = 0; + } + break; + } + + if(type & MODE_WRITE) + { + unsigned int pc = ws->cpu->env.regs[15]; + printf("[Timer] at [0x%08X] [0x%08X] -> [0x%08X]\r\n", pc, value, address); + } + else + { + return ret; + } + return 0; +} + +unsigned int eos_handle_gpio ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int ret = 1; + + switch(parm) + { + case 0: + if((address & 0xFFF) == 0x0DC) + { + /* abort situation for FROMUTIL on 600D */ + ret = 0; + } + if((address & 0xFFF) == 0x0B0) + { + /* FUNC SW OFF on 7D */ + ret = 0; + } + if((address & 0xFFF) == 0x024) + { + /* master woke up on 7D */ + ret = 0; + } + + if((address & 0xFFF) == 0x070) + { + /* VIDEO on 600D */ + printf("[GPIO] VIDEO CONNECT read at [0x%08X]\r\n", ws->cpu->env.regs[15]); + return 0; + } + if((address & 0xFFF) == 0x108) + { + /* ERASE SW OFF on 600D */ + printf("[GPIO] ERASE SW OFF read at [0x%08X]\r\n", ws->cpu->env.regs[15]); + return 0; + } + if((address & 0xFFF) == 0x0E8) + { + /* MIC on 600D */ + printf("[GPIO] MIC CONNECT read at [0x%08X]\r\n", ws->cpu->env.regs[15]); + return 1; + } + if((address & 0xFFF) == 0x034) + { + /* USB on 600D */ + printf("[GPIO] USB CONNECT read at [0x%08X]\r\n", ws->cpu->env.regs[15]); + return 0; + } + if((address & 0xFFF) == 0x138) + { + /* HDMI on 600D */ + printf("[GPIO] HDMI CONNECT read at [0x%08X]\r\n", ws->cpu->env.regs[15]); + return 0; + } + if((address & 0xFFF) == 0x014) + { + /* /VSW_ON on 600D */ + printf("[GPIO] /VSW_ON read at [0x%08X]\r\n", ws->cpu->env.regs[15]); + return 0; + } + if((address & 0xFFF) == 0x128) + { + /* CS for RTC on 600D */ + if(type & MODE_WRITE) + { + if((value & 0x06) == 0x06) + { + printf("[RTC] CS set at [0x%08X]\r\n", ws->cpu->env.regs[15]); + ws->rtc.transfer_format = 0xFF; + } + else + { + printf("[RTC] CS reset at [0x%08X]\r\n", ws->cpu->env.regs[15]); + } + } + ret = 0; + } + break; + case 3: + if((address & 0xFFF) == 0x01C) + { + /* 40D CF Detect -> set low, so there is no CF */ + ret = 0; + } + break; + } + + unsigned int pc = ws->cpu->env.regs[15]; + if(type & MODE_WRITE) + { + printf("[GPIO] at [0x%08X] [0x%08X] -> [0x%08X]\r\n", pc, value, address); + } + else + { + printf("[GPIO] at [0x%08X] [0x%08X] <- [0x%08X]\r\n", pc, ret, address); + return ret; + } + return 0; +} + +unsigned int eos_handle_ram ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + if(type & MODE_WRITE) + { + printf("[RAM] [0x%08X] -> [0x%08X]\r\n", value, address); + } + else + { + printf("[RAM] [0x%08X] <- [0x%08X]\r\n", value, address); + } + return eos_default_handle ( ws, address, type, value ); +} + +unsigned int eos_handle_cartridge ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + if(type & MODE_WRITE) + { + printf("[Cartridge] [0x%08X] -> [0x%08X]\r\n", value, address); + } + else + { + return 0; + } + return 0; +} + +unsigned int eos_handle_dma ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int ret = 0; + unsigned int log = 1; + static unsigned int srcAddr = 0; + static unsigned int dstAddr = 0; + static unsigned int count = 0; + unsigned int interruptId[] = { 0x00, 0x2f, 0x74, 0x75, 0x76 }; + + switch(address & 0xFF) + { + case 0x08: + if(type & MODE_WRITE) + { + if(value & 1) + { + /* Start DMA */ + printf("[DMA%i] Copy [0x%08X] -> [0x%08X], length [0x%08X], flags [0x%08X]\r\n", parm, srcAddr, dstAddr, count, value); + + uint32_t blocksize = 8192; + uint8_t *buf = malloc(blocksize); + uint32_t remain = count; + + while(remain) + { + uint32_t transfer = (remain > blocksize) ? blocksize : remain; + + cpu_physical_memory_rw(srcAddr, buf, transfer, 0); + cpu_physical_memory_rw(dstAddr, buf, transfer, 1); + + remain -= transfer; + } + free(buf); + + printf("[DMA%i] OK\n", parm); + + eos_trigger_int(ws, interruptId[parm], 0); + log = 0; + } + } + else + { + ret = 0; + } + break; + + case 0x18: + if(type & MODE_WRITE) + { + srcAddr = value; + log = 1; + } + else + { + return srcAddr; + } + break; + + case 0x1C: + if(type & MODE_WRITE) + { + dstAddr = value; + log = 1; + } + else + { + return dstAddr; + } + break; + + case 0x20: + if(type & MODE_WRITE) + { + count = value; + log = 1; + } + else + { + return count; + } + break; + } + + if(log) + { + if(type & MODE_WRITE) + { + printf("[DMA%i] [0x%08X] -> [0x%08X]\r\n", parm, value, address); + } + else + { + printf("[DMA%i] [0x%08X] <- [0x%08X]\r\n", parm, ret, address); + } + } + + return 0; +} + + +unsigned int eos_handle_tio ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + switch(address & 0xFF) + { + case 0x00: + if(type & MODE_WRITE) + { + if((value == 0x08 || value == 0x0A || (value >= 0x20 && value <= 0x7F))) + { + printf("%c", value); + } + } + else + { + return 0; + } + break; + + case 0x04: + printf("[TIO] Read byte: 0x%02X\r\n", ws->tio_rxbyte & 0xFF); + return ws->tio_rxbyte & 0xFF; + break; + + case 0x14: + if(type & MODE_WRITE) + { + if(value & 1) + { + printf("[TIO] Reset RX indicator\r\n"); + ws->tio_rxbyte |= 0x100; + } + } + else + { + if((ws->tio_rxbyte & 0x100) == 0) + { + printf("[TIO] Signalling RX indicator\r\n"); + return 3; + } + return 2; + } + break; + } + + return 0; +} + +unsigned int eos_handle_sio ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + static unsigned int last_sio_data = 0; + static unsigned int last_sio_setup1 = 0; + static unsigned int last_sio_setup2 = 0; + static unsigned int last_sio_setup3 = 0; + unsigned int pc = ws->cpu->env.regs[15]; + + switch(address & 0xFF) + { + case 0x04: + if((type & MODE_WRITE) && (value & 1)) + { + printf("[SIO%i] Transmit: 0x%08X, setup 0x%08X 0x%08X 0x%08X PC: 0x%08X\r\n", parm, last_sio_data, last_sio_setup1, last_sio_setup2, last_sio_setup3, pc ); + + switch(ws->rtc.transfer_format) + { + /* no special mode */ + case 0xFF: + { + uint8_t cmd = value & 0x0F; + uint8_t reg = (value>>4) & 0x0F; + ws->rtc.transfer_format = cmd; + ws->rtc.current_reg = reg; + + switch(cmd) + { + /* burst writing */ + case 0x00: + /* burst reading */ + case 0x04: + /* 1 byte writing */ + case 0x08: + /* 1 byte reading */ + case 0x0C: + break; + + default: + printf("[SIO%i] RTC: Requested invalid transfer mode 0x%02X at PC: 0x%08X\r\n", parm, value, pc ); + break; + } + } + + /* burst writing */ + case 0x00: + ws->rtc.regs[ws->rtc.current_reg] = value; + ws->rtc.current_reg++; + ws->rtc.current_reg %= 0x10; + break; + + /* burst reading */ + case 0x04: + last_sio_data = ws->rtc.regs[ws->rtc.current_reg]; + ws->rtc.current_reg++; + ws->rtc.current_reg %= 0x10; + break; + + /* 1 byte writing */ + case 0x08: + ws->rtc.regs[ws->rtc.current_reg] = value; + ws->rtc.transfer_format = 0xFF; + break; + + /* 1 byte reading */ + case 0x0C: + last_sio_data = ws->rtc.regs[ws->rtc.current_reg]; + ws->rtc.transfer_format = 0xFF; + break; + + default: + break; + } + return 0; + } + else + { + return 0; + } + break; + + case 0x0C: + if(type & MODE_WRITE) + { + last_sio_setup1 = value; + return 0; + } + else + { + return last_sio_setup1; + } + + case 0x10: + if(type & MODE_WRITE) + { + last_sio_setup3 = value; + return 0; + } + else + { + return last_sio_setup3; + } + + case 0x14: + if(type & MODE_WRITE) + { + last_sio_setup1 = value; + return 0; + } + else + { + return last_sio_setup1; + } + + case 0x18: + if(type & MODE_WRITE) + { + last_sio_data = value; + + printf("[SIO%i] Write to TX register PC: 0x%08X\r\n", parm, pc); + return 0; + } + else + { + return last_sio_data; + } + + case 0x1C: + if(type & MODE_WRITE) + { + printf("[SIO%i] Write access to RX register\r\n", parm); + return 0; + } + else + { + printf("[SIO%i] Read from RX register PC: 0x%08X read: 0x%02X\r\n", parm, pc, last_sio_data); + + return last_sio_data; + } + } + + return 0; +} + +unsigned int eos_handle_unk ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int pc = ws->cpu->env.regs[15]; + unsigned int ret = 0; + static unsigned val = 0; + + switch(parm) + { + case 0: + if(type & MODE_WRITE) + { + ret = 0; + } + else + { + ret = val; + val += 1000; + } + break; + } + + if(type & MODE_WRITE) + { + printf("[Timer] at [0x%08X] [0x%08X] -> [0x%08X]\r\n", pc, value, address); + } + else + { + //printf("[Timer] at [0x%08X] [0x%08X] <- [0x%08X]\r\n", pc, ret, address); + } + return ret; +} + + +unsigned int eos_handle_sdio ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int pc = ws->cpu->env.regs[15]; + unsigned int ret = 0; + + switch(address & 0xFFF) + { + case 0x10: + /* code is waiting for bit0 getting high, bit1 is an error flag */ + ret = 3; + break; + case 0x34: + /* code is waiting for transfer status */ + ret = 0xFFFFFF; + break; + } + + if(type & MODE_WRITE) + { + printf("[Basic] at [0x%08X] [0x%08X] -> [0x%08X]\r\n", pc, value, address); + } + else + { + printf("[Basic] at [0x%08X] [0x%08X] <- [0x%08X]\r\n", pc, ret, address); + } + return ret; +} + +unsigned int eos_handle_basic ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int ret = 0; + unsigned int pc = ws->cpu->env.regs[15]; + static int unk = 0; + + switch(parm) + { + case 1: + switch(address & 0xFFF) + { + case 0xA4: + if(type & MODE_WRITE) + { + } + else + { + ret = 1; + } + break; + } + break; + + case 2: + switch(address & 0xFFF) + { + case 0x100: + if(type & MODE_WRITE) + { + } + else + { + ret = unk; + unk++; + unk %= 2; + } + break; + + case 0x198: + if(type & MODE_WRITE) + { + } + else + { + ret = unk; + unk++; + unk %= 2; + } + break; + + /* + 0xC022F480 [32] Other VSW Status + 0x40000 /VSW_OPEN Hi + 0x80000 /VSW_REVO Hi + */ + case 0x480: + if(type & MODE_WRITE) + { + } + else + { + ret = 0x40000 | 0x80000; + printf("[Basic] VSW_STATUS at [0x%08X] [0x%08X] <- [0x%08X]\r\n", pc, ret, address); + return ret; + } + break; + + } + break; + } + if(type & MODE_WRITE) + { + printf("[Basic] at [0x%08X] [0x%08X] -> [0x%08X]\r\n", pc, value, address); + } + else + { + printf("[Basic] at [0x%08X] [0x%08X] <- [0x%08X]\r\n", pc, ret, address); + } + + return ret; +} + + +#define FLASH_STATE_READ 0 +#define FLASH_STATE_UNLOCK_2 1 +#define FLASH_STATE_UNLOCKED 2 +#define FLASH_STATE_ERASE_1 3 +#define FLASH_STATE_ERASE_2 4 +#define FLASH_STATE_ERASE_3 5 +#define FLASH_STATE_PROGRAM 6 +#define FLASH_STATE_UNLOCK_BYPASS 7 +#define FLASH_STATE_UNLOCK_BYPASS_RESET 8 +#define FLASH_STATE_UNLOCK_BYPASS_ERASE 9 +#define FLASH_STATE_BLOCK_ERASE_BUSY 10 + +unsigned int flash_get_blocksize(unsigned int rom, unsigned int size, unsigned int word_offset) +{ + switch(size) + { + /* 32mbit flash x16 */ + case 0x00400000: + if((word_offset < 0x8000) || (word_offset > 0x1F0000)) + { + /* 4 kwords */ + return 4 * 1024 * 2; + } + else + { + /* 32 kwords */ + return 32 * 1024 * 2; + } + break; + + default: + return 0; + } +} + +unsigned int eos_handle_rom ( unsigned int rom, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int pc = ws->cpu->env.regs[15]; + unsigned int ret = 0; + unsigned int real_address = 0; + unsigned int byte_offset = 0; + unsigned int word_offset = 0; + unsigned int base = 0; + unsigned int size = 0; + unsigned int fail = 0; + + static int block_erase_counter = 0; + static int state[2] = { FLASH_STATE_READ, FLASH_STATE_READ }; + + switch(rom) + { + case 0: + base = 0xF8000000; + size = ROM1_SIZE; + break; + case 1: + base = 0xF0000000; + size = ROM0_SIZE; + break; + } + + /* the offset relative from flash chip start */ + byte_offset = (address - base) & (size - 1); + word_offset = byte_offset >> 1; + + /* the address of the flash data in memory space */ + real_address = base + byte_offset; + + if(!ws->flash_state_machine) + { + return eos_default_handle ( ws, real_address, type, value ); + } + + if(type & MODE_WRITE) + { + switch(state[rom]) + { + case FLASH_STATE_READ: + if(value == 0xF0) + { + state[rom] = FLASH_STATE_READ; + } + else if(word_offset == 0x555 && value == 0xAA) + { + state[rom] = FLASH_STATE_UNLOCK_2; + } + else if(value == 0xA0) + { + printf("[ROM%i:%i] at [0x%04X] Command: UNLOCK BYPASS PROGRAM\r\n", rom, state[rom], pc); + state[rom] = FLASH_STATE_PROGRAM; + } + else if(value == 0x80) + { + state[rom] = FLASH_STATE_UNLOCK_BYPASS_ERASE; + } + else if(value == 0x90) + { + state[rom] = FLASH_STATE_UNLOCK_BYPASS_RESET; + } + else if(value == 0x98) + { + printf("[ROM%i:%i] at [0x%04X] Command: UNLOCK BYPASS CFI unhandled\r\n", rom, state[rom], pc); + state[rom] = FLASH_STATE_READ; + } + else + { + fail = 1; + } + break; + + case FLASH_STATE_UNLOCK_BYPASS: + printf("[ROM%i:%i] at [0x%04X] 2nd UNLOCK BYPASS [0x%08X] -> [0x%08X] unhandled\r\n", rom, state[rom], pc, value, word_offset); + state[rom] = FLASH_STATE_READ; + break; + + + case FLASH_STATE_UNLOCK_BYPASS_RESET: + if(value == 0x00) + { + printf("[ROM%i:%i] at [0x%04X] Command: UNLOCK BYPASS RESET\r\n", rom, state[rom], pc); + state[rom] = FLASH_STATE_READ; + } + else + { + fail = 1; + } + break; + + case FLASH_STATE_UNLOCK_2: + if(word_offset == 0x2AA && value == 0x55) + { + state[rom] = FLASH_STATE_UNLOCKED; + } + else + { + state[rom] = FLASH_STATE_READ; + fail = 1; + } + break; + + case FLASH_STATE_UNLOCKED: + if(value == 0x90) + { + printf("[ROM%i:%i] at [0x%04X] [0x%08X] -> [0x%08X] in autoselect unhandled\r\n", rom, state[rom], pc, value, word_offset); + state[rom] = FLASH_STATE_READ; + } + else if(word_offset == 0x555 && value == 0xA0) + { + //printf("[ROM%i:%i] at [0x%04X] Command: PROGRAM\r\n", rom, state[rom], pc); + state[rom] = FLASH_STATE_PROGRAM; + } + else if(word_offset == 0x555 && value == 0x20) + { + printf("[ROM%i:%i] at [0x%04X] Command: UNLOCK BYPASS\r\n", rom, state[rom], pc); + state[rom] = FLASH_STATE_READ; + } + else if(word_offset == 0x555 && value == 0x80) + { + state[rom] = FLASH_STATE_ERASE_1; + } + else + { + state[rom] = FLASH_STATE_READ; + fail = 1; + } + break; + + case FLASH_STATE_ERASE_1: + if(word_offset == 0x555 && value == 0xAA) + { + state[rom] = FLASH_STATE_ERASE_2; + } + else + { + state[rom] = FLASH_STATE_READ; + fail = 1; + } + break; + + case FLASH_STATE_ERASE_2: + if(word_offset == 0x2AA && value == 0x55) + { + state[rom] = FLASH_STATE_ERASE_3; + } + else + { + state[rom] = FLASH_STATE_READ; + fail = 1; + } + break; + + case FLASH_STATE_UNLOCK_BYPASS_ERASE: + if(value == 0x30) + { + int pos = 0; + int block_size = flash_get_blocksize(rom, size, word_offset); + + printf("[ROM%i:%i] at [0x%04X] Command: UNLOCK BYPASS BLOCK ERASE [0x%08X]\r\n", rom, state[rom], pc, real_address); + for(pos = 0; pos < block_size; pos += 2) + { + eos_set_mem_w ( ws, real_address + pos, 0xFFFF ); + } + block_erase_counter = 0; + state[rom] = FLASH_STATE_BLOCK_ERASE_BUSY; + } + else if(value == 0x10) + { + int pos = 0; + + printf("[ROM%i:%i] at [0x%04X] Command: UNLOCK BYPASS CHIP ERASE\r\n", rom, state[rom], pc); + for(pos = 0; pos < size; pos += 2) + { + eos_set_mem_w ( ws, base + pos, 0xFFFF ); + } + state[rom] = FLASH_STATE_READ; + } + else + { + fail = 1; + } + break; + + case FLASH_STATE_ERASE_3: + if(word_offset == 0x555 && value == 0x10) + { + int pos = 0; + printf("[ROM%i:%i] at [0x%04X] Command: CHIP ERASE\r\n", rom, state[rom], pc); + for(pos = 0; pos < size; pos += 2) + { + eos_set_mem_w ( ws, base + pos, 0xFFFF ); + } + state[rom] = FLASH_STATE_READ; + } + else if(value == 0x30) + { + int pos = 0; + int block_size = flash_get_blocksize(rom, size, word_offset); + + printf("[ROM%i:%i] at [0x%04X] Command: BLOCK ERASE [0x%08X]\r\n", rom, state[rom], pc, real_address); + for(pos = 0; pos < block_size; pos += 2) + { + eos_set_mem_w ( ws, real_address + pos, 0xFFFF ); + } + block_erase_counter = 0; + state[rom] = FLASH_STATE_BLOCK_ERASE_BUSY; + } + else + { + state[rom] = FLASH_STATE_READ; + fail = 1; + } + break; + + case FLASH_STATE_PROGRAM: + printf("[ROM%i:%i] at [0x%04X] Command: PROGRAM [0x%04X] -> [0x%08X]\r\n", rom, state[rom], pc, value, real_address); + eos_set_mem_w ( ws, real_address, value ); + state[rom] = FLASH_STATE_READ; + break; + } + if(fail) + { + printf("[ROM%i:%i] at [0x%04X] [0x%08X] -> [0x%08X]\r\n", rom, state[rom], pc, value, word_offset); + } + } + else + { + + switch(state[rom]) + { + case FLASH_STATE_READ: + ret = eos_default_handle ( ws, real_address, type, value ); + break; + + case FLASH_STATE_BLOCK_ERASE_BUSY: + if(block_erase_counter < 0x10) + { + block_erase_counter++; + ret = ((block_erase_counter&1)<<6) | ((block_erase_counter&1)<<2); + } + else + { + ret = 0x80; + state[rom] = FLASH_STATE_READ; + } + break; + + default: + printf("[ROM%i:%i] at [0x%04X] read in unknown state [0x%08X] <- [0x%08X]\r\n", rom, state[rom], pc, ret, word_offset); + break; + } + } + + return ret; +} + + +unsigned int eos_handle_flashctrl ( unsigned int parm, EOSState *ws, unsigned int address, unsigned char type, unsigned int value ) +{ + unsigned int pc = ws->cpu->env.regs[15]; + unsigned int ret = 0; + + switch(address & 0x1FF) + { + case 0x10: + if(type & MODE_WRITE) + { + if(((value | (value >> 16)) & 0xFFFF) == 0xD9C5) + { + printf("[FlashIF] at [0x%08X]: 'Write enable' enabled\r\n", pc); + } + else if(value == 0x0) + { + printf("[FlashIF] at [0x%08X]: 'Write enable' disabled\r\n", pc); + } + else + { + printf("[FlashIF] at [0x%08X]: unknown command\r\n", pc); + } + } + else + { + ret = 1; + } + break; + } + return ret; +} + + +/* its not done yet */ +#if defined(EOS_ROM_DEVICE_IMPLEMENTED) +ROMState *eos_rom_register(hwaddr base, DeviceState *qdev, const char *name, hwaddr size, + BlockDriverState *bs, + uint32_t sector_len, int nb_blocs, int width, + uint16_t id0, uint16_t id1, + uint16_t id2, uint16_t id3, int be) +{ + DeviceState *dev = qdev_create(NULL, "eos.rom"); + SysBusDevice *busdev = SYS_BUS_DEVICE(dev); + ROMState *pfl = (ROMState *)object_dynamic_cast(OBJECT(dev), + "cfi.pflash01"); + + if (bs && qdev_prop_set_drive(dev, "drive", bs)) { + abort(); + } + qdev_prop_set_uint32(dev, "num-blocks", nb_blocs); + qdev_prop_set_uint64(dev, "sector-length", sector_len); + qdev_prop_set_uint8(dev, "width", width); + qdev_prop_set_uint8(dev, "big-endian", !!be); + qdev_prop_set_uint16(dev, "id0", id0); + qdev_prop_set_uint16(dev, "id1", id1); + qdev_prop_set_uint16(dev, "id2", id2); + qdev_prop_set_uint16(dev, "id3", id3); + qdev_prop_set_string(dev, "name", name); + qdev_init_nofail(dev); + + sysbus_mmio_map(busdev, 0, base); + return pfl; +} + +static const MemoryRegionOps eos_rom_ops = { +/* .old_mmio = { + .read = { pflash_readb_be, pflash_readw_be, pflash_readl_be, }, + .write = { pflash_writeb_be, pflash_writew_be, pflash_writel_be, }, + }, + .endianness = DEVICE_NATIVE_ENDIAN,*/ +}; + +static int eos_rom_init(SysBusDevice *dev) +{ + ROMState *pfl = FROM_SYSBUS(typeof(*pfl), dev); + uint64_t total_len = 0x00100000; + int ret = 0; + + memory_region_init_rom_device(&pfl->mem, &eos_rom_ops, pfl, pfl->name, total_len); + vmstate_register_ram(&pfl->mem, DEVICE(pfl)); + pfl->storage = memory_region_get_ram_ptr(&pfl->mem); + sysbus_init_mmio(dev, &pfl->mem); + + if (pfl->bs) { + /* read the initial flash content */ + ret = bdrv_read(pfl->bs, 0, pfl->storage, total_len >> 9); + + if (ret < 0) { + vmstate_unregister_ram(&pfl->mem, DEVICE(pfl)); + memory_region_destroy(&pfl->mem); + return 1; + } + } + + return ret; +} + +static Property eos_rom_properties[] = { + DEFINE_PROP_DRIVE("drive", ROMState, bs), + DEFINE_PROP_UINT32("num-blocks", ROMState, nb_blocs, 0), + DEFINE_PROP_UINT64("sector-length", ROMState, sector_len, 0), + DEFINE_PROP_UINT8("width", ROMState, width, 0), + DEFINE_PROP_UINT8("big-endian", ROMState, be, 0), + DEFINE_PROP_UINT16("id0", ROMState, ident0, 0), + DEFINE_PROP_UINT16("id1", ROMState, ident1, 0), + DEFINE_PROP_UINT16("id2", ROMState, ident2, 0), + DEFINE_PROP_UINT16("id3", ROMState, ident3, 0), + DEFINE_PROP_STRING("name", ROMState, name), + DEFINE_PROP_END_OF_LIST(), +}; + +static const TypeInfo eos_rom_info = { + .name = "eos.rom", + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(ROMState), + .class_init = eos_rom_class_init, +}; + + +static void eos_rom_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(class); + SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(class); + + k->init = eos_rom_init; + dc->props = eos_rom_properties; +} + +static void eos_rom_register_types(void) +{ + type_register_static(&eos_rom_info); +} + +type_init(eos_rom_register_types) +#endif +======= #include "hw/hw.h" #include "hw/loader.h" #include "sysemu/sysemu.h" @@ -1659,3 +3293,4 @@ type_init(eos_rom_register_types) #endif +>>>>>>> other diff -r 4b3129d5a739 -r 7a5ccc6c8531 contrib/qemu/install.sh --- a/contrib/qemu/install.sh Fri Sep 20 16:56:08 2013 +0300 +++ b/contrib/qemu/install.sh Sun Sep 22 11:41:50 2013 -0500 @@ -14,11 +14,19 @@ function die { echo "${1:-"Unknown Error"}" 1>&2 ; exit 1; } +<<<<<<< local +pwd | grep tragic-lantern-6d/contrib/qemu > /dev/null || die "error: we should be in tragic-lantern-6d/contrib/qemu" +======= pwd | grep $ML/contrib/qemu > /dev/null || die "error: we should be in $ML/contrib/qemu" +>>>>>>> other -# go to the parent of magic-lantern folder +# go to the parent of tragic-lantern-6d folder cd ../../.. +<<<<<<< local +ls | grep tragic-lantern-6d > /dev/null || die "error: expecting to find tragic-lantern-6d here" +======= ls | grep $ML > /dev/null || die "error: expecting to find $ML here" +>>>>>>> other mkdir -p qemu cd qemu @@ -32,11 +40,26 @@ tar jxf $QEMU_NAME.tar.bz2 # apply our patch +<<<<<<< local +cp -v ../tragic-lantern-6d/contrib/qemu/scripts/* . +======= cp -v ../$ML/contrib/qemu/scripts/* . +>>>>>>> other chmod +x *.sh +<<<<<<< local +cd ${QEMU_DIR} +<<<<<<< local +cp -v ../../tragic-lantern-6d/contrib/qemu/hw/* hw/ +patch -N -p1 < ../../tragic-lantern-6d/contrib/qemu/qemu-1.4.0.patch +======= +cp -v ../../$ML/contrib/qemu/hw/* hw/ +patch -N -p1 < ../../$ML/contrib/qemu/qemu-1.4.0.patch +>>>>>>> other +======= cd ${QEMU_NAME} cp -v ../../$ML/contrib/qemu/hw/* hw/arm patch -N -p1 < ../../$ML/contrib/qemu/$QEMU_NAME.patch +>>>>>>> other cd .. echo "" @@ -57,9 +80,14 @@ echo echo " cat ROM0.BIN ROM1.BIN > ROM-60D.BIN" echo +<<<<<<< local +echo "3) Enable CONFIG_QEMU=y in your Makefile.user from tragic-lantern-6d directory," +echo " then run 'make clean' to make sure you will rebuild ML from scratch." +======= echo "3) Enable CONFIG_QEMU=y and ML_SRC_STATIC_FONTS=y in your Makefile.user" echo " from magic-lantern directory, then run 'make clean' to make sure" echo " you will rebuild ML from scratch." +>>>>>>> other echo echo "4) Start emulation with:" echo diff -r 4b3129d5a739 -r 7a5ccc6c8531 contrib/qemu/scripts/run_ml_6D.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/qemu/scripts/run_ml_6D.sh Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,3 @@ +#!/bin/bash + +sh run_ml.sh 6D 112 diff -r 4b3129d5a739 -r 7a5ccc6c8531 installer/EOSM.202/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/installer/EOSM.202/Makefile Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,2 @@ +MODEL=EOSM +include ../Makefile.installer diff -r 4b3129d5a739 -r 7a5ccc6c8531 installer/EOSM.202/reboot-ins.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/installer/EOSM.202/reboot-ins.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,176 @@ +/** \file + * Reboot into the hacked firmware. + * + * This program is very simple: attempt to reboot into the normal + * firmware RAM image after startup. + */ +/* + * Copyright (C) 2009 Trammell Hudson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "arm-mcr.h" + +#define SIG_LEN 0x10000 +#define FIRMWARE_SIGNATURE 0x2D7c6dcf // from FF0C0000 + +asm( + ".text\n" + ".globl _start\n" + "_start:\n" + " b 1f\n" + ".ascii \"gaonisoy\"\n" // 0x124, 128 + "1:\n" + "MRS R0, CPSR\n" + "BIC R0, R0, #0x3F\n" // Clear I,F,T + "ORR R0, R0, #0xD3\n" // Set I,T, M=10011 == supervisor + "MSR CPSR, R0\n" + " ldr sp, =0x1900\n" // 0x130 + " mov fp, #0\n" + " b cstart\n" + ); + + +static void busy_wait(int n) +{ + int i,j; + static volatile int k = 0; + for (i = 0; i < n; i++) + for (j = 0; j < 100000; j++) + k++; +} + +static void blink(int n) +{ + while (1) + { + *(int*)0xC02200BC |= 2; // card LED on + busy_wait(n); + *(int*)0xC02200BC &= ~2; // card LED off + busy_wait(n); + } +} + +static void fail() +{ + blink(50); +} + +static int compute_signature(int* start, int num) +{ + int c = 0; + int* p; + for (p = start; p < start + num; p++) + { + c += *p; + } + return c; +} + + +/** Include the relocatable shim code */ +extern uint8_t blob_start; +extern uint8_t blob_end; + +asm( + ".text\n" + ".align 12\n" // 2^12 == 4096 bytes + ".globl blob_start\n" + "blob_start:\n" + ".incbin \"magiclantern.bin\"\n" // + ".align 12\n" + "blob_end:\n" + ".globl blob_end\n" + ); + + +/** Determine the in-memory offset of the code. + * If we are autobooting, there is no offset (code is loaded at + * 0x800000). If we are loaded via a firmware file then there + * is a 0x120 byte header infront of our code. + * + * Note that mov r0, pc puts pc+8 into r0. + */ +static int +__attribute__((noinline)) +find_offset( void ) +{ + uintptr_t pc; + asm __volatile__ ( + "mov %0, %%pc" + : "=&r"(pc) + ); + + return pc - 8 - (uintptr_t) find_offset; +} + +void +__attribute__((noreturn)) +cstart( void ) +{ + // check firmware version + if (compute_signature(ROMBASEADDR, SIG_LEN) != FIRMWARE_SIGNATURE) + fail(); + + // there is a bug in that we are 0x120 bytes off from + // where we should be, so we must offset the blob start. + ssize_t offset = find_offset(); + + // Set the flag if this was an autoboot load + int autoboot_loaded = (offset == 0); + + if (!autoboot_loaded) // running from FIR + { + // write bootflag strings to SD card + // this can only be called from a "reboot" (updater) context, + // not from normal DryOS + + // doesn'tworkstation.. + //~ int (*write_bootflags_to_card)(int) = 0xffff5170; + //~ int not_ok = write_bootflags_to_card(0); + + //~ if (not_ok) + //~ fail(); + } + + // Copy the copy-and-restart blob somewhere + + blob_memcpy( + (void*) RESTARTSTART, + &blob_start + offset, + &blob_end + offset + ); + clean_d_cache(); + flush_caches(); + + // Jump into the newly relocated code + void __attribute__((noreturn))(*copy_and_restart)(int) + = (void*) RESTARTSTART; + + void __attribute__((noreturn))(*firmware_start)(void) + = (void*) ROMBASEADDR; + + if( 1 ) + copy_and_restart(offset); + else + firmware_start(); + + // Unreachable + while(1) + ; +} diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/Makefile.modules --- a/modules/Makefile.modules Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/Makefile.modules Sun Sep 22 11:41:50 2013 -0500 @@ -27,7 +27,7 @@ echo "WARNING: module $(MODULE_NAME) failed to build, deleting"; \ echo "********************************************************"; \ echo ""; \ - make clean; \ + #make clean; \ } -include $(MODULE_DEPS) diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/Makefile.modules.default --- a/modules/Makefile.modules.default Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/Makefile.modules.default Sun Sep 22 11:41:50 2013 -0500 @@ -1,4 +1,4 @@ MODULE_CFLAGS += -I../../src/ -ML_MODULES_STATIC ?= -ML_MODULES_DYNAMIC ?= raw_rec file_man pic_view ettr dual_iso autoexpo arkanoid silent dot_tune +ML_MODULES_STATIC ?= +ML_MODULES_DYNAMIC ?= raw_rec file_man pic_view ettr autoexpo dual_iso arkanoid silent dot_tune mlv_rec diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/adtg_log/adtg_log.c --- a/modules/adtg_log/adtg_log.c Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/adtg_log/adtg_log.c Sun Sep 22 11:41:50 2013 -0500 @@ -1,10 +1,56 @@ /** * */ +// Ram Offset 0xFF9DEF48 +//~ #define ADTG_WRITE_FUNC 0x11644 //"[REG] @@@@@@@@@@@@ Start ADTG[CS:%lx]" +//~ #define CMOS_WRITE_FUNC 0x119CC //"[REG] ############ Start CMOS OC_KICK" +//~ #define CMOS16_WRITE_FUNC 0x11AB8 //"[REG] ############ Start CMOS16 OC_KICK" +//~ #define CARTRIDGE_WRITE_FUNC 0xFF418A80 //CARTRIDGE1_ADDR Adder ==> 0x% -#define ADTG_WRITE_FUNC 0x11644 -#define CMOS_WRITE_FUNC 0x119CC -#define CMOS16_WRITE_FUNC 0x11AB8 +//6D RAM Offset FFCC34E4 +//~ #define ADTG_WRITE_FUNC 0x0 +//#define CMOS_WRITE_FUNC 0x2445C ////"[REG] ############ Start CMOS OC_KICK" +//~ #define CARTRIDGE_WRITE_FUNC 0 +//~ #define ADTG_WRITE_FUNC 0x24108 //"[REG] @@@@@@@@@@@@ Start ADTG[CS:%lx]" +//~ #define CMOS_WRITE_FUNC 0x2420C //"[REG] ############ Start CMOS" +//~ #define CMOS16_WRITE_FUNC 0x24548 //"[REG] ############ Start CMOS16 OC_KICK" +//~ #define CARTRIDGE_WRITE_FUNC 0xFF47A4BC //CARTRIDGE1_ADDR Adder ==> 0x% + +/* +#define CMOS_WRITE_FUNC 0xFFCE76F0 //0x2445C +#define CMOS16_WRITE_FUNC 0xFFCE7A2C //0x24548 +*/ + +// 50D + +//~ #define ADTG_WRITE_FUNC 0xFFA11FDC +//~ #define CMOS_WRITE_FUNC 0xFFA12190 +//~ #define CMOS16_WRITE_FUNC 0 +//~ #define CARTRIDGE_WRITE_FUNC 0 + +//EOSM +//~ #define ADTG_WRITE_FUNC 0x2986C +//~ #define ADTG_WRITE_FUNC 0 +//~ #define CMOS_WRITE_FUNC 0x2998C +//~ #define CMOS_WRITE_FUNC 0x0 +//~ #define CMOS16_WRITE_FUNC 0 +//~ #define CARTRIDGE_WRITE_FUNC 0x0 +//~ #define CARTRIDGE_WRITE_FUNC 0xFF48B0F4 +//~ #define CARTRIDGE_WRITE_FUNC 0xFF48B370 +//~ #define CARTRIDGE_WRITE_FUNC 0xFF48B490 + +//60D +//~ #define ADTG_WRITE_FUNC 0xFF2C9788 //"[REG] @@@@@@@@@@@@ Start ADTG[CS:%lx]" +//~ #define CMOS_WRITE_FUNC 0xFF2C997C //"[REG] ############ Start CMOS" +//~ #define CMOS16_WRITE_FUNC 0x0 //"[REG] ############ Start CMOS16 OC_KICK" +//~ #define CARTRIDGE_WRITE_FUNC 0xFF402884 //CARTRIDGE1_ADDR Adder ==> 0x% + +//7D +#define ADTG_WRITE_FUNC 0xFFA92DFC //"[REG] @@@@@@@@@@@@ Start ADTG[CS:%lx]" +#define CMOS_WRITE_FUNC 0xFFA92F1C //"[REG] ############ Start CMOS" +#define CMOS16_WRITE_FUNC 0x0 //"[REG] ############ Start CMOS16 OC_KICK" +#define CARTRIDGE_WRITE_FUNC 0x0 //CARTRIDGE1_ADDR Adder ==> 0x% + #include #include @@ -13,140 +59,140 @@ #include #include +#include "../trace/trace.h" #include #include -unsigned int hook_calls = 0; +static unsigned int adtg_log_trace_ctx = TRACE_ERROR; +static volatile unsigned int adtg_log_active = 0; -unsigned int *adtg_buf = NULL; -unsigned int adtg_buf_pos = 0; -unsigned int adtg_buf_pos_max = 0; -unsigned int adtg_current_vsync_pos = 0; -unsigned int adtg_last_vsync_pos = 0; - -static uint32_t nrzi_decode( uint32_t in_val ) -{ - uint32_t val = 0; - if (in_val & 0x8000) - val |= 0x8000; - for (int num = 0; num < 31; num++) - { - uint32_t old_bit = (val & 1<<(30-num+1)) >> 1; - val |= old_bit ^ (in_val & 1<<(30-num)); - } - return val; -} unsigned short cmos_regs[8]; static int cmos_delta[8]; +static int adtg_reg_1 = 0; +static int adtg_reg_2 = 0; +static int adtg_reg_3 = 0; +static int adtg_reg_4 = 0; +static int adtg_delta = 0; + +static breakpoint_t *adtg_log_bkpt1 = NULL; +static breakpoint_t *adtg_log_bkpt2 = NULL; +static breakpoint_t *adtg_log_bkpt3 = NULL; +static breakpoint_t *adtg_log_bkpt4 = NULL; + + static void cmos_reg_update(unsigned short cmos_data) { unsigned short reg = (cmos_data >> 12) & 0x07; unsigned short data = cmos_data & 0x0FFF; - cmos_regs[reg] = data; } - +/* static void cmos_reg_manipulate(unsigned short *cmos_data) { unsigned short reg = (*cmos_data >> 12) & 0x07; unsigned short data = *cmos_data & 0x0FFF; - data += cmos_delta[reg]; - *cmos_data = (data & 0x0FFF) | (reg << 12); -} + /* + if(reg == 1) + { + data = 0x800; + } + if(reg == 6) + { + data = 0x370; + } + */ + //~ data += cmos_delta[reg]; + //~ *cmos_data = (data & 0x0FFF) | (reg << 12); + //~ NotifyBox(1000,"CMOS %x", reg); + +//~ } static unsigned int adtg_log_vsync_cbr(unsigned int unused) { - if(!adtg_buf) + if(adtg_log_trace_ctx != TRACE_ERROR) { - return; + trace_write(adtg_log_trace_ctx, "-------- VSYNC --------"); } - - if(adtg_buf_pos + 2 >= adtg_buf_pos_max) - { - return; - } - - adtg_last_vsync_pos = adtg_current_vsync_pos; - adtg_current_vsync_pos = adtg_buf_pos; - - adtg_buf[adtg_buf_pos] = 0xFFFFFFFF; - adtg_buf_pos++; - adtg_buf[adtg_buf_pos] = 0xFFFFFFFF; - adtg_buf_pos++; + return 0; } static void adtg_log(breakpoint_t *bkpt) { - if(!adtg_buf) - { - return; - } - unsigned int cs = bkpt->ctx[0]; unsigned int *data_buf = bkpt->ctx[1]; - void* buf0 = data_buf; + if(adtg_log_trace_ctx != TRACE_ERROR) + { + trace_write(adtg_log_trace_ctx, "ADTG"); + } /* log all ADTG writes */ while(*data_buf != 0xFFFFFFFF) { - if(adtg_buf_pos + 2 >= adtg_buf_pos_max) + unsigned int reg = *data_buf >> 16; + unsigned int data = *data_buf & 0xFFFF; + + if(adtg_log_trace_ctx != TRACE_ERROR) { - return; + trace_write(adtg_log_trace_ctx, " %02X %04X %04X %08X", cs, reg, data, data_buf); } + + /* check if value should get patched */ + unsigned int delta_reg = (adtg_reg_1 << 12) | (adtg_reg_2 << 8) | (adtg_reg_3 << 4) | (adtg_reg_4 << 0); + if(reg == delta_reg) + { + *data_buf = (reg<<16) | ((data + adtg_delta) & 0xFFFF); + } + data_buf++; + } +} -/* shutter override - uint32_t dat = *data_buf; - int reg = dat >> 16; - int val = dat & 0xFFFF; - if (reg == 0x8060) - { - *data_buf = 0x80600479; - NotifyBox(1000, "%x ", buf0); - } -*/ - - adtg_buf[adtg_buf_pos] = cs; - adtg_buf_pos++; - adtg_buf[adtg_buf_pos] = *data_buf; - adtg_buf_pos++; - - data_buf++; +static void cartridge_log(breakpoint_t *bkpt) +{ + if(adtg_log_trace_ctx == TRACE_ERROR) + { + return; + } + trace_write(adtg_log_trace_ctx, "CARTRIDGE %08X %08X", bkpt->ctx[0], bkpt->ctx[1]); + + return; + switch(bkpt->ctx[0]) + { + case 0xC0F10C64: + bkpt->ctx[1] = 0x02B00207; + break; + case 0xC0F10C68: + bkpt->ctx[1] = 0x014C00ED; + break; + case 0xC0F10C6C: + bkpt->ctx[1] = 0x0095005F; + break; + } } static void cmos_log(breakpoint_t *bkpt) { - static int loops = 0; + unsigned short *data_buf = bkpt->ctx[0]; - loops++; - loops &= 0xFFF; - - if(!adtg_buf) + if(adtg_log_trace_ctx != TRACE_ERROR) { - return; + trace_write(adtg_log_trace_ctx, "CMOS"); } - unsigned short *data_buf = bkpt->ctx[0]; - /* log all CMOS writes */ while(*data_buf != 0xFFFF) { - if(adtg_buf_pos + 2 >= adtg_buf_pos_max) + if(adtg_log_trace_ctx != TRACE_ERROR) { - return; + trace_write(adtg_log_trace_ctx, " %02X %04X %08X", *data_buf >> 12, *data_buf & 0x0FFF, data_buf); } - adtg_buf[adtg_buf_pos] = 0x00FF0000; - adtg_buf_pos++; - adtg_buf[adtg_buf_pos] = *data_buf; - adtg_buf_pos++; - cmos_reg_update(*data_buf); - cmos_reg_manipulate(data_buf); - + //~ cmos_reg_update(*data_buf); + //~ cmos_reg_manipulate(data_buf); data_buf++; } } @@ -154,117 +200,58 @@ static void cmos16_log(breakpoint_t *bkpt) { - if(!adtg_buf) + unsigned short *data_buf = bkpt->ctx[0]; + + if(adtg_log_trace_ctx != TRACE_ERROR) { - return; + trace_write(adtg_log_trace_ctx, "CMOS16"); } - hook_calls++; - - unsigned short *data_buf = bkpt->ctx[0]; - /* log all CMOS writes */ while(*data_buf != 0xFFFF) { - if(adtg_buf_pos + 2 >= adtg_buf_pos_max) + if(adtg_log_trace_ctx != TRACE_ERROR) { - return; + trace_write(adtg_log_trace_ctx, " %02X %04X", *data_buf >> 12, *data_buf & 0x0FFF); } - adtg_buf[adtg_buf_pos] = 0xFF000000; - adtg_buf_pos++; - adtg_buf[adtg_buf_pos] = *data_buf; - adtg_buf_pos++; - cmos_reg_update(*data_buf); - cmos_reg_manipulate(data_buf); + //~ cmos_reg_update(*data_buf); + //~ cmos_reg_manipulate(data_buf); data_buf++; } } void adtg_log_task() { - adtg_buf_pos_max = 128 * 1024; - adtg_buf = shoot_malloc(adtg_buf_pos_max * 4 + 0x100); + char filename[100]; + snprintf(filename, sizeof(filename), "%sadtg.txt", MODULE_CARD_DRIVE); + adtg_log_trace_ctx = trace_start("taskmon", filename); + trace_format(adtg_log_trace_ctx, TRACE_FMT_TIME_REL | TRACE_FMT_COMMENT, ' '); - if(!adtg_buf) - { - return; - } - - /* set watchpoints at ADTG and CMOS writes */ - gdb_setup(); - breakpoint_t *bkpt1 = gdb_add_watchpoint(ADTG_WRITE_FUNC, 0, &adtg_log); - breakpoint_t *bkpt2 = gdb_add_watchpoint(CMOS_WRITE_FUNC, 0, &cmos_log); - breakpoint_t *bkpt3 = gdb_add_watchpoint(CMOS16_WRITE_FUNC, 0, &cmos16_log); - + adtg_log_active = 1; /* wait for buffer being filled */ - while(adtg_buf_pos + 2 < adtg_buf_pos_max) + while(adtg_log_active) { - bmp_printf(FONT_MED, 10, 20, "cmos:"); - for(int pos = 0; pos < 8; pos++) + bmp_printf(FONT_MED, 30, 60, "cmos:"); + for(int pos = 0; pos < 8; pos+=2) { - bmp_printf(FONT_MED, 10, 40 + pos * font_med.height, "[%d] 0x%03X ", pos, cmos_regs[pos]); - } - - int x = 200; - int y = 30; - bmp_printf(FONT_MED, x, y-10, "adtg:"); - for (int pos = adtg_last_vsync_pos + 2; pos < adtg_current_vsync_pos; pos += 2) - { - uint32_t dst = adtg_buf[pos]; - uint32_t dat = adtg_buf[pos+1]; - if (dst == 0xFF000000) /* CMOS16 */ - { - } - else if (dst == 0x00FF0000) /* CMOS */ - { - } - else - { - int reg = dat >> 16; - int val = dat & 0xFFFF; - bmp_printf(FONT_SMALL, x, y += font_small.height, - "[ADTG%d] %04X -> %04X (%X)", dst & 0x0F, reg, val, nrzi_decode(val) - ); - if (y > 400) - { - y = 30; - x += 250; - } - } + bmp_printf(FONT_MED, 30, 80 + pos / 2 * font_med.height, "[%d] 0x%03X [%d] 0x%03X", pos, cmos_regs[pos], pos + 1, cmos_regs[pos+1]); } msleep(100); } - beep(); - - /* uninstall watchpoints */ - gdb_delete_bkpt(bkpt1); - gdb_delete_bkpt(bkpt2); - gdb_delete_bkpt(bkpt3); - - /* dump all stuff */ - char filename[100]; - snprintf(filename, sizeof(filename), "%s/adtg.bin", get_dcim_dir()); - FILE* f = FIO_CreateFileEx(filename); - FIO_WriteFile(f, adtg_buf, adtg_buf_pos * 4); - FIO_CloseFile(f); - - /* free buffer */ - void *buf = adtg_buf; - adtg_buf = NULL; - shoot_free(buf); + trace_stop(adtg_log_trace_ctx, 1); } static MENU_SELECT_FUNC(adtg_log_toggle) { - if(!adtg_buf) + if(!adtg_log_active) { task_create("adtg_log_task", 0x1e, 0x1000, adtg_log_task, (void*)0); } else { - adtg_buf_pos_max = adtg_buf_pos; + adtg_log_active = 0; } } @@ -274,11 +261,45 @@ { .name = "ADTG Logging", .select = &adtg_log_toggle, - .priv = &adtg_buf, .max = 1, .help = "Log ADTG writes", .children = (struct menu_entry[]) { { + .name = "adtg_Xxxx", + .priv = &adtg_reg_1, + .edit_mode = EM_MANY_VALUES_LV, + .min = 0, + .max = 8, + }, + { + .name = "adtg_xXxx", + .priv = &adtg_reg_2, + .edit_mode = EM_MANY_VALUES_LV, + .min = 0, + .max = 0x0F, + }, + { + .name = "adtg_xxXx", + .priv = &adtg_reg_3, + .edit_mode = EM_MANY_VALUES_LV, + .min = 0, + .max = 0x0F, + }, + { + .name = "adtg_xxxX", + .priv = &adtg_reg_4, + .edit_mode = EM_MANY_VALUES_LV, + .min = 0, + .max = 0x0F, + }, + { + .name = "adtg_delta", + .priv = &adtg_delta, + .edit_mode = EM_MANY_VALUES_LV, + .min = -1000, + .max = 1000, + }, + { .name = "cmos[0]", .priv = cmos_delta, .edit_mode = EM_MANY_VALUES_LV, @@ -341,12 +362,29 @@ static unsigned int adtg_log_init() { + //EOSM + + //~ MEM(0x0C) = 0xE59FF000; + //~ *(volatile uint32_t *)(0x0C) =0xE59FF000; + + /* set watchpoints at ADTG and CMOS writes */ + gdb_setup(); + adtg_log_bkpt1 = gdb_add_watchpoint(ADTG_WRITE_FUNC, 0, &adtg_log); + adtg_log_bkpt2 = gdb_add_watchpoint(CMOS_WRITE_FUNC, 0, &cmos_log); + adtg_log_bkpt3 = gdb_add_watchpoint(CMOS16_WRITE_FUNC, 0, &cmos16_log); + adtg_log_bkpt4 = gdb_add_watchpoint(CARTRIDGE_WRITE_FUNC, 0, &cartridge_log); + menu_add("Movie", adtg_log_menu, COUNT(adtg_log_menu)); return 0; } static unsigned int adtg_log_deinit() { + /* uninstall watchpoints */ + gdb_delete_bkpt(adtg_log_bkpt1); + gdb_delete_bkpt(adtg_log_bkpt2); + gdb_delete_bkpt(adtg_log_bkpt3); + gdb_delete_bkpt(adtg_log_bkpt4); return 0; } @@ -356,13 +394,13 @@ MODULE_INIT(adtg_log_init) MODULE_DEINIT(adtg_log_deinit) MODULE_INFO_END() - +/* MODULE_STRINGS_START() MODULE_STRING("Description", "ADTG Logging") MODULE_STRING("License", "GPL") MODULE_STRING("Author", "g3gg0") MODULE_STRINGS_END() - +*/ MODULE_CBRS_START() MODULE_CBR(CBR_VSYNC, adtg_log_vsync_cbr, 0) MODULE_CBRS_END() diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/bolt_rec/README.rst --- a/modules/bolt_rec/README.rst Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/bolt_rec/README.rst Sun Sep 22 11:41:50 2013 -0500 @@ -1,10 +1,11 @@ bolt_rec -======== Start video on lightning. - :Author: g3gg0 :License: GPL :Credits: a1ex (raw_rec) :Summary: Start video on lightning +<<<<<<< local +======= :Forum: http://www.magiclantern.fm/forum/index.php?topic=6303.0 +>>>>>>> other diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/bolt_rec/bolt_rec.c --- a/modules/bolt_rec/bolt_rec.c Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/bolt_rec/bolt_rec.c Sun Sep 22 11:41:50 2013 -0500 @@ -39,9 +39,11 @@ #include "raw.h" -#define LOG_ENTRIES 100 -#define MAX_SCANLINES 20 -#define MAX_WIDTH 6000 +#define LOG_ENTRIES 50 +//~ #define MAX_SCANLINES 20 +#define MAX_SCANLINES 5 +//~ #define MAX_WIDTH 6000 +#define MAX_WIDTH 2000 /* interface functions required by raw_rec */ unsigned int raw_rec_cbr_starting(); diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/checkdep.py --- a/modules/checkdep.py Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/checkdep.py Sun Sep 22 11:41:50 2013 -0500 @@ -100,4 +100,4 @@ if not working_cameras: # no cameras working? force dep checking again on next "make" and exit with error os.system("rm " + os.path.join(module, module + ".dep")) - exit(1) + # exit(1) diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/dual_iso/dual_iso.c --- a/modules/dual_iso/dual_iso.c Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/dual_iso/dual_iso.c Sun Sep 22 11:41:50 2013 -0500 @@ -94,6 +94,7 @@ static int is_600d = 0; static int is_650d = 0; static int is_700d = 0; +static int is_eosm = 0; static uint32_t FRAME_CMOS_ISO_START = 0; static uint32_t FRAME_CMOS_ISO_COUNT = 0; @@ -242,7 +243,7 @@ raw &= ~(CMOS_ISO_MASK << (CMOS_FLAG_BITS + CMOS_ISO_BITS)); raw |= (my_iso2 << (CMOS_FLAG_BITS + CMOS_ISO_BITS)); - if (is_650d || is_700d) //TODO: This hack is probably needed on EOSM and 100D + if (is_eosm || is_650d || is_700d) //TODO: This hack is probably needed on EOSM and 100D { raw &= 0x7FF; // Clear the MSB to fix line-skipping. 1 -> 8 lines, 0 -> 4 lines } @@ -843,6 +844,44 @@ CMOS_EXPECTED_FLAG = 3; } + else if (streq(camera_model_short, "EOSM")) + { + is_eosm = 1; + + /* 00 0803 40502516 */ + /* 00 0827 40502538 */ + /* 00 084B 4050255A */ + /* 00 086F 4050257C */ + /* 00 0893 4050259E */ + /* 00 08B7 405025C0 */ + + + FRAME_CMOS_ISO_START = 0x40502516; + FRAME_CMOS_ISO_COUNT = 6; + FRAME_CMOS_ISO_SIZE = 34; + + +/* + 00 0803 4050124C + 00 0827 4050125C + 00 084B 4050126C + 00 086F 4050127C + 00 0893 4050128C + 00 08B7 4050129C +*/ + + PHOTO_CMOS_ISO_START = 0x4050124C; + PHOTO_CMOS_ISO_COUNT = 6; + PHOTO_CMOS_ISO_SIZE = 16; + + CMOS_ISO_BITS = 3; + CMOS_FLAG_BITS = 2; + CMOS_EXPECTED_FLAG = 3; + } + + + + if (FRAME_CMOS_ISO_START || PHOTO_CMOS_ISO_START) { menu_add("Expo", isoless_menu, COUNT(isoless_menu)); diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/ettr/ettr.sym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/ettr/ettr.sym Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,3 @@ +0000274c auto_ettr_export_correction +0000277c auto_ettr_intervalometer_warning +00002818 auto_ettr_intervalometer_wait diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/file_man/file_man.dep --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/file_man/file_man.dep Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,37 @@ +__aeabi_idiv +__aeabi_idivmod +__aeabi_uidiv +beep +big_bmp_printf +bmp_fill +bmp_printf +console_printf +create_named_semaphore +date_format +FIO_CleanupAfterFindNext_maybe +FIO_CloseFile +FIO_CreateFileEx +FIO_FindFirstEx +FIO_FindNextEx +FIO_Open +FIO_ReadFile +FIO_RemoveFile +FIO_WriteFile +get_ms_clock_value +give_semaphore +is_dir +__mem_free +__mem_malloc +memset +menu_add +menu_close_submenu +menu_open_submenu +menu_remove +msleep +snprintf +strcmp +strcpy +streq +strlen +take_semaphore +task_create diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/file_man/file_man.sym --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/file_man/file_man.sym Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,1 @@ +00001d70 fileman_register_type diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/lv_rec/lv_rec.c --- a/modules/lv_rec/lv_rec.c Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/lv_rec/lv_rec.c Sun Sep 22 11:41:50 2013 -0500 @@ -28,6 +28,16 @@ void lv_rec_start(); void lv_rec_stop(); +/* 5D3 hardcoded for now */ +#if defined(CONFIG_5D3) +int (*HPCopyAsync) (unsigned char *dst, unsigned char *src, int length, void (*cbr)(unsigned int), int ctx) = (int (*) (unsigned char *dst, unsigned char *src, int length, void (*cbr)(unsigned int), int ctx))0xCB80; +#elif defined(CONFIG_6D) +int (*HPCopyAsync) (unsigned char *dst, unsigned char *src, int length, void (*cbr)(unsigned int), int ctx) = (int (*) (unsigned char *dst, unsigned char *src, int length, void (*cbr)(unsigned int), int ctx))0xD7AC; +//~ int (*HPCopyAsync) (unsigned char *dst, unsigned char *src, int length, void (*cbr)(unsigned int), int ctx) = (int (*) (unsigned char *dst, unsigned char *src, int length, void (*cbr)(unsigned int), int ctx))0xDAB8; +// Look For DTS Copy Continue First "loc" called. There is a ram ver and rom ver FFCD0C90 D7AC Should Be correct Above MovieRecDMLogEnable +#endif + + unsigned int exmem_clear(struct memSuite * hSuite, char fill); unsigned int exmem_save_buffer(struct memSuite * hSuite, char *file); @@ -145,18 +155,25 @@ void lv_rec_update_resolution(lv_rec_save_data_t *save_data) { if(lv_rec_raw_mode) - { + { + //~ #if defined(CONFIG_5D3) /* hardcoded for now */ /* 5D3: video at 1280x720 -> */ /* 5D3: video at 1920x1080 and 640x480 and photo-LV -> 2080x1318 */ /* 5D3: zoomed at any mode x5/x10 -> 3744x1380 */ /* 5D3: video at 1920x1080 and 640x480 and photo-LV -> 2080x1318, the top 28 lines are black */ - save_data->width = 2080; - save_data->height = 1318; - save_data->topCrop = 28; + //~ save_data->width = 2080; + //~ save_data->height = 1318; + //~ save_data->topCrop = 28; + //~ save_data->bottomCrop = 0; + //~ #elif defined(CONFIG_6D) //Have to Check + save_data->width = 1920; + save_data->height = 1262; + save_data->topCrop = 40; save_data->bottomCrop = 0; - + //~ #endif + /* set raw specific sizes */ save_data->bytesPerLine = (save_data->width * 14) / 8; save_data->frameSizeReal = save_data->bytesPerLine * save_data->height; diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/lv_rec/raw2dng Binary file modules/lv_rec/raw2dng has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/mlv_rec/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/mlv_rec/Makefile Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,77 @@ + +# define the module name - make sure name is max 8 characters +MODULE_NAME=mlv_rec +MODULE_OBJS=mlv_rec.o mlv.o + +# include modules environment +include ../Makefile.modules + + +MINGW=i686-w64-mingw32 +MINGW_GCC=$(MINGW)-gcc +MINGW_AR=$(MINGW)-ar + +# large file support +# get them with $(shell getconf LFS_CFLAGS) +LFS_FLAGS=-DLARGEFILES -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +MLV_CFLAGS=-DMLV_USE_LZMA -Wpadded -mno-ms-bitfields -std=c99 -m32 -O2 -Wall $(LFS_FLAGS) -I$(SRC_DIR) + +# LZMA library flags +LZMA_DIR=lzma/ +LZMA_CFLAGS=-c -O2 -Wall -c +LZMA_INC=-I$(LZMA_DIR) +LZMA_LIB=$(LZMA_DIR)lib7z.a +LZMA_LIB_MINGW=$(LZMA_DIR)lib7z.w32.a +# linux version doesnt support multi threading? +LZMA_OBJS=$(LZMA_DIR)7zAlloc.host.o $(LZMA_DIR)7zBuf.host.o $(LZMA_DIR)7zBuf2.host.o $(LZMA_DIR)7zCrc.host.o $(LZMA_DIR)7zCrcOpt.host.o $(LZMA_DIR)7zDec.host.o $(LZMA_DIR)7zFile.host.o $(LZMA_DIR)7zIn.host.o $(LZMA_DIR)7zStream.host.o $(LZMA_DIR)Alloc.host.o $(LZMA_DIR)Bcj2.host.o $(LZMA_DIR)Bra.host.o $(LZMA_DIR)Bra86.host.o $(LZMA_DIR)BraIA64.host.o $(LZMA_DIR)CpuArch.host.o $(LZMA_DIR)Delta.host.o $(LZMA_DIR)LzFind.host.o $(LZMA_DIR)Lzma2Dec.host.o $(LZMA_DIR)Lzma2Enc.host.o $(LZMA_DIR)Lzma86Dec.host.o $(LZMA_DIR)Lzma86Enc.host.o $(LZMA_DIR)LzmaDec.host.o $(LZMA_DIR)LzmaEnc.host.o $(LZMA_DIR)LzmaLib.host.o $(LZMA_DIR)Ppmd7.host.o $(LZMA_DIR)Ppmd7Dec.host.o $(LZMA_DIR)Ppmd7Enc.host.o $(LZMA_DIR)Sha256.host.o $(LZMA_DIR)Xz.host.o $(LZMA_DIR)XzCrc64.host.o +LZMA_OBJS_MINGW=$(LZMA_DIR)Threads.w32.o $(LZMA_DIR)LzFindMt.w32.o $(LZMA_DIR)MtCoder.w32.o $(LZMA_DIR)7zAlloc.w32.o $(LZMA_DIR)7zBuf.w32.o $(LZMA_DIR)7zBuf2.w32.o $(LZMA_DIR)7zCrc.w32.o $(LZMA_DIR)7zCrcOpt.w32.o $(LZMA_DIR)7zDec.w32.o $(LZMA_DIR)7zFile.w32.o $(LZMA_DIR)7zIn.w32.o $(LZMA_DIR)7zStream.w32.o $(LZMA_DIR)Alloc.w32.o $(LZMA_DIR)Bcj2.w32.o $(LZMA_DIR)Bra.w32.o $(LZMA_DIR)Bra86.w32.o $(LZMA_DIR)BraIA64.w32.o $(LZMA_DIR)CpuArch.w32.o $(LZMA_DIR)Delta.w32.o $(LZMA_DIR)LzFind.w32.o $(LZMA_DIR)Lzma2Dec.w32.o $(LZMA_DIR)Lzma2Enc.w32.o $(LZMA_DIR)Lzma86Dec.w32.o $(LZMA_DIR)Lzma86Enc.w32.o $(LZMA_DIR)LzmaDec.w32.o $(LZMA_DIR)LzmaEnc.w32.o $(LZMA_DIR)LzmaLib.w32.o $(LZMA_DIR)Ppmd7.w32.o $(LZMA_DIR)Ppmd7Dec.w32.o $(LZMA_DIR)Ppmd7Enc.w32.o $(LZMA_DIR)Sha256.w32.o $(LZMA_DIR)Xz.w32.o $(LZMA_DIR)XzCrc64.w32.o + + + +all:: raw2dng mlv_dump + +clean:: + $(call rm_files, raw2dng mlv_dump $(LZMA_OBJS) $(LZMA_LIB) $(LZMA_OBJS_MINGW) $(LZMA_LIB_MINGW) ) + +# RAW to DNG converter for PC +raw2dng: $(SRC_DIR)/chdk-dng.c ../lv_rec/raw2dng.c + $(call build,GCC,gcc -c $(SRC_DIR)/chdk-dng.c -m32 -O2 -Wall -I$(SRC_DIR)) + $(call build,GCC,gcc -c ../lv_rec/raw2dng.c -m32 -O2 -Wall -I$(SRC_DIR) -D_FILE_OFFSET_BITS=64) + $(call build,GCC,gcc raw2dng.o chdk-dng.o -o raw2dng -lm -m32) + +raw2dng.exe: $(SRC_DIR)/chdk-dng.c ../lv_rec/raw2dng.c + $(call build,MINGW-GCC,$(MINGW_GCC) -c $(SRC_DIR)/chdk-dng.c -m32 -mno-ms-bitfields -O2 -Wall -I$(SRC_DIR)) + $(call build,MINGW-GCC,$(MINGW_GCC) -c ../lv_rec/raw2dng.c -m32 -mno-ms-bitfields -O2 -Wall -I$(SRC_DIR) -D_FILE_OFFSET_BITS=64) + $(call build,MINGW-GCC,$(MINGW_GCC) raw2dng.o chdk-dng.o -o raw2dng.exe -lm -m32) + +# debug tool +dng2raw: dng2raw.c + $(call build,GCC,gcc dng2raw.c -m32 -O2 -Wall -I$(SRC_DIR)) -o dng2raw + +# +# rules for host and win32 objects +# +%.host.o: %.c + gcc $(LZMA_CFLAGS) -D_7ZIP_ST -mno-ms-bitfields -o $@ $< + +%.w32.o: %.c + $(MINGW_GCC) $(LZMA_CFLAGS) -D_7ZIP_MT -mno-ms-bitfields -o $@ $< + +# +# create static LZMA library +# +$(LZMA_LIB): $(LZMA_OBJS) + ar -q $@ $(LZMA_OBJS) + +$(LZMA_LIB_MINGW): $(LZMA_OBJS_MINGW) + $(MINGW_AR) -q $@ $(LZMA_OBJS_MINGW) + +# +# mlv_dump rules +# +mlv_dump: $(LZMA_LIB) mlv_dump.c + $(call build,GCC,gcc -o $@ mlv_dump.c $(LZMA_LIB) $(LZMA_INC) $(MLV_CFLAGS)) + +mlv_dump.exe: $(LZMA_LIB_MINGW) mlv_dump.c + $(call build,MINGW-GCC,$(MINGW_GCC) -o $@ mlv_dump.c $(LZMA_LIB_MINGW) $(LZMA_INC) $(MLV_CFLAGS)) + diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/mlv_rec/dng2raw.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/mlv_rec/dng2raw.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,204 @@ +/* + * Copyright (C) 2013 Magic Lantern Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "stdio.h" +#include "stdlib.h" +#include "string.h" + +#include "../lv_rec/lv_rec.h" +#include + +#define T_BYTE 1 +#define T_ASCII 2 +#define T_SHORT 3 +#define T_LONG 4 +#define T_RATIONAL 5 +#define T_SBYTE 6 +#define T_UNDEFINED 7 +#define T_SSHORT 8 +#define T_SLONG 9 +#define T_SRATIONAL 10 +#define T_FLOAT 11 +#define T_DOUBLE 12 + +lv_rec_file_footer_t lv_rec_footer; + + //~ { "Canon EOS 5D Mark III", 0, 0x3c80, + //~ { 6722,-635,-963,-4287,12460,2028,-908,2162,5668 } }, + #define CAM_COLORMATRIX1 \ + 6722, 10000, -635, 10000, -963, 10000, \ + -4287, 10000, 12460, 10000, 2028, 10000, \ + -908, 10000, 2162, 10000, 5668, 10000 + +struct raw_info raw_info = { + .api_version = 1, + .bits_per_pixel = 14, + .black_level = 1024, + .white_level = 13000, + .cfa_pattern = 0x02010100, // Red Green Green Blue + .calibration_illuminant1 = 1, // Daylight + .color_matrix1 = {CAM_COLORMATRIX1},// camera-specific, from dcraw.c + .dynamic_range = 1100, // not correct; use numbers from DxO instead +}; + +int parse_ifd(int id, char* buf, int off) +{ + int entries = *(short*)(buf+off); off += 2; + printf("ifd %d: (%d)\n", id, entries); + int imagetype = -1; + int i; + for (i = 0; i < entries; i++) + { + unsigned int tag = *(unsigned short*)(buf+off); off += 2; + unsigned int type = *(unsigned short*)(buf+off); off += 2; (void)type; + unsigned int count = *(unsigned int*)(buf+off); off += 4; (void)count; + unsigned int data = *(unsigned int*)(buf+off); off += 4; + //~ printf("%x %x %x %d\n", tag, type, count, data); + + switch (tag) + { + case 0xFE: /* NewSubFileType */ + imagetype = data; + break; + + case 0x14A: /* SubIFD */ + printf("subifd: %x\n", data); + parse_ifd(id+10, buf, data); + break; + } + + if (imagetype == 0) /* NewSubFileType: Main Image */ + { + switch (tag) + { + case 0x100: /* ImageWidth */ + printf("width: %d\n", data); + raw_info.width = data; + break; + case 0x101: /* ImageLength */ + printf("height: %d\n", data); + raw_info.height = data; + break; + case 0x111: /* StripOffset */ + printf("buffer offset: %d\n", data); + raw_info.buffer = buf + data; + break; + case 0xC61A: /* BlackLevel */ + printf("black: %d\n", data); + raw_info.black_level = data; + break; + case 0xC61D: /* WhiteLevel */ + printf("white: %d\n", data); + raw_info.white_level = data; + break; + case 0xC68D: /* active area */ + { + int* area = (void*)buf + data; + printf("crop: %d %d %d %d\n", area[0], area[1], area[2], area[3]); + memcpy(&raw_info.active_area, area, 4 * 4); + break; + } + } + } + } + unsigned int next = *(unsigned int*)(buf+off); off += 4; + return next; +} + +static void reverse_bytes_order(char* buf, int count) +{ + short* buf16 = (short*) buf; + int i; + for (i = 0; i < count/2; i++) + { + short x = buf16[i]; + buf[2*i+1] = x; + buf[2*i] = x >> 8; + } +} + +void raw_set_geometry(int width, int height, int skip_left, int skip_right, int skip_top, int skip_bottom) +{ + raw_info.width = width; + raw_info.height = height; + raw_info.pitch = raw_info.width * 14 / 8; + raw_info.frame_size = raw_info.height * raw_info.pitch; + raw_info.active_area.x1 = skip_left; + raw_info.active_area.y1 = skip_top; + raw_info.active_area.x2 = raw_info.width - skip_right; + raw_info.active_area.y2 = raw_info.height - skip_bottom; + raw_info.jpeg.x = 0; + raw_info.jpeg.y = 0; + raw_info.jpeg.width = raw_info.width - skip_left - skip_right; + raw_info.jpeg.height = raw_info.height - skip_top - skip_bottom; +} + +int main(int argc, char** argv) +{ + FILE* fi = fopen(argv[1], "rb"); + if (!fi) perror(argv[1]); + fseek(fi, 0, SEEK_END); + int size = ftell(fi); + fseek(fi, 0, SEEK_SET); + char* buf = malloc(size); + printf("reading %s (size=%d)\n", argv[1], size); + int br = fread(buf, 1, size, fi); + printf("read %d\n", br); + if (!buf) perror("malloc"); + + //~ short* buf16 = (short*) buf; + int* buf32 = (int*) buf; + + if (buf32[0] != 0x002A4949 && buf32[1] != 0x00000008) + perror("not a chdk dng"); + + int off = 8; + int ifd; + for (ifd = 0; off; ifd++) + { + off = parse_ifd(ifd, buf, off); + } + + raw_set_geometry(raw_info.width, raw_info.height, raw_info.active_area.x1, raw_info.active_area.y1, raw_info.width - raw_info.active_area.x2, raw_info.height - raw_info.active_area.y2); + + raw_info.api_version = 1; + strncpy((char*)lv_rec_footer.magic, "RAWM", 4); + lv_rec_footer.raw_info = raw_info; + lv_rec_footer.xRes = raw_info.width; + lv_rec_footer.yRes = raw_info.height; + lv_rec_footer.frameSize = raw_info.frame_size; + lv_rec_footer.frameCount = 1; + + int len = strlen(argv[1]); + argv[1][len-3] = 'R'; + argv[1][len-2] = 'A'; + argv[1][len-1] = 'W'; + + reverse_bytes_order(raw_info.buffer, raw_info.frame_size); + + printf("writing %s\n", argv[1]); + FILE* fo = fopen(argv[1], "wb"); + fwrite(raw_info.buffer, 1, raw_info.frame_size, fo); + fwrite(&lv_rec_footer, 1, sizeof(lv_rec_footer), fo); + fclose(fo); + return 0; +} + + diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/mlv_rec/mlv.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/mlv_rec/mlv.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,244 @@ +/* + * Copyright (C) 2013 Magic Lantern Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include "raw.h" +#include "mlv.h" +#include "../trace/trace.h" + +//~ extern uint32_t raw_rec_trace_ctx; + +extern uint64_t get_us_clock_value(); +extern char *strcpy(char *dest, const char *src); +extern char *strncpy(char *dest, const char *src, int n); +extern const char* get_picstyle_name(int raw_picstyle); + +extern struct prop_picstyle_settings picstyle_settings[]; + +extern int WEAK_FUNC(own_PROPAD_GetPropertyData) PROPAD_GetPropertyData(uint32_t property, void** addr, size_t* len); + +static int own_PROPAD_GetPropertyData(uint32_t property, void** addr, size_t* len) +{ + //~ trace_write(raw_rec_trace_ctx, "WARNING: This model doesn't have 'PROPAD_GetPropertyData' defined. Reading properties not possible."); + return 1; +} + +void mlv_fill_lens(mlv_lens_hdr_t *hdr, uint64_t start_timestamp) +{ + /* prepare header */ + mlv_set_type((mlv_hdr_t *)hdr, "LENS"); + mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp); + hdr->blockSize = sizeof(mlv_lens_hdr_t); + + hdr->focalLength = lens_info.focal_len; + hdr->focalDist = lens_info.focus_dist; + hdr->aperture = lens_info.aperture * 10; + hdr->stabilizerMode = lens_info.IS; + hdr->lensID = lens_info.lens_id; + hdr->autofocusMode = 0; + hdr->flags = 0; + + strncpy((char *)hdr->lensName, lens_info.name, 32); + strncpy((char *)hdr->lensSerial, "", 32); +} + +void mlv_fill_wbal(mlv_wbal_hdr_t *hdr, uint64_t start_timestamp) +{ + /* prepare header */ + mlv_set_type((mlv_hdr_t *)hdr, "WBAL"); + mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp); + hdr->blockSize = sizeof(mlv_wbal_hdr_t); + + hdr->wb_mode = lens_info.wb_mode; + hdr->kelvin = lens_info.kelvin; + hdr->wbgain_r = lens_info.WBGain_R; + hdr->wbgain_g = lens_info.WBGain_G; + hdr->wbgain_b = lens_info.WBGain_G; + hdr->wbs_gm = lens_info.wbs_gm; + hdr->wbs_ba = lens_info.wbs_ba; +} + +void mlv_fill_styl(mlv_styl_hdr_t *hdr, uint64_t start_timestamp) +{ + /* prepare header */ + mlv_set_type((mlv_hdr_t *)hdr, "STYL"); + mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp); + hdr->blockSize = sizeof(mlv_styl_hdr_t); + + hdr->picStyleId = lens_info.raw_picstyle; + hdr->contrast = picstyle_settings[lens_info.picstyle].contrast; + hdr->sharpness = picstyle_settings[lens_info.picstyle].sharpness; + hdr->saturation = picstyle_settings[lens_info.picstyle].saturation; + hdr->colortone = picstyle_settings[lens_info.picstyle].color_tone; + + strncpy((char *)hdr->picStyleName, get_picstyle_name(lens_info.raw_picstyle), sizeof(hdr->picStyleName)); +} + +void mlv_fill_expo(mlv_expo_hdr_t *hdr, uint64_t start_timestamp) +{ + /* prepare header */ + mlv_set_type((mlv_hdr_t *)hdr, "EXPO"); + mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp); + hdr->blockSize = sizeof(mlv_expo_hdr_t); + + /* iso is zero when auto-iso is enabled */ + if(lens_info.iso == 0) + { + hdr->isoMode = 1; + hdr->isoValue = lens_info.iso_auto; + } + else + { + hdr->isoMode = 0; + hdr->isoValue = lens_info.iso; + } + hdr->isoAnalog = lens_info.iso_analog_raw; + hdr->digitalGain = lens_info.iso_digital_ev; + hdr->shutterValue = (uint32_t)(1000.0f * (1000000.0f / (float)get_current_shutter_reciprocal_x1000())); +} + +void mlv_fill_rtci(mlv_rtci_hdr_t *hdr, uint64_t start_timestamp) +{ + struct tm now; + memset(&now, 0x00, sizeof(struct tm)); + + /* prepare header */ + mlv_set_type((mlv_hdr_t *)hdr, "RTCI"); + mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp); + hdr->blockSize = sizeof(mlv_rtci_hdr_t); + + /* get calendar time from real time clock */ + LoadCalendarFromRTC(&now); + + hdr->tm_sec = now.tm_sec; + hdr->tm_min = now.tm_min; + hdr->tm_hour = now.tm_hour; + hdr->tm_mday = now.tm_mday; + hdr->tm_mon = now.tm_mon; + hdr->tm_year = now.tm_year; + hdr->tm_wday = now.tm_wday; + hdr->tm_yday = now.tm_yday; + hdr->tm_isdst = now.tm_isdst; + hdr->tm_gmtoff = now.tm_gmtoff; + + memset(hdr->tm_zone, 0x00, 8); + strncpy((char *)hdr->tm_zone, now.tm_zone, 8); +} + +void mlv_fill_idnt(mlv_idnt_hdr_t *hdr, uint64_t start_timestamp) +{ + char *model_data = NULL; + uint64_t *body_data = NULL; + size_t model_len = 0; + size_t body_len = 0; + int err = 0; + + /* prepare header */ + mlv_set_type((mlv_hdr_t *)hdr, "IDNT"); + mlv_set_timestamp((mlv_hdr_t *)hdr, start_timestamp); + hdr->blockSize = sizeof(mlv_idnt_hdr_t); + + /* default values */ + hdr->cameraName[0] = '\000'; + hdr->cameraSerial[0] = '\000'; + hdr->cameraModel = 0; + + /* get camera properties */ + err |= PROPAD_GetPropertyData(PROP_CAM_MODEL, (void **) &model_data, &model_len); + //~ trace_write(raw_rec_trace_ctx, "[IDNT] err: %d model_data: 0x%08X model_len: %d", err, model_data, model_len); + + err |= PROPAD_GetPropertyData(PROP_BODY_ID, (void **) &body_data, &body_len); + //~ trace_write(raw_rec_trace_ctx, "[IDNT] err: %d body_data: 0x%08X body_len: %d", err, body_data, body_len); + + if(err || model_len < 36 || body_len != 8 || !model_data || !body_data) + { + strcpy((char*)hdr->cameraName, "Failed to get properties."); + return; + } + + /* properties are ok, so read data */ + memcpy((char *)hdr->cameraName, &model_data[0], 32); + memcpy((char *)&hdr->cameraModel, &model_data[32], 4); + snprintf((char *)hdr->cameraSerial, sizeof(hdr->cameraSerial), "%X%08X", (uint32_t)(*body_data & 0xFFFFFFFF), (uint32_t) (*body_data >> 32)); + + //~ trace_write(raw_rec_trace_ctx, "[IDNT] cameraName: '%s' cameraModel: 0x%08X cameraSerial: '%s'", hdr->cameraName, hdr->cameraModel, hdr->cameraSerial); +} + +uint64_t mlv_prng_lfsr(uint64_t value) +{ + uint64_t lfsr = value; + int max_clocks = 512; + + for(int clocks = 0; clocks < max_clocks; clocks++) + { + /* maximum length LFSR according to http://www.xilinx.com/support/documentation/application_notes/xapp052.pdf */ + int bit = ((lfsr >> 63) ^ (lfsr >> 62) ^ (lfsr >> 60) ^ (lfsr >> 59)) & 1; + lfsr = (lfsr << 1) | bit; + } + + return lfsr; +} + +uint64_t mlv_generate_guid() +{ + struct tm now; + uint64_t guid = get_us_clock_value(); + LoadCalendarFromRTC(&now); + + /* now run through prng once to shuffle bits */ + guid = mlv_prng_lfsr(guid); + + /* then seed shuffled bits with rtc time */ + guid ^= now.tm_sec; + guid ^= now.tm_min << 7; + guid ^= now.tm_hour << 12; + guid ^= now.tm_yday << 17; + guid ^= now.tm_year << 26; + guid ^= get_us_clock_value() << 37; + + /* now run through final prng pass */ + return mlv_prng_lfsr(guid); +} + +void mlv_init_fileheader(mlv_file_hdr_t *hdr) +{ + mlv_set_type((mlv_hdr_t*)hdr, "MLVI"); + hdr->blockSize = sizeof(mlv_file_hdr_t); + strncpy((char*)hdr->versionString, MLV_VERSION_STRING, sizeof(hdr->versionString)); +} + +void mlv_set_type(mlv_hdr_t *hdr, char *type) +{ + memcpy(hdr->blockType, type, 4); +} + +uint64_t mlv_set_timestamp(mlv_hdr_t *hdr, uint64_t start) +{ + uint64_t timestamp = get_us_clock_value(); + + if(hdr) + { + hdr->timestamp = timestamp - start; + } + return timestamp; +} diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/mlv_rec/mlv.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/mlv_rec/mlv.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,260 @@ +/* + * Copyright (C) 2013 Magic Lantern Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _mlv_h_ +#define _mlv_h_ + +#define MLV_VERSION_STRING "v2.0" +#define MLV_VIDEO_CLASS_RAW 0x01 +#define MLV_VIDEO_CLASS_YUV 0x02 +#define MLV_VIDEO_CLASS_JPEG 0x03 +#define MLV_VIDEO_CLASS_H264 0x04 + +#define MLV_VIDEO_CLASS_FLAG_LZMA 0x80 +#define MLV_VIDEO_CLASS_FLAG_DELTA 0x40 + +#define MLV_AUDIO_CLASS_FLAG_LZMA 0x80 + +#if defined(PACKED) +#undef PACKED +#endif + +#pragma pack(push,0) +#ifdef WIN32 +#define PACKED __attribute__ ((gcc_struct, __packed__)) +#else +#define PACKED __attribute__ ((__packed__)) +#endif + +typedef struct { + uint8_t blockType[4]; + uint32_t blockSize; + uint64_t timestamp; +} PACKED mlv_hdr_t; + +typedef struct { + uint8_t fileMagic[4]; /* Magic Lantern Video file header */ + uint32_t blockSize; /* size of the whole header */ + uint8_t versionString[8]; /* null-terminated C-string of the exact revision of this format */ + uint64_t fileGuid; /* UID of the file (group) generated using hw counter, time of day and PRNG */ + uint16_t fileNum; /* the ID within fileCount this file has (0 to fileCount-1) */ + uint16_t fileCount; /* how many files belong to this group (splitting or parallel) */ + uint32_t fileFlags; /* 1=out-of-order data, 2=dropped frames, 4=single image mode, 8=stopped due to error */ + uint16_t videoClass; /* 0=none, 1=RAW, 2=YUV, 3=JPEG, 4=H.264 */ + uint16_t audioClass; /* 0=none, 1=WAV */ + uint32_t videoFrameCount; /* number of video frames in this file. set to 0 on start, updated when finished. */ + uint32_t audioFrameCount; /* number of audio frames in this file. set to 0 on start, updated when finished. */ + uint32_t sourceFpsNom; /* configured fps in 1/s multiplied by sourceFpsDenom */ + uint32_t sourceFpsDenom; /* denominator for fps. usually set to 1000, but may be 1001 for NTSC */ +} PACKED mlv_file_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* this block contains one frame of video data */ + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint32_t frameNumber; /* unique video frame number */ + uint16_t cropPosX; /* specifies from which sensor row/col the video frame was copied (8x2 blocks) */ + uint16_t cropPosY; /* (can be used to process dead/hot pixels) */ + uint16_t panPosX; /* specifies the panning offset which is cropPos, but with higher resolution (1x1 blocks) */ + uint16_t panPosY; /* (it's the frame area from sensor the user wants to see) */ + uint32_t frameSpace; /* size of dummy data before frameData starts, necessary for EDMAC alignment */ + /* uint8_t frameData[variable] */; +} PACKED mlv_vidf_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* this block contains audio data */ + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint32_t frameNumber; /* unique audio frame number */ + uint32_t frameSpace; /* size of dummy data before frameData starts, necessary for EDMAC alignment */ + /* uint8_t frameData[variable] */; +} PACKED mlv_audf_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* when videoClass is RAW, this block will contain detailed format information */ + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint16_t xRes; /* Configured video resolution, may differ from payload resolution */ + uint16_t yRes; /* Configured video resolution, may differ from payload resolution */ + struct raw_info raw_info; /* the raw_info structure delivered by raw.c of ML Core */ +} PACKED mlv_rawi_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* when audioClass is WAV, this block contains format details compatible to RIFF */ + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint16_t format; /* 1=Integer PCM, 6=alaw, 7=mulaw */ + uint16_t channels; /* audio channel count: 1=mono, 2=stereo */ + uint32_t samplingRate; /* audio sampling rate in 1/s */ + uint32_t bytesPerSecond; /* audio data rate */ + uint16_t blockAlign; /* see RIFF WAV hdr description */ + uint16_t bitsPerSample; /* audio ADC resolution */ +} PACKED mlv_wavi_hdr_t; + +typedef struct { + uint8_t blockType[4]; + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint32_t isoMode; /* 0=manual, 1=auto */ + uint32_t isoValue; /* camera delivered ISO value */ + uint32_t isoAnalog; /* ISO obtained by hardware amplification (most full-stop ISOs, except extreme values) */ + uint32_t digitalGain; /* digital ISO gain (1024 = 1 EV) - it's not baked in the raw data, so you may want to scale it or adjust the white level */ + uint64_t shutterValue; /* exposure time in microseconds */ +} PACKED mlv_expo_hdr_t; + +typedef struct { + uint8_t blockType[4]; + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint16_t focalLength; /* in mm */ + uint16_t focalDist; /* in mm (65535 = infinite) */ + uint16_t aperture; /* f-number * 100 */ + uint8_t stabilizerMode; /* 0=off, 1=on, (is the new L mode relevant) */ + uint8_t autofocusMode; /* 0=off, 1=on */ + uint32_t flags; /* 1=CA avail, 2=Vign avail, ... */ + uint32_t lensID; /* hexadecimal lens ID (delivered by properties?) */ + uint8_t lensName[32]; /* full lens string */ + uint8_t lensSerial[32]; /* full lens serial number */ +} PACKED mlv_lens_hdr_t; + +typedef struct { + uint8_t blockType[4]; + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint16_t tm_sec; /* seconds (0-59) */ + uint16_t tm_min; /* minute (0-59) */ + uint16_t tm_hour; /* hour (0-24) */ + uint16_t tm_mday; /* day of month (1-31) */ + uint16_t tm_mon; /* month (1-12) */ + uint16_t tm_year; /* year */ + uint16_t tm_wday; /* day of week */ + uint16_t tm_yday; /* day of year */ + uint16_t tm_isdst; /* daylight saving */ + uint16_t tm_gmtoff; /* GMT offset */ + uint8_t tm_zone[8]; /* time zone string */ +} PACKED mlv_rtci_hdr_t; + +typedef struct { + uint8_t blockType[4]; + uint32_t blockSize; /* total frame size */ + uint64_t timestamp; /* hardware counter timestamp for this frame (relative to recording start) */ + uint8_t cameraName[32]; /* PROP (0x00000002), offset 0, length 32 */ + uint32_t cameraModel; /* PROP (0x00000002), offset 32, length 4 */ + uint8_t cameraSerial[32]; /* Camera serial number (if available) */ +} PACKED mlv_idnt_hdr_t; + +typedef struct { + uint16_t fileNumber; /* the logical file number as specified in header */ + uint16_t empty; /* for future use. set to zero. */ + uint64_t frameOffset; /* the file offset at which the frame is stored (VIDF/AUDF) */ +} PACKED mlv_xref_t; + +typedef struct { + uint8_t blockType[4]; /* can be added in post processing when out of order data is present */ + uint32_t blockSize; /* this can also be placed in a separate file with only file header plus this block */ + uint64_t timestamp; + uint32_t frameType; /* bitmask: 1=video, 2=audio */ + uint32_t entryCount; /* number of xrefs that follow here */ + mlv_xref_t xrefEntries; /* this structure refers to the n'th video/audio frame offset in the files */ + /* uint8_t xrefData[variable] */; +} PACKED mlv_xref_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* user definable info string. take number, location, etc. */ + uint32_t blockSize; + uint64_t timestamp; + /* uint8_t stringData[variable] */; +} PACKED mlv_info_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* Dual-ISO information */ + uint32_t blockSize; + uint64_t timestamp; + uint32_t dualMode; /* bitmask: 0=off, 1=odd lines, 2=even lines, upper bits may be defined later */ + uint32_t isoValue; +} PACKED mlv_diso_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* markers set by user while recording */ + uint32_t blockSize; + uint64_t timestamp; + uint32_t type; /* value may depend on the button being pressed or counts up (t.b.d) */ +} PACKED mlv_mark_hdr_t; + +typedef struct { + uint8_t blockType[4]; + uint32_t blockSize; + uint64_t timestamp; + uint32_t picStyleId; + int32_t contrast; + int32_t sharpness; + int32_t saturation; + int32_t colortone; + uint8_t picStyleName[16]; +} PACKED mlv_styl_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* Electronic level (orientation) data */ + uint32_t blockSize; + uint64_t timestamp; + uint32_t roll; /* degrees x100 (here, 45.00 degrees) */ + uint32_t pitch; /* 10.00 degrees */ +} PACKED mlv_elvl_hdr_t; + +typedef struct { + uint8_t blockType[4]; /* White balance info */ + uint32_t blockSize; + uint64_t timestamp; + uint32_t wb_mode; /* WB_AUTO 0, WB_SUNNY 1, WB_SHADE 8, WB_CLOUDY 2, WB_TUNGSTEN 3, WB_FLUORESCENT 4, WB_FLASH 5, WB_CUSTOM 6, WB_KELVIN 9 */ + uint32_t kelvin; /* only when wb_mode is WB_KELVIN */ + uint32_t wbgain_r; /* only when wb_mode is WB_CUSTOM */ + uint32_t wbgain_g; /* 1024 = 1.0 */ + uint32_t wbgain_b; /* note: it's 1/canon_gain (uses dcraw convention) */ + uint32_t wbs_gm; /* WBShift (no idea how to use these in post) */ + uint32_t wbs_ba; /* range: -9...9 */ +} PACKED mlv_wbal_hdr_t; + +#pragma pack(pop) + +/* helper routines for filling structures from generic camera information */ +void mlv_fill_rtci(mlv_rtci_hdr_t *hdr, uint64_t start_timestamp); +void mlv_fill_expo(mlv_expo_hdr_t *hdr, uint64_t start_timestamp); +void mlv_fill_lens(mlv_lens_hdr_t *hdr, uint64_t start_timestamp); +void mlv_fill_idnt(mlv_idnt_hdr_t *hdr, uint64_t start_timestamp); +void mlv_fill_wbal(mlv_wbal_hdr_t *hdr, uint64_t start_timestamp); + + +/* randomize the 64 bits passed in parameter using LFSR */ +uint64_t mlv_prng_lfsr(uint64_t value); + +/* generate a 64 bit random number based on time of day and camera uptime */ +uint64_t mlv_generate_guid(); + +/* fill file header with constant stuff */ +void mlv_init_fileheader(mlv_file_hdr_t *hdr); + +/* set the block type of a block. cares for string lengths. */ +void mlv_set_type(mlv_hdr_t *hdr, char *type); + +/* if hdr is non-null, set the timestamp field with the time since start (has to be passed as parameter). + returns current time since start. */ +uint64_t mlv_set_timestamp(mlv_hdr_t *hdr, uint64_t start); + +#endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/mlv_rec/mlv_dump.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/mlv_rec/mlv_dump.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,1858 @@ +/* + * Copyright (C) 2013 Magic Lantern Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +/* system includes */ +#include +#include +#include +#include +#include +#include + +/* some compile warning, why? */ +char *strdup(const char *s); + +//#define MLV_USE_LZMA + +#ifdef MLV_USE_LZMA +#include +#endif + +/* project includes */ +#include "../lv_rec/lv_rec.h" +#include "../../src/raw.h" +#include "mlv.h" + +/* helper macros */ +#define MAX(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a > _b ? _a : _b; }) + + +#define MIN(a,b) \ + ({ __typeof__ (a) _a = (a); \ + __typeof__ (b) _b = (b); \ + _a < _b ? _a : _b; }) + +#define COERCE(val,min,max) MIN(MAX((value),(min)),(max)) + +/* this structure is used to build the mlv_xref_t table */ +typedef struct +{ + uint64_t frameTime; + uint64_t frameOffset; + uint32_t fileNumber; +} frame_xref_t; + + + + + +void xref_resize(frame_xref_t **table, int entries, int *allocated) +{ + /* make sure there is no crappy pointer before using */ + if(*allocated == 0) + { + *table = NULL; + } + + /* only resize if the buffer is too small */ + if(entries * sizeof(frame_xref_t) > *allocated) + { + *allocated += (entries + 1) * sizeof(frame_xref_t); + *table = realloc(*table, *allocated); + } +} + +void xref_sort(frame_xref_t *table, int entries) +{ + int n = entries; + do + { + int newn = 1; + for (int i = 0; i < n-1; ++i) + { + if (table[i].frameTime > table[i+1].frameTime) + { + frame_xref_t tmp = table[i+1]; + table[i+1] = table[i]; + table[i] = tmp; + newn = i + 1; + } + } + n = newn; + } while (n > 1); +} + +void bitinsert(uint16_t *dst, int position, int depth, uint16_t new_value) +{ + uint16_t old_value = 0; + int dst_pos = position * depth / 16; + int bits_to_left = ((depth * position) - (16 * dst_pos)) % 16; + int shift_right = 16 - depth - bits_to_left; + + old_value = dst[dst_pos]; + if(shift_right >= 0) + { + /* this case is a bit simpler. the word fits into this uint16_t */ + uint16_t mask = ((1<> (-shift_right)) & mask1; + dst[dst_pos] = old_value; + + /* write the lower bits */ + old_value = dst[dst_pos + 1]; + old_value &= ~mask2; + old_value |= (new_value << (16+shift_right)) & mask2; + dst[dst_pos + 1] = old_value; + } +} + +uint16_t bitextract(uint16_t *src, int position, int depth) +{ + uint16_t value = 0; + int src_pos = position * depth / 16; + int bits_to_left = ((depth * position) - (16 * src_pos)) % 16; + int shift_right = 16 - depth - bits_to_left; + + value = src[src_pos]; + + if(shift_right >= 0) + { + value >>= shift_right; + } + else + { + value <<= -shift_right; + value |= src[src_pos + 1] >> (16 + shift_right); + } + value &= (1<\n", executable); + fprintf(stderr, "Parameters:\n"); + fprintf(stderr, " -o output_file set the filename to write into\n"); + fprintf(stderr, " -v verbose output\n"); + fprintf(stderr, " -r output into a legacy raw file for e.g. raw2dng\n"); + fprintf(stderr, " -b bits convert image data to given bit depth per channel (1-16)\n"); + fprintf(stderr, " -z bits zero the lowest bits, so we have only specified number of bits containing data (1-16) (improves compression rate)\n"); + fprintf(stderr, " -f frames stop after that number of frames\n"); + + fprintf(stderr, " -x build xref file (indexing)\n"); + + fprintf(stderr, " -m write only metadata, no audio or video frames\n"); + fprintf(stderr, " -n write no metadata, only audio and video frames\n"); + + fprintf(stderr, " -a average all frames in and output a single-frame MLV from it\n"); + fprintf(stderr, " -s mlv_file subtract the reference frame in given file from every single frame during processing\n"); + + fprintf(stderr, " -e delta-encode frames to improve compression, but lose random access capabilities\n"); + + /* yet unclear which format to choose, so keep that as reminder */ + //fprintf(stderr, " -u lut_file look-up table with 4 * xRes * yRes 16-bit words that is applied before bit depth conversion\n"); +#ifdef MLV_USE_LZMA + fprintf(stderr, " -c (re-)compress video and audio frames using LZMA (set bpp to 16 to improve compression rate)\n"); + fprintf(stderr, " -d decompress compressed video and audio frames using LZMA\n"); + fprintf(stderr, " -l level set compression level from 0=fastest to 9=best compression\n"); +#else + fprintf(stderr, " -c, -d, -l NOT AVAILABLE: compression support was not compiled into this release\n"); +#endif +} + +int main (int argc, char *argv[]) +{ + char *input_filename = NULL; + char *output_filename = NULL; + char *subtract_filename = NULL; + char *lut_filename = NULL; + int blocks_processed = 0; + + int frame_limit = 0; + int vidf_frames_processed = 0; + int vidf_max_number = 0; + + int delta_encode_mode = 0; + int xref_mode = 0; + int average_mode = 0; + int subtract_mode = 0; + int no_metadata_mode = 0; + int only_metadata_mode = 0; + int average_samples = 0; + + int mlv_output = 0; + int raw_output = 0; + int bit_depth = 0; + int bit_zap = 0; + int compress_output = 0; + int decompress_output = 0; + int verbose = 0; + int lzma_level = 5; + char opt = ' '; + + int video_xRes = 0; + int video_yRes = 0; + +#ifdef MLV_USE_LZMA + /* this may need some tuning */ + int lzma_dict = 1<<27; + int lzma_lc = 0; + int lzma_lp = 1; + int lzma_pb = 1; + int lzma_fb = 16; + int lzma_threads = 8; +#endif + + printf("\n"); + printf(" MLV Dumper v1.0\n"); + printf("-----------------\n"); + printf("\n"); + + if(sizeof(mlv_file_hdr_t) != 52) + { + printf("Error: Your compiler setup is weird. sizeof(mlv_file_hdr_t) is %d on your machine. Expected: 52\n", sizeof(mlv_file_hdr_t)); + return 0; + } + + while ((opt = getopt(argc, argv, "xz:emnas:uvrcdo:l:b:f:")) != -1) + { + switch (opt) + { + case 'x': + xref_mode = 1; + break; + + case 'm': + only_metadata_mode = 1; + break; + + case 'n': + no_metadata_mode = 1; + break; + + case 'e': + delta_encode_mode = 1; + break; + + case 'a': + average_mode = 1; + decompress_output = 1; + no_metadata_mode = 1; + break; + + case 's': + if(!optarg) + { + fprintf(stderr, "Error: Missing subtract frame filename\n"); + return 0; + } + subtract_filename = strdup(optarg); + subtract_mode = 1; + decompress_output = 1; + break; + + case 'u': + if(!optarg) + { + fprintf(stderr, "Error: Missing LUT filename\n"); + return 0; + } + lut_filename = strdup(optarg); + break; + + case 'v': + verbose = 1; + break; + + case 'r': + raw_output = 1; + bit_depth = 14; + break; + + case 'c': +#ifdef MLV_USE_LZMA + compress_output = 1; +#else + fprintf(stderr, "Error: Compression support was not compiled into this release\n"); + return 0; +#endif + break; + + case 'd': +#ifdef MLV_USE_LZMA + decompress_output = 1; +#else + fprintf(stderr, "Error: Compression support was not compiled into this release\n"); + return 0; +#endif + break; + + case 'o': + if(!optarg) + { + fprintf(stderr, "Error: Missing output filename\n"); + return 0; + } + output_filename = strdup(optarg); + break; + + case 'l': + lzma_level = MIN(9, MAX(0, atoi(optarg))); + break; + + case 'f': + frame_limit = MAX(0, atoi(optarg)); + break; + + case 'b': + if(!raw_output) + { + bit_depth = MIN(16, MAX(1, atoi(optarg))); + } + break; + + case 'z': + if(!raw_output) + { + bit_zap = MIN(16, MAX(1, atoi(optarg))); + } + break; + + default: + show_usage(argv[0]); + return 0; + } + } + + if(optind >= argc) + { + fprintf(stderr, "Error: Missing input filename\n"); + show_usage(argv[0]); + return 0; + } + + + /* get first file */ + input_filename = argv[optind]; + + printf("[i] Mode of operation:\n"); + printf(" - Input MLV file: '%s'\n", input_filename); + + if(verbose) + { + printf(" - Verbose messages\n"); + } + + /* display and set/unset variables according to parameters to have a consistent state */ + if(output_filename) + { + if(raw_output) + { + printf(" - Convert to legacy RAW\n"); + + delta_encode_mode = 0; + compress_output = 0; + mlv_output = 0; + if(average_mode) + { + printf(" - disabled average mode, not possible\n"); + average_mode = 0; + } + } + else + { + mlv_output = 1; + printf(" - Rewrite MLV\n"); + if(bit_zap) + { + printf(" - Only store %d bits of information per pixel\n", bit_zap); + } + if(bit_depth) + { + printf(" - Convert to %d bpp\n", bit_depth); + } + if(delta_encode_mode) + { + printf(" - Only store changes to previous frame\n"); + } + if(compress_output) + { + printf(" - Compress frame data\n"); + } + if(average_mode) + { + printf(" - Output only one frame with averaged pixel values\n"); + subtract_mode = 0; + } + if(subtract_mode) + { + printf(" - Subtract reference frame '%s' from single images\n", subtract_filename); + } + } + + printf(" - Output into '%s'\n", output_filename); + } + else + { + /* those dont make sense then */ + raw_output = 0; + compress_output = 0; + + printf(" - Verify file structure\n"); + if(verbose) + { + printf(" - Dump all block information\n"); + } + } + + if(xref_mode) + { + printf(" - Output .idx file for faster processing\n"); + } + + /* start processing */ + lv_rec_file_footer_t lv_rec_footer; + mlv_file_hdr_t main_header; + + /* this table contains the XREF chunk read from idx file, if existing */ + mlv_xref_hdr_t *block_xref = NULL; + int block_xref_pos = 0; + + uint32_t frame_buffer_size = 32*1024*1024; + + uint32_t *frame_arith_buffer = NULL; + uint8_t *frame_buffer = NULL; + uint8_t *prev_frame_buffer = NULL; + + FILE *out_file = NULL; + FILE **in_files = NULL; + FILE *in_file = NULL; + + int in_file_count = 0; + int in_file_num = 0; + + /* this is for our generated XREF table */ + frame_xref_t *frame_xref_table = NULL; + int frame_xref_allocated = 0; + int frame_xref_entries = 0; + + /* initialize stuff */ + memset(&lv_rec_footer, 0x00, sizeof(lv_rec_file_footer_t)); + memset(&main_header, 0x00, sizeof(mlv_file_hdr_t)); + + /* open files */ + in_files = load_all_chunks(input_filename, &in_file_count); + if(!in_files || !in_file_count) + { + fprintf(stderr, "[E] Failed to open file '%s'\n", input_filename); + return 0; + } + else + { + in_file_num = 0; + in_file = in_files[in_file_num]; + } + + if(!xref_mode) + { + block_xref = load_index(input_filename); + + if(block_xref) + { + printf("[i] XREF table contains %d entries\n", block_xref->entryCount); + } + else + { + if(delta_encode_mode) + { + fprintf(stderr, "[E] Delta encoding is not possible without an index file. Please create one using -x option.\n"); + return 0; + } + } + } + + if(average_mode || subtract_mode) + { + frame_arith_buffer = malloc(frame_buffer_size); + if(!frame_arith_buffer) + { + fprintf(stderr, "[E] Failed to alloc mem\n"); + return 0; + } + memset(frame_arith_buffer, 0x00, frame_buffer_size); + } + + if(subtract_mode) + { + int ret = load_frame(subtract_filename, 0, (uint8_t*)frame_arith_buffer); + + if(ret) + { + fprintf(stderr, "[E] Failed to load subtract frame (%d)\n", ret); + return 0; + } + } + + //if(delta_encode_mode) + { + prev_frame_buffer = malloc(frame_buffer_size); + if(!prev_frame_buffer) + { + fprintf(stderr, "[E] Failed to alloc mem\n"); + return 0; + } + memset(prev_frame_buffer, 0x00, frame_buffer_size); + } + + if(output_filename) + { + frame_buffer = malloc(frame_buffer_size); + if(!frame_buffer) + { + fprintf(stderr, "[E] Failed to alloc mem\n"); + return 0; + } + + out_file = fopen(output_filename, "wb+"); + if(!out_file) + { + fprintf(stderr, "[E] Failed to open file '%s'\n", output_filename); + return 0; + } + } + + printf("[i] Processing...\n"); + do + { + mlv_hdr_t buf; + uint64_t position = 0; + +read_headers: + + if(block_xref) + { + block_xref_pos++; + if(block_xref_pos >= block_xref->entryCount) + { + printf("[i] Reached end of all files after %i blocks\n", blocks_processed); + break; + } + + /* get the file and position of the next block */ + in_file_num = ((mlv_xref_t*)&block_xref->xrefEntries)[block_xref_pos].fileNumber; + position = ((mlv_xref_t*)&block_xref->xrefEntries)[block_xref_pos].frameOffset; + + /* select file and seek to the right position */ + in_file = in_files[in_file_num]; + fseeko(in_file, position, SEEK_SET); + } + + position = ftello(in_file); + + if(fread(&buf, sizeof(mlv_hdr_t), 1, in_file) != 1) + { + if(block_xref) + { + printf("[i] Reached EOF of chunk %d/%d after %i blocks total. This should never happen or your index file is wrong.\n", in_file_num, in_file_count, blocks_processed); + break; + } + printf("[i] Reached end of chunk %d/%d after %i blocks\n", in_file_num, in_file_count, blocks_processed); + + if(in_file_num < (in_file_count - 1)) + { + in_file_num++; + in_file = in_files[in_file_num]; + } + else + { + break; + } + + blocks_processed = 0; + + goto read_headers; + } + + /* jump back to the beginning of the block just read */ + fseeko(in_file, position, SEEK_SET); + + position = ftello(in_file); + + /* file header */ + if(!memcmp(buf.blockType, "MLVI", 4)) + { + mlv_file_hdr_t file_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_file_hdr_t), buf.blockSize); + + /* read the whole header block, but limit size to either our local type size or the written block size */ + if(fread(&file_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + fseeko(in_file, position + file_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf("File Header (MLVI)\n"); + printf(" Size : 0x%08X\n", file_hdr.blockSize); + printf(" Ver : %s\n", file_hdr.versionString); + printf(" GUID : %08" PRIu64 "\n", file_hdr.fileGuid); + printf(" FPS : %f\n", (double)file_hdr.sourceFpsNom / (double)file_hdr.sourceFpsDenom); + printf(" File : %d / %d\n", file_hdr.fileNum, file_hdr.fileCount); + printf(" Frames Video: %d\n", file_hdr.videoFrameCount); + printf(" Frames Audio: %d\n", file_hdr.audioFrameCount); + } + + /* is this the first file? */ + if(file_hdr.fileNum == 0) + { + /* in xref mode, use every block and get its timestamp etc */ + if(xref_mode) + { + xref_resize(&frame_xref_table, frame_xref_entries + 1, &frame_xref_allocated); + + /* add xref data */ + frame_xref_table[frame_xref_entries].frameTime = 0; + frame_xref_table[frame_xref_entries].frameOffset = position; + frame_xref_table[frame_xref_entries].fileNumber = in_file_num; + + frame_xref_entries++; + } + + memcpy(&main_header, &file_hdr, sizeof(mlv_file_hdr_t)); + + if(mlv_output) + { + /* correct header size if needed */ + file_hdr.blockSize = sizeof(mlv_file_hdr_t); + + if(average_mode) + { + file_hdr.videoFrameCount = 1; + } + + /* set the output compression flag */ + if(compress_output) + { + file_hdr.videoClass |= MLV_VIDEO_CLASS_FLAG_LZMA; + } + else + { + file_hdr.videoClass &= ~MLV_VIDEO_CLASS_FLAG_LZMA; + } + + if(delta_encode_mode) + { + file_hdr.videoClass |= MLV_VIDEO_CLASS_FLAG_DELTA; + } + else + { + file_hdr.videoClass &= ~MLV_VIDEO_CLASS_FLAG_DELTA; + } + + if(fwrite(&file_hdr, file_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else + { + /* no, its another chunk */ + if(main_header.fileGuid != file_hdr.fileGuid) + { + printf("Error: GUID within the file chunks mismatch!\n"); + break; + } + } + + if(raw_output) + { + lv_rec_footer.frameCount += file_hdr.videoFrameCount; + lv_rec_footer.sourceFpsx1000 = (double)file_hdr.sourceFpsNom / (double)file_hdr.sourceFpsDenom * 1000; + lv_rec_footer.frameSkip = 0; + } + } + else + { + /* in xref mode, use every block and get its timestamp etc */ + if(xref_mode) + { + xref_resize(&frame_xref_table, frame_xref_entries + 1, &frame_xref_allocated); + + /* add xref data */ + frame_xref_table[frame_xref_entries].frameTime = buf.timestamp; + frame_xref_table[frame_xref_entries].frameOffset = position; + frame_xref_table[frame_xref_entries].fileNumber = in_file_num; + + frame_xref_entries++; + } + + if(main_header.blockSize == 0) + { + fprintf(stderr, "[E] Missing file header\n"); + goto abort; + } + + if(verbose) + { + printf("Block: %c%c%c%c\n", buf.blockType[0], buf.blockType[1], buf.blockType[2], buf.blockType[3]); + printf(" Offset: 0x%08" PRIx64 "\n", position); + printf(" Size: %d\n", buf.blockSize); + + /* NULL blocks don't have timestamps */ + if(memcmp(buf.blockType, "NULL", 4)) + { + printf(" Time: %f ms\n", (double)buf.timestamp / 1000.0f); + } + } + + if(!memcmp(buf.blockType, "VIDF", 4)) + { + mlv_vidf_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_vidf_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + if(verbose) + { + printf(" Frame: #%d\n", block_hdr.frameNumber); + printf(" Crop: %dx%d\n", block_hdr.cropPosX, block_hdr.cropPosY); + printf(" Pan: %dx%d\n", block_hdr.panPosX, block_hdr.panPosY); + printf(" Space: %d\n", block_hdr.frameSpace); + } + + if(raw_output || mlv_output) + { + /* if already compressed, we have to decompress it first */ + int compressed = main_header.videoClass & MLV_VIDEO_CLASS_FLAG_LZMA; + int recompress = compressed && compress_output; + int decompress = compressed && decompress_output; + + int frame_size = block_hdr.blockSize - sizeof(mlv_vidf_hdr_t) - block_hdr.frameSpace; + int prev_frame_size = frame_size; + + fseeko(in_file, block_hdr.frameSpace, SEEK_CUR); + if(fread(frame_buffer, frame_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + if(recompress || decompress || (raw_output && compressed)) + { +#ifdef MLV_USE_LZMA + size_t lzma_out_size = *(uint32_t *)frame_buffer; + size_t lzma_in_size = frame_size - LZMA_PROPS_SIZE - 4; + size_t lzma_props_size = LZMA_PROPS_SIZE; + unsigned char *lzma_out = malloc(lzma_out_size); + + int ret = LzmaUncompress( + lzma_out, &lzma_out_size, + (unsigned char *)&frame_buffer[4 + LZMA_PROPS_SIZE], &lzma_in_size, + (unsigned char *)&frame_buffer[4], lzma_props_size + ); + + if(ret == SZ_OK) + { + frame_size = lzma_out_size; + memcpy(frame_buffer, lzma_out, frame_size); + if(verbose) + { + printf(" LZMA: %d -> %d (%2.2f%%)\n", lzma_in_size, lzma_out_size, ((float)lzma_out_size * 100.0f) / (float)lzma_in_size); + } + } + else + { + printf(" LZMA: Failed (%d)\n", ret); + goto abort; + } +#else + printf(" LZMA: not compiled into this release, aborting.\n"); + goto abort; +#endif + } + + int old_depth = lv_rec_footer.raw_info.bits_per_pixel; + int new_depth = bit_depth; + + /* this value changes in this context */ + int current_depth = old_depth; + + /* in average mode, sum up all pixel values of a pixel position */ + if(average_mode) + { + int pitch = video_xRes * lv_rec_footer.raw_info.bits_per_pixel / 8; + + for(int y = 0; y < video_yRes; y++) + { + uint16_t *src_line = (uint16_t *)&frame_buffer[y * pitch]; + + for(int x = 0; x < video_xRes; x++) + { + uint16_t value = bitextract(src_line, x, lv_rec_footer.raw_info.bits_per_pixel); + + frame_arith_buffer[y * video_xRes + x] += value; + } + } + + average_samples++; + } + + /* in subtract mode, subtrace reference frame */ + if(subtract_mode) + { + int pitch = video_xRes * lv_rec_footer.raw_info.bits_per_pixel / 8; + + for(int y = 0; y < video_yRes; y++) + { + uint16_t *src_line = (uint16_t *)&frame_buffer[y * pitch]; + uint16_t *sub_line = (uint16_t *)&((uint8_t*)frame_arith_buffer)[y * pitch]; + + for(int x = 0; x < video_xRes; x++) + { + int32_t value = bitextract(src_line, x, lv_rec_footer.raw_info.bits_per_pixel); + int32_t sub_value = bitextract(sub_line, x, lv_rec_footer.raw_info.bits_per_pixel); + + value -= sub_value; + value += lv_rec_footer.raw_info.black_level; + value = COERCE(value, lv_rec_footer.raw_info.black_level, lv_rec_footer.raw_info.white_level); + + bitinsert(src_line, x, lv_rec_footer.raw_info.bits_per_pixel, value); + } + } + } + + /* now resample bit depth if requested */ + if(new_depth && (old_depth != new_depth)) + { + int new_size = (video_xRes * video_yRes * new_depth + 7) / 8; + unsigned char *new_buffer = malloc(new_size); + + if(verbose) + { + printf(" depth: %d -> %d, size: %d -> %d (%2.2f%%)\n", old_depth, new_depth, frame_size, new_size, ((float)new_depth * 100.0f) / (float)old_depth); + } + + int calced_size = ((video_xRes * video_yRes * old_depth + 7) / 8); + if(calced_size > frame_size) + { + printf("Error: old frame size is too small for %dx%d at %d bpp. Input data corrupt. (%d < %d)\n", video_xRes, video_yRes, old_depth, frame_size, calced_size); + break; + } + + int old_pitch = video_xRes * old_depth / 8; + int new_pitch = video_xRes * new_depth / 8; + + for(int y = 0; y < video_yRes; y++) + { + uint16_t *src_line = (uint16_t *)&frame_buffer[y * old_pitch]; + uint16_t *dst_line = (uint16_t *)&new_buffer[y * new_pitch]; + + for(int x = 0; x < video_xRes; x++) + { + uint16_t value = bitextract(src_line, x, old_depth); + + /* normalize the old value to 16 bits */ + value <<= (16-old_depth); + + /* convert the old value to destination depth */ + value >>= (16-new_depth); + + bitinsert(dst_line, x, new_depth, value); + } + } + + frame_size = new_size; + current_depth = new_depth; + + memcpy(frame_buffer, new_buffer, frame_size); + free(new_buffer); + } + + if(bit_zap) + { + int pitch = video_xRes * current_depth / 8; + uint32_t mask = ~((1 << (16 - bit_zap)) - 1); + + for(int y = 0; y < video_yRes; y++) + { + uint16_t *src_line = (uint16_t *)&frame_buffer[y * pitch]; + + for(int x = 0; x < video_xRes; x++) + { + int32_t value = bitextract(src_line, x, current_depth); + + /* normalize the old value to 16 bits */ + value <<= (16-current_depth); + + value &= mask; + + /* convert the old value to destination depth */ + value >>= (16-current_depth); + + + bitinsert(src_line, x, current_depth, value); + } + } + } + + if(delta_encode_mode) + { + /* only delta encode, if not already encoded */ + if(!(main_header.videoClass & MLV_VIDEO_CLASS_FLAG_DELTA)) + { + uint8_t *current_frame_buffer = malloc(frame_size); + int pitch = video_xRes * current_depth / 8; + + /* backup current frame for later */ + memcpy(current_frame_buffer, frame_buffer, frame_size); + + for(int y = 0; y < video_yRes; y++) + { + uint16_t *src_line = (uint16_t *)&frame_buffer[y * pitch]; + uint16_t *ref_line = (uint16_t *)&prev_frame_buffer[y * pitch]; + int32_t offset = 1 << (current_depth - 1); + int32_t max_val = (1 << current_depth) - 1; + + for(int x = 0; x < video_xRes; x++) + { + int32_t value = bitextract(src_line, x, current_depth); + int32_t ref_value = bitextract(ref_line, x, current_depth); + + /* when e.g. using 16 bit values: + delta = 1 -> encode to 0x8001 + delta = 0 -> encode to 0x8000 + delta = -1 -> encode to 0x7FFF + delta = -0xFFFF -> encode to 0x0001 + delta = 0xFFFF -> encode to 0x7FFF + so this is basically a signed int with overflow and a max/2 offset. + this offset makes the frames uniform grey when viewing non-decoded frames and improves compression rate a bit. + */ + int32_t delta = offset + value - ref_value; + + uint16_t new_value = (uint16_t)(delta & max_val); + + bitinsert(src_line, x, current_depth, new_value); + } + } + + /* save current original frame to prev buffer */ + memcpy(prev_frame_buffer, current_frame_buffer, frame_size); + free(current_frame_buffer); + } + } + else + { + /* delta decode, if input data is encoded */ + if(main_header.videoClass & MLV_VIDEO_CLASS_FLAG_DELTA) + { + int pitch = video_xRes * current_depth / 8; + + for(int y = 0; y < video_yRes; y++) + { + uint16_t *src_line = (uint16_t *)&frame_buffer[y * pitch]; + uint16_t *ref_line = (uint16_t *)&prev_frame_buffer[y * pitch]; + int32_t offset = 1 << (current_depth - 1); + int32_t max_val = (1 << current_depth) - 1; + + for(int x = 0; x < video_xRes; x++) + { + int32_t value = bitextract(src_line, x, current_depth); + int32_t ref_value = bitextract(ref_line, x, current_depth); + + /* when e.g. using 16 bit values: + delta = 1 -> encode to 0x8001 + delta = 0 -> encode to 0x8000 + delta = -1 -> encode to 0x7FFF + delta = -0xFFFF -> encode to 0x0001 + delta = 0xFFFF -> encode to 0x7FFF + so this is basically a signed int with overflow and a max/2 offset. + this offset makes the frames uniform grey when viewing non-decoded frames and improves compression rate a bit. + */ + int32_t delta = offset + value + ref_value; + + uint16_t new_value = (uint16_t)(delta & max_val); + + bitinsert(src_line, x, current_depth, new_value); + } + } + + /* save current original frame to prev buffer */ + memcpy(prev_frame_buffer, frame_buffer, frame_size); + } + } + + if(raw_output) + { + if(!lv_rec_footer.frameSize) + { + lv_rec_footer.frameSize = frame_size; + } + + fseeko(out_file, (uint64_t)block_hdr.frameNumber * (uint64_t)frame_size, SEEK_SET); + fwrite(frame_buffer, frame_size, 1, out_file); + } + + if(mlv_output && !only_metadata_mode && !average_mode) + { + if(compress_output) + { +#ifdef MLV_USE_LZMA + size_t lzma_out_size = 2 * frame_size; + size_t lzma_in_size = frame_size; + size_t lzma_props_size = LZMA_PROPS_SIZE; + unsigned char *lzma_out = malloc(lzma_out_size + LZMA_PROPS_SIZE); + + int ret = LzmaCompress( + &lzma_out[LZMA_PROPS_SIZE], &lzma_out_size, + (unsigned char *)frame_buffer, lzma_in_size, + &lzma_out[0], &lzma_props_size, + lzma_level, lzma_dict, lzma_lc, lzma_lp, lzma_pb, lzma_fb, lzma_threads + ); + + if(ret == SZ_OK) + { + /* store original frame size */ + *(uint32_t *)frame_buffer = frame_size; + + /* set new compressed size and copy buffers */ + frame_size = lzma_out_size + LZMA_PROPS_SIZE + 4; + memcpy(&frame_buffer[4], lzma_out, frame_size - 4); + + if(verbose) + { + printf(" LZMA: %d -> %d (%2.2f%%)\n", lzma_in_size, frame_size, ((float)lzma_out_size * 100.0f) / (float)lzma_in_size); + } + } + else + { + printf(" LZMA: Failed (%d)\n", ret); + goto abort; + } + free(lzma_out); +#else + printf(" LZMA: not compiled into this release, aborting.\n"); + goto abort; +#endif + } + + if(frame_size != prev_frame_size) + { + printf(" saving: %d -> %d (%2.2f%%)\n", prev_frame_size, frame_size, ((float)frame_size * 100.0f) / (float)prev_frame_size); + } + + /* delete free space and correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_vidf_hdr_t) + frame_size; + block_hdr.frameSpace = 0; + + if(fwrite(&block_hdr, sizeof(mlv_vidf_hdr_t), 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + if(fwrite(frame_buffer, frame_size, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else + { + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + } + + vidf_max_number = MAX(vidf_max_number, block_hdr.frameNumber); + + vidf_frames_processed++; + if(frame_limit && vidf_frames_processed > frame_limit) + { + printf("[i] Reached limit of %i frames\n", frame_limit); + break; + } + } + else if(!memcmp(buf.blockType, "LENS", 4)) + { + mlv_lens_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_lens_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" Name: '%s'\n", block_hdr.lensName); + printf(" Serial: '%s'\n", block_hdr.lensSerial); + printf(" Focal Len: %d mm\n", block_hdr.focalLength); + printf(" Focus Dist: %d mm\n", block_hdr.focalDist); + printf(" Aperture: f/%.2f\n", (double)block_hdr.aperture / 100.0f); + printf(" IS Mode: %d\n", block_hdr.stabilizerMode); + printf(" AF Mode: %d\n", block_hdr.autofocusMode); + printf(" Lens ID: 0x%08X\n", block_hdr.lensID); + printf(" Flags: 0x%08X\n", block_hdr.flags); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_lens_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "INFO", 4)) + { + mlv_info_hdr_t block_hdr; + int32_t hdr_size = MIN(sizeof(mlv_info_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* get the string length and malloc a buffer for that string */ + int str_length = block_hdr.blockSize - hdr_size; + + if(str_length) + { + char *buf = malloc(str_length + 1); + + if(fread(buf, str_length, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + if(verbose) + { + buf[str_length] = '\000'; + printf(" String: '%s'\n", buf); + } + + /* only output this block if there is any data */ + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_info_hdr_t) + str_length; + if(fwrite(&block_hdr, sizeof(mlv_info_hdr_t), 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + if(fwrite(buf, str_length, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + + free(buf); + } + } + else if(!memcmp(buf.blockType, "ELVL", 4)) + { + mlv_elvl_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_elvl_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" Roll: %2.2f\n", (double)block_hdr.roll / 100.0f); + printf(" Pitch: %2.2f\n", (double)block_hdr.pitch / 100.0f); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_elvl_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "STYL", 4)) + { + mlv_styl_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_styl_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" picStyle: %d\n", block_hdr.picStyle); + printf(" contrast: %d\n", block_hdr.contrast); + printf(" sharpness: %d\n", block_hdr.sharpness); + printf(" saturation: %d\n", block_hdr.saturation); + printf(" colortone: %d\n", block_hdr.colortone); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_styl_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "WBAL", 4)) + { + mlv_wbal_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_wbal_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" Mode: %d\n", block_hdr.wb_mode); + printf(" Kelvin: %d\n", block_hdr.kelvin); + printf(" Gain R: %d\n", block_hdr.wbgain_r); + printf(" Gain G: %d\n", block_hdr.wbgain_g); + printf(" Gain B: %d\n", block_hdr.wbgain_b); + printf(" Shift GM: %d\n", block_hdr.wbs_gm); + printf(" Shift BA: %d\n", block_hdr.wbs_ba); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_wbal_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "IDNT", 4)) + { + mlv_idnt_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_idnt_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" Camera Name: '%s'\n", block_hdr.cameraName); + printf(" Camera Serial: '%s'\n", block_hdr.cameraSerial); + printf(" Camera Model: 0x%08X\n", block_hdr.cameraModel); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_idnt_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "RTCI", 4)) + { + mlv_rtci_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_rtci_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" Date: %02d.%02d.%04d\n", block_hdr.tm_mday, block_hdr.tm_mon, 1900 + block_hdr.tm_year); + printf(" Time: %02d:%02d:%02d (GMT+%d)\n", block_hdr.tm_hour, block_hdr.tm_min, block_hdr.tm_sec, block_hdr.tm_gmtoff); + printf(" Zone: '%s'\n", block_hdr.tm_zone); + printf(" Day of week: %d\n", block_hdr.tm_wday); + printf(" Day of year: %d\n", block_hdr.tm_yday); + printf(" Daylight s.: %d\n", block_hdr.tm_isdst); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_rtci_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "MARK", 4)) + { + mlv_mark_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_mark_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" Button: 0x%02X\n", block_hdr.type); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_mark_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "EXPO", 4)) + { + mlv_expo_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_expo_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + if(verbose) + { + printf(" ISO Mode: %d\n", block_hdr.isoMode); + printf(" ISO: %d\n", block_hdr.isoValue); + printf(" ISO Analog: %d\n", block_hdr.isoAnalog); + printf(" ISO DGain: %d/1024 EV\n", block_hdr.digitalGain); + printf(" Shutter: %" PRIu64 " µs (1/%.2f)\n", block_hdr.shutterValue, 1000000.0f/(float)block_hdr.shutterValue); + } + + if(mlv_output && !no_metadata_mode) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_expo_hdr_t); + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else if(!memcmp(buf.blockType, "RAWI", 4)) + { + mlv_rawi_hdr_t block_hdr; + uint32_t hdr_size = MIN(sizeof(mlv_rawi_hdr_t), buf.blockSize); + + if(fread(&block_hdr, hdr_size, 1, in_file) != 1) + { + fprintf(stderr, "[E] File ends in the middle of a block\n"); + goto abort; + } + + /* skip remaining data, if there is any */ + fseeko(in_file, position + block_hdr.blockSize, SEEK_SET); + + video_xRes = block_hdr.xRes; + video_yRes = block_hdr.yRes; + if(verbose) + { + printf(" Res: %dx%d\n", block_hdr.xRes, block_hdr.yRes); + printf(" raw_info:\n"); + printf(" api_version 0x%08X\n", block_hdr.raw_info.api_version); + printf(" height %d\n", block_hdr.raw_info.height); + printf(" width %d\n", block_hdr.raw_info.width); + printf(" pitch %d\n", block_hdr.raw_info.pitch); + printf(" frame_size 0x%08X\n", block_hdr.raw_info.frame_size); + printf(" bits_per_pixel %d\n", block_hdr.raw_info.bits_per_pixel); + printf(" black_level %d\n", block_hdr.raw_info.black_level); + printf(" white_level %d\n", block_hdr.raw_info.white_level); + printf(" active_area.y1 %d\n", block_hdr.raw_info.active_area.y1); + printf(" active_area.x1 %d\n", block_hdr.raw_info.active_area.x1); + printf(" active_area.y2 %d\n", block_hdr.raw_info.active_area.y2); + printf(" active_area.x2 %d\n", block_hdr.raw_info.active_area.x2); + printf(" exposure_bias %d, %d\n", block_hdr.raw_info.exposure_bias[0], block_hdr.raw_info.exposure_bias[1]); + printf(" cfa_pattern 0x%08X\n", block_hdr.raw_info.cfa_pattern); + printf(" calibration_ill %d\n", block_hdr.raw_info.calibration_illuminant1); + } + + /* cache these bits when we convert to legacy or resample bit depth */ + //if(raw_output || bit_depth) + { + strncpy((char*)lv_rec_footer.magic, "RAWM", 4); + lv_rec_footer.xRes = block_hdr.xRes; + lv_rec_footer.yRes = block_hdr.yRes; + lv_rec_footer.raw_info = block_hdr.raw_info; + } + + /* always output RAWI blocks, its not just metadata, but important frame format data */ + if(mlv_output /*&& !no_metadata_mode*/) + { + /* correct header size if needed */ + block_hdr.blockSize = sizeof(mlv_rawi_hdr_t); + + if(bit_depth) + { + block_hdr.raw_info.bits_per_pixel = bit_depth; + } + + if(fwrite(&block_hdr, block_hdr.blockSize, 1, out_file) != 1) + { + fprintf(stderr, "[E] Failed writing into output file\n"); + goto abort; + } + } + } + else + { + printf("[i] Unknown Block: %c%c%c%c, skipping\n", buf.blockType[0], buf.blockType[1], buf.blockType[2], buf.blockType[3]); + fseeko(in_file, position + buf.blockSize, SEEK_SET); + } + } + + /* count any read block, no matter if header or video frame */ + blocks_processed++; + } + while(!feof(in_file)); + +abort: + + printf("[i] Processed %d video frames\n", vidf_frames_processed); + + /* in average mode, finalize average calculation and output the resulting average */ + if(average_mode) + { + int new_pitch = video_xRes * lv_rec_footer.raw_info.bits_per_pixel / 8; + for(int y = 0; y < video_yRes; y++) + { + uint16_t *dst_line = (uint16_t *)&frame_buffer[y * new_pitch]; + for(int x = 0; x < video_xRes; x++) + { + uint32_t value = frame_arith_buffer[y * video_xRes + x]; + + value /= average_samples; + bitinsert(dst_line, x, lv_rec_footer.raw_info.bits_per_pixel, value); + } + } + + int frame_size = ((video_xRes * video_yRes * lv_rec_footer.raw_info.bits_per_pixel + 7) / 8); + + mlv_vidf_hdr_t hdr; + + memset(&hdr, 0x00, sizeof(mlv_vidf_hdr_t)); + memcpy(hdr.blockType, "VIDF", 4); + hdr.blockSize = sizeof(mlv_vidf_hdr_t) + frame_size; + + fwrite(&hdr, sizeof(mlv_vidf_hdr_t), 1, out_file); + fwrite(frame_buffer, frame_size, 1, out_file); + } + + if(raw_output) + { + lv_rec_footer.frameCount = vidf_max_number + 1; + lv_rec_footer.raw_info.bits_per_pixel = 14; + + fseeko(out_file, 0, SEEK_END); + fwrite(&lv_rec_footer, sizeof(lv_rec_file_footer_t), 1, out_file); + } + + if(xref_mode) + { + printf("[i] XREF table contains %d entries\n", frame_xref_entries); + xref_sort(frame_xref_table, frame_xref_entries); + save_index(input_filename, &main_header, in_file_count, frame_xref_table, frame_xref_entries); + } + + /* free list of input files */ + for(in_file_num = 0; in_file_num < in_file_count; in_file_num++) + { + fclose(in_files[in_file_num]); + } + free(in_files); + + if(out_file) + { + fclose(out_file); + } + + /* passing NULL to free is absolutely legal, so no check required */ + free(lut_filename); + free(subtract_filename); + free(output_filename); + free(prev_frame_buffer); + free(frame_arith_buffer); + free(block_xref); + + + printf("[i] Done\n"); + printf("\n"); + + return 0; +} diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/mlv_rec/mlv_rec.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/mlv_rec/mlv_rec.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,3402 @@ +/** + * RAW recording. Similar to lv_rec, with some different internals: + * + * - buffering strategy: + * - group the frames in contiguous chunks, up to 32MB, to maximize writing speed + * (speed profile depends on buffer size: http://www.magiclantern.fm/forum/index.php?topic=5471 ) + * - always write if there's something to write, even if that means using a small buffer + * (this minimizes idle time for the writing task, keeps memory free in the startup phase, + * and has no impact on the sustained write speeds + * - always choose the largest unused chunk => this maximizes the sustained writing speed + * (small chunks will only be used in extreme situations, to squeeze the last few frames) + * - use any memory chunks that can contain at least one video frame + * (they will only be used when recording is about to stop, so no negative impact in sustained write speed) + * + * - edmac_copy_rectangle: we can crop the image and trim the black borders! + * - edmac operation done outside the LV task (in background, synchronized) + * - on buffer overflow, it stops or skips frames (user-selected) + * - using generic raw routines, no hardcoded stuff (should be easier to port) + * - only for RAW in a single file (do one thing and do it well) + * - goal #1: 1920x1080 on 1000x cards (achieved and exceeded, reports say 1920x1280 continuous!) + * - goal #2: maximize number of frames for any given resolution + buffer + card speed configuration + * (see buffering strategy; I believe it's close to optimal, though I have no idea how to write a mathematical proof for it) + * + * Usage: + * - enable modules in Makefile.user (CONFIG_MODULES = y, CONFIG_TCC = y, CONFIG_PICOC = n, CONFIG_CONSOLE = y) + * - run "make" from modules/raw_rec to compile this module and the DNG converter + * - run "make install" from platform dir to copy the modules on the card + * - from Module menu: Load modules now + * - look in Movie menu + */ + +/* + * Copyright (C) 2013 Magic Lantern Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + + +//#define CONFIG_CONSOLE +//#define TRACE_DISABLED + +#define DEBUG_REDRAW_INTERVAL 1000 /* normally 1000; low values like 50 will reduce write speed a lot! */ +#define MLV_RTCI_BLOCK_INTERVAL 500 +#define MLV_INFO_BLOCK_INTERVAL 2000 + + + +#include +#include +#include +#include +#include +#include +#include +#include "edmac.h" +#include "../lv_rec/lv_rec.h" +#include "../file_man/file_man.h" +#include "../ime_base/ime_base.h" +#include "../trace/trace.h" +#include "cache_hacks.h" +#include "mlv.h" + +/* camera-specific tricks */ +/* todo: maybe add generic functions like is_digic_v, is_5d2 or stuff like that? */ +static int32_t cam_eos_m = 0; +static int32_t cam_5d2 = 0; +static int32_t cam_50d = 0; +static int32_t cam_5d3 = 0; +static int32_t cam_6d = 0; +static int32_t cam_700d = 0; +static int32_t cam_7d = 0; +static int32_t cam_600d = 0; + +#define MAX_WRITER_THREADS 2 + +static uint32_t raw_rec_edmac_align = 4096; +static uint32_t raw_rec_write_align = 4096; + +static uint32_t mlv_writer_threads = 2; +uint32_t trace_ctx = TRACE_ERROR; +static uint32_t abort_test = 0; +/** + * resolution should be multiple of 16 horizontally + * see http://www.magiclantern.fm/forum/index.php?topic=5839.0 + * use roughly 10% increments + **/ + +static int resolution_presets_x[] = { 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408 ,1472, 1536, 1600, 1664, 1728, 1792, 1856, 1920, 1984, 2048, 2560, 2880, 3456, 3520 }; +#define RESOLUTION_CHOICES_X CHOICES( "640","704","768","832","896","960","1024","1088","1152","1216","1280","1344","1408","1472","1536","1600","1664","1728","1792","1856","1920","1984","2048","2560","2880", "3456", "3520") + +static int aspect_ratio_presets_num[] = { 5, 4 , 3, 8, 25, 239, 235, 22, 2, 185, 16, 5, 3, 4, 1, 1, 9}; +static int aspect_ratio_presets_den[] = { 1, 1, 1, 3, 10, 100, 100, 10, 1, 100, 9, 3, 2, 3, 1, 2, 16}; +static const char * aspect_ratio_choices[] = { "5:1","4:1","3:1","2.67:1","2.50:1","2.39:1","2.35:1","2.20:1","2:1","1.85:1", "16:9","5:3","3:2","4:3","1:1","1:2","9:16"}; + +/* config variables */ + +static CONFIG_INT("raw.video.enabled", raw_video_enabled, 0); + +static CONFIG_INT("raw.video.buffer_fill_method", buffer_fill_method, 4); +static CONFIG_INT("raw.video.fast_card_buffers", fast_card_buffers, 3); +static CONFIG_INT("raw.video.test_mode", test_mode, 0); +static CONFIG_INT("raw.video.tracing", enable_tracing, 0); +static CONFIG_INT("raw.video.show_graph", show_graph, 0); + +static CONFIG_INT("raw.res.x", resolution_index_x, 12); +static CONFIG_INT("raw.aspect.ratio", aspect_ratio_index, 10); +static CONFIG_INT("raw.write.speed", measured_write_speed, 0); +static CONFIG_INT("raw.skip.frames", allow_frame_skip, 0); +static CONFIG_INT("raw.skip.card_spanning", card_spanning, 0); +static CONFIG_INT("raw.sound", sound_rec, 0); + +static CONFIG_INT("raw.delay", start_delay_idx, 0); +static CONFIG_INT("raw.killgd", kill_gd, 1); +static CONFIG_INT("raw.reckey", rec_key, 0); + + +static CONFIG_INT("raw.dolly", dolly_mode, 0); +#define FRAMING_CENTER (dolly_mode == 0) +#define FRAMING_PANNING (dolly_mode == 1) + +static CONFIG_INT("raw.preview", preview_mode, 0); +#define PREVIEW_AUTO (preview_mode == 0) +#define PREVIEW_CANON (preview_mode == 1) +#define PREVIEW_ML (preview_mode == 2) +#define PREVIEW_HACKED (preview_mode == 3) +#define PREVIEW_NOT (preview_mode == 4) + + +static CONFIG_INT("raw.warm.up", warm_up, 0); +static CONFIG_INT("raw.memory.hack", memory_hack, 0); +static CONFIG_INT("raw.small.hacks", small_hacks, 1); + + +/* state variables */ +static int start_delay = 0; + +static int32_t res_x = 0; +static int32_t res_y = 0; +static int32_t max_res_x = 0; +static int32_t max_res_y = 0; +static float squeeze_factor = 0; +static int32_t frame_size = 0; +static int32_t skip_x = 0; +static int32_t skip_y = 0; + +static int32_t frame_offset_x = 0; +static int32_t frame_offset_y = 0; +static int32_t frame_offset_delta_x = 0; +static int32_t frame_offset_delta_y = 0; + +#define RAW_IDLE 0 +#define RAW_PREPARING 1 +#define RAW_RECORDING 2 +#define RAW_FINISHING 3 + +static int32_t raw_recording_state = RAW_IDLE; +static int32_t raw_playing = 0; +static int32_t raw_previewing = 0; + +#define RAW_IS_IDLE (raw_recording_state == RAW_IDLE) +#define RAW_IS_PREPARING (raw_recording_state == RAW_PREPARING) +#define RAW_IS_RECORDING (raw_recording_state == RAW_RECORDING) +#define RAW_IS_FINISHING (raw_recording_state == RAW_FINISHING) + +/* if these get set, on the next frame the according blocks get queued */ +static int32_t mlv_update_lens = 0; +static int32_t mlv_update_styl = 0; +static int32_t mlv_update_wbal = 0; + + +static mlv_expo_hdr_t last_expo_hdr; +static mlv_lens_hdr_t last_lens_hdr; +static mlv_wbal_hdr_t last_wbal_hdr; +static mlv_styl_hdr_t last_styl_hdr; + + + +/* one video frame */ +struct frame_slot +{ + void *ptr; + int32_t frame_number; /* from 0 to n */ + int32_t size; + int32_t writer; + enum {SLOT_FREE, SLOT_FULL, SLOT_WRITING} status; +}; + +struct frame_slot_group +{ + int32_t slot; + int32_t len; + int32_t size; +}; + +typedef struct +{ + uint32_t block_len; + uint32_t block_start; + uint32_t block_size; + void *block_ptr; + + /* filled by writer */ + int64_t time_before; + int64_t time_after; + int64_t last_time_after; + uint32_t writer; +} write_job_t; + +static struct memSuite * mem_suite = 0; /* memory suite for our buffers */ + +static void * fullsize_buffers[2]; /* original image, before cropping, double-buffered */ +static int32_t fullsize_buffer_pos = 0; /* which of the full size buffers (double buffering) is currently in use */ + +static struct frame_slot slots[512]; /* frame slots */ +static struct frame_slot_group slot_groups[512]; +static int32_t slot_count = 0; /* how many frame slots we have */ +static int32_t slot_group_count = 0; +static int32_t capture_slot = -1; /* in what slot are we capturing now (index) */ +static volatile int32_t force_new_buffer = 0; /* if some other task decides it's better to search for a new buffer */ + +static int32_t frame_count = 0; /* how many frames we have processed */ +static int32_t frame_skips = 0; /* how many frames were dropped/skipped */ +static char* movie_filename = 0; /* file name for current (or last) movie */ + +/* per-thread data */ +static char chunk_filename[MAX_WRITER_THREADS][100]; /* file name for current movie chunk */ +static uint32_t written[MAX_WRITER_THREADS]; /* how many KB we have written in this movie */ +static uint32_t frames_written[MAX_WRITER_THREADS]; /* how many frames we have written in this movie */ +static int32_t writing_time[MAX_WRITER_THREADS]; /* time spent by raw_video_rec_task in FIO_WriteFile calls */ +static int32_t idle_time[MAX_WRITER_THREADS]; /* time spent by raw_video_rec_task doing something else */ +static FILE *mlv_handles[MAX_WRITER_THREADS]; +static struct msg_queue *mlv_writer_queues[MAX_WRITER_THREADS]; + +/* mlv information */ +struct msg_queue *mlv_block_queue = NULL; +struct msg_queue *mlv_mgr_queue = NULL; +static uint64_t mlv_start_timestamp = 0; +static mlv_file_hdr_t mlv_file_hdr; + +/* info block data */ +static char raw_tag_str[1024]; +static char raw_tag_str_tmp[1024]; +static int32_t raw_tag_take = 0; + +static int32_t mlv_file_count = 0; + +static volatile int32_t frame_countdown = 0; /* for waiting X frames */ + +/* interface to other modules: + * + * uint32_t raw_rec_skip_frame(unsigned char *frame_data) + * This function is called on every single raw frame that is received from sensor with a pointer to frame data as parameter. + * If the return value is zero, the frame will get save into the saving buffers, else it is skipped + * Default: Do not skip frame (0) + * + * uint32_t raw_rec_save_buffer(uint32_t used, uint32_t buffer_count) + * This function is called whenever the writing loop is checking if it has data to save to card. + * The parameters are the number of used buffers and the total buffer count + * Default: Save buffer (1) + * + * uint32_t raw_rec_skip_buffer(uint32_t buffer_index, uint32_t buffer_count); + * Whenever the buffers are full, this function is called with the buffer index that is subject to being dropped, the number of frames in this buffer and the total buffer count. + * If it returns zero, this buffer will not get thrown away, but the next frame will get dropped. + * Default: Do not throw away buffer, but throw away incoming frame (0) + */ +extern WEAK_FUNC(ret_0) uint32_t raw_rec_cbr_starting(); +extern WEAK_FUNC(ret_0) uint32_t raw_rec_cbr_stopping(); +extern WEAK_FUNC(ret_0) uint32_t raw_rec_cbr_mlv_block(mlv_hdr_t *hdr); +extern WEAK_FUNC(ret_0) uint32_t raw_rec_cbr_skip_frame(unsigned char *frame_data); +extern WEAK_FUNC(ret_1) uint32_t raw_rec_cbr_save_buffer(uint32_t used, uint32_t buffer_index, uint32_t frame_count, uint32_t buffer_count); +extern WEAK_FUNC(ret_0) uint32_t raw_rec_cbr_skip_buffer(uint32_t buffer_index, uint32_t frame_count, uint32_t buffer_count); + + +// extern int32_t msg_queue_receive(struct msg_queue *queue, void *buffer, uint32_t timeout); +extern int32_t msg_queue_count(struct msg_queue *queue, uint32_t *count); +extern struct msg_queue *msg_queue_create(char *name, uint32_t backlog); + +static void flush_queue(struct msg_queue *queue) +{ + uint32_t messages = 0; + + msg_queue_count(queue, &messages); + while(messages > 0) + { + uint32_t tmp_buf = 0; + msg_queue_receive(queue, (struct event **)&tmp_buf, 0); + msg_queue_count(queue, &messages); + } +} + +static int32_t calc_res_y(int32_t res_x, int32_t num, int32_t den, float squeeze) +{ + if (squeeze != 1.0f) + { + /* image should be enlarged vertically in post by a factor equal to "squeeze" */ + return (int32_t)(roundf(res_x * den / num / squeeze) + 1) & ~1; + } + else + { + /* assume square pixels */ + return (res_x * den / num + 1) & ~1; + } +} + +static void update_cropping_offsets() +{ + int32_t sx = raw_info.active_area.x1 + (max_res_x - res_x) / 2; + int32_t sy = raw_info.active_area.y1 + (max_res_y - res_y) / 2; + + if (FRAMING_PANNING) + { + sx += frame_offset_x; + sy += frame_offset_y; + } + else if (FRAMING_CENTER && lv_dispsize > 1) + { + /* try to center the recording window on the YUV frame */ + int delta_x, delta_y; + int32_t ok = focus_box_get_raw_crop_offset(&delta_x, &delta_y); + if (ok) + { + sx = COERCE(sx - delta_x, raw_info.active_area.x1, raw_info.active_area.x2 - res_x); + sy = COERCE(sy - delta_y, raw_info.active_area.y1, raw_info.active_area.y2 - res_y); + } + } + + skip_x = sx; + skip_y = sy; +} + +static void update_resolution_params() +{ + /* max res X */ + /* make sure we don't get dead pixels from rounding */ + int32_t left_margin = (raw_info.active_area.x1 + 7) / 8 * 8; + int32_t right_margin = (raw_info.active_area.x2) / 8 * 8; + int32_t max = (right_margin - left_margin) & ~15; + while (max % 16) max--; + max_res_x = max; + + /* max res Y */ + max_res_y = raw_info.jpeg.height & ~1; + + /* squeeze factor */ + if ( (cam_eos_m && !video_mode_crop) ? (lv_dispsize == 1) : (video_mode_resolution == 1 && lv_dispsize == 1 && is_movie_mode()) ) /* 720p, image squeezed */ + { + /* assume the raw image should be 16:9 when de-squeezed */ + int32_t correct_height = max_res_x * 9 / 16; + //int32_t correct_height = max_res_x * 2 / 3; //TODO : FIX THIS, USE FOR NON-FULLFRAME SENSORS! + squeeze_factor = (float)correct_height / max_res_y; + } + else squeeze_factor = 1.0f; + + /* res X */ + res_x = MIN(resolution_presets_x[resolution_index_x], max_res_x); + + /* res Y */ + int32_t num = aspect_ratio_presets_num[aspect_ratio_index]; + int32_t den = aspect_ratio_presets_den[aspect_ratio_index]; + res_y = MIN(calc_res_y(res_x, num, den, squeeze_factor), max_res_y); + + /* frame size without rounding */ + /* must be multiple of 4 */ + frame_size = res_x * res_y * 14/8; + ASSERT(frame_size % 4 == 0); + + update_cropping_offsets(); +} + +static char* guess_aspect_ratio(int32_t res_x, int32_t res_y) +{ + static char msg[20]; + int32_t best_num = 0; + int32_t best_den = 0; + float ratio = (float)res_x / res_y; + float minerr = 100; + /* common ratios that are expressed as integer numbers, e.g. 3:2, 16:9, but not 2.35:1 */ + static int32_t common_ratios_x[] = {1, 2, 3, 3, 4, 16, 5, 5}; + static int32_t common_ratios_y[] = {1, 1, 1, 2, 3, 9, 4, 3}; + for (int32_t i = 0; i < COUNT(common_ratios_x); i++) + { + int32_t num = common_ratios_x[i]; + int32_t den = common_ratios_y[i]; + float err = ABS((float)num / den - ratio); + if (err < minerr) + { + minerr = err; + best_num = num; + best_den = den; + } + } + + if (minerr < 0.05) + { + int32_t h = calc_res_y(res_x, best_num, best_den, squeeze_factor); + /* if the difference is 1 pixel, consider it exact */ + char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; + snprintf(msg, sizeof(msg), "%s%d:%d", qualifier, best_num, best_den); + } + else if (ratio > 1) + { + int32_t r = (int32_t)roundf(ratio * 100); + /* is it 2.35:1 or 2.353:1? */ + int32_t h = calc_res_y(res_x, r, 100, squeeze_factor); + char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; + if (r%100) snprintf(msg, sizeof(msg), "%s%d.%02d:1", qualifier, r/100, r%100); + } + else + { + int32_t r = (int32_t)roundf((1/ratio) * 100); + int32_t h = calc_res_y(res_x, 100, r, squeeze_factor); + char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; + if (r%100) snprintf(msg, sizeof(msg), "%s1:%d.%02d", qualifier, r/100, r%100); + } + return msg; +} + +static int32_t predict_frames(int32_t write_speed) +{ + int32_t slot_size = frame_size + 64 + raw_rec_edmac_align + raw_rec_write_align; + + int32_t fps = fps_get_current_x1000(); + int32_t capture_speed = slot_size / 1000 * fps; + int32_t buffer_fill_speed = capture_speed - write_speed; + if (buffer_fill_speed <= 0) + return INT_MAX; + + int32_t write_size = 0; + for (int32_t group = 0; group < slot_group_count; group++) + { + write_size += slot_groups[group].size; + } + + float buffer_fill_time = write_size / (float) buffer_fill_speed; + int32_t frames = buffer_fill_time * fps / 1000; + return frames; +} + +/* how many frames can we record with current settings, without dropping? */ +static char* guess_how_many_frames() +{ + if (!measured_write_speed) return ""; + + int32_t write_speed_lo = measured_write_speed * 1024 / 100 * 1024 - 512 * 1024; + int32_t write_speed_hi = measured_write_speed * 1024 / 100 * 1024 + 512 * 1024; + + int32_t f_lo = predict_frames(write_speed_lo); + int32_t f_hi = predict_frames(write_speed_hi); + + static char msg[50]; + if (f_lo < 5000) + { + int32_t write_speed = (write_speed_lo + write_speed_hi) / 2; + write_speed = (write_speed * 10 + 512 * 1024) / (1024 * 1024); + if (f_lo != f_hi) + snprintf(msg, sizeof(msg), "Expect %d-%d frames at %d.%dMB/s.", f_lo, f_hi, write_speed / 10, write_speed % 10); + else + snprintf(msg, sizeof(msg), "Expect around %d frames at %d.%dMB/s.", f_lo, write_speed / 10, write_speed % 10); + } + else + { + snprintf(msg, sizeof(msg), "Continuous recording OK."); + } + + return msg; +} + +static MENU_UPDATE_FUNC(write_speed_update) +{ + int32_t fps = fps_get_current_x1000(); + int32_t speed = (res_x * res_y * 14/8 / 1024) * fps / 10 / 1024; + int32_t ok = speed < measured_write_speed; + speed /= 10; + + + if (!measured_write_speed) + MENU_SET_WARNING(ok ? MENU_WARN_INFO : MENU_WARN_ADVICE, + "Write speed needed: %d.%d MB/s at %d.%03d fps.", + speed/10, speed%10, fps/1000, fps%1000 + ); + else + MENU_SET_WARNING(ok ? MENU_WARN_INFO : MENU_WARN_ADVICE, + "%d.%d MB/s at %d.%03dp. %s", + speed/10, speed%10, fps/1000, fps%1000, + guess_how_many_frames() + ); +} + +static void refresh_raw_settings(int32_t force) +{ + if (!lv) return; + + if (RAW_IS_IDLE && !raw_playing && !raw_previewing) + { + /* autodetect the resolution (update 4 times per second) */ + static int32_t aux = INT_MIN; + if (force || should_run_polling_action(250, &aux)) + { + if (raw_update_params()) + { + update_resolution_params(); + } + } + } +} + +static MENU_UPDATE_FUNC(raw_main_update) +{ + if (!raw_video_enabled) return; + + refresh_raw_settings(0); + + if (auto_power_off_time) + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "\"Auto power off\" is enabled in Canon menu. Video may stop."); + + if (is_custom_movie_mode() && !is_native_movie_mode()) + { + MENU_SET_WARNING(MENU_WARN_ADVICE, "You are recording video in photo mode. Use expo override."); + } + + if (!RAW_IS_IDLE) + { + MENU_SET_VALUE(RAW_IS_RECORDING ? "Recording..." : RAW_IS_PREPARING ? "Starting..." : RAW_IS_FINISHING ? "Stopping..." : "err"); + MENU_SET_ICON(MNI_RECORD, 0); + } + else + { + MENU_SET_VALUE("ON, %dx%d", res_x, res_y); + } + + write_speed_update(entry, info); +} + +static MENU_UPDATE_FUNC(aspect_ratio_update_info) +{ + if (squeeze_factor == 1.0f) + { + char* ratio = guess_aspect_ratio(res_x, res_y); + MENU_SET_HELP("%dx%d (%s)", res_x, res_y, ratio); + } + else + { + int32_t num = aspect_ratio_presets_num[aspect_ratio_index]; + int32_t den = aspect_ratio_presets_den[aspect_ratio_index]; + int32_t sq100 = (int32_t)roundf(squeeze_factor*100); + int32_t res_y_corrected = calc_res_y(res_x, num, den, 1.0f); + MENU_SET_HELP("%dx%d. Stretch by %s%d.%02dx to get %dx%d (%s) in post.", res_x, res_y, FMT_FIXEDPOINT2(sq100), res_x, res_y_corrected, aspect_ratio_choices[aspect_ratio_index]); + } +} + +static MENU_UPDATE_FUNC(resolution_update) +{ + if (!raw_video_enabled || !lv) + { + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Enable RAW video first."); + MENU_SET_VALUE("N/A"); + return; + } + + refresh_raw_settings(1); + + int32_t selected_x = resolution_presets_x[resolution_index_x]; + + MENU_SET_VALUE("%dx%d", res_x, res_y); + + if (selected_x > max_res_x) + { + MENU_SET_HELP("%d is not possible in current video mode (max %d).", selected_x, max_res_x); + } + else + { + aspect_ratio_update_info(entry, info); + } + + write_speed_update(entry, info); +} + +static MENU_UPDATE_FUNC(aspect_ratio_update) +{ + if (!raw_video_enabled || !lv) + { + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Enable RAW video first."); + MENU_SET_VALUE("N/A"); + return; + } + + refresh_raw_settings(0); + + int32_t num = aspect_ratio_presets_num[aspect_ratio_index]; + int32_t den = aspect_ratio_presets_den[aspect_ratio_index]; + int32_t selected_y = calc_res_y(res_x, num, den, squeeze_factor); + + if (selected_y > max_res_y + 2) + { + char* ratio = guess_aspect_ratio(res_x, res_y * squeeze_factor); + MENU_SET_VALUE(ratio); + MENU_SET_HELP("Could not get %s. Max vertical resolution: %d.", aspect_ratio_choices[aspect_ratio_index], res_y); + } + else + { + aspect_ratio_update_info(entry, info); + } + write_speed_update(entry, info); +} + +static void setup_chunk(uint32_t ptr, uint32_t size) +{ + if((int32_t)size < frame_size) + { + return; + } + + /* write alignment */ + uint32_t pre_align = raw_rec_write_align - (ptr % raw_rec_write_align); + ptr += pre_align; + size -= pre_align; + + /* fit as many frames as we can */ + while (size >= (frame_size + raw_rec_edmac_align + raw_rec_write_align) && (slot_count < COUNT(slots))) + { + mlv_vidf_hdr_t *vidf_hdr = (mlv_vidf_hdr_t *)ptr; + memset(vidf_hdr, 0x00, sizeof(mlv_vidf_hdr_t)); + mlv_set_type((mlv_hdr_t *)vidf_hdr, "VIDF"); + + /* write frame header */ + uint32_t dataStart = (uint32_t)vidf_hdr + sizeof(mlv_vidf_hdr_t); + int32_t edmac_size_align = raw_rec_edmac_align - (dataStart % raw_rec_edmac_align); + vidf_hdr->frameSpace = edmac_size_align; + vidf_hdr->blockSize = sizeof(mlv_vidf_hdr_t) + edmac_size_align + frame_size; + + /* now add a NULL block for aligning the whole slot size to optimal write size */ + int32_t write_size_align = raw_rec_write_align - (vidf_hdr->blockSize % raw_rec_write_align); + if(write_size_align < (int32_t)sizeof(mlv_hdr_t)) + { + write_size_align += raw_rec_write_align; + } + + mlv_hdr_t *write_align_hdr = (mlv_hdr_t *)((uint32_t)vidf_hdr + vidf_hdr->blockSize); + memset(write_align_hdr, 0xA5, write_size_align); + mlv_set_type(write_align_hdr, "NULL"); + write_align_hdr->blockSize = write_size_align; + + /* store this slot */ + slots[slot_count].ptr = (void*)ptr; + slots[slot_count].status = SLOT_FREE; + slots[slot_count].size = vidf_hdr->blockSize + write_align_hdr->blockSize; + + trace_write(trace_ctx, "slot %d: edmac_size_align = %d, write_size_align = %d, data_start = 0x%X, size = 0x%X", slot_count, edmac_size_align, write_size_align, dataStart + vidf_hdr->frameSpace, slots[slot_count].size); + + ptr += slots[slot_count].size; + size -= slots[slot_count].size; + slot_count++; + } +} + +static int32_t setup_buffers() +{ + slot_count = 0; + slot_group_count = 0; + fullsize_buffers[0] = 0; + fullsize_buffers[1] = 0; + + /* allocate the entire memory, but only use large chunks */ + /* yes, this may be a bit wasteful, but at least it works */ + + if(memory_hack) + { + PauseLiveView(); + msleep(200); + } + + mem_suite = shoot_malloc_suite(0); + + if(memory_hack) + { + ResumeLiveView(); + msleep(500); + while (!raw_update_params()) + { + msleep(100); + } + refresh_raw_settings(1); + } + + if (!mem_suite) + { + return 0; + } + + /* allocate memory for double buffering */ + int32_t buf_size = raw_info.width * raw_info.height * 14/8 * 33/32; /* leave some margin, just in case */ + + /* find the smallest chunk that we can use for buf_size */ + struct memChunk * chunk = GetFirstChunkFromSuite(mem_suite); + int32_t waste = INT_MAX; + while(chunk) + { + int32_t size = GetSizeOfMemoryChunk(chunk); + if (size >= buf_size) + { + if (size - buf_size < waste) + { + waste = size - buf_size; + fullsize_buffers[0] = GetMemoryAddressOfMemoryChunk(chunk); + } + } + chunk = GetNextMemoryChunk(mem_suite, chunk); + } + + /* reuse Canon's buffer */ + fullsize_buffers[1] = UNCACHEABLE(raw_info.buffer); + + if (fullsize_buffers[0] == 0 || fullsize_buffers[1] == 0) + { + return 0; + } + + + /* use all chunks larger than frame_size for recording */ + chunk = GetFirstChunkFromSuite(mem_suite); + + while(chunk) + { + uint32_t size = GetSizeOfMemoryChunk(chunk); + uint32_t ptr = (uint32_t)GetMemoryAddressOfMemoryChunk(chunk); + + if (ptr != (uint32_t)fullsize_buffers[0]) /* already used */ + { + setup_chunk(ptr, size); + } + chunk = GetNextMemoryChunk(mem_suite, chunk); + } + +#if 0 + /* try to recycle the waste - BUG: seems to cause memory corruption */ + if (waste >= frame_size) + { + uint32_t size = waste; + uint32_t ptr = (uint32_t)fullsize_buffers[0] + buf_size; + + setup_chunk(ptr, size); + } +#endif + + char msg[100]; + snprintf(msg, sizeof(msg), "buffer size: %d frames", slot_count); + bmp_printf(FONT_MED, 30, 90, msg); + + /* we need at least 3 slots */ + if (slot_count < 3) + { + return 0; + } + + trace_write(trace_ctx, "Building a group list..."); + uint32_t block_start = 0; + uint32_t block_len = 0; + uint32_t block_size = 0; + uint32_t last_slot_end = 0; + + /* this loop goes one slot behind the end */ + for(int32_t slot = 0; slot <= slot_count; slot++) + { + uint32_t slot_start = 0; + uint32_t slot_end = 0; + + if(slot < slot_count) + { + slot_start = (uint32_t) slots[slot].ptr; + slot_end = slot_start + slots[slot].size; + } + + /* the first time, on a non contiguous area or the last frame (its == slot_count) reset all counters */ + uint32_t non_contig = slot_start != last_slot_end; + uint32_t last_iteration = slot == slot_count; + + if((block_len != 0) && (non_contig || last_iteration)) + { + slot_groups[slot_group_count].slot = block_start; + slot_groups[slot_group_count].len = block_len; + slot_groups[slot_group_count].size = block_size; + + trace_write(trace_ctx, "group: %d block_len: %d block_start: %d", slot_group_count, block_len, block_start); + slot_group_count++; + + if(slot == slot_count) + { + break; + } + block_len = 0; + } + + if(slot < slot_count) + { + if(block_len == 0) + { + block_len = 1; + block_start = slot; + block_size = slots[slot].size; + } + else + { + /* its a contiguous area, increase counters */ + block_len++; + block_size += slots[slot].size; + } + } + last_slot_end = slot_end; + } + + /* hackish bubble sort group list */ + trace_write(trace_ctx, "Sorting group list..."); + int n = slot_group_count; + do + { + int newn = 1; + for (int i = 0; i < n-1; ++i) + { + if (slot_groups[i].len < slot_groups[i+1].len) + { + struct frame_slot_group tmp = slot_groups[i+1]; + slot_groups[i+1] = slot_groups[i]; + slot_groups[i] = tmp; + newn = i + 1; + } + } + n = newn; + } while (n > 1); + + for(int group = 0; group < slot_group_count; group++) + { + trace_write(trace_ctx, "group: %d length: %d slot: %d", group, slot_groups[group].len, slot_groups[group].slot); + } + return 1; +} + +static void free_buffers() +{ + if (mem_suite) + { + shoot_free_suite(mem_suite); + } + mem_suite = 0; +} + +static int32_t get_free_slots() +{ + int32_t free_slots = 0; + for (int32_t i = 0; i < slot_count; i++) + if (slots[i].status == SLOT_FREE) + free_slots++; + return free_slots; +} + +static void show_buffer_status() +{ + if (!liveview_display_idle()) return; + + char buffer_str[256]; + int buffer_str_pos = 0; + + int32_t scale = MAX(1, (300 / slot_count + 1) & ~1); + int32_t x = 30; + int32_t y = 50; + + for (int32_t group = 0; group < slot_group_count; group++) + { + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = '['; + } + + for (int32_t slot = slot_groups[group].slot; slot < (slot_groups[group].slot + slot_groups[group].len); slot++) + { + int32_t color = COLOR_BLACK; + + switch(slots[slot].status) + { + case SLOT_FREE: + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = ' '; + } + color = COLOR_GRAY(10); + break; + + case SLOT_WRITING: + if(slots[slot].writer == 0) + { + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = '0'; + } + color = COLOR_GREEN1; + } + else + { + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = '1'; + } + color = COLOR_YELLOW; + } + break; + + case SLOT_FULL: + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = 'F'; + } + color = COLOR_LIGHT_BLUE; + break; + + default: + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = '?'; + } + color = COLOR_BLACK; + break; + } + + for(int32_t k = 0; k < scale; k++) + { + draw_line(x, y+5, x, y+17, color); + x++; + } + + if(scale > 3) + { + x++; + } + } + x += MAX(2, scale); + + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = ']'; + } + } + if(enable_tracing) + { + buffer_str[buffer_str_pos++] = '\000'; + trace_write(trace_ctx, buffer_str); + } + + if (frame_skips > 0) + { + bmp_printf(FONT(FONT_MED, COLOR_RED, COLOR_BLACK), x+10, y, "%d skips", frame_skips); + } + + if(show_graph) + { + int32_t free = get_free_slots(); + int32_t x = frame_count % 720; + int32_t ymin = 190; + int32_t ymax = 400; + int32_t y = ymin + free * (ymax - ymin) / slot_count; + static int32_t prev_x = 0; + static int32_t prev_y = 0; + if (prev_x && prev_y && prev_x < x) + { + draw_line(prev_x, prev_y, x, y, COLOR_GREEN1); + } + dot(x-16, y-16, COLOR_GREEN1, 3); + prev_x = x; + prev_y = y; + + static int32_t prev_xp = 0; + if(prev_xp) + { + draw_line(prev_xp, ymax, prev_xp, ymin, COLOR_BLACK); + } + int32_t xp = predict_frames(measured_write_speed * 1024 / 100 * 1024) % 720; + draw_line(xp, ymax, xp, ymin, COLOR_RED); + prev_xp = xp; + + bmp_draw_rect(COLOR_GRAY(20), 0, ymin, 720, ymax-ymin); + } +} + +static uint32_t raw_rec_should_preview(uint32_t ctx); + +static void cropmark_draw() +{ + if (lv_dispsize > 1) return; + if (hdmi_code == 5) return; //Don't draw in HDMI + + int32_t x = RAW2BM_X(skip_x); + int32_t y = RAW2BM_Y(skip_y); + int32_t w = RAW2BM_DX(res_x); + int32_t h = RAW2BM_DY(res_y); + int32_t p = raw_rec_should_preview(0); + static int32_t prev_x = 0; + static int32_t prev_y = 0; + static int32_t prev_w = 0; + static int32_t prev_h = 0; + static int32_t prev_p = 0; + + /* window changed? erase the old cropmark */ + if ((prev_p != p) ^ (prev_x != x || prev_y != y || prev_w != w || prev_h != h)) + { + bmp_draw_rect(0, prev_x, prev_y, prev_w, prev_h); + bmp_draw_rect(0, prev_x-1, prev_y-1, prev_w+2, prev_h+2); + } + + prev_x = x; + prev_y = y; + prev_w = w; + prev_h = h; + + if (!p) + { + /* display a simple cropmark */ + bmp_draw_rect(COLOR_WHITE, x, y, w, h); + bmp_draw_rect(COLOR_BLACK, x-1, y-1, w+2, h+2); + } +} + +static void panning_update() +{ + if (!FRAMING_PANNING) return; + + int32_t sx = raw_info.active_area.x1 + (max_res_x - res_x) / 2; + int32_t sy = raw_info.active_area.y1 + (max_res_y - res_y) / 2; + + frame_offset_x = COERCE( + frame_offset_x + frame_offset_delta_x, + raw_info.active_area.x1 - sx, + raw_info.active_area.x1 + max_res_x - res_x - sx + ); + + frame_offset_y = COERCE( + frame_offset_y + frame_offset_delta_y, + raw_info.active_area.y1 - sy, + raw_info.active_area.y1 + max_res_y - res_y - sy + ); + + update_cropping_offsets(); +} + +static void raw_video_enable() +{ + /* toggle the lv_save_raw flag from raw.c */ + raw_lv_request(); + if (cam_50d && !(hdmi_code == 5)) + { + //~ call("lv_output_device", "vga"); //Shrink LV + call("lv_af_fase_addr", 0); //Turn off face detection + } + + /* EOS-M needs this hack. Please don't use it unless there's no other way. */ + if (!is_movie_mode()) set_custom_movie_mode(1); + + msleep(50); +} + +static void raw_video_disable() +{ + raw_lv_release(); + if (is_custom_movie_mode()) set_custom_movie_mode(0); +} + +static void raw_lv_request_update() +{ + static int32_t raw_lv_requested = 0; + + if (raw_video_enabled && lv) /* exception: EOS-M needs to record in photo mode */ + { + if (!raw_lv_requested) + { + raw_video_enable(); + raw_lv_requested = 1; + } + } + else + { + if (raw_lv_requested) + { + raw_video_disable(); + raw_lv_requested = 0; + } + } +} + + +static unsigned int raw_rec_polling_cbr(unsigned int unused) +{ + raw_lv_request_update(); + + if (!raw_video_enabled) + return 0; + + if (!lv || !is_movie_mode()) + return 0; + + /* refresh cropmark (faster when panning, slower when idle) */ + static int32_t aux = INT_MIN; + int cropmark_delay = RAW_IS_IDLE ? 500 : 10000; + + if (frame_offset_delta_x || frame_offset_delta_y || should_run_polling_action(cropmark_delay, &aux)) + { + if (liveview_display_idle()) + { + BMP_LOCK( cropmark_draw(); ) + } + } + + /* update settings when changing video modes (outside menu) */ + if (RAW_IS_IDLE && !gui_menu_shown()) + { + refresh_raw_settings(0); + } + + /* update status messages */ + static int32_t auxrec = INT_MIN; + static int32_t block_queueing = INT_MIN; + static int32_t rtci_queueing = INT_MIN; + + if (RAW_IS_RECORDING) + { + if(should_run_polling_action(MLV_RTCI_BLOCK_INTERVAL, &rtci_queueing)) + { + mlv_rtci_hdr_t *rtci_hdr = malloc(sizeof(mlv_rtci_hdr_t)); + mlv_fill_rtci(rtci_hdr, mlv_start_timestamp); + msg_queue_post(mlv_block_queue, rtci_hdr); + } + + /* enqueue lens, rtc, expo etc status */ + if(should_run_polling_action(MLV_INFO_BLOCK_INTERVAL, &block_queueing)) + { + mlv_expo_hdr_t *expo_hdr = malloc(sizeof(mlv_expo_hdr_t)); + mlv_lens_hdr_t *lens_hdr = malloc(sizeof(mlv_lens_hdr_t)); + mlv_wbal_hdr_t *wbal_hdr = malloc(sizeof(mlv_wbal_hdr_t)); + + mlv_fill_expo(expo_hdr, mlv_start_timestamp); + mlv_fill_lens(lens_hdr, mlv_start_timestamp); + mlv_fill_wbal(wbal_hdr, mlv_start_timestamp); + + msg_queue_post(mlv_block_queue, expo_hdr); + msg_queue_post(mlv_block_queue, lens_hdr); + msg_queue_post(mlv_block_queue, wbal_hdr); + } + + if(liveview_display_idle() && should_run_polling_action(DEBUG_REDRAW_INTERVAL, &auxrec)) + { + int32_t fps = fps_get_current_x1000(); + int32_t t = (frame_count * 1000 + fps/2) / fps; + int32_t predicted = predict_frames(measured_write_speed * 1024 / 100 * 1024); + if (predicted < 10000) + bmp_printf( FONT_MED, 30, cam_50d ? 350 : 400, + "%02d:%02d, %d frames / %d expected ", + t/60, t%60, + frame_count, + predicted + ); + else + bmp_printf( FONT_MED, 30, cam_50d ? 350 : 400, + "%02d:%02d, %d frames, continuous OK ", + t/60, t%60, + frame_count + ); + + show_buffer_status(); + + /* how fast are we writing? does this speed match our benchmarks? */ + for(uint32_t writer = 0; writer < mlv_writer_threads; writer++) + { + if (writing_time[writer] || idle_time[writer]) + { + int32_t speed = written[writer] * 100 / writing_time[writer] * 1000 / 1024; // MB/s x100 + int32_t idle_percent = idle_time[writer] * 100 / (writing_time[writer] + idle_time[writer]); + speed /= 10; + + char msg[100]; + snprintf(msg, sizeof(msg), + "%s: %d MB, %d.%d MB/s", + chunk_filename[writer], /* skip A:/DCIM/100CANON/ */ + written[writer] / 1024, + speed/10, speed%10 + ); + if (idle_time[writer]) + { + if (idle_percent) + { + STR_APPEND(msg, ", %d%% idle ", idle_percent); + } + else + { + STR_APPEND(msg, ", %dms idle ", idle_time[writer]); + } + } + bmp_printf( FONT_MED, 30, cam_50d ? 370 : 420 + writer * font_med.height, "%s", msg); + } + else + { + bmp_printf( FONT_MED, 30, cam_50d ? 370 : 420 + writer * font_med.height, "%s: Initializing", chunk_filename[writer]); + } + } + + if(card_spanning) + { + char msg[100]; + snprintf(msg, sizeof(msg), "Total rate: %d.%d MB/s", measured_write_speed/100, (measured_write_speed/10)%10); + bmp_printf( FONT_MED, 30, 130 + mlv_writer_threads * font_med.height, "%s", msg); + } + } + } + + return 0; +} + + + +static void unhack_liveview_vsync(int32_t unused); + +static void hack_liveview_vsync() +{ + if (cam_5d2 || cam_50d /*|| cam_7d*/ ) + { + /* try to fix pink preview in zoom mode (5D2/50D) */ + if (lv_dispsize > 1 && !get_halfshutter_pressed()) + { + if (RAW_IS_IDLE) + { + /** + * This register seems to be raw type on digic 4; digic 5 has it at c0f37014 + * - default is 5 on 5D2 with lv_save_raw, 0xB without, 4 is lv_af_raw + * - don't record this: you will have lots of bad pixels (no big deal if you can remove them) + * - don't record lv_af_raw: you will have random colored dots that contain focus info; their position is not fixed, so you can't remove them + * - use half-shutter heuristic for clean silent pics + * + * Reason for overriding here: + * - if you use lv_af_raw, you can no longer restore it when you start recording. + * - if you override here, image quality is restored as soon as you stop overriding + * - but pink preview is also restored, you can't have both + */ + + *(volatile uint32_t*)0xc0f08114 = 0; + } + else + { + /** + * While recording, we will have pink image + * Make it grayscale and bring the shadows down a bit + * (these registers will only touch the preview, not the recorded image) + */ + *(volatile uint32_t*)0xc0f0f070 = 0x01000100; + //~ *(volatile uint32_t*)0xc0f0e094 = 0; + *(volatile uint32_t*)0xc0f0f1c4 = 0xFFFFFFFF; + } + } + } + + //~ if (!PREVIEW_HACKED) return; + + int32_t rec = RAW_IS_RECORDING; + static int32_t prev_rec = 0; + int32_t should_hack = 0; + int32_t should_unhack = 0; + + if (rec) + { + if (frame_count == 0) + should_hack = 1; + } + else if (prev_rec) + { + should_unhack = 1; + } + prev_rec = rec; + + if (should_hack) + { + if(!PREVIEW_CANON && !PREVIEW_AUTO) +{ int y = 100; + for (int channel = 0; channel < 32; channel++) + { + /* silence out the EDMACs used for HD and LV buffers */ + int pitch = edmac_get_length(channel) & 0xFFFF; + if (pitch == vram_lv.pitch || pitch == vram_hd.pitch || pitch== 2000 || pitch== 512 || pitch== 576 || pitch== 3456) + //~ if (pitch == vram_lv.pitch || pitch == vram_hd.pitch) + { + uint32_t reg = edmac_get_base(channel); + bmp_printf(FONT_SMALL, 30, y += font_small.height, "Hack %x %dx%d ", reg, shamem_read(reg + 0x10) & 0xFFFF, shamem_read(reg + 0x10) >> 16); + *(volatile uint32_t *)(reg + 0x10) = shamem_read(reg + 0x10) & 0xFFFF; + } + } +} + } + else if (should_unhack) + { + if (cam_eos_m) //EOS-M not unhacking, why? + { //call("aewb_enableaewb", 1); + + PauseLiveView(); + ResumeLiveView(); + idle_globaldraw_en(); + } + else + task_create("lv_unhack", 0x1e, 0x1000, unhack_liveview_vsync, (void*)0); + } +} + +/* this is a separate task */ +static void unhack_liveview_vsync(int32_t unused) +{ + while (!RAW_IS_IDLE) msleep(100); + idle_globaldraw_en(); + PauseLiveView(); + ResumeLiveView(); +} + +static void hack_liveview(int32_t unhack) +{ + if (PREVIEW_NOT || kill_gd) + { + idle_globaldraw_dis(); + clrscr(); + } + + if (small_hacks) + { + /* disable canon graphics (gains a little speed) */ + static int32_t canon_gui_was_enabled; + if (!unhack) + { + canon_gui_was_enabled = !canon_gui_front_buffer_disabled(); + canon_gui_disable_front_buffer(); + } + else if (canon_gui_was_enabled) + { + canon_gui_enable_front_buffer(0); + canon_gui_was_enabled = 0; + } + + /* disable auto exposure and auto white balance */ + call("aewb_enableaewb", unhack ? 1 : 0); /* for new cameras */ + call("lv_ae", unhack ? 1 : 0); /* for old cameras */ + call("lv_wb", unhack ? 1 : 0); + + /* change dialog refresh timer from 50ms to 8192ms */ + uint32_t dialog_refresh_timer_addr = /* in StartDialogRefreshTimer */ + cam_50d ? 0xffa84e00 : + cam_5d2 ? 0xffaac640 : + cam_5d3 ? 0xff4acda4 : + cam_6d ? 0xFF52BE94 : + cam_eos_m ? 0xFF539C1C : + cam_600d ? 0xFF37AA18 : + cam_700d ? 0xFF52B53C : + cam_7d ? 0xFF345788 : + /* ... */ + 0; + uint32_t dialog_refresh_timer_orig_instr = 0xe3a00032; /* mov r0, #50 */ + uint32_t dialog_refresh_timer_new_instr = 0xe3a00a02; /* change to mov r0, #8192 */ + + if (*(volatile uint32_t*)dialog_refresh_timer_addr != dialog_refresh_timer_orig_instr) + { + /* something's wrong */ + NotifyBox(1000, "Hack error at %x:\nexpected %x, got %x", dialog_refresh_timer_addr, dialog_refresh_timer_orig_instr, *(volatile uint32_t*)dialog_refresh_timer_addr); + beep_custom(1000, 2000, 1); + dialog_refresh_timer_addr = 0; + } + + if (dialog_refresh_timer_addr) + { + if (!unhack) /* hack */ + { + cache_fake(dialog_refresh_timer_addr, dialog_refresh_timer_new_instr, TYPE_ICACHE); + } + else /* unhack */ + { + cache_fake(dialog_refresh_timer_addr, dialog_refresh_timer_orig_instr, TYPE_ICACHE); + } + } + } +} + +static int32_t FAST choose_next_capture_slot() +{ + + switch(buffer_fill_method) + { + case 0: + /* new: return next free slot for out-of-order writing */ + for (int32_t slot = 0; slot < slot_count; slot++) + { + if (slots[slot].status == SLOT_FREE) + { + return slot; + } + } + + return -1; + + case 4: + case 1: + /* new method: first fill largest group */ + for (int32_t group = 0; group < slot_group_count; group++) + { + for (int32_t slot = slot_groups[group].slot; slot < (slot_groups[group].slot + slot_groups[group].len); slot++) + { + if (slots[slot].status == SLOT_FREE) + { + return slot; + } + } + } + return -1; + + case 3: + /* new method: first fill largest groups */ + for (int32_t group = 0; group < fast_card_buffers; group++) + { + for (int32_t slot = slot_groups[group].slot; slot < (slot_groups[group].slot + slot_groups[group].len); slot++) + { + if (slots[slot].status == SLOT_FREE) + { + return slot; + } + } + } + + /* if those are already filled, queue anywhere */ + break; + + case 2: + default: + /* use default method below */ + break; + } + + + /* keep on rolling? */ + /* O(1) */ + if (capture_slot >= 0 && capture_slot + 1 < slot_count) + { + if(slots[capture_slot + 1].ptr == slots[capture_slot].ptr + slots[capture_slot].size && + slots[capture_slot + 1].status == SLOT_FREE && !force_new_buffer ) + return capture_slot + 1; + } + + + /* choose a new buffer? */ + /* choose the largest contiguous free section */ + /* O(n), n = slot_count */ + int32_t len = 0; + void* prev_ptr = INVALID_PTR; + int32_t prev_blockSize = 0; + int32_t best_len = 0; + int32_t best_index = -1; + for (int32_t i = 0; i < slot_count; i++) + { + if (slots[i].status == SLOT_FREE) + { + if (slots[i].ptr == prev_ptr + prev_blockSize) + { + len++; + prev_ptr = slots[i].ptr; + prev_blockSize = slots[i].size; + if (len > best_len) + { + best_len = len; + best_index = i - len + 1; + } + } + else + { + len = 1; + prev_ptr = slots[i].ptr; + prev_blockSize = slots[i].size; + if (len > best_len) + { + best_len = len; + best_index = i; + } + } + } + else + { + len = 0; + prev_ptr = INVALID_PTR; + } + } + + /* fixme: */ + /* avoid 32MB writes, they are slower (they require two DMA calls) */ + /* go back a few K and the speed is restored */ + //~ best_len = MIN(best_len, (32*1024*1024 - 8192) / frame_size); + + force_new_buffer = 0; + + return best_index; +} + +/* this function uses the frameSpace area in a VIDF that was meant for padding to insert some other block before */ +static int32_t mlv_prepend_block(mlv_vidf_hdr_t *vidf, mlv_hdr_t *block) +{ + if(!memcmp(vidf->blockType, "VIDF", 4)) + { + /* it's a VIDF block that should get shrinked and data prepended. + new layout: + NULL (with the old VIDF data content plus a backup of the original size, which is 4 bytes) + BLOCK + VIDF + */ + if(vidf->frameSpace < block->blockSize + sizeof(mlv_vidf_hdr_t) + 4 + 8) + { + /* there is not enough room */ + return 1; + } + + /* calculate start address of repositioned VIDF block */ + uint32_t block_offset = sizeof(mlv_vidf_hdr_t) + 4; + uint32_t new_vidf_offset = block_offset + block->blockSize; + + mlv_vidf_hdr_t *new_vidf = (mlv_vidf_hdr_t *)((uint32_t)vidf + new_vidf_offset); + + + /* copy VIDF header to new position and fix frameSpace */ + memcpy(new_vidf, vidf, sizeof(mlv_vidf_hdr_t)); + new_vidf->blockSize -= new_vidf_offset; + new_vidf->frameSpace -= new_vidf_offset; + + /* copy block to prepend */ + memcpy((void*)((uint32_t)vidf + block_offset), block, block->blockSize); + + /* set old header to a skipped header format */ + mlv_set_type((mlv_hdr_t *)vidf, "NULL"); + + /* backup old size into free space */ + ((uint32_t*) vidf)[sizeof(mlv_vidf_hdr_t)/4] = vidf->blockSize; + + /* then set the header to be totally skipped */ + vidf->blockSize = sizeof(mlv_vidf_hdr_t) + 4; + + return 0; + } + else if(!memcmp(vidf->blockType, "NULL", 4)) + { + /* there is already something injected, try to add a new block behind prepended */ + mlv_vidf_hdr_t *hdr = NULL; + uint32_t offset = vidf->blockSize; + + /* now skip until the VIDF is reached */ + while(offset < vidf->frameSpace) + { + hdr = (mlv_vidf_hdr_t *)((uint32_t)vidf + offset); + + ASSERT(hdr->blockSize > 0); + + if(!memcmp(hdr->blockType, "VIDF", 4)) + { + if(hdr->frameSpace < block->blockSize) + { + /* there is not enough room */ + return 2; + } + + /* calculate start address of the again repositioned VIDF block */ + mlv_vidf_hdr_t *new_vidf = (mlv_vidf_hdr_t *)((uint32_t)hdr + block->blockSize); + + /* copy VIDF header to new position and fix frameSpace */ + memcpy(new_vidf, hdr, sizeof(mlv_vidf_hdr_t)); + new_vidf->blockSize -= block->blockSize; + new_vidf->frameSpace -= block->blockSize; + + /* copy block to prepend */ + memcpy(hdr, block, block->blockSize); + + return 0; + } + else + { + /* skip to next block */ + offset += hdr->blockSize; + } + } + + return 0; + } + + return 4; +} + +static int32_t FAST process_frame() +{ + /* skip the first frame, it will be gibberish */ + if (frame_count == 0) + { + frame_count++; + return 0; + } + + /* where to save the next frame? */ + capture_slot = choose_next_capture_slot(capture_slot); + + if (capture_slot < 0) + { + /* card too slow */ + frame_skips++; + return 0; + } + + + /* restore from NULL block used when prepending data */ + mlv_vidf_hdr_t *hdr = slots[capture_slot].ptr; + if(!memcmp(hdr->blockType, "NULL", 4)) + { + mlv_set_type((mlv_hdr_t *)hdr, "VIDF"); + hdr->blockSize = ((uint32_t*) hdr)[sizeof(mlv_vidf_hdr_t)/4]; + ASSERT(hdr->blockSize > 0); + } + mlv_set_timestamp((mlv_hdr_t *)hdr, mlv_start_timestamp); + + /* frame number in file is off by one. nobody needs to know we skipped the first frame */ + hdr->frameNumber = frame_count - 1; + hdr->cropPosX = (skip_x + 7) & ~7; + hdr->cropPosY = (skip_y + 7) & ~7; + hdr->panPosX = skip_x; + hdr->panPosY = skip_y; + + void* ptr = (void*)((int32_t)hdr + sizeof(mlv_vidf_hdr_t) + hdr->frameSpace); + void* fullSizeBuffer = fullsize_buffers[(fullsize_buffer_pos+1) % 2]; + + /* advance to next buffer for the upcoming capture */ + fullsize_buffer_pos = (fullsize_buffer_pos + 1) % 2; + + /* dont process this frame if a module wants to skip that */ + if(raw_rec_cbr_skip_frame(fullSizeBuffer)) + { + return 0; + } + + /* try a sync beep */ + //~ if ((sound_rec == 2 && frame_count == 1) && !test_mode) + //~ { + //beep(); + //~ } + + int32_t ans = edmac_copy_rectangle_start(ptr, fullSizeBuffer, raw_info.pitch, (skip_x+7)/8*14, skip_y/2*2, res_x*14/8, res_y); + + /* write blocks if some were queued */ + static int32_t queued = 0; + static int32_t failed = 0; + uint32_t msg_count = 0; + + /* check if there is a block that should get embedded */ + msg_queue_count(mlv_block_queue, &msg_count); + + /* embed what is possible */ + for(uint32_t msg = 0; msg < msg_count; msg++) + { + mlv_hdr_t *block = NULL; + + /* there is a block in the queue, try to get that block */ + if(msg_queue_receive(mlv_block_queue, (struct event **)&block, 0)) + { + bmp_printf(FONT_MED, 0, 400, "MESSAGE RECEIVE ERROR!!"); + } + else + { + trace_write(trace_ctx, "--> call cbr for '%4s' block", block->blockType); + raw_rec_cbr_mlv_block(block); + trace_write(trace_ctx, "--> prepend '%4s' block", block->blockType); + + /* prepend the given block if possible or requeue it in case of error */ + int32_t ret = mlv_prepend_block(hdr, block); + if(!ret) + { + queued++; + free(block); + } + else + { + failed++; + msg_queue_post(mlv_block_queue, block); + bmp_printf(FONT_MED, 0, 430, "FAILED. queued: %d failed: %d (requeued)", queued, failed); + } + } + } + + /* copy current frame to our buffer and crop it to its final size */ + slots[capture_slot].frame_number = frame_count; + slots[capture_slot].status = SLOT_FULL; + + trace_write(trace_ctx, "==> enqueue frame %d in slot %d", frame_count, capture_slot); + + /* advance to next frame */ + frame_count++; + + return ans; +} + +static unsigned int FAST raw_rec_vsync_cbr(unsigned int unused) +{ + static int32_t dma_transfer_in_progress = 0; + /* there may be DMA transfers started in process_frame, finish them */ + /* let's assume they are faster than LiveView refresh rate (well, they HAVE to be) */ + if (dma_transfer_in_progress) + { + edmac_copy_rectangle_finish(); + dma_transfer_in_progress = 0; + } + + if (!raw_video_enabled) return 0; + if (!is_movie_mode()) return 0; + + if (frame_countdown) + frame_countdown--; + + hack_liveview_vsync(); + + /* panning window is updated when recording, but also when not recording */ + panning_update(); + + if (!RAW_IS_RECORDING) return 0; + if (!raw_lv_settings_still_valid()) { raw_recording_state = RAW_FINISHING; return 0; } + if (!allow_frame_skip && frame_skips) return 0; + + /* double-buffering */ + raw_lv_redirect_edmac(fullsize_buffers[fullsize_buffer_pos % 2]); + + dma_transfer_in_progress = process_frame(); + + if(mlv_update_lens) + { + mlv_update_lens = 0; + mlv_expo_hdr_t old_expo = last_expo_hdr; + mlv_lens_hdr_t old_lens = last_lens_hdr; + + mlv_fill_expo(&last_expo_hdr, mlv_start_timestamp); + mlv_fill_lens(&last_lens_hdr, mlv_start_timestamp); + + /* update timestamp for comparing content changes */ + old_expo.timestamp = last_expo_hdr.timestamp; + old_lens.timestamp = last_lens_hdr.timestamp; + + /* write new state if something changed */ + if(memcmp(&last_expo_hdr, &old_expo, sizeof(mlv_expo_hdr_t))) + { + mlv_hdr_t *hdr = malloc(sizeof(mlv_expo_hdr_t)); + memcpy(hdr, &last_expo_hdr, sizeof(mlv_expo_hdr_t)); + msg_queue_post(mlv_block_queue, hdr); + } + + /* write new state if something changed */ + if(memcmp(&last_lens_hdr, &old_lens, sizeof(mlv_lens_hdr_t))) + { + mlv_hdr_t *hdr = malloc(sizeof(mlv_lens_hdr_t)); + memcpy(hdr, &last_lens_hdr, sizeof(mlv_lens_hdr_t)); + msg_queue_post(mlv_block_queue, hdr); + } + } + + if(mlv_update_styl) + { + mlv_update_styl = 0; + + mlv_styl_hdr_t old_hdr = last_styl_hdr; + mlv_fill_styl(&last_styl_hdr, mlv_start_timestamp); + + /* update timestamp for comparing content changes */ + old_hdr.timestamp = last_styl_hdr.timestamp; + + /* write new state if something changed */ + if(memcmp(&last_styl_hdr, &old_hdr, sizeof(mlv_styl_hdr_t))) + { + mlv_hdr_t *hdr = malloc(sizeof(mlv_styl_hdr_t)); + memcpy(hdr, &last_styl_hdr, sizeof(mlv_styl_hdr_t)); + msg_queue_post(mlv_block_queue, hdr); + } + } + + if(mlv_update_wbal) + { + mlv_update_wbal = 0; + + /* capture last state and get new one */ + mlv_wbal_hdr_t old_hdr = last_wbal_hdr; + mlv_fill_wbal(&last_wbal_hdr, mlv_start_timestamp); + + /* update timestamp for comparing content changes */ + old_hdr.timestamp = last_wbal_hdr.timestamp; + + /* write new state if something changed */ + if(memcmp(&last_wbal_hdr, &old_hdr, sizeof(mlv_wbal_hdr_t))) + { + mlv_hdr_t *hdr = malloc(sizeof(mlv_wbal_hdr_t)); + memcpy(hdr, &last_wbal_hdr, sizeof(mlv_wbal_hdr_t)); + msg_queue_post(mlv_block_queue, hdr); + } + } + + return 0; +} + +static char* get_next_raw_movie_file_name() +{ + static char filename[100]; + + struct tm now; + LoadCalendarFromRTC(&now); + + for (int32_t number = 0 ; number < 100; number++) + { + /** + * Get unique file names from the current date/time + * last field gets incremented if there's another video with the same name + */ + snprintf(filename, sizeof(filename), "%s/M%02d-%02d%02d.MLV", get_dcim_dir(), now.tm_mday, now.tm_hour, COERCE(now.tm_min + number, 0, 99)); + + trace_write(trace_ctx, "Filename: '%s'", filename); + /* already existing file? */ + uint32_t size; + if( FIO_GetFileSize( filename, &size ) != 0 ) break; + if (size == 0) break; + } + + return filename; +} + +static int32_t get_next_chunk_file_name(char* base_name, char* filename, int32_t chunk) +{ + /* change file extension, according to chunk number: MLV, M00, M01 and so on */ + strcpy(filename, base_name); + + if(chunk > 0) + { + int32_t len = strlen(filename); + snprintf(filename + len - 2, 3, "%02d", chunk-1); + } + + return 0; +} + +static char* get_wav_file_name(char* movie_filename) +{ + /* same name as movie, but with wav extension */ + static char wavfile[100]; + snprintf(wavfile, sizeof(wavfile), movie_filename); + int32_t len = strlen(wavfile); + wavfile[len-4] = '.'; + wavfile[len-3] = 'W'; + wavfile[len-2] = 'A'; + wavfile[len-1] = 'V'; + /* prefer SD card for saving WAVs (should be faster on 5D3) */ + if (is_dir("B:/")) wavfile[0] = 'B'; + return wavfile; +} + +static int32_t mlv_write_info(FILE* f) +{ + mlv_info_hdr_t *hdr = malloc(1080); + char *str_pos = (char *)((uint32_t)hdr + sizeof(mlv_info_hdr_t)); + int32_t ret = 0; + + /* init empty string */ + strcpy(str_pos, ""); + + /* if any text is given, set it first */ + if(strlen(raw_tag_str) > 0) + { + strcpy(&str_pos[strlen(str_pos)], "text: "); + strcpy(&str_pos[strlen(str_pos)], raw_tag_str); + strcpy(&str_pos[strlen(str_pos)], "; "); + } + + /* if take number is enabled, append it */ + if(raw_tag_take) + { + char buf[32]; + + snprintf(buf, 32, "%d", raw_tag_take); + + strcpy(&str_pos[strlen(str_pos)], "take: "); + strcpy(&str_pos[strlen(str_pos)], buf); + strcpy(&str_pos[strlen(str_pos)], "; "); + } + + /* now build block header */ + mlv_set_type((mlv_hdr_t *)hdr, "INFO"); + mlv_set_timestamp((mlv_hdr_t *)hdr, mlv_start_timestamp); + hdr->blockSize = sizeof(mlv_info_hdr_t) + strlen(str_pos); + + int32_t written = FIO_WriteFile(f, hdr, hdr->blockSize); + ret = written == (int32_t)hdr->blockSize; + + free(hdr); + return ret; +} + +static void mlv_init_header() +{ + /* recording start timestamp */ + mlv_start_timestamp = mlv_set_timestamp(NULL, 0); + + /* setup header */ + mlv_init_fileheader(&mlv_file_hdr); + mlv_file_hdr.fileGuid = mlv_generate_guid(); + mlv_file_hdr.fileNum = 0; + mlv_file_hdr.fileCount = 0; + mlv_file_hdr.fileFlags = 1; + + /* for now only raw video, no sound */ + mlv_file_hdr.videoClass = 1; + mlv_file_hdr.audioClass = 0; + mlv_file_hdr.videoFrameCount = 0; + mlv_file_hdr.audioFrameCount = 0; + + /* can be improved to make use of nom/denom */ + mlv_file_hdr.sourceFpsNom = fps_get_current_x1000(); + mlv_file_hdr.sourceFpsDenom = 1000; +} + +static int32_t mlv_write_hdr(FILE* f, mlv_hdr_t *hdr) +{ + uint32_t written = FIO_WriteFile(f, hdr, hdr->blockSize); + + return written == hdr->blockSize; +} + +static int32_t mlv_write_rawi(FILE* f, struct raw_info raw_info) +{ + mlv_rawi_hdr_t rawi; + + mlv_set_type((mlv_hdr_t *)&rawi, "RAWI"); + mlv_set_timestamp((mlv_hdr_t *)&rawi, mlv_start_timestamp); + rawi.blockSize = sizeof(mlv_rawi_hdr_t); + rawi.xRes = res_x; + rawi.yRes = res_y; + rawi.raw_info = raw_info; + + return mlv_write_hdr(f, (mlv_hdr_t *)&rawi); +} + +static uint32_t find_largest_buffer(uint32_t start_group, write_job_t *write_job) +{ + write_job_t job; + uint32_t get_partial = 0; + +retry_find: + + /* initialize write job */ + memset(write_job, 0x00, sizeof(write_job_t)); + memset(&job, 0x00, sizeof(write_job_t)); + + for (int32_t group = start_group; group < slot_group_count; group++) + { + uint32_t block_len = 0; + uint32_t block_start = 0; + uint32_t block_size = 0; + + uint32_t group_full = 1; + + for (int32_t slot = slot_groups[group].slot; slot < (slot_groups[group].slot + slot_groups[group].len); slot++) + { + /* check for the slot being ready for saving */ + if(slots[slot].status == SLOT_FULL) + { + /* the first time or on a non contiguous area reset all counters */ + if(block_len == 0) + { + block_start = slot; + } + + block_len++; + block_size += slots[slot].size; + + /* we have a new candidate */ + if(block_len > job.block_len) + { + job.block_start = block_start; + job.block_len = block_len; + job.block_size = block_size; + } + } + else + { + group_full = 0; + block_len = 0; + block_size = 0; + block_start = 0; + } + } + + /* methods 3 and 4 want the "fast card" buffers to fill before queueing */ + if(buffer_fill_method == 3 || buffer_fill_method == 4) + { + /* the queued group is not ready to be queued yet, reset */ + if(!group_full && (group < fast_card_buffers) && !get_partial) + { + memset(&job, 0x00, sizeof(write_job_t)); + } + } + + /* if the current group has more frames, use it */ + if(job.block_len > write_job->block_len) + { + *write_job = job; + } + } + + /* if nothing was found, even a partially filled buffer is better than nothing */ + if(write_job->block_len == 0 && !get_partial) + { + get_partial = 1; + goto retry_find; + } + + + /* if we were able to locate blocks for writing, return 1 */ + return (write_job->block_len > 0); +} + +static uint32_t raw_get_next_filenum() +{ + uint32_t fileNum = 0; + + uint32_t old_int = cli(); + fileNum = mlv_file_hdr.fileCount; + mlv_file_hdr.fileCount++; + sei(old_int); + + return fileNum; +} + +static void raw_prepare_chunk(FILE *f, mlv_file_hdr_t *hdr) +{ + mlv_write_hdr(f, (mlv_hdr_t *)hdr); + + /* fill and write camera and lens information */ + if(hdr->fileNum == 0) + { + mlv_write_rawi(f, raw_info); + mlv_write_info(f); + + mlv_rtci_hdr_t rtci_hdr; + mlv_expo_hdr_t expo_hdr; + mlv_lens_hdr_t lens_hdr; + mlv_idnt_hdr_t idnt_hdr; + mlv_wbal_hdr_t wbal_hdr; + mlv_styl_hdr_t styl_hdr; + + mlv_fill_rtci(&rtci_hdr, mlv_start_timestamp); + mlv_fill_expo(&expo_hdr, mlv_start_timestamp); + mlv_fill_lens(&lens_hdr, mlv_start_timestamp); + mlv_fill_idnt(&idnt_hdr, mlv_start_timestamp); + mlv_fill_wbal(&wbal_hdr, mlv_start_timestamp); + mlv_fill_styl(&styl_hdr, mlv_start_timestamp); + + mlv_write_hdr(f, (mlv_hdr_t *)&rtci_hdr); + mlv_write_hdr(f, (mlv_hdr_t *)&expo_hdr); + mlv_write_hdr(f, (mlv_hdr_t *)&lens_hdr); + mlv_write_hdr(f, (mlv_hdr_t *)&idnt_hdr); + mlv_write_hdr(f, (mlv_hdr_t *)&wbal_hdr); + mlv_write_hdr(f, (mlv_hdr_t *)&styl_hdr); + } +} + +static void raw_writer_task(uint32_t writer) +{ + trace_write(trace_ctx, " --> WRITER#%d: starting", writer); + struct msg_queue *queue = mlv_writer_queues[writer]; + + /* keep it local to make sure it is getting optimized */ + FILE* f = mlv_handles[writer]; + + /* used to calculate the execution time of management code */ + int64_t last_time_after = 0; + /* number of frames in current chunk */ + uint32_t frames_written = 0; + /* in bytes, for current chunk */ + uint32_t written_chunk = 0; + + /* use global file header and update local fields */ + mlv_file_hdr_t file_header; + file_header = mlv_file_hdr; + file_header.videoFrameCount = 0; + file_header.audioFrameCount = 0; + + /* update file count */ + trace_write(trace_ctx, " --> WRITER#%d: updating file count...", writer); + file_header.fileNum = raw_get_next_filenum(); + trace_write(trace_ctx, " --> WRITER#%d: done, we are #%d", writer, file_header.fileNum); + + /* write file header and info chunks */ + raw_prepare_chunk(f, &file_header); + + written_chunk = FIO_SeekFile(f, 0, SEEK_CUR); + trace_write(trace_ctx, " --> WRITER#%d: writing headers done", writer); + + /* main recording loop */ + while (1) + { + write_job_t *tmp_job = NULL; + write_job_t write_job; + + trace_write(trace_ctx, " --> WRITER#%d: waiting for message", writer); + + /* receive write job from dispatcher */ + if(msg_queue_receive(queue, (struct event **)&tmp_job, 500)) + { + static uint32_t timeouts = 0; + trace_write(trace_ctx, " --> WRITER#%d: message timed out %d times now", writer, ++timeouts); + continue; + } + + /* just to make sure */ + if(!tmp_job) + { + trace_write(trace_ctx, " --> WRITER#%d: message is NULL", writer); + continue; + } + + /* keep this structure local to make sure there is no dereferencing at all */ + write_job = *tmp_job; + + /* this is an "abort" job */ + if(write_job.block_len == 0) + { + free(tmp_job); + trace_write(trace_ctx, " --> WRITER#%d: expected to terminate", writer); + break; + } + + trace_write(trace_ctx, " --> WRITER#%d: write %d slots from %d (%dKiB, addr 0x%08X, size 0x%08X)", writer, write_job.block_len, write_job.block_start, write_job.block_size/1024, write_job.block_ptr, write_job.block_size); + + /* ToDo: ask an optional external routine if this buffer should get saved now. if none registered, it will return 1 */ + int32_t ext_gating = 1; + if (ext_gating) + { + write_job.last_time_after = last_time_after; + write_job.time_before = get_us_clock_value(); + + if(0xFFFFFFFF - written_chunk < write_job.block_size) + { + trace_write(trace_ctx, " --> WRITER#%d: reached 4GiB", writer); + + /* rewrite header */ + file_header.videoFrameCount = frames_written; + + FIO_SeekFile(f, 0, SEEK_SET); + mlv_write_hdr(f, (mlv_hdr_t *)&file_header); + FIO_CloseFile(f); + f = INVALID_PTR; + + /* in test mode remove all files after closing */ + if(test_mode) + { + FIO_RemoveFile(chunk_filename[writer]); + } + + /* try to create a new chunk */ + file_header.fileNum = raw_get_next_filenum(); + + get_next_chunk_file_name(movie_filename, chunk_filename[writer], file_header.fileNum); + + /* patch drive letter */ + if(writer == 1) + { + chunk_filename[writer][0] = 'A'; + } + trace_write(trace_ctx, " --> WRITER#%d: new file: '%s'", writer, chunk_filename[writer]); + + f = FIO_CreateFileEx(chunk_filename[writer]); + if (f == INVALID_PTR) + { + goto abort; + } + + /* write next header */ + frames_written = 0; + file_header.videoFrameCount = 0; + file_header.audioFrameCount = 0; + + raw_prepare_chunk(f, &file_header); + written_chunk = FIO_SeekFile(f, 0, SEEK_CUR); + } + + int32_t r = FIO_WriteFile(f, write_job.block_ptr, write_job.block_size); + write_job.time_after = get_us_clock_value(); + + last_time_after = write_job.time_after; + + /* handle disk full cases */ + if (r != (int32_t)write_job.block_size) /* 4GB limit or card full? */ + { + trace_write(trace_ctx, " --> WRITER#%d: write error: %d", writer, r); + + /* it failed right away? card must be full */ + if (written[writer] == 0) + { + trace_write(trace_ctx, " --> WRITER#%d: write error: could not write anything, exiting", writer); + goto abort; + } + + if (r == -1) + { + trace_write(trace_ctx, " --> WRITER#%d: write error: write failed", writer); + goto abort; + } + + trace_write(trace_ctx, " --> WRITER#%d: write error: write failed, wrote only partially (%d/%d bytes)", writer, r, write_job.block_size); + goto abort; + } + else + { + /* all fine */ + written_chunk += write_job.block_size; + } + + frames_written += write_job.block_len; + } + + /* send job back and wake up manager */ + write_job.writer = writer; + *tmp_job = write_job; + msg_queue_post(mlv_mgr_queue, tmp_job); + trace_write(trace_ctx, " --> WRITER#%d: returned job 0x%08X", writer, tmp_job); + + + /* error handling */ + if (0) + { +abort: + bmp_printf( FONT_MED, 30, 90, + "Movie recording stopped automagically " + ); + /* this is error beep, not audio sync beep */ + beep_times(2); + break; + } + } + + if(f != INVALID_PTR) + { + file_header.videoFrameCount = frames_written; + + FIO_SeekFile(f, 0, SEEK_SET); + mlv_write_hdr(f, (mlv_hdr_t *)&file_header); + FIO_CloseFile(f); + } + + if(test_mode) + { + FIO_RemoveFile(chunk_filename[writer]); + } +} + +static void enqueue_buffer(uint32_t writer, write_job_t *write_job) +{ + /* if we are about to overflow, save a smaller number of frames, so they can be freed quicker */ + if (measured_write_speed) + { + int32_t fps = fps_get_current_x1000(); + /* measured_write_speed unit: 0.01 MB/s */ + /* FPS unit: 0.001 Hz */ + /* overflow time unit: 0.1 seconds */ + int32_t free_slots = get_free_slots(); + int32_t overflow_time = free_slots * 1000 * 10 / fps; + /* better underestimate write speed a little */ + int32_t frame_limit = overflow_time * 1024 / 10 * (measured_write_speed * 9 / 100) * 1024 / (write_job->block_size / write_job->block_len) / 10; + + /* do not decrease write size if skipping is allowed */ + if (!allow_frame_skip && frame_limit >= 0 && frame_limit < (int32_t)write_job->block_len) + { + trace_write(trace_ctx, "<-- careful, will overflow in %d.%d seconds, better write only %d frames", overflow_time/10, overflow_time%10, frame_limit); + write_job->block_len = MAX(1, frame_limit - 2); + write_job->block_size = 0; + + /* now fix the buffer size to write */ + for(uint32_t slot = write_job->block_start; slot < write_job->block_start + write_job->block_len; slot++) + { + write_job->block_size += slots[slot].size; + } + } + } + +#if 0 + while(write_job->block_size > 16*1024*1024 - 2048) + { + write_job->block_len--; + write_job->block_size = 0; + + /* now fix the buffer size to write */ + for(int32_t slot = write_job->block_start; slot < write_job->block_start + write_job->block_len; slot++) + { + write_job->block_size += slots[slot].size; + } + } +#endif + +#if 0 + //while(write_job->block_size > 16*1024*1024 - 2048) + { + write_job->block_len = 3; + write_job->block_size = 0; + + /* now fix the buffer size to write */ + for(int32_t slot = write_job->block_start; slot < write_job->block_start + write_job->block_len; slot++) + { + write_job->block_size += slots[slot].size; + } + } +#endif + + /* mark slots to be written */ + for(uint32_t slot = write_job->block_start; slot < (write_job->block_start + write_job->block_len); slot++) + { + slots[slot].status = SLOT_WRITING; + slots[slot].writer = writer; + } + + /* enqueue the next largest block */ + write_job->block_ptr = slots[write_job->block_start].ptr; + + write_job_t *queue_job = malloc(sizeof(write_job_t)); + *queue_job = *write_job; + + msg_queue_post(mlv_writer_queues[writer], queue_job); + trace_write(trace_ctx, "<-- POST: group with %d entries at %d (%dKiB) for slow card", write_job->block_len, write_job->block_start, write_job->block_size/1024); +} + +static void raw_video_rec_task() +{ + int test_loop = 0; + int test_case_loop = 0; + + /* init stuff */ + raw_recording_state = RAW_PREPARING; + + /* wait for two frames to be sure everything is refreshed */ + frame_countdown = 2; + for (int32_t i = 0; i < 200; i++) + { + msleep(20); + if (frame_countdown == 0) break; + } + + /* detect raw parameters (geometry, black level etc) */ + raw_set_dirty(); + if (!raw_update_params()) + { + bmp_printf( FONT_MED, 30, 50, "Raw detect error"); + goto cleanup; + } + + update_resolution_params(); + + trace_write(trace_ctx, "Resolution: %dx%d @ %d.%03d FPS", res_x, res_y, fps_get_current_x1000()/1000, fps_get_current_x1000()%1000); + + /* signal that we are starting, call this before any memory allocation to give CBR the chance to allocate memory */ + raw_rec_cbr_starting(); + + /* allocate memory */ + if (!setup_buffers()) + { + bmp_printf( FONT_MED, 30, 50, "Memory error"); + goto cleanup; + } + + /* + if (sound_rec == 1) + { + char* wavfile = get_wav_file_name(movie_filename); + bmp_printf( FONT_MED, 30, 90, "Sound: %s%s", wavfile + 17, wavfile[0] == 'B' && movie_filename[0] == 'A' ? " on SD card" : ""); + bmp_printf( FONT_MED, 30, 90, "%s", wavfile); + WAV_StartRecord(wavfile); + } + */ + msleep(start_delay * 1000); + + hack_liveview(0); + + if(test_mode) + { + buffer_fill_method = 0; + fast_card_buffers = 0; + abort_test = 0; + } + clrscr(); + + do + { + /* get exclusive access to our edmac channels */ + edmac_memcpy_res_lock(); + + write_job_t *write_job = NULL; + + frame_count = 0; + frame_skips = 0; + mlv_file_count = 0; + capture_slot = -1; + fullsize_buffer_pos = 0; + + /* setup MLV stuff */ + mlv_init_header(); + + /* this will enable the vsync CBR and the other task(s) */ + raw_recording_state = RAW_RECORDING; + + /* try a sync beep (not very precise, but better than nothing) */ + if (sound_rec == 1) + { + beep(); + } + + + /* fake recording status, to integrate with other ml stuff (e.g. hdr video */ + recording = -1; + + /* create output file name */ + movie_filename = get_next_raw_movie_file_name(); + + /* fill in file names for threads */ + get_next_chunk_file_name(movie_filename, chunk_filename[0], 0); + + if(card_spanning && cam_5d3) + { + mlv_writer_threads = 2; + get_next_chunk_file_name(movie_filename, chunk_filename[1], 1); + chunk_filename[1][0] = 'B'; + } + else + { + mlv_writer_threads = 1; + } + + if(test_mode) + { + int ypos = 210 + ((test_loop % 13) * font_med.height); + + bmp_printf(FONT(FONT_MED, COLOR_YELLOW, COLOR_BLACK), 30, ypos, "[Test #%03d] M: %d B: %d ", test_loop + 1, buffer_fill_method, fast_card_buffers); + } + + /* create files for writers */ + for(uint32_t writer = 0; writer < mlv_writer_threads; writer++) + { + trace_write(trace_ctx, "Filename(%d): '%s'", writer, chunk_filename[writer]); + + written[writer] = 0; + frames_written[writer] = 0; + writing_time[writer] = 0; + idle_time[writer] = 0; + mlv_handles[writer] = FIO_CreateFileEx(chunk_filename[writer]); + + if (mlv_handles[writer] == INVALID_PTR) + { + trace_write(trace_ctx, "FIO_CreateFileEx(#%d): FAILED", writer); + bmp_printf(FONT_MED, 30, 50, "File create error"); + return; + } + } + + /* create writer threads with decreasing priority */ + for(uint32_t writer = 0; writer < mlv_writer_threads; writer++) + { + task_create("writer_thread", 0x10 + writer, 0x1000, raw_writer_task, (void*)writer); + } + + uint32_t used_slots = 0; + uint32_t writing_slots = 0; + uint32_t queued_writes = 0; + + while((raw_recording_state == RAW_RECORDING) || (used_slots > 0)) + { + /* here we receive a previously sent job back. process it after refilling the queue */ + write_job_t *returned_job = NULL; + int timeout = 500; + + /* send dummy command to ensure manager generates writer jobs after entering loop and on empty queues */ + if(used_slots == 0 || queued_writes == 0) + { + msg_queue_post(mlv_mgr_queue, NULL); + } + + if(msg_queue_receive(mlv_mgr_queue, (struct event **)&returned_job, timeout)) + { + returned_job = NULL; + } + + /* when capture task had to skip a frame, stop recording */ + if (!allow_frame_skip && frame_skips) + { + raw_recording_state = RAW_FINISHING; + } + + if(test_mode && (frames_written[0] + frames_written[1] > 4000)) + { + raw_recording_state = RAW_FINISHING; + } + + /* how fast are we writing? does this speed match our benchmarks? */ + int32_t temp_speed = 0; + for(uint32_t writer = 0; writer < mlv_writer_threads; writer++) + { + if (writing_time[writer] || idle_time[writer]) + { + int32_t speed = written[writer] * 100 / writing_time[writer] * 1000 / 1024; // MB/s x100 + temp_speed += speed; + } + } + measured_write_speed = temp_speed; + + /* check if there is a writer without jobs */ + uint32_t msg_count[2]; + + /* check CF queue */ + msg_queue_count(mlv_writer_queues[0], &msg_count[0]); + if(msg_count[0] < 1) + { + write_job_t write_job; + trace_write(trace_ctx, "<-- No jobs in fast-card queue"); + + /* in case there is something to write... */ + if(find_largest_buffer(0, &write_job)) + { + enqueue_buffer(0, &write_job); + msg_count[0]++; + } + else + { + trace_write(trace_ctx, "<-- (nothing found to enqueue)"); + } + } + + /* check SD queue */ + msg_queue_count(mlv_writer_queues[1], &msg_count[1]); + if((mlv_writer_threads > 1) && (msg_count[1] < 1)) + { + write_job_t write_job; + trace_write(trace_ctx, "<-- No jobs in slow-card queue"); + + /* in case there is something to write... SD must not use the two largest buffers */ + if(find_largest_buffer(fast_card_buffers, &write_job)) + { + enqueue_buffer(1, &write_job); + msg_count[1]++; + } + else + { + trace_write(trace_ctx, "<-- (nothing found to enqueue)"); + } + } + + /* a writer finished and we have to update statistics etc */ + if(returned_job) + { + trace_write(trace_ctx, "<-- processing returned_job 0x%08X from %d", returned_job, returned_job->writer); + /* set all slots as free again */ + for(uint32_t slot = returned_job->block_start; slot < (returned_job->block_start + returned_job->block_len); slot++) + { + slots[slot].status = SLOT_FREE; + trace_write(trace_ctx, " --> WRITER#%d: free slot %d", returned_job->writer, slot); + } + + /* calc writing and idle time */ + int32_t write_time = (uint32_t)(returned_job->time_after - returned_job->time_before); + int32_t mgmt_time = 0; + + /* wait until first block is written before counting */ + if(returned_job->last_time_after) + { + mgmt_time = (uint32_t)(returned_job->time_before - returned_job->last_time_after); + } + + trace_write(trace_ctx, " --> WRITER#%d: write took: %d µs (%dKiB/s)", returned_job->writer, write_time, (returned_job->block_size/1024 * 1000) / (write_time / 1000)); + trace_write(trace_ctx, " --> WRITER#%d: mgmt took: %d µs", returned_job->writer, mgmt_time); + + /* update statistics */ + writing_time[returned_job->writer] += write_time / 1000; + idle_time[returned_job->writer] += mgmt_time / 1000; + written[returned_job->writer] += returned_job->block_size / 1024; + frames_written[returned_job->writer] += returned_job->block_len; + + free(returned_job); + returned_job = NULL; + } + + /* update some statistics. do this last, to make sure the writers have enough jobs */ + queued_writes = msg_count[0] + msg_count[1]; + + used_slots = 0; + writing_slots = 0; + for(int32_t slot = 0; slot < slot_count; slot++) + { + if(slots[slot].status != SLOT_FREE) + { + used_slots++; + } + if(slots[slot].status == SLOT_WRITING) + { + writing_slots++; + } + } + trace_write(trace_ctx, "Slots used: %d, writing: %d", used_slots, writing_slots); + + if(raw_recording_state != RAW_RECORDING) + { + show_buffer_status(); + } + } + + /* wait until all jobs done */ + int32_t has_data = 0; + do + { + show_buffer_status(); + has_data = 0; + + for(int32_t slot = 0; slot < slot_count; slot++) + { + if(slots[slot].status == SLOT_WRITING) + { + has_data = 1; + } + } + + if(has_data) + { + trace_write(trace_ctx, "<-- still have data to write..."); + } + msleep(200); + } while(has_data); + + /* done, this will stop the vsync CBR and the copying task */ + raw_recording_state = RAW_FINISHING; + + /* queue two aborts to cancel tasks */ + write_job = malloc(sizeof(write_job_t)); + write_job->block_len = 0; + msg_queue_post(mlv_writer_queues[0], write_job); + + write_job = malloc(sizeof(write_job_t)); + write_job->block_len = 0; + msg_queue_post(mlv_writer_queues[1], write_job); + + /* flush queues */ + msleep(250); + + /* exclusive edmac access no longer needed */ + edmac_memcpy_res_unlock(); + + /* make sure all queues are empty */ + flush_queue(mlv_writer_queues[0]); + flush_queue(mlv_writer_queues[1]); + flush_queue(mlv_block_queue); + flush_queue(mlv_mgr_queue); + + /* wait until the other tasks calm down */ + msleep(500); + + recording = 0; + + if(test_mode) + { + int written_kbytes = written[0] + written[1]; + int written_frames = frames_written[0] + frames_written[1]; + char msg[100]; + snprintf(msg, sizeof(msg), "%d.%d MB/s", measured_write_speed/100, (measured_write_speed/10)%10); + + trace_write(trace_ctx, "[Test #%03d] M: %d, B: %d, W: %d KiB, F: %d, Rate: %s", test_loop + 1, buffer_fill_method, fast_card_buffers, written_kbytes, written_frames, msg); + + + int ypos = 210 + ((test_loop % 13) * font_med.height); + bmp_printf(FONT(FONT_MED, COLOR_GREEN1, COLOR_BLACK), 30, ypos, "[Test #%03d] M: %d B: %d W: %5d MiB F: %4d (%s) ", test_loop + 1, buffer_fill_method, fast_card_buffers, written_kbytes / 1024, written_frames, msg); + + test_loop++; + } + + test_case_loop++; + test_case_loop %= 4; + + if(test_case_loop == 0) + { + buffer_fill_method++; + buffer_fill_method %= 5; + + if(!buffer_fill_method) + { + fast_card_buffers++; + fast_card_buffers %= MIN((slot_count - 1), 5); + } + } + } while(test_mode && !abort_test); + + /* signal that we are stopping */ + raw_rec_cbr_stopping(); + +/* if (sound_rec == 1) + { + WAV_StopRecord(); + } +*/ + bmp_printf( FONT_MED, 30, 70, + "Frames captured: %d ", + frame_count - 1 + ); + + +cleanup: + free_buffers(); + + /* count up take number */ + if(raw_tag_take) + { + raw_tag_take++; + } + + if(show_graph) + { + take_screenshot(0); + } + hack_liveview(1); + redraw(); + raw_recording_state = RAW_IDLE; +} + +static MENU_SELECT_FUNC(raw_start_stop) +{ + if (!RAW_IS_IDLE) + { + abort_test = 1; + raw_recording_state = RAW_FINISHING; + //if (sound_rec == 2) beep(); + } + else + { + raw_recording_state = RAW_PREPARING; + gui_stop_menu(); + task_create("raw_rec_task", 0x15, 0x1000, raw_video_rec_task, (void*)0); + } +} + + +IME_DONE_FUNC(raw_tag_str_done) +{ + if(status == IME_OK) + { + strcpy(raw_tag_str, raw_tag_str_tmp); + } + return IME_OK; +} + +struct rolling_pitching +{ + uint8_t status; + uint8_t cameraposture; + uint8_t roll_hi; + uint8_t roll_lo; + uint8_t pitch_hi; + uint8_t pitch_lo; +}; + +/* LENS changes */ +PROP_HANDLER( PROP_LV_LENS_STABILIZE ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_STROBO_AECOMP ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_ISO_AUTO ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_ISO ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_LV_LENS ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_APERTURE ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_APERTURE2 ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_SHUTTER ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_SHUTTER_ALSO ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_BV ) +{ + mlv_update_lens = 1; +} + +PROP_HANDLER( PROP_AE ) +{ + mlv_update_lens = 1; +} + +/* STYL changes */ +PROP_HANDLER( PROP_PICTURE_STYLE ) +{ + mlv_update_styl = 1; +} + +/* any WBAL change */ +PROP_HANDLER( PROP_WB_MODE_LV ) +{ + mlv_update_wbal = 1; +} + +PROP_HANDLER( PROP_WBS_GM ) +{ + mlv_update_wbal = 1; +} + +PROP_HANDLER( PROP_WBS_BA ) +{ + mlv_update_wbal = 1; +} + +PROP_HANDLER( PROP_WB_KELVIN_LV ) +{ + mlv_update_wbal = 1; +} + +PROP_HANDLER( PROP_CUSTOM_WB ) +{ + mlv_update_wbal = 1; +} + +PROP_HANDLER(PROP_ROLLING_PITCHING_LEVEL) +{ + struct rolling_pitching * orientation = (struct rolling_pitching *) buf; + + if (RAW_IS_RECORDING && orientation->status == 2) + { + mlv_elvl_hdr_t *hdr = malloc(sizeof(mlv_elvl_hdr_t)); + + /* prepare header */ + mlv_set_type((mlv_hdr_t *)hdr, "ELVL"); + mlv_set_timestamp((mlv_hdr_t *)hdr, mlv_start_timestamp); + hdr->blockSize = sizeof(mlv_elvl_hdr_t); + + /* fill in data */ + hdr->roll = orientation->roll_hi * 256 + orientation->roll_lo; + hdr->pitch = orientation->pitch_hi * 256 + orientation->pitch_lo; + + /* put into block queue */ + msg_queue_post(mlv_block_queue, hdr); + } +} + +static MENU_SELECT_FUNC(raw_tag_str_start) +{ + strcpy(raw_tag_str_tmp, raw_tag_str); + ime_base_start((unsigned char *)"Enter text", (unsigned char *)raw_tag_str_tmp, sizeof(raw_tag_str_tmp)-1, IME_UTF8, IME_CHARSET_ANY, NULL, raw_tag_str_done, 0, 0, 0, 0); +} + +static MENU_UPDATE_FUNC(raw_tag_str_update) +{ + if(strlen(raw_tag_str)) + { + MENU_SET_VALUE(raw_tag_str); + } + else + { + MENU_SET_VALUE("none"); + } +} + +static MENU_UPDATE_FUNC(raw_tag_take_update) +{ + if(raw_tag_take) + { + MENU_SET_VALUE("#%d", raw_tag_take); + } + else + { + MENU_SET_VALUE("OFF"); + } +} + +static MENU_UPDATE_FUNC(start_delay_update) +{ + switch (start_delay_idx) { + case 0: + start_delay = 0; break; + case 1: + start_delay = 2; break; + case 2: + start_delay = 4; break; + case 3: + start_delay = 10; break; + default: + start_delay= 0; break; + } +} + + +static struct menu_entry raw_video_menu[] = +{ + { + .name = "RAW video", + .priv = &raw_video_enabled, + .max = 1, + .update = raw_main_update, + .submenu_width = 710, + .depends_on = DEP_LIVEVIEW | DEP_MOVIE_MODE, + .help = "Record 14-bit RAW video. Press LiveView to start.", + .children = (struct menu_entry[]) { + { + .name = "Resolution", + .priv = &resolution_index_x, + .max = COUNT(resolution_presets_x) - 1, + .update = resolution_update, + .choices = RESOLUTION_CHOICES_X, + }, + { + .name = "Aspect ratio", + .priv = &aspect_ratio_index, + .max = COUNT(aspect_ratio_presets_num) - 1, + .update = aspect_ratio_update, + .choices = aspect_ratio_choices, + }, + /* + { + .name = "Source ratio", + .priv = &source_ratio, + .max = 2, + .choices = CHOICES("Square pixels", "16:9", "3:2"), + .help = "Choose aspect ratio of the source image (LiveView buffer).", + .help2 = "Useful for video modes with squeezed image (e.g. 720p).", + }, + */ + { + .name = "Sound", + .priv = &sound_rec, + .max = 1, + .choices = CHOICES("OFF", "Sync beep"), + .help = "Sound recording options.", + }, + { + .name = "Global Draw", + .priv = &kill_gd, + .max = 1, + .choices = CHOICES("ON", "OFF"), + .help = "Disable global draw while recording.\n Some previews depend on GD", + }, + { + .name = "Rec Key", + .priv = &rec_key, + .max = 1, + .choices = CHOICES("LV/REC", "MENU"), + .help = "Start recording with either LV or Menu button. Required for EOSM", + }, + + { + .name = "Preview", + .priv = &preview_mode, + .max = 4, + .choices = CHOICES("Auto", "Canon", "ML Grayscale", "HaCKeD", "Hacked No Prev"), + .help2 = "Auto: ML chooses what's best for each video mode\n" + "Canon: plain old LiveView. Framing is not always correct.\n" + "ML Grayscale: looks ugly, but at least framing is correct.\n" + "HaCKeD: try to squeeze a little speed by killing LiveView.\n" + "HaCKeD2: No preview. Disables Global draw while recording.\n" + }, + { + .name = "Start delay", + .priv = &start_delay_idx, + .max = 3, + .choices = CHOICES("OFF", "2 sec.", "4 sec.", "10 sec."), + .update = start_delay_update, + .help = "Start delay. Useful to stabilize in photo mode.", + .help2 = "Pressing shutter button.", + }, + + { + .name = "Digital dolly", + .priv = &dolly_mode, + .max = 1, + .help = "Smooth panning of the recording window (software dolly).", + .help2 = "Use arrow keys (joystick) to move the window." + }, + { + .name = "Frame skipping", + .priv = &allow_frame_skip, + .max = 1, + .choices = CHOICES("OFF", "Allow"), + .help = "Enable if you don't mind skipping frames (for slow cards).", + }, + { + .name = "Debug trace", + .priv = &enable_tracing, + .max = 1, + .help = "Write an execution trace to memory card. Causes perfomance drop.", + .help2 = "You have to restart camera before setting takes effect.", + }, + { + .name = "Show buffer graph", + .priv = &show_graph, + .max = 1, + .help = "Displays a graph of the current buffer usage and expected frames", + }, + { + .name = "Test mode", + .priv = &test_mode, + .max = 1, + .help = "Record repeatedly, changing buffering methods etc", + }, + { + .name = "Card warm-up", + .priv = &warm_up, + .max = 7, + .choices = CHOICES("OFF", "16 MB", "32 MB", "64 MB", "128 MB", "256 MB", "512 MB", "1 GB"), + .help = "Write a large file on the card at camera startup.", + .help2 = "Some cards seem to get a bit faster after this.", + }, + { + .name = "Buffer fill method", + .priv = &buffer_fill_method, + .max = 4, + .help = "Method for filling buffers. Will affect write speed.", + }, + { + .name = "CF-only buffers", + .priv = &fast_card_buffers, + .max = 9, + .help = "How many of the largest buffers are for CF writing.", + }, + { + .name = "Memory hack", + .priv = &memory_hack, + .max = 1, + .help = "Allocate memory with LiveView off. On 5D3 => 2x32M extra.", + }, + { + .name = "Extra hacks", + .priv = &small_hacks, + .max = 1, + .help = "Slow down Canon GUI, disable auto exposure, white balance...", + }, + { + .name = "Card spanning", + .priv = &card_spanning, + .max = 1, + .help = "Span video file over cards to use SD+CF write speed", + }, + { + .name = "Tag: Text", + .priv = raw_tag_str, + .select = raw_tag_str_start, + .update = raw_tag_str_update, + .help = "Free text field", + }, + { + .name = "Tag: Take", + .priv = &raw_tag_take, + .min = 0, + .max = 99, + .update = raw_tag_take_update, + .help = "Auto-Counting take number", + }, + MENU_EOL, + }, + } +}; + + +static unsigned int raw_rec_keypress_cbr(unsigned int key) +{ + if (!raw_video_enabled) + return 1; + + if (!is_movie_mode()) + return 1; + + /* keys are only hooked in LiveView */ + if (!liveview_display_idle()) + return 1; + + /* start/stop recording with the LiveView key */ + int32_t rec_key_pressed = (key == MODULE_KEY_LV || key == MODULE_KEY_REC); + + /* MENU ON EOSM Photo Mode */ + if (cam_eos_m) + rec_key_pressed = ( rec_key ? key== MODULE_KEY_MENU : (key == MODULE_KEY_LV || key == MODULE_KEY_REC) ); + + /* ... or SET on 5D2/50D */ + if (cam_50d || cam_5d2) rec_key_pressed = (key == MODULE_KEY_PRESS_SET); + + if (rec_key_pressed) + { + switch(raw_recording_state) + { + case RAW_IDLE: + case RAW_RECORDING: + raw_start_stop(0,0); + break; + } + return 0; + } + + /* panning (with arrow keys) */ + if (FRAMING_PANNING) + { + switch (key) + { + case MODULE_KEY_PRESS_LEFT: + frame_offset_delta_x -= 8; + return 0; + case MODULE_KEY_PRESS_RIGHT: + frame_offset_delta_x += 8; + return 0; + case MODULE_KEY_PRESS_UP: + frame_offset_delta_y -= 2; + return 0; + case MODULE_KEY_PRESS_DOWN: + frame_offset_delta_y += 2; + return 0; + case MODULE_KEY_PRESS_DOWN_LEFT: + frame_offset_delta_y += 2; + frame_offset_delta_x -= 8; + return 0; + case MODULE_KEY_PRESS_DOWN_RIGHT: + frame_offset_delta_y += 2; + frame_offset_delta_x += 8; + return 0; + case MODULE_KEY_PRESS_UP_LEFT: + frame_offset_delta_y -= 2; + frame_offset_delta_x -= 8; + return 0; + case MODULE_KEY_PRESS_UP_RIGHT: + frame_offset_delta_y -= 2; + frame_offset_delta_x += 8; + return 0; + case MODULE_KEY_JOY_CENTER: + /* first click stop the motion, second click center the window */ + if (frame_offset_delta_x || frame_offset_delta_y) + { + frame_offset_delta_y = 0; + frame_offset_delta_x = 0; + } + else + { + frame_offset_y = 0; + frame_offset_x = 0; + } + } + } + + return 1; +} + +static int32_t preview_dirty = 0; + +static uint32_t raw_rec_should_preview(uint32_t ctx) +{ + if (!raw_video_enabled) return 0; + if (!is_movie_mode()) return 0; + if (kill_gd && (RAW_IS_PREPARING || RAW_IS_RECORDING)) + return 0; + + /* keep x10 mode unaltered, for focusing */ + if (lv_dispsize == 10 && !cam_7d) return 0; + + if (PREVIEW_AUTO) + /* enable preview in x5 mode, since framing doesn't match */ + return lv_dispsize == 5; + + else if (PREVIEW_CANON) + return 0; + + else if (PREVIEW_ML) + return 1; + + else if (PREVIEW_HACKED) + return RAW_IS_RECORDING || get_halfshutter_pressed() || lv_dispsize == 5; + + return 0; +} + +static unsigned int raw_rec_update_preview(unsigned int ctx) +{ + /* just say whether we can preview or not */ + if (ctx == 0) + { + int32_t enabled = raw_rec_should_preview(ctx); + if (!enabled && preview_dirty) + { + /* cleanup the mess, if any */ + raw_set_dirty(); + preview_dirty = 0; + } + return enabled; + } + + struct display_filter_buffers * buffers = (struct display_filter_buffers *) ctx; + + raw_previewing = 1; + raw_set_preview_rect(skip_x, skip_y, res_x, res_y); + raw_force_aspect_ratio_1to1(); + raw_preview_fast_ex((void*)-1, PREVIEW_HACKED && RAW_RECORDING ? (void*)-1 : buffers->dst_buf, -1, -1, !get_halfshutter_pressed()); + raw_previewing = 0; + + if (!RAW_IS_IDLE) + { + /* be gentle with the CPU, save it for recording (especially if the buffer is almost full) */ + //~ msleep(free_buffers <= 2 ? 2000 : used_buffers > 1 ? 1000 : 100); + msleep(1000); + } + + preview_dirty = 1; + return 1; +} + +static unsigned int raw_rec_init() +{ + /* enable tracing */ + if(enable_tracing) + { + char filename[100]; + snprintf(filename, sizeof(filename), "%sraw_rec.txt", MODULE_CARD_DRIVE); + trace_ctx = trace_start("raw_rec", filename); + trace_format(trace_ctx, TRACE_FMT_TIME_REL | TRACE_FMT_COMMENT, ' '); + } + + /* create message queues */ + mlv_block_queue = (struct msg_queue *) msg_queue_create("mlv_block_queue", 100); + mlv_writer_queues[0] = (struct msg_queue *) msg_queue_create("mlv_writer_queue", 10); + mlv_writer_queues[1] = (struct msg_queue *) msg_queue_create("mlv_writer_queue", 10); + mlv_mgr_queue = (struct msg_queue *) msg_queue_create("mlv_mgr_queue", 10); + + /* default free text string is empty */ + strcpy(raw_tag_str, ""); + + cam_eos_m = streq(camera_model_short, "EOSM"); + cam_5d2 = streq(camera_model_short, "5D2"); + cam_50d = streq(camera_model_short, "50D"); + cam_5d3 = streq(camera_model_short, "5D3"); + cam_6d = streq(camera_model_short, "6D"); + cam_700d = streq(camera_model_short, "700D"); + cam_7d = streq(camera_model_short, "7D"); + cam_600d = streq(camera_model_short, "600D"); + + + for (struct menu_entry * e = raw_video_menu[0].children; !MENU_IS_EOL(e); e++) + { + /* customize menus for each camera here (e.g. hide what doesn't work) */ + + /* 50D doesn't have sound and can't even beep */ + if ( (cam_50d || cam_eos_m) && streq(e->name, "Sound")) + { + e->shidden = 1; + //sound_rec = 0; + } + if (!cam_eos_m && streq(e->name, "Rec Key") ) + e->shidden = 1; + if (cam_eos_m && streq(e->name, "Digital dolly") ) + e->shidden = 1; + + if (!cam_5d3 && streq(e->name, "CF-only buffers") ) + e->shidden = 1; + if (!cam_5d3 && streq(e->name, "Card spanning") ) + e->shidden = 1; + if (streq(e->name, "Debug trace") ) + e->shidden = 1; + + /* Memory hack confirmed to work only on 5D3 and 6D */ + if (streq(e->name, "Memory hack") && !(cam_5d3 || cam_6d)) + { + e->shidden = 1; + memory_hack = 0; + } + } + + if (cam_5d2 || cam_50d) + { + raw_video_menu[0].help = "Record 14-bit RAW video. Press SET to start."; + } + + menu_add("Movie", raw_video_menu, COUNT(raw_video_menu)); + + /* some cards may like this */ + if (warm_up) + { + NotifyBox(100000, "Card warming up..."); + char warmup_filename[100]; + snprintf(warmup_filename, sizeof(warmup_filename), "%s/warmup.raw", get_dcim_dir()); + FILE* f = FIO_CreateFileEx(warmup_filename); + FIO_WriteFile(f, (void*)0x40000000, 8*1024*1024 * (1 << warm_up)); + FIO_CloseFile(f); + FIO_RemoveFile(warmup_filename); + NotifyBoxHide(); + } + + return 0; +} + +static unsigned int raw_rec_deinit() +{ + if(trace_ctx != TRACE_ERROR) + { + trace_stop(trace_ctx, 0); + trace_ctx = TRACE_ERROR; + } + return 0; +} + +MODULE_INFO_START() + MODULE_INIT(raw_rec_init) + MODULE_DEINIT(raw_rec_deinit) +MODULE_INFO_END() + +/* +MODULE_STRINGS_START() + MODULE_STRING("Description", "14-bit RAW video") + MODULE_STRING("License", "GPL") + MODULE_STRING("Author", "a1ex") + MODULE_STRING("Credits", "g3gg0 (lv_rec)") +MODULE_STRINGS_END() +*/ +MODULE_CBRS_START() + MODULE_CBR(CBR_VSYNC, raw_rec_vsync_cbr, 0) + MODULE_CBR(CBR_KEYPRESS, raw_rec_keypress_cbr, 0) + MODULE_CBR(CBR_SHOOT_TASK, raw_rec_polling_cbr, 0) + MODULE_CBR(CBR_DISPLAY_FILTER, raw_rec_update_preview, 0) +MODULE_CBRS_END() + +MODULE_PROPHANDLERS_START() + MODULE_PROPHANDLER(PROP_ROLLING_PITCHING_LEVEL) + MODULE_PROPHANDLER(PROP_LV_LENS_STABILIZE) + MODULE_PROPHANDLER(PROP_STROBO_AECOMP) + MODULE_PROPHANDLER(PROP_ISO_AUTO) + MODULE_PROPHANDLER(PROP_ISO) + MODULE_PROPHANDLER(PROP_LV_LENS) + MODULE_PROPHANDLER(PROP_APERTURE) + MODULE_PROPHANDLER(PROP_APERTURE2) + MODULE_PROPHANDLER(PROP_SHUTTER) + MODULE_PROPHANDLER(PROP_SHUTTER_ALSO) + MODULE_PROPHANDLER(PROP_BV) + MODULE_PROPHANDLER(PROP_AE) + MODULE_PROPHANDLER(PROP_PICTURE_STYLE) + MODULE_PROPHANDLER(PROP_WB_MODE_LV) + MODULE_PROPHANDLER(PROP_WBS_GM) + MODULE_PROPHANDLER(PROP_WBS_BA) + MODULE_PROPHANDLER(PROP_WB_KELVIN_LV) + MODULE_PROPHANDLER(PROP_CUSTOM_WB) +MODULE_PROPHANDLERS_END() + +MODULE_CONFIGS_START() + MODULE_CONFIG(raw_video_enabled) + MODULE_CONFIG(resolution_index_x) + MODULE_CONFIG(aspect_ratio_index) + MODULE_CONFIG(measured_write_speed) + MODULE_CONFIG(allow_frame_skip) + MODULE_CONFIG(sound_rec) + MODULE_CONFIG(dolly_mode) + MODULE_CONFIG(preview_mode) + MODULE_CONFIG(memory_hack) + MODULE_CONFIG(small_hacks) + MODULE_CONFIG(warm_up) + MODULE_CONFIG(card_spanning) + MODULE_CONFIG(buffer_fill_method) + MODULE_CONFIG(fast_card_buffers) + MODULE_CONFIG(enable_tracing) + MODULE_CONFIG(test_mode) + MODULE_CONFIG(show_graph) + + MODULE_CONFIG(start_delay_idx) + MODULE_CONFIG(kill_gd) + MODULE_CONFIG(rec_key) + +MODULE_CONFIGS_END() + diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/mlv_rec/raw2dng Binary file modules/mlv_rec/raw2dng has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/raw_rec/600D.png Binary file modules/raw_rec/600D.png has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/raw_rec/Test1.png Binary file modules/raw_rec/Test1.png has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/raw_rec/raw_rec.c --- a/modules/raw_rec/raw_rec.c Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/raw_rec/raw_rec.c Sun Sep 22 11:41:50 2013 -0500 @@ -67,6 +67,21 @@ #include "../file_man/file_man.h" #include "cache_hacks.h" +/** + * resolution should be multiple of 64x32 or 128x16 + * this way, we get frame size multiple of 512, so there's no write speed penalty + * (see http://chdk.setepontos.com/index.php?topic=9970 ; confirmed by benchmarks) + * mod16 request: http://www.magiclantern.fm/forum/index.php?topic=5839.0 + **/ + +static int resolution_presets_x[] = { 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408 ,1472, 1536, 1600, 1664, 1728, 1792, 1856, 1920, 1984, 2048, 2560, 2880, 3456, 3520 }; +#define RESOLUTION_CHOICES_X CHOICES( "640","704","768","832","896","960","1024","1088","1152","1216","1280","1344","1408","1472","1536","1600","1664","1728","1792","1856","1920","1984","2048","2560","2880", "3456", "3520") + + +static int aspect_ratio_presets_num[] = { 5, 4 , 3, 8, 25, 239, 235, 22, 2, 185, 16, 5, 3, 4, 1, 1, 9}; +static int aspect_ratio_presets_den[] = { 1, 1, 1, 3, 10, 100, 100, 10, 1, 100, 9, 3, 2, 3, 1, 2, 16}; +static const char * aspect_ratio_choices[] = { "5:1","4:1","3:1","2.67:1","2.50:1","2.39:1","2.35:1","2.20:1","2:1","1.85:1", "16:9","5:3","3:2","4:3","1:1","1:2","9:16"}; + /* camera-specific tricks */ /* todo: maybe add generic functions like is_digic_v, is_5d2 or stuff like that? */ static int cam_eos_m = 0; @@ -83,38 +98,44 @@ * use roughly 10% increments **/ -static int resolution_presets_x[] = { 640, 704, 768, 864, 960, 1152, 1280, 1344, 1472, 1600, 1728, 1856, 1920, 2048, 2240, 2560, 2880, 3584 }; -#define RESOLUTION_CHOICES_X CHOICES("640","704","768","864","960","1152","1280","1344","1472","1600","1728","1856","1920","2048","2240","2560","2880","3584") +//~ static int resolution_presets_x[] = { 640, 704, 768, 864, 960, 1152, 1280, 1344, 1472, 1600, 1728, 1856, 1920, 2048, 2240, 2560, 2880, 3584 }; +//~ #define RESOLUTION_CHOICES_X CHOICES("640","704","768","864","960","1152","1280","1344","1472","1600","1728","1856","1920","2048","2240","2560","2880","3584") -static int aspect_ratio_presets_num[] = { 5, 4, 3, 8, 25, 239, 235, 22, 2, 185, 16, 5, 3, 4, 1, 1 }; -static int aspect_ratio_presets_den[] = { 1, 1, 1, 3, 10, 100, 100, 10, 1, 100, 9, 3, 2, 3, 1, 2 }; -static const char * aspect_ratio_choices[] = {"5:1","4:1","3:1","2.67:1","2.50:1","2.39:1","2.35:1","2.20:1","2:1","1.85:1", "16:9","5:3","3:2","4:3","1:1","1:2"}; +//~ static int aspect_ratio_presets_num[] = { 5, 4, 3, 8, 25, 239, 235, 22, 2, 185, 16, 5, 3, 4, 1, 1 }; +//~ static int aspect_ratio_presets_den[] = { 1, 1, 1, 3, 10, 100, 100, 10, 1, 100, 9, 3, 2, 3, 1, 2 }; +//~ static const char * aspect_ratio_choices[] = {"5:1","4:1","3:1","2.67:1","2.50:1","2.39:1","2.35:1","2.20:1","2:1","1.85:1", "16:9","5:3","3:2","4:3","1:1","1:2"}; /* config variables */ + +static CONFIG_INT("raw.delay", start_delay_idx, 0); +static CONFIG_INT("raw.killgd", kill_gd, 0); +static CONFIG_INT("raw.reckey", rec_key, 0); + + static CONFIG_INT("raw.video.enabled", raw_video_enabled, 0); - -static CONFIG_INT("raw.res.x", resolution_index_x, 12); +static CONFIG_INT("raw.res.x", resolution_index_x, 10); static CONFIG_INT("raw.aspect.ratio", aspect_ratio_index, 10); static CONFIG_INT("raw.write.speed", measured_write_speed, 0); static CONFIG_INT("raw.skip.frames", allow_frame_skip, 0); -//~ static CONFIG_INT("raw.sound", sound_rec, 2); -#define sound_rec 2 +static CONFIG_INT("raw.sound", sound_rec, 0); static CONFIG_INT("raw.dolly", dolly_mode, 0); #define FRAMING_CENTER (dolly_mode == 0) #define FRAMING_PANNING (dolly_mode == 1) -static CONFIG_INT("raw.preview", preview_mode, 0); +static CONFIG_INT("raw.preview", preview_mode, 1); #define PREVIEW_AUTO (preview_mode == 0) #define PREVIEW_CANON (preview_mode == 1) #define PREVIEW_ML (preview_mode == 2) #define PREVIEW_HACKED (preview_mode == 3) +#define PREVIEW_NOT (preview_mode == 4) static CONFIG_INT("raw.warm.up", warm_up, 0); static CONFIG_INT("raw.memory.hack", memory_hack, 0); -static CONFIG_INT("raw.small.hacks", small_hacks, 0); +static CONFIG_INT("raw.small.hacks", small_hacks, 1); +static int start_delay = 0; /* state variables */ static int res_x = 0; static int res_y = 0; @@ -203,15 +224,18 @@ static int calc_res_y(int res_x, int num, int den, float squeeze) { + //~ int rounding_mask = res_x % 128 ? 31 : 15; if (squeeze != 1.0f) { /* image should be enlarged vertically in post by a factor equal to "squeeze" */ - return (int)(roundf(res_x * den / num / squeeze) + 1) & ~1; + //~ return (int)(roundf(res_x * den / num / squeeze) + rounding_mask) & ~rounding_mask; + return (int)(roundf(res_x * den / num / squeeze) + 1) & ~1; } else { /* assume square pixels */ - return (res_x * den / num + 1) & ~1; + //~ return (res_x * den / num + rounding_mask) & ~rounding_mask; + return (res_x * den / num + 1) & ~1; } } @@ -236,7 +260,6 @@ sy = COERCE(sy - delta_y, raw_info.active_area.y1, raw_info.active_area.y2 - res_y); } } - skip_x = sx; skip_y = sy; } @@ -248,18 +271,24 @@ int left_margin = (raw_info.active_area.x1 + 7) / 8 * 8; int right_margin = (raw_info.active_area.x2) / 8 * 8; int max = (right_margin - left_margin) & ~15; - while (max % 16) max--; + //~ while (max % 16 || (max * 14/8) % 16) max--; + while (max % 16) max--; + max_res_x = max; /* max res Y */ - max_res_y = raw_info.jpeg.height & ~1; + //~ int rounding_mask_y = res_x % 128 ? 31 : 15; + //~ max_res_y = raw_info.jpeg.height & ~rounding_mask_y; + max_res_y = raw_info.jpeg.height & ~1; /* squeeze factor */ - if (video_mode_resolution == 1 && lv_dispsize == 1 && is_movie_mode()) /* 720p, image squeezed */ + + if ( (cam_eos_m && !video_mode_crop) ? (lv_dispsize == 1) : (video_mode_resolution == 1 && lv_dispsize == 1 && is_movie_mode()) ) /* 720p, image squeezed */ + //~ if (lv_dispsize = 1) /* 720p, EOS-M All the Time */ { /* assume the raw image should be 16:9 when de-squeezed */ - int correct_height = max_res_x * 9 / 16; - //int correct_height = max_res_x * 2 / 3; //TODO : FIX THIS, USE FOR NON-FULLFRAME SENSORS! + int correct_height = cam_eos_m ? (max_res_x * 2 / 3) : (max_res_x * 9 / 16); + //~ int correct_height = max_res_x * 2 / 3; squeeze_factor = (float)correct_height / max_res_y; } else squeeze_factor = 1.0f; @@ -273,7 +302,6 @@ res_y = MIN(calc_res_y(res_x, num, den, squeeze_factor), max_res_y); /* frame size */ - /* should be multiple of 512, so there's no write speed penalty (see http://chdk.setepontos.com/index.php?topic=9970 ; confirmed by benchmarks) */ /* should be multiple of 4096 for proper EDMAC alignment */ int frame_size_padded = (res_x * res_y * 14/8 + 4095) & ~4095; @@ -317,21 +345,26 @@ if (minerr < 0.05) { int h = calc_res_y(res_x, best_num, best_den, squeeze_factor); + char* qualifier = h != res_y ? "almost " : ""; /* if the difference is 1 pixel, consider it exact */ - char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; + //~ char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; snprintf(msg, sizeof(msg), "%s%d:%d", qualifier, best_num, best_den); } else if (ratio > 1) { int r = (int)roundf(ratio * 100); + int r2 = (int)roundf(ratio * 1000); /* is it 2.35:1 or 2.353:1? */ - int h = calc_res_y(res_x, r, 100, squeeze_factor); - char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; + char* qualifier = ABS(r2 - r * 10) >= 1 ? "almost " : ""; + //~ int h = calc_res_y(res_x, r, 100, squeeze_factor); + //~ char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; if (r%100) snprintf(msg, sizeof(msg), "%s%d.%02d:1", qualifier, r/100, r%100); } else { int r = (int)roundf((1/ratio) * 100); + //~ int r2 = (int)roundf((1/ratio) * 1000); + //~ char* qualifier = ABS(r2 - r * 10) >= 1 ? "almost " : ""; int h = calc_res_y(res_x, 100, r, squeeze_factor); char* qualifier = ABS(h - res_y) > 1 ? "almost " : ""; if (r%100) snprintf(msg, sizeof(msg), "%s1:%d.%02d", qualifier, r/100, r%100); @@ -393,7 +426,8 @@ int ok = speed < measured_write_speed; speed /= 10; - if (frame_size % 512) + //~ if ((res_x * res_y * 14/8) % 512) + if (frame_size % 512) { MENU_SET_WARNING(MENU_WARN_ADVICE, "Frame size not multiple of 512 bytes!"); } @@ -517,6 +551,7 @@ int den = aspect_ratio_presets_den[aspect_ratio_index]; int selected_y = calc_res_y(res_x, num, den, squeeze_factor); + //~ if (selected_y != res_y) if (selected_y > max_res_y + 2) { char* ratio = guess_aspect_ratio(res_x, res_y * squeeze_factor); @@ -530,6 +565,22 @@ write_speed_update(entry, info); } +static MENU_UPDATE_FUNC(start_delay_update) +{ + switch (start_delay_idx) { + case 0: + start_delay = 0; break; + case 1: + start_delay = 2; break; + case 2: + start_delay = 4; break; + case 3: + start_delay = 10; break; + default: + start_delay= 0; break; + } +} + /* add a footer to given file handle to */ static unsigned int lv_rec_save_footer(FILE *save_file) { @@ -610,7 +661,10 @@ } if (!mem_suite) return 0; - + + ResumeLiveView(); + msleep(1000); + /* allocate memory for double buffering */ int buf_size = raw_info.width * raw_info.height * 14/8 * 33/32; /* leave some margin, just in case */ @@ -674,7 +728,7 @@ } chunk = GetNextMemoryChunk(mem_suite, chunk); } - + /* try to recycle the waste */ if (waste >= frame_size + 8192) { @@ -691,6 +745,20 @@ } } +/*New Strategy */ + /* Sort Buffers */ + + /* + static struct buff temp[10]; + for (int i = 0; i < buffer_count; i++) + for(int j = 0; j < buffer_count- i - 1; j++) + if(buffers[j].size < buffers[j + 1].size) + { + temp[j] = buffers[j]; + buffers[j] = buffers[j + 1]; + buffers[j + 1] = temp[j]; + } + */ char msg[100]; snprintf(msg, sizeof(msg), "Alloc: %d frames", slot_count); bmp_printf(FONT_MED, 30, 90, msg); @@ -774,6 +842,7 @@ static void cropmark_draw() { if (lv_dispsize > 1) return; + if (hdmi_code == 5) return; //Don't draw in HDMI int x = RAW2BM_X(skip_x); int y = RAW2BM_Y(skip_y); @@ -832,9 +901,21 @@ { /* toggle the lv_save_raw flag from raw.c */ raw_lv_request(); - + if (cam_50d && !(hdmi_code == 5)) + { + //~ call("lv_output_device", "vga"); //Shrink LV + call("lv_af_fase_addr", 0); //Turn off face detection + //~ call("lv_crop", 1); //Turn off face detection + //~ call("LV_OUTPUT_VRAM_TYPE", "vga"); //Turn off face detection + + } +/* + if (cam_7d && !(hdmi_code == 5)) + call("LV_OUTPUT_VRAM_TYPE", "vga"); + */ /* EOS-M needs this hack. Please don't use it unless there's no other way. */ - if (cam_eos_m) set_custom_movie_mode(1); + //~ if (cam_eos_m) set_custom_movie_mode(1); + if (!is_movie_mode()) set_custom_movie_mode(1); msleep(50); } @@ -842,14 +923,16 @@ static void raw_video_disable() { raw_lv_release(); - if (cam_eos_m) set_custom_movie_mode(0); + //~ if (cam_eos_m) set_custom_movie_mode(0); + if (is_custom_movie_mode()) set_custom_movie_mode(0); } + static void raw_lv_request_update() { static int raw_lv_requested = 0; - if (raw_video_enabled && lv && (is_movie_mode() || cam_eos_m)) /* exception: EOS-M needs to record in photo mode */ + if (raw_video_enabled && lv) /* exception: EOS-M needs to record in photo mode */ { if (!raw_lv_requested) { @@ -903,14 +986,14 @@ int t = (frame_count * 1000 + fps/2) / fps; int predicted = predict_frames(measured_write_speed * 1024 / 100 * 1024); if (predicted < 10000) - bmp_printf( FONT_MED, 30, 70, + bmp_printf( FONT_MED, 30, cam_50d ? 350 : 400, "%02d:%02d, %d frames / %d expected ", t/60, t%60, frame_count, predicted ); else - bmp_printf( FONT_MED, 30, 70, + bmp_printf( FONT_MED, 30, cam_50d ? 350 : 400, "%02d:%02d, %d frames, continuous OK ", t/60, t%60, frame_count @@ -938,41 +1021,110 @@ if (idle_percent) { STR_APPEND(msg, ", %d%% idle ", idle_percent); } else { STR_APPEND(msg, ", %dms idle ", idle_time); } } - bmp_printf( FONT_MED, 30, 90, "%s", msg); + bmp_printf( FONT_MED, 30, cam_50d ? 370 : 420, "%s", msg); } } return 0; } +/* +static void lv_unhack(int unused) +{ + while (!RAW_IS_IDLE) msleep(100); + if (cam_50d) + { + call("lv_ae", 1); + call("lv_wb", 1); + }else call("aewb_enableaewb", 1); + idle_globaldraw_en(); + PauseLiveView(); + ResumeLiveView(); +} +*/ -/* todo: reference counting, like with raw_lv_request */ -static void cache_require(int lock) +/* this is a separate task */ +static void unhack_liveview_vsync(int unused) { - static int cache_was_unlocked = 0; - if (lock) + while (!RAW_IS_IDLE) msleep(100); + idle_globaldraw_en(); + PauseLiveView(); + ResumeLiveView(); +} + + +static void hack_liveview(int unhack) +{ + if (PREVIEW_NOT || kill_gd) + { + idle_globaldraw_dis(); + clrscr(); + } + if (small_hacks) { - if (!cache_locked()) + /* disable canon graphics (gains a little speed) */ + static int canon_gui_was_enabled; + if (!unhack) { - cache_was_unlocked = 1; - icache_lock(); + canon_gui_was_enabled = !canon_gui_front_buffer_disabled(); + canon_gui_disable_front_buffer(); } - } - else - { - if (cache_was_unlocked) + else if (canon_gui_was_enabled) { - icache_unlock(); - cache_was_unlocked = 0; + canon_gui_enable_front_buffer(0); + canon_gui_was_enabled = 0; } + /* disable auto exposure and auto white balance */ + + call("aewb_enableaewb", unhack ? 1 : 0); /* for new cameras */ + call("lv_ae", unhack ? 1 : 0); /* for old cameras */ + call("lv_wb", unhack ? 1 : 0); + if (cam_7d) call("lv_no_flicker", unhack ? 0 : 1); //Disable Flicker + //~ if (cam_7d) call("lv_exec_flicker", "0"); //Disable Flicker + //~ if (cam_7d && !(hdmi_code == 5)) + //~ call("LV_OUTPUT_VRAM_TYPE", unhack ? "1080f" : "vga"); + /* change dialog refresh timer from 50ms to 2048ms */ + uint32_t dialog_refresh_timer_addr = /* in StartDialogRefreshTimer */ + cam_50d ? 0xffa84e00 : + cam_5d2 ? 0xffaac640 : + cam_5d3 ? 0xff4acda4 : + cam_6d ? 0xFF52BE94 : + cam_eos_m ? 0xFF539C1C : + cam_700d ? 0xFF52B53C : + cam_7d ? 0xFF345788 : + /* ... */ + 0; + uint32_t dialog_refresh_timer_orig_instr = 0xe3a00032; /* mov r0, #50 */ + //~ uint32_t dialog_refresh_timer_new_instr = 0xe3a00b02; /* change to mov r0, #2048 */ + uint32_t dialog_refresh_timer_new_instr = 0xe3a00a02; /* change to mov r0, #8192 */ + + if (*(volatile uint32_t*)dialog_refresh_timer_addr != dialog_refresh_timer_orig_instr) + { + /* something's wrong */ + NotifyBox(1000, "Hack error at %x:\nexpected %x, got %x", dialog_refresh_timer_addr, dialog_refresh_timer_orig_instr, *(volatile uint32_t*)dialog_refresh_timer_addr); + beep_custom(1000, 2000, 1); + dialog_refresh_timer_addr = 0; + + } + if (dialog_refresh_timer_addr) + { + if (!unhack) /* hack */ + { + cache_fake(dialog_refresh_timer_addr, dialog_refresh_timer_new_instr, TYPE_ICACHE); + } + else /* unhack */ + { + cache_fake(dialog_refresh_timer_addr, dialog_refresh_timer_orig_instr, TYPE_ICACHE); + } + } + } } -static void unhack_liveview_vsync(int unused); static void hack_liveview_vsync() { - if (cam_5d2 || cam_50d || cam_7d ) + if (cam_5d2 || cam_50d /*|| cam_7d*/ ) //Its not gray { /* try to fix pink preview in zoom mode (5D2/50D) */ if (lv_dispsize > 1 && !get_halfshutter_pressed()) @@ -1005,113 +1157,58 @@ //~ *(volatile uint32_t*)0xc0f0e094 = 0; *(volatile uint32_t*)0xc0f0f1c4 = 0xFFFFFFFF; } + } } + //~ if (!PREVIEW_HACKED && !PREVIEW_NOT && !PREVIEW_CANON && !PREVIEW_ML) return; - if (!PREVIEW_HACKED) return; - int rec = RAW_IS_RECORDING; - static int prev_rec = 0; int should_hack = 0; int should_unhack = 0; - - if (rec) + if (RAW_IS_RECORDING) { if (frame_count == 0) should_hack = 1; } - else if (prev_rec) - { + else if (RAW_IS_FINISHING) + { should_unhack = 1; } - prev_rec = rec; - + if (should_hack) { - int y = 100; + if(!PREVIEW_CANON && !PREVIEW_AUTO) +{ int y = 100; for (int channel = 0; channel < 32; channel++) { /* silence out the EDMACs used for HD and LV buffers */ int pitch = edmac_get_length(channel) & 0xFFFF; - if (pitch == vram_lv.pitch || pitch == vram_hd.pitch) + if (pitch == vram_lv.pitch || pitch == vram_hd.pitch || pitch== 2000 || pitch== 512 || pitch== 576 || pitch== 3456) + //~ if (pitch == vram_lv.pitch || pitch == vram_hd.pitch) { uint32_t reg = edmac_get_base(channel); bmp_printf(FONT_SMALL, 30, y += font_small.height, "Hack %x %dx%d ", reg, shamem_read(reg + 0x10) & 0xFFFF, shamem_read(reg + 0x10) >> 16); *(volatile uint32_t *)(reg + 0x10) = shamem_read(reg + 0x10) & 0xFFFF; } - } + } +} } else if (should_unhack) - { - task_create("lv_unhack", 0x1e, 0x1000, unhack_liveview_vsync, (void*)0); + { + + if (cam_eos_m) //EOS-M not unhacking, why? + { //call("aewb_enableaewb", 1); + + PauseLiveView(); + ResumeLiveView(); + idle_globaldraw_en(); + } + else + task_create("lv_unhack", 0x1e, 0x1000, unhack_liveview_vsync, (void*)0); } } -/* this is a separate task */ -static void unhack_liveview_vsync(int unused) -{ - while (!RAW_IS_IDLE) msleep(100); - PauseLiveView(); - ResumeLiveView(); -} -static void hack_liveview(int unhack) -{ - if (small_hacks) - { - /* disable canon graphics (gains a little speed) */ - static int canon_gui_was_enabled; - if (!unhack) - { - canon_gui_was_enabled = !canon_gui_front_buffer_disabled(); - canon_gui_disable_front_buffer(); - } - else if (canon_gui_was_enabled) - { - canon_gui_enable_front_buffer(0); - canon_gui_was_enabled = 0; - } - - /* disable auto exposure and auto white balance */ - call("aewb_enableaewb", unhack ? 1 : 0); /* for new cameras */ - call("lv_ae", unhack ? 1 : 0); /* for old cameras */ - call("lv_wb", unhack ? 1 : 0); - - /* change dialog refresh timer from 50ms to 8192ms */ - uint32_t dialog_refresh_timer_addr = /* in StartDialogRefreshTimer */ - cam_50d ? 0xffa84e00 : - cam_5d2 ? 0xffaac640 : - cam_5d3 ? 0xff4acda4 : - cam_7d ? 0xFF345788 : - cam_700d ? 0xFF52B53C : - /* ... */ - 0; - uint32_t dialog_refresh_timer_orig_instr = 0xe3a00032; /* mov r0, #50 */ - uint32_t dialog_refresh_timer_new_instr = 0xe3a00a02; /* change to mov r0, #8192 */ - - if (*(volatile uint32_t*)dialog_refresh_timer_addr != dialog_refresh_timer_orig_instr) - { - /* something's wrong */ - NotifyBox(1000, "Hack error at %x:\nexpected %x, got %x", dialog_refresh_timer_addr, dialog_refresh_timer_orig_instr, *(volatile uint32_t*)dialog_refresh_timer_addr); - beep_custom(1000, 2000, 1); - dialog_refresh_timer_addr = 0; - } - - if (dialog_refresh_timer_addr) - { - if (!unhack) /* hack */ - { - cache_require(1); - cache_fake(dialog_refresh_timer_addr, dialog_refresh_timer_new_instr, TYPE_ICACHE); - } - else /* unhack */ - { - cache_fake(dialog_refresh_timer_addr, dialog_refresh_timer_orig_instr, TYPE_ICACHE); - cache_require(0); - } - } - } -} static int FAST choose_next_capture_slot() { @@ -1416,17 +1513,19 @@ bmp_printf( FONT_MED, 30, 50, "Memory error"); goto cleanup; } - - if (sound_rec == 1) +/* + if (sound_rec == 2) { char* wavfile = get_wav_file_name(movie_filename); bmp_printf( FONT_MED, 30, 90, "Sound: %s%s", wavfile + 17, wavfile[0] == 'B' && movie_filename[0] == 'A' ? " on SD card" : ""); bmp_printf( FONT_MED, 30, 90, "%s", wavfile); WAV_StartRecord(wavfile); } - - hack_liveview(0); - +*/ + msleep(start_delay * 1000); + + hack_liveview(0); + /* get exclusive access to our edmac channels */ edmac_memcpy_res_lock(); @@ -1434,7 +1533,7 @@ raw_recording_state = RAW_RECORDING; /* try a sync beep (not very precise, but better than nothing) */ - if (sound_rec == 2) + if (sound_rec == 1) { beep(); } @@ -1670,7 +1769,7 @@ "Movie recording stopped automagically " ); /* this is error beep, not audio sync beep */ - beep_times(2); + //~ beep_times(2); } break; } @@ -1689,12 +1788,12 @@ edmac_memcpy_res_unlock(); recording = 0; - - if (sound_rec == 1) +/* + if (sound_rec == 2) { WAV_StopRecord(); } - +*/ bmp_printf( FONT_MED, 30, 70, "Frames captured: %d ", frame_count - 1 @@ -1777,7 +1876,7 @@ #ifdef DEBUG_BUFFERING_GRAPH take_screenshot(0); #endif - hack_liveview(1); + hack_liveview(1); redraw(); raw_recording_state = RAW_IDLE; } @@ -1787,7 +1886,7 @@ if (!RAW_IS_IDLE) { raw_recording_state = RAW_FINISHING; - if (sound_rec == 2) beep(); + if (sound_rec == 1) beep(); } else { @@ -1797,6 +1896,7 @@ } } + static void raw_video_playback_task() { void* buf = NULL; @@ -1911,6 +2011,14 @@ MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Record a video clip first."); } +static void raw_delete(void* priv, int delta) +{ + if(!RAW_IS_IDLE || !movie_filename) return; + + FIO_RemoveFile(movie_filename); + movie_filename = 0; +} + static struct menu_entry raw_video_menu[] = { { @@ -1946,24 +2054,67 @@ .help2 = "Useful for video modes with squeezed image (e.g. 720p).", }, */ - /* gets out of sync + { .name = "Sound", .priv = &sound_rec, - .max = 2, - .choices = CHOICES("OFF", "Separate WAV", "Sync beep"), + .max = 1, + //~ .choices = CHOICES("OFF", "Separate WAV", "Sync beep"), + .choices = CHOICES("OFF", "Sync beep"), .help = "Sound recording options.", }, - */ + { + .name = "Global Draw", + .priv = &kill_gd, + .max = 1, + .choices = CHOICES("ON", "OFF"), + .help = "Disable global draw while recording.\n Some previews depend on GD", + }, + { + .name = "Rec Key", + .priv = &rec_key, + .max = 1, + .choices = CHOICES("LV/REC", "MENU"), + .help = "Start recording with either LV or Menu button. Required for EOSM", + }, + + { + .name = "Frame skipping", + .priv = &allow_frame_skip, + .max = 1, + .choices = CHOICES("OFF", "Allow"), + .help = "Enable if you don't mind skipping frames (for slow cards).", + }, +/* { + .name = "Framing", + .priv = &framing_mode, + .update = framing_update, + .max = 2, + .choices = CHOICES("Center", "Force Left", "Dolly mode"), + .help = "Choose how to frame recorded the image.", + .help2 = "Center: most intuitive, but not the fastest.\n" + "Force Left: we can chop off the right side for higher speed.\n" + "Dolly: smooth panning of the recording window, with arrows." + }, */ { .name = "Preview", .priv = &preview_mode, - .max = 3, - .choices = CHOICES("Auto", "Canon", "ML Grayscale", "HaCKeD"), + .max = 4, + .choices = CHOICES("Auto", "Canon", "ML Grayscale", "HaCKeD", "Hacked No Prev"), .help2 = "Auto: ML chooses what's best for each video mode\n" "Canon: plain old LiveView. Framing is not always correct.\n" "ML Grayscale: looks ugly, but at least framing is correct.\n" "HaCKeD: try to squeeze a little speed by killing LiveView.\n" + "HaCKeD2: No preview. Disables Global draw while recording.\n" + }, + { + .name = "Start delay", + .priv = &start_delay_idx, + .max = 3, + .choices = CHOICES("OFF", "2 sec.", "4 sec.", "10 sec."), + .update = start_delay_update, + .help = "Start delay. Useful to stabilize in photo mode.", + .help2 = "Pressing shutter button.", }, { .name = "Digital dolly", @@ -1973,13 +2124,6 @@ .help2 = "Use arrow keys (joystick) to move the window." }, { - .name = "Frame skipping", - .priv = &allow_frame_skip, - .max = 1, - .choices = CHOICES("OFF", "Allow"), - .help = "Enable if you don't mind skipping frames (for slow cards).", - }, - { .name = "Card warm-up", .priv = &warm_up, .max = 7, @@ -1994,17 +2138,23 @@ .help = "Allocate memory with LiveView off. On 5D3 => 2x32M extra.", }, { - .name = "Small hacks", + .name = "Extra Hacks", .priv = &small_hacks, .max = 1, - .help = "Slow down Canon GUI, disable auto exposure, white balance...", + .help = "Slow down Canon GUI, Lock digital expo while recording...", }, { .name = "Playback", .select = raw_playback_start, - .update = raw_playback_update, + .update = raw_playback_update, .icon_type = IT_ACTION, - .help = "Play back the last raw video clip.", + .help = "Play back the last raw video clip when idle", + .depends_on = DEP_LIVEVIEW, + }, + { + .name = "Delete", + .select = raw_delete, + .help = "Set video file size to zero", }, MENU_EOL, }, @@ -2026,7 +2176,11 @@ /* start/stop recording with the LiveView key */ int rec_key_pressed = (key == MODULE_KEY_LV || key == MODULE_KEY_REC); - + + /* MENU ON EOSM Photo Mode */ + if (cam_eos_m) + rec_key_pressed = ( rec_key ? key== MODULE_KEY_MENU : (key == MODULE_KEY_LV || key == MODULE_KEY_REC) ); + /* ... or SET on 5D2/50D */ if (cam_50d || cam_5d2) rec_key_pressed = (key == MODULE_KEY_PRESS_SET); @@ -2099,9 +2253,11 @@ { if (!raw_video_enabled) return 0; if (!is_movie_mode()) return 0; - + if (kill_gd && (RAW_IS_PREPARING || RAW_IS_RECORDING)) + return 0; /* keep x10 mode unaltered, for focusing */ - if (lv_dispsize == 10) return 0; + /* But on 7D the YUV buff shrinks to 720x56 */ + if (lv_dispsize == 10 && !cam_7d) return 0; if (PREVIEW_AUTO) /* enable preview in x5 mode, since framing doesn't match */ @@ -2116,6 +2272,9 @@ else if (PREVIEW_HACKED) return RAW_IS_RECORDING || get_halfshutter_pressed() || lv_dispsize == 5; + else if (PREVIEW_NOT) + return 0; + return 0; } @@ -2132,6 +2291,7 @@ preview_dirty = 0; } return enabled; + //~ break; } struct display_filter_buffers * buffers = (struct display_filter_buffers *) ctx; @@ -2168,12 +2328,12 @@ /* customize menus for each camera here (e.g. hide what doesn't work) */ /* 50D doesn't have sound and can't even beep */ - if (cam_50d && streq(e->name, "Sound")) - { - e->shidden = 1; - //sound_rec = 0; - } - + if ( (cam_50d || cam_eos_m) && streq(e->name, "Sound")) + e->shidden = 1; + if (!cam_eos_m && streq(e->name, "Rec Key") ) + e->shidden = 1; + if (cam_eos_m && streq(e->name, "Digital dolly") ) + e->shidden = 1; /* Memory hack confirmed to work only on 5D3 and 6D */ if (streq(e->name, "Memory hack") && !(cam_5d3 || cam_6d)) { @@ -2229,10 +2389,15 @@ MODULE_CONFIG(aspect_ratio_index) MODULE_CONFIG(measured_write_speed) MODULE_CONFIG(allow_frame_skip) - //~ MODULE_CONFIG(sound_rec) MODULE_CONFIG(dolly_mode) MODULE_CONFIG(preview_mode) MODULE_CONFIG(memory_hack) - MODULE_CONFIG(small_hacks) + MODULE_CONFIG(sound_rec) + + MODULE_CONFIG(start_delay_idx) + MODULE_CONFIG(kill_gd) + MODULE_CONFIG(rec_key) + + MODULE_CONFIG(small_hacks) MODULE_CONFIG(warm_up) MODULE_CONFIGS_END() diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/raw_rec/speedsim.py --- a/modules/raw_rec/speedsim.py Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/raw_rec/speedsim.py Sun Sep 22 11:41:50 2013 -0500 @@ -6,8 +6,20 @@ import os, sys, math from pylab import * -# buffers = [32*1024*1024] * 4 # 5D3 1x +#buffers = [32*1024*1024] * 4 # 5D3 1x # buffers = [32*1024*1024] * 3 + [22 * 1024 * 1024] # 5D3 zoom +<<<<<<< local +#buffers = [32*1024*1024] * 8 + [23 * 1024 * 1024] # 60D (wow!) +buffers = [31*1024*1024] + [30*1024*1024] + [28*1024*1024] # 60D (wow!) + + + +x = 1728; +y = 736; +fps = 24; +write_speed = 19.2*1024*1024; +timing_variation = 0.01; +======= # buffers = [32*1024*1024] * 8 + [8 * 1024 * 1024] # 60D (wow!) buffers = [32*1024*1024] * 2 + [8 * 1024 * 1024] # 550D @@ -15,6 +27,7 @@ y = 464; fps = 23.976; write_speed = 21.0*1024*1024; +>>>>>>> other framesize = x * y * 14/8; diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/script/script.c --- a/modules/script/script.c Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/script/script.c Sun Sep 22 11:41:50 2013 -0500 @@ -263,7 +263,7 @@ static void find_scripts(void) { struct fio_file file; - struct fio_dirent * dirent = FIO_FindFirstEx( "ML/SCRIPTS/", &file ); + struct fio_dirent * dirent = FIO_FindFirstEx( "B:/ML/SCRIPTS/", &file ); if( IS_ERROR(dirent) ) { NotifyBox(2000, "Scripts dir missing" ); diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/spy_ae/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/spy_ae/Makefile Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,9 @@ +# define the module name - make sure name is max 8 characters +MODULE_NAME=spy_ae +MODULE_OBJS=spy_ae.o + +#include modules environment +include ../Makefile.modules + + + diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/spy_ae/spy_ae.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/spy_ae/spy_ae.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,190 @@ +/* +these are suspicious + +173ec +1745c +15c48 +17400 +17404 +17408 +17410 +13024 +13044 +173fc +2828 +13008 +1c14 + +*/ + +#include +#include +#include +#include + +int mem_spy = 0; + +int mem_spy_start = 0x70000; // start from here +int mem_spy_bool = 0; // only display booleans (0,1,-1) +int mem_spy_fixed_addresses = 0; // only look from a list of fixed addresses +const int mem_spy_addresses[] = {};//0xc0000044, 0xc0000048, 0xc0000057, 0xc00011cf, 0xc02000a8, 0xc02000ac, 0xc0201004, 0xc0201010, 0xc0201100, 0xc0201104, 0xc0201200, 0xc0203000, 0xc020301c, 0xc0203028, 0xc0203030, 0xc0203034, 0xc020303c, 0xc0203044, 0xc0203048, 0xc0210200, 0xc0210208, 0xc022001c, 0xc0220028, 0xc0220034, 0xc0220070, 0xc02200a4, 0xc02200d0, 0xc02200d4, 0xc02200d8, 0xc02200e8, 0xc02200ec, 0xc0220100, 0xc0220104, 0xc022010c, 0xc0220118, 0xc0220130, 0xc0220134, 0xc0220138, 0xc0222000, 0xc0222004, 0xc0222008, 0xc022200c, 0xc0223000, 0xc0223010, 0xc0223060, 0xc0223064, 0xc0223068, 0xc0224100, 0xc0224104, 0xc022d000, 0xc022d02c, 0xc022d074, 0xc022d1ec, 0xc022d1f0, 0xc022d1f4, 0xc022d1f8, 0xc022d1fc, 0xc022dd14, 0xc022f000, 0xc022f004, 0xc022f200, 0xc022f210, 0xc022f214, 0xc022f340, 0xc022f344, 0xc022f430, 0xc022f434, 0xc0238060, 0xc0238064, 0xc0238080, 0xc0238084, 0xc0238098, 0xc0242010, 0xc0300000, 0xc0300100, 0xc0300104, 0xc0300108, 0xc0300204, 0xc0400004, 0xc0400008, 0xc0400018, 0xc040002c, 0xc0400080, 0xc0400084, 0xc040008c, 0xc04000b4, 0xc04000c0, 0xc04000c4, 0xc04000cc, 0xc0410000, 0xc0410008, 0xc0500080, 0xc0500088, 0xc0500090, 0xc0500094, 0xc05000a0, 0xc05000a8, 0xc05000b0, 0xc05000b4, 0xc05000c0, 0xc05000c4, 0xc05000c8, 0xc05000cc, 0xc05000d0, 0xc05000d4, 0xc05000d8, 0xc0520000, 0xc0520004, 0xc0520008, 0xc052000c, 0xc0520014, 0xc0520018, 0xc0720000, 0xc0720004, 0xc0720008, 0xc072000c, 0xc0720014, 0xc0720024, 0xc07200ec, 0xc07200f0, 0xc0720100, 0xc0720104, 0xc0720108, 0xc072010c, 0xc0720110, 0xc0720114, 0xc0720118, 0xc072011c, 0xc07201c8, 0xc0720200, 0xc0720204, 0xc0720208, 0xc072020c, 0xc0720210, 0xc0800008, 0xc0800014, 0xc0800018, 0xc0820000, 0xc0820304, 0xc0820308, 0xc082030c, 0xc0820310, 0xc0820318, 0xc0920000, 0xc0920004, 0xc0920008, 0xc092000c, 0xc0920010, 0xc0920100, 0xc0920118, 0xc092011c, 0xc0920120, 0xc0920124, 0xc0920204, 0xc0920208, 0xc092020c, 0xc0920210, 0xc0920220, 0xc0920224, 0xc0920238, 0xc0920320, 0xc0920344, 0xc0920348, 0xc0920354, 0xc0920358, 0xc0a00000, 0xc0a00008, 0xc0a0000c, 0xc0a00014, 0xc0a00018, 0xc0a0001c, 0xc0a00020, 0xc0a00024, 0xc0a00044, 0xc0a10008 }; +int mem_spy_len = 200000/4; // look at ### int32's; use only when mem_spy_fixed_addresses = 0 +//~ int mem_spy_len = COUNT(mem_spy_addresses); // use this when mem_spy_fixed_addresses = 1 + +int mem_spy_count_lo = 10; // how many times is a value allowed to change +int mem_spy_count_hi = 100; // (limits) +int mem_spy_freq_lo = 0; +int mem_spy_freq_hi = 5; // or check frequecy between 2 limits (0 = disable) +int mem_spy_value_lo = 8; +int mem_spy_value_hi = 2049; // or look for a specific range of values (0 = disable) +int mem_spy_start_time = 15; // ignore values changing early (these are noise) + + +static int* dbg_memmirror = 0; +static int* dbg_memchanges = 0; +static int* dbg_posY = 0; + +static int dbg_memspy_get_addr(int i) +{ + if (mem_spy_fixed_addresses) + return mem_spy_addresses[i]; + else + return mem_spy_start + i*4; +} + +// for debugging purpises only +int _t = 0; +static int _get_timestamp(struct tm * t) +{ + return t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600 + t->tm_mday * 3600 * 24; +} +static void _tic() +{ + struct tm now; + LoadCalendarFromRTC(&now); + _t = _get_timestamp(&now); +} +static int _toc() +{ + struct tm now; + LoadCalendarFromRTC(&now); + return _get_timestamp(&now) - _t; +} + +static void dbg_memspy_init() // initial state of the analyzed memory +{ + bmp_printf(FONT_MED, 10,10, "memspy init @ %x ... (+%x) ... %x", mem_spy_start, mem_spy_len, mem_spy_start + mem_spy_len * 4); + //~ msleep(2000); + //mem_spy_len is number of int32's + if (!dbg_memmirror) dbg_memmirror = SmallAlloc(mem_spy_len*4 + 100); // local copy of mem area analyzed + if (!dbg_memmirror) return; + if (!dbg_memchanges) dbg_memchanges = SmallAlloc(mem_spy_len*4 + 100); // local copy of mem area analyzed + if (!dbg_memchanges) return; + if (!dbg_posY) dbg_posY = SmallAlloc(mem_spy_len*4 + 100); // local copy of mem area analyzed + if (!dbg_posY) return; + int i; + //~ bmp_printf(FONT_MED, 10,10, "memspy alloc"); + int crc = 0; + for (i = 0; i < mem_spy_len; i++) + { + uint32_t addr = dbg_memspy_get_addr(i); + dbg_memmirror[i] = (int) MEMX(addr); + dbg_memchanges[i] = 0; + crc += dbg_memmirror[i]; + //~ bmp_printf(FONT_MED, 10,10, "memspy: %8x => %8x ", addr, dbg_memmirror[i]); + //~ msleep(1000); + } + bmp_printf(FONT_MED, 10,10, "memspy OK: %x", crc); + + _tic(); +} + +static void dbg_memspy_update() +{ + int i; + static int init_done = 0; + if (!init_done) dbg_memspy_init(); + + if (!dbg_memmirror) return; + if (!dbg_memchanges) return; + if (!dbg_posY) return; + + if(!init_done) + for (i = 0; i < mem_spy_len; i++){ + dbg_posY[i]=0; + } + init_done = 1; + + + int elapsed_time = _toc(); + bmp_printf(FONT_MED, 50, 400, "%ds ", elapsed_time); + + static int nextY = 0; + + for (i = 0; i < mem_spy_len; i++) + { + uint32_t addr = dbg_memspy_get_addr(i); + int oldval = dbg_memmirror[i]; + int newval = (int) MEMX(addr); + if (oldval != newval) + { + dbg_memmirror[i] = newval; + if((*(int*)0x173ec) != 23)//ae related + dbg_memchanges[i]++; + else + dbg_memchanges[i]-=2;//penalty + } + //if( (oldval || newval) != (2049 || 2048 || ((2049 - 1) * 8 / 2048)) ) goto ignored; + + if (mem_spy_value_lo && newval < mem_spy_value_lo) goto ignored; + if (mem_spy_value_hi && newval > mem_spy_value_hi) goto ignored; + + if (mem_spy_count_lo && dbg_memchanges[i] < mem_spy_count_lo) goto ignored; + if (mem_spy_count_hi && dbg_memchanges[i] > mem_spy_count_hi) goto ignored; + + int freq = dbg_memchanges[i] / elapsed_time; + if (mem_spy_freq_lo && freq < mem_spy_freq_lo) goto ignored; + if (mem_spy_freq_hi && freq > mem_spy_freq_hi) goto ignored; + + if(!dbg_posY[i]){ + nextY += font_small.height; + dbg_posY[i]=nextY; + } + + ignored: + if(!dbg_posY[i])continue; + + bmp_printf( + (oldval == newval) ? FONT_SMALL : FONT(FONT_SMALL, COLOR_YELLOW, COLOR_BLACK), + 0, dbg_posY[i], + "%8x : %8d : %8d : ae: %d", + addr, dbg_memchanges[i], newval, (*(int*)0x173ec)!=23 + ); + } +} + +unsigned int shoot_task_cbr(unsigned int ctx) +{ + dbg_memspy_update(); + return 0; +} + +static unsigned int dummy() +{ + return 0; +} + +MODULE_INFO_START() + MODULE_INIT(dummy) + MODULE_DEINIT(dummy) +MODULE_INFO_END() + +MODULE_STRINGS_START() + MODULE_STRING("Description", "AE related addresses via mem spy") + MODULE_STRING("License", "GPL") +MODULE_STRINGS_END() + +MODULE_CBRS_START() + MODULE_CBR(CBR_SHOOT_TASK, shoot_task_cbr, 0) +MODULE_CBRS_END() + diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/tinypy/tinypy-desktop Binary file modules/tinypy/tinypy-desktop has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 modules/trace/trace.c --- a/modules/trace/trace.c Fri Sep 20 16:56:08 2013 +0300 +++ b/modules/trace/trace.c Sun Sep 22 11:41:50 2013 -0500 @@ -527,4 +527,3 @@ MODULE_INIT(trace_init) MODULE_DEINIT(trace_deinit) MODULE_INFO_END() - diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/50D.109/Makefile.platform.default --- a/platform/50D.109/Makefile.platform.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/50D.109/Makefile.platform.default Sun Sep 22 11:41:50 2013 -0500 @@ -11,4 +11,5 @@ # RESTARTSTART is selected to be just above the end of the bss # RESTARTSTART = 0x0004b000 +#RESTARTSTART = 0x00C60100 endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/50D.109/Makefile.setup.default --- a/platform/50D.109/Makefile.setup.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/50D.109/Makefile.setup.default Sun Sep 22 11:41:50 2013 -0500 @@ -8,8 +8,7 @@ raw.o \ chdk-dng.o \ edmac-memcpy.o \ -# dm-spy.o \ + dm-spy.o \ # video_hacks.o - # reloc.o \ # af_patterns.o \ diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/50D.109/consts.h --- a/platform/50D.109/consts.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/50D.109/consts.h Sun Sep 22 11:41:50 2013 -0500 @@ -18,6 +18,7 @@ #define HIJACK_FIXBR_BZERO32 0xff8108a4 #define HIJACK_FIXBR_CREATE_ITASK 0xff81092c #define HIJACK_INSTR_MY_ITASK 0xff810948 + #define HIJACK_TASK_ADDR 0x1A70 //~ Allocate Mem Boot @@ -39,6 +40,7 @@ //~ #define ML_RESERVED_MEM 640*1024 #define CACHE_HACK_FLUSH_RATE_SLAVE 0xFF84D358 + #define ARMLIB_OVERFLOWING_BUFFER 0x1e948 // in AJ_armlib_setup_related3 #define DRYOS_ASSERT_HANDLER 0x1A14 // dec TH_assert or assert_0 @@ -126,8 +128,8 @@ #define MOV_OPT_STEP 2 #define MOV_GOP_OPT_STEP 2 -// http://www.magiclantern.fm/forum/index.php?topic=7208.100 -#define AE_STATE (*(int8_t*)(0xFB30 + 0x1C)) + +#define AE_STATE (*(int8_t*)(0xFB30 + 0x1C)) #define AE_VALUE (*(int8_t*)(0xFB30 + 0x1D)) #define CURRENT_DIALOG_MAYBE (*(int*)0x387C) @@ -141,8 +143,9 @@ #define DLG_Q_UNAVI 0x18 #define DLG_FLASH_AE 0x22 #define DLG_PICQ 6 -#define DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED 0 // (CURRENT_DIALOG_MAYBE == 0x1A) -#define DLG_MOVIE_PRESS_LV_TO_RESUME 0 // (CURRENT_DIALOG_MAYBE == 0x1B) + +#define DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED (CURRENT_DIALOG_MAYBE == 0x1B) //Sure +#define DLG_MOVIE_PRESS_LV_TO_RESUME (CURRENT_DIALOG_MAYBE == 0x1C) //Not Sure #define AUDIO_MONITORING_HEADPHONES_CONNECTED (!((*(int*)0xc0220070) & 1)) #define HOTPLUG_VIDEO_OUT_PROP_DELIVER_ADDR 0x1af8 // this prop_deliver performs the action for Video Connect and Video Disconnect @@ -235,14 +238,13 @@ #define DISPLAY_IS_ON MEM(0x2860) // TurnOnDisplay (PUB) Type=%ld fDisplayTurnOn=%ld #define LV_STRUCT_PTR 0x1D74 + //Set 1 #define FRAME_SHUTTER *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x56) #define FRAME_APERTURE *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x57) #define FRAME_ISO *(uint16_t*)(MEM(LV_STRUCT_PTR) + 0x58) #define FRAME_SHUTTER_TIMER *(uint16_t*)(MEM(LV_STRUCT_PTR) + 0x5c) -//Smoother I think -#define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) -//~ #define FRAME_BV *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x60) //Looks like BV +#define FRAME_BV *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x5A) //Looks like BV //set 2 Doesn't do HDR //~ #define FRAME_SHUTTER *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x68) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/50D.109/features.h --- a/platform/50D.109/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/50D.109/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -4,20 +4,33 @@ #define FEATURE_MOVIE_RECORDING_50D #define CONFIG_MOVIE_RECORDING_50D_SHUTTER_HACK -/* slows down LiveView; has other side effects on 5D2/50D */ -#undef FEATURE_FOCUS_PEAK_DISP_FILTER //oh yea! -#define FEATURE_LV_FOCUS_BOX_SNAP_TO_X5_RAW +#define FEATURE_NOHELP // Kill Help Menus +#define FEATURE_PREFIX +#define FEATURE_FOCUS_PEAK_DISP_FILTER //oh yea! +//~ #define FEATURE_AFMA_TUNING //Module +#define FEATURE_TIMER_HACK + // no audio at all #undef FEATURE_AUDIO_METERS -#undef FEATURE_BEEP #undef FEATURE_WAV_RECORDING #undef FEATURE_VOICE_TAGS #undef FEATURE_AUDIO_REMOTE_SHOT #undef FEATURE_NITRATE_WAV_RECORD #undef FEATURE_FPS_WAV_RECORD +#undef CONFIG_AUTOBACKUP_ROM //Its wrong anyways +#undef CONFIG_STRESS_TEST #undef FEATURE_SHUTTER_FINE_TUNING //Too Flashy +#undef FEATURE_GRADUAL_EXPOSURE //Unreliable even with ISO only. #undef FEATURE_FLEXINFO - #undef FEATURE_UPSIDE_DOWN // not working, http://www.magiclantern.fm/forum/index.php?topic=4430 + +#define FEATURE_PROP_DISPLAY +#define CONFIG_HEXDUMP +#define CONFIG_DEBUG_INTERCEPT + +//~ #define FEATURE_VIDEO_HACKS +//~ #define CONFIG_TSKMON +//~ #define FEATURE_REMAP +#define FEATURE_LV_FOCUS_BOX_SNAP_TO_X5_RAW diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/50D.109/gui.c --- a/platform/50D.109/gui.c Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/50D.109/gui.c Sun Sep 22 11:41:50 2013 -0500 @@ -109,7 +109,6 @@ return 1; } - struct gui_main_struct { void * obj; // off_0x00; uint32_t counter; // off_0x04; diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/50D.109/internals.h --- a/platform/50D.109/internals.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/50D.109/internals.h Sun Sep 22 11:41:50 2013 -0500 @@ -78,7 +78,6 @@ #define CONFIG_FRAME_ISO_OVERRIDE /** We can also override shutter on a per-frame basis */ -/* really? no other old camera can do this */ //~ #define CONFIG_FRAME_SHUTTER_OVERRIDE /** And we can override the digital ISO component via FRAME_ISO too **/ @@ -97,7 +96,7 @@ #define CONFIG_RESTORE_AFTER_FORMAT /** DMA_MEMCPY **/ -//~ #define CONFIG_DMA_MEMCPY +#define CONFIG_DMA_MEMCPY /** We shouldn't warn the user if movie exposure is Auto **/ //~ #define CONFIG_MOVIE_AE_WARNING diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/50D.109/stubs.S --- a/platform/50D.109/stubs.S Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/50D.109/stubs.S Sun Sep 22 11:41:50 2013 -0500 @@ -1,297 +1,298 @@ -/** \file - * Entry points into the firmware image. - * - * These are the functions that we can call from our tasks - * in the Canon 1.0.9 firmware for the 50d. - * - * - * Copyright (C) 2010 Magic Lantern Team - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include - -.text - -NSTUB( ROMBASEADDR, firmware_entry ) - -/** These must be found first for any progress to be made */ -NSTUB( 0xFF810894, cstart ) //d -NSTUB( 0xFFC09A64, bzero32 ) // called by cstart() //d -NSTUB( 0xff811dbc, init_task ) // passed as arg to create_init_task, look for dmSetup //d -NSTUB( 0xFF817264, create_init_task ) //d - - -NSTUB( 0xff983474, FIO_FindFirstEx ) //d -NSTUB( 0xff9835A0, FIO_FindNextEx ) //d -NSTUB( 0xff9836A0, FIO_CleanupAfterFindNext_maybe) // called with ret_FIO_FindFirstEx after finishing the dir scanning loop - -NSTUB( 0xFF822CB4, GUI_ChangeMode ) //d - -NSTUB( 0xff9add28, DispSensorStart ) //d -NSTUB( 0xffa5f738, RedrawDisplay ) //d - - -/** Look for the normal printf strings */ -NSTUB( 0xff863b10, DryosDebugMsg ) //d - -/** Task dispatch hook hasn't moved in several versions */ -NSTUB( 0x1934, task_dispatch_hook ) //d - -/** Find the additional version string in GUI_GetFirmVersion */ -NSTUB( 0xFF3C, additional_version ) //d -NSTUB( 0xff9abff4, GUI_GetFirmVersion ) //d - -// Everything below here is not needed for the first boot - -/** Camera interface? */ -NSTUB( 0xC0220000, camera_engine ) //d - -NSTUB( 0xff86488c, call ) //d - -/** Find the shell register commands */ -NSTUB( 0xff98f96c, register_func ) //d - -/** Debugging commands are all registered by name. Search for the strings */ -NSTUB( 0xff863a90, dmstart ) //d -NSTUB( 0xff863ad0, dmstop ) //d -NSTUB( 0xff8643a4, dumpf ) //d - -/** Look in DebugMsg, near the bottom. It calls vsnprintf() - * with a buffer size of 0x4C. - */ -NSTUB( 0xff98e1e4, vsnprintf ) //d - -NSTUB( 0xff866e08, msleep ) // called from EV_GETDONE_CACHE param 0x64 //d -NSTUB( 0xff866ebc, task_create ) //d -NSTUB( 0xff982434, FIO_Open) //d -NSTUB( 0xff9824e8, FIO_CreateFile ) //d -NSTUB( 0xff982590, FIO_CloseFile ) //d -NSTUB( 0xff982b84, FIO_GetFileSize ) //d -NSTUB( 0xff9829d0, FIO_WriteFile ) //d -NSTUB( 0xff982820, FIO_ReadFile ) //d -NSTUB( 0xff982704, FIO_RemoveFile ) //d -NSTUB( 0xff982df4, FIO_CreateDirectory) -NSTUB( 0xFF9829A0, FIO_SeekFile) // mk11174 and Chucho 0xff9829b0 - -NSTUB( 0xff866a1c, give_semaphore ) //d -NSTUB( 0xff866934, take_semaphore ) //d -NSTUB( 0xff863e5c, dm_set_store_level ) // called by "dmstore" //d -NSTUB( 0xff85978c, prop_register_slave ) // called by"GUI_RegisterPropertySlave" //d -NSTUB( 0xff8598c4, _prop_request_change ) //d -NSTUB( 0xff859704, prop_deliver ) //d -NSTUB( 0xff8599e0, prop_get_value ) //d - -NSTUB( 0xff85ed2c, dispcheck ) //d -NSTUB( 0xff85f114, SetBitmapVramAddress ) // where to find bmp_vram_info //d -NSTUB( 0x24284 , bmp_vram_info ) //d -NSTUB( 0x36318 , vram_info ) // located in vram_get_number //d -NSTUB( 0xffa1d5c8, vram_get_number ) //d -NSTUB( 0xff983b98, vram_get_pos_and_size ) - -NSTUB( 0xff818cf4, _malloc ) // maybe it's better to use Allocate/Free? -NSTUB( 0xff818dc8, _free ) -NSTUB( 0xff867b54, _AllocateMemory ) // thanks Alex -NSTUB( 0xff867d18, _FreeMemory ) // release_mem in Indy's IDC - -NSTUB( 0x2c48, dm_names ) // in DebugMsg, before the 1st loop target -NSTUB( 0xff86334c, LoadCalendarFromRTC ) -NSTUB( 0xff86f990, task_trampoline ) - -NSTUB( 0xff859860, _prop_cleanup ) - -//NSTUB( 0xff85413c, _audio_ic_write ) -//NSTUB( 0xff854a88, _audio_ic_read ) -//NSTUB( 0xff855778, sounddev_task ) -//NSTUB( 0xff855b68, sounddev_active_in ) -//NSTUB( 0x2348 , sounddev ) // in sounddev_task //d - -NSTUB( 0xff8667d4, create_named_semaphore ) -NSTUB( 0xffa45f94, gui_task_create ) -NSTUB( 0xffa460b4, gui_task_destroy ) -NSTUB( 0xffa45e44, ctrlman_dispatch_event ) - -NSTUB( 0xff88b7c4, prop_request_icu_auto_poweroff ) -NSTUB( 0xff991018, _alloc_dma_memory ) -NSTUB( 0xff99104c, _free_dma_memory ) - -NSTUB( 0xFFB62584, cfReadBlk ) -NSTUB( 0x1D6FC, cf_device ) // in cfReadBlk -NSTUB( 0xFFB6E920, sdReadBlk ) -NSTUB( 0x1d744, sd_device ) // in sdReadBlk - -NSTUB( 0xffb0a9b4, fsuDecodePartitionTable ) - -NSTUB( 0xff81d9d8, hotplug_task ) -NSTUB( 0x1AF0 , hotplug_struct ) //d -NSTUB( 0x1B28 , hotplug_usb_buf ) // after "USB Disconnect" //d - -NSTUB( 0xff863778, bootdisk_enable ) -NSTUB( 0xff863784, bootdisk_disable ) - -NSTUB( 0xFF812E44, cli_save ) //d -NSTUB( 0xFF812E58, sei_restore ) //d -NSTUB( 0xff9ed888, ptp_register_handler ) //d -NSTUB( 0xff90e764, gui_lock ) // PtpPropSetUILock //d -NSTUB( 0xff8652cc, oneshot_timer ) //d -NSTUB( 0xffa460b4, gui_task_destroy ) //d -NSTUB( 0xff8225f0, gui_main_task ) //identical to 5d2 and 500d //d -NSTUB( 0xff822fa0, gui_init_end ) // EndGuiInit //d -NSTUB( 0x3960 , gui_timer_struct ) // in GUI_Control_Post //d -NSTUB( 0x1C50 , gui_main_struct ) // in gui_main_task //d -NSTUB( 0xff866534, msg_queue_receive ) //d -NSTUB( 0x1C18 , main_ctrl_struct ) //d -NSTUB( 0x1FAF0 , main_ctrl_struct_2 ) //d -NSTUB( 0xff866720, msg_queue_post ) //d -NSTUB( 0xff8898cc, gui_local_post ) //d -NSTUB( 0xff889358, gui_change_mode ) // GUI_ChangeMode_Post //d -NSTUB( 0xff889ca8, gui_other_post ) //d -NSTUB( 0xff88800c, gui_massive_event_loop ) // GUI_Control_Post //d -NSTUB( 0xff822ab4, GUI_Control ) - -NSTUB( 0xff968874, mvrFixQScale ) //d -NSTUB( 0xff968690, mvrSetDefQScale ) //d -NSTUB( 0xff84d88c, mvrSetBitRate ) //ds -NSTUB( 0xff968894, mvrSetPrintMovieLog ) //d -NSTUB( 0xff9686c8, mvrSetFullHDOptSize ) //d -//NSTUB( 0xFF17BF24, mvrSetHDOptSize ) -NSTUB( 0xff968804, mvrSetVGAOptSize ) //d -//NSTUB( 0xFF17BF94, mvrSetGopOptSizeFULLHD ) -//NSTUB( 0xFF17BFDC, mvrSetGopOptSizeHD ) -//NSTUB( 0xFF17C024, mvrSetGopOptSizeVGA ) -NSTUB( 0xff96863c, mvrSetDeblockingFilter ) //d - -NSTUB( 0xff820e80, main_ctrl_task ) //d -NSTUB( 0xff834b04, LVCAF_LensDriveStart ) //d -NSTUB( 0x7674 , mvr_config ) //d -NSTUB( 0xff9ada5c, GuiEdLedOn ) //d -NSTUB( 0xff9ada80, GuiEdLedOff ) //d -NSTUB( 0xff9adaa4, GuiEdLedBlink ) - -NSTUB( 0xff889dcc, gui_post_10000085 ) // should be called post 100000a5 no ? <-- not sure what this means.. //d -NSTUB( 0xff88a484, gui_init_event ) //d -NSTUB( 0xff889e80, gui_change_shoot_type_post ) //d -NSTUB( 0xff889f18, gui_change_lcd_state_post ) //d -NSTUB( 0xff98a990, gui_timer_something ) //d - -//NSTUB( 0xffa855f4, ChangeHDMIOutputSizeToVGA) //d -//NSTUB( 0xffa86684, ChangeHDMIOutputSizeToFULLHD) //d - -NSTUB(0xff86af18, CreateRecursiveLock) -NSTUB(0xff98ad28, AcquireRecursiveLock) -NSTUB(0xff98ae3c, ReleaseRecursiveLock) - -NSTUB(0xffa47a80, dialog_redraw) // called by CreateDialogBox -NSTUB(0x12A58, gui_task_list) // look in gui_task_create - -NSTUB(0xffa854d0, BeginMovieRecSequence) -NSTUB( 0xFFA850e0, EndMovieRecSequence ) - -NSTUB(0xff9a4674, GUI_SetLvMode) -NSTUB(0xff9a474c, GUI_SetMovieSize_a) -NSTUB(0xFF9A4848, GUI_SetMovieSize_b) -NSTUB(0xFF9A4630, GUI_SetLvTimer) - -NSTUB(0xff85dddc, MuteOff_0) // not quite the same as in other cameras, but should work -NSTUB(0xff85dd98, MuteOn_0) // idem - -NSTUB(0xFF90EC2c, RemoteRelease) -NSTUB(0xFF90ED58, ptpPropButtonSW1) -NSTUB(0xff90ede8, ptpPropButtonSW2) - -NSTUB(0xFF8680C8, GetMemoryInformation) - -NSTUB(0xffa4717c, CreateDialogBox) -NSTUB(0xffa46c14, DeleteDialogBox) -NSTUB(0xFFA47A80, dialog_redraw) -NSTUB(0xFFAAB654, dialog_set_property_str) - -NSTUB(0xFFBE75DC, StartFactoryMenuApp) - -NSTUB(0xFFB38BB8, GetCFnData) -NSTUB(0xFFB38CC0, SetCFnData) - -NSTUB(0xffa86e8c, LiveViewApp_handler) -NSTUB(0xffaa7c9c, ShootOlcApp_handler) -NSTUB(0xdeadbeef, ErrCardForLVApp_handler) -NSTUB(0xFFA796BC, ErrForCamera_handler) // ERR70, ERR80 etc (DlgErrForCamera.c, AJ_DIALOG.HANDLER_DlgErrForCamera.c) -NSTUB(0xffa9c890, PlayMain_handler) -NSTUB(0xdeadbeef, PlayMovieGuideApp_handler) - -NSTUB(0xFF97D904, _engio_write) -NSTUB(0xff97d7f8, shamem_read) // AJ_0x8FB0_engio_struct_n_R0_manipulation_to_get_ptr -NSTUB(0xff97d794, _EngDrvOut) - -NSTUB(0xff8166b4, get_current_task) - -NSTUB(0x242C0, LCD_Palette) // in InitializeBitmapDisplayDevice, right after 0xc0f14800 - -NSTUB(0xFF86AD34, msg_queue_create) // CreateMessageQueue -NSTUB(0xFF866760, msg_queue_count) // Above "!!!!!!! QUE Overflo" - -NSTUB(0xFF86B278, dma_memcpy) //Str HPC - -//Display Filter -NSTUB(0xFF85E90C , EnableImagePhysicalScreenParameter) - -// for task information -NSTUB(0x30f8, task_max) -NSTUB(0xFF8180BC, is_taskid_valid) // AJ_task_trampoline_related_p10 -NSTUB(0xFF817F04, get_obj_attr) // AJ_checks_if_Process_id_created_by_Dryos - -NSTUB(0xFF8875E4, SetGUIRequestMode) - -NSTUB(0xff8542c4, PowerAudioOutput) -NSTUB(0xff852494, StartASIFDMADAC) -NSTUB(0xFF852A80, StopASIFDMADAC) -NSTUB(0xff855290, SetSamplingRate ) -//NSTUB(0xFF8527B0, SetSamplingRate ) -NSTUB(0xff85460c, SetAudioVolumeOut) -NSTUB(0xff853250, TH_asif_initialize) -NSTUB(0xff854fc8, TH_audio_ic_initialize) - -/** ExMem **/ -NSTUB(0xff86be28, AllocateMemoryResource) // m_pfAllocMemoryCBR -NSTUB(0xff86be6c, AllocateContinuousMemoryResource) // m_pfContAllocMemoryCBR -NSTUB(0xff86bf7c, FreeMemoryResource) // m_pfFreeMemoryCBR -NSTUB(0xff869524, GetFirstChunkFromSuite) // AJ_PackMemory_PackMem_p3 -NSTUB(0xff869c9c, GetNextMemoryChunk) // AJ_PackMemory_PackMem.c_IsChunkSignature_p2 -NSTUB(0xff868f44, GetMemoryAddressOfMemoryChunk) // AJ_PackMemory_PackMem.c_IsChunkSignature - -/** EDMAC routines **/ -NSTUB(0xFF97C8D4, SetEDmac) -NSTUB(0xFF97C938, StartEDmac) -NSTUB(0xFF97CA98, PopEDmac) -//NSTUB([idk], AbortEDmac) -NSTUB(0xFF97C8F0, ConnectWriteEDmac) -NSTUB(0xFF97C918, ConnectReadEDmac) - -/** keep the old name until all are refcatored **/ -NSTUB(0xFF97CA84, EDMAC_RegisterCompleteCBR) - -/** register/unregister CBR names **/ -NSTUB(0xFF97CA84, RegisterEDmacCompleteCBR) -NSTUB(0xFF97CAAC, RegisterEDmacAbortCBR) -NSTUB(0xFF97CB14, RegisterEDmacPopCBR) -NSTUB(0xFF97CA98, UnregisterEDmacCompleteCBR) -NSTUB(0xFF97CAE4, UnregisterEDmacAbortCBR) -NSTUB(0xFF97CB28, UnregisterEDmacPopCBR) -/* ResLock */ -NSTUB(0xFFA6C918, CreateResLockEntry) -NSTUB(0xFFA6CD5C, LockEngineResources) -NSTUB(0xFFA6CE4C, UnLockEngineResources) +/** \file + * Entry points into the firmware image. + * + * These are the functions that we can call from our tasks + * in the Canon 1.0.9 firmware for the 50d. + * + * + * Copyright (C) 2010 Magic Lantern Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +.text + +NSTUB( ROMBASEADDR, firmware_entry ) + +/** These must be found first for any progress to be made */ +NSTUB( 0xFF810894, cstart ) //d +NSTUB( 0xFFC09A64, bzero32 ) // called by cstart() //d +NSTUB( 0xff811dbc, init_task ) // passed as arg to create_init_task, look for dmSetup //d +NSTUB( 0xFF817264, create_init_task ) //d + + +NSTUB( 0xff983474, FIO_FindFirstEx ) //d +NSTUB( 0xff9835A0, FIO_FindNextEx ) //d +NSTUB( 0xff9836A0, FIO_CleanupAfterFindNext_maybe) // called with ret_FIO_FindFirstEx after finishing the dir scanning loop + +NSTUB( 0xFF822CB4, GUI_ChangeMode ) //d + +NSTUB( 0xff9add28, DispSensorStart ) //d +NSTUB( 0xffa5f738, RedrawDisplay ) //d + + +/** Look for the normal printf strings */ +NSTUB( 0xff863b10, DryosDebugMsg ) //d + +/** Task dispatch hook hasn't moved in several versions */ +NSTUB( 0x1934, task_dispatch_hook ) //d + +/** Find the additional version string in GUI_GetFirmVersion */ +NSTUB( 0xFF3C, additional_version ) //d +NSTUB( 0xff9abff4, GUI_GetFirmVersion ) //d + +// Everything below here is not needed for the first boot + +/** Camera interface? */ +NSTUB( 0xC0220000, camera_engine ) //d + +NSTUB( 0xff86488c, call ) //d + +/** Find the shell register commands */ +NSTUB( 0xff98f96c, register_func ) //d + +/** Debugging commands are all registered by name. Search for the strings */ +NSTUB( 0xff863a90, dmstart ) //d +NSTUB( 0xff863ad0, dmstop ) //d +NSTUB( 0xff8643a4, dumpf ) //d + +/** Look in DebugMsg, near the bottom. It calls vsnprintf() + * with a buffer size of 0x4C. + */ +NSTUB( 0xff98e1e4, vsnprintf ) //d + +NSTUB( 0xff866e08, msleep ) // called from EV_GETDONE_CACHE param 0x64 //d +NSTUB( 0xff866ebc, task_create ) //d +NSTUB( 0xff982434, FIO_Open) //d +NSTUB( 0xff9824e8, FIO_CreateFile ) //d +NSTUB( 0xff982590, FIO_CloseFile ) //d +NSTUB( 0xff982b84, FIO_GetFileSize ) //d +NSTUB( 0xff9829d0, FIO_WriteFile ) //d +NSTUB( 0xff982820, FIO_ReadFile ) //d +NSTUB( 0xff982704, FIO_RemoveFile ) //d +NSTUB( 0xff982df4, FIO_CreateDirectory) +NSTUB( 0xFF9829A0, FIO_SeekFile) // mk11174 and Chucho 0xff9829b0 + +NSTUB( 0xff866a1c, give_semaphore ) //d +NSTUB( 0xff866934, take_semaphore ) //d +NSTUB( 0xff863e5c, dm_set_store_level ) // called by "dmstore" //d +NSTUB( 0xff85978c, prop_register_slave ) // called by"GUI_RegisterPropertySlave" //d +NSTUB( 0xff8598c4, _prop_request_change ) //d +NSTUB( 0xff859704, prop_deliver ) //d +NSTUB( 0xff8599e0, prop_get_value ) //d + +NSTUB( 0xff85ed2c, dispcheck ) //d +NSTUB( 0xff85f114, SetBitmapVramAddress ) // where to find bmp_vram_info //d +NSTUB( 0x24284 , bmp_vram_info ) //d +NSTUB( 0x36318 , vram_info ) // located in vram_get_number //d +NSTUB( 0xffa1d5c8, vram_get_number ) //d +NSTUB( 0xff983b98, vram_get_pos_and_size ) + +NSTUB( 0xff818cf4, _malloc ) // maybe it's better to use Allocate/Free? +NSTUB( 0xff818dc8, _free ) +NSTUB( 0xff867b54, _AllocateMemory ) // thanks Alex +NSTUB( 0xff867d18, _FreeMemory ) // release_mem in Indy's IDC + +NSTUB( 0x2c48, dm_names ) // in DebugMsg, before the 1st loop target +NSTUB( 0xff86334c, LoadCalendarFromRTC ) +NSTUB( 0xff86f990, task_trampoline ) + +NSTUB( 0xff859860, _prop_cleanup ) + +//NSTUB( 0xff85413c, _audio_ic_write ) +//NSTUB( 0xff854a88, _audio_ic_read ) +//NSTUB( 0xff855778, sounddev_task ) +//NSTUB( 0xff855b68, sounddev_active_in ) +//NSTUB( 0x2348 , sounddev ) // in sounddev_task //d + +NSTUB( 0xff8667d4, create_named_semaphore ) +NSTUB( 0xffa45f94, gui_task_create ) +NSTUB( 0xffa460b4, gui_task_destroy ) +NSTUB( 0xffa45e44, ctrlman_dispatch_event ) + +NSTUB( 0xff88b7c4, prop_request_icu_auto_poweroff ) +NSTUB( 0xff991018, _alloc_dma_memory ) +NSTUB( 0xff99104c, _free_dma_memory ) + +NSTUB( 0xFFB62584, cfReadBlk ) +NSTUB( 0x1D6FC, cf_device ) // in cfReadBlk +NSTUB( 0xFFB6E920, sdReadBlk ) +NSTUB( 0x1d744, sd_device ) // in sdReadBlk + +NSTUB( 0xffb0a9b4, fsuDecodePartitionTable ) + +NSTUB( 0xff81d9d8, hotplug_task ) +NSTUB( 0x1AF0 , hotplug_struct ) //d +NSTUB( 0x1B28 , hotplug_usb_buf ) // after "USB Disconnect" //d + +NSTUB( 0xff863778, bootdisk_enable ) +NSTUB( 0xff863784, bootdisk_disable ) + +NSTUB( 0xFF812E44, cli_save ) //d +NSTUB( 0xFF812E58, sei_restore ) //d +NSTUB( 0xff9ed888, ptp_register_handler ) //d +NSTUB( 0xff90e764, gui_lock ) // PtpPropSetUILock //d +NSTUB( 0xff8652cc, oneshot_timer ) //d +NSTUB( 0xffa460b4, gui_task_destroy ) //d +NSTUB( 0xff8225f0, gui_main_task ) //identical to 5d2 and 500d //d +NSTUB( 0xff822fa0, gui_init_end ) // EndGuiInit //d +NSTUB( 0x3960 , gui_timer_struct ) // in GUI_Control_Post //d +NSTUB( 0x1C50 , gui_main_struct ) // in gui_main_task //d +NSTUB( 0xff866534, msg_queue_receive ) //d +NSTUB( 0x1C18 , main_ctrl_struct ) //d +NSTUB( 0x1FAF0 , main_ctrl_struct_2 ) //d +NSTUB( 0xff866720, msg_queue_post ) //d +NSTUB( 0xff8898cc, gui_local_post ) //d +NSTUB( 0xff889358, gui_change_mode ) // GUI_ChangeMode_Post //d +NSTUB( 0xff889ca8, gui_other_post ) //d +NSTUB( 0xff88800c, gui_massive_event_loop ) // GUI_Control_Post //d +NSTUB( 0xff822ab4, GUI_Control ) + +NSTUB( 0xff968874, mvrFixQScale ) //d +NSTUB( 0xff968690, mvrSetDefQScale ) //d +NSTUB( 0xff84d88c, mvrSetBitRate ) //ds +NSTUB( 0xff968894, mvrSetPrintMovieLog ) //d +NSTUB( 0xff9686c8, mvrSetFullHDOptSize ) //d +//NSTUB( 0xFF17BF24, mvrSetHDOptSize ) +NSTUB( 0xff968804, mvrSetVGAOptSize ) //d +//NSTUB( 0xFF17BF94, mvrSetGopOptSizeFULLHD ) +//NSTUB( 0xFF17BFDC, mvrSetGopOptSizeHD ) +//NSTUB( 0xFF17C024, mvrSetGopOptSizeVGA ) +NSTUB( 0xff96863c, mvrSetDeblockingFilter ) //d + +NSTUB( 0xff820e80, main_ctrl_task ) //d +NSTUB( 0xff834b04, LVCAF_LensDriveStart ) //d +NSTUB( 0x7674 , mvr_config ) //d +NSTUB( 0xff9ada5c, GuiEdLedOn ) //d +NSTUB( 0xff9ada80, GuiEdLedOff ) //d +NSTUB( 0xff9adaa4, GuiEdLedBlink ) + +NSTUB( 0xff889dcc, gui_post_10000085 ) // should be called post 100000a5 no ? <-- not sure what this means.. //d +NSTUB( 0xff88a484, gui_init_event ) //d +NSTUB( 0xff889e80, gui_change_shoot_type_post ) //d +NSTUB( 0xff889f18, gui_change_lcd_state_post ) //d +NSTUB( 0xff98a990, gui_timer_something ) //d + +//NSTUB( 0xffa855f4, ChangeHDMIOutputSizeToVGA) //d +//NSTUB( 0xffa86684, ChangeHDMIOutputSizeToFULLHD) //d + +NSTUB(0xff86af18, CreateRecursiveLock) +NSTUB(0xff98ad28, AcquireRecursiveLock) +NSTUB(0xff98ae3c, ReleaseRecursiveLock) + +NSTUB(0xffa47a80, dialog_redraw) // called by CreateDialogBox +NSTUB(0x12A58, gui_task_list) // look in gui_task_create + +NSTUB(0xffa854d0, BeginMovieRecSequence) +NSTUB( 0xFFA850e0, EndMovieRecSequence ) + +NSTUB(0xff9a4674, GUI_SetLvMode) +NSTUB(0xff9a474c, GUI_SetMovieSize_a) +NSTUB(0xFF9A4848, GUI_SetMovieSize_b) +NSTUB(0xFF9A4630, GUI_SetLvTimer) + +NSTUB(0xff85dddc, MuteOff_0) // not quite the same as in other cameras, but should work +NSTUB(0xff85dd98, MuteOn_0) // idem + +NSTUB(0xFF90EC2c, RemoteRelease) +NSTUB(0xFF90ED58, ptpPropButtonSW1) +NSTUB(0xff90ede8, ptpPropButtonSW2) + +NSTUB(0xFF8680C8, GetMemoryInformation) + +NSTUB(0xffa4717c, CreateDialogBox) +NSTUB(0xffa46c14, DeleteDialogBox) +NSTUB(0xFFA47A80, dialog_redraw) +NSTUB(0xFFAAB654, dialog_set_property_str) + +NSTUB(0xFFBE75DC, StartFactoryMenuApp) + +NSTUB(0xFFB38BB8, GetCFnData) +NSTUB(0xFFB38CC0, SetCFnData) + +NSTUB(0xffa86e8c, LiveViewApp_handler) +NSTUB(0xffaa7c9c, ShootOlcApp_handler) +NSTUB(0xdeadbeef, ErrCardForLVApp_handler) +NSTUB(0xFFA796BC, ErrForCamera_handler) // ERR70, ERR80 etc (DlgErrForCamera.c, AJ_DIALOG.HANDLER_DlgErrForCamera.c) +NSTUB(0xffa9c890, PlayMain_handler) +NSTUB(0xdeadbeef, PlayMovieGuideApp_handler) + +NSTUB(0xFF97D904, _engio_write) +NSTUB(0xff97d7f8, shamem_read) // AJ_0x8FB0_engio_struct_n_R0_manipulation_to_get_ptr +NSTUB(0xff97d794, _EngDrvOut) + +NSTUB(0xff8166b4, get_current_task) + +NSTUB(0x242C0, LCD_Palette) // in InitializeBitmapDisplayDevice, right after 0xc0f14800 + +NSTUB(0xFF86AD34, msg_queue_create) // CreateMessageQueue +NSTUB(0xFF866760, msg_queue_count) // Above "!!!!!!! QUE Overflo" + +NSTUB(0xFF86B278, dma_memcpy) //Str HPC + +//Display Filter +NSTUB(0xFF85E90C , EnableImagePhysicalScreenParameter) + +// for task information +NSTUB(0x30f8, task_max) +NSTUB(0xFF8180BC, is_taskid_valid) // AJ_task_trampoline_related_p10 +NSTUB(0xFF817F04, get_obj_attr) // AJ_checks_if_Process_id_created_by_Dryos + +NSTUB(0xFF8875E4, SetGUIRequestMode) + +NSTUB(0xff8542c4, PowerAudioOutput) +NSTUB(0xff852494, StartASIFDMADAC) +NSTUB(0xFF852A80, StopASIFDMADAC) +NSTUB(0xff855290, SetSamplingRate ) +//NSTUB(0xFF8527B0, SetSamplingRate ) +NSTUB(0xff85460c, SetAudioVolumeOut) +NSTUB(0xff853250, TH_asif_initialize) +NSTUB(0xff854fc8, TH_audio_ic_initialize) + +/** ExMem **/ +NSTUB(0xff86be28, AllocateMemoryResource) // m_pfAllocMemoryCBR +NSTUB(0xff86be6c, AllocateContinuousMemoryResource) // m_pfContAllocMemoryCBR +NSTUB(0xff86bf7c, FreeMemoryResource) // m_pfFreeMemoryCBR +NSTUB(0xff869524, GetFirstChunkFromSuite) // AJ_PackMemory_PackMem_p3 +NSTUB(0xff869c9c, GetNextMemoryChunk) // AJ_PackMemory_PackMem.c_IsChunkSignature_p2 +NSTUB(0xff868f44, GetMemoryAddressOfMemoryChunk) // AJ_PackMemory_PackMem.c_IsChunkSignature + +/** EDMAC routines **/ +NSTUB(0xFF97C8D4, SetEDmac) +NSTUB(0xFF97C938, StartEDmac) +NSTUB(0xFF97CA98, PopEDmac) +//NSTUB([idk], AbortEDmac) +NSTUB(0xFF97C8F0, ConnectWriteEDmac) +NSTUB(0xFF97C918, ConnectReadEDmac) + +/** keep the old name until all are refcatored **/ +NSTUB(0xFF97CA84, EDMAC_RegisterCompleteCBR) + +/** register/unregister CBR names **/ +NSTUB(0xFF97CA84, RegisterEDmacCompleteCBR) +NSTUB(0xFF97CAAC, RegisterEDmacAbortCBR) +NSTUB(0xFF97CB14, RegisterEDmacPopCBR) +NSTUB(0xFF97CA98, UnregisterEDmacCompleteCBR) +NSTUB(0xFF97CAE4, UnregisterEDmacAbortCBR) +NSTUB(0xFF97CB28, UnregisterEDmacPopCBR) + +/* ResLock */ +NSTUB(0xFFA6C918, CreateResLockEntry) +NSTUB(0xFFA6CD5C, LockEngineResources) +NSTUB(0xFFA6CE4C, UnLockEngineResources) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/550D.109/features.h --- a/platform/550D.109/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/550D.109/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -8,4 +8,6 @@ #define FEATURE_INTERMEDIATE_ISO_PHOTO_DISPLAY #undef FEATURE_WIND_FILTER // crashes -#define FEATURE_RAW_HISTOGRAM +#define FEATURE_REC_ON_RESUME +#define FEATURE_MOVIE_AUTOSTOP_RECORDING + diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/5D2.212/features.h --- a/platform/5D2.212/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/5D2.212/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -5,5 +5,9 @@ #undef FEATURE_FLASH_TWEAKS // no built-in flash #undef FEATURE_FLASH_NOFLASH +#define FEATURE_MOVIE_AUTOSTOP_RECORDING +#define FEATURE_REC_ON_RESUME #define FEATURE_LV_FOCUS_BOX_SNAP_TO_X5_RAW + +#define FEATURE_NOHELP diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/5D3.113/features.h --- a/platform/5D3.113/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/5D3.113/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -17,6 +17,8 @@ #define FEATURE_ZOOM_TRICK_5D3 // Not reliable //~ #define FEATURE_REMEMBER_LAST_ZOOM_POS_5D3 // Too many conflicts with other features #undef FEATURE_IMAGE_POSITION +#define FEATURE_NOHELP +#undef CONFIG_STRESS_TEST //~ #define FEATURE_VIDEO_HACKS diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/600D.102/Makefile.platform.default --- a/platform/600D.102/Makefile.platform.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/600D.102/Makefile.platform.default Sun Sep 22 11:41:50 2013 -0500 @@ -16,7 +16,10 @@ # DryOSmemory map # RESTARTSTART is selected to be just above the end of the bss # -RESTARTSTART = 0x00082000 +#RESTARTSTART = 0x00082000 +#RESTARTSTART = 0x00C80100 +RESTARTSTART = 0x00C60100 + endif #End of FW_VERSION == 102 diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/600D.102/Makefile.setup.default --- a/platform/600D.102/Makefile.setup.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/600D.102/Makefile.setup.default Sun Sep 22 11:41:50 2013 -0500 @@ -11,5 +11,6 @@ ML_SRC_EXTRA_OBJS = \ raw.o \ chdk-dng.o \ - edmac-memcpy.o - + edmac-memcpy.o \ + dm-spy.o \ + video_hacksU.o \ diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/600D.102/cfn.c --- a/platform/600D.102/cfn.c Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/600D.102/cfn.c Sun Sep 22 11:41:50 2013 -0500 @@ -21,3 +21,60 @@ value = COERCE(value, 0, 3); prop_request_change(PROP_ALO, &value, 4); } +/* +// 5D2 only; other cameras have different offsets, buffer size etc +#define PROP_AFMA_CFN 0x80010006 +static int8_t afma_buf[0x5]; +#define AFMA_MODE afma_buf[0] +#define AFMA_PER_LENS afma_buf[1] +#define AFMA_ALL_LENSES afma_buf[2] + +#ifdef CONFIG_AFMA_EXTENDED +#define AFMA_MAX 100 +#else +#define AFMA_MAX 20 +#endif + +int get_afma_max() { return AFMA_MAX; } +int get_afma_mode() { return AFMA_MODE; } + +PROP_HANDLER(PROP_AFMA_CFN) +{ + ASSERT(len == sizeof(afma_buf)); + my_memcpy(afma_buf, buf, sizeof(afma_buf)); +} + +int get_afma(int mode) +{ + 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) +{ + 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)); +} +*/ diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/600D.102/consts.h --- a/platform/600D.102/consts.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/600D.102/consts.h Sun Sep 22 11:41:50 2013 -0500 @@ -13,10 +13,16 @@ #define HIJACK_CACHE_HACK -#define HIJACK_CACHE_HACK_BSS_END_ADDR 0xFF0123E4 -#define HIJACK_CACHE_HACK_BSS_END_INSTR 0xE3A01732 +//#define HIJACK_CACHE_HACK_BSS_END_ADDR 0xFF0123E4 +//#define HIJACK_CACHE_HACK_BSS_END_INSTR 0xE3A01732 #define HIJACK_CACHE_HACK_INITTASK_ADDR 0xFF0110DC +#define HIJACK_CACHE_HACK_BSS_END_ADDR 0xFF0123E4 +#define HIJACK_CACHE_HACK_BSS_END_INSTR 0xE3A018C6 +#define ML_RESERVED_MEM 640*1024 + +#define CACHE_HACK_FLUSH_RATE_SLAVE 0xFF04DE74 + #define HIJACK_TASK_ADDR 0x1a2c @@ -109,7 +115,9 @@ #define LV_BOTTOM_BAR_STATE (*(uint8_t*)0x7DF7) // in JudgeBottomInfoDispTimerState, if bottom bar state is 2, Judge returns 0; ML will make it 0 to hide bottom bar #define ISO_ADJUSTMENT_ACTIVE ((*(int*)0x5B28) == 0xF) #define SHOOTING_MODE (*(int*)0x3364) -#define UNAVI_FEEDBACK_TIMER_ACTIVE (MEM(0xC848) != 0x17) // dec CancelUnaviFeedBackTimer +#define QMENU_FEEDBACK_TIMER_ACTIVE (MEM(0xC848) != 0x17) // Qmenu lingers if not erased + +#define UNAVI_FEEDBACK_TIMER_ACTIVE (MEM(0xC860) == 2) #define COLOR_FG_NONLV 80 @@ -134,8 +142,6 @@ #define DLG_PICQ 6 #define DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED (CURRENT_DIALOG_MAYBE == 0x1e) #define DLG_MOVIE_PRESS_LV_TO_RESUME (CURRENT_DIALOG_MAYBE == 0x1f) -//~ #define DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED 0 // not good -//~ #define DLG_MOVIE_PRESS_LV_TO_RESUME 0 #define PLAY_MODE (gui_state == GUISTATE_PLAYMENU && CURRENT_DIALOG_MAYBE == DLG_PLAY) #define MENU_MODE (gui_state == GUISTATE_PLAYMENU && CURRENT_DIALOG_MAYBE == DLG_MENU) @@ -273,6 +279,13 @@ #define FRAME_SHUTTER (*(uint8_t*)(VIDEO_PARAMETERS_SRC_3+0xa)) #define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) + +#define FRAME_SHUTTER_BLANKING_ZOOM (*(uint16_t*)0x40694CD4) // ADTG register 805f +#define FRAME_SHUTTER_BLANKING_NOZOOM (*(uint16_t*)0x40694CD8) // ADTG register 8061 +#define FRAME_SHUTTER_BLANKING_READ (lv_dispsize > 1 ? FRAME_SHUTTER_BLANKING_NOZOOM : FRAME_SHUTTER_BLANKING_ZOOM) /* when reading, use the other mode, as it contains the original value (not overriden) */ +#define FRAME_SHUTTER_BLANKING_WRITE (lv_dispsize > 1 ? &FRAME_SHUTTER_BLANKING_ZOOM : &FRAME_SHUTTER_BLANKING_NOZOOM) + + // see "Malloc Information" #define MALLOC_STRUCT 0x172c8 #define MALLOC_FREE_MEMORY (MEM(MALLOC_STRUCT + 8) - MEM(MALLOC_STRUCT + 0x1C)) // "Total Size" - "Allocated Size" diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/600D.102/features.h --- a/platform/600D.102/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/600D.102/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -1,9 +1,32 @@ #include "all_features.h" +#undef CONFIG_STRESS_TEST // Not Needed +#undef CONFIG_AUTOBACKUP_ROM //WTF, Batman? +#undef FEATURE_AUTO_BURST_PICQ // not working on 600D + + #define FEATURE_DIGITAL_ZOOM_SHORTCUT #define FEATURE_LV_3RD_PARTY_FLASH #define FEATURE_EYEFI_TRICKS -#undef FEATURE_AUTO_BURST_PICQ // not working on 600D #define FEATURE_INTERMEDIATE_ISO_PHOTO_DISPLAY +#define FEATURE_NOHELP + +#define FEATURE_FOCUS_PEAK_DISP_FILTER +#define FEATURE_NITRATE_WAV_RECORD +#define FEATURE_MOVIE_AUTOSTOP_RECORDING // will be moved to scripts +#define FEATURE_INTERVALOMETER_MOVIE // will be moved to scripts +#define FEATURE_REMAP + +#define FEATURE_PICQ_DANGEROUS + +#define FEATURE_PROP_DISPLAY +#define CONFIG_DIGIC_POKE +#define CONFIG_HEXDUMP +#define FEATURE_DEBUG_INTERCEPT + +#define FEATURE_VIDEO_HACKS +#define FEATURE_LV_FOCUS_BOX_SNAP_TO_X5_RAW + +#undef CONFIG_MEMPATCH_CHECK diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/600D.102/internals.h --- a/platform/600D.102/internals.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/600D.102/internals.h Sun Sep 22 11:41:50 2013 -0500 @@ -111,7 +111,7 @@ #define CONFIG_EVF_STATE_SYNC /** This camera loads ML into the AllocateMemory pool **/ -//#define CONFIG_ALLOCATE_MEMORY_POOL +//~ #define CONFIG_ALLOCATE_MEMORY_POOL /** We have access to raw data in both photo mode and in LiveView */ #define CONFIG_RAW_PHOTO @@ -120,3 +120,8 @@ /** for 600D */ #define CONFIG_EDMAC_MEMCPY +/** We know how to use engine resource locks */ +#define CONFIG_ENGINE_RESLOCK + +/** FIO_RenameFile works **/ +#define CONFIG_FIO_RENAMEFILE_WORKS diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/600D.102/stubs.S --- a/platform/600D.102/stubs.S Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/600D.102/stubs.S Sun Sep 22 11:41:50 2013 -0500 @@ -311,6 +311,11 @@ NSTUB(0xFF1E0AB8, UnregisterEDmacAbortCBR) NSTUB(0xFF1E0B94, UnregisterEDmacPopCBR) +/* ResLock */ +NSTUB(0xFF1E4910, CreateResLockEntry) +NSTUB(0xFF1E4E50, LockEngineResources) +NSTUB(0xFF1E4F8C, UnLockEngineResources) + /** Unused **/ //NSTUB(0xFF073580, GetRemainOfMemoryChunk) //NSTUB(0xFF0735B0, GetSizeOfMemoryChunk) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-BootFixup1 Binary file platform/6D.112/autoexec.bin-BootFixup1 has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-DisplayFilterFix Binary file platform/6D.112/autoexec.bin-DisplayFilterFix has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-Fix-Remote-Shot-Photo Binary file platform/6D.112/autoexec.bin-Fix-Remote-Shot-Photo has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-Flush_tester Binary file platform/6D.112/autoexec.bin-Flush_tester has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-Gops Binary file platform/6D.112/autoexec.bin-Gops has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-Increased_timeouts_latestCommits Binary file platform/6D.112/autoexec.bin-Increased_timeouts_latestCommits has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-LimitlessAsif Binary file platform/6D.112/autoexec.bin-LimitlessAsif has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-RockwellZoom Binary file platform/6D.112/autoexec.bin-RockwellZoom has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin-SyncShutter Binary file platform/6D.112/autoexec.bin-SyncShutter has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/autoexec.bin.ALLOCATE_POOL Binary file platform/6D.112/autoexec.bin.ALLOCATE_POOL has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.112/qemu-helper Binary file platform/6D.112/qemu-helper has changed diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/Makefile.platform.default --- a/platform/6D.113/Makefile.platform.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/Makefile.platform.default Sun Sep 22 11:41:50 2013 -0500 @@ -1,7 +1,7 @@ #Makefile.setup.platform for 6D ifeq ($(FW_VERSION),113) -CANON_NAME_FIR=6D000113.FIR +CANON_NAME_FIR = 6D000113.FIR ROMBASEADDR = 0xFF0C0000 ifeq ($(ML_SRC_PROFILE),generic) @@ -14,4 +14,4 @@ endif #End of FW_VERSION == 113 -endif \ No newline at end of file +endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/Makefile.setup.default --- a/platform/6D.113/Makefile.setup.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/Makefile.setup.default Sun Sep 22 11:41:50 2013 -0500 @@ -2,6 +2,7 @@ ML_BITRATE_OBJ = bitrate-6d.o ML_AF_PATTERNS_OBJ = n +ML_AUDIO_OBJ = audio-ng.o ML_SRC_EXTRA_OBJS = \ misc.o \ @@ -13,4 +14,3 @@ reloc.o \ edmac-memcpy.o \ asm.o - diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/consts.h --- a/platform/6D.113/consts.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/consts.h Sun Sep 22 11:41:50 2013 -0500 @@ -1,5 +1,7 @@ /* - * Consts for 6D 113 firmware + * Almost none of this is correct yet, only a skeleton to be filled in later. + * + * Indented line = incorrect. */ #define CARD_DRIVE "B:/" @@ -11,6 +13,8 @@ #define FORMAT_BTN "[Q]" #define STR_LOC 12 + + #define HIJACK_CACHE_HACK #define HIJACK_ASIF_NEXT_BUFF 0xFF2AC4C8 @@ -22,7 +26,6 @@ //~ #define HIJACK_ASIF_CONT_JUMP_ADDR 0xFF2AC5E0 //~ #define HIJACK_ASIF_CONT_JUMP_INSTR 0xEA000009 #define HIJACK_ASIF_CONT_JUMP_ADDR 0xFF2AC5DC -#define HIJACK_ASIF_CONT_JUMP_INSTR 0xE1500000 //~ max volume supported for beeps @@ -136,6 +139,7 @@ #define AE_STATE (*(int8_t*)(0x7F554 + 0x1C)) #define AE_VALUE (*(int8_t*)(0x7F554 + 0x1D)) + //Metering for LV in Manual Mode //FF6C98FC: ebf28def bl sub_FF36D0C0 ⬁ //FF6C9900: e5c50007 strb r0, [r5, #7] @@ -279,12 +283,20 @@ #define FRAME_ISO (*(uint8_t*)(VIDEO_PARAMETERS_SRC_3+0)) #define FRAME_APERTURE (*(uint8_t*)(VIDEO_PARAMETERS_SRC_3+1)) #define FRAME_SHUTTER (*(uint8_t*)(VIDEO_PARAMETERS_SRC_3+2)) -#define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) +//~ #define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) +#define FRAME_BV (*(uint16_t*)(VIDEO_PARAMETERS_SRC_3+4)) #define FRAME_SHUTTER_TIMER (*(uint16_t*)(VIDEO_PARAMETERS_SRC_3+6)) -//real frame BV -//#define FRAME_BV (*(uint16_t*)(VIDEO_PARAMETERS_SRC_3+4)) -//calculated frame bv (faster?) + + +#define FRAME_SHUTTER_BLANKING_ZOOM (*(uint16_t*)0x404514CC) // ADTG register 805f +#define FRAME_SHUTTER_BLANKING_NOZOOM (*(uint16_t*)0x404514D0) // ADTG register 8061 + +#define FRAME_SHUTTER_BLANKING_READ (lv_dispsize > 1 ? FRAME_SHUTTER_BLANKING_NOZOOM : FRAME_SHUTTER_BLANKING_ZOOM) /* when reading, use the other mode, as it contains the original value (not overriden) */ +#define FRAME_SHUTTER_BLANKING_WRITE (lv_dispsize > 1 ? &FRAME_SHUTTER_BLANKING_ZOOM : &FRAME_SHUTTER_BLANKING_NOZOOM) + + + // see "Malloc Information" #define FRAME_SHUTTER_BLANKING_ZOOM (*(uint16_t*)0x404514CC) // ADTG register 805f @@ -299,6 +311,6 @@ //~ #define UNAVI_FEEDBACK_TIMER_ACTIVE (MEM(0x84100) != 0x17) // 1 All the Time //~ #define UNAVI_FEEDBACK_TIMER_ACTIVE (MEM(0x8418c) == 0x2) // Between the "17s" find with mem browser //~ #define UNAVI (MEM(0x8418c)) // Between the "17s" find with mem browser -#define UNAVI (MEM(0x8418c) ==2) // Between the "17s" find with mem browser -#define SCROLLHACK (MEM(0x841C0) !=0) +#define UNAVI (MEM(0x8418c) == 2) // Between the "17s" find with mem browser +#define SCROLLHACK (MEM(0x841C0) != 0) #define UNAVI_FEEDBACK_TIMER_ACTIVE (UNAVI || SCROLLHACK) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/features.h --- a/platform/6D.113/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -8,27 +8,41 @@ #undef FEATURE_IMAGE_REVIEW_PLAY // not needed, one can press Zoom right away #undef CONFIG_STRESS_TEST // We don't need this so much. #undef CONFIG_MEMPATCH_CHECK // Reports 0 for total. - +#undef FEATURE_SHOW_CPU_USAGE // Not working +#undef FEATURE_FORCE_HDMI_VGA // Causes flip back/forth from HD/SD +#undef FEATURE_FPS_WAV_RECORD // We have 2 other wav recording options, just use those +#undef CONFIG_AUTOBACKUP_ROM //WTF, Batman? +#undef FEATURE_WIND_FILTER //Needs better investigation and more options /*Work Relatively well*/ #define CONFIG_FPS_AGGRESSIVE_UPDATE +#define FEATURE_MOVIE_AUTOSTOP_RECORDING +#define FEATURE_REC_ON_RESUME #define FEATURE_FOCUS_PEAK_DISP_FILTER #define FEATURE_ZOOM_TRICK_5D3 // Doubleclick to zoom/shortcut #define FEATURE_KEN_ROCKWELL_ZOOM_5D3 // Play From Image Review Mode - Did not bring up play #define CONFIG_AFMA_EXTENDED +#define FEATURE_NOHELP //No one can help you now +#define FEATURE_PREFIX + /* Development */ +#define FEATURE_TIMER_HACK +#define FEATURE_LV_FOCUS_BOX_SNAP_TO_X5_RAW +//~ #define CONFIG_GUI_DEBUG /* Debugging Stuff */ +#define FEATURE_PROP_DISPLAY #define CONFIG_HEXDUMP #define CONFIG_DIGIC_POKE +#define CONFIG_DEBUG_INTERCEPT //~ #define FEATURE_SHOW_SIGNATURE //~ #define CONFIG_DUMPROM Lawyers will kill your camera.. and you. - +//~ #define CONFIG_ISR_HOOKS /* Audio Features */ -#define FEATURE_HEADPHONE_MONITORING #define FEATURE_NITRATE_WAV_RECORD -#define FEATURE_WAV_RECORDING -#define FEATURE_AUDIO_METERS +#define CONFIG_DUMP_AUDIO -//~ #define FEATURE_HEADPHONE_OUTPUT_VOLUME + + + diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/gui.h --- a/platform/6D.113/gui.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/gui.h Sun Sep 22 11:41:50 2013 -0500 @@ -54,11 +54,13 @@ #define GMT_OLC_INFO_CHANGED 0x69 // backtrace copyOlcDataToStorage call in gui_massive_event_loop + // needed for correct shutdown from powersave modes #define GMT_GUICMD_START_AS_CHECK 97 #define GMT_GUICMD_OPEN_SLOT_COVER 93 #define GMT_GUICMD_LOCK_OFF 91 + #define BTN_ZEBRAS_FOR_PLAYBACK BGMT_LIGHT // what button to use for zebras in Play mode #define BTN_ZEBRAS_FOR_PLAYBACK_NAME "LIGHT" diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/internals.h --- a/platform/6D.113/internals.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/internals.h Sun Sep 22 11:41:50 2013 -0500 @@ -79,7 +79,7 @@ #define CONFIG_FRAME_ISO_OVERRIDE /** But we can't override the digital ISO component via FRAME_ISO **/ -#define CONFIG_FRAME_ISO_OVERRIDE_ANALOG_ONLY +//~ #define CONFIG_FRAME_ISO_OVERRIDE_ANALOG_ONLY /** We can also override shutter on a per-frame basis */ #define CONFIG_FRAME_SHUTTER_OVERRIDE @@ -135,3 +135,6 @@ /** We know how to use engine resource locks */ #define CONFIG_ENGINE_RESLOCK + +/** We can control audio settings from ML **/ +#define CONFIG_AUDIO_CONTROLS diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/misc.c --- a/platform/6D.113/misc.c Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/misc.c Sun Sep 22 11:41:50 2013 -0500 @@ -9,7 +9,6 @@ int new_LiveViewApp_handler = 0xff123456; -// dummy stubs /* called from misc_shooting_info() in shoot.c */ void display_clock() diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/6D.113/stubs.S --- a/platform/6D.113/stubs.S Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/6D.113/stubs.S Sun Sep 22 11:41:50 2013 -0500 @@ -71,12 +71,14 @@ NSTUB(0xFF18DFE8, SetGUIRequestMode) NSTUB(0x752e0, sounddev ) // Maybe 0x752e0 or 0x753f4 NSTUB(0xFF11E24C, sounddev_task ) -NSTUB(0xFF143118, _audio_ic_write) -NSTUB(0xFF1424F4, _audio_ic_read) +NSTUB(0xFF1422B0, _audio_ic_write) //SerialCommanSend(int *array) +NSTUB(0xFF1424F4, _audio_ic_read) // Correct NSTUB(0xFF142820, TestSetAudioHeadPhone) NSTUB(0xFF1422B0, SerialCommand_Send) NSTUB(0xFF11EA28, SetAudioVolumeOut) //str:SetVolumeOut_Volume 1 Parameter NSTUB(0xFF9D031C, audio_thresholds) +NSTUB(0xFF143C40 , SelectMic) + NSTUB(0xFFCFD630 - RAM_OFFSET, _alloc_dma_memory) @@ -171,12 +173,6 @@ NSTUB(0xFFD0EFA0 - RAM_OFFSET, is_taskid_valid) // AJ_task_trampoline_related_p10 NSTUB(0xFFCD4DD8 - RAM_OFFSET, get_obj_attr) // AJ_checks_if_Process_id_created_by_Dryos -NSTUB(0xFF2ABD58, asifAIntDmaDac) -NSTUB(0xFF2AC318, asifAStopDmaDac) -NSTUB(0xFF2AC3CC, asifAStopDmaAdc) -NSTUB(0xFF2AC67C, asifAFuncIgnore_Give_FuncSync) -NSTUB(0xFF2AC6BC, asifAIgnore_ASIF) - NSTUB(0xFF142D68, PowerAudioOutput) //sub_FF142D54 Same Actions NSTUB(0xFF11C9A4, StartASIFDMADAC) //~ warning: looks different @@ -193,8 +189,10 @@ NSTUB(0xFF142DE4, SetSamplingRate) //AudioIC.c_SetRate_hHPTimer Identical NSTUB(0xFF142B70, SetAudioVolumeOut) //Keep Volume (%d->%d) NSTUB(0xFF11E9F4, SetAudioVolumeIn) // SetVolumeIn(alc, L, R) -NSTUB(0xFF11E654, SoundDevActiveIn) -NSTUB(0xFF11E680, SoundDevActiveOut) +NSTUB(0xFF11E654, sounddev_active_in) +//NSTUB(0xFF11E654, SoundDevActiveIn) +NSTUB(0xFF11E680, sounddev_active_out) +//NSTUB(0xFF11E680, SoundDevActiveOut) NSTUB(0xFF11E8AC, SoundDevShutDownIn) NSTUB(0xFF11E6E0, SoundDevStartIn) @@ -215,6 +213,7 @@ /* Electronic level - roll/pitch info */ NSTUB(0xFF270968, GUI_SetRollingPitchingLevelStatus); // RequestRollingPitching - no side effects :) + NSTUB(0xFF2AD104, mvrSetPrintMovieLog) NSTUB( 0x7AE8C, mvr_config) @@ -261,8 +260,9 @@ NSTUB(0xFFCF8BE4 - RAM_OFFSET, MREQ_ISR) NSTUB(0xFFCF8C68 - RAM_OFFSET, SIO3_ISR) NSTUB(0xFFCCC4C8 - RAM_OFFSET, register_interrupt) + + /* ISR */ - NSTUB(0x74AD0, pre_isr_hook) NSTUB(0x74AD4, post_isr_hook) @@ -272,6 +272,8 @@ NSTUB(0xFF2B2564, LockEngineResources) NSTUB(0xFF2B2708, UnLockEngineResources) + + /** Unused **/ //NSTUB(0xFFCCEC88 - RAM_OFFSET, GetSizeOfMemoryChunk) //NSTUB(0xFFCCEC58 - RAM_OFFSET, GetRemainOfMemoryChunk) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D.203/Makefile.setup.default --- a/platform/7D.203/Makefile.setup.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D.203/Makefile.setup.default Sun Sep 22 11:41:50 2013 -0500 @@ -15,5 +15,6 @@ raw.o \ edmac-memcpy.o \ chdk-dng.o \ - afma.o + afma.o \ +# dm-spy.o \ diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D.203/consts.h --- a/platform/7D.203/consts.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D.203/consts.h Sun Sep 22 11:41:50 2013 -0500 @@ -18,7 +18,9 @@ #define AVAIL_SHOT_WORKAROUND #define HIJACK_CACHE_HACK +//~ #define CONFIG_7D_FIR_MASTER #if defined(CONFIG_7D_FIR_MASTER) +//~ #if defined(CONFIG_7D_MASTER) #define HIJACK_CACHE_HACK_BSS_END_ADDR 0xFF811508 #define HIJACK_CACHE_HACK_BSS_END_INSTR 0xE3A01732 #define HIJACK_CACHE_HACK_INITTASK_ADDR 0xFF811064 @@ -131,19 +133,20 @@ #define DLG_FLASH_AE 0x22 #define DLG_PICQ 6 -#define _MOVIE_MODE_NON_LIVEVIEW 0 -#define DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED 0 -#define DLG_MOVIE_PRESS_LV_TO_RESUME 0 +#define DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED (CURRENT_DIALOG_MAYBE == 0x1B) //Sure +#define DLG_MOVIE_PRESS_LV_TO_RESUME (CURRENT_DIALOG_MAYBE == 0x1C) //? Not sure #define PLAY_MODE (gui_state == GUISTATE_PLAYMENU && CURRENT_DIALOG_MAYBE == DLG_PLAY) #define MENU_MODE (gui_state == GUISTATE_PLAYMENU && CURRENT_DIALOG_MAYBE == DLG_MENU) +//Neds work, on master #define AUDIO_MONITORING_HEADPHONES_CONNECTED 0 - //~ #define HOTPLUG_VIDEO_OUT_PROP_DELIVER_ADDR 0x1aac // this prop_deliver performs the action for Video Connect and Video Disconnect - //~ #define HOTPLUG_VIDEO_OUT_STATUS_ADDR 0x1ad4 // passed as 2nd arg to prop_deliver; 1 = display connected, 0 = not, other values disable this event (trick) - +//~ #define AUDIO_MONITORING_HEADPHONES_CONNECTED (!((*(int*)0xc02200F8) & 1)) +//~ #define HOTPLUG_VIDEO_OUT_PROP_DELIVER_ADDR 0x1A2C // this prop_deliver performs the action for Video Connect and Video Disconnect +//~ #define HOTPLUG_VIDEO_OUT_STATUS_ADDR 0x1A54 // passed as 2nd arg to prop_deliver; 1 = display connected, 0 = not, other values disable this event (trick) +//0x1a58 is mic. // In bindGUIEventFromGUICBR, look for "LV Set" => arg0 = 6 // Next, in SetGUIRequestMode, look at what code calls NotifyGUIEvent(6, something) #define GUIMODE_ML_MENU (recording ? 0 : lv ? 45 : 2) @@ -263,11 +266,15 @@ #define DISPLAY_IS_ON MEM(0x21B0) // TurnOnDisplay (PUB) Type=%ld fDisplayTurnOn=%ld #define SOUNDDEV_STARTED MEM(0x1F60) +//On master 1C08 #define LV_STRUCT_PTR 0x1D34 -#define FRAME_ISO *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x74) // smooth ISO is +0x60 -#define FRAME_APERTURE *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x73) -#define FRAME_SHUTTER *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x72) -#define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) +#define FRAME_ISO *(uint16_t*)(MEM(LV_STRUCT_PTR) + 0x60) // smooth ISO is +0x60 +#define FRAME_APERTURE *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x5F) +#define FRAME_SHUTTER *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x5E) +//~ #define FRAME_SHUTTER_TIMER *(uint16_t*)(MEM(LV_STRUCT_PTR) + 0x64) +#define FRAME_BV *(uint8_t*)(MEM(LV_STRUCT_PTR) + 0x62) //Looks like BV + +//~ #define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) // see "Malloc Information" #define MALLOC_STRUCT 0x249e4 diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D.203/features.h --- a/platform/7D.203/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D.203/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -1,16 +1,34 @@ #include "all_features.h" -#undef FEATURE_ARROW_SHORTCUTS // idk why :P +#define FEATURE_TIMER_HACK +#define FEATURE_PREFIX +#define FEATURE_VIDEO_HACKS +//~ #define FEATURE_AFMA_TUNING //Module +#define FEATURE_FOCUS_PEAK_DISP_FILTER //oh yea! +#define FEATURE_NOHELP +#define FEATURE_NITRATE_WAV_RECORD + + + +//~ #undef FEATURE_ARROW_SHORTCUTS // idk why :P #undef FEATURE_IMAGE_POSITION -#undef FEATURE_FPS_OVERRIDE #undef FEATURE_FPS_WAV_RECORD -#undef FEATURE_FPS_RAMPING +//~ #undef FEATURE_FPS_RAMPING #undef FEATURE_EXPO_ISO_DIGIC // not working, no idea why -> test on master? #undef FEATURE_SHUTTER_LOCK // Canon has it #undef FEATURE_IMAGE_EFFECTS // they work in preview only and cause trouble -#undef FEATURE_FPS_OVERRIDE +#undef FEATURE_AF_PATTERNS //Like 6D, won't work +#undef CONFIG_AUTOBACKUP_ROM //Its wrong anyways +#undef CONFIG_STRESS_TEST +//~ #undef FEATURE_GRADUAL_EXPOSURE +//~ #undef FEATURE_HDR_VIDEO +//~ #undef FEATURE_FORCE_LIVEVIEW -#define FEATURE_VIDEO_HACKS +#define FEATURE_PROP_DISPLAY +#define CONFIG_HEXDUMP +//~ #define CONFIG_DEBUG_INTERCEPT //Locks it up... fuuuk -#undef FEATURE_AF_PATTERNS - +#define FEATURE_HEADPHONE_OUTPUT_VOLUME +#undef FEATURE_HEADPHONE_MONITORING +//~ #define CONFIG_DUMP_AUDIO +//~ #undef FEATURE_SHOW_FREE_MEMORY diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D.203/internals.h --- a/platform/7D.203/internals.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D.203/internals.h Sun Sep 22 11:41:50 2013 -0500 @@ -66,10 +66,10 @@ /** We can't redirect the display buffer **/ //~ #define CONFIG_CAN_REDIRECT_DISPLAY_BUFFER_EASILY -//~ #define CONFIG_CAN_REDIRECT_DISPLAY_BUFFER +#define CONFIG_CAN_REDIRECT_DISPLAY_BUFFER /** Therefore, we can't implement display filters (features that alter the LiveView image in real-time) **/ -//~ #define CONFIG_DISPLAY_FILTERS +#define CONFIG_DISPLAY_FILTERS /** Not sure whether we can override ISO on a per-frame basis, by changing FRAME_ISO (e.g. for HDR video or gradual exposure) **/ /** Will leave it off for now **/ @@ -113,3 +113,12 @@ /** We can use the DMA controller to copy data */ #define CONFIG_EDMAC_MEMCPY + +/** We know how to use engine resource locks */ +#define CONFIG_ENGINE_RESLOCK + +/** We can also override shutter on a per-frame basis */ +//~ #define CONFIG_FRAME_SHUTTER_OVERRIDE + +/** We can control audio settings from ML **/ +#define CONFIG_AUDIO_CONTROLS diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D.203/stubs.S --- a/platform/7D.203/stubs.S Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D.203/stubs.S Sun Sep 22 11:41:50 2013 -0500 @@ -128,6 +128,7 @@ NSTUB(0xff0a8738, SetGUIRequestMode) NSTUB(0xff072f7c, _audio_ic_read) NSTUB(0xff0730c8, _audio_ic_write) +NSTUB(0xFF57B014, audio_thresholds) NSTUB( 0x16fb8, additional_version) NSTUB(0xff20da50, _alloc_dma_memory) NSTUB( 0x29a60, bmp_vram_info ) @@ -190,7 +191,8 @@ //NSTUB( 0x208D8, sd_device) NSTUB(0xff0104d0, sei_restore) NSTUB( 0x1f54, sounddev) -NSTUB(0xff063d64, sounddev_task) +//NSTUB(0xff063d64, sounddev_task) +NSTUB(0xFF063C70, sounddev_task) NSTUB(0xFF0640EC, sounddev_active_in) NSTUB(0xff07b924, take_semaphore) NSTUB(0xff07beac, task_create) @@ -240,10 +242,19 @@ NSTUB(0xFF0621C4, SetNextASIFADCBuffer) // called by SetNextUINT8ASIFADCBuffer and SetNextINT16ASIFADCBuffer NSTUB(0xFF06227C, SetNextASIFDACBuffer) NSTUB(0xff0736f4, SetSamplingRate ) -NSTUB(0xFF073944, SetAudioVolumeOut) +//NSTUB(0xFF073944, SetAudioVolumeOut) +NSTUB(0xFF073380, SetAudioVolumeOut) +NSTUB(0xFF074410, PowerMicAmp) NSTUB(0xFF06EDD0, AsyncEnableImagePhysicalScreenParameter) NSTUB(0xff06e8b0, EnableImagePhysicalScreenParameter) NSTUB(0xFF41E17C, StartPlayProtectGuideApp) NSTUB(0xff41dde0, StopPlayProtectGuideApp) + +/* ResLock */ +NSTUB(0xFF1F9694, CreateResLockEntry) +NSTUB(0xFF1F9BDC, LockEngineResources) +NSTUB(0xFF1F9D18, UnLockEngineResources) + +//NSTUB(0xFF81AD28, master_write_memory) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D_MASTER.203/consts.h --- a/platform/7D_MASTER.203/consts.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D_MASTER.203/consts.h Sun Sep 22 11:41:50 2013 -0500 @@ -14,3 +14,7 @@ //~ max volume supported for beeps #define ASIF_MAX_VOL 5 + +//~ #define AUDIO_MONITORING_HEADPHONES_CONNECTED (!((*(int*)0xc02200F8) & 1)) +#define HOTPLUG_VIDEO_OUT_PROP_DELIVER_ADDR 0x1A2C // this prop_deliver performs the action for Video Connect and Video Disconnect +#define HOTPLUG_VIDEO_OUT_STATUS_ADDR 0x1A54 // passed as 2nd arg to prop_deliver; 1 = display connected, 0 = not, other values disable this event (trick) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D_MASTER.203/master_boot.c --- a/platform/7D_MASTER.203/master_boot.c Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D_MASTER.203/master_boot.c Sun Sep 22 11:41:50 2013 -0500 @@ -80,7 +80,7 @@ #if defined(CONFIG_AUTOBACKUP_ROM) #define BACKUP_BLOCKSIZE 0x00100000 - +/* void backup_region(char *file, uint32_t base, uint32_t length) { FILE *handle = NULL; @@ -88,13 +88,13 @@ uint32_t pos = 0; /* already backed up that region? */ - if((FIO_GetFileSize( file, &size ) == 0) && (size == length) ) +/* if((FIO_GetFileSize( file, &size ) == 0) && (size == length) ) { return; } /* no, create file and store data */ - handle = FIO_CreateFileEx(file); +/* handle = FIO_CreateFileEx(file); while(pos < length) { uint32_t blocksize = BACKUP_BLOCKSIZE; @@ -108,16 +108,17 @@ pos += blocksize; /* to make sure lower prio tasks can also run */ - msleep(20); - } - FIO_CloseFile(handle); -} + //~ msleep(20); + //~ } + //~ FIO_CloseFile(handle); +//~ } void backup_task() { msleep(1000); - backup_region(CARD_DRIVE "ML/LOGS/M_ROM1.BIN", 0xF8000000, 0x01000000); - backup_region(CARD_DRIVE "ML/LOGS/M_ROM0.BIN", 0xF0000000, 0x01000000); + //~ backup_region(CARD_DRIVE "ML/LOGS/M_ROM1.BIN", 0xF8000000, 0x01000000); + //~ backup_region(CARD_DRIVE "ML/LOGS/M_ROM0.BIN", 0xF0000000, 0x01000000); + //~ master_write_memory("ROM1.BIN", 0xf8000000, 0x00800000); } #endif @@ -280,7 +281,20 @@ } } } - +//~ static int setonce = 0; +void audio_headphone_run() +{ + + //~ if (AUDIO_MONITORING_HEADPHONES_CONNECTED) + //~ { + //~ static int *value; + //~ *value = 0; + *(int*)HOTPLUG_VIDEO_OUT_STATUS_ADDR = 2; + //~ prop_deliver(*(int*)(HOTPLUG_VIDEO_OUT_PROP_DELIVER_ADDR), &value, 4, 0x0); + //~ setonce=1; + //~ } + //~ if (!AUDIO_MONITORING_HEADPHONES_CONNECTED && setonce) setonce=0; +} /** Call all of the init functions */ static void call_init_funcs( void * priv ) @@ -311,7 +325,7 @@ call_init_funcs(0); - + // //pre_isr_hook = isrlog; //cache_fake(0xFF88BCB4, 0xE3A01002, TYPE_ICACHE); /* flush video buffer every frame */ diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/7D_MASTER.203/stubs.S --- a/platform/7D_MASTER.203/stubs.S Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/7D_MASTER.203/stubs.S Sun Sep 22 11:41:50 2013 -0500 @@ -37,7 +37,7 @@ NSTUB(0xFF9315E8, EngDrvOut) NSTUB(0xFF812B4C, init_task) NSTUB(0xFF83976C, msleep) -NSTUB(0xFF839820, task_create) +NSTUB(0xFF839820, task_create) //Master NSTUB(0xFF838EA0, RegisterRPCHandler) NSTUB(0xFF838F50, RequestRPC) @@ -49,4 +49,7 @@ NSTUB(0x400006F8, isr_table_handler) NSTUB(0x40000AF8, isr_table_param) +//NSTUB(0xFF81AD28, master_write_memory) + +NSTUB(0xff830670, prop_deliver) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.106/Makefile.platform.default --- a/platform/EOSM.106/Makefile.platform.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/EOSM.106/Makefile.platform.default Sun Sep 22 11:41:50 2013 -0500 @@ -7,7 +7,9 @@ # DryOSmemory map # RESTARTSTART is selected to be just above the end of the bss # -RESTARTSTART = 0x0009E300 +#RESTARTSTART = 0x0009E300 +#RESTARTSTART = 0x00CEC100 +RESTARTSTART = 0x00CCC100 AUTOEXEC_BASE = 0x40800000 FIR_BASE = 0x40800120 endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.106/Makefile.setup.default --- a/platform/EOSM.106/Makefile.setup.default Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/EOSM.106/Makefile.setup.default Sun Sep 22 11:41:50 2013 -0500 @@ -6,11 +6,12 @@ ML_SRC_EXTRA_OBJS = \ misc.o \ dm-spy.o \ - video_hacks.o \ + tp-spy.o \ + reloc.o \ raw.o \ chdk-dng.o \ - tp-spy.o \ - reloc.o \ + video_hacks.o \ edmac-memcpy.o + diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.106/cfn.c --- a/platform/EOSM.106/cfn.c Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/EOSM.106/cfn.c Sun Sep 22 11:41:50 2013 -0500 @@ -1,13 +1,21 @@ #include #include -int get_htp() { return 0; } -void set_htp(int value) {} +int get_htp() { return GetCFnData(0, 3); } +void set_htp(int value) { SetCFnData(0, 3, value); } -int get_alo() { return 0; } +int get_mlu() { return GetCFnData(0, 5); } +void set_mlu(int value) { SetCFnData(0, 5, value); } -int get_mlu() { return 0; } -void set_mlu(int value) {} +int cfn_get_af_button_assignment() { return GetCFnData(0, 6); } +void cfn_set_af_button(int value) { SetCFnData(0, 6, value); } -int cfn_get_af_button_assignment() { return 0; } -void cfn_set_af_button(int value) {} +// on some cameras, ALO is CFn +PROP_INT(PROP_ALO, alo); +int get_alo() { return alo; } + +void set_alo(int value) +{ + value = COERCE(value, 0, 3); + prop_request_change(PROP_ALO, &value, 4); +} diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.106/consts.h --- a/platform/EOSM.106/consts.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/EOSM.106/consts.h Sun Sep 22 11:41:50 2013 -0500 @@ -12,13 +12,17 @@ #define STR_LOC 4 #define HIJACK_CACHE_HACK + #define HIJACK_CACHE_HACK_INITTASK_ADDR 0xFF0C1CC8 +#define HIJACK_TASK_ADDR 0x3E2D8 + +/* #define HIJACK_INSTR_BL_CSTART 0xff0c0d80 #define HIJACK_INSTR_BSS_END 0xff0c1cbc #define HIJACK_FIXBR_BZERO32 0xff0c1c20 #define HIJACK_FIXBR_CREATE_ITASK 0xff0c1cac #define HIJACK_INSTR_MY_ITASK 0xFF0C1CC8 -#define HIJACK_TASK_ADDR 0x3E2D8 +*/ // Doesn't resize memory.. // load ML in the malloc pool //0xD16F8 - A0000 = 316F8 @@ -51,7 +55,7 @@ #define CACHE_HACK_FLUSH_RATE_SLAVE 0xFF0E2C60 //~ #define CACHE_HACK_GOP_SIZE_SLAVE 0xFF23AAC4 //~ #define CACHE_HACK_GOP_SIZE_SLAVE 0xFF23AF6C -#define CACHE_HACK_GOP_SIZE_SLAVE 0xFF2078A0 +//~ #define CACHE_HACK_GOP_SIZE_SLAVE 0xFF2078A0 // no idea if it's overflowing, need to check experimentally #define ARMLIB_OVERFLOWING_BUFFER 0x66114 // in AJ_armlib_setup_related3 @@ -144,8 +148,8 @@ // In bindGUIEventFromGUICBR, look for "LV Set" => arg0 = 8 // Next, in SetGUIRequestMode, look at what code calls NotifyGUIEvent(8, something) //~ #define GUIMODE_ML_MENU (recording ? 0 : lv ? 90 : 2) // any from 90...102 ?! - #define GUIMODE_ML_MENU (recording ? 99 : 90 ) // any from 90...102 ?! - //~ #define GUIMODE_ML_MENU 86 // any from 90...102 ?! + +#define GUIMODE_ML_MENU ( (recording && !raw_lv_is_enabled()) ? 99 : 90 ) // any from 90...102 ?! // for displaying TRAP FOCUS msg outside LV #define DISPLAY_TRAP_FOCUS_POS_X 50 @@ -218,6 +222,11 @@ #define FRAME_SHUTTER_TIMER (*(uint16_t*)(VIDEO_PARAMETERS_SRC_3+6)) #define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) +#define FRAME_SHUTTER_BLANKING_ZOOM (*(uint16_t*)0x40501B20) // ADTG register 805f +#define FRAME_SHUTTER_BLANKING_NOZOOM (*(uint16_t*)0x40501B24) // ADTG register 8061 +#define FRAME_SHUTTER_BLANKING_READ (lv_dispsize > 1 ? FRAME_SHUTTER_BLANKING_NOZOOM : FRAME_SHUTTER_BLANKING_ZOOM) /* when reading, use the other mode, as it contains the original value (not overriden) */ +#define FRAME_SHUTTER_BLANKING_WRITE (lv_dispsize > 1 ? &FRAME_SHUTTER_BLANKING_ZOOM : &FRAME_SHUTTER_BLANKING_NOZOOM) + // see "Malloc Information" #define MALLOC_STRUCT 0x66d08 diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.106/features.h --- a/platform/EOSM.106/features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/EOSM.106/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -1,33 +1,65 @@ #include "all_features.h" +/* Can't Be Implemented */ +#undef FEATURE_FORCE_LIVEVIEW // Already Live View +#undef FEATURE_MLU // No Mirror +#undef FEATURE_MLU_HANDHELD +#undef FEATURE_STICKY_DOF // No DOF button +#undef FEATURE_IMAGE_EFFECTS // DigicV new effects check "Art Filter" +#undef CONFIG_MEMPATCH_CHECK // Reports 0 for total, like 6D +#undef FEATURE_INTERMEDIATE_ISO_PHOTO_DISPLAY // Well.. it will work in 1 mode +#undef FEATURE_AF_PATTERNS // No regular AF +#undef FEATURE_VOICE_TAGS // Just to be sure +#undef FEATURE_PLAY_422 // No way to select -#undef FEATURE_INTERMEDIATE_ISO_PHOTO_DISPLAY -#undef FEATURE_GHOST_IMAGE -#undef FEATURE_OVERLAYS_IN_PLAYBACK_MODE -#undef FEATURE_FORCE_LIVEVIEW + +/* Some Hope Yet */ #undef FEATURE_AUDIO_REMOTE_SHOT -#undef FEATURE_MLU -#undef FEATURE_MLU_HANDHELD #undef FEATURE_TRAP_FOCUS #undef FEATURE_FOLLOW_FOCUS #undef FEATURE_RACK_FOCUS #undef FEATURE_FOCUS_STACKING -#undef FEATURE_AF_PATTERNS -#undef FEATURE_SET_MAINDIAL +#undef FEATURE_GHOST_IMAGE // No way to pick image but works. +#undef FEATURE_SET_MAINDIAL // Set taken over by Q #undef FEATURE_PLAY_EXPOSURE_FUSION #undef FEATURE_PLAY_COMPARE_IMAGES #undef FEATURE_PLAY_TIMELAPSE #undef FEATURE_PLAY_EXPOSURE_ADJUST -#undef FEATURE_PLAY_422 #undef FEATURE_QUICK_ZOOM #undef FEATURE_QUICK_ERASE -#undef FEATURE_VOICE_TAGS -#undef FEATURE_AUDIO_METERS #undef FEATURE_LV_FOCUS_BOX_FAST #undef FEATURE_LV_FOCUS_BOX_SNAP -#undef FEATURE_LV_FOCUS_BOX_AUTOHIDE #undef FEATURE_ARROW_SHORTCUTS -#undef FEATURE_STICKY_DOF -#undef FEATURE_IMAGE_EFFECTS // none working +#undef CONFIG_STRESS_TEST // We don't need this so much. +#undef CONFIG_AUTOBACKUP_ROM //WTF, Batman? #undef FEATURE_FLEXINFO +//~ #undef FEATURE_OVERLAYS_IN_PLAYBACK_MODE +//~ #undef FEATURE_AUDIO_METERS // Work While Recording +//~ #undef FEATURE_LV_FOCUS_BOX_AUTOHIDE // Works in FB mode + + + +#define FEATURE_FOCUS_PEAK_DISP_FILTER //Need early sync. + +/* Works */ +#define FEATURE_VIDEO_HACKS +#define FEATURE_PROP_DISPLAY +#define CONFIG_HEXDUMP +#define CONFIG_DIGIC_POKE +#define FEATURE_PREFIX //Named HDR Bracketing B01, B02, etc +#define FEATURE_NOHELP //No one can help you now + +#define FEATURE_TIMER_HACK +#define CONFIG_TSKMON + +//~ #undef SHOULD_CHECK_SIG +//~ #define FEATURE_ISR_HOOKS + +//~ #define FEATURE_SHOW_SIGNATURE +//~ #define CONSOLE_DEBUG +#define FEATURE_DEBUG_INTERCEPT +//~ #define FEATURE_PICQ_DANGEROUS // All 3 Props are len 4. Show up as len0? Mraw/Sraw causes crash. #define FEATURE_CROP_MODE_HACK + +//~ #undef FEATURE_SILENT_PIC // none working +#undef FEATURE_LV_FOCUS_BOX_SNAP_TO_X5_RAW diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.106/internals.h --- a/platform/EOSM.106/internals.h Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/EOSM.106/internals.h Sun Sep 22 11:41:50 2013 -0500 @@ -38,7 +38,7 @@ //~ #define CONFIG_MLU /** This camera reports focus info in LiveView **/ -#define CONFIG_LV_FOCUS_INFO +//~ #define CONFIG_LV_FOCUS_INFO /** Sensor gives some data Needs Help **/ //~ #define CONFIG_ELECTRONIC_LEVEL @@ -84,17 +84,17 @@ /** We can't change ExpSim from ML (at least not yet) **/ #define CONFIG_EXPSIM -/** We can;t playback sounds via ASIF DMA (yet) **/ -#define CONFIG_BEEP +/** Asif hangs camera.. will look for a fix **/ +//~ #define CONFIG_BEEP /** This camera has no trouble saving Kelvin and/or WBShift in movie mode **/ -//~ #define CONFIG_WB_WORKAROUND +#define CONFIG_WB_WORKAROUND /** We can restore ML files after formatting the card in the camera **/ #define CONFIG_RESTORE_AFTER_FORMAT -/** We know how to use DMA_MEMCPY but regular memcpy is faster anyway **/ -//~ #define CONFIG_DMA_MEMCPY +/** We don't know how to use DMA_MEMCPY (yet) **/ +#define CONFIG_DMA_MEMCPY /** We know how to use edmac_memcpy. This one is really fast (600MB/s!) */ #define CONFIG_EDMAC_MEMCPY diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.106/stubs.S --- a/platform/EOSM.106/stubs.S Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/EOSM.106/stubs.S Sun Sep 22 11:41:50 2013 -0500 @@ -36,124 +36,190 @@ #define RAM_OFFSET 0xFFA68D58 // some functions are copied to RAM at around ff0c009c; they have to be called from RAM... -NSTUB(0xFFA87C1C - RAM_OFFSET, AcquireRecursiveLock) // AJ_KernelDry_KerRLock.c -NSTUB(0xFFA70BB4 - RAM_OFFSET, _AllocateMemory) -NSTUB(0xFF4C35D8, CreateDialogBox) -NSTUB(0xFFA735B8 - RAM_OFFSET, CreateRecursiveLock) -NSTUB(0xFF4C25A0, DeleteDialogBox) -NSTUB(0xFFA6CDB0 - RAM_OFFSET, DryosDebugMsg) -NSTUB(0xFF347460, FIO_CleanupAfterFindNext_maybe) // proper name: FindClose +/** Startup **/ +NSTUB(0xFF0C1C10, cstart) +NSTUB(0xFFAA0090 - RAM_OFFSET, bzero32) +NSTUB(0xFFA6BC10 - RAM_OFFSET, create_init_task) +NSTUB(0xFF0C5488, init_task) + //NSTUB( 0x468b8, additional_version) + +/** Misc **/ +NSTUB(0xC0220000, camera_engine) +NSTUB(0xFF1320E8, LoadCalendarFromRTC) +NSTUB(0xFFA89258 - RAM_OFFSET, vsnprintf) + +/** File I/O **/ +NSTUB(0xFF3460C4, FIO_CreateFile) +NSTUB(0xFF346008, FIO_Open) NSTUB(0xFF346468, FIO_CloseFile) NSTUB(0xFF346398, FIO_SeekFile) //All take forever //NSTUB(0xFF3462C8, FIO_SeekFile) //SeekSkipFile - Seems to work too. +NSTUB(0xFF346218, FIO_ReadFile) +NSTUB(0xFF3463B8, FIO_WriteFile) +NSTUB(0xFF3465E4, FIO_GetFileSize) +NSTUB(0xFF346170, FIO_RemoveFile) NSTUB(0xFF346CC4, FIO_CreateDirectory) -NSTUB(0xFF3460C4, FIO_CreateFile) NSTUB(0xFF34728C, FIO_FindFirstEx) NSTUB(0xFF347380, FIO_FindNextEx) -NSTUB(0xFF3465E4, FIO_GetFileSize) -NSTUB(0xFF346008, FIO_Open) -NSTUB(0xFF346218, FIO_ReadFile) -NSTUB(0xFF346170, FIO_RemoveFile) -NSTUB(0xFF3463B8, FIO_WriteFile) +NSTUB(0xFF347460, FIO_CleanupAfterFindNext_maybe) // proper name: FindClose NSTUB(0xFF346AFC, FIO_RenameFile) -NSTUB(0xFFA70F50 - RAM_OFFSET, _FreeMemory) -NSTUB(0xFF0D783C, GUI_ChangeMode) -NSTUB(0xFF0D7680, GUI_Control) -NSTUB(0xFF1BD13C, GUI_GetFirmVersion) -NSTUB(0xFF1320E8, LoadCalendarFromRTC) -NSTUB(0xFF32D348, MuteOff_0) -NSTUB(0xFF32D300, MuteOn_0) -NSTUB(0xFF4E3D50, RedrawDisplay) -NSTUB(0xFFA87D30 - RAM_OFFSET, ReleaseRecursiveLock) // AJ_KernelDry_KerRLock.c_p2 -NSTUB(0xFF1299C4, SetBitmapVramAddress) -NSTUB(0xFF1A7BD0, SetGUIRequestMode) +/** Bitmap **/ +NSTUB( 0x6D6F4, bmp_vram_info ) // look in SetBitmapVramAddress - as in 60D +NSTUB(0x6BEF4, LCD_Palette) // in InitializeBitmapDisplayDevice, right after 0xc0f14800 -/*---------------*/ - NSTUB(0xFF345F6C, _audio_ic_read) // Good Candidate i2c read - NSTUB(0xff136ea4, _audio_ic_write) // str:Reg_0x_02X_Data_04x -/*--------------*/ - - -NSTUB(0xFFA8B200 - RAM_OFFSET, _alloc_dma_memory) -NSTUB( 0x6D6F4, bmp_vram_info ) // look in SetBitmapVramAddress - as in 60D -NSTUB(0xFFAA0090 - RAM_OFFSET, bzero32) -NSTUB(0xFF137AD4, call) -NSTUB(0xC0220000, camera_engine) -NSTUB(0xFF0C10E4, cli_save) -NSTUB(0xFFA6BC10 - RAM_OFFSET, create_init_task) -NSTUB(0xFFA6F634 - RAM_OFFSET, create_named_semaphore) -NSTUB(0xFF0C1C10, cstart) -NSTUB(0xFF4C135C, ctrlman_dispatch_event) -NSTUB(0xFF4C4314, dialog_redraw) -NSTUB(0xFF52F148, dialog_set_property_str) +/** Debug messages **/ NSTUB( 0x3F0DC, dm_names) +NSTUB(0xFFA6CDB0 - RAM_OFFSET, DryosDebugMsg) NSTUB(0xFFA6D11C - RAM_OFFSET, dm_set_store_level) NSTUB(0xFFA6D0B4 - RAM_OFFSET, dm_set_print_level) -NSTUB(0xFF0C83C0, _free) // see "can't malloc" -NSTUB(0xFFA8B234 - RAM_OFFSET, _free_dma_memory) -NSTUB(0xFF4F7D60, fsuDecodePartitionTable) // AJ_fsuGetPart_related + +/** Task sleep **/ +NSTUB(0xFFA6FC70 - RAM_OFFSET, msleep) + +/** Semaphores **/ +NSTUB(0xFFA6F634 - RAM_OFFSET, create_named_semaphore) +NSTUB(0xFFA6F794 - RAM_OFFSET, take_semaphore) NSTUB(0xFFA6F880 - RAM_OFFSET, give_semaphore) -NSTUB(0xFF0D7D24, gui_init_end) -NSTUB( 0x3E5B4, gui_main_struct) -NSTUB(0xFF0D72AC, gui_main_task) -NSTUB( 0x591F0, gui_task_list) -NSTUB(0xFF0C5488, init_task) -NSTUB(0xFF0C8368, _malloc) + + +/** Recursive locks **/ +NSTUB(0xFFA735B8 - RAM_OFFSET, CreateRecursiveLock) +NSTUB(0xFFA87C1C - RAM_OFFSET, AcquireRecursiveLock) // AJ_KernelDry_KerRLock.c +NSTUB(0xFFA87D30 - RAM_OFFSET, ReleaseRecursiveLock) // AJ_KernelDry_KerRLock.c_p2 + +/** Message queues **/ +NSTUB(0xFFA733D0 - RAM_OFFSET, msg_queue_create) NSTUB(0xFFA87AD0 - RAM_OFFSET, msg_queue_post) NSTUB(0xFFA878E4 - RAM_OFFSET, msg_queue_receive) -NSTUB(0xFFA6FC70 - RAM_OFFSET, msleep) -NSTUB(0xFF12015C, _prop_cleanup) -NSTUB(0xFF120090, prop_deliver) -NSTUB(0xFF11F8E0, prop_register_slave) -NSTUB(0xFF11FAD4, _prop_request_change) -NSTUB(0xFF45F61C, ptp_register_handler) -NSTUB(0xFF3420F4, register_func) -NSTUB(0xFF6421C0, sdReadBlk) -NSTUB( 0x60B2C, sd_device) -NSTUB(0xFF0C10F8, sei_restore) -NSTUB(0xFFA6F794 - RAM_OFFSET, take_semaphore) + + +/** Tasks **/ NSTUB(0xFFA6FD24 - RAM_OFFSET, task_create) NSTUB( 0x3E1C0, task_dispatch_hook ) NSTUB(0xFFA7503C - RAM_OFFSET, task_trampoline) -NSTUB(0xFFA89258 - RAM_OFFSET, vsnprintf) -NSTUB( 0x8D330, vram_info) -NSTUB(0xFF6FB53C, LiveViewShutterApp_handler) +/** Task info **/ +NSTUB(0x3F5AC, task_max) +NSTUB(0xFFA6B284 - RAM_OFFSET, get_current_task) +NSTUB(0xFFA96158 - RAM_OFFSET, is_taskid_valid) // AJ_task_trampoline_related_p10 +NSTUB(0xFFA77B48 - RAM_OFFSET, get_obj_attr) // AJ_checks_if_Process_id_created_by_Dryos + +/** Interrupts **/ +NSTUB(0xFF0C10E4, cli_save) +NSTUB(0xFF0C10F8, sei_restore) + +/** Eventprocs (call by name) **/ +NSTUB(0xFF137AD4, call) + +/** GUI **/ +NSTUB(0xFF0D7680, GUI_Control) +NSTUB(0xFF1A7BD0, SetGUIRequestMode) +NSTUB(0xFF0D72AC, gui_main_task) +NSTUB( 0x3E5B4, gui_main_struct) +NSTUB(0xFF0D7D24, gui_init_end) + //NSTUB(0xff1a4fc8, gui_massive_event_loop) +NSTUB( 0x591F0, gui_task_list) + + +/** Dialog API **/ +NSTUB(0xFF4C35D8, CreateDialogBox) +NSTUB(0xFF4C25A0, DeleteDialogBox) +NSTUB(0xFF4C4314, dialog_redraw) +NSTUB(0xFF52F148, dialog_set_property_str) +NSTUB(0xFF4E3D50, RedrawDisplay) + +/** Dialog handlers **/ + //NSTUB(0xff658aa8, LiveViewLevelApp_handler) + //NSTUB(0xFF623240, LiveViewWbApp_handler) NSTUB(0xFF539DC4, LiveViewApp_handler) - NSTUB(0xFF3BBAFC, PlayMain_handler) NSTUB(0xFF553994, PlayMovieGuideApp_handler) NSTUB(0xFF6A2650, ErrCardForLVApp_handler) NSTUB(0xFF520378, ErrForCamera_handler) // ERR70, ERR80 etc (DlgErrForCamera.c, AJ_DIALOG.HANDLER_DlgErrForCamera.c) NSTUB(0xFF53786C, HideUnaviFeedBack_maybe) // look for StartUnaviFeedBackTimer +NSTUB(0xFF541484, ShootOlcApp_handler) // AJ_DIALOG.HANDLER_DlgShootOlcInfo.c +NSTUB(0xFF6FB53C, LiveViewShutterApp_handler) + +/** Properties **/ +NSTUB(0xFF11F8E0, prop_register_slave) +NSTUB(0xFF12015C, _prop_cleanup) +NSTUB(0xFF120090, prop_deliver) +NSTUB(0xFF11FAD4, _prop_request_change) +NSTUB(0xFF1202B8, prop_get_value) + + +/** Memory allocation **/ +NSTUB(0xFF0C8368, malloc) +NSTUB(0xFF0C83C0, free) // see "can't malloc" +NSTUB(0xFFA70BB4 - RAM_OFFSET, AllocateMemory) +NSTUB(0xFFA70F50 - RAM_OFFSET, FreeMemory) +NSTUB(0xFFA8B200 - RAM_OFFSET, alloc_dma_memory) +NSTUB(0xFFA8B234 - RAM_OFFSET, free_dma_memory) +NSTUB(0xFFA70954 - RAM_OFFSET, GetMemoryInformation) + +/** ExMem **/ +NSTUB(0xFF13B678, AllocateMemoryResource) // m_pfAllocMemoryCBR +NSTUB(0xFF13B6C4, AllocateContinuousMemoryResource) // m_pfContAllocMemoryCBR +NSTUB(0xFF13B7DC, FreeMemoryResource) // m_pfFreeMemoryCBR + +NSTUB(0xFFA723E4 - RAM_OFFSET, GetFirstChunkFromSuite) // AJ_PackMemory_PackMem_p3 +NSTUB(0xFFA72B80 - RAM_OFFSET, GetNextMemoryChunk) +NSTUB(0xFFA71DBC - RAM_OFFSET, GetMemoryAddressOfMemoryChunk) + +/** Engio **/ NSTUB(0xFF2C1524, _engio_write) NSTUB(0xFF2C12A8, shamem_read) // AJ_0x8FB0_engio_struct_n_R0_manipulation_to_get_ptr NSTUB(0xFF2C120C, _EngDrvOut) // AJ_EngDrvOut_1xVar_to_ShadowStruct -NSTUB(0xFF541484, ShootOlcApp_handler) // AJ_DIALOG.HANDLER_DlgShootOlcInfo.c +/** Edmac **/ +NSTUB(0x92E0, CreateMemorySuite) //FFCCEF34 +NSTUB(0x90D8, DeleteMemorySuite) // FFCCED2C - //NSTUB(0xff987200 - RAM_OFFSET, set_fps_maybe) +NSTUB(0x1C530, SetEDmac) //FFA85288 +NSTUB(0x1C848, StartEDmac) //FFA855A0 +NSTUB(0x1C9DC, PopEDmac) //From popedmacformemorysuite +NSTUB(0x1C994, AbortEDmac) //FFCF7BBC +NSTUB(0x1C5DC, ConnectWriteEDmac) //FFA85334 +NSTUB(0x1C6A0, ConnectReadEDmac) //FFA853F8 -NSTUB(0xFFA6B284 - RAM_OFFSET, get_current_task) +/** keep the old name until all are refcatored **/ +NSTUB(0x1CA34, EDMAC_RegisterCompleteCBR) -NSTUB(0x6BEF4, LCD_Palette) // in InitializeBitmapDisplayDevice, right after 0xc0f14800 +/** register/unregister CBR names **/ +NSTUB(0x1CA34, RegisterEDmacCompleteCBR) //FFCF7C5C +NSTUB(0x1CB1C, RegisterEDmacAbortCBR) //FFCF7CF0 +NSTUB(0x1CBB0, RegisterEDmacPopCBR) //FFCF7D84 +NSTUB(0x1CA70, UnregisterEDmacCompleteCBR) +NSTUB(0x1CB58, UnregisterEDmacAbortCBR) //FFCF7D2C +NSTUB(0x1CBEC , UnregisterEDmacPopCBR) //FFCF7DC0 -NSTUB(0xFF1B4F70, Gui_SetSoundRecord) // Look for GUI_setsoundrec - Just changes prop +NSTUB(0xFF5FE6E8, PackMem_SetEDmacForMemorySuite) +NSTUB(0xFF5FEA70, PackMem_RegisterEDmacPopCBRForMemorySuite) +NSTUB(0xFF5FE9D4, PackMem_RegisterEDmacCompleteCBRForMemorySuite) +NSTUB(0xFF5FEB0C, PackMem_RegisterEDmacAbortCBRForMemorySuite) -NSTUB(0xFFA70954 - RAM_OFFSET, GetMemoryInformation) -NSTUB(0xFF143C18, copy_malloc_info_maybe) +NSTUB(0xFF5FE7FC, PackMem_StartEDmac) +NSTUB(0xFF5FE904, PackMem_PopEDmacForMemorySuite) -NSTUB(0xFFA733D0 - RAM_OFFSET, msg_queue_create) +/** PTP **/ +NSTUB(0xFF45F61C, ptp_register_handler) -NSTUB(0xFF101E04, PD_RemoteRelease) +/** Audio **/ + NSTUB(0xFF345F6C, _audio_ic_read) // Good Candidate i2c read + NSTUB(0xff136ea4, _audio_ic_write) // str:Reg_0x_02X_Data_04x - // for task information -NSTUB(0x3F5AC, task_max) -NSTUB(0xFFA96158 - RAM_OFFSET, is_taskid_valid) // AJ_task_trampoline_related_p10 -NSTUB(0xFFA77B48 - RAM_OFFSET, get_obj_attr) // AJ_checks_if_Process_id_created_by_Dryos +NSTUB(0xFF7FB3B8, audio_thresholds) +NSTUB( 0x3E8CC, sounddev ) +NSTUB(0xFF10CD10, sounddev_task ) +NSTUB(0xFF10D118, SoundDevActiveIn) +NSTUB(0xFF10D144, SoundDevActiveOut) +NSTUB(0xFF10D370, SoundDevShutDownIn) + + +/** ASIF **/ NSTUB(0xFF135034, PowerAudioOutput) //Look for actrlCpowerControl Case 1 Sub NSTUB(0xFF10AA18, StartASIFDMADAC) //~ Needs Patches Or //NSTUB(0xFF2BF578, StartASIFDMADAC) //~ Direct @@ -177,81 +243,29 @@ NSTUB(0xFF134458, SetSamplingRate ) NSTUB(0xFF133070, SetAudioVolumeOut) -NSTUB(0xFF7FB3B8, audio_thresholds) -NSTUB(0x3E8CC, sounddev ) -NSTUB(0xFF10CD10, sounddev_task ) -NSTUB(0xFF10D118, SoundDevActiveIn) -NSTUB(0xFF10D144, SoundDevActiveOut) -NSTUB(0xFF10D370, SoundDevShutDownIn) +/** Making the card bootable (How?) **/ + // NSTUB(0x0, cfReadBlk) + // NSTUB(0x0, cf_device) idk... +//NSTUB(0xFF6421C0, sdReadBlk) +NSTUB( 0x60B2C, sd_device) +NSTUB(0xFF4F7D60, fsuDecodePartitionTable) // AJ_fsuGetPart_related - -NSTUB(0xFF19991C, ENCODE_StartEncodeJpeg) - -NSTUB(0xFF13B678, AllocateMemoryResource) // m_pfAllocMemoryCBR -NSTUB(0xFF13B6C4, AllocateContinuousMemoryResource) // m_pfContAllocMemoryCBR -NSTUB(0xFF13B7DC, FreeMemoryResource) // m_pfFreeMemoryCBR -NSTUB(0xFFA723E4 - RAM_OFFSET, GetFirstChunkFromSuite) // AJ_PackMemory_PackMem_p3 -NSTUB(0xFFA71DBC - RAM_OFFSET, GetMemoryAddressOfMemoryChunk) - -NSTUB(0xFFA72B80 - RAM_OFFSET, GetNextMemoryChunk) - - -NSTUB(0xFFA7391C - RAM_OFFSET, dma_memcpy) - +/* Electronic level - roll/pitch info */ NSTUB(0xFF1B4454, GUI_SetRollingPitchingLevelStatus) - +/* H264 Encoder */ NSTUB(0xFF2C04E0, mvrSetPrintMovieLog) NSTUB(0xFF2BFEF0, mvrSetQscale) NSTUB( 0x4C584, mvr_config) NSTUB(0xFF2C04BC, mvrFixQScale) NSTUB(0xFF2BFFB4, mvrSetDefQScale) -NSTUB(0xFF1202B8, prop_get_value) -NSTUB(0xFF2A3378, ptpPropSetUILock) +/* Touchscreen */ NSTUB(0xFF334610, touch_cbr_canon) -NSTUB(0xFF5B6688, lvae_setdispgain) - -NSTUB(0xFF0E5808, MVR_NotifyLvFrameTiming) - - -// Edmac -// Ram Offset:FFCC34E4 -//M RAM_OFFSET 0xFFA68D58 -NSTUB(0x92E0, CreateMemorySuite) //FFCCEF34 -NSTUB(0x90D8, DeleteMemorySuite) // FFCCED2C - -NSTUB(0x1C530, SetEDmac) //FFA85288 -NSTUB(0x1C848, StartEDmac) //FFA855A0 -NSTUB(0x1C9DC, PopEDmac) //From popedmacformemorysuite -NSTUB(0x1C994, AbortEDmac) //FFCF7BBC -NSTUB(0x1C5DC, ConnectWriteEDmac) //FFA85334 -NSTUB(0x1C6A0, ConnectReadEDmac) //FFA853F8 - -/** keep the old name until all are refcatored **/ -NSTUB(0x1CA34, EDMAC_RegisterCompleteCBR) - -/** register/unregister CBR names **/ -NSTUB(0x1CA34, RegisterEDmacCompleteCBR) //FFCF7C5C -NSTUB(0x1CB1C, RegisterEDmacAbortCBR) //FFCF7CF0 -NSTUB(0x1CBB0, RegisterEDmacPopCBR) //FFCF7D84 -NSTUB(0x1CA70, UnregisterEDmacCompleteCBR) -NSTUB(0x1CB58, UnregisterEDmacAbortCBR) //FFCF7D2C -NSTUB(0x1CBEC , UnregisterEDmacPopCBR) //FFCF7DC0 - -NSTUB(0xFF5FE6E8, PackMem_SetEDmacForMemorySuite) -NSTUB(0xFF5FEA70, PackMem_RegisterEDmacPopCBRForMemorySuite) -NSTUB(0xFF5FE9D4, PackMem_RegisterEDmacCompleteCBRForMemorySuite) -NSTUB(0xFF5FEB0C, PackMem_RegisterEDmacAbortCBRForMemorySuite) - -NSTUB(0xFF5FE7FC, PackMem_StartEDmac) -NSTUB(0xFF5FE904, PackMem_PopEDmacForMemorySuite) - -NSTUB(0xFF681104, GetCFnData) -NSTUB(0xFF68131C, SetCFnData) +/* Debugging */ NSTUB(0x22260, TryPostEvent) NSTUB(0x222E4 , TryPostEvent_end) @@ -259,12 +273,40 @@ NSTUB(0x21B80, TryPostStageEvent) NSTUB(0x21C04, TryPostStageEvent_end) +NSTUB(0x3E1C8, pre_isr_hook) +NSTUB(0x3E1CC, post_isr_hook) + + +/* Misc */ +NSTUB(0xFFA7391C - RAM_OFFSET, dma_memcpy) +NSTUB(0xFF681104, GetCFnData) +NSTUB(0xFF68131C, SetCFnData) + + +/* Unused */ +//NSTUB(0xFF0D783C, GUI_ChangeMode) +//NSTUB(0xFF1BD13C, GUI_GetFirmVersion) +//NSTUB(0xFF32D348, MuteOff_0) +//NSTUB(0xFF32D300, MuteOn_0) +//NSTUB(0xFF1299C4, SetBitmapVramAddress) +//NSTUB(0xFF4C135C, ctrlman_dispatch_event) +//NSTUB(0xFF3420F4, register_func) +//NSTUB( 0x8D330, vram_info) + //NSTUB(0xff987200 - RAM_OFFSET, set_fps_maybe) +//NSTUB(0xFF1B4F70, Gui_SetSoundRecord) // Look for GUI_setsoundrec - Just changes prop +//NSTUB(0xFF143C18, copy_malloc_info_maybe) +//NSTUB(0xFF101E04, PD_RemoteRelease) +//NSTUB(0xFF19991C, ENCODE_StartEncodeJpeg) +//NSTUB(0xFF2A3378, ptpPropSetUILock) +//NSTUB(0xFF5B6688, lvae_setdispgain) +//NSTUB(0xFF0E5808, MVR_NotifyLvFrameTiming) +//NSTUB(0xFFA71D5C - RAM_OFFSET, GetRemainOfMemoryChunk) +//NSTUB(0xFFA71D8C - RAM_OFFSET, GetSizeOfMemoryChunk) +//NSTUB(0xFFA720C4 - RAM_OFFSET, GetSizeOfMemorySuite) +//NSTUB(0xFFA721A4 - RAM_OFFSET, GetNumberOfChunks) + //FIND //NSTUB(0x35700, MREQ_ISR) //NSTUB(0x35784, SIO3_ISR) //NSTUB(0x8FE4, register_interrupt) //Unused -//NSTUB(0xFFA71D5C - RAM_OFFSET, GetRemainOfMemoryChunk) -//NSTUB(0xFFA71D8C - RAM_OFFSET, GetSizeOfMemoryChunk) -//NSTUB(0xFFA720C4 - RAM_OFFSET, GetSizeOfMemorySuite) -//NSTUB(0xFFA721A4 - RAM_OFFSET, GetNumberOfChunks) diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/Makefile Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,4 @@ +#Makefile for EOS M + +MODEL=EOSM +include ../Makefile.platform diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/Makefile.platform.default --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/Makefile.platform.default Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,16 @@ +#Makefile.setup.platform for EOS M + +ifeq ($(FW_VERSION),202) +CANON_NAME_FIR=EOSM1202.FIR + +ROMBASEADDR = 0xFF0C0000 + +# DryOSmemory map +# RESTARTSTART is selected to be just above the end of the bss +# +#RESTARTSTART = 0x0009E300 +#RESTARTSTART = 0x00CEC100 +RESTARTSTART = 0x00CCC100 +AUTOEXEC_BASE = 0x40800000 +FIR_BASE = 0x40800120 +endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/Makefile.setup.default --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/Makefile.setup.default Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,17 @@ +#Makefile for EOS M + +TOP_DIR=../.. +ML_AF_PATTERNS_OBJ = n + +ML_SRC_EXTRA_OBJS = \ + misc.o \ + dm-spy.o \ + video_hacksU.o \ + raw.o \ + chdk-dng.o \ + edmac-memcpy.o + +# tp-spy.o \ +# reloc.o \ + + diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/cfn.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/cfn.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,21 @@ +#include +#include + +int get_htp() { return GetCFnData(0, 3); } +void set_htp(int value) { SetCFnData(0, 3, value); } + +int get_mlu() { return GetCFnData(0, 5); } +void set_mlu(int value) { SetCFnData(0, 5, value); } + +int cfn_get_af_button_assignment() { return GetCFnData(0, 6); } +void cfn_set_af_button(int value) { SetCFnData(0, 6, value); } + +// on some cameras, ALO is CFn +PROP_INT(PROP_ALO, alo); +int get_alo() { return alo; } + +void set_alo(int value) +{ + value = COERCE(value, 0, 3); + prop_request_change(PROP_ALO, &value, 4); +} diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/consts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/consts.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,271 @@ +/* + * EOS M 2.0.2 consts + */ + +#define CARD_DRIVE "B:/" +#define CARD_LED_ADDRESS 0xC022C188 // http://magiclantern.wikia.com/wiki/Led_addresses +#define LEDON 0x138800 +#define LEDOFF 0x838C00 + +//~ Format dialog consts +#define FORMAT_BTN "[Tap Screen]" +#define STR_LOC 4 + +#define HIJACK_CACHE_HACK +#define HIJACK_CACHE_HACK_INITTASK_ADDR 0xFF0C1CC8 +/* Intaller */ +#define HIJACK_INSTR_BL_CSTART 0xff0c0d80 +//~ #define HIJACK_INSTR_BSS_END 0xff0c1cbc +#define HIJACK_FIXBR_BZERO32 0xff0c1c20 +#define HIJACK_FIXBR_CREATE_ITASK 0xff0c1cac +#define HIJACK_INSTR_MY_ITASK 0xFF0C1CC8 + +#define HIJACK_TASK_ADDR 0x3DE78 + +// Doesn't resize memory.. +// load ML in the malloc pool //0xD16F8 - A0000 = 316F8 +//~ #define HIJACK_CACHE_HACK_BSS_END_ADDR 0xff0c1cbc +//~ #define HIJACK_CACHE_HACK_BSS_END_INSTR 0xCCC000 +//~ #define HIJACK_CACHE_HACK_BSS_END_INSTR 0x13E260 //Move Start Address Up + +//Patch Malloc End +//~ #define HIJACK_CACHE_HACK_ALLOCMEM_SIZE_ADDR 0xFF0C1CC0 +//~ #define HIJACK_CACHE_HACK_ALLOCMEM_SIZE_INSTR 0xCF958 + + + +// load ML in the AllocateMemory pool +//0xD6C000 - 0x80000 = CEC000 +#define HIJACK_CACHE_HACK_BSS_END_ADDR 0xFF0C31AC +//~ #define HIJACK_CACHE_HACK_BSS_END_INSTR 0xCEC000 +//0xA0000 - 640K Should Be enough for everyone +#define HIJACK_CACHE_HACK_BSS_END_INSTR 0xCCC000 + + +//~ fixup start address of AllocateMemory pool +#define HIJACK_CACHE_HACK_ALLOCMEM_SIZE_ADDR 0xFF0C3058 +//~ #define HIJACK_CACHE_HACK_ALLOCMEM_SIZE_INSTR 0xE2410887 +//0x7D0000 +#define HIJACK_CACHE_HACK_ALLOCMEM_SIZE_INSTR 0xE241087D + + + +#define CACHE_HACK_FLUSH_RATE_SLAVE 0xFF0E2C54 + +#define ARMLIB_OVERFLOWING_BUFFER 0x65CC4 // in AJ_armlib_setup_related3 + +#define DRYOS_ASSERT_HANDLER 0x3DE58 // dec TH_assert or assert_0 + +#define YUV422_LV_BUFFER_1 0x4F1D7800 +#define YUV422_LV_BUFFER_2 0x4F5E7800 +#define YUV422_LV_BUFFER_3 0x4F9F7800 + +// http://magiclantern.wikia.com/wiki/VRAM_ADDR_from_code +// stateobj_disp[1] +#define YUV422_LV_BUFFER_DISPLAY_ADDR (*(uint32_t*)(0x3E650+0x11c)) + +#define REG_EDMAC_WRITE_LV_ADDR 0xc0f04208 // SDRAM address of LV buffer (aka VRAM) +#define REG_EDMAC_WRITE_HD_ADDR 0xc0f04108 // SDRAM address of HD buffer (aka YUV) + +#define YUV422_HD_BUFFER_DMA_ADDR (shamem_read(REG_EDMAC_WRITE_HD_ADDR)) // first line from DMA is dummy + + +// http://magiclantern.wikia.com/wiki/ASM_Zedbra +#define YUV422_HD_BUFFER_1 0x44000080 +#define YUV422_HD_BUFFER_2 0x46000080 +#define IS_HD_BUFFER(x) ((0x40FFFFFF & (x)) == 0x40000080 ) // quick check if x looks like a valid HD buffer + +// see "focusinfo" and Wiki:Struct_Guessing +#define FOCUS_CONFIRMATION (*(int*)0x420F0) + +//~ look for string "[MC] permit LV instant", it's the struct refrenced in this function. +#define HALFSHUTTER_PRESSED (*(int*)0x3F224) + +#define DISPLAY_SENSOR_POWERED 0 + +// for gui_main_task +#define GMT_NFUNCS 7 +#define GMT_FUNCTABLE 0xFF7F9624 // dec gui_main_task + +#define SENSOR_RES_X 5280 +#define SENSOR_RES_Y 3528 + + +#define CURRENT_DIALOG_MAYBE (*(int*)0x40FBC) + +#define LV_BOTTOM_BAR_DISPLAYED UNAVI_FEEDBACK_TIMER_ACTIVE + +#define ISO_ADJUSTMENT_ACTIVE 0 // dec ptpNotifyOlcInfoChanged and look for: if arg1 == 1: MEM(0x79B8) = *(arg2) + + // from a screenshot + #define COLOR_FG_NONLV 1 + +#define MVR_516_STRUCT (*(void**)0x3E1E0) // look in MVR_Initialize for AllocateMemory call; decompile it and see where ret_AllocateMemory is stored. + +//~ #define MEM(x) (*(volatile int*)(x)) +#define div_maybe(a,b) ((a)/(b)) + +// see mvrGetBufferUsage, which is not really safe to call => err70 +// macros copied from arm-console +#define MVR_BUFFER_USAGE_FRAME MAX(MEM(MVR_516_STRUCT + 0x580), MEM(MVR_516_STRUCT + 0x57C)) +#define MVR_BUFFER_USAGE_SOUND 0 // not sure +#define MVR_BUFFER_USAGE MAX(MVR_BUFFER_USAGE_FRAME, MVR_BUFFER_USAGE_SOUND) + +#define MVR_FRAME_NUMBER (*(int*)(0x1F4 + MVR_516_STRUCT)) // in mvrExpStarted +#define MVR_BYTES_WRITTEN (*(int*)(0xb0 + MVR_516_STRUCT)) + +#define MOV_RES_AND_FPS_COMBINATIONS 9 +#define MOV_OPT_NUM_PARAMS 2 +#define MOV_GOP_OPT_NUM_PARAMS 5 +#define MOV_OPT_STEP 5 +#define MOV_GOP_OPT_STEP 5 + +//~ #define AE_VALUE (*(int8_t*)0x517FC) + +#define AE_STATE (*(int8_t*)(0x517A0 + 0x1C)) +#define AE_VALUE (*(int8_t*)(0x517A0 + 0x1D)) + + +#define DLG_PLAY 1 +#define DLG_MENU 2 +#define DLG_INFO 0x15 +#define DLG_FOCUS_MODE 0x123456 + +/* these don't exist in the M */ +#define DLG_MOVIE_ENSURE_A_LENS_IS_ATTACHED 0 +#define DLG_MOVIE_PRESS_LV_TO_RESUME 0 +/*--------------*/ + +#define PLAY_MODE (gui_state == GUISTATE_PLAYMENU && CURRENT_DIALOG_MAYBE == DLG_PLAY) +#define MENU_MODE (gui_state == GUISTATE_PLAYMENU && CURRENT_DIALOG_MAYBE == DLG_MENU) + +#define AUDIO_MONITORING_HEADPHONES_CONNECTED (!((*(int*)0xC0220138) & 1)) //EnableVideoOut +#define HOTPLUG_VIDEO_OUT_PROP_DELIVER_ADDR 0x3DED8 +#define HOTPLUG_VIDEO_OUT_STATUS_ADDR 0x3DEC8 + +// In bindGUIEventFromGUICBR, look for "LV Set" => arg0 = 8 +// Next, in SetGUIRequestMode, look at what code calls NotifyGUIEvent(8, something) + //~ #define GUIMODE_ML_MENU (recording ? 0 : lv ? 90 : 2) // any from 90...102 ?! + +#define GUIMODE_ML_MENU ( (recording && !raw_lv_is_enabled()) ? 99 : 90 ) // any from 90...102 ?! + +// for displaying TRAP FOCUS msg outside LV +#define DISPLAY_TRAP_FOCUS_POS_X 50 +#define DISPLAY_TRAP_FOCUS_POS_Y 360 +#define DISPLAY_TRAP_FOCUS_MSG "TRAP FOCUS" +#define DISPLAY_TRAP_FOCUS_MSG_BLANK " " + +#define NUM_PICSTYLES 10 +#define PROP_PICSTYLE_SETTINGS(i) (PROP_PICSTYLE_SETTINGS_STANDARD - 1 + i) + +#define FLASH_MAX_EV 3 +#define FLASH_MIN_EV -10 // not sure if it actually works +#define FASTEST_SHUTTER_SPEED_RAW 152 +#define MAX_AE_EV 5 + +#define DIALOG_MnCardFormatBegin (0x60970) // ret_CreateDialogBox(...DlgMnCardFormatBegin_handler...) is stored there +#define DIALOG_MnCardFormatExecute (0x643F0) // similar + +#define BULB_MIN_EXPOSURE 1000 + +// http://magiclantern.wikia.com/wiki/Fonts + #define BFNT_CHAR_CODES 0xffcb9c04 + #define BFNT_BITMAP_OFFSET 0xffcbcb88 + #define BFNT_BITMAP_DATA 0xffcbfb0c + + #define DLG_SIGNATURE 0x6e6144 + +// from CFn +#define AF_BTN_HALFSHUTTER 0 +#define AF_BTN_STAR 2 + + #define IMGPLAY_ZOOM_LEVEL_ADDR (0x51E28) // dec GuiImageZoomDown and look for a negative counter + #define IMGPLAY_ZOOM_LEVEL_MAX 14 + #define IMGPLAY_ZOOM_POS_X MEM(0x8D38C) // CentrePos + #define IMGPLAY_ZOOM_POS_Y MEM(0x8D390) + #define IMGPLAY_ZOOM_POS_X_CENTER 360 + #define IMGPLAY_ZOOM_POS_Y_CENTER 240 + + #define BULB_EXPOSURE_CORRECTION 150 // min value for which bulb exif is OK [not tested] + +// see http://magiclantern.wikia.com/wiki/VRAM/BMP +#define WINSYS_BMP_DIRTY_BIT_NEG MEM(0x58F14+0x2c) + +// manual exposure overrides +#define LVAE_STRUCT 0x969D0 +#define CONTROL_BV (*(uint16_t*)(LVAE_STRUCT+0x20)) // EP_SetControlBv +#define CONTROL_BV_TV (*(uint16_t*)(LVAE_STRUCT+0x22)) // EP_SetControlParam +#define CONTROL_BV_AV (*(uint16_t*)(LVAE_STRUCT+0x24)) +#define CONTROL_BV_ISO (*(uint16_t*)(LVAE_STRUCT+0x26)) +#define CONTROL_BV_ZERO (*(uint16_t*)(LVAE_STRUCT+0x28)) +#define LVAE_ISO_SPEED (*(uint8_t* )(LVAE_STRUCT)) // offset 0x0; at 3 it changes iso very slowly +//~ #define LVAE_ISO_MIN (*(uint8_t* )(LVAE_STRUCT+0x28)) // string: ISOMin:%d +//~ #define LVAE_ISO_HIS (*(uint8_t* )(LVAE_STRUCT+0x2a)) // no idea what this is +#define LVAE_DISP_GAIN (*(uint16_t*)(LVAE_STRUCT+0x3c)) // lvae_setdispgain +#define LVAE_MOV_M_CTRL (*(uint8_t* )(LVAE_STRUCT+0x1c)) // lvae_setmoviemanualcontrol + +#define MIN_MSLEEP 10 + +#define INFO_BTN_NAME "INFO" +#define Q_BTN_NAME "[1-Finger Tap]" + #define ARROW_MODE_TOGGLE_KEY "IDK" + +#define DISPLAY_STATEOBJ (*(struct state_object **)0x3E758) +#define DISPLAY_IS_ON (DISPLAY_STATEOBJ->current_state != 0) + +#define VIDEO_PARAMETERS_SRC_3 MEM(0x404C8) +#define FRAME_ISO (*(uint8_t*)(VIDEO_PARAMETERS_SRC_3+0)) +#define FRAME_APERTURE (*(uint8_t*)(VIDEO_PARAMETERS_SRC_3+1)) +#define FRAME_SHUTTER (*(uint8_t*)(VIDEO_PARAMETERS_SRC_3+2)) +#define FRAME_SHUTTER_TIMER (*(uint16_t*)(VIDEO_PARAMETERS_SRC_3+6)) +#define FRAME_BV ((int)FRAME_SHUTTER + (int)FRAME_APERTURE - (int)FRAME_ISO) + +#define FRAME_SHUTTER_BLANKING_ZOOM (*(uint16_t*)0x40501B20) // ADTG register 805f +#define FRAME_SHUTTER_BLANKING_NOZOOM (*(uint16_t*)0x40501B24) // ADTG register 8061 +#define FRAME_SHUTTER_BLANKING_READ (lv_dispsize > 1 ? FRAME_SHUTTER_BLANKING_NOZOOM : FRAME_SHUTTER_BLANKING_ZOOM) /* when reading, use the other mode, as it contains the original value (not overriden) */ +#define FRAME_SHUTTER_BLANKING_WRITE (lv_dispsize > 1 ? &FRAME_SHUTTER_BLANKING_ZOOM : &FRAME_SHUTTER_BLANKING_NOZOOM) + + +// see "Malloc Information" +#define MALLOC_STRUCT 0x668C8 +#define MALLOC_FREE_MEMORY (MEM(MALLOC_STRUCT + 8) - MEM(MALLOC_STRUCT + 0x1C)) // "Total Size" - "Allocated Size" + +#define UNAVI (MEM(0x5D408) == 2) // Find with Mem Browser // dec CancelUnaviFeedBackTimer +#define SCROLLHACK (MEM(0x5D43C) != 0) //-450 +#define UNAVI_FEEDBACK_TIMER_ACTIVE (UNAVI || SCROLLHACK) + + + +/****************************************************************************************************************** + * touch_num_fingers_ptr: + * --> value=0x11100 when screen isn't being touched, value=0x11101 when 1 finger is held touching the screen + * --> value=0x11102 with 2 fingers touching the screen + * --> value=0x11103 with 3 fingers + * --> value=0x1104 with 4 fingers! Note: only the LSB seems to be used here, other bits seem to change sometimes. + * but the rightmost bit always changes to match how many fingers are touching the screen. We can recognize up to + * 2 touch points active. Looks like canon doesn't utilize more than 2 finger gestures, it does't report the + * coordinates of the 3rd-6th fingers. + * + * touch_coord_ptr: + * --> top left corner = 0x0000000 + * --> top right corner = 0x00002CF + * --> bottom right corner = 0x1DF02CF + * --> bottom left corner = 0x1DF0000 + * + * [**] lower 3 bits represent the X coordinates, from 0 to 719 (720px wide) + * [**] middle bit is always 0 + * [**] upper 3 bits represent the Y coordinates, from 0 to 479 (480px tall) + * + * And that's how Canon's touch screen works :) + *******************************************************************************************************************/ +//~ not used [was for early implemenation] +//#define TOUCH_XY_RAW1 0x4D868 +//#define TOUCH_XY_RAW2 (TOUCH_XY_RAW1+4) +//#define TOUCH_MULTI 0x4D810 //~ found these with memspy. look for addresses changing with screen touches. +//-------------- +#define HIJACK_TOUCH_CBR_PTR 0x4D3F8 + + +//~ max volume supported for beeps +#define ASIF_MAX_VOL 10 + diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/features.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/features.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,69 @@ +#include "all_features.h" +/* Can't Be Implemented */ +#undef FEATURE_FORCE_LIVEVIEW // Already Live View +#undef FEATURE_MLU // No Mirror +#undef FEATURE_MLU_HANDHELD +#undef FEATURE_STICKY_DOF // No DOF button +#undef FEATURE_IMAGE_EFFECTS // DigicV new effects check "Art Filter" +#undef CONFIG_MEMPATCH_CHECK // Reports 0 for total, like 6D +#undef FEATURE_INTERMEDIATE_ISO_PHOTO_DISPLAY // Well.. it will work in 1 mode +#undef FEATURE_AF_PATTERNS // No regular AF +#undef FEATURE_VOICE_TAGS // Just to be sure +#undef FEATURE_PLAY_422 // No way to select +#undef FEATURE_SHUTTER_FINE_TUNING //Doesn't seem to work + + +/* Working */ +#define FEATURE_CROP_MODE_HACK +#define FEATURE_PREFIX //Named HDR Bracketing B01, B02, etc +#define FEATURE_NOHELP //No one can help you now +#define FEATURE_VIDEO_HACKS +#define FEATURE_TIMER_HACK + + +/* Debug */ +#undef CONFIG_STRESS_TEST // We don't need this so much. +//~ #undef SHOULD_CHECK_SIG +#undef CONFIG_AUTOBACKUP_ROM //WTF, Batman? +#define CONFIG_HEXDUMP +#define CONFIG_TSKMON +#define CONFIG_DEBUG_INTERCEPT +#define FEATURE_PROP_DISPLAY +//~ #define CONFIG_DIGIC_POKE +//~ #define FEATURE_ISR_HOOKS +//~ #define FEATURE_SHOW_SIGNATURE + + + +/* Some Hope Yet */ +//~ #undef FEATURE_AUDIO_REMOTE_SHOT +#undef FEATURE_TRAP_FOCUS +#undef FEATURE_FOLLOW_FOCUS +#undef FEATURE_RACK_FOCUS +#undef FEATURE_FOCUS_STACKING +#undef FEATURE_GHOST_IMAGE // No way to pick image but works. +#undef FEATURE_SET_MAINDIAL // Set taken over by Q +#undef FEATURE_PLAY_EXPOSURE_FUSION +#undef FEATURE_PLAY_COMPARE_IMAGES +#undef FEATURE_PLAY_TIMELAPSE +#undef FEATURE_PLAY_EXPOSURE_ADJUST +#undef FEATURE_QUICK_ZOOM +#undef FEATURE_QUICK_ERASE +#undef FEATURE_LV_FOCUS_BOX_FAST +#undef FEATURE_LV_FOCUS_BOX_SNAP +#undef FEATURE_ARROW_SHORTCUTS + + +//~ #define FEATURE_LV_FOCUS_BOX_SNAP_TO_X5_RAW +//~ #define FEATURE_LV_FOCUS_BOX_AUTOHIDE + +//~ #undef FEATURE_OVERLAYS_IN_PLAYBACK_MODE +//~ #undef FEATURE_AUDIO_METERS // Work While Recording +//~ #undef FEATURE_LV_FOCUS_BOX_AUTOHIDE // Works in FB mode + +#define FEATURE_FOCUS_PEAK_DISP_FILTER //Need early sync. + +//~ #define FEATURE_PICQ_DANGEROUS // All 3 Props are len 4. Show up as len0? Mraw/Sraw causes crash. + +#define FEATURE_HEADPHONE_MONITORING +#define CONFIG_DUMP_AUDIO diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/gui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/gui.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,95 @@ +#ifndef _cameraspecific_gui_h_ +#define _cameraspecific_gui_h_ + +// touch events +#define TOUCH_1_FINGER 0x6f +#define UNTOUCH_1_FINGER 0x70 +#define TOUCH_2_FINGER 0x76 +#define UNTOUCH_2_FINGER 0x77 + +// used for knowing when canon's lv overlays are showing +#define GUI_LV_OVERLAYS_HIDDEN -7 +#define GUI_LV_OVERLAYS_VISIBLE 0x37 + + +// button codes as received by gui_main_task +#define BGMT_WHEEL_UP 2 +#define BGMT_WHEEL_DOWN 3 + #define BGMT_WHEEL_LEFT 12345 + #define BGMT_WHEEL_RIGHT 123456 + +#define BGMT_PRESS_SET 0x4 +#define BGMT_UNPRESS_SET 0x5 + +#define BGMT_MENU 0x6 +#define BGMT_INFO 0x7 +#define BGMT_PLAY 0xb +#define BGMT_TRASH TOUCH_2_FINGER + + #define BGMT_PRESS_DP 0x2f + #define BGMT_UNPRESS_DP 0x35 + #define BGMT_RATE 0x21 +#define BGMT_REC 0x1E + + + #define BGMT_PRESS_ZOOMIN_MAYBE 0x12 + #define BGMT_UNPRESS_ZOOMIN_MAYBE 0x13 + //~ #define BGMT_PRESS_ZOOMOUT_MAYBE 0x1234 // no zoom out button in play mode?! + //~ #define BGMT_UNPRESS_ZOOMOUT_MAYBE 0x5678 + + #define BGMT_LV 0x1E + //~ #define BGMT_Q 0xDEADBEEF0 +#define BGMT_Q TOUCH_1_FINGER + //~ #define BGMT_Q_ALT 0x67 + + //~ #define BGMT_FUNC 0x12 + #define BGMT_PICSTYLE 0x13 + //~ #define BGMT_JOY_CENTER (lv ? 0x1e : 0x3b) +#if 0 +#define BGMT_JOY_CENTER 0x3e +#define BGMT_UNPRESS_UDLR 0x35 +#endif + +#define BGMT_PRESS_UP 0x2a //~ unpress = 0x2b +#define BGMT_UNPRESS_UP 0x2b + #define BGMT_PRESS_UP_RIGHT 0x17 + #define BGMT_PRESS_UP_LEFT 0x18 +#define BGMT_PRESS_RIGHT 0x26 //~ unpress = 0x27 +#define BGMT_UNPRESS_RIGHT 0x27 +#define BGMT_PRESS_LEFT 0x28 //~ unpress = 0x29 +#define BGMT_UNPRESS_LEFT 0x29 + #define BGMT_PRESS_DOWN_RIGHT 0x1B + #define BGMT_PRESS_DOWN_LEFT 0x1C +#define BGMT_PRESS_DOWN 0x2c //~ unpress = 0x2d +#define BGMT_UNPRESS_DOWN 0x2d + +#define BGMT_PRESS_HALFSHUTTER 0x50 +#define BGMT_UNPRESS_HALFSHUTTER 0x51 +#define BGMT_PRESS_FULLSHUTTER 0x52 +#define BGMT_UNPRESS_FULLSHUTTER 0x53 + + #define BGMT_FLASH_MOVIE 0 + #define BGMT_PRESS_FLASH_MOVIE 0 + #define BGMT_UNPRESS_FLASH_MOVIE 0 + #define FLASH_BTN_MOVIE_MODE 0 + #define BGMT_ISO_MOVIE 0 + #define BGMT_PRESS_ISO_MOVIE 0 + #define BGMT_UNPRESS_ISO_MOVIE 0 + + #define GMT_GUICMD_PRESS_BUTTON_SOMETHING 0x52 // unhandled buttons? + + #define BGMT_LIGHT 0x20 // the little button for top screen backlight + +#define GMT_OLC_INFO_CHANGED 105 // backtrace copyOlcDataToStorage call in gui_massive_event_loop + +// needed for correct shutdown from powersave modes +#define GMT_GUICMD_START_AS_CHECK 97 +#define GMT_GUICMD_OPEN_SLOT_COVER 93 +#define GMT_GUICMD_LOCK_OFF 91 + + #define BTN_ZEBRAS_FOR_PLAYBACK BGMT_LIGHT // what button to use for zebras in Play mode + +//~ not implemented yet +#define GMT_LOCAL_DIALOG_REFRESH_LV 0x36 // event type = 2, gui code = 0x100000C6 in EOS-M + +#endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/include/platform/mvr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/include/platform/mvr.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,138 @@ +#ifndef __PLATFORM_MVR_H__ +#define __PLATFORM_MVR_H__ + +// Movie recording. +// tab size: 4 + +struct mvr_config +{ + int16_t qscale_related_1; // 0x00, 67bc + uint16_t debug_flag; // 0x02, 67be 1 = write debugmsg's + uint16_t qscale_mode; // 0x04, 67c0 1 = QScale, 0 = CBR + uint16_t db_filter_a; // 0x06, 67c2 + uint16_t db_filter_b; // 0x08, 67c4 + int16_t def_q_scale; // 0x0a, 67c6 + int16_t qscale_related_2; // 0x0c, 67c8 + int16_t qscale_related_3; // 0x0e, 67ca + uint16_t x67cc; // 0x10, 67cc + int16_t qscale_limit_L; // 0x12, 67ce + int16_t qscale_limit_H; // 0x14, 67d0 + uint16_t time_const; // 0x16, 67d2 + uint32_t fullhd_30fps_opt_size_I;// 0x18, 67d4 + uint32_t fullhd_30fps_opt_size_P;// 0x1c, 67d8 + uint32_t D1_30fps; // 0x20, 67dc + uint32_t D2_30fps; // 0x24, 67e0 + uint32_t x67e4; // 0x28, 67e4 + uint32_t fullhd_25fps_opt_size_I;// 0x2c, 67e8 + uint32_t fullhd_25fps_opt_size_P;// 0x30, 67ec + uint32_t fullhd_25fps_D1; // 0x34, 67f0 + uint32_t fullhd_25fps_D2; // 0x38, 67f4 + uint32_t x67f8; // 0x3c, 67f8 + uint32_t fullhd_24fps_opt_size_I;// 0x40, 67fc + uint32_t fullhd_24fps_opt_size_P;// 0x44, 6800 + uint32_t fullhd_24fps_D1; // 0x48, 6804 + uint32_t fullhd_24fps_D2; // 0x4c, 6808 + uint32_t x680c; // 0x50, 680c + uint32_t hd_60fps_opt_size_I; // 0x54, 6810 + uint32_t hd_60fps_opt_size_P; // 0x58, 6814 + uint32_t hd_60fps_D1; // 0x5c, 6818 + uint32_t hd_60fps_D2; // 0x60, 681c + uint32_t x6820; // 0x64, 6820 + uint32_t hd_50fps_opt_size_I; // 0x68, 6824 + uint32_t hd_50fps_opt_size_P; // 0x6c, 6828 + uint32_t hd_50fps_D1; // 0x70, 682c + uint32_t hd_50fps_D2; // 0x74, 6830 + uint32_t x6834_kinda_counter; // 0x78, 6834 + uint32_t x6838; // 0x7c, 6838 + uint32_t x683c; // 0x80, 683c + uint32_t x6840; // 0x84, 6840 + uint32_t x6844; // 0x88, 6844 + uint32_t x6848; // 0x8c, 6848 + int32_t another_def_q_scale; // 0x90, 684c + int32_t IniQScale; // 0x94, 6850 + uint32_t x6854; // 0x98, 6854 + uint32_t x6858; // 0x9c, 6858 + uint32_t x685c; // 0xa0, 685c + uint32_t vga_30fps_opt_size_I; // 0xa4, 6860 + uint32_t vga_30fps_opt_size_P; // 0xa8, 6864 + uint32_t vga_30fps_D1; // 0xac, 6868 + uint32_t vga_30fps_D2; // 0xb0, 686c + uint32_t x6870; // 0xb4, 6870 + uint32_t vga_25fps_opt_size_I; // 0xb8, 6874 + uint32_t vga_25fps_opt_size_P; // 0xbc, 6878 + uint32_t vga_25fps_D1; // 0xc0, 687c + uint32_t vga_25fps_D2; // 0xc4, 6880 + uint32_t x6884; // 0xc8, 6884 + uint32_t x6888; // 0xcc, 6888 + uint32_t x688c; // 0xd0, 688c + uint32_t x6890; // 0xd4, 6890 + uint32_t x6894; // 0xd8, 6894 + uint32_t x6898; // 0xdc, 6898 + uint32_t x689c; // 0xe0, 689c + uint32_t x68a0; // 0xe4, 68a0 + uint32_t x68a4; // 0xe8, 68a4 + uint32_t x68a8; // 0xec, 68a8 + uint32_t x68ac; // 0xf0, 68ac + uint32_t actual_qscale_maybe3; // 0xf4, 68b0 + uint32_t actual_qscale_maybe2; // 0xf8, 68b4 + uint32_t actual_qscale_maybe; // 0xfc, 68b8 + uint32_t IOptSize; // 0x100, 68bc + uint32_t POptSize; // 0x104, 68c0 + uint32_t IOptSize2; // 0x108, 68c4 + uint32_t POptSize2; // 0x10c, 68c8 + uint32_t GopSize; // 0x110, 68cc + uint32_t x68d0; // 0x114, 68d0 + uint32_t x68d4; // 0x118, 68d4 + uint32_t _D1; // 0x11c, 68d8 + uint32_t _D2; // 0x120, 68dc + uint32_t x68e0; // 0x124, 68e0 + uint32_t fullhd_30fps_gop_opt_0; // 0x128, 68e4 + uint32_t fullhd_30fps_gop_opt_1; // 0x12c, 68e8 + uint32_t fullhd_30fps_gop_opt_2; // 0x130, 68ec + uint32_t fullhd_30fps_gop_opt_3; // 0x134, 68f0 + uint32_t fullhd_30fps_gop_opt_4; // 0x138, 68f4 + uint32_t fullhd_25fps_gop_opt_0; // 0x13c, 68f8 + uint32_t fullhd_25fps_gop_opt_1; // 0x140, 68fc + uint32_t fullhd_25fps_gop_opt_2; // 0x144, 6900 + uint32_t fullhd_25fps_gop_opt_3; // 0x148, 6904 + uint32_t fullhd_25fps_gop_opt_4; // 0x14c, 6908 + uint32_t fullhd_24fps_gop_opt_0; // 0x150, 690c + uint32_t fullhd_24fps_gop_opt_1; // 0x154, 6910 + uint32_t fullhd_24fps_gop_opt_2; // 0x158, 6914 + uint32_t fullhd_24fps_gop_opt_3; // 0x15c, 6918 + uint32_t fullhd_24fps_gop_opt_4; // 0x160, 691c + uint32_t hd_60fps_gop_opt_0; // 0x164, 6920 + uint32_t hd_60fps_gop_opt_1; // 0x168, 6924 + uint32_t hd_60fps_gop_opt_2; // 0x16c, 6928 + uint32_t hd_60fps_gop_opt_3; // 0x170, 692c + uint32_t hd_60fps_gop_opt_4; // 0x174, 6930 + uint32_t hd_50fps_gop_opt_0; // 0x178, 6934 + uint32_t hd_50fps_gop_opt_1; // 0x17c, 6938 + uint32_t hd_50fps_gop_opt_2; // 0x180, 693c + uint32_t hd_50fps_gop_opt_3; // 0x184, 6940 + uint32_t hd_50fps_gop_opt_4; // 0x188, 6944 + uint32_t x6948; // 0x18c, 6948 + uint32_t x694c; // 0x190, 694c + uint32_t x6950; // 0x194, 6950 + uint32_t x6954; // 0x198, 6954 + uint32_t x6958; // 0x19c, 6958 + uint32_t x695c; // 0x1a0, 695c + uint32_t x6960; // 0x1a4, 6960 + uint32_t x6964; // 0x1a8, 6964 + uint32_t x6968; // 0x1ac, 6968 + uint32_t x696c; // 0x1b0, 696c + uint32_t vga_30fps_gop_opt_0; // 0x1b4, 6970 + uint32_t vga_30fps_gop_opt_1; // 0x1b8, 6974 + uint32_t vga_30fps_gop_opt_2; // 0x1bc, 6978 + uint32_t vga_30fps_gop_opt_3; // 0x1c0, 697c + uint32_t vga_30fps_gop_opt_4; // 0x1c4, 6980 + uint32_t vga_25fps_gop_opt_0; // 0x1c8, 6984 + uint32_t vga_25fps_gop_opt_1; // 0x1cc, 6988 + uint32_t vga_25fps_gop_opt_2; // 0x1d0, 698c + uint32_t vga_25fps_gop_opt_3; // 0x1d4, 6990 + uint32_t vga_25fps_gop_opt_4; // 0x1d8, 6994 +} __attribute__((aligned,packed)); + +//~ SIZE_CHECK_STRUCT( mvr_config, 0x30 ); + +#endif /* __PLATFORM_MVR_H__ */ diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/include/platform/state-object.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/include/platform/state-object.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,16 @@ +#ifndef __platform_state_object_h +#define __platform_state_object_h + +#define EVF_STATE (*(struct state_object **)0x404E4) +#define SSS_STATE (*(struct state_object **)0x401C4) +#define MOVREC_STATE (*(struct state_object **)0x42254) +#define DISPLAY_STATE DISPLAY_STATEOBJ //Works for Photo Overlay +#define INPUT_SET_IMAGE_VRAM_PARAMETER_MUTE_FLIP_CBR 26 +#define INPUT_ENABLE_IMAGE_PHYSICAL_SCREEN_PARAMETER 27 + //#define FACE_STATE (*(struct state_object **)0x40A4C) + //#define DISP2_STATE (*(struct state_object **)0x3EBBC) + //#define LVCDEV_STATE (*(struct state_object **)0x43978) + //#define CLR_CALC_STATE (*(struct state_object **)0x43B74) + //~ #define DISPLAY_STATE FACE_STATE + +#endif // __platform_state_object_h diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/internals.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/internals.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,141 @@ +/** + * Camera internals for EOS-M 1.0.6 + */ + +/** Properties are persistent (saved in NVRAM) => a mistake can cause permanent damage. Undefine this for new ports. */ +/** The EOS_M port is very young, so we don't enable these for now. **/ +#define CONFIG_PROP_REQUEST_CHANGE + +/** + * State object hooks are pieces of code that run in Canon tasks (state objects). See state-object.c . + * They might slow down Canon code, so here you can disable all of them (useful for debugging or early ports) + */ +#define CONFIG_STATE_OBJECT_HOOKS + +/** This camera runs DryOS **/ +//~ #define CONFIG_VXWORKS + +/** This camera has a DIGIC V chip */ +#define CONFIG_DIGIC_V + +/** This camera has an APS-C sensor */ +//~ #define CONFIG_FULLFRAME + +/** This camera has LiveView and can record video **/ +#define CONFIG_LIVEVIEW +#define CONFIG_MOVIE + +/** This camera has a 3:2 screen, 720x480 **/ +#define CONFIG_3_2_SCREEN + +/** We only have a single LED **/ +//~ #define CONFIG_BLUE_LED + +/** There is no LCD sensor that turns the display off **/ +//~ #define CONFIG_LCD_SENSOR + +/** This camera has no miror **/ +//~ #define CONFIG_MLU + +/** This camera reports focus info in LiveView **/ +//~ #define CONFIG_LV_FOCUS_INFO + +/** Sensor gives some data Needs Help **/ +//~ #define CONFIG_ELECTRONIC_LEVEL + +/** Define this if the camera has an ambient light sensor used for auto brightness **/ +//~ #define CONFIG_AUTO_BRIGHTNESS + +/** idk **/ +//~ #define CONFIG_Q_MENU_PLAYBACK + +/** No flip-out display **/ +//~ #define CONFIG_VARIANGLE_DISPLAY + +/** Battery does not report exact percentage **/ +//~ #define CONFIG_BATTERY_INFO + +/** We can do bulb exposures (well, I hope) **/ +#define CONFIG_BULB + +/** There is no Bulb Mode **/ +//~ #define CONFIG_SEPARATE_BULB_MODE + +/** We can't control audio settings from ML **/ +//~ #define CONFIG_AUDIO_CONTROLS + +/** No zoom button **/ +#define CONFIG_ZOOM_BTN_NOT_WORKING_WHILE_RECORDING + +/** We can redirect the display buffer to some arbitrary address, just by changing YUV422_LV_BUFFER_DISPLAY_ADDR **/ +/** Well, I hope so **/ +#define CONFIG_CAN_REDIRECT_DISPLAY_BUFFER_EASILY +#define CONFIG_CAN_REDIRECT_DISPLAY_BUFFER + +/** Therefore, we can implement display filters (features that alter the LiveView image in real-time) **/ +#define CONFIG_DISPLAY_FILTERS + +/** We can override ISO on a per-frame basis, by changing FRAME_ISO (e.g. for HDR video or gradual exposure) **/ +#define CONFIG_FRAME_ISO_OVERRIDE + +/** But we can't override the digital ISO component via FRAME_ISO **/ +#define CONFIG_FRAME_ISO_OVERRIDE_ANALOG_ONLY + +/** We can also override shutter on a per-frame basis */ +#define CONFIG_FRAME_SHUTTER_OVERRIDE + +/** We can't change ExpSim from ML (at least not yet) **/ +#define CONFIG_EXPSIM + +/** Asif hangs camera.. will look for a fix **/ +//~ #define CONFIG_BEEP + +/** This camera has no trouble saving Kelvin and/or WBShift in movie mode **/ +#define CONFIG_WB_WORKAROUND + +/** We can restore ML files after formatting the card in the camera **/ +#define CONFIG_RESTORE_AFTER_FORMAT + +/** We don't know how to use DMA_MEMCPY (yet) **/ +#define CONFIG_DMA_MEMCPY + +/** We know how to use edmac_memcpy. This one is really fast (600MB/s!) */ +#define CONFIG_EDMAC_MEMCPY + +/** We shouldn't warn the user if movie exposure is Auto **/ +#define CONFIG_MOVIE_AE_WARNING + +/** No photo mode outside LiveView **/ +//~ #define CONFIG_PHOTO_MODE_INFO_DISPLAY + +/** No additional_version stub on this DryOS version **/ +#define CONFIG_NO_ADDITIONAL_VERSION + +/** Touchscreen support **/ +// Needs more hacking, I'll fix it once i get the EOSM - nanomad +//~ #define CONFIG_TOUCHSCREEN + +/** Perfect sync using EVF_STATE **/ +#define CONFIG_EVF_STATE_SYNC + +/** FPS override: Canon changes FPS registers often; we need to undo their changes asap */ +#define CONFIG_FPS_AGGRESSIVE_UPDATE + +/** FIO_RenameFile works **/ +#define CONFIG_FIO_RENAMEFILE_WORKS + +/** FPS override: change timers from EVF state */ +#define CONFIG_FPS_UPDATE_FROM_EVF_STATE + +/** There is a Movie Mode, needs research */ +#define CONFIG_NO_DEDICATED_MOVIE_MODE + +/** We have access to Raw data */ +#define CONFIG_RAW_LIVEVIEW +#define CONFIG_RAW_PHOTO + +/** We know how to use engine resource locks */ +#define CONFIG_ENGINE_RESLOCK + +/** We can control audio settings from ML **/ +//~ #define CONFIG_AUDIO_CONTROLS diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/misc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/misc.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,16 @@ +// misc functions specific to 60D/109 + +#include +#include +#include +#include +#include +#include + + +int new_LiveViewApp_handler = 0xff123456; + + + +// dummy stubs +int handle_af_patterns(struct event * event) { return 1; } diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/mvr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/mvr.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,283 @@ + +// Movie recording. + +extern struct mvr_struct * mvr_struct; +extern struct state_object * mvr_state; + +// tab size: 4 + +struct mvr_config +{ + int16_t qscale_related_1; // 0x00, 67bc + uint16_t debug_flag; // 0x02, 67be 1 = write debugmsg's + uint16_t qscale_mode; // 0x04, 67c0 1 = QScale, 0 = CBR + uint16_t db_filter_a; // 0x06, 67c2 + uint16_t db_filter_b; // 0x08, 67c4 + int16_t def_q_scale; // 0x0a, 67c6 + int16_t qscale_related_2; // 0x0c, 67c8 + int16_t qscale_related_3; // 0x0e, 67ca + uint16_t x67cc; // 0x10, 67cc + int16_t qscale_limit_L; // 0x12, 67ce + int16_t qscale_limit_H; // 0x14, 67d0 + uint16_t time_const; // 0x16, 67d2 + uint32_t fullhd_30fps_opt_size_I;// 0x18, 67d4 + uint32_t fullhd_30fps_opt_size_P;// 0x1c, 67d8 + uint32_t D1_30fps; // 0x20, 67dc + uint32_t D2_30fps; // 0x24, 67e0 + uint32_t x67e4; // 0x28, 67e4 + uint32_t fullhd_25fps_opt_size_I;// 0x2c, 67e8 + uint32_t fullhd_25fps_opt_size_P;// 0x30, 67ec + uint32_t fullhd_25fps_D1; // 0x34, 67f0 + uint32_t fullhd_25fps_D2; // 0x38, 67f4 + uint32_t x67f8; // 0x3c, 67f8 + uint32_t fullhd_24fps_opt_size_I;// 0x40, 67fc + uint32_t fullhd_24fps_opt_size_P;// 0x44, 6800 + uint32_t fullhd_24fps_D1; // 0x48, 6804 + uint32_t fullhd_24fps_D2; // 0x4c, 6808 + uint32_t x680c; // 0x50, 680c + uint32_t hd_60fps_opt_size_I; // 0x54, 6810 + uint32_t hd_60fps_opt_size_P; // 0x58, 6814 + uint32_t hd_60fps_D1; // 0x5c, 6818 + uint32_t hd_60fps_D2; // 0x60, 681c + uint32_t x6820; // 0x64, 6820 + uint32_t hd_50fps_opt_size_I; // 0x68, 6824 + uint32_t hd_50fps_opt_size_P; // 0x6c, 6828 + uint32_t hd_50fps_D1; // 0x70, 682c + uint32_t hd_50fps_D2; // 0x74, 6830 + uint32_t x6834_kinda_counter; // 0x78, 6834 + uint32_t x6838; // 0x7c, 6838 + uint32_t x683c; // 0x80, 683c + uint32_t x6840; // 0x84, 6840 + uint32_t x6844; // 0x88, 6844 + uint32_t x6848; // 0x8c, 6848 + int32_t another_def_q_scale; // 0x90, 684c + int32_t IniQScale; // 0x94, 6850 + uint32_t x6854; // 0x98, 6854 + uint32_t x6858; // 0x9c, 6858 + uint32_t x685c; // 0xa0, 685c + uint32_t vga_30fps_opt_size_I; // 0xa4, 6860 + uint32_t vga_30fps_opt_size_P; // 0xa8, 6864 + uint32_t vga_30fps_D1; // 0xac, 6868 + uint32_t vga_30fps_D2; // 0xb0, 686c + uint32_t x6870; // 0xb4, 6870 + uint32_t vga_25fps_opt_size_I; // 0xb8, 6874 + uint32_t vga_25fps_opt_size_P; // 0xbc, 6878 + uint32_t vga_25fps_D1; // 0xc0, 687c + uint32_t vga_25fps_D2; // 0xc4, 6880 + uint32_t x6884; // 0xc8, 6884 + uint32_t x6888; // 0xcc, 6888 + uint32_t x688c; // 0xd0, 688c + uint32_t x6890; // 0xd4, 6890 + uint32_t x6894; // 0xd8, 6894 + uint32_t x6898; // 0xdc, 6898 + uint32_t x689c; // 0xe0, 689c + uint32_t x68a0; // 0xe4, 68a0 + uint32_t x68a4; // 0xe8, 68a4 + uint32_t x68a8; // 0xec, 68a8 + uint32_t x68ac; // 0xf0, 68ac + uint32_t actual_qscale_maybe3; // 0xf4, 68b0 + uint32_t actual_qscale_maybe2; // 0xf8, 68b4 + uint32_t actual_qscale_maybe; // 0xfc, 68b8 + uint32_t IOptSize; // 0x100, 68bc + uint32_t POptSize; // 0x104, 68c0 + uint32_t IOptSize2; // 0x108, 68c4 + uint32_t POptSize2; // 0x10c, 68c8 + uint32_t GopSize; // 0x110, 68cc + uint32_t x68d0; // 0x114, 68d0 + uint32_t x68d4; // 0x118, 68d4 + uint32_t _D1; // 0x11c, 68d8 + uint32_t _D2; // 0x120, 68dc + uint32_t x68e0; // 0x124, 68e0 + uint32_t fullhd_30fps_gop_opt_0; // 0x128, 68e4 + uint32_t fullhd_30fps_gop_opt_1; // 0x12c, 68e8 + uint32_t fullhd_30fps_gop_opt_2; // 0x130, 68ec + uint32_t fullhd_30fps_gop_opt_3; // 0x134, 68f0 + uint32_t fullhd_30fps_gop_opt_4; // 0x138, 68f4 + uint32_t fullhd_25fps_gop_opt_0; // 0x13c, 68f8 + uint32_t fullhd_25fps_gop_opt_1; // 0x140, 68fc + uint32_t fullhd_25fps_gop_opt_2; // 0x144, 6900 + uint32_t fullhd_25fps_gop_opt_3; // 0x148, 6904 + uint32_t fullhd_25fps_gop_opt_4; // 0x14c, 6908 + uint32_t fullhd_24fps_gop_opt_0; // 0x150, 690c + uint32_t fullhd_24fps_gop_opt_1; // 0x154, 6910 + uint32_t fullhd_24fps_gop_opt_2; // 0x158, 6914 + uint32_t fullhd_24fps_gop_opt_3; // 0x15c, 6918 + uint32_t fullhd_24fps_gop_opt_4; // 0x160, 691c + uint32_t hd_60fps_gop_opt_0; // 0x164, 6920 + uint32_t hd_60fps_gop_opt_1; // 0x168, 6924 + uint32_t hd_60fps_gop_opt_2; // 0x16c, 6928 + uint32_t hd_60fps_gop_opt_3; // 0x170, 692c + uint32_t hd_60fps_gop_opt_4; // 0x174, 6930 + uint32_t hd_50fps_gop_opt_0; // 0x178, 6934 + uint32_t hd_50fps_gop_opt_1; // 0x17c, 6938 + uint32_t hd_50fps_gop_opt_2; // 0x180, 693c + uint32_t hd_50fps_gop_opt_3; // 0x184, 6940 + uint32_t hd_50fps_gop_opt_4; // 0x188, 6944 + uint32_t x6948; // 0x18c, 6948 + uint32_t x694c; // 0x190, 694c + uint32_t x6950; // 0x194, 6950 + uint32_t x6954; // 0x198, 6954 + uint32_t x6958; // 0x19c, 6958 + uint32_t x695c; // 0x1a0, 695c + uint32_t x6960; // 0x1a4, 6960 + uint32_t x6964; // 0x1a8, 6964 + uint32_t x6968; // 0x1ac, 6968 + uint32_t x696c; // 0x1b0, 696c + uint32_t vga_30fps_gop_opt_0; // 0x1b4, 6970 + uint32_t vga_30fps_gop_opt_1; // 0x1b8, 6974 + uint32_t vga_30fps_gop_opt_2; // 0x1bc, 6978 + uint32_t vga_30fps_gop_opt_3; // 0x1c0, 697c + uint32_t vga_30fps_gop_opt_4; // 0x1c4, 6980 + uint32_t vga_25fps_gop_opt_0; // 0x1c8, 6984 + uint32_t vga_25fps_gop_opt_1; // 0x1cc, 6988 + uint32_t vga_25fps_gop_opt_2; // 0x1d0, 698c + uint32_t vga_25fps_gop_opt_3; // 0x1d4, 6990 + uint32_t vga_25fps_gop_opt_4; // 0x1d8, 6994 +} __attribute__((aligned,packed)); + +//~ SIZE_CHECK_STRUCT( mvr_config, 0x30 ); + +extern struct mvr_config mvr_config; + + +// This is from 5D2, not used here. +/* + * + * State information is in this structure. A pointer to the global + * object is at 0x1ee0. It is of size 0x1b4. + * + * The state object is in 0x68a4. + */ +/*struct mvr_struct +{ + const char * type; // "MovieRecorder" off 0 + uint32_t off_0x04; + uint32_t task; // off_0x08; + uint32_t off_0x0c; + uint32_t off_0x10; + uint32_t off_0x14; + uint32_t off_0x18; + uint32_t off_0x1c; + uint32_t off_0x20; + uint32_t off_0x24; + uint32_t off_0x28; + uint32_t off_0x2c; + uint32_t off_0x30; + uint32_t off_0x34; + uint32_t off_0x38; + uint32_t off_0x3c; + uint32_t off_0x40; + uint32_t off_0x44; + uint32_t off_0x48; + uint32_t off_0x4c; + uint32_t off_0x50; + uint32_t off_0x54; + uint32_t off_0x58; + uint32_t off_0x5c; + uint32_t off_0x60; + uint32_t off_0x64; + uint32_t off_0x68; + uint32_t off_0x6c; + uint32_t off_0x70; + uint32_t off_0x74; + uint32_t off_0x78; + uint32_t off_0x7c; + uint32_t off_0x80; + uint32_t off_0x84; + uint32_t off_0x88; + uint32_t off_0x8c; + uint32_t off_0x90; + uint32_t off_0x94; + uint32_t off_0x98; + uint32_t off_0x9c; + uint32_t off_0xa0; + uint32_t off_0xa4; + uint32_t off_0xa8; + uint32_t off_0xac; + uint32_t off_0xb0; + uint32_t off_0xb4; + uint32_t off_0xb8; + uint32_t off_0xbc; + uint32_t off_0xc0; + uint32_t off_0xc4; + uint32_t off_0xc8; + uint32_t off_0xcc; + uint32_t off_0xd0; + uint32_t off_0xd4; + uint32_t off_0xd8; + uint32_t off_0xdc; + uint32_t off_0xe0; + uint32_t off_0xe4; + uint32_t off_0xe8; + uint32_t off_0xec; + uint32_t off_0xf0; + uint32_t off_0xf4; + uint32_t off_0xf8; + uint32_t off_0xfc; + uint32_t off_0x100; + uint32_t off_0x104; + uint32_t off_0x108; + uint32_t off_0x10c; + uint32_t off_0x110; + uint32_t off_0x114; + uint32_t off_0x118; + uint32_t off_0x11c; + uint32_t off_0x120; + uint32_t off_0x124; + uint32_t off_0x128; + uint32_t off_0x12c; + uint32_t off_0x130; + uint32_t off_0x134; + uint32_t off_0x138; + uint32_t off_0x13c; + uint32_t is_vga; // 0==1920, 1==640 off_0x140; + uint32_t off_0x144; + uint32_t off_0x148; + uint32_t fps; // 30, off_0x14c; + uint32_t width; // off_0x150; + uint32_t height; // off_0x154; + uint32_t audio_rec; // off_0x158; + uint32_t auido_channels; // 2 or 0, off_0x15c; + uint32_t audio_rate; // 44100 or 0, off_0x160; + uint32_t off_0x164; + uint32_t off_0x168; + uint32_t off_0x16c; + uint32_t off_0x170; + uint32_t off_0x174; + uint32_t off_0x178; + uint32_t off_0x17c; + uint32_t off_0x180; + uint32_t off_0x184; + uint32_t off_0x188; + uint32_t off_0x18c; + uint32_t bit_rate; // off_0x190; + uint32_t off_0x194; + uint32_t off_0x198; + uint32_t off_0x19c; + uint32_t off_0x1a0; + uint32_t off_0x1a4; + uint32_t off_0x1a8; + uint32_t off_0x1ac; + uint32_t off_0x1b0; + uint32_t off_0x1b4; + uint32_t off_0x1b8; + uint32_t off_0x1bc; + uint32_t off_0x1c0; + uint32_t off_0x1c4; + uint32_t off_0x1c8; + uint32_t off_0x1cc; + uint32_t off_0x1d0; + uint32_t off_0x1d4; + uint32_t off_0x1d8; + uint32_t off_0x1dc; + uint32_t off_0x1e0; + uint32_t off_0x1e4; + uint32_t off_0x1e8; + uint32_t off_0x1ec; + uint32_t off_0x1f0; + uint32_t off_0x1f4; + uint32_t off_0x1f8; + uint32_t off_0x1fc; +}; + +SIZE_CHECK_STRUCT( mvr_struct, 512 );*/ diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/EOSM.202/stubs.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/platform/EOSM.202/stubs.S Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,332 @@ +/** \file + * Entry points into the firmware image. + * + * These are the functions that we can call from our tasks + * in the Canon 1.0.6 firmware for the EOS M. + * + * This is a straight copy from the 5d3, EOS M stubs need found/verified still. + * + * \todo Sort this file? Generate it from the IDA map? + */ +/* + * Copyright (C) 2012 Magic Lantern Team + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include + +.text + +NSTUB( ROMBASEADDR, firmware_entry ) + +#define RAM_OFFSET 0xFFA69590 // some functions are copied to RAM at around ff0c009c; they have to be called from RAM... + +/** Startup **/ +NSTUB(0xFF0C1C10, cstart) +NSTUB(0xFFAA0468 - RAM_OFFSET, bzero32) +NSTUB(0xFFA6C448 - RAM_OFFSET, create_init_task) //2EB8 +NSTUB(0xFF0C5484, init_task) + //NSTUB( 0x468b8, additional_version) + +/** Misc **/ +NSTUB(0xC0220000, camera_engine) +NSTUB(0xFF132118, LoadCalendarFromRTC) +NSTUB(0xFFA89B5C - RAM_OFFSET, vsnprintf) //205CC + +/** File I/O **/ +NSTUB(0xFF346550, FIO_CreateFile) +NSTUB(0xFF346494, FIO_Open) +NSTUB(0xFF3468F4, FIO_CloseFile) +NSTUB(0xFF346824, FIO_SeekFile) +NSTUB(0xFF3466A4, FIO_ReadFile) +NSTUB(0xFF346844, FIO_WriteFile) +NSTUB(0xFF346A70, FIO_GetFileSize) +NSTUB(0xFF3465FC, FIO_RemoveFile) +NSTUB(0xFF347150, FIO_CreateDirectory) +NSTUB(0xFF347718, FIO_FindFirstEx) +NSTUB(0xFF34780C, FIO_FindNextEx) +NSTUB(0xFF3478EC, FIO_CleanupAfterFindNext_maybe) // proper name: FindClose +NSTUB(0xFF346F88, FIO_RenameFile) + +/** Bitmap **/ +NSTUB( 0x6D2B4, bmp_vram_info ) // look in SetBitmapVramAddress - as in 60D +NSTUB( 0x6BAB4, LCD_Palette) // in InitializeBitmapDisplayDevice, right after 0xc0f14800 + +/** Debug messages **/ +NSTUB( 0x3EC7C, dm_names) +NSTUB(0xFFA6D664 - RAM_OFFSET, DryosDebugMsg) +NSTUB(0xFFA6D9D0 - RAM_OFFSET, dm_set_store_level) +NSTUB(0xFFA6D968 - RAM_OFFSET, dm_set_print_level) + +/** Task sleep **/ +NSTUB(0xFFA70524 - RAM_OFFSET, msleep) //6F94 + +/** Semaphores **/ +NSTUB(0xFFA6FEE8 - RAM_OFFSET, create_named_semaphore) +NSTUB(0xFFA70048 - RAM_OFFSET, take_semaphore) +NSTUB(0xFFA70134 - RAM_OFFSET, give_semaphore) + + +/** Recursive locks **/ +NSTUB(0xFFA73E6C - RAM_OFFSET, CreateRecursiveLock) +NSTUB(0xFFA87CB8 - RAM_OFFSET, AcquireRecursiveLock) // AJ_KernelDry_KerRLock.c +NSTUB(0xFFA87D64 - RAM_OFFSET, ReleaseRecursiveLock) // AJ_KernelDry_KerRLock.c_p2 + +/** Message queues **/ +NSTUB(0xFFA73C84 - RAM_OFFSET, msg_queue_create) +NSTUB(0xFFA883D4 - RAM_OFFSET, msg_queue_post) //1EE44 +NSTUB(0xFFA881E8 - RAM_OFFSET, msg_queue_receive) //1EC58 +NSTUB(0xFFA88414 - RAM_OFFSET, msg_queue_count) // 0x1EE84 Above "!!!!!!! QUE Overflo" + + +/** Tasks **/ +NSTUB(0xFFA705D8 - RAM_OFFSET, task_create) +NSTUB( 0x3DD60, task_dispatch_hook ) +NSTUB(0xFFA758F0 - RAM_OFFSET, task_trampoline) + +/** Task info **/ +NSTUB(0x3F14C, task_max) +NSTUB(0xFFA6BABC - RAM_OFFSET, get_current_task) +NSTUB(0xFFA96530 - RAM_OFFSET, is_taskid_valid) // AJ_task_trampoline_related_p10 +NSTUB(0xFFA783FC - RAM_OFFSET, get_obj_attr) // AJ_checks_if_Process_id_created_by_Dryos + +/** Interrupts **/ +NSTUB(0xFF0C10E4, cli_save) +NSTUB(0xFF0C10F8, sei_restore) + +/** Eventprocs (call by name) **/ +NSTUB(0xFF137C1C, call) + +/** GUI **/ +NSTUB(0xFF0D7674, GUI_Control) +NSTUB(0xFF1A805C, SetGUIRequestMode) +NSTUB(0xFF0D72A0, gui_main_task) +NSTUB( 0x3E154, gui_main_struct) +NSTUB(0xFF0D7D18, gui_init_end) + //NSTUB(0xff1a4fc8, gui_massive_event_loop) +NSTUB( 0x58DA0, gui_task_list) + + +/** Dialog API **/ +NSTUB(0xFF4C3BC0, CreateDialogBox) +NSTUB(0xFF4C2B88, DeleteDialogBox) +NSTUB(0xFF4C48FC, dialog_redraw) +NSTUB(0xFF52F748, dialog_set_property_str) +NSTUB(0xFF4E4338, RedrawDisplay) + + /** Dialog handlers **/ + //NSTUB(0xff658aa8, LiveViewLevelApp_handler) + //NSTUB(0xFF623240, LiveViewWbApp_handler) +NSTUB(0xFF53A558, LiveViewApp_handler) +NSTUB(0xFF3BC078, PlayMain_handler) +NSTUB(0xFF5540E4, PlayMovieGuideApp_handler) +NSTUB(0xFF6A2E00, ErrCardForLVApp_handler) +NSTUB(0xFF520960, ErrForCamera_handler) // ERR70, ERR80 etc (DlgErrForCamera.c, AJ_DIALOG.HANDLER_DlgErrForCamera.c) +NSTUB(0xFF53800C, HideUnaviFeedBack_maybe) // look for StartUnaviFeedBackTimer +NSTUB(0xFF541BD4, ShootOlcApp_handler) // AJ_DIALOG.HANDLER_DlgShootOlcInfo.c +NSTUB(0xFF6FBD44, LiveViewShutterApp_handler) + + +/** Properties **/ +NSTUB(0xFF11F910, prop_register_slave) +NSTUB(0xFF12018C, _prop_cleanup) +NSTUB(0xFF1200C0, prop_deliver) +NSTUB(0xFF11FB04, _prop_request_change) +NSTUB(0xFF1202E8, prop_get_value) + + +/** Memory allocation **/ +NSTUB(0xFF0C8364, _malloc) +NSTUB(0xFF0C83BC, _free) // see "can't malloc" +NSTUB(0xFFA71468 - RAM_OFFSET, _AllocateMemory) +NSTUB(0xFFA71804 - RAM_OFFSET, _FreeMemory) +NSTUB(0xFFA8BB04 - RAM_OFFSET, _alloc_dma_memory) +NSTUB(0xFFA8BB38 - RAM_OFFSET, _free_dma_memory) +NSTUB(0xFFA71208 - RAM_OFFSET, GetMemoryInformation) + +/** ExMem **/ +NSTUB(0xFF13B7C0, AllocateMemoryResource) // m_pfAllocMemoryCBR +NSTUB(0xFF13B80C, AllocateContinuousMemoryResource) // m_pfContAllocMemoryCBR +NSTUB(0xFF13B924, FreeMemoryResource) // m_pfFreeMemoryCBR + +NSTUB(0xFFA72C98 - RAM_OFFSET, GetFirstChunkFromSuite) // AJ_PackMemory_PackMem_p3 +NSTUB(0xFFA73434 - RAM_OFFSET, GetNextMemoryChunk) +NSTUB(0xFFA72670 - RAM_OFFSET, GetMemoryAddressOfMemoryChunk) + +/** Engio **/ +NSTUB(0xFF2C19AC, _engio_write) +NSTUB(0xFF2C1730, shamem_read) // AJ_0x8FB0_engio_struct_n_R0_manipulation_to_get_ptr +NSTUB(0xFF2C1694, _EngDrvOut) // AJ_EngDrvOut_1xVar_to_ShadowStruct + +/** Edmac **/ +NSTUB(0x935C, CreateMemorySuite) +NSTUB(0x9154, DeleteMemorySuite) + +NSTUB(0x1C5FC, SetEDmac) +NSTUB(0x1C914, StartEDmac) +NSTUB(0x1CAA8, PopEDmac) //From popedmacformemorysuite +NSTUB(0x1CA60, AbortEDmac) +NSTUB(0x1C6A8, ConnectWriteEDmac) +NSTUB(0x1C76C, ConnectReadEDmac) + +/** keep the old name until all are refcatored **/ +NSTUB(0x1CB00, EDMAC_RegisterCompleteCBR) + +/** register/unregister CBR names **/ +NSTUB(0x1CB00, RegisterEDmacCompleteCBR) +NSTUB(0x1CBE8, RegisterEDmacAbortCBR) +NSTUB(0x1CC7C, RegisterEDmacPopCBR) +NSTUB(0x1CB3C, UnregisterEDmacCompleteCBR) +NSTUB(0x1CC24, UnregisterEDmacAbortCBR) +NSTUB(0x1CCB8 , UnregisterEDmacPopCBR) + +NSTUB(0xFF5FEE38, PackMem_SetEDmacForMemorySuite) +NSTUB(0xFF5FF1C0, PackMem_RegisterEDmacPopCBRForMemorySuite) +NSTUB(0xFF5FF124, PackMem_RegisterEDmacCompleteCBRForMemorySuite) +NSTUB(0xFF5FF25C, PackMem_RegisterEDmacAbortCBRForMemorySuite) + +NSTUB(0xFF5FEF4C, PackMem_StartEDmac) +NSTUB(0xFF5FF054, PackMem_PopEDmacForMemorySuite) + +/** PTP **/ +NSTUB(0xFF45FBDC, ptp_register_handler) + +/** Audio **/ +// NSTUB(0xFF130C94, _audio_ic_read) // Good Candidate i2c read +// NSTUB(0xFF339B00, _audio_ic_read) // Good Candidate i2c read + NSTUB(0xFF339ADC, _audio_ic_read) // Good Candidate i2c read + NSTUB(0xFF339490, _audio_ic_write) // str:i2c(int *array) + +NSTUB(0xFF339490, i2c_write) +#NSTUB(0xFF3463F8, i2c_read) +NSTUB(0xFF346230, i2c_read) +NSTUB(0xFF133DC0, send_audio) + +NSTUB(0xFF7FBBDC, audio_thresholds) +NSTUB( 0x3E46C, sounddev ) +NSTUB(0xFF10CD40, sounddev_task ) + + NSTUB(0xFF10D118, SoundDevActiveIn) + NSTUB(0xFF10D144, SoundDevActiveOut) + NSTUB(0xFF10D370, SoundDevShutDownIn) + + +/** ASIF **/ +NSTUB(0xFF1350F0, PowerAudioOutput) //Look for actrlCpowerControl Case 1 Sub +NSTUB(0xFF10AA48, StartASIFDMADAC) //~ Needs Patches Or +NSTUB(0xFF10ACC8, StopASIFDMADAC) //~ NormalStopAsif +NSTUB(0xFF10B378, SetNextASIFDACBuffer) // Int16 Regular +NSTUB(0xFF134504, SetSamplingRate ) +NSTUB(0xFF1330A0, SetAudioVolumeOut) + +NSTUB(0xFF10A674, StartASIFDMAADC) //~ To Regular +NSTUB(0xFF10A920, StopASIFDMAADC) //~ Regular +NSTUB(0xFF10B190, SetNextASIFADCBuffer) // Int16 +NSTUB(0xFF134CE4, PowerMicAmp) + + + +//NSTUB(0xFF2BF578, StartASIFDMADAC) //~ Direct +//NSTUB(0xFF111D74, StartASIFDMADAC) //~ SePlayStart + + + + +//NSTUB(0xFF10AC98, StopASIFDMADAC) //~ NormalStopAsif +//NSTUB(0xFF2BF754, StopASIFDMADAC) //~ ACTRL Direct +//NSTUB(0xFF4743D0, StopASIFDMADAC) //~ AsifStopCBR +//NSTUB(0xFF133CA0, StopASIFDMADAC) //~ StopPlayWavData +//NSTUB(0xFF111EE4, StopASIFDMADAC) //~ TouchSoundSePlayStop +//NSTUB(0xFF111D10, StopASIFDMADAC) //~ SeTerminate + //NSTUB(0xFF339938, StopASIFDMADAC) //~ Call Play Stop + +//NSTUB(0xFF2BFAEC, SetNextASIFDACBuffer) // Int16 Direct Control + + + +/** Making the card bootable (How?) **/ + // NSTUB(0x0, cfReadBlk) + // NSTUB(0x0, cf_device) idk... +//NSTUB(0xFF642910, sdReadBlk) +NSTUB( 0x606DC, sd_device) +NSTUB(0xFF4F8348, fsuDecodePartitionTable) // AJ_fsuGetPart_related + + +/* Electronic level - roll/pitch info */ + //NSTUB(0xFF1B4454, GUI_SetRollingPitchingLevelStatus) + +/* H264 Encoder */ +NSTUB(0xFF2C0968, mvrSetPrintMovieLog) +NSTUB(0xFF2C0378, mvrSetQscale) +NSTUB( 0x4C124, mvr_config) +NSTUB(0xFF2C0944, mvrFixQScale) +NSTUB(0xFF2C043C, mvrSetDefQScale) + +/* Touchscreen */ +NSTUB(0xFF334A98, touch_cbr_canon) + +/* Debugging */ + +NSTUB(0x2232C, TryPostEvent) +NSTUB(0x223B0 , TryPostEvent_end) + +NSTUB(0x21C4C, TryPostStageEvent) +NSTUB(0x21CD0, TryPostStageEvent_end) + + NSTUB(0x3E1C8, pre_isr_hook) + NSTUB(0x3E1CC, post_isr_hook) + + +/* Misc */ +NSTUB(0xFFA741D0 - RAM_OFFSET, dma_memcpy) +NSTUB(0xFF6818B4, GetCFnData) +NSTUB(0xFF681ACC, SetCFnData) + +/* ResLock */ +NSTUB(0xFF2C5848, CreateResLockEntry) +NSTUB(0xFF2C5D10, LockEngineResources) +NSTUB(0xFF2C5EB4, UnLockEngineResources) + + +/* Unused Some Are OldFW */ +//NSTUB(0xFF0D783C, GUI_ChangeMode) +//NSTUB(0xFF1BD13C, GUI_GetFirmVersion) +//NSTUB(0xFF32D348, MuteOff_0) +//NSTUB(0xFF32D300, MuteOn_0) +//NSTUB(0xFF1299C4, SetBitmapVramAddress) +//NSTUB(0xFF4C135C, ctrlman_dispatch_event) +//NSTUB(0xFF3420F4, register_func) +//NSTUB( 0x8D330, vram_info) + //NSTUB(0xff987200 - RAM_OFFSET, set_fps_maybe) +//NSTUB(0xFF1B4F70, Gui_SetSoundRecord) // Look for GUI_setsoundrec - Just changes prop +//NSTUB(0xFF143C18, copy_malloc_info_maybe) +//NSTUB(0xFF101E04, PD_RemoteRelease) +//NSTUB(0xFF19991C, ENCODE_StartEncodeJpeg) +//NSTUB(0xFF2A3378, ptpPropSetUILock) +//NSTUB(0xFF5B6688, lvae_setdispgain) +//NSTUB(0xFF0E5808, MVR_NotifyLvFrameTiming) +//NSTUB(0xFFA71D5C - RAM_OFFSET, GetRemainOfMemoryChunk) +//NSTUB(0xFFA71D8C - RAM_OFFSET, GetSizeOfMemoryChunk) +//NSTUB(0xFFA720C4 - RAM_OFFSET, GetSizeOfMemorySuite) +//NSTUB(0xFFA721A4 - RAM_OFFSET, GetNumberOfChunks) + +//FIND +//NSTUB(0x35700, MREQ_ISR) +//NSTUB(0x35784, SIO3_ISR) +//NSTUB(0x8FE4, register_interrupt) +//Unused diff -r 4b3129d5a739 -r 7a5ccc6c8531 platform/Makefile.platform.map --- a/platform/Makefile.platform.map Fri Sep 20 16:56:08 2013 +0300 +++ b/platform/Makefile.platform.map Sun Sep 22 11:41:50 2013 -0500 @@ -13,7 +13,7 @@ 650D.104 \ 6D.113 \ 7D_MASTER.203 \ - EOSM.106 \ + EOSM.202 \ 700D.111 \ 100D.100 diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/Makefile.src --- a/src/Makefile.src Fri Sep 20 16:56:08 2013 +0300 +++ b/src/Makefile.src Sun Sep 22 11:41:50 2013 -0500 @@ -123,8 +123,6 @@ gui-common.o \ chdk-gui_draw.o \ movtweaks.o \ - menuhelp.o \ - menuindex.o \ $(ML_AF_PATTERNS_OBJ) \ focus.o \ notify_box.o \ diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/af_patterns.h --- a/src/af_patterns.h Fri Sep 20 16:56:08 2013 +0300 +++ b/src/af_patterns.h Sun Sep 22 11:41:50 2013 -0500 @@ -48,7 +48,6 @@ #define AF_POINT_R 0x44c00 // Right #define AF_POINT_RR 0x44e00 // Right-right #define AF_POINT_RRR 0x45000 // Right-right-right -// ---------------------------------------------------- #elif defined(CONFIG_6D) #define AF_POINT_C 0x4A00 // Center @@ -82,6 +81,9 @@ */ + + +// ---------------------------------------------------- #else #define AF_POINT_C 0x0100 // Center #define AF_POINT_T 0x0200 // Top diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/all_features.h --- a/src/all_features.h Fri Sep 20 16:56:08 2013 +0300 +++ b/src/all_features.h Sun Sep 22 11:41:50 2013 -0500 @@ -225,6 +225,7 @@ #endif #define FEATURE_FORCE_HDMI_VGA + #define FEATURE_UNIWB_CORRECTION //~ #define FEATURE_DISPLAY_SHAKE // looks ugly :P diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/audio-ak.c --- a/src/audio-ak.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/audio-ak.c Sun Sep 22 11:41:50 2013 -0500 @@ -29,25 +29,25 @@ #include "gui.h" #include "audio-common.c" +//~ #ifdef CONFIG_7D +//~ #include +//~ #endif + static CONFIG_INT( "audio.dgain.l", dgain_l, 0 ); static CONFIG_INT( "audio.dgain.r", dgain_r, 0 ); static CONFIG_INT( "audio.mgain", mgain, 4 ); static CONFIG_INT( "audio.mic-power", mic_power, 1 ); static CONFIG_INT( "audio.o2gain", o2gain, 0 ); -//CONFIG_INT( "audio.mic-in", mic_in, 0 ); // not used any more? int audio_meters_are_drawn() { #ifdef FEATURE_AUDIO_METERS - if (!SOUND_RECORDING_ENABLED && !fps_should_record_wav()) + if (!SOUND_RECORDING_ENABLED && !fps_should_record_wav() + #ifdef FEATURE_NITRATE_WAV_RECORD + && !hibr_should_record_wav() + #endif + ) return 0; - -#if defined(CONFIG_7D) - if(!recording) - { - return 0; - } -#endif return ( @@ -208,6 +208,8 @@ #ifdef FEATURE_HEADPHONE_MONITORING static void audio_monitoring_update() { + + // kill video connect/disconnect event... or not *(int*)HOTPLUG_VIDEO_OUT_STATUS_ADDR = audio_monitoring ? 2 : 0; @@ -223,6 +225,10 @@ void audio_configure( int force ) { +#if defined(CONFIG_5D3) || defined(CONFIG_6D) //|| defined(CONFIG_EOSM) + return; +#endif + extern int beep_playing; if (beep_playing && !(audio_monitoring && AUDIO_MONITORING_HEADPHONES_CONNECTED)) return; // don't redirect wav playing to headphones if they are not connected @@ -637,6 +643,7 @@ "!!!!! %s started sem=%x", __func__, (uint32_t) sounddev.sem_alc + //~ (uint32_t) sounddev.sem_volume ); //DIY debug .. @@ -649,7 +656,28 @@ // Fake the sound dev task parameters sounddev.sem_alc = create_named_semaphore( 0, 0 ); + + /*7D Testing */ + //sem_alc is actually sem_volume. Both semaphores are created/required! + + //~ sounddev.sem_volume = create_named_semaphore( 0xFF5b6463, 0 ); + //~ sounddev.sem_volume = create_named_semaphore("SndDevNrTaskSemSignature", 0 ); + //~ sounddev.sem_alc = create_named_semaphore( 0xFF5b641b, 1 ); + //~ sounddev.sem_alc = create_named_semaphore( "SndDevNrCBRSemSignature", 1 ); + + //~ cache_fake(0xFF064438, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF0644C0, 0xE1A00000, TYPE_ICACHE); + + //~ cache_fake(0xFF064598, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF06499C, 0xE1A00000, TYPE_ICACHE); + + //~ sounddev.sem_volume = create_named_semaphore( 0, 0 ); + //~ sounddev.sem_alc = create_named_semaphore( 0, 1 ); + //~ void (*alvstart)() = 0xFF0640C8; //Meters + //~ alvstart(); + + //Will flood out 7D H264 buffer... some semaphore or event? sounddev_active_in(0,0); audio_configure( 1 ); // force it this time @@ -668,15 +696,21 @@ { // will be unlocked by the property handler int rc = take_semaphore( gain.sem, recording && MVR_FRAME_NUMBER < 30 ? 100 : 1000 ); + //~ int rc = take_semaphore( sounddev.sem_volume, recording && MVR_FRAME_NUMBER < 30 ? 100 : 1000 ); + //~ int rc = take_semaphore( sounddev.sem_volume, 0 ); if(gui_state != GUISTATE_PLAYMENU || (audio_monitoring && AUDIO_MONITORING_HEADPHONES_CONNECTED)) { audio_configure( rc == 0 ); // force it if we got the semaphore } } + } +#if !defined(CONFIG_600D) && !defined(CONFIG_DIGIC_V) && !defined(CONFIG_7D) TASK_OVERRIDE( sounddev_task, my_sounddev_task ); #endif +#endif + static void volume_display() { #ifdef FEATURE_DIGITAL_GAIN diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/audio-common.c --- a/src/audio-common.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/audio-common.c Sun Sep 22 11:41:50 2013 -0500 @@ -1,7 +1,7 @@ #define SOUND_RECORDING_ENABLED (sound_recording_mode != 1) // not 100% sure -#if defined(CONFIG_500D) || defined(CONFIG_5D3) || defined(CONFIG_7D) || defined(CONFIG_650D) || defined(CONFIG_700D) || defined(CONFIG_100D) +#if defined(CONFIG_500D) || defined(CONFIG_5D3) || defined(CONFIG_650D) || defined(CONFIG_700D) || defined(CONFIG_100D) int audio_thresholds[] = { 0x7fff, 0x7213, 0x65ab, 0x5a9d, 0x50c2, 0x47fa, 0x4026, 0x392c, 0x32f4, 0x2d6a, 0x2879, 0x2412, 0x2026, 0x1ca7, 0x1989, 0x16c2, 0x1449, 0x1214, 0x101d, 0xe5c, 0xccc, 0xb68, 0xa2a, 0x90f, 0x813, 0x732, 0x66a, 0x5b7, 0x518, 0x48a, 0x40c, 0x39b, 0x337, 0x2dd, 0x28d, 0x246, 0x207, 0x1ce, 0x19c, 0x16f, 0x147 }; #endif @@ -31,6 +31,7 @@ // Or on the scren #undef CONFIG_AUDIO_REG_BMP +#ifndef CONFIG_6D struct gain_struct { struct semaphore * sem; @@ -42,7 +43,7 @@ static struct gain_struct gain = { .sem = (void*) 1, }; - +#endif static CONFIG_INT( "audio.lovl", lovl, 0 ); static CONFIG_INT( "audio.alc-enable", alc_enable, 0 ); static int loopback = 1; @@ -58,7 +59,7 @@ { return audio_levels; } - +#ifdef CONFIG_600D // from linux snd_soc_update_bits() static void masked_audio_ic_write( unsigned reg, // the register we wish to manipulate (eg AUDIO_IC_SIG1) @@ -71,7 +72,7 @@ new = (old &~mask) | (bits & mask); _audio_ic_write(reg | new); // bitwise OR everything together and call _audio_ic_write function } - +#endif /** Returns a dB translated from the raw level * @@ -94,7 +95,7 @@ } #ifdef OSCOPE_METERS -void draw_meters(void) +void FAST draw_meters(void) { #define MAX_SAMPLES 720 static int16_t levels[ MAX_SAMPLES ]; @@ -157,7 +158,7 @@ } -static void +static void FAST draw_meter( int x_origin, int y_origin, @@ -216,7 +217,7 @@ } -static void +static void FAST draw_ticks( int x, int y, @@ -250,7 +251,7 @@ static int audio_cmd_to_gain_x1000(int cmd); /* Normal VU meter */ -static void draw_meters(void) +static void FAST draw_meters(void) { int screen_layout = get_screen_layout(); // The db values are multiplied by 8 to make them @@ -313,6 +314,8 @@ { #ifdef CONFIG_600D int dgain_x1000 = audio_cmd_to_gain_x1000(audio_ic_read(ML_ALC_TARGET_LEV-0x100)); +#elif defined(CONFIG_6D) + int dgain_x1000 = audio_cmd_to_gain_x1000(audio_ic_read(0xD)); #else int dgain_x1000 = audio_cmd_to_gain_x1000(audio_ic_read(AUDIO_IC_ALCVOL)); #endif @@ -357,6 +360,9 @@ level->peak = ( level->peak * 63 + level->avg ) / 64; level->peak_fast = ( level->peak_fast * 7 + level->avg ) / 8; } +#if defined(CONFIG_7D) || defined(CONFIG_6D) +static int setonce = 0; +#endif /** Task to monitor the audio levels. * @@ -369,7 +375,7 @@ meter_task( void* unused ) { -#ifdef CONFIG_600D +#if defined(CONFIG_600D) || defined(CONFIG_7D) || defined(CONFIG_6D) //initialize audio config for 600D audio_configure(1); #endif @@ -377,13 +383,44 @@ TASK_LOOP { msleep(DISPLAY_IS_ON ? 50 : 500); - + + //~ NotifyBox(1000, "%x", audio_meters_are_drawn()); + if (audio_meters_are_drawn()) { if (!is_mvr_buffer_almost_full()) BMP_LOCK( draw_meters(); ) + //~ #ifdef CONFIG_EOSM //And stay on! + //~ cache_fake(0xFF10ECF8, 0xE1A00000, TYPE_ICACHE); + //~ #endif + #ifdef CONFIG_6D + extern int audio_recording; + //~ static void (*FilterRec)() = 0xFF143638; + if (!recording && !audio_recording && !setonce) + { + //~ FilterRec(); + audio_configure(1); + setonce=1; + } + if (recording) //Do it again after movie end. + setonce = 0; + + #endif + #ifdef CONFIG_7D + extern int audio_recording; + static void (*FilterRec)() = 0xFF073F54; //Filter REC + if (!recording && !audio_recording && !setonce) + { FilterRec(); + audio_configure(1); + setonce=1; + } + if (recording) //Do it again after movie end. + setonce = 0; + #endif } - + #if defined(CONFIG_6D) || defined(CONFIG_7D) + else if (PLAY_OR_QR_MODE || MENU_MODE) { setonce=0; } + #endif if (audio_monitoring) { static int hp = 0; @@ -792,7 +829,6 @@ #else audio_configure( 1 ); #endif - //~ menu_set_dirty(); } static int get_input_source() @@ -924,7 +960,7 @@ // Movie recording stopped; (fallthrough) case 2: // Movie recording started - #ifdef CONFIG_600D + #if defined(CONFIG_600D) || defined(CONFIG_7D) || defined(CONFIG_6D) audio_configure(1); #else give_semaphore( gain.sem ); @@ -938,19 +974,23 @@ break; } } - +/* // to be called from some other tasks that may mess with audio static void audio_force_reconfigure() { give_semaphore( gain.sem ); } - +*/ static void enable_meters(int mode) { loopback = do_draw_meters = !mode; + //Allow Monitoing in deadview + #if defined(CONFIG_6D) || defined(CONFIG_7D) + if(!lv) loopback = 1; + #endif #if !defined(CONFIG_600D) - audio_configure( 1 ); + audio_configure( 1 ); #endif } @@ -959,7 +999,7 @@ PROP_HANDLER( PROP_LV_ACTION ) { const unsigned mode = buf[0]; - enable_meters( mode ); + enable_meters( mode ); } PROP_HANDLER( PROP_MVR_REC_START ) diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/audio-ng.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/audio-ng.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,556 @@ +/** \file + * Next Gen Audio... probably ak4950 + */ +/* + * Copyright (C) 2009 Trammell Hudson + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "dryos.h" +#include "bmp.h" +#include "config.h" +#include "property.h" +#include "menu.h" +#include "gui.h" +#include "audio-common.c" +extern void SelectMic(int var); +//~ extern void PowerMicAmp(); +//~ extern void SoundDevActiveIn(); +static CONFIG_INT( "audio.dgain.l", dgain_l, 0 ); +static CONFIG_INT( "audio.dgain.r", dgain_r, 0 ); +static CONFIG_INT( "audio.mgain", mgain, 4 ); +static CONFIG_INT( "audio.mic-power", mic_power, 1 ); +static CONFIG_INT( "audio.o2gain", o2gain, 0 ); + +int audio_meters_are_drawn() +{ +#ifdef FEATURE_AUDIO_METERS + if (!SOUND_RECORDING_ENABLED && !fps_should_record_wav() + #ifdef FEATURE_NITRATE_WAV_RECORD + && !hibr_should_record_wav() + #endif + ) + return 0; + + return + ( + is_movie_mode() && cfg_draw_meters && do_draw_meters && (zebra_should_run() || get_halfshutter_pressed()) && !gui_menu_shown() + ) + || + ( + gui_menu_shown() && is_menu_active("Audio") && cfg_draw_meters + ); +#else + return 0; +#endif +} + +#ifdef FEATURE_ANALOG_GAIN +static inline void +audio_ic_set_mgain( + unsigned index + ) +{ + + unsigned bits = mgain_index2bits(index); + bits &= 0x7; + unsigned sig1 = audio_ic_read( 0x82 ); + + sig1 &= ~0x3; + sig1 |= (bits & 1); + sig1 |= (bits & 4) >> 1; + audio_ic_write( AUDIO_IC_SIG1 | sig1 ); + //~ gain.sig1 = sig1; + + unsigned sig2 = audio_ic_read( 0x83 ); + sig2 &= ~(1<<5); + sig2 |= (bits & 2) << 4; + audio_ic_write( AUDIO_IC_SIG2 | sig2 ); + //~ gain.sig2 = sig2; + +} +#endif + +#ifdef FEATURE_DIGITAL_GAIN +//no support for anything but gain for now. +static inline void +audio_ic_set_input_volume( + int channel, + int gain + ) +{ + unsigned cmd = audio_gain_to_cmd( gain ); + if( channel ) + cmd |= AUDIO_IC_IVL; + else + cmd |= AUDIO_IC_IVR; + + audio_ic_write( cmd ); +} +#endif + +#ifdef FEATURE_MIC_POWER +static int get_mic_power(int input_source) +{ + return (input_source >= 2) ? mic_power : 1; +} +#endif + +#ifdef FEATURE_HEADPHONE_MONITORING +static void audio_monitoring_update() +{ + + + // kill video connect/disconnect event... or not + *(int*)HOTPLUG_VIDEO_OUT_STATUS_ADDR = audio_monitoring ? 2 : 0; + + if (audio_monitoring && rca_monitor) + { + audio_monitoring_force_display(0); + msleep(1000); + audio_monitoring_display_headphones_connected_or_not(); + } +} +#endif + +void +audio_configure( int force ) +{ + + extern int beep_playing; + if (beep_playing && !(audio_monitoring && AUDIO_MONITORING_HEADPHONES_CONNECTED)) + return; // don't redirect wav playing to headphones if they are not connected + +#ifdef CONFIG_AUDIO_REG_LOG + audio_reg_dump( force ); + return; +#endif +#ifdef CONFIG_AUDIO_REG_BMP + audio_reg_dump_screen(); + return; +#endif + +#if defined(CONFIG_AUDIO_CONTROLS) && !defined(CONFIG_500D) + // redirect wav playing to headphones if they are connected + int loopback0 = beep_playing ? 0 : loopback; +#endif + + + audio_set_meterlabel(); + +#ifdef CONFIG_AUDIO_CONTROLS + int pm3[] = { 0x00, 0x05, 0x07, 0x11 }; //should this be in a header file? + + //Set audio rec mode (or internal is muted) + MEM(0x757A4) = 0; + + //Power Mic Again + SelectMic(0); + + //Change Power register to ALL on. + audio_ic_write( 0x806D ); // power up ADC and DAC LO + + + //~ audio_ic_write( 0x1101 ); // Bypass filters + //~ audio_ic_write( 0x88ED ); // +/* + static int command[2]; + command[0] = 0x006d0000; + command[1] = 0xFFFFFFFF; + void (*SerialCommand_Send)(int *var2) = 0xFF1422B0; //6D + SerialCommand_Send(&command); +*/ + + int input_source = get_input_source(); + +#ifdef FEATURE_MIC_POWER + //mic_power is forced on if input source is 0 or 1 + int mic_pow = get_mic_power(input_source); +#endif + + audio_ic_write( AUDIO_IC_SIG1 + | 0x10 + | ( mic_pow ? 0x4 : 0x0 ) + ); // power up, no gain + audio_ic_write( AUDIO_IC_SIG2 + | 0x04 // external, no gain + | ( lovl & 0x3) << 0 // line output level + ); + + + //PM3 is set according to the input choice +audio_ic_write( AUDIO_IC_PM3 | pm3[input_source] ); + + static int alc; + alc = alc_enable ? (1<<5) : 0; + audio_ic_write( AUDIO_IC_ALC1 | alc ); // disable all ALC + +#ifdef FEATURE_DIGITAL_GAIN + // Control left/right gain independently + audio_ic_write( AUDIO_IC_MODE4 | 0x00 ); + + audio_ic_set_input_volume( 0, dgain_r ); + audio_ic_set_input_volume( 1, dgain_l ); +#endif + +#ifdef FEATURE_ANALOG_GAIN + audio_ic_set_mgain( mgain ); +#endif +/* These need more configuration + //HPF Filter, disable other filter blocks + audio_ic_write( AUDIO_IC_FIL1 | (enable_filters ? 0x1 : 0)); +*/ + + + // Enable loop mode and output digital volume2 + uint32_t mode3 = audio_ic_read( 0x8E ); + mode3 &= ~0x5C; // disable loop, olvc, datt0/1 + audio_ic_write( AUDIO_IC_MODE3 + | mode3 // old value + | loopback0 << 6 // loop mode + | (o2gain & 0x3) << 2 // output volume + ); + + #ifdef FEATURE_HEADPHONE_MONITORING + audio_monitoring_update(); + #endif + +#endif +} +static inline unsigned mgain_index2gain(int index) // sorted mgain values +{ + static uint8_t gains[] = { 0, 10, 17, 20, 23, 26, 29, 32 }; + return gains[index & 0x7]; +} +static inline unsigned mgain_index2bits(int index) // sorted mgain values +{ + static uint8_t bitsv[] = { 0, 0x4, 0x5, 0x01, 0x06, 0x02, 0x07, 0x03 }; + return bitsv[index & 0x7]; +} + + + + +static inline uint8_t +audio_gain_to_cmd( + int gain + ) +{ + unsigned cmd = ( gain * 1000 ) / 375 + 145; + cmd &= 0xFF; + + return cmd; +} + + +static void +audio_3bit_toggle( void * priv, int delta ) +{ + unsigned * ptr = priv; + *ptr = (*ptr + delta) & 0x3; + audio_configure( 1 ); +} + +static void +audio_binary_toggle( void * priv, int delta ) +{ + unsigned * ptr = priv; + *ptr = !*ptr; + audio_configure( 1 ); +} + +#ifdef FEATURE_ANALOG_GAIN +static void +audio_mgain_toggle( void * priv, int delta ) +{ + unsigned * ptr = priv; + *ptr = (*ptr + delta) & 0x7; + audio_configure( 1 ); +} + +#endif + +#ifdef FEATURE_DIGITAL_GAIN +static inline void +audio_dgain_toggle_reverse( void * priv, int delta ) +{ + unsigned dgain = *(unsigned*) priv; + if( dgain <= 0 ) { + dgain = 36; + } else { + dgain -= 6; + } + *(unsigned*) priv = dgain; + audio_configure( 1 ); +} +static void +audio_dgain_toggle( void * priv, int delta ) +{ + if (delta < 0) // will the compiler optimize it? :) + { + audio_dgain_toggle_reverse( priv, delta ); + return; + } + unsigned dgain = *(unsigned*) priv; + dgain += 6; + if( dgain > 40 ) + dgain = 0; + *(unsigned*) priv = dgain; + audio_configure( 1 ); +} + +static MENU_UPDATE_FUNC(audio_dgain_display) +{ + unsigned val = CURRENT_VALUE; + MENU_SET_VALUE("%d dB", val); + if (alc_enable) + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "AGC is enabled."); + MENU_SET_ENABLED(val); +} +#endif + +#ifdef FEATURE_HEADPHONE_OUTPUT_VOLUME +static MENU_UPDATE_FUNC(audio_lovl_display) +{ + if (!audio_monitoring) + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Headphone monitoring is disabled"); +} +#endif + +#ifdef FEATURE_INPUT_SOURCE +static void +audio_input_toggle( void * priv, int delta ) +{ + menu_numeric_toggle(priv, delta, 0, 4); + audio_configure( 1 ); +} +#endif + +#ifdef FEATURE_MIC_POWER +static MENU_UPDATE_FUNC(audio_micpower_display) +{ + int mic_pow = get_mic_power(get_input_source()); + MENU_SET_RINFO( + mic_pow ? "Low Z" : "High Z" + ); + + if (get_input_source() < 2) + { + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "Mic power is required by internal mic, can't turn off."); + } +} +#endif + +static struct menu_entry audio_menus[] = { + #ifdef FEATURE_ANALOG_GAIN + { + .name = "Analog Gain", + .priv = &mgain, + .select = audio_mgain_toggle, + .icon_type = IT_PERCENT_OFF, + .max = 7, + .choices = (const char *[]) {"0 dB", "10 dB", "17 dB", "20 dB", "23 dB", "26 dB", "29 dB", "32 dB"}, + .help = "Gain applied to both inputs in analog domain (preferred).", + .depends_on = DEP_SOUND_RECORDING, + .edit_mode = EM_MANY_VALUES, + }, + #endif + #ifdef FEATURE_DIGITAL_GAIN + { + .name = "Digital Gain", + .select = menu_open_submenu, + .help = "Digital gain (not recommended, use only for headphones!)", + .depends_on = DEP_SOUND_RECORDING, + .children = (struct menu_entry[]) { + { + .name = "Left Digital Gain", + .priv = &dgain_l, + .max = 36, + .icon_type = IT_PERCENT_OFF, + .select = audio_dgain_toggle, + .update = audio_dgain_display, + .help = "Digital gain (LEFT). Any nonzero value reduces quality.", + }, + { + .name = "Right Digital Gain", + .priv = &dgain_r, + .max = 36, + .icon_type = IT_PERCENT_OFF, + .select = audio_dgain_toggle, + .update = audio_dgain_display, + .help = "Digital gain (RIGHT). Any nonzero value reduces quality.", + }, + #ifdef FEATURE_AGC_TOGGLE + { + .name = "AGC", + .priv = &alc_enable, + .select = audio_binary_toggle, + .max = 1, + .help = "Automatic Gain Control - turn it off :)", + }, + #endif + MENU_EOL, + }, + }, + #endif + #ifdef FEATURE_INPUT_SOURCE + { + .name = "Input source", + .priv = &input_choice, + .select = audio_input_toggle, + .icon_type = IT_DICE, + .max = 4, + .choices = (const char *[]) {"Internal mic", "L:int R:ext", "External stereo", "L:int R:balanced", "Auto int/ext"}, + .help = "Audio input: internal / external / both / balanced / auto.", + .depends_on = DEP_SOUND_RECORDING, + }, + #endif + + #ifdef FEATURE_WIND_FILTER + { + .name = "Wind Filter", + .priv = &enable_filters, + .help = "High pass filter for wind noise reduction.", + .select = audio_binary_toggle, + .max = 1, + .depends_on = DEP_SOUND_RECORDING, + }, + #endif + + #ifdef CONFIG_AUDIO_REG_LOG + { + .name = "Close register log", + .select = audio_reg_close, + }, + #endif + + #ifdef FEATURE_MIC_POWER + { + .name = "Mic Power", + .priv = &mic_power, + .select = audio_binary_toggle, + .update = audio_micpower_display, + .max = 1, + .help = "Needed for int. and some other mics, but lowers impedance.", + .depends_on = DEP_SOUND_RECORDING, + }, + #endif + + + #ifdef FEATURE_HEADPHONE_MONITORING + { + .name = "Headphone Mon.", + .priv = &audio_monitoring, + .select = audio_monitoring_toggle, + .max = 1, + .help = "Monitoring via A-V jack. Disable if you use a SD display.", + .depends_on = DEP_SOUND_RECORDING, + }, + #ifdef FEATURE_HEADPHONE_OUTPUT_VOLUME + { + .name = "Headphone Volume", + .priv = &lovl, + .select = audio_3bit_toggle, + .update = audio_lovl_display, + .max = 3, + .icon_type = IT_PERCENT_OFF, + .choices = (const char *[]) {"0 dB", "2 dB (digital)", "4 dB (digital)", "6 dB (digital)"}, + .help = "Output volume for audio monitoring (headphones only).", + .depends_on = DEP_SOUND_RECORDING, + }, + #endif + #endif +}; + + +static void volume_display() +{ + #ifdef FEATURE_DIGITAL_GAIN + int mgain_db = mgain_index2gain(mgain); + NotifyBox(2000, "Volume: %d + (%d,%d) dB", mgain_db, dgain_l, dgain_r); + #elif defined(FEATURE_ANALOG_GAIN) + int mgain_db = mgain_index2gain(mgain); + NotifyBox(2000, "Volume: %d dB", mgain_db); + #endif +} + +#ifdef FEATURE_ANALOG_GAIN +void volume_up() +{ + int mgain_db = mgain_index2gain(mgain); + if (mgain_db < 32) + audio_mgain_toggle(&mgain, 1); + #ifdef FEATURE_DIGITAL_GAIN + else + { + if( MAX(dgain_l, dgain_r) + 6 <= 40 ) + { + audio_dgain_toggle(&dgain_l, 1); + audio_dgain_toggle(&dgain_r, 1); + } + } + #endif + volume_display(); +} + +void volume_down() +{ + int mgain_db = mgain_index2gain(mgain); + + #ifdef FEATURE_DIGITAL_GAIN + if( MIN(dgain_l, dgain_r) > 0 ) + { + audio_dgain_toggle(&dgain_l, -1); + audio_dgain_toggle(&dgain_r, -1); + } + else + #endif + if (mgain_db > 0) + audio_mgain_toggle(&mgain, -1); + volume_display(); +} +#endif + +static void out_volume_display() +{ + //int mgain_db = mgain_index2gain(mgain); + NotifyBox(2000, "Out Volume: %d dB", 2 * lovl); +} +void out_volume_up() +{ + int* p = (int*) &lovl; + *p = COERCE(*p + 1, 0, 3); + audio_configure( 1 ); + out_volume_display(); +} +void out_volume_down() +{ + int* p = (int*) &lovl; + *p = COERCE(*p - 1, 0, 3); + audio_configure( 1 ); + out_volume_display(); +} + + +static void audio_menus_init() +{ + menu_add( "Audio", audio_menus, COUNT(audio_menus) ); +} + + +INIT_FUNC("audio.init", audio_menus_init); diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/audio.h --- a/src/audio.h Fri Sep 20 16:56:08 2013 +0300 +++ b/src/audio.h Sun Sep 22 11:41:50 2013 -0500 @@ -25,7 +25,7 @@ #define _audio_h_ #include "compiler.h" - +#ifndef CONFIG_6D //Unused /* * Audio information structure at 0x7324. * This controls the AGC system. @@ -101,7 +101,7 @@ SIZE_CHECK_STRUCT( sounddev, 0x74 ); extern struct sounddev sounddev; - +#endif // Calls the unlock function when done if non-zero extern void sounddev_active_in( @@ -122,12 +122,21 @@ unsigned cmd, unsigned * result ); - +#ifdef CONFIG_DIGIC_V +extern void +_audio_ic_write( + int *cmd +); +#else extern void _audio_ic_write( unsigned cmd ); +#endif +#ifdef CONFIG_6D +//~ static void msleep(int msec){} +#endif static inline uint8_t audio_ic_read( unsigned cmd @@ -135,8 +144,17 @@ { unsigned value = 0; //uint32_t flags = cli(); + #ifdef CONFIG_DIGIC_V + //~ cmd = cmd >> 8; + #endif _audio_ic_read( cmd, &value ); + + #ifdef CONFIG_6D + msleep(10); + _audio_ic_read( cmd, &value ); + #endif //sei( flags ); + //~ msleep(50); return value; } @@ -145,9 +163,20 @@ unsigned cmd ) { + + #ifdef CONFIG_DIGIC_V + static int command[2]; + command[0] = cmd << 8 << 8; + command[1] = 0xFFFFFFFF; + //~ cmd = cmd << 8 << 8; + _audio_ic_write( command ); + + + #else //uint32_t flags = cli(); _audio_ic_write( cmd ); //sei( flags ); + #endif } @@ -576,6 +605,24 @@ #define AUDIO_IC_SIG4 0x3000 #define AUDIO_IC_FIL1 0x3100 + #elif defined(CONFIG_6D) + #define AUDIO_IC_PM1 0x8000 + #define AUDIO_IC_PM2 0x8100 + + #define AUDIO_IC_SIG1 0x8200 + #define AUDIO_IC_SIG2 0x8300 + + #define AUDIO_IC_MODE3 0x8E00 + #define AUDIO_IC_PM3 0x9000 + #define AUDIO_IC_ALCVOL 0x8D00 + #define AUDIO_IC_ALC1 0x8700 + + #define AUDIO_IC_IVL 0x8900 + #define AUDIO_IC_IVR 0x8C00 + #define AUDIO_IC_MODE4 0x8F00 + + #define AUDIO_IC_FIL1 0x9100 + #else //CONFIG_500D else #define AUDIO_IC_PM1 0x2000 diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/beep.c --- a/src/beep.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/beep.c Sun Sep 22 11:41:50 2013 -0500 @@ -5,7 +5,10 @@ #include "config.h" #define _beep_c_ #include "property.h" + +#ifdef CONFIG_6D #include "cache_hacks.h" +#endif extern int gui_state; extern int file_number; @@ -39,18 +42,36 @@ static void asif_stopped_cbr() { beep_playing = 0; + #ifdef CONFIG_7D // ReEnable Meter + static void (*FilterRec)() = 0xFF073F54; //Filter REC + FilterRec(); + #endif audio_configure(1); + + // Restart Mics if disabled by play. + /* #ifdef CONFIG_6D + if (!recording && (hibr_should_record_wav() || SOUND_RECORDING_ENABLED) ) + PowerMicAmp(); + #endif */ + } + static void asif_stop_cbr() -{ +{ StopASIFDMADAC(asif_stopped_cbr, 0); audio_configure(1); + } static void play_beep(int16_t* buf, int N) { - beep_playing = 1; + #ifdef CONFIG_6D + if (recording && !raw_lv_is_enabled()) + return; + #endif + beep_playing = 1; SetSamplingRate(48000, 1); MEM(0xC0920210) = 4; // SetASIFDACModeSingleINT16 + //~ call("SetASIFDACModeSingleINT16"); PowerAudioOutput(); audio_configure(1); SetAudioVolumeOut(COERCE(beep_volume, 1, ASIF_MAX_VOL)); @@ -59,9 +80,16 @@ static void play_beep_ex(int16_t* buf, int N, int sample_rate) { - beep_playing = 1; + #ifdef CONFIG_6D + if (recording && !raw_lv_is_enabled()) + return; + #endif + + beep_playing = 1; SetSamplingRate(sample_rate, 1); MEM(0xC0920210) = 4; // SetASIFDACModeSingleINT16 + //~ MEM(0xC0920210) = 3; // SetASIFDACModeSingleINT16 + //~ call("SetASIFDACModeSingleINT16"); PowerAudioOutput(); audio_configure(1); SetAudioVolumeOut(COERCE(beep_volume, 1, ASIF_MAX_VOL)); @@ -82,7 +110,7 @@ #ifndef FEATURE_BEEP #error This requires FEATURE_BEEP. #endif - +/* This is stereo header not mono */ // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ // http://www.sonicspot.com/guide/wavefiles.html static uint8_t wav_header[44] = { @@ -92,10 +120,10 @@ 0x66, 0x6d, 0x74, 0x20, // fmt 0x10, 0x00, 0x00, 0x00, // subchunk size = 16 0x01, 0x00, // PCM uncompressed - 0x01, 0x00, // mono + 0x02, 0x00, // Stereo 0x80, 0xbb, 0x00, 0x00, // 48000 Hz - 0x00, 0x77, 0x01, 0x00, // 96000 bytes / second - 0x02, 0x00, // 2 bytes / sample + 0x00, 0xee, 0x02, 0x00, // 192000 bytes / second + 0x04, 0x00, // 4 bytes / sample 0x10, 0x00, // 16 bits / sample 0x64, 0x61, 0x74, 0x61, // data 0xff, 0xff, 0xff, 0xff, // data size (bytes) @@ -183,6 +211,7 @@ { uint8_t* buf1 = (uint8_t*)(wav_buf[0]); uint8_t* buf2 = (uint8_t*)(wav_buf[1]); + if (!buf1) return; if (!buf2) return; @@ -210,7 +239,6 @@ uint8_t* data = buf1 + data_offset + 8; int N1 = s1 - data_offset - 8; int N2 = s2; - beep_playing = 1; SetSamplingRate(sample_rate, 1); // 1 = mono uint8 @@ -238,7 +266,7 @@ file = INVALID_PTR; } -static int audio_recording = 0; +int audio_recording = 0; static int audio_recording_start_time = 0; static void asif_rec_stop_cbr() { @@ -315,6 +343,7 @@ { info_led_on(); audio_recording = 2; // the CBR will stop recording and close the file properly + while (audio_recording) msleep(100); ASSERT(file == INVALID_PTR); } @@ -361,13 +390,26 @@ tmpq->buf = alloc_dma_memory(WAV_BUF_SIZE*QBUF_SIZE); } int offset = WAV_BUF_SIZE * tmpq->multiplex; + #ifdef CONFIG_EDMAC_MEMCPY + edmac_memcpy(tmpq->buf + offset,buf,WAV_BUF_SIZE); + #elif defined(CONFIG_DMA_MEMCPY) + dma_memcpy(tmpq->buf + offset,buf,WAV_BUF_SIZE); + #else memcpy(tmpq->buf + offset,buf,WAV_BUF_SIZE); + #endif + tmpq->multiplex++; }else{ newq = SmallAlloc(sizeof(WRITE_Q)); memset(newq,0,sizeof(WRITE_Q)); newq->buf = alloc_dma_memory(WAV_BUF_SIZE*QBUF_SIZE); + #ifdef CONFIG_EDMAC_MEMCPY + edmac_memcpy(newq->buf ,buf,WAV_BUF_SIZE); + #elif defined(CONFIG_DMA_MEMCPY) + dma_memcpy(newq->buf ,buf,WAV_BUF_SIZE); + #else memcpy(newq->buf ,buf,WAV_BUF_SIZE); + #endif newq->multiplex++; tmpq->next = newq; } @@ -403,10 +445,10 @@ file = INVALID_PTR; audio_recording = 0; info_led_off(); -#ifdef CONFIG_6D + #ifdef CONFIG_6D void StopASIFDMAADC(); StopASIFDMAADC(asif_rec_stop_cbr, 0); -#endif + #endif return; } SetNextASIFADCBuffer(buf, WAV_BUF_SIZE); @@ -427,16 +469,18 @@ audio_recording = 1; audio_recording_start_time = get_seconds_clock(); +//~ #if defined(CONFIG_6D) || defined(CONFIG_EOSM) + /* experimental for 6D now, has to be made generic */ + /* Enable audio Device */ + //~ void PowerMicAmp(); // If something turned it off. + //~ PowerMicAmp(); + //~ extern int mic_inserted; + //~ void SoundDevActiveIn (uint32_t); + //~ SoundDevActiveIn(mic_inserted ? 1 : 0); +//~ #endif -#if defined(CONFIG_7D) || defined(CONFIG_6D) || defined(CONFIG_EOSM) - /* experimental for 7D now, has to be made generic */ - /* Enable audio Device */ - void SoundDevActiveIn (uint32_t); - SoundDevActiveIn(0); -#endif - - SetSamplingRate(48000, 1); - MEM(0xC092011C) = 4; // SetASIFADCModeSingleINT16 + SetSamplingRate(48000, 3); //StereoUint8 + MEM(0xC092011C) = 6; // StereoINT16 wav_ibuf = 0; @@ -446,12 +490,12 @@ msleep(100); if (show_progress) record_show_progress(); } -#if defined(CONFIG_7D) || defined(CONFIG_6D) || defined(CONFIG_EOSM) - /* experimental for 7D now, has to be made generic */ +//~ #if defined(CONFIG_6D) || defined(CONFIG_EOSM) + /* experimental for 6D now, has to be made generic */ /* Disable Audio */ - void SoundDevShutDownIn(); - SoundDevShutDownIn(); -#endif + //~ void SoundDevShutDownIn(); + //~ SoundDevShutDownIn(); +//~ #endif info_led_off(); } @@ -717,7 +761,7 @@ SmallFree(beep_buf); } msleep(100); - audio_configure(1); + audio_configure(1); } } @@ -918,7 +962,7 @@ int handle_voice_tags(struct event * event) { if (!voice_tags) return 1; - if (event->param == BGMT_PRESS_SET) + if (event->param == BGMT_UNPRESS_SET) // Its missing press event? Why? { if (audio_recording) { @@ -940,7 +984,7 @@ #ifdef FEATURE_WAV_RECORDING PROP_HANDLER( PROP_MVR_REC_START ) { - if (!fps_should_record_wav() && !hibr_should_record_wav()) return; + if ((!fps_should_record_wav() && !hibr_should_record_wav()) || raw_lv_is_enabled()) return; int rec = buf[0]; if (rec == 1) { @@ -1070,13 +1114,64 @@ #endif static void beep_init() -{ +{ #ifdef CONFIG_6D cache_fake(HIJACK_ASIF_DAC_TIMEOUT, NOP_INSTR, TYPE_ICACHE); //~ FF11CD44 Assert This. Does it not stop properly? cache_fake(HIJACK_ASIF_KILL_SEM_WAIT, NOP_INSTR, TYPE_ICACHE); //~ Kill Wait for Semaphore cache_fake(HIJACK_ASIF_ADC_TIMEOUT, NOP_INSTR, TYPE_ICACHE); //~ FF11C99C ADC ASSERT cache_fake(HIJACK_ASIF_KILL_SEM_WAIT2, NOP_INSTR, TYPE_ICACHE); //~ FF11C910 ADC Semaphore - cache_fake(HIJACK_ASIF_CONT_JUMP_ADDR, HIJACK_ASIF_CONT_JUMP_INSTR, TYPE_ICACHE); //~ FF11C910 ADC Continue Jump Assert, change BEQ to B + cache_fake(HIJACK_ASIF_CONT_JUMP_ADDR, HIJACK_ASIF_CONT_JUMP_INSTR, TYPE_ICACHE); //~ CMP R0,R0 + cache_fake(HIJACK_ASIF_NEXT_BUFF, HIJACK_ASIF_CONT_JUMP_INSTR, TYPE_ICACHE); //~ CMP R0, R0 +#endif +//~ #ifdef CONFIG_EOSM +#if 0 + + cache_fake(0xFF10ADE8, NOP_INSTR, TYPE_ICACHE); //~ Assert 486 + cache_fake(0xFF10AD98, NOP_INSTR, TYPE_ICACHE); //~ BNE, ERR END + + //~ cache_fake(0xFF10AD20, NOP_INSTR, TYPE_ICACHE); //~ PostEvent + //~ cache_fake(0xFF10AD5C, NOP_INSTR, TYPE_ICACHE); //~ Semaphore + + //~ cache_fake(0xFF10AAE8, NOP_INSTR, TYPE_ICACHE); //~ PostEv Start + //~ cache_fake(0xFF10AB3C, NOP_INSTR, TYPE_ICACHE); //~ Semaphore Start + + cache_fake(0xFF1330F8, NOP_INSTR, TYPE_ICACHE); //~ Semaphore Vol + cache_fake(0xFF13314C, NOP_INSTR, TYPE_ICACHE); //~ G Semaphore Vol + + + //DAC + //FF10AD64 CMP R1, R1 + //~ cache_fake(0xFF10AD64 , 0xE1510001, TYPE_ICACHE); + + //FF10ACF4 CMP R0, R0 + //~ cache_fake(0xFF10ACF4 , 0xE1500000, TYPE_ICACHE); + + //FF10AD30 CMP R0, R0 + //~ cache_fake(0xFF10ACF4 , 0xE1500000, TYPE_ICACHE); + + //~ Kill Wait for Semaphore + //~ cache_fake(0xFF10AD2C, 0xE1A00000, TYPE_ICACHE); + + //DirectSem + //~ cache_fake(0xFF2BF7FC, 0xE1A00000, TYPE_ICACHE); + + //Start Semaphore + //~ cache_fake(0xFF10AB0C, 0xE1A00000, TYPE_ICACHE); + + + + //~ FF11CD44 Assert This. Does it not stop properly? + //~ cache_fake(0xFF10ADB8, 0xE1A00000, TYPE_ICACHE); + //~ Kill Wait for Semaphore + //~ cache_fake(0xFF10AD2C , 0xE1A00000, TYPE_ICACHE); + //FF11C99C ADC ASSERT + //~ cache_fake(0xFF10AA10 , 0xE1A00000, TYPE_ICACHE); + //FF11C910 ADC Semaphore + //~ cache_fake(0xFF10A984 , 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF4744C8 , 0xE1A00000, TYPE_ICACHE); + + //FF11C910 ADC Continue Jump Assert + //~ cache_fake(0xFF2AC5E0, 0xEA000009, TYPE_ICACHE); #endif #ifdef FEATURE_WAV_RECORDING @@ -1124,9 +1219,10 @@ void Beep(){} void beep_times(int times){}; int beep_enabled = 0; +#if defined(CONFIG_EOSM) || defined(CONFIG_50D) void WAV_StartRecord(char* filename){}; void WAV_StopRecord(){}; +#endif void beep_custom(int duration, int frequency, int wait) {} #endif - diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/bitrate-5d3.c --- a/src/bitrate-5d3.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/bitrate-5d3.c Sun Sep 22 11:41:50 2013 -0500 @@ -173,3 +173,4 @@ ) } } + diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/bitrate-6d.c --- a/src/bitrate-6d.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/bitrate-6d.c Sun Sep 22 11:41:50 2013 -0500 @@ -19,9 +19,7 @@ static CONFIG_INT("h264.flush", bitrate_flushing_rate, 3); static CONFIG_INT("h264.gop", bitrate_gop_size, 0); static CONFIG_INT( "time.indicator", time_indicator, 1); // 0 = off, 1 = current clip length, 2 = time remaining until filling the card, 3 = time remaining until 4GB -static CONFIG_INT( "bitrate.indicator", bitrate_indicator, 1); static CONFIG_INT( "hibr.wav.record", cfg_hibr_wav_record, 0); - PROP_INT(PROP_REBOOT_MAYBE, rebootnow); PROP_INT(PROP_MOVIE_SOUND_RECORD, sound); #ifndef CONFIG_5D3 @@ -46,17 +44,6 @@ #ifdef FEATURE_NITRATE_WAV_RECORD int hibr_should_record_wav() { return cfg_hibr_wav_record; } -static CONFIG_INT("snd.inputvol", input_vol, 36); -static int powered_input = 0; -void SoundDevActiveIn(); -void SoundDevShutDownIn(); -void SetAudioVolumeIn(); -extern int mic_inserted; -//~ uint8_t sound_level[3]; -//~ PROP_HANDLER(PROP_MOVIE_REC_VOLUME) -//~ { - //~ memcpy(sound_level, buf, 4); -//~ } #else int hibr_should_record_wav() { return 0; } #endif @@ -78,6 +65,9 @@ #endif +#define override (autoload == 2) +#define config_loaded (ivaparam == 1) +#define config_disabled (ivaparam == 2) /* static void patch_flush_errors() @@ -112,7 +102,7 @@ //FF1F4C7C - FF1F4C10 //~ cache_fake(0xFF1F4C7C , 0xE1A00000, TYPE_ICACHE); //~ cache_fake(0xFF1F4C7C , 0xE1A00000, TYPE_ICACHE); - +*/ // Calls to Check pheader... Assert 0 Returns /* cache_fake(0xFF1E1650 , 0xE1A00000, TYPE_ICACHE); cache_fake(0xFF1E1804 , 0xE1A00000, TYPE_ICACHE); @@ -149,6 +139,10 @@ #ifdef CONFIG_6D //FF1F1230 ./MovieRecorder/EncDrvWrapper.c:1926, task MovieRecorder cache_fake(0xFF1F1244 , 0xE1A00000, TYPE_ICACHE); + + // Rscmgr.c Assert - False + //~ cache_fake(0xFF0F5D80 , 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF0F5D28 , 0xE1A00000, TYPE_ICACHE); //FF3BEFE4 RECORDING: ./Fcreate/FcsMaker.c:2314, task MovieRecorder cache_fake(0xFF3BEFF8 , 0xE1A00000, TYPE_ICACHE); @@ -187,6 +181,7 @@ static void load_h264_ini() { gui_stop_menu(); + if (h2config == 1) { call("IVAParamMode", "B:/ML/cbr.ini"); //~ call("IVAParamMode", CARD_DRIVE "ML/cbr.ini"); @@ -208,6 +203,7 @@ call("IVAParamMode", "B:/ML/H264.ini"); NotifyBox(2000, "%s", l_ivastring); //0xaa4f4 78838 } + msleep(400); } @@ -254,11 +250,9 @@ uint8_t oldh2config; void bitrate_set() { - if (!lv) return; - if (!is_movie_mode()) return; - #ifdef FEATURE_NITRATE_WAV_RECORD - if (hibr_should_record_wav() && input_vol != 0) - { static int mic; + //~ #ifdef FEATURE_NITRATE_WAV_RECORD + //~ if (hibr_should_record_wav() && input_vol != 0) + //~ { static int mic; //~ sound_level[0] = 00 | input_vol; //~ sound_level[2] = input_vol; @@ -271,31 +265,35 @@ //~ *(ivol + 65) = input_vol; //L //~ *(ivol + 66) = input_vol; //R //~ SoundDevActiveIn(0); // Apply Maybe + meters on. - if (!powered_input || mic != mic_inserted) - { SetAudioVolumeIn(0, input_vol , input_vol); - SoundDevActiveIn(mic_inserted ? 1 : 0); - powered_input = 1; - } - mic = mic_inserted; - } - #endif + //~ if (!powered_input || mic != mic_inserted) + //~ { + + //~ SetAudioVolumeIn(0, input_vol , input_vol); + //~ SoundDevActiveIn(mic_inserted ? 1 : 0); + //~ powered_input = 1; + //~ } + //~ mic = mic_inserted; + //~ } + //~ #endif + if (!lv) return; + if (!is_movie_mode()) return; if (raw_lv_is_enabled())return; //~ if (gui_menu_shown()) return; if (recording) return; - if (!(ivaparam == 2)) ivaparam= *ivaparamstatus; + if (!config_disabled) ivaparam= *ivaparamstatus; if (patched_errors == 0) patch_errors(); //~ if (flush_errors == 0) patch_flush_errors(); // Otherwise Err70 on Play - if (ivaparam == 2 ) MEM(l_EncoMode) = 0; + if (config_disabled) MEM(l_EncoMode) = 0; else { - if (!gui_menu_shown()) // Don't load config during menu - { - if (!ivaparam && h2config !=0 && autoload!=0) load_h264_ini(); + //~ if (!gui_menu_shown()) // Don't load config during menu + //~ { + if (!config_loaded && h2config !=0 && autoload!=0) load_h264_ini(); if (autoload!=0 && (oldh2config!=h2config) && h2config !=0) load_h264_ini(); - } + //~ } } - if (!ivaparam || (autoload == 2 || ivaparam == 2)) + if (!config_loaded || override || config_disabled) { /* TODO if( !(autoload==2) && bitrate!=0 && MEM(0X78830)==0 ) { NotifyBox(2000,"Eko Mode: Must set both parameters!"); @@ -378,6 +376,14 @@ measured_bitrate = (ABS(bytes_delta) / 1024) * 8 / 1024; } +#ifdef CONFIG_6D +PROP_INT(PROP_CLUSTER_SIZE, cluster_size); +PROP_INT(PROP_FREE_SPACE, free_space_raw); +#else //5D3 +PROP_INT(PROP_CLUSTER_SIZE_A, cluster_size); +PROP_INT(PROP_FREE_SPACE_A, free_space_raw); +#endif +#define free_space_32k (free_space_raw * (cluster_size>>10) / (32768>>10)) void bitrate_mvr_log(char* mvr_logfile_buffer) { @@ -391,42 +397,11 @@ movie_start_timestamp = get_seconds_clock(); } -static PROP_INT(PROP_CLUSTER_SIZE, cluster_size); -static PROP_INT(PROP_FREE_SPACE, free_space_raw); -#define free_space_32k (free_space_raw * (cluster_size>>10) / (32768>>10)) - -void free_space_show() -{ - if (!get_global_draw()) return; - if (gui_menu_shown()) return; - if (recording && time_indicator) return; - int fsg = free_space_32k >> 15; - int fsgr = free_space_32k - (fsg << 15); - int fsgf = (fsgr * 10) >> 15; - - // trick to erase the old text, if any (problem due to shadow fonts) - bmp_printf( - FONT(FONT_MED, COLOR_WHITE, TOPBAR_BGCOLOR), - time_indic_x + 160 - 6 * font_med.width, - time_indic_y, - " " - ); - - bmp_printf( - FONT(SHADOW_FONT(FONT_MED), COLOR_WHITE, COLOR_BLACK), - time_indic_x + 160 - 6 * font_med.width, - time_indic_y, - "%d.%dGB", - fsg, - fsgf - ); -} - void time_indicator_show() { if (!get_global_draw()) return; - if (!recording) + if (!recording || raw_lv_is_enabled()) { //~ free_space_show(); return; @@ -457,9 +432,7 @@ dispvalue / 60, dispvalue % 60 ); - } - if (bitrate_indicator) - { + bmp_printf( FONT_SMALL, 680 - font_small.width * 5, 55, @@ -473,57 +446,7 @@ measured_bitrate ); } - } - -void fps_show() -{ - if (!get_global_draw()) return; - if (gui_menu_shown()) return; - if (!is_movie_mode() || recording) return; - //~ if (hdmi_code == 5) return; // workaround - int screen_layout = get_screen_layout(); - if (screen_layout > SCREENLAYOUT_3_2_or_4_3) return; - - bmp_printf( - FONT(FONT_MED, COLOR_WHITE, TOPBAR_BGCOLOR), - time_indic_x + 160 - 6 * font_med.width, - time_indic_y + font_med.height - 3, - " " - ); - - int f = fps_get_current_x1000(); - bmp_printf( - SHADOW_FONT(FONT_MED), - time_indic_x + 160 - 6 * font_med.width, - time_indic_y + font_med.height - 3, - "%2d.%03d", - f / 1000, f % 1000 - ); -} - -void free_space_show_photomode() -{ - int fsg = free_space_32k >> 15; - int fsgr = free_space_32k - (fsg << 15); - int fsgf = (fsgr * 10) >> 15; - -#if defined DISPLAY_CLOCK_POS_X - int x = DISPLAY_CLOCK_POS_X - 135; - int y = DISPLAY_CLOCK_POS_Y; -#else - int x = time_indic_x + 2 * font_med.width; - int y = 452; -#endif - bmp_printf( - FONT(SHADOW_FONT(FONT_LARGE), COLOR_FG_NONLV, bmp_getpixel(x-10,y+10)), - x, y, - "%d.%dGB", - fsg, - fsgf - ); -} - #ifdef FEATURE_NITRATE_WAV_RECORD static void hibr_wav_record_select( void * priv, int x, int y, int selected ){ menu_numeric_toggle(priv, 1, 0, 1); @@ -534,10 +457,11 @@ int mode = 1; //disabled prop_request_change(PROP_MOVIE_SOUND_RECORD, &mode, 4); NotifyBox(2000,"Canon sound disabled"); - audio_configure(1); + //~ audio_configure(1); } } } +/* static void in_vol_toggle(void * priv, int delta) { if (!hibr_should_record_wav()) return; //Yes it will work but cannon may overwrite. int *input_volume = (int *)priv; @@ -558,12 +482,12 @@ MENU_SET_VALUE("%d dB", input_vol); } } - +*/ #endif MENU_UPDATE_FUNC(bit_rated) { -if ( (!ivaparam || (autoload == 2 || ivaparam == 2)) && CURRENT_VALUE != 0) +if ( (!config_loaded || config_disabled || override) && CURRENT_VALUE != 0) MENU_SET_ENABLED(1); else { MENU_SET_ENABLED(0); @@ -574,7 +498,7 @@ MENU_UPDATE_FUNC(init_qp_d) { -if ( (!ivaparam || (autoload == 2 || ivaparam == 2)) && CURRENT_VALUE != 0) +if ( (!config_loaded || (override || config_disabled)) && CURRENT_VALUE != 0) MENU_SET_ENABLED(1); else { MENU_SET_ENABLED(0); @@ -612,12 +536,11 @@ static struct menu_entry mov_menus[] = { - /* + { .name = "Encoder", .select = menu_open_submenu, .help = "Change H.264 bitrate. Pick configs. Be careful, recording may stop!", .submenu_width = 715, -// .edit_mode = EM_MANY_VALUES, .depends_on = DEP_MOVIE_MODE, .children = (struct menu_entry[]) { { @@ -678,9 +601,6 @@ }, { .name = "Load Config", - //~ .priv = &bitrate, - //~ .min = 1, - //~ .max = 20, .select = load_h264_ini, .help = "Manual Load Config from selection" }, @@ -692,10 +612,10 @@ .max = 3, .update = ivaparam_d, .icon_type = IT_BOOL, -// .choices = (const char *[]) {"No", "Yes", "Disable"}, + .choices = (const char *[]) {"Disable", "Check"}, .help = "Config Loaded. Disabling may keep some of the parameters" }, - */ + { .name = "REC indicator", @@ -717,7 +637,7 @@ .choices = (const char *[]) {"Normal", "Separate WAV"}, .help = "Record audio with WAV separately. Source will auto select.", }, - { +/* { .name = "Input Volume", .priv = &input_vol, .update = input_vol_up, @@ -725,7 +645,7 @@ .min = 0, .max = 63, .help = "Record audio with WAV separately.", - }, + },*/ }; #endif @@ -770,12 +690,14 @@ measure_bitrate(); BMP_LOCK( show_mvr_buffer_status(); ) + movie_indicators_show(); + if ( (movie_elapsed_time_01s<200) && (movie_elapsed_time_01s>100) && (measured_bitrate == 0) && (movie_bytes_written_32k == 0) ) //~ && (!fps_override) && (bitrate_flushing_rate == 3) ) {// ASSERT (0); //call ("SHUTDOWN"); - //call ("dumpf"); + //~ call ("dumpf"); NotifyBox(2000,"Not writing! Check settings, rebooting!"); msleep(1000); prop_request_change(PROP_REBOOT_MAYBE, 0, 4); @@ -794,5 +716,4 @@ } } -//~ TASK_CREATE("bitrate_task", bitrate_task, 0, 0x1d, 0x1000 ); - +TASK_CREATE("bitrate_task", bitrate_task, 0, 0x1d, 0x1000 ); diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/bitrate.c --- a/src/bitrate.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/bitrate.c Sun Sep 22 11:41:50 2013 -0500 @@ -27,6 +27,9 @@ #else int hibr_should_record_wav() { return 0; } #endif +#ifndef CONFIG_RAW_LIVEVIEW +static int raw_lv_is_enabled() { return 0; } +#endif static int time_indic_warning = 120; static int time_indic_font = FONT(FONT_MED, COLOR_RED, COLOR_BLACK ); @@ -194,7 +197,7 @@ if (!lv) return; if (!is_movie_mode()) return; if (gui_menu_shown()) return; - if (recording) return; + if (recording || raw_lv_is_enabled()) return; if (bitrate_mode == 0) { @@ -341,7 +344,7 @@ { if (!get_global_draw()) return; - if (!recording) + if (!recording || raw_lv_is_enabled()) { free_space_show(); return; @@ -480,7 +483,7 @@ void movie_indicators_show() { #ifdef FEATURE_REC_INDICATOR - if (recording) + if (recording && !raw_lv_is_enabled()) { BMP_LOCK( time_indicator_show(); ) } @@ -550,7 +553,13 @@ .unit = UNIT_PERCENT, .help = "ML will pause CPU-intensive graphics if buffer gets full." }, + MENU_EOL + }, + }, +}; + #ifdef FEATURE_NITRATE_WAV_RECORD +static struct menu_entry wav_menus[] = { { .name = "Sound Record", .priv = &cfg_hibr_wav_record, @@ -559,11 +568,8 @@ .choices = (const char *[]) {"Normal", "Separate WAV"}, .help = "You may get higher bitrates if you record sound separately.", }, +}; #endif - MENU_EOL - }, - }, -}; static struct menu_entry mov_tweak_menus[] = { #ifdef FEATURE_REC_INDICATOR @@ -582,6 +588,10 @@ { menu_add( "Movie", mov_menus, COUNT(mov_menus) ); menu_add( "Movie Tweaks", mov_tweak_menus, COUNT(mov_tweak_menus) ); + #ifdef FEATURE_NITRATE_WAV_RECORD + menu_add( "Audio", wav_menus, COUNT(wav_menus) ); + #endif + } INIT_FUNC(__FILE__, bitrate_init); @@ -594,13 +604,14 @@ TASK_LOOP { - if (recording) + if (recording && !raw_lv_is_enabled()) { /* uses a bit of CPU, but it's precise */ wait_till_next_second(); movie_elapsed_time_01s += 10; measure_bitrate(); BMP_LOCK( show_mvr_buffer_status(); ) + movie_indicators_show(); } else { @@ -614,3 +625,4 @@ TASK_CREATE("bitrate_task", bitrate_task, 0, 0x1d, 0x1000 ); #endif + diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/bmp.c --- a/src/bmp.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/bmp.c Sun Sep 22 11:41:50 2013 -0500 @@ -58,9 +58,9 @@ if (((uintptr_t)bmp_buf & 0xFFF) == 0x4c8) // SD mode 1 return (uint8_t*)((uintptr_t)bmp_buf - BMP_HDMI_OFFSET - 0x3c8); - + // something else - new camera? return it unchanged (failsafe) - ASSERT(0); + //~ ASSERT(0); return bmp_buf; } @@ -109,8 +109,9 @@ { if (direction) memcpy(BMP_VRAM_START(real), BMP_VRAM_START(idle), BMP_VRAM_SIZE); + else - memcpy(BMP_VRAM_START(idle), BMP_VRAM_START(real), BMP_VRAM_SIZE); + memcpy(BMP_VRAM_START(idle), BMP_VRAM_START(real), BMP_VRAM_SIZE); } else { @@ -590,7 +591,7 @@ size_needed += 2; //0001 EOF fast_buf = BmpAlloc( size_needed ); if( !fast_buf ) goto fail_buf_copy; - memcpy(fast_buf, buf, sizeof(struct bmp_file_t)); + memcpy(fast_buf, buf, sizeof(struct bmp_file_t)); gpos = fast_buf + sizeof(struct bmp_file_t); for (y = 0; y < bmp->height; y++) { uint8_t* pos = bmp->image + y*bmp->width; diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/boot-hack.c --- a/src/boot-hack.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/boot-hack.c Sun Sep 22 11:41:50 2013 -0500 @@ -33,7 +33,7 @@ #include "property.h" #include "consts.h" #include "tskmon.h" -#if defined(HIJACK_CACHE_HACK) +#if defined(HIJACK_CACHE_HACK) || defined(CONFIG_6D) || defined(CONFIG_50D) || defined(CONFIG_EOSM) #include "cache_hacks.h" #endif @@ -132,7 +132,7 @@ * create_init_task */ // Reserve memory after the BSS for our application - #if !defined(CONFIG_ALLOCATE_MEMORY_POOL) // Some cameras load ML into the AllocateMemory pool (like 5500D/1100D) + #if !defined(CONFIG_ALLOCATE_MEMORY_POOL) && !defined(CONFIG_6D) // Some cameras load ML into the AllocateMemory pool (like 5500D/1100D) INSTR( HIJACK_INSTR_BSS_END ) = (uintptr_t) _bss_end; ml_reserved_mem = (uintptr_t)_bss_end - RESTARTSTART; #endif @@ -148,6 +148,16 @@ clean_d_cache(); flush_caches(); + #if defined(CONFIG_50D) || defined(CONFIG_EOSM) + cache_lock(); + #endif + #ifdef CONFIG_6D + //Hijack GUI Task Here - Now we're booting with cache hacks and have menu. + cache_lock(); + cache_fake(0xFF0DF6DC, BL_INSTR(0xFF0DF6DC, (uint32_t)hijack_6d_guitask), TYPE_ICACHE); + #endif + + // We enter after the signature, avoiding the // relocation jump that is at the head of the data thunk reloc_entry = (thunk)( RELOCADDR + 0xC ); @@ -665,7 +675,7 @@ uint32_t* addr_AllocMem_end = (void*)(CreateTaskMain_reloc_buf + ROM_ALLOCMEM_END + CreateTaskMain_offset); uint32_t* addr_BL_AllocMem_init = (void*)(CreateTaskMain_reloc_buf + ROM_ALLOCMEM_INIT + CreateTaskMain_offset); - #ifdef CONFIG_550D + #if defined(CONFIG_550D) || defined(CONFIG_50D) // change end limit to 0xc60000 => reserve 640K for ML *addr_AllocMem_end = MOV_R1_0xC60000_INSTR; ml_reserved_mem = 640 * 1024; @@ -789,14 +799,41 @@ } else { - /* we are not sure if this is a instruction, so patch data cache also */ + /* patch dcache/icache */ cache_fake(HIJACK_CACHE_HACK_BSS_END_ADDR, new_instr, TYPE_ICACHE); cache_fake(HIJACK_CACHE_HACK_BSS_END_ADDR, new_instr, TYPE_DCACHE); //~ fix start of AllocateMemory pool so it actually shrinks in size. - #ifdef CONFIG_6D - cache_fake(HIJACK_CACHE_HACK_ALLOCMEM_SIZE_ADDR, HIJACK_CACHE_HACK_ALLOCMEM_SIZE_INSTR, TYPE_ICACHE); - #endif + #ifdef HIJACK_CACHE_HACK_ALLOCMEM_SIZE_ADDR + cache_fake(HIJACK_CACHE_HACK_ALLOCMEM_SIZE_ADDR, HIJACK_CACHE_HACK_ALLOCMEM_SIZE_INSTR, TYPE_ICACHE); +/* + #ifdef CONFIG_6D //Bigmem:Resource Manger crashes depends on bvram in malloc + cache_fake(0xFFCE5E54, 0xE1A00000, TYPE_ICACHE); //hJpegMemSuite + cache_fake(0xFF0F5A48, 0xE1A00000, TYPE_ICACHE); //Semaphore Prevent Busy ON + cache_fake(0xFFCE5E44, HIJACK_ASIF_CONT_JUMP_INSTR, TYPE_ICACHE); //CMP R0, R0 + cache_fake(0xFF0F5A5C, 0xE1A00000, TYPE_ICACHE); //GIS startup + cache_fake(0xFF0F5A4C, 0xE1100000, TYPE_ICACHE); //TST R0, R0 + + //HDR + + //~ cache_fake(0xFF0F5C5C, 0xE1A00000, TYPE_ICACHE); //HDR startup assert + + //Inner Develop + //~ cache_fake(0xFF0F5D74, 0xE1A00000, TYPE_ICACHE); //Inner Develop startup assert + + //Multi Expo + //~ cache_fake(0xFF0F5CF8, 0xE1A00000, TYPE_ICACHE); //Multi Expo startup assert + //DP + //~ cache_fake(0xFF0F57A0, 0xE1A00000, TYPE_ICACHE); //DP assert + #endif + */ + #endif + //~ cache_fake(0xFF0C4EAC, 0xE1A00000, TYPE_ICACHE); //Multi Expo startup assert + //~ cache_fake(0xFF0C4EC8, 0xE1A00000, TYPE_ICACHE); //Multi Expo startup assert + //~ cache_fake(0xFF10A338, 0xE1A00000, TYPE_ICACHE); //Multi Expo startup assert + //~ cache_fake(0xFF11E5D0, 0xE1A00000, TYPE_ICACHE); //Multi Expo startup assert + + } #ifdef ML_RESERVED_MEM // define this if we can't autodetect the reserved memory size diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/chdk-dng.c --- a/src/chdk-dng.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/chdk-dng.c Sun Sep 22 11:41:50 2013 -0500 @@ -566,7 +566,6 @@ free_dng_header(); } } - #ifdef CONFIG_MAGICLANTERN PROP_HANDLER(PROP_CAM_MODEL) { diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/debug.c --- a/src/debug.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/debug.c Sun Sep 22 11:41:50 2013 -0500 @@ -11,6 +11,7 @@ #include "gui.h" #include "lens.h" #include "version.h" +#include "cache_hacks.h" #include "edmac.h" #include "asm.h" @@ -26,7 +27,6 @@ #ifdef CONFIG_MODULES #include "module.h" #endif -//#include "lua.h" #if defined(CONFIG_7D) #include "ml_rpc.h" @@ -35,7 +35,40 @@ #if defined(CONFIG_600D) && defined(CONFIG_AUDIO_600D_DEBUG) void audio_reg_dump_once(); #endif - +#ifdef CONFIG_DUMP_AUDIO +void +audio_reg_dump_dv() +{ + char log_filename[100]; + + int log_number = 0; + for (log_number = 0; log_number < 100; log_number++) + { + snprintf(log_filename, sizeof(log_filename), CARD_DRIVE "ML/audio%02d.LOG", log_number); + unsigned size; + if( FIO_GetFileSize( log_filename, &size ) != 0 ) break; + if (size == 0) break; + } + + FILE* f = FIO_CreateFileEx(log_filename); + + unsigned i; + for( i=0x0 ; i<0x100 ; i++ ) + { + const uint16_t reg = audio_ic_read( i + #ifndef CONFIG_DIGIC_V + << 8 + #endif + ); + my_fprintf(f, "%02x %02x\n", i, reg); + msleep(10); + } + + FIO_CloseFile(f); + + NotifyBox(4000, "log audio%02d.log saved", log_number ); +} +#endif #if defined(CONFIG_EDMAC_MEMCPY) #include "edmac-memcpy.h" #endif @@ -68,6 +101,8 @@ #ifdef CONFIG_DEBUG_INTERCEPT void j_debug_intercept() { debug_intercept(); } +#endif +#ifdef FEATURE_TP_INTERCEPT void j_tp_intercept() { tp_intercept(); } #endif @@ -360,9 +395,8 @@ m = x[i]; return m; } - #endif - +#ifdef CONFIG_DUMPROM static void dump_rom_task(void* priv, int unused) { msleep(200); @@ -372,7 +406,8 @@ if (f != (void*) -1) { bmp_printf(FONT_LARGE, 0, 60, "Writing ROM0"); - FIO_WriteFile(f, (void*) 0xF0000000, 0x01000000); + //~ FIO_WriteFile(f, (void*) 0xF0000000, 0x01000000); + FIO_WriteFile(f, (void*) 0xf0800000, 0x007FE000); FIO_CloseFile(f); } msleep(200); @@ -381,7 +416,8 @@ if (f != (void*) -1) { bmp_printf(FONT_LARGE, 0, 60, "Writing ROM1"); - FIO_WriteFile(f, (void*) 0xF8000000, 0x01000000); + //~ FIO_WriteFile(f, (void*) 0xF8000000, 0x01000000); + FIO_WriteFile(f, (void*) 0xF8000000, 0x00ffffff); FIO_CloseFile(f); } msleep(200); @@ -394,7 +430,8 @@ gui_stop_menu(); task_create("dump_task", 0x1e, 0, dump_rom_task, 0); } - +#endif +#ifdef CONFIG_DEBUGMSG static void dump_logs_task(void* priv) { msleep(200); @@ -675,14 +712,112 @@ msleep(1000); } } + + #endif - -//~ uncompressed video testing -#ifdef CONFIG_6D -FILE * movfile; -int record_uncomp = 0; #endif +#ifdef FEATURE_TIMER_HACK +static int hacked_timers = 0; + +static void hack_t() +{ + //Switch didn't work here. +if (hacked_timers == 0) +{ + #if defined(CONFIG_EOSM) + cache_fake(0xFF53B204, MEM(0xFF53AA64), TYPE_ICACHE); + #elif defined(CONFIG_6D) + cache_fake(0xFF52D818, MEM(0xFF52D818), TYPE_ICACHE); + #elif defined(CONFIG_50D) + cache_fake(0xFFA872F0, MEM(0xFFA872F0), TYPE_ICACHE); + cache_fake(0xffa84e00, 0xe3a00032, TYPE_ICACHE); + #elif defined(CONFIG_7D) + cache_fake(0xFF347EE8, MEM(0xFF347EE8), TYPE_ICACHE); + #endif +} +else if (hacked_timers == 1) + #if defined(CONFIG_6D) + cache_fake(0xFF52D818, 0xE1A00000, TYPE_ICACHE); + #elif defined(CONFIG_EOSM) + cache_fake(0xFF53B204, 0xE1A00000, TYPE_ICACHE); + #elif defined(CONFIG_7D) + cache_fake(0xFF347EE8, 0xE1A00000, TYPE_ICACHE); + #elif defined(CONFIG_50D) + cache_fake(0xFFA872F0, 0xE1A00000, TYPE_ICACHE); //Disable +else if (hacked_timers == 2) + { + cache_fake(0xFFA872F0, MEM(0xFFA872F0), TYPE_ICACHE); //Undo Disable + cache_fake(0xffa84e00, 0xE3A00B01, TYPE_ICACHE); /* change to mov r0, #1024 */ + } +else if (hacked_timers == 3) + { + cache_fake(0xffa84e00, 0xE3A00A01, TYPE_ICACHE); /* change to mov r0, #4096 */ + } +else if (hacked_timers == 4) + { + cache_fake(0xffa84e00, 0xE3A00A02, TYPE_ICACHE); /* change to mov r0, #8192 */ + } +else if (hacked_timers == 5) + { + cache_fake(0xffa84e00, 0xE3A00901, TYPE_ICACHE); /* change to mov r0, #16384 */ + } +else if (hacked_timers == 6) + { + cache_fake(0xffa84e00, 0xE3A00902, TYPE_ICACHE); /* change to mov r0, #32768 */ + } + #endif +} + +static void hacked_timers_select(void* priv, int delta) +{ + if(lv) + { + NotifyBox(1000, "Works best with LV off!"); + } + menu_numeric_toggle(&hacked_timers, delta, 0, + #ifdef CONFIG_50D + 6 + #else + 1 + #endif + ); + run_in_separate_task(hack_t, 1); +} + + +MENU_UPDATE_FUNC(hacked_timers_display) +{ + + if (hacked_timers == 0) + { MENU_SET_ENABLED(0); + MENU_SET_ICON(MNI_DICE, 0); + } + + + else if (hacked_timers >= 1) + { MENU_SET_ENABLED(1); + MENU_SET_ICON(MNI_DICE, 1); + } + +} +#endif + + + + +//PROP_INT(PROP_REGISTRATION_DATA_UPDATE_FUNC, servo); +//PROP_INT(PROP_CONTINUOUS_AF_MODE, contaf); +//PROP_INT(PROP_CONTINUOUS_AF_VALID, modevalid); +//PROP_INT(PROP_AF_MODE, newaf); +//PROP_INT(PROP_DIGITAL_ZOOM_RATIO, dzoom); + +int video_mode[6]; +PROP_HANDLER(PROP_VIDEO_MODE) +{ memcpy(video_mode, buf, 24); +} + +/* static void bsod() { msleep(rand() % 20000 + 2000); @@ -717,11 +852,267 @@ bmp_printf(fnt, 0, y+=h, " Contact the Magic Lantern guys at www.magiclantern.fm" ); bmp_printf(fnt, 0, y+=h, " for further assistance and information." ); } +*/ +//int afmode[2]; +//PROP_HANDLER(PROP_AF_MODE) +//{ +// memcpy(afmode, buf, 2); +//} + +/* +int lvd[2]; +PROP_HANDLER(PROP_CONTINUOUS_AF_MODE) +{ + memcpy(lvd, buf, 4); + // bmp_printf(FONT_MED, 10,120, "g0: %d", buf[0]); + +} +*/ +//void TestSetAudioHeadPhone(); + +//void SerialCommand_Send(int data); +/* +static int8_t afma_buf[0x5]; +PROP_HANDLER(0x80010006) +{ + ASSERT(len == sizeof(afma_buf)); + my_memcpy(afma_buf, buf, sizeof(afma_buf)); +} +*/ +/* +static int afp[2]; +static int afp_len = 0; +PROP_HANDLER(PROP_AFPOINT) +{ + afp[0] = buf[0]; + afp[1] = buf[1]; + afp_len = len; +} +*/ +//~ uint32_t lvlens[59]; +//~ static int lvlens_len = 0; + +//~ PROP_HANDLER(0x80050000) +//~ { + //~ lvlens_len = len; + //~ for (int x =0; x < len; x++) + //~ lvlens[x] = buf[x]; +//~ } + + +//LV lens EF 35-135 +//EOS M - Len 59 ~ lines + +//0 - 6050c3 +//1 - c02d3e +//2 - c09fbc +//3 - 0 +//4 - 0 +//5 - 0 - +//6 - 0 - +//7 - 0 - +//8 - 2500 0000 ma: 10d0 0000 mid: b080 0000 ring +//9 - 4a50 2828 135: 5e58 3030 70: 5655 2d2d 100: 5a57 2f2f lens -identical + +//10 9b98 3701 135: 7973 2601 70: 8681 2501 100: 7973 2501 lens + //~ 9b98 3701 + +//11 95 8700 756 a00 88 7600 756a00 lens + //~ 2300 2300 + +//12 ff 230023 230023 3: 1230023 - both + //~ 4900 4a00 + +//13 ff1f f 4900 4a mid 7800 93 3: e01 a4 ring + //~ 900000 +//14 800000 +//15 55550000 +//16 59ca50 + + +//PROP_INT(PROP_PHOTO_STUDIO_MODE, studio); +//PROP_INT(0x8003000f, fa_rel); +//PROP_INT(PROP_AF_METHOD_SELECT_FOCUS_AREA, areax); +//void ENCODE_StartEncodeJpeg(); +//uint32_t strobo_settings[34]; +//PROP_HANDLER(0x80030038) +//{ +// memcpy(strobo_settings, buf, 34); +//} +//~ PROP_INT(0x80000049, noise); +//~ PROP_INT(0x80000045, multiexpo); +//~ PROP_INT(0x8000004e, gis); +//~ PROP_INT(PROP_SHUTTER, shtr); +//~ PROP_INT(PROP_SHUTTER_RANGE, shtr2); +//~ PROP_INT(PROP_SHUTTER_ALSO, shtr); +//~ PROP_INT(0x80040056, shtr3); +/* +int headphone_mode[8]; +PROP_HANDLER(PROP_HEADPHONE_PHYSICAL_CONNECT) +{ + memcpy(video_mode, buf, 24); +} +*/ +/* +#include "raw.h" +static char* silent_pic_get_name() +{ + static char imgname[100]; + static int silent_number = 1; // cache this number for speed (so it won't check all files until 10000 to find the next free number) + + static int prev_file_number = -1; + static int prev_folder_number = -1; + + char *extension = "DNG"; + + if (prev_file_number != file_number) silent_number = 1; + if (prev_folder_number != folder_number) silent_number = 1; + + prev_file_number = file_number; + prev_folder_number = folder_number; + + for ( ; silent_number < 10000; silent_number++) + { + snprintf(imgname, sizeof(imgname), "%s/%04d%04d.%s", get_dcim_dir(), file_number, silent_number, extension); + uint32_t size; + if( FIO_GetFileSize( imgname, &size ) != 0 ) break; + if (size == 0) break; + } +// bmp_printf(FONT_MED, 0, 35, "%s ", imgname); + return imgname; +} +*/ +//~ PROP_INT(0x205000C, shtr); +//~ PROP_INT(0x8004001A, shtr); +//~ PROP_INT(PROP_LV_DISPSIZE, lv_disp); +//~ int foof = 500 ; +//~ extern int variable; +//~ extern void find_free_edmac_channels(){} +//~ void i2c_write (int parameter); +//~ int i2c_read (int parameter2); +//~ extern uint8_t bmp_vram_real(); +//~ extern uint8_t bmp_vram_idle(); static void run_test() -{ - malloc(2*1024*1024); - return; +{ + //~ cache_fake(0xFF53A6D4, 0xE3A000FF, TYPE_ICACHE); + //~ cache_fake(0xFF24BE0C, 0xE3A000FF, TYPE_ICACHE); + //~ cache_fake(0xFF35E8D4, 0xE3A000FF, TYPE_ICACHE); + + +//~ uint8_t *vreal, *vidle; +//~ SetGUIRequestMode(DLG_PLAY); +//~ vreal = bmp_vram_real(); +//~ vidle = bmp_vram_idle(); + +//~ NotifyBox(1000, "real %x, idle %x", vreal, vidle); + //~ call("StudioOn",1); + + //~ variable++; + //~ NotifyBox(1000, "%d", variable); + //~ foof -= 5; + //~ call("lv_crop", foof); + //~ call("lv_hd", foof); + //~ call("lv_fa_mode", 1); + //~ NotifyBox(1000, "%d", foof); + + + //~ ml_rpc_send(ML_RPC_CACHE_HACK, 0xFF8083EC, 0xE1A00000, TYPE_ICACHE, 2); + //~ master_write_memory("ROM1.BIN", 0xf8000000, 0x00800000); + + //~ ml_rpc_call(0xFF81AD28, 0xf8000000, 0x00800000); + //~ cache_fake(0xFF01F804, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF10ECF8, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF13318C, 0xE1A00000, TYPE_ICACHE); + //ALV state sig + //~ cache_fake(0xFF10F6C4, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF10A390, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF10A360, 0xE1A00000, TYPE_ICACHE); + + //Don't lock UI + //~ cache_fake(0xFF2A3844, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF2A28EC, 0xE1A00000, TYPE_ICACHE); + +//~ int bleh = audio_ic_read( 0x80); +//~ msleep(50); +//~ int bleh2 = audio_ic_read( 0x0300 ); +//~ msleep(50); +//~ bleh = audio_ic_read( 0x80); +//~ NotifyBox(1000, "one %x two %x", bleh, bleh); +//~ call("TestSetAudioHPMon", 10); + //~ int command[2]; + //~ command[0] = 0x100000; + //~ command[1] = 0x06200000; + //~ command[1] = 0xFFFFFFFF; + //~ void (*SerialCommand_Send)(int a1) = 0xFF143118; //Meters + //~ void (*SerialCommand_Send)(int var1, int var2) = 0xFF142618; //Meters + //~ void (*SerialCommand_Send)(int *var2) = 0xFF1422B0; //6D + //~ void (*SerialCommand_Send)(int *var2) = 0xFF339490; //M + //~ SerialCommand_Send(&command); + //~ SerialCommand_Send(command); + //~ NotifyBox(1000, "ptr %x data %x", command, *command); + + //~ void (*headphone)(int parameterx) = 0xFF133028; //HP + //~ headphone(10); + + //7D 780 - 21fps 725 23fps 702 23.807 701 .841 700 .875 699 .910 698 .944 697 23.978 + //~ int blah =0; + //~ blah = i2c_read(0x02); + //~ NotifyBox(1000, "Reg %x", blah); + //~ call("TestSetAudioHPMon", 1); + + //~ set_shooting_mode(SHOOTMODE_M); + + //~ *(uint16_t*)40450E08 = 0x50; + //~ *(uint16_t*)0x404B5EC0 = 0x104; + //LV + //~ *(uint16_t*)0x40452196 = 0x70; + //~ find_free_edmac_channels(); + //0x366 reg. 795 zoom + //~ foof -= 1; + //~ call("lv_hd", 795); + //~ call("lv_fa_mode", 1); + //~ NotifyBox(1000, "%d", foof); + //~ call("lv_ae", 0); + //~ call("lv_af_fase_addr", 0); + //~ call("lv_face_ael", 0); + //~ call("lv_output_device", "vga"); + //~ call("lv_output_device", "1080full"); + + //~ call("lv_continous_frame", 1); + //~ call("lv_hd", 0x36A); + //~ call("lv_hd", 0x366); + //~ call("lv_changemoviemode",1); + //~ call("lv_120fps_test",1); + //~ call("lv_dzoom_test",1); + //~ call("lv_dzoom_test",0); + + //~ call("lv_flicker_on",0); + //~ call("lv_cfilter_mode",1); + //~ call("lv_hd", 0x7D0); + //~ call("lv_hd", 2200); + //~ call("lv_magnify", 0); + //~ call("lv_defmark_raw", 1); + //~ call("lv_fps", 1); + + /* change dialog refresh timer from 50ms to 1024ms */ + //~ if (MEM(0xffa84e00) == 0xe3a00032) /* mov r0, #50 */ + //~ cache_fake(0xffa84e00, 0xE3A00B01, TYPE_ICACHE); /* change to mov r0, #1024 */ + //~ cache_fake(0xffa84e00, 0xE3A00A01, TYPE_ICACHE); /* change to mov r0, #4096 */ + //~ cache_fake(0xffa84e00, 0xE3A00A02, TYPE_ICACHE); /* change to mov r0, #8192 */ + //~ cache_fake(0xffa84e00, 0xE3A00901, TYPE_ICACHE); /* change to mov r0, #16384 */ + //~ cache_fake(0xffa84e00, 0xE3A00902, TYPE_ICACHE); /* change to mov r0, #32768 */ + + + //~ cache_fake(0xFF84D388, 0xE1500000, TYPE_ICACHE); /* change to mov r0, #32768 */ + //~ lv_disp = 5; +//~ prop_request_change(PROP_LV_DISPSIZE, &lv_disp, 4); +//~ #define RAW_LV_EDMAC 0xC0F04508 +//~ #define RAW_LV_EDMAC 0xC0F26208 +//~ NotifyBox(1000, "Shv %x\nEdm %X Cont:%X", RAW_LV_EDMAC-8, MEM(RAW_LV_EDMAC-8), MEM(RAW_LV_EDMAC-8+0x1C)); + + //~ malloc(2*1024*1024); + //~ return; //~ bfnt_test(); #ifdef FEATURE_SHOW_SIGNATURE console_show(); @@ -729,7 +1120,149 @@ msleep(1000); return; #endif - +//~ FF9A45A4 +//~ shtr = 0x3C; +//~ prop_request_change(0x8004001A, &shtr, 4); + + //~ FFA872E4 + //~ FFA872E4 + //~ cache_fake(0xFFA872E4, 0xE3A000FF, TYPE_ICACHE); + //~ cache_fake(0xFFA880E0, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF966554, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF966560, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF96665C, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF96666C, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFFA872E0, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFFA872D4, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFFA881B8, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFFA91A6C, 0xE3A01003, TYPE_ICACHE); + //~ cache_fake(0xFF9C7BFC, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF968B18, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF9C7C38, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF84D4C4, 0xE3A0C018, TYPE_ICACHE); + //~ cache_fake(0xFF84C55C, 0xE3A01017, TYPE_ICACHE); + + //~ cache_fake(0xFF84D388, 0xE1500000, TYPE_ICACHE); //CMP R0, R0 + + + //~ GUI_SetMovieSize_a(1); + //~ NotifyBox(1000, "shut %d", get_current_shutter_reciprocal_x1000()); +// #ifdef CONFIG_6D + //~ multiexpo = 0x2; + //~ prop_request_change(0x80000045, &multiexpo, 5); + + /* + noise = 4; + prop_request_change(0x80000049, &noise, 4); + //~ msleep(100); + //~ noise = 0; + //~ prop_request_change(0x80000049, &noise, 4); + //Patch Again! + cache_fake(0xFFCE5E54, 0xE1A00000, TYPE_ICACHE); + cache_fake(0xFF0F5A48, 0xE1A00000, TYPE_ICACHE); //Semaphore + //~ cache_fake(0xFFCE5E44, HIJACK_ASIF_CONT_JUMP_INSTR, TYPE_ICACHE); //CMP R0, R0 + cache_fake(0xFF0F5A5C, 0xE1A00000, TYPE_ICACHE); + cache_fake(0xFF0F5A4C, 0xE1100000, TYPE_ICACHE); //TST R0, R0 + + + //~ gis = 0x1000001; + //~ prop_request_change(0x8000004E, &gis, 4); + #endif +/* +void (*mnavfree2)() = 0xFF0F5D0C; //Inner Dev +//~ void (*mnavfree2)() = 0xFF0F5C84; //Mulit Expo +//~ void (*mnavfree2)() = 0xFF0F56F8; //DP +mnavfree2(); +/* +void (*mnavfree)() = 0xFF0F59A0; +mnavfree(); +*/ + + //~ call("memdump"); + //~ call("smemTerm"); + //~ call("sstgShowDcf"); + //~ call("scls"); + /* + call("EnableLvFnoCorrect"); + call("EnableFnoCorrect"); + call("lv_debug_mon",1); + call("lv_put_usage",1); + + call("lv_rshd_raw", 1); + msleep(2000); + call("lv_rshd_raw",1); + */ + //EOS: M 0x506C4 + //6D type 22 + //~ for (int type = 0; type < 100; type++) + //~ { + /* from lv_af_raw -> lv_set_raw_type(arg0 ? 4 : 7) -> MEM(0x2D168) = a bunch of values, default 34 */ + //~ MEM(0x7E020 + 4) = type; + //~ call("lv_af_raw", 1); + //~ MEM(0x506C4 + 4) = type; + + /* this enables a LiveView debug flag that gives us 14-bit RAW data. Cool! */ + //~ raw_lv_request(); + //~ msleep(50); + + /* after filling one frame, disable the flag so we can dump the data without tearing */ + //~ raw_lv_release(); + //~ msleep(50); + + /* update raw geometry, autodetect black/white levels etc */ + //~ raw_update_params(); + + /* save it to card */ + //~ char* fn = silent_pic_get_name(); + //~ bmp_printf(FONT_MED, 0, 60, "Saving raw type %d, %d x %d...", type, raw_info.jpeg.width, raw_info.jpeg.height); + //~ save_dng(fn); + //~ } + +//~ console_show(); +//~ NotifyBox(2000, " %x %x %x ", sound_level[0], sound_level[1], sound_level[2]); +//~ NotifyBox(8000, " %x %x %x %x %x", lvlens[10], lvlens[11], lvlens[12], lvlens[13], lvlens[14]); +//~ debug_intercept(); +//~ call("DumpEeko"); + //~ cache_fake(0xFF52CCB4, 0xE1510001, TYPE_ICACHE); + //~ cache_fake(0xFF52F300, 0xE1A00000, TYPE_ICACHE); + //~ cache_fake(0xFF52D5C8, 0xE1A00000, TYPE_ICACHE); +//~ int shtr = 0x7b; //A0 +//~ int shtr2 = 0x10007b; +//~ prop_request_change(PROP_SHUTTER_RANGE, &shtr2, 4); +//~ prop_request_change(PROP_SHUTTER_ALSO, &shtr, 4); +//~ prop_request_change(PROP_SHUTTER, &shtr, 4); +//call("Release"); + +/* +video_mode[2] = 0x18; +video_mode[5] = 3; + + prop_request_change(PROP_VIDEO_MODE, video_mode, 24); +NotifyBox(2000, "1: %x 2:%x 3:%x\n4:%x 5:%x, 6:%x", video_mode[0],video_mode[1],video_mode[2],video_mode[3],video_mode[4],video_mode[5]); +*/ +/* +msleep (1000); +video_mode[0] = 0xc; +video_mode[2] = 0x18; +video_mode[4] = 2; +//~ video_mode[5] = 3; + prop_request_change(PROP_VIDEO_MODE, video_mode, 24); + +NotifyBox(2000, "1: %x 2:%x 3:%x\n4:%x 5:%x, 6:%x", video_mode[0],video_mode[1],video_mode[2],video_mode[3],video_mode[4],video_mode[5]); +*/ +//FF102578 Fencing_DisablePath MEM(773B4) == face detection mode/status +//~ call ("lvfaceEnd"); +#ifdef CONFIG_6D +//~ void (*disable_fence)() = (void*)0xFF170D5C; +//~ disable_fence(); +//~ call ("lvfaceEnd"); +//~ MEM(0x773B4) = 0; +#endif +//~ cache_fake(0x1D68C , 0xE1520002, TYPE_ICACHE); +//~ cache_fake(0x1D974 , 0xE1A00000, TYPE_ICACHE); +//~ cache_fake(0x1D9A8 , 0xE1A00000, TYPE_ICACHE); + +/* #ifdef CONFIG_EDMAC_MEMCPY msleep(2000); @@ -754,71 +1287,341 @@ edmac_memcpy_res_unlock(); return; #endif - + */ +/* call("lv_save_raw", 1); call("aewb_enableaewb", 0); return; - -#if 0 - void exmem_test(); - - exmem_test(); - return; -#endif + */ + +//NotifyBox(2000, " %x", strobo_settings[0x26]); +//strobo_settings[0x26] = 0xB; +//prop_request_change(0x80030038, &strobo_settings, 34); + +//NotifyBox(2000, " %x", strobo_settings[0x26]); +//39E24 +FFCC34D4 = TryPostEvent FFCFD2F8 +//3973C +FFCC34D4 = TryPostStageEvent +//39F04 +FFCC34d4 = FFCFD3D8 EVF + +//afp[0]=0x4A00; +//afp[1]=0x464a4e00; +//prop_request_change(PROP_AFPOINT, afp, afp_len); + +//int areax=0x0A00; +//prop_request_change(PROP_AF_METHOD_SELECT_FOCUS_AREA, &areax, 4); + +//int fa_rel=0; +//prop_request_change(0x8003000f, &fa_rel, 4); + + +//int studio = 0x1; +//prop_request_change(PROP_PHOTO_STUDIO_MODE, &studio, 4); + + +//call("SaveLensToFile"); +//int zebra = zebra_should_run(); + +//NotifyBox(2000, " %d", zebra); + +//call("FA_MovieStart"); +//debug_intercept(); + + +//tp_intercept(); +//ENCODE_StartEncodeJpeg(); +//msleep(10000); + +//call("FA_MovieEnd"); + +//NSTUB(0xFF0C8FEC, str:02d.bin_error._write_Save) + + +//call("FA_SetSavePropertyListNum",1); +//call("FA_SavePropertyList", 1); +//call("lv_dzoom_debug"); + /* -#ifdef CONFIG_MEMCHECK - console_show(); - console_printf("should raise error at index=10...\n"); - char* foo = AllocateMemory(10); - foo[9] = 0; - foo[10] = 0; - FreeMemory(foo); - msleep(1000); -#endif +call("lv_nv12_dump"); +call("epp_jpeg2card"); +call("lv_save_jpeg"); +call("epp_vram_dump"); + +msleep(30000); +debug_intercept(); +msleep(1000); +call("dumpf"); */ -#ifdef CONFIG_MODULES - console_show(); - - console_printf("Loading modules...\n"); - msleep(1000); - module_load_all(); - return; - - console_printf("\n"); - - console_printf("Testing TCC executable...\n"); - console_printf(" [i] this may take some time\n"); - msleep(1000); - - for(int try = 0; try < 100; try++) - { - void *module = NULL; - uint32_t ret = 0; - - module = module_load(MODULE_PATH"libtcc.mex"); - if(module) - { - ret = module_exec(module, "tcc_new", 0); - if(!(ret & 0x40000000)) - { - console_printf("tcc_new() returned: 0x%08X\n", ret); - } - else - { - module_exec(module, "tcc_delete", 1, ret); - } - module_unload(module); - } - else - { - console_printf(" [E] load failed\n"); - } - } - - console_printf("Done!\n"); -#endif +//Center 0x4A00, 4a004a +//TC 0xa00, 4a004a +//BC 0x8a00, 4a004a +//TL 0x2800, 4a004a +//TR 0x2c00, 4a004a +//L 0x4600, 4a004a +//R 0x4e00, 4a004a +//BL 0x6800, 4a004a +//BR 0x6C00, 4a004a +//LeftC 0x4800, +//RIGHTC 0x4C00, +/* + *TC + *TL *TR +L * * *C * * R + *BL *BR + *BC +*/ +//04 - 1 +// 12 51 +//14 4 +//15 -128 + +//Adjust By 3 W - 13 +//Adjust By 3 T - 14 +//Adjust ALL 16 +// MOde 9 +//Next 2 17, 9 +// Lens registered 15? 2 after registered +//afp[0]=0xca00; +//prop_request_change(PROP_AFPOINT, afp, afp_len); +//NotifyBox(2000, "afp %d %d %x %x", afp[0], afp[1], afp[0], afp[1]); +//NotifyBox(2000, "afma %d %d %d %d %d %d", afma_buf[0], afma_buf[1], afma_buf[2], afma_buf[3], afma_buf[4], afma_buf[0]); + +/* +call("FA_StartLvTestImage"); +call("lv_jukai_mode"); +msleep(1000); +call("lv_ss_dump"); +msleep(1000); +call("lv_ohy_dump"); +msleep(1000); +call("lv_save_raw"); +msleep(1000); +call("lv_raw_dump"); +//call("epp_memorywrite"); +//call("lv_vram_dump"); +//call("DeliverStage"); +debug_intercept(); +//call("lv_nv12_dump"); + +//call("sht_memoryread2"); +//call("sht_memoryread"); + +//cracklimits(); +//NotifyBox(2000, "button %x %x %x", button_cfn[6], button_cfn[7], button_cfn[8]); +//FA_SeBitProperty32' +//'FA_ClearBitProperty32' +//FA_SetProperty32 +/* + +uint16_t reg = audio_ic_read(0x2); +NotifyBox(1000,"%02x\n", reg); + msleep(1000); +audio_ic_write(0x226); +reg = audio_ic_read( 0x2 ); +NotifyBox(1000,"%02x\n", reg); +msleep(1000); +reg = audio_ic_read( 0x4 ); +NotifyBox(1000,"%02x\n", reg); +audio_ic_write(0x9c26); +msleep(1000); +reg = audio_ic_read( 0x30 ); +NotifyBox(1000,"%02x\n", reg); +msleep(1000); +reg = audio_ic_read( 0x9c ); +NotifyBox(1000,"%02x\n", reg); + +debug_intercept(); + + +//void (*stop)(int bar) = 0xFF1F5C44; +//stop(0); + +//for (int i=1; i < 100; i++ ) +//call("TurnAVLineMuteOff"); +/* + cache_fetch_line(0xFF1E3134, TYPE_ICACHE); + cache_fake(0xFF1E3134 , 0x010050E3, TYPE_ICACHE); + + cache_fetch_line(0xFF1E3118, TYPE_ICACHE); + cache_fake(0xFF1E3118 , 0x010050E3, TYPE_ICACHE); + + +//debug_intercept(); +//call("lv_raw_dump"); +//msleep(50); +//call("lv_raw_dump2"); +//msleep(50); +//call("lv_sndpas_dump2"); +//msleep(50); +//call("lv_sequence_checker"); +//msleep(50); +//call("lv_save_jpeg"); +//call("lv_sndpas_dump"); +//call("lv_yuv_dump"); +//call("lv_save_raw"); +//call("epptest"); +//call("FA_SavePropertyList"); +//call("epp_vram_dump"); + +//call("epp_sendjpeg"); + +//call("epp_jpeg2card"); + +//call("lv_nv12_dump"); +*/ +//Disable servo aF and stay off +//int servo = 1; +//prop_request_change(PROP_REGISTRATION_DATA_UPDATE_FUNC, &servo, 4); +//int x=0; +//prop_request_change(PROP_CONTINUOUS_AF_MODE, &x, 4); +//int x2=1; +//prop_request_change(PROP_CONTINUOUS_AF_VALID, &x2, 1); + +//servo = 0; +//prop_request_change(PROP_REGISTRATION_DATA_UPDATE_FUNC, &servo, 4); + +//NSTUB(0xFFCE65C8, str:DCIM_06d.jpg_Jpeg_Start[_End[) +//void (*jpeg)(int bar, int baz, int blah) = 0xFFCE65C8; +//jpeg(0,0,1); + +//debug_intercept(); +//prop_request_change(PROP_MOVIE_SOUND_RECORD, 1, 4); +//disable_electronic_level(); +//debug_intercept(); + +/* +//Level Movie Start + + cache_fetch_line(0xFF527424, TYPE_ICACHE); + cache_fake(0xFF527424 , 0xE1A00000, TYPE_ICACHE); +// Available Image Area + cache_fetch_line(0xFF527684, TYPE_ICACHE); + cache_fake(0xFF527684 , 0xE1A00000, TYPE_ICACHE); +// live view app handler 1 + cache_fetch_line(0xFF52D248, TYPE_ICACHE); + cache_fake(0xFF52D248 , 0xE1A00000, TYPE_ICACHE); +// lv app handler 2 + cache_fetch_line(0xFF52E124, TYPE_ICACHE); + cache_fake(0xFF52E124 , 0xE1A00000, TYPE_ICACHE); +// Level.c card warning + cache_fetch_line(0xFF716758, TYPE_ICACHE); + cache_fake(0xFF716758 , 0xE1A00000, TYPE_ICACHE); +// Card warning stop level app + cache_fetch_line(0xFF716770, TYPE_ICACHE); + cache_fake(0xFF716770 , 0xE1A00000, TYPE_ICACHE); + + cache_fetch_line(0xFF540830, TYPE_ICACHE); + cache_fake(0xFF540830 , 0xE1A00000, TYPE_ICACHE); +// move and resize + cache_fetch_line(0xFF52A5D0, TYPE_ICACHE); + cache_fake(0xFF52A5D0 , 0xE1A00000, TYPE_ICACHE); + + cache_fetch_line(0xFF6BE2D0, TYPE_ICACHE); + cache_fake(0xFF6BE2D0 , 0xE1A00000, TYPE_ICACHE); + + cache_fetch_line(0xFF6BE370, TYPE_ICACHE); + cache_fake(0xFF6BE370 , 0xE1A00000, TYPE_ICACHE); + +void (*level)() = 0xFF6BCDC4; + +level(); + + +//void (*jpeg)(int bar, int baz, MEM(MEM(0x7747C) + 0x70)) = 0xFFCE65C8; +//foo(3,4); +/* +int fuck= MEM(MEM(0x7747C) + 0x70); +bmp_printf(FONT_MED, 10,120, "g0 %x", fuck ); +call("lv_jukai_mode"); + + +call("epp_jpeg2card",1); +msleep(100); +call("WriteJpegToCard",1); +msleep(100); +//call(0xFFCE65C8); +msleep(100); +//debug_intercept(); + +//dump_big_seg(4, CARD_DRIVE "ML/LOGS/RAM4.BIN"); +/* + + +// FF5379F4 bl str:StartLiveViewWifiOffConfirmApp_G_REQUEST Fixes record button + + cache_fetch_line(0xFF5379F4, TYPE_ICACHE); + cache_fake(0xFF5379F4 , 0xE1A00000, TYPE_ICACHE); +// cmp r0,0x66 + cache_fetch_line(0xFF5379C4, TYPE_ICACHE); + cache_fake(0xFF5379C4 , 0x0F0000EA, TYPE_ICACHE); +//FF52C054 + cache_fetch_line(0xFF52C054, TYPE_ICACHE); + cache_fake(0xFF52C054 , 0xE1A00000, TYPE_ICACHE); + +//FF6CE608 warning to win system + cache_fetch_line(0xFF6CE608, TYPE_ICACHE); + cache_fake(0xFF6CE608 , 0x050000EA, TYPE_ICACHE); + +//FF537AE0 sub_FF537AA8 + cache_fetch_line(0xFF537AE0, TYPE_ICACHE); + cache_fake(0xFF537AE0 , 0xE1A00000, TYPE_ICACHE); + +//silent_pic_take(0); +//call("FA_MovieStart"); +//msleep(200); +//afmode[0]=101; +//prop_request_change(PROP_AF_MODE, &afmode, 2); + + + + +//lvd[0]=1; +//lvd[1]=0; +//prop_request_change(PROP_CONTINUOUS_AF_MODE, &lvd, 4); +//int x=1; +//prop_request_change(PROP_CONTINUOUS_AF_VALID, &x, 1); +//int y=101; +//lvd[0]=0; +//prop_request_change(PROP_CONTINUOUS_AF_MODE, &lvd, 4); + + +//PowerAudioOutput(); +//SetAudioVolumeOut(5); +//TestSetAudioHeadPhone(1); + //debug_intercept(); +/* video_mode[0] = 0x8; + video_mode[4] = 2; + //video_mode[6] = 2; + prop_request_change(PROP_VIDEO_MODE, video_mode, 24); + int x = 300; + prop_request_change(PROP_DIGITAL_ZOOM_RATIO, &x, 8); +//call("dumpf"); +//bmp_printf(FONT_MED, 10,80, "g0: %d g1: %d g2: %d g3: %d g4 %d", video_mode[0], video_mode[1], video_mode[2], video_mode[3], video_mode[4]); +//bmp_printf(FONT_MED, 10,120, "g0: %d", digital_zoom_ratio); + + + // bmp_printf(FONT_MED, 10,120, "g0: %d", lvd[0]); +SerialCommand_Send(0x00750000); +SerialCommand_Send(0x02200000); + +audio_ic_write(0x0075); +audio_ic_write(0x0220); + + + + + +#ifdef CONFIG_6D + msleep(3000); + movfile = FIO_CreateFileEx("B:/movtest.422"); + record_uncomp = 1; //~ signals to lv_vsync_signal() that it should start writing frames to the card. + msleep(10000); //~ record for 10 seconds before closing file. + record_uncomp = 0; + FIO_CloseFile(movfile); +#endif*/ + } + void run_in_separate_task(void (*priv)(void), int delta) { gui_stop_menu(); @@ -864,8 +1667,10 @@ msleep(2000); { - void* buf = shoot_malloc(bufsize); - if (buf) + //void* buf = alloc_dma_memory(bufsize); + void* buf = shoot_malloc(bufsize); + + if (buf) { FILE* f = FIO_Open(CARD_BENCHMARK_FILE, O_RDONLY | O_SYNC); int t0 = get_ms_clock_value(); @@ -945,7 +1750,7 @@ bmp_printf(FONT_MED, 0, 80, "CF %s %s", CARD_A_MAKER, CARD_A_MODEL); #endif - card_benchmark_wr(2*1024*1024, 1, 9); + card_benchmark_wr(2*1024*1024, 1, 9); card_benchmark_wr(2000000, 2, 9); card_benchmark_wr(3*1024*1024, 3, 9); card_benchmark_wr(3000000, 4, 9); @@ -953,7 +1758,7 @@ card_benchmark_wr(4000000, 6, 9); card_benchmark_wr(16*1024*1024, 7, 9); card_benchmark_wr(16000000, 8, 9); - card_benchmark_wr(128*1024, 9, 9); + //~ card_benchmark_wr(128*1024, 9, 9); call("dispcheck"); msleep(3000); canon_gui_enable_front_buffer(0); @@ -1242,7 +2047,6 @@ } #endif - #ifdef CONFIG_STRESS_TEST /*static void stress_test_long(void* priv, int delta) @@ -2521,7 +3325,6 @@ if (hexdump_addr & 0xF0000000) return; MENU_SET_VALUE( "%s", - "Val string: %s", (char*)hexdump_addr ); } @@ -2870,7 +3673,7 @@ } #endif -#ifdef FEATURE_DEBUG_PROP_DISPLAY +#ifdef FEATURE_PROP_DISPLAY static CONFIG_INT("prop.i", prop_i, 0); static CONFIG_INT("prop.j", prop_j, 0); static CONFIG_INT("prop.k", prop_k, 0); @@ -3130,7 +3933,6 @@ extern void menu_benchmark(); extern int show_cpu_usage_flag; - static struct menu_entry debug_menus[] = { MENU_PLACEHOLDER("File Manager"), #ifdef CONFIG_HEXDUMP @@ -3190,7 +3992,7 @@ }, }, #endif - /*{ + /*{ .name = "Flashlight", .select = flashlight_lcd, .select_reverse = flashlight_frontled, @@ -3230,11 +4032,13 @@ .help = "Dialog templates (up/dn) and color palettes (left/right)" },*/ #endif +#ifdef CONFIG_DUMPROM { .name = "Dump ROM and RAM", .select = dump_rom, .help = "ROM0.BIN:F0000000, ROM1.BIN:F8000000, RAM4.BIN" }, +#endif #ifdef CONFIG_40D { .name = "Dump camera logs", @@ -3250,6 +4054,36 @@ .help = "The camera may turn into a 1DX or it may explode." }, #endif +#ifdef FEATURE_TIMER_HACK + { + .name = "Dialog Timers", + .min = 0, + #ifdef CONFIG_50D + .max = 6, + #else + .max = 1, + #endif + .priv = &hacked_timers, + .select = hacked_timers_select, + .update = hacked_timers_display, + .choices = (const char *[]) {"Normal", "Disabled" + #ifdef CONFIG_50D + , "1024", "4096", "8172", "16384", "32768" + #endif + }, + .help = "Disable dialog timers, dialogs may not work" + }, + + +#endif +#ifdef CONFIG_DUMP_AUDIO + { + .name = "Dump Audio Regs DV", + .priv = audio_reg_dump_dv, + .select = (void(*)(void*,int))run_in_separate_task, + .help = "The camera may turn into a 1DX or it may explode." + }, +#endif #ifdef CONFIG_DEBUG_INTERCEPT { .name = "DM Log", @@ -3257,6 +4091,8 @@ .select = (void(*)(void*,int))run_in_separate_task, .help = "Log DebugMessages" }, + #endif + #ifdef FEATURE_TP_INTERCEPT { .name = "TryPostEvent Log", .priv = j_tp_intercept, @@ -3565,12 +4401,12 @@ .icon_type = IT_ALWAYS_ON, }, #endif -#ifdef FEATURE_DEBUG_PROP_DISPLAY +#ifdef FEATURE_PROP_DISPLAY { - .name = "PROP Display", + .name = "PROP", .update = prop_display, .select = prop_toggle_k, - // .select_reverse = prop_toggle_j, + //.select_reverse = prop_toggle_j, .select_Q = prop_toggle_i, .help = "Raw property display (read-only)", }, @@ -4040,20 +4876,19 @@ retries > 2 ? "Restart your camera (malloc error)." : "Format: malloc error :(" ); - beep(); + beep(); msleep(2000); return 0; } - if (!tmp_buffer) tmp_buffer = (void*)shoot_malloc(TMP_MAX_BUF_SIZE); if (!tmp_buffer) { retries++; - HijackCurrentDialogBox(4, - retries > 2 ? "Restart your camera (shoot_malloc err)." : + HijackCurrentDialogBox(4, + retries > 5 ? "Restart your camera (shoot_malloc err)." : "Format: shoot_malloc error, retrying..." ); - beep(); + beep(); msleep(2000); SmallFree(tmp_files); tmp_files = 0; return 0; diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/dm-spy.c --- a/src/dm-spy.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/dm-spy.c Sun Sep 22 11:41:50 2013 -0500 @@ -23,7 +23,7 @@ #include "cache_hacks.h" #endif -unsigned int BUF_SIZE = (1024*1024); +unsigned int BUF_SIZE = 2*(1024*1024); static char* buf = 0; static int len = 0; @@ -62,7 +62,8 @@ { if (!buf) // first call, intercept debug messages { - buf = alloc_dma_memory(BUF_SIZE); + //~ buf = alloc_dma_memory(BUF_SIZE); + buf = shoot_malloc(BUF_SIZE); #if defined(CONFIG_DIGIC_V) uint32_t d = (uint32_t)&DryosDebugMsg; diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/edmac-memcpy.c --- a/src/edmac-memcpy.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/edmac-memcpy.c Sun Sep 22 11:41:50 2013 -0500 @@ -15,15 +15,25 @@ #if defined(CONFIG_5D2) || defined(CONFIG_50D) uint32_t edmac_read_chan = 0x19; uint32_t edmac_write_chan = 0x3; +/* +50D +R 2-15 +W 3-8 10-15 +*/ #elif defined(CONFIG_650D) || defined(CONFIG_EOSM) || defined(CONFIG_700D) || defined(CONFIG_100D) uint32_t edmac_read_chan = 0x19; uint32_t edmac_write_chan = 0x13; +//~ r 2 3 5 7 8 9 10 11-13 +//~ w 3 4 6 10 11-15 #elif defined(CONFIG_60D) uint32_t edmac_read_chan = 0x19; /* free indices: 2, 3, 4, 5, 6, 7, 8, 9 */ uint32_t edmac_write_chan = 0x06; /* 1, 4, 6, 10 */ +#elif defined(CONFIG_6D) +uint32_t edmac_read_chan = 0x19; /* Read: 0 5 7 11 14 15 */ +uint32_t edmac_write_chan = 0x11; /* Write: 6 8 15 */ #elif defined(CONFIG_7D) -uint32_t edmac_read_chan = 0x19; -uint32_t edmac_write_chan = 0x04; +uint32_t edmac_read_chan = 0x19; /*Read 1 2 3 4 5 7 8 9 10 11 12 13 14 15 */ +uint32_t edmac_write_chan = 0x05; /* Write 3 4 5 6 7 8 10 11 12 13 14 15 */ #else uint32_t edmac_read_chan = 0x19; uint32_t edmac_write_chan = 0x11; @@ -68,7 +78,7 @@ } //~ else bmp_printf(FONT_MED, 50, 50, "%d %d %d %d %d ", edmac_write_chan, write_edmac_index, edmac_read_chan, read_edmac_index, dmaConnection, resLock); - ASSERT(resLock); + //~ ASSERT(resLock); #endif } @@ -109,6 +119,7 @@ take_semaphore(edmac_memcpy_sem, 0); /* see wiki, register map, EDMAC what the flags mean. they are for setting up copy block size */ + //~ uint32_t dmaFlags = 0x60000000; uint32_t dmaFlags = 0x20001000; /* create a memory suite from a already existing (continuous) memory block with given size. */ diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/exmem.c --- a/src/exmem.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/exmem.c Sun Sep 22 11:41:50 2013 -0500 @@ -125,6 +125,7 @@ { /* allocate some backup that will service the queued allocation request that fails during the loop */ int backup_size = 8 * 1024 * 1024; + //~ int backup_size = 4 * 1024 * 1024; int max_size = 0; struct memSuite *backup = shoot_malloc_suite(backup_size); diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/fps-engio.c --- a/src/fps-engio.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/fps-engio.c Sun Sep 22 11:41:50 2013 -0500 @@ -130,11 +130,10 @@ #endif }; -static CONFIG_INT("fps.override", fps_override, 0); +CONFIG_INT("fps.override", fps_override, 0); #ifndef FEATURE_FPS_OVERRIDE #define fps_override 0 #endif - static CONFIG_INT("fps.override.idx", fps_override_index, 10); // 1000 = zero, more is positive, less is negative @@ -200,12 +199,12 @@ #define FPS_TIMER_B_MAX (0x4000-1) #endif + #ifdef CONFIG_FPS_TIMER_A_ONLY #undef FPS_TIMER_B_MAX #define FPS_TIMER_B_MAX fps_timer_b_orig #endif -//~ #define FPS_TIMER_B_MIN (fps_timer_b_orig-100) #define FPS_TIMER_B_MIN fps_timer_b_orig // it might go lower than that, but it causes trouble high shutter speeds #define ZOOM (lv_dispsize > 1) @@ -231,21 +230,22 @@ #define FPS_TIMER_B_MIN (fps_timer_b_orig - (ZOOM ? 44 : MV720 ? 0 : 70)) /* you can push LiveView until 68fps (timer_b_orig - 50), but good luck recording that */ #elif defined(CONFIG_EOSM) #define TG_FREQ_BASE 32000000 - #define TG_FREQ_SHUTTER (ntsc || !recording ? 56760000 : 50000000) - #define FPS_TIMER_A_MIN 520 + #define TG_FREQ_SHUTTER (ntsc ? 56760000 : 50000000) + #define FPS_TIMER_A_MIN (fps_timer_a_orig - (ZOOM ? 10 : MV720 ? 10 : MV1080CROP ? 10 : 10)) /* Can relax a little more but get black bar */ + //~ #define FPS_TIMER_A_MIN MIN(fps_timer_a_orig - (ZOOM ? 0 : 20), ZOOM ? 716 : 520) + // #undef FPS_TIMER_B_MIN - #define FPS_TIMER_B_MIN MIN(fps_timer_b_orig, 1970) - //~ #undef FPS_TIMER_B_MAX - //~ #define FPS_TIMER_B_MAX 0x8000 - //~ #undef FPS_TIMER_A_MAX - //~ #define FPS_TIMER_A_MAX 0x8000 + #define FPS_TIMER_B_MIN (fps_timer_b_orig - (ZOOM ? 261 : MV720 ? 127 : MV1080CROP ? 1204 : 127)) + //IDLE 2022 1895 + //CROP 2444 1240 + //5X 1491 1200~1230 + #elif defined(CONFIG_6D) #define TG_FREQ_BASE 25600000 - #define TG_FREQ_SHUTTER (ntsc ? 44000000 : 40000000) - #define FPS_TIMER_A_MIN MIN(fps_timer_a_orig - (ZOOM ? 0 : 20), ZOOM ? 708 : 512) - #undef FPS_TIMER_B_MIN - #define FPS_TIMER_B_MIN MIN(fps_timer_b_orig, 1386) - // 1294 - 1363/64 + #define TG_FREQ_SHUTTER (ntsc ? 43920000 : 40000000) + #define FPS_TIMER_A_MIN (fps_timer_a_orig - (ZOOM ? 22 : MV720 ? 10 : 34) ) //, ZOOM ? 708 : 512) + #undef FPS_TIMER_B_MIN + #define FPS_TIMER_B_MIN (fps_timer_b_orig - (ZOOM ? 6 : MV720 ? 10 : 10)) #elif defined(CONFIG_650D) #define TG_FREQ_BASE 32000000 #define TG_FREQ_SHUTTER (ntsc ? 56760000 : 50000000) @@ -256,7 +256,10 @@ #define FPS_TIMER_A_MIN MIN(fps_timer_a_orig - (ZOOM ? 0 : 10), ZOOM ? 1400 : video_mode_resolution == 0 ? 1284 : 1348) #elif defined(CONFIG_50D) #define TG_FREQ_BASE 28800000 - #define TG_FREQ_SHUTTER 41379310 // not sure + //~ #define TG_FREQ_SHUTTER 46080000 // ShutterT * 60000 + #define TG_FREQ_SHUTTER 38760000 // ShutterT (646) * 60000 ISO 100 1/60.0 + //~ #define TG_FREQ_SHUTTER 74460000 // ShutterT (1241) * 60000 1/30 shows 1/60 + //~ #define TG_FREQ_SHUTTER 37230000 // ShutterT (1241) * 60000 1/60/2 #define FPS_TIMER_A_MIN MIN(fps_timer_a_orig - (ZOOM ? 0 : 10), ZOOM ? 630 : 688 ) #else // 550D, 600D, 60D #define TG_FREQ_BASE 28800000 @@ -308,6 +311,20 @@ #endif */ +/* +#if defined(CONFIG_6D) + #define NEW_FPS_METHOD 1 + #define SENSOR_TIMING_TABLE MEM(0x82e14) // This is right. + #define VIDEO_PARAMETERS_SRC_3 MEM(0x76cfc) +// #undef FPS_TIMER_B_MIN + // #define FPS_TIMER_B_MIN 100 +// #define FPS_TIMER_B_MIN fps_timer_b_orig + static const int mode_offset_map[] = { 4, 7, 2, 6, 5, 0, 2 }; +#endif +*/ + + + #ifdef NEW_FPS_METHOD static int fps_timer_b_method = 0; static uint16_t * sensor_timing_table_original = 0; @@ -573,7 +590,7 @@ return; #endif - #ifdef CONFIG_5D2 + #if defined(CONFIG_5D2) Gui_SetSoundRecord(COERCE(x,1,3)); #else prop_request_change(PROP_MOVIE_SOUND_RECORD, &x, 4); @@ -693,7 +710,7 @@ // check hard limits again timerB = COERCE(timerB, FPS_TIMER_B_MIN, FPS_TIMER_B_MAX); - #ifdef NEW_FPS_METHOD + #if defined(NEW_FPS_METHOD) if (fps_timer_b_method == 0) // digic method { fps_unpatch_table(1); @@ -718,7 +735,7 @@ written_value_b = PACK(timerB, fps_reg_b_orig); EngDrvOutFPS(FPS_REGISTER_B, written_value_b); fps_needs_updating = 0; - #ifdef NEW_FPS_METHOD + #if defined(NEW_FPS_METHOD) } else { @@ -827,12 +844,13 @@ memcpy(video_mode, buf, len); } + static void flip_zoom_twostage(int stage) { // flip zoom or video mode back and forth to apply settings instantly if (!lv) return; if (recording) return; - #ifndef CONFIG_DIGIC_V // causes corrupted video headers on 5D3 + #ifndef CONFIG_5D3 // causes corrupted video headers on 5D3 if (is_movie_mode()) { // in movie mode, flipping the FPS seems nicer @@ -884,7 +902,7 @@ flip_zoom_twostage(1); flip_zoom_twostage(2); } - +#ifndef CONFIG_DIGIC_V static void fps_unpatch_table(int refresh) { if (SENSOR_TIMING_TABLE == (intptr_t) sensor_timing_table_original) @@ -898,6 +916,7 @@ } } #endif +#endif // don't msleep from here, it may be called from GMT static void fps_register_reset() @@ -925,7 +944,7 @@ fps_disable_timers_evfstate(); #endif - #ifdef NEW_FPS_METHOD + #if defined(NEW_FPS_METHOD) && !defined(CONFIG_DIGIC_V) fps_unpatch_table(1); #endif @@ -1163,10 +1182,11 @@ fps_timer_b_method = 1; #endif - #ifdef CONFIG_DIGIC_V + //~ #ifdef CONFIG_DIGIC_V /* we need to do the magic from timer A... */ - timerA_max = FPS_TIMER_A_MAX; - #endif + //~ timerA_max = FPS_TIMER_A_MAX; + //~ #endif + break; } @@ -1435,7 +1455,7 @@ if (recording == 1) return; //~ info_led_blink(1,10,10); fps_reg_a_orig = FPS_REGISTER_A_DEFAULT_VALUE; - #ifdef NEW_FPS_METHOD + #if defined(NEW_FPS_METHOD) int mode = get_fps_video_mode(); unsigned int pos = get_table_pos(mode_offset_map[mode], video_mode_crop, 0, lv_dispsize); fps_reg_b_orig = sensor_timing_table_original[pos] - 1; // nobody will change it from here :) @@ -1481,14 +1501,19 @@ static volatile int fps_timerA_override = 0; static volatile int fps_timerB_override = 0; static volatile int fps_timers_updated = 0; - +//~ static int k = 0; void fps_update_timers_from_evfstate() { - if (fps_timerA_override && fps_timerB_override && !fps_video_mode_changed()) + if (fps_timerA_override && fps_timerB_override && !fps_video_mode_changed()) { EngDrvOutLV(FPS_REGISTER_A, fps_timerA_override); - EngDrvOutLV(FPS_REGISTER_B, fps_timerB_override); + + //~ if (k % 2 == 0) + //~ EngDrvOutLV(FPS_REGISTER_B, fps_timerB_override - 1); + //~ else + EngDrvOutLV(FPS_REGISTER_B, fps_timerB_override); EngDrvOutLV(FPS_REGISTER_CONFIRM_CHANGES, 1); + //~ k++; } fps_timers_updated = 1; } @@ -1515,7 +1540,7 @@ { TASK_LOOP { - + #ifdef FEATURE_FPS_RAMPING if (FPS_RAMP) { @@ -1598,8 +1623,8 @@ #endif fps_read_current_timer_values(); - // take care of sound settings to prevent recording from stopping - update_sound_recording(); + // take care of sound settings to prevent recording from stopping + update_sound_recording(); int x0 = os.x0; int y0 = os.y_max - 2; @@ -1639,17 +1664,20 @@ continue; } - //~ info_led_on(); fps_setup_timerA(f); #ifndef CONFIG_FPS_TIMER_A_ONLY fps_setup_timerB(f); #endif - //~ info_led_off(); + + fps_read_current_timer_values(); //~ bmp_printf(FONT_LARGE, 50, 100, "%dx, new timers: %d,%d ", lv_dispsize, fps_timer_a, fps_timer_b); - // take care of sound settings to prevent recording from stopping - update_sound_recording(); + // take care of sound settings to prevent recording from stopping + update_sound_recording(); + + + if (!fps_warned && !gui_menu_shown()) { @@ -1661,6 +1689,12 @@ NotifyBox(2000, msg); fps_warned = 1; } + + + #ifdef CONFIG_50D + if (fps_warned && ((fps_get_current_x1000()/1000) == 22) && (fps_get_current_x1000() != fps_values_x1000[fps_override_index]) ) + NotifyBox(2000, "FPS warning, possible overheating!\n"); + #endif #ifdef FEATURE_EXPO_OVERRIDE if (CONTROL_BV && !is_movie_mode()) // changes in FPS may affect expsim calculations in photo mode @@ -1715,7 +1749,7 @@ event->param == BGMT_LV #endif - #ifdef NEW_FPS_METHOD + #if defined(NEW_FPS_METHOD) && !defined(CONFIG_DIGIC_V) // we won't be able to change/restore FPS on the fly with table patching method :( && SENSOR_TIMING_TABLE != (intptr_t) sensor_timing_table_patched #endif @@ -1825,7 +1859,7 @@ video_mode_fps == 24 ? 4 : 0; return mode; } - +#ifndef CONFIG_DIGIC_V int get_table_pos(unsigned int fps_mode, unsigned int crop_mode, unsigned int type, int dispsize) { unsigned short ret[2]; @@ -1916,5 +1950,5 @@ } INIT_FUNC("sensor-timing", sensor_timing_table_init); - +#endif #endif // NEW_FPS_METHOD diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/fw-signature.h --- a/src/fw-signature.h Fri Sep 20 16:56:08 2013 +0300 +++ b/src/fw-signature.h Sun Sep 22 11:41:50 2013 -0500 @@ -27,6 +27,7 @@ #define SIG_6D_113 0x6B6A9C6F #define SIG_5D3_113 0x2e2f65f5 #define SIG_EOSM_106 0x6393A881 +#define SIG_EOSM_202 0x2D7c6dcf #define SIG_7D_203 0x50163E93 #define SIG_7D_MASTER_203 0x640BF4D1 #define SIG_650D_104 0x4B7FC4D0 diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/gui-common.c --- a/src/gui-common.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/gui-common.c Sun Sep 22 11:41:50 2013 -0500 @@ -11,7 +11,10 @@ #define CONFIG_LVAPP_HACK_RELOC #elif defined(CONFIG_5D3) || defined(CONFIG_6D) || defined(CONFIG_EOSM) #define CONFIG_LVAPP_HACK_DEBUGMSG -#elif defined(CONFIG_650D) || defined(CONFIG_700D) || defined(CONFIG_100D) +#if defined(CONFIG_6D) || defined(CONFIG_EOSM) +#define CONFIG_LVAPP_HACK_FBUFF // One is for scroll wheel, one is for 1/2 shutter +#endif +#elif defined(CONFIG_650D) || defined(CONFIG_700D) || defined(CONFIG_100D) || defined(CONFIG_6D) #define CONFIG_LVAPP_HACK_FBUFF #endif @@ -19,14 +22,37 @@ #define CONFIG_LVAPP_HACK #endif +#ifdef CONFIG_LVAPP_HACK_FBUFF +static void black_bars_16x9() +{ + if (!get_global_draw()) return; + if (!is_movie_mode()) return; + get_yuv422_vram(); + if (video_mode_resolution > 1) + { + int off_43 = (os.x_ex - os.x_ex * 8/9) / 2; + bmp_fill(COLOR_BLACK, os.x0, os.y0, off_43, os.y_ex); + bmp_fill(COLOR_BLACK, os.x_max - off_43, os.y0, off_43, os.y_ex); + } + else + { + bmp_fill(COLOR_BLACK, os.x0, os.y0, os.x_ex, os.off_169); + bmp_fill(COLOR_BLACK, os.x0, os.y_max - os.off_169, os.x_ex, os.off_169); + } +} +#endif + + static int bottom_bar_dirty = 0; static int last_time_active = 0; int is_canon_bottom_bar_dirty() { return bottom_bar_dirty; } int get_last_time_active() { return last_time_active; } +#ifndef CONFIG_50D // disable Canon bottom bar static int bottom_bar_hack = 0; +#endif #if defined(CONFIG_LVAPP_HACK_DEBUGMSG) @@ -42,7 +68,7 @@ #elif defined(CONFIG_6D) MEM(0x841C0) = 0; #elif defined(CONFIG_EOSM) - MEM(0x5D88C) = 0; + MEM(0x5D43C) = 0; #endif #ifdef CONFIG_5D3 @@ -122,9 +148,9 @@ #ifdef CONFIG_LVAPP_HACK_FBUFF if (!canon_gui_front_buffer_disabled() && UNAVI_FEEDBACK_TIMER_ACTIVE) - { - clrscr(); - canon_gui_disable_front_buffer(); + { canon_gui_disable_front_buffer(); + clrscr(); + black_bars_16x9(); bottom_bar_dirty=0; } @@ -299,6 +325,33 @@ return 1; } #endif //CONFIG_MENU_WITH_AV +/* +#ifdef CONFIG_50D + + +int disp_zoom_pressed = 0; + +int handle_wheel_shutter(struct event * event) +{ + switch(event->param) { + case BGMT_WHEEL_LEFT: + disp_pressed = 1; + break; + case BGMT_WHEEL_RIGHT: + disp_pressed = 0; + break; + default: + break; + } + + + + + +#endif + +*/ + #ifdef FEATURE_DIGITAL_ZOOM_SHORTCUT PROP_INT(PROP_DIGITAL_ZOOM_RATIO, digital_zoom_ratio); diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/hdr.c --- a/src/hdr.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/hdr.c Sun Sep 22 11:41:50 2013 -0500 @@ -10,12 +10,19 @@ #include "lens.h" #include "propvalues.h" #include "config.h" +/* +#ifdef CONFIG_7D_MASTER +#include "ml_rpc.h" +#endif +*/ #if defined(CONFIG_MODULES) #include "module.h" #endif -//#define FEATURE_HDR_EXTENDED +#ifdef CONFIG_FRAME_SHUTTER_OVERRIDE +#define FEATURE_HDR_EXTENDED +#endif #ifdef FEATURE_HDR_EXTENDED #define CONFIG_HDR_EXTENDED_STEPS 8 @@ -73,16 +80,15 @@ #ifdef FEATURE_HDR_EXTENDED static int hdrv_shutter_table[] = { 0, 24, 25, 30, 40, 50, 60, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1500, 2000, 3000, 4000, 6000, 8000, 12500, 25000}; -static void hdrv_extended_shutter_display( void * priv, int x, int y, int selected ) +static MENU_UPDATE_FUNC (hdrv_extended_shutter_display) { - uint8_t *shutter_index = (uint8_t *)priv; - uint8_t pos = hdrv_extended_step_edit - 1; + + uint8_t *shutter_index = hdrv_extended_shutter; + uint8_t pos = hdrv_extended_step_edit - 1; - if(shutter_index[pos]) + if(CURRENT_VALUE) { - bmp_printf( - selected ? MENU_FONT_SEL : MENU_FONT, - x, y, + MENU_SET_VALUE( "Shutter #%d : 1/%d", pos + 1, hdrv_shutter_table[shutter_index[pos]] @@ -90,9 +96,7 @@ } else { - bmp_printf( - selected ? MENU_FONT_SEL : MENU_FONT, - x, y, + MENU_SET_VALUE( "Shutter #%d : ---", pos + 1 ); @@ -100,11 +104,11 @@ if(hdrv_extended_step_edit > hdrv_extended_steps) { - menu_draw_icon(x, y, MNI_WARNING, (intptr_t) "This entry is unused. Increase step count."); + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "This entry is unused. Increase step count."); } } -void hdrv_extended_shutter_toggle(void* priv, int delta) +static MENU_SELECT_FUNC (hdrv_extended_shutter_toggle) { uint8_t *shutter_index = (uint8_t *)priv; uint8_t pos = hdrv_extended_step_edit - 1; @@ -114,21 +118,25 @@ shutter_index[pos] = new_pos; } -static void hdrv_extended_iso_toggle(void* priv, int delta) +static MENU_SELECT_FUNC (hdrv_extended_iso_toggle) { uint8_t *iso_table = (uint8_t *)priv; uint8_t pos = hdrv_extended_step_edit - 1; + int new_pos = 0; do { - iso_table[pos] = mod(iso_table[pos] - 72 + delta, MAX_ISO_BV - 72 + 1) + 72; + new_pos = mod(iso_table[pos] - 72 + delta, MAX_ISO_BV - 72 + 1) + 72; + iso_table[pos] = new_pos; } while (!is_hdr_valid_iso(raw2iso(iso_table[pos]))); } -void hdrv_extended_iso_display(void *priv, int x, int y, int selected) +static MENU_UPDATE_FUNC (hdrv_extended_iso_display) { - uint8_t *iso_table = (uint8_t *)priv; - uint8_t pos = hdrv_extended_step_edit - 1; + uint8_t *iso_table = hdrv_extended_iso; + + uint8_t pos = hdrv_extended_step_edit - 1; + int effective_iso = get_effective_hdr_iso_for_display(iso_table[pos]); int d = effective_iso - iso_table[pos]; d = d * 10 / 8; @@ -137,9 +145,7 @@ { if (d) { - bmp_printf( - selected ? MENU_FONT_SEL : MENU_FONT, - x, y, + MENU_SET_VALUE( "ISO #%d: %d (%d, %s%d.%d EV)", pos + 1, raw2iso(effective_iso), @@ -149,9 +155,7 @@ } else { - bmp_printf( - selected ? MENU_FONT_SEL : MENU_FONT, - x, y, + MENU_SET_VALUE( "ISO #%d : %d", pos + 1, raw2iso(effective_iso) @@ -160,16 +164,14 @@ } else { - bmp_printf( - selected ? MENU_FONT_SEL : MENU_FONT, - x, y, - "ISO #%d : ---", + MENU_SET_VALUE( + "OFF #%d : ---", pos + 1 ); } if(hdrv_extended_step_edit > hdrv_extended_steps) { - menu_draw_icon(x, y, MNI_WARNING, (intptr_t) "This entry is unused. Increase step count."); + MENU_SET_WARNING(MENU_WARN_NOT_WORKING, "This entry is unused. Increase step count."); } } #endif @@ -452,22 +454,22 @@ .help = "Edit ISO/Shutter settings.", }, { - .name = "Ext. ISO", + .name = "Ext.", .priv = hdrv_extended_iso, .min = 72, .max = MAX_ISO_BV, .select = hdrv_extended_iso_toggle, - .display = hdrv_extended_iso_display, + .update = hdrv_extended_iso_display, .unit = UNIT_ISO, .help = "Edit ISO settings.", }, { - .name = "Ext. Shutter", + .name = "Ext.", .priv = hdrv_extended_shutter, - .min = 1, + .min = 0, .max = MAX_ISO_BV, .select = hdrv_extended_shutter_toggle, - .display = hdrv_extended_shutter_display, + .update = hdrv_extended_shutter_display, .help = "Edit Shutter settings.", }, #endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/installer.c --- a/src/installer.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/installer.c Sun Sep 22 11:41:50 2013 -0500 @@ -28,6 +28,10 @@ #include "menu.h" #include "property.h" #include "consts.h" +#if defined(HIJACK_CACHE_HACK) +#include "cache_hacks.h" +#endif + /** These are called when new tasks are created */ int my_init_task(int a, int b, int c, int d); @@ -141,11 +145,22 @@ void -__attribute__((noreturn,noinline,naked)) +__attribute__((noreturn,noinline)) copy_and_restart( int offset ) { zero_bss(); +#ifdef HIJACK_CACHE_HACK + /* make sure we have the first segment locked in d/i cache for patching */ + cache_lock(); + + /* patch init code to start our init task instead of canons default */ + cache_fake(HIJACK_CACHE_HACK_INITTASK_ADDR, (uint32_t) my_init_task, TYPE_DCACHE); + + /* now start main firmware */ + void (*reset)(void) = (void*) ROMBASEADDR; + reset(); +#else // Set the flag if this was an autoboot load autoboot_loaded = (offset == 0); @@ -209,7 +224,7 @@ // instead. void (*ram_cstart)(void) = (void*) &INSTR( cstart ); ram_cstart(); - +#endif // Unreachable while(1) ; diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/lens.c --- a/src/lens.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/lens.c Sun Sep 22 11:41:50 2013 -0500 @@ -1919,8 +1919,7 @@ iso_components_update(); } - -#ifdef CONFIG_EOSM +#if defined(CONFIG_EOSM) PROP_HANDLER( PROP_LV_FOCAL_DISTANCE ) { #ifdef FEATURE_MAGIC_ZOOM @@ -1940,7 +1939,7 @@ const struct prop_lv_lens * const lv_lens = (void*) buf; lens_info.focal_len = bswap16( lv_lens->focal_len ); lens_info.focus_dist = bswap16( lv_lens->focus_dist ); - + //~ NotifyBox(1000, "Lens: %08x D:%08x", lv_lens->focal_len, lv_lens->focus_dist); if (lens_info.focal_len > 1000) // bogus values lens_info.focal_len = 0; diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/lens.h --- a/src/lens.h Fri Sep 20 16:56:08 2013 +0300 +++ b/src/lens.h Sun Sep 22 11:41:50 2013 -0500 @@ -93,6 +93,7 @@ #if defined(CONFIG_6D) struct prop_lv_lens { + uint32_t lens_rotation; // Identical Doesn't Change uint32_t lens_step; // Value Matches initial but doesn't move. uint32_t off_0x08; @@ -103,13 +104,13 @@ uint32_t off_0x1c; uint32_t off_0x20; uint32_t off_0x24; - uint32_t off_0x28; - uint16_t off_unk0; - uint8_t off_unk1; - uint16_t focal_len; - uint16_t off_unk2; + uint32_t off_0x28; //-10 + uint16_t off_unk0; + uint8_t off_unk1; + uint16_t focal_len; + uint16_t off_unk2; uint16_t focus_dist; - uint32_t off_0x30; + uint32_t off_0x30; uint32_t off_0x34; uint8_t off_0x38; @@ -165,7 +166,6 @@ } __attribute__((packed)); SIZE_CHECK_STRUCT( prop_lv_lens, 58 ); - #endif struct prop_focus @@ -241,8 +241,15 @@ // exact values: //~ static const int values_shutter[] = {0, 24, 26, 29, 31, 34, 37, 41, 44, 48, 53, 57, 63, 68, 74, 81, 88, 96, 105, 115, 125, 136, 149, 162, 177, 193, 210, 229, 250, 273, 297, 324, 354, 386, 420, 459, 500, 545, 595, 648, 707, 771, 841, 917,1000,1091,1189,1297,1414,1542,1682,1834,2000,2181,2378,2594,2828,3084,3364,3668,4000,4362,4757,5187,5657,6169,6727,7336,8000}; // rounded to 2 digits: +/* +#ifdef CONFIG_50D +static const uint16_t values_shutter[] = { 25, 26, 29, 31, 34, 37, 41, 44, 48, 53, 57, 63, 68, 74, 81, 88, 96, 110, 120, 130, 140, 150, 160, 180, 190, 210, 230, 250, 270, 300, 320, 350, 390, 420, 460, 500, 560, 600, 650, 710, 770, 840, 920,1000,1100,1200,1300,1400,1500,1700,1800,2000,2200,2300,2600,2800,3000,3400,3700,4000,4400,4800,5200,5600,6200,6800,7300,8000}; +static const uint8_t codes_shutter[] = { 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160}; +#else +*/ static const uint16_t values_shutter[] = {0, 25, 26, 29, 31, 34, 37, 41, 44, 48, 53, 57, 63, 68, 74, 81, 88, 96, 110, 120, 130, 140, 150, 160, 180, 190, 210, 230, 250, 270, 300, 320, 350, 390, 420, 460, 500, 560, 600, 650, 710, 770, 840, 920,1000,1100,1200,1300,1400,1500,1700,1800,2000,2200,2300,2600,2800,3000,3400,3700,4000,4400,4800,5200,5600,6200,6800,7300,8000}; static const uint8_t codes_shutter[] = {0, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160}; +//~ #endif // aperture*10 // in 1/8ev, but values different than Canon display: diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/lv-img-engio.c --- a/src/lv-img-engio.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/lv-img-engio.c Sun Sep 22 11:41:50 2013 -0500 @@ -523,7 +523,7 @@ vignetting_data_prep[index] = data; } -#if defined(CONFIG_7D) +#if defined(CONFIG_7D) //&& !defined(CONFIG_7D_MASTER) /* send vignetting data to master */ ml_rpc_send_vignetting(vignetting_data_prep, vignetting_correction_enable ? sizeof(vignetting_data_prep) : 0); #endif @@ -584,7 +584,7 @@ uint32_t *state = (uint32_t *)priv; *state = !*state; -#if defined(CONFIG_7D) +#if defined(CONFIG_7D) //&& !defined(CONFIG_7D_MASTER) ml_rpc_send_vignetting(vignetting_data_prep, *state ? sizeof(vignetting_data_prep) : 0); #endif } @@ -595,7 +595,7 @@ vignetting_correction_set_coeffs(vignetting_correction_a, vignetting_correction_b, vignetting_correction_c); -#ifdef CONFIG_7D +#if defined(CONFIG_7D)// && !defined(CONFIG_7D_MASTER) if (vignetting_correction_enable) ml_rpc_send_vignetting(vignetting_data_prep, sizeof(vignetting_data_prep)); #endif @@ -1137,4 +1137,6 @@ } INIT_FUNC("lv_img", lv_img_init); +//~ #ifdef FEATURE_VIGNETTING_CORRECTION TASK_CREATE( "vignetting_init", vignetting_init, 0, 0x1e, 0x2000 ); +//~ #endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/menu.c --- a/src/menu.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/menu.c Sun Sep 22 11:41:50 2013 -0500 @@ -31,6 +31,11 @@ #include "font.h" #include "menu.h" +#ifndef CONFIG_RAW_LIVEVIEW +static int raw_lv_is_enabled() { return 0; } +#endif + + #define CONFIG_MENU_ICONS //~ #define CONFIG_MENU_DIM_HACKS #undef SUBMENU_DEBUG_JUNKIE @@ -123,6 +128,13 @@ #define HAS_SINGLE_ITEM_SUBMENU(entry) ((entry)->children && !(entry)->children[0].next && !(entry)->children[0].prev && !MENU_IS_EOL(entry->children)) #define IS_SINGLE_ITEM_SUBMENU_ENTRY(entry) (!(entry)->next && !(entry)->prev) +#ifdef FEATURE_NOHELP +void str_make_lowercase(char* s) +{ + while (*s) { *s = tolower(*s); s++; } +} +#endif + static int can_be_turned_off(struct menu_entry * entry) { return @@ -975,7 +987,7 @@ main_ptr->select = PIC_RESOLVE(main_ptr->select); //~ main_ptr->select_reverse = PIC_RESOLVE(main_ptr->select_reverse); main_ptr->select_Q = PIC_RESOLVE(main_ptr->select_Q); - main_ptr->display = PIC_RESOLVE(main_ptr->display); + //~ main_ptr->display = PIC_RESOLVE(main_ptr->display); main_ptr->help = PIC_RESOLVE(main_ptr->help); main_ptr->name = PIC_RESOLVE(main_ptr->name); main_ptr->priv = PIC_RESOLVE(main_ptr->priv); @@ -1937,7 +1949,7 @@ snprintf(warning, MENU_MAX_WARNING_LEN, "This feature requires Manual (M) mode."); else if (DEPENDS_ON(DEP_MANUAL_ISO) && !lens_info.raw_iso) snprintf(warning, MENU_MAX_WARNING_LEN, "This feature requires manual ISO."); - else if (DEPENDS_ON(DEP_SOUND_RECORDING) && !SOUND_RECORDING_ENABLED) + else if (DEPENDS_ON(DEP_SOUND_RECORDING) && !SOUND_RECORDING_ENABLED && !hibr_should_record_wav()) snprintf(warning, MENU_MAX_WARNING_LEN, (was_sound_recording_disabled_by_fps_override() && !fps_should_record_wav()) ? "Sound recording was disabled by FPS override." : "Sound recording is disabled. Enable it from Canon menu." @@ -3822,7 +3834,9 @@ if (menu_help_active) { - BMP_LOCK( menu_help_redraw(); ) + #ifndef FEATURE_NOHELP + BMP_LOCK( menu_help_redraw(); ) + #endif menu_damage = 0; } else @@ -3887,8 +3901,9 @@ draw_ml_bottombar(0, 1); bfnt_draw_char(ICON_ML_Q_BACK, 680, -5, COLOR_WHITE, COLOR_BLACK); } - +#ifndef FEATURE_NOHELP if (beta_should_warn()) draw_beta_warning(); +#endif #ifdef CONFIG_CONSOLE console_draw_from_menu(); @@ -4218,8 +4233,9 @@ case BGMT_PRESS_UP: case BGMT_WHEEL_UP: - if (menu_help_active) { menu_help_prev_page(); break; } - + #ifndef FEATURE_NOHELP + if (menu_help_active) { menu_help_prev_page(); break; } + #endif if (edit_mode && !menu_lv_transparent_mode) menu_entry_select( menu, 1 ); else @@ -4232,8 +4248,9 @@ case BGMT_PRESS_DOWN: case BGMT_WHEEL_DOWN: - if (menu_help_active) { menu_help_next_page(); break; } - + #ifndef FEATURE_NOHELP + if (menu_help_active) { menu_help_next_page(); break; } + #endif if (edit_mode && !menu_lv_transparent_mode) menu_entry_select( menu, 0 ); else @@ -4247,7 +4264,9 @@ case BGMT_PRESS_RIGHT: case BGMT_WHEEL_RIGHT: menu_damage = 1; + #ifndef FEATURE_NOHELP if (menu_help_active) { menu_help_next_page(); break; } + #endif if (SUBMENU_OR_EDIT || menu_lv_transparent_mode) menu_entry_select( menu, 0 ); else { menu_move( menu, 1 ); menu_lv_transparent_mode = 0; menu_needs_full_redraw = 1; } //~ menu_hidden_should_display_help = 0; @@ -4256,7 +4275,9 @@ case BGMT_PRESS_LEFT: case BGMT_WHEEL_LEFT: menu_damage = 1; + #ifndef FEATURE_NOHELP if (menu_help_active) { menu_help_prev_page(); break; } + #endif if (SUBMENU_OR_EDIT || menu_lv_transparent_mode) menu_entry_select( menu, 1 ); else { menu_move( menu, -1 ); menu_lv_transparent_mode = 0; menu_needs_full_redraw = 1; } //~ menu_hidden_should_display_help = 0; @@ -4497,7 +4518,9 @@ static void piggyback_canon_menu() { #ifdef GUIMODE_ML_MENU + #if !defined(CONFIG_EOSM) // EOS M won't open otherwise if (recording) return; + #endif if (sensor_cleaning) return; if (gui_state == GUISTATE_MENUDISP) return; NotifyBoxHide(); @@ -4561,7 +4584,7 @@ menu_shown = 1; //~ menu_hidden_should_display_help = 0; if (lv) menu_zebras_mirror_dirty = 1; - + piggyback_canon_menu(); canon_gui_disable_front_buffer(0); if (lv && EXT_MONITOR_CONNECTED) clrscr(); @@ -4580,7 +4603,7 @@ close_canon_menu(); #ifdef CONFIG_EOSM - if (recording) + if (recording && !raw_lv_is_enabled()) SetGUIRequestMode(0); #endif canon_gui_enable_front_buffer(0); @@ -4881,7 +4904,9 @@ struct menu_entry * entry = get_selected_entry(menu); if (!entry) return; + #ifndef FEATURE_NOHELP menu_help_go_to_label(entry->name); + #endif give_semaphore(menu_sem); } @@ -5417,7 +5442,6 @@ } console_printf("Wrap test: %d OK, %d bad\n", ok, bad); } - void menu_self_test() { msleep(2000); diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/movtweaks.c --- a/src/movtweaks.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/movtweaks.c Sun Sep 22 11:41:50 2013 -0500 @@ -135,10 +135,17 @@ CONFIG_INT("movie.cliplen", movie_cliplen,0); #endif -//~ CONFIG_INT("movie.mode-remap", movie_mode_remap, 0); + +#ifdef FEATURE_REMAP +static CONFIG_INT("movie.mode-remap", movie_mode_remap, 0); +#endif static CONFIG_INT("movie.rec-key", movie_rec_key, 0); static CONFIG_INT("movie.rec-key-action", movie_rec_key_action, 0); static CONFIG_INT("movie.rec-key-long", movie_rec_key_long, 0); +#ifdef FEATURE_REC_ON_RESUME +//reconresume +CONFIG_INT("movie.autostart-at-resume", start_recording_on_resume, 0); +#endif #ifdef FEATURE_MOVIE_AUTOSTOP_RECORDING @@ -169,6 +176,7 @@ "after %d min", val ); + if (val == 0) { MENU_SET_ENABLED(0); MENU_SET_VALUE("OFF"); } } #endif @@ -201,7 +209,7 @@ } #endif -#if 0 // unstable +#ifdef FEATURE_REMAP // unstable void do_movie_mode_remap() { if (gui_state == GUISTATE_PLAYMENU) return; @@ -340,6 +348,18 @@ #ifdef FEATURE_EXPO_OVERRIDE bv_auto_update(); #endif + + #ifdef FEATURE_REC_ON_RESUME + //reconresume + if(start_recording_on_resume) + { + if(lv && is_movie_mode()) + { + schedule_movie_start(); + } + + } + #endif } static int wait_for_lv_err_msg(int wait) // 1 = msg appeared, 0 = did not appear @@ -744,7 +764,7 @@ { if (!fixed_iso_needed_by_max_auto_iso) // iso auto is alive and kicking { - #ifdef CONFIG_5D2 + #if defined(CONFIG_5D2) || defined(CONFIG_50D) int a = (uint8_t)FRAME_ISO; lens_info.raw_iso_auto = a; lens_info.iso_auto = raw2iso(a); @@ -772,7 +792,7 @@ { int bv = prop_bv; //int c = (uint8_t)((bv >> 16) & 0xFF); - #if defined(CONFIG_5D2) || defined(CONFIG_1100D) + #if defined(CONFIG_5D2) || defined(CONFIG_1100D) || defined(CONFIG_50D) int b = (uint8_t)((bv >> 8) & 0xFF); ae_value = (int)lvae_iso_max - b; #else @@ -1021,7 +1041,7 @@ .choices = CHOICES("Start/Stop", "Start only", "Stop only"), .help = "Select actions for half-shutter.", }, - MENU_EOL + MENU_EOL, }, }, #endif @@ -1077,12 +1097,18 @@ .depends_on = DEP_MOVIE_MODE, }, #endif - #if 0 + #ifdef FEATURE_REMAP { .name = "MovieModeRemap", .priv = &movie_mode_remap, .update = mode_remap_print, - .select = menu_ternary_toggle, + .min = 0, + #ifdef CONFIG_50 + .max = 1, + #else + .max = 2, + #endif + .choices = CHOICES("OFF", "A-DEP", "CA"), .help = "Remap movie mode to A-DEP, CA or C. Shortcut key: ISO+LV.", }, #endif @@ -1150,15 +1176,15 @@ }, #endif - #if 0 - { - .name = "REC on resume", - .priv = &start_recording_on_resume, - .max = 1, - .help = "Auto-record if camera wakes up due to halfshutter press." - .depends_on = DEP_MOVIE_MODE, - }, - #endif + #ifdef FEATURE_REC_ON_RESUME + { + .name = "REC on resume", + .priv = &start_recording_on_resume, + . max = 1, + .help = "Auto-record if camera wakes up due to halfshutter press." + //.depends_on = DEP_MOVIE_MODE, + }, + #endif MENU_EOL } diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/property.c --- a/src/property.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/property.c Sun Sep 22 11:41:50 2013 -0500 @@ -82,7 +82,7 @@ void prop_add_handler (uint32_t property, void *handler) { #if defined(POSITION_INDEPENDENT) - handler[entry].handler = PIC_RESOLVE(handler[entry].handler); + //~ handler[entry].handler = PIC_RESOLVE(handler[entry].handler); #endif property_handlers[actual_num_handlers].handler = handler; property_handlers[actual_num_handlers].property = property; @@ -307,11 +307,6 @@ } #endif - #if defined(CONFIG_DIGIC_V) && defined(CONFIG_FULLFRAME) - if (property == PROP_VIDEO_MODE) // corrupted video headers on 5D3 - return; - #endif - int correct_len = prop_get_prop_len((int)property); if (len == 0) len = correct_len; if (len == 0) diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/property.h --- a/src/property.h Fri Sep 20 16:56:08 2013 +0300 +++ b/src/property.h Sun Sep 22 11:41:50 2013 -0500 @@ -26,6 +26,7 @@ #define _property_h_ #define PROP_CAM_MODEL 0x00000002 +#define PROP_BODY_ID 0x01000006 #define PROP_FIRMWARE_VER 0x02000001 #define PROP_OPTICAL_CORRECT_PARAM 0x0B000000 @@ -297,7 +298,8 @@ #define PROP_MLU 0x80000047 #endif -#ifdef CONFIG_6D +#ifdef CONFIG_6D //May work for others. +#define PROP_HI_ISO_NR 0x80000049 //Len 4, 4 is multishot #define PROP_HTP 0x8000004a #define PROP_MULTIPLE_EXPOSURE 0x0202000c #define PROP_MULTIPLE_EXPOSURE_SETTING 0x8000003F diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/raw.c --- a/src/raw.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/raw.c Sun Sep 22 11:41:50 2013 -0500 @@ -96,6 +96,7 @@ * look it up on the EDMAC registers and use that one instead. */ raw_buffer_photo = shamem_read(RAW_PHOTO_EDMAC); +//~ dump_seg(raw_buffer_photo, MAX(raw_info.frame_size, 1000000), CARD_DRIVE"raw.buf"); } @@ -124,6 +125,12 @@ // #define USE_LV_AF_RAW #endif +#ifdef CONFIG_EOSM +//Lets see what happens +//~ #define USE_LV_AF_RAW //Edge Detection +//~ #define PREFERRED_RAW_TYPE 16 +//~ #define RAW_TYPE_ADDRESS 0x506C4 +#endif /** * RAW_TYPE 78 (and others) have a frame-wide green pattern on them * ACR can clear them but also kills some details and does not do @@ -131,29 +138,21 @@ * http://www.magiclantern.fm/forum/index.php?topic=6658.0 */ -/* -#ifdef CONFIG_700D -#define PREFERRED_RAW_TYPE 78 -#define RAW_TYPE_ADDRESS 0x351B8 +#ifdef CONFIG_6D +//~ #define PREFERRED_RAW_TYPE 0x1E +//~ #define RAW_TYPE_ADDRESS 0x7E020 + 4 +//~ #define USE_LV_AF_RAW //Looks like peaking #endif - -#ifdef CONFIG_650D -#define PREFERRED_RAW_TYPE 78 -#define RAW_TYPE_ADDRESS 0x350B4 -#endif -*/ - /** * White level * one size fits all: should work on most cameras and can't be wrong by more than 0.1 EV */ +#ifdef CONFIG_6D +#define WHITE_LEVEL 13000 +#else #define WHITE_LEVEL 15000 +#endif -/** there may be exceptions */ -#ifdef CONFIG_6D -#undef WHITE_LEVEL -#define WHITE_LEVEL 13000 -#endif /** * Color matrix should be copied from DCRAW. @@ -558,15 +557,16 @@ skip_top = 50; #endif -/* - #if defined(CONFIG_50D) // NEED Raw dump to get correct values - width = 5344; - height = 3516; - skip_left = 142; - skip_right = 0; - skip_top = 50; + + #if defined(CONFIG_50D) // cr2 file + width = 4832; + height = 3228; + skip_left = 72; + skip_right = 4832-4823; + skip_top = 56; + skip_bottom = 3228-3223; #endif -*/ + #if defined(CONFIG_650D) || defined(CONFIG_EOSM) || defined(CONFIG_700D) || defined(CONFIG_100D) width = 5280; @@ -763,6 +763,7 @@ { int delta_x, delta_y; if (focus_box_get_raw_crop_offset(&delta_x, &delta_y)) + //~ if (0) { /* in 10x, the yuv area is twice as small than in 5x */ int zoom_corr = lv_dispsize == 10 ? 2 : 1; @@ -1308,6 +1309,7 @@ MEM(RAW_TYPE_ADDRESS) = PREFERRED_RAW_TYPE; #elif defined(USE_LV_AF_RAW) call("lv_af_raw", 1); + //~ call("lv_md_visible", 0); //Works? #endif } diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/raw.h --- a/src/raw.h Fri Sep 20 16:56:08 2013 +0300 +++ b/src/raw.h Sun Sep 22 11:41:50 2013 -0500 @@ -73,6 +73,20 @@ unsigned int g_lo: 2; } __attribute__((packed)); +struct raw12_pixblock +{ + unsigned int c_hi: 8; + unsigned int b: 12; + unsigned int a: 12; + unsigned int f_hi: 4; + unsigned int e: 12; + unsigned int d: 12; + unsigned int c_lo: 4; + unsigned int h: 12; + unsigned int g: 12; + unsigned int f_lo: 8; +} __attribute__((packed)); + /* call this before performing any raw image analysis */ /* returns 1=success, 0=failed */ int raw_update_params(); diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/reboot-all.c --- a/src/reboot-all.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/reboot-all.c Sun Sep 22 11:41:50 2013 -0500 @@ -32,6 +32,7 @@ #define RESTARTSTART_60 0x1FE00000 #define RESTARTSTART_600 0xC80100 #define RESTARTSTART_50 0x4b000 +//~ #define RESTARTSTART_50 0xC60100 #define RESTARTSTART_500 0x4d000 #define RESTARTSTART_5D2 0x4E000 #define RESTARTSTART_1100 0xC80100 diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/reboot.c --- a/src/reboot.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/reboot.c Sun Sep 22 11:41:50 2013 -0500 @@ -108,7 +108,7 @@ #endif #ifdef CONFIG_EOSM - if (s != (int)SIG_EOSM_106) + if (s != (int)SIG_EOSM_202) fail(); #endif @@ -125,8 +125,7 @@ #ifdef CONFIG_6D if (s != (int)SIG_6D_113) fail(); - #endif - + #endif #ifdef CONFIG_650D if (s != (int)SIG_650D_104) fail(); diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/shoot.c --- a/src/shoot.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/shoot.c Sun Sep 22 11:41:50 2013 -0500 @@ -104,6 +104,20 @@ ABS((int)lens_info.WBGain_B - 1024) < 100; } +/* +static CONFIG_INT("uniwb.mode", uniwb_mode, 0); +static CONFIG_INT("uniwb.old.wb_mode", uniwb_old_wb_mode, 0); +static CONFIG_INT("uniwb.old.gain_R", uniwb_old_gain_R, 0); +static CONFIG_INT("uniwb.old.gain_G", uniwb_old_gain_G, 0); +static CONFIG_INT("uniwb.old.gain_B", uniwb_old_gain_B, 0); + +int uniwb_is_active() +{ + return + uniwb_mode && + uniwb_is_active_check_lensinfo_only(); +}*/ + //~ CONFIG_INT("iso_selection", iso_selection, 0); CONFIG_INT("hdr.enabled", hdr_enabled, 0); @@ -610,9 +624,10 @@ static volatile int afframe_ack = 0; #ifdef CONFIG_LIVEVIEW static int afframe[128]; + PROP_HANDLER( PROP_LV_AFFRAME ) { ASSERT(len <= sizeof(afframe)); - + #ifdef FEATURE_SPOTMETER spotmeter_erase(); #endif @@ -649,6 +664,7 @@ #else ASSERT(buf[0] == 1 || buf[0] == 5 || buf[0] == 10); #endif + zoom_sharpen_step(); if (buf[0] == 1) zoom_was_triggered_by_halfshutter = 0; @@ -963,7 +979,7 @@ int Xc = Xtl + w/2; int Yc = Ytl + h/2; - //~ NotifyBox(2000, "aff(%d,%d)\nhere (%d,%d)\ndest (%d,%d)\ntotal (%d,%d)", Xc, Yc, here_x, here_y, dest_x, dest_y, W, H); + NotifyBox(2000, "here (%d,%d)\ndest (%d,%d)\ntotal (%d,%d)", Xc, Yc, (Xc + delta_x), (Yc + delta_y), W, H); /* and we'll move it here */ pos_x[1] = Xc + delta_x; @@ -1386,6 +1402,7 @@ void ensure_movie_mode() { #ifdef CONFIG_MOVIE + if (!lv) force_liveview(); if (!is_movie_mode()) { #ifdef CONFIG_50D @@ -1393,16 +1410,18 @@ GUI_SetMovieSize_b(1); #elif defined(CONFIG_5D2) GUI_SetLvMode(2); - #else + #elif defined(FEATURE_REMAP) + set_shooting_mode(SHOOTMODE_MOVIE); + #endif + while (!is_movie_mode()) { - NotifyBox(2000, "Please switch to Movie mode."); + NotifyBox(2000, "Please switch to Movie mode.\nSomething went wrong."); msleep(500); } - #endif + msleep(500); } - if (!lv) force_liveview(); #endif } @@ -1743,6 +1762,8 @@ void kelvin_toggle( void* priv, int sign ) { + //~ if (uniwb_is_active()) return; + int k; switch (lens_info.wb_mode) { @@ -1874,6 +1895,7 @@ static void wb_custom_gain_toggle( void * priv, int delta ) { + //~ if (uniwb_is_active()) return; int p = (intptr_t) priv; int deltaR = p == 1 ? -delta * 16 * MAX(1, lens_info.WBGain_R/1024) : 0; int deltaG = p == 2 ? -delta * 16 * MAX(1, lens_info.WBGain_G/1024) : 0; @@ -1881,6 +1903,76 @@ lens_set_custom_wb_gains(lens_info.WBGain_R + deltaR, lens_info.WBGain_G + deltaG, lens_info.WBGain_B + deltaB); } +/* +static void uniwb_save_normal_wb_params() +{ + if (uniwb_is_active_check_lensinfo_only()) return; + //~ info_led_blink(1,50,50); + uniwb_old_wb_mode = lens_info.wb_mode; + if (lens_info.WBGain_R != 1024 || lens_info.WBGain_G != 1024 || lens_info.WBGain_B != 1024) + { + uniwb_old_gain_R = lens_info.WBGain_R; + uniwb_old_gain_G = lens_info.WBGain_G; + uniwb_old_gain_B = lens_info.WBGain_B; + } +} + +static void uniwb_enable() +{ + uniwb_save_normal_wb_params(); + lens_set_custom_wb_gains(1024, 1024, 1024); +} + +static void uniwb_disable() +{ + //~ info_led_blink(2,200,200); + if (!uniwb_old_gain_R) return; + lens_set_custom_wb_gains(uniwb_old_gain_R, uniwb_old_gain_G, uniwb_old_gain_B); + prop_request_change(PROP_WB_MODE_LV, &uniwb_old_wb_mode, 4); + prop_request_change(PROP_WB_MODE_PH, &uniwb_old_wb_mode, 4); + msleep(100); + if (!uniwb_is_active_check_lensinfo_only()) // successfully disabled + { + uniwb_old_gain_R = uniwb_old_gain_G = uniwb_old_gain_B = uniwb_old_wb_mode = 0; + } +} + +void uniwb_step() +{ + //~ if (!lv) return; + + int uniwb_desired_state = 0; + switch (uniwb_mode) + { + case 0: // always off + uniwb_desired_state = 0; + break; + case 1: // always on + uniwb_desired_state = 1; + break; + case 2: // halfshutter + uniwb_desired_state = get_halfshutter_pressed(); + break; + case 3: // halfshutter not pressed + uniwb_desired_state = !get_halfshutter_pressed(); + break; + } + + if (!display_idle() && !gui_menu_shown()) + { + uniwb_save_normal_wb_params(); // maybe user is changing WB settings from Canon menu - save them as non-uniWB params + } + else if (uniwb_desired_state == 0) + { + if (uniwb_old_gain_R) uniwb_disable(); + } + else + { + if (!uniwb_is_active()) uniwb_enable(); + } +} +*/ + static int crit_kelvin(int k) { if (!lv) return 0; @@ -4132,23 +4224,13 @@ .depends_on = DEP_MANUAL_FOCUS, }, #ifdef FEATURE_ZOOM_TRICK_5D3 - #ifdef CONFIG_6D { .name = "Double Click", .priv = &zoom_trick, .max = 2, - .help = "Double-click top-right button in LV. Shortcuts or Zoom.", + .help = "Double-click dead button in LV. Shortcuts or Zoom", .choices = CHOICES("OFF", "Zoom", "Shortcuts"), }, - #else // 5D3 - { - .name = "Zoom with old button", - .priv = &zoom_trick, - .max = 1, - .help = "Use the old Zoom In button, as in 5D2. Double-click in LV.", - .choices = CHOICES("OFF", "ON (!)"), - }, - #endif #endif MENU_EOL }, @@ -4175,7 +4257,7 @@ .update = kelvin_wbs_display, .select = kelvin_toggle, .help = "Adjust Kelvin white balance and GM/BA WBShift.", - .help2 = "Advanced: WBShift, RGB multipliers, Push-button WB...", + .help2 = "Advanced: WBShift, RGB multipliers, UniWB, Push-button WB...", .edit_mode = EM_MANY_VALUES_LV, .submenu_width = 700, .children = (struct menu_entry[]) { @@ -4234,6 +4316,14 @@ .edit_mode = EM_MANY_VALUES_LV, }, /*{ + .name = "UniWB", + .priv = &uniwb_mode, + .max = 3, + .choices = CHOICES("OFF", "Always ON", "on HalfShutter", "not HalfShutter"), + .help = "Cancels white balance => good RAW histogram approximation.", + }, + */ + /*{ .name = "Auto adjust Kelvin", .select = kelvin_auto, .help = "LiveView: adjust Kelvin value once for the current scene." @@ -5179,6 +5269,85 @@ #endif } +#ifdef FEATURE_PREFIX +// look in DCIM dir for other files named B00_something, B01_something etc +int hdr_counter = 0; +int hdr_update_prefix_counter() +{ + struct fio_file file; + struct fio_dirent * dirent = 0; + + + dirent = FIO_FindFirstEx( get_dcim_dir(), &file ); + if( IS_ERROR(dirent) ) + return 0; + + do { + if (file.mode & 0x10) continue; // is a directory + int n = strlen(file.name); + if (n > 4) + { + if (file.name[0] == 'B' && file.name[3] == '_' && isdigit(file.name[1]) && isdigit(file.name[2])) + { + int num = (file.name[1]-'0') * 10 + (file.name[2]-'0'); + hdr_counter = MAX(num, hdr_counter); + } + else if (file.name[0] == 'B' && isdigit(file.name[1]) && isdigit(file.name[2]) && isdigit(file.name[3])) + { + int num = (file.name[1]-'0') * 100 + (file.name[2]-'0') * 10 + (file.name[3]-'0'); + hdr_counter = MAX(num, hdr_counter); + } + } + } while( FIO_FindNextEx( dirent, &file ) == 0); + FIO_CleanupAfterFindNext_maybe(dirent); + return 1; // success +} + +static int hdr_file_prefix_dirty = 0; +static char hdr_prefix[8] = "B00_"; +static int pre_key = 0; +void hdr_increment_file_prefix() +{ + if (hdr_counter < 0) return; // you have poured alcohol into the CPU? + hdr_counter++; + if (hdr_counter >= 1000) return; // you took 1000 bracketed shots?! + + if (hdr_counter < 100) snprintf(hdr_prefix, 8, "B%02d_", hdr_counter); + else snprintf(hdr_prefix, 8, "B%03d", hdr_counter); + + while (lens_info.job_state) msleep(100); + + if (pre_key) file_prefix_reset(pre_key); // already changed, restore first + + pre_key = file_prefix_set(hdr_prefix); + + //~ NotifyBox(1000, "Key %d", pre_key); + + hdr_file_prefix_dirty = 1; + +} + +void hdr_change_file_prefix() +{ + if (ml_shutdown_requested) return; + if (intervalometer_running) return; // would overflow probably soon, better leave them unchanged in this case + if (hdr_file_prefix_dirty) return; // already changed, restore first + + if (hdr_update_prefix_counter()) + hdr_increment_file_prefix(); +} + +void hdr_restore_file_prefix() +{ + if (hdr_file_prefix_dirty) + { + while (lens_info.job_state) msleep(100); + file_prefix_reset(pre_key); + hdr_file_prefix_dirty = 0; + } +} +#endif + // take one picture or a HDR / focus stack sequence // to be used with the intervalometer, focus stack, etc // AF is disabled (don't enable it here, it will only introduce weird bugs) @@ -5197,6 +5366,11 @@ lens_wait_readytotakepic(64); if (drive_mode_bak >= 0) lens_set_drivemode(drive_mode_bak); + + #ifdef FEATURE_PREFIX + hdr_increment_file_prefix(); + #endif + } else // regular pic (not HDR) #endif @@ -5298,7 +5472,7 @@ void display_shooting_info_lv() { -#ifndef CONFIG_5D2 +#if !defined(CONFIG_5D2) #ifdef FEATURE_LCD_SENSOR_REMOTE int screen_layout = get_screen_layout(); int audio_meters_at_top = audio_meters_are_drawn() @@ -5566,16 +5740,19 @@ static void misc_shooting_info() { - if (!DISPLAY_IS_ON) return; + if (!DISPLAY_IS_ON) return; display_shortcut_key_hints_lv(); if (get_global_draw()) { #ifdef CONFIG_PHOTO_MODE_INFO_DISPLAY - if (!lv && display_idle()) + if (!lv && display_idle()) BMP_LOCK - ( + ( +#ifdef CONFIG_6D + display_clock(); +#endif display_shooting_info(); #ifndef FEATURE_FLEXINFO free_space_show_photomode(); @@ -5646,6 +5823,17 @@ static void shoot_task( void* unused ) { +/* + #ifdef FEATURE_PREFIX + // file numbering was left to B00_ from bracketing + if (file_prefix[0] == 'B' && isdigit(file_prefix[1]) && isdigit(file_prefix[2]) && (isdigit(file_prefix[3]) || file_prefix[3] == '_')) + { + NotifyBox(5000, "Images are named %snnnn.JPG\nRestore IMG_ from Canon menu."); + msleep(5000); + } + #endif +*/ + /* this is used to determine if a feature is active that requires high task rate */ int priority_feature_enabled = 0; @@ -5662,7 +5850,7 @@ { int msg; int delay = 50; - + /* specify the maximum wait time */ if(!DISPLAY_IS_ON) { @@ -5674,6 +5862,8 @@ } int err = msg_queue_receive(shoot_task_mqueue, (struct event**)&msg, delay); + //~ NotifyBox(1000, "DIAL : %x", CURRENT_DIALOG_MAYBE); + priority_feature_enabled = 0; /* when we received a message, redraw immediately */ @@ -5782,8 +5972,17 @@ info_led_off(); msleep(100); } + #endif + #ifdef FEATURE_PREFIX + // change file prefix to B00, B01 etc (change is done only once) + if (HDR_ENABLED) + hdr_change_file_prefix(); + else + hdr_restore_file_prefix(); + #endif + #ifdef FEATURE_BULB_TIMER if (bulb_timer && is_bulb_mode() && !gui_menu_shown()) { @@ -6293,29 +6492,24 @@ #endif #ifdef FEATURE_AUDIO_REMOTE_SHOT -#if defined(CONFIG_7D) || defined(CONFIG_6D) - /* experimental for 7D now, has to be made generic */ - static int last_audio_release_running = 0; +//~ #if defined(CONFIG_6D) + //~ /* experimental for 6D now, has to be made generic */ + //~ static int last_audio_release_running = 0; - if(audio_release_running != last_audio_release_running) - { - last_audio_release_running = audio_release_running; + //~ if(audio_release_running != last_audio_release_running) + //~ { + //~ last_audio_release_running = audio_release_running; - if(audio_release_running) - { - #ifdef CONFIG_7D - void (*SoundDevActiveIn) (uint32_t) = 0xFF0640EC; - SoundDevActiveIn(0); - #else //Enable Audio IC In Photo Mode if off - { if (!is_movie_mode()) - { void SoundDevActiveIn(); - SoundDevActiveIn(0); - } - } - #endif - } - } -#endif + //~ if(audio_release_running) + //~ { + //~ { if (!is_movie_mode()) + //~ { void SoundDevActiveIn(); + //~ SoundDevActiveIn(0); + //~ } + //~ } + //~ } + //~ } +//~ #endif if (audio_release_running) { static int countdown = 0; @@ -6401,3 +6595,4 @@ #endif } + diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/state-object.c --- a/src/state-object.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/state-object.c Sun Sep 22 11:41:50 2013 -0500 @@ -98,12 +98,18 @@ #if defined(CONFIG_5D3) || defined(CONFIG_6D) if (self == DISPLAY_STATE && (input == INPUT_ENABLE_IMAGE_PHYSICAL_SCREEN_PARAMETER)) lv_vsync_signal(); +/* +#elif defined(CONFIG_5D2) || defined(CONFIG_50D) + if (self == LV_STATE && old_state == 4) + { + lv_vsync_signal(); + } +*/ -#elif defined(CONFIG_5D2) - if (self == LV_STATE)//&& old_state == 4) - { - //~ lv_vsync_signal(); - } +#elif defined(CONFIG_7D) + if (self == LV_STATE && input== 13 && old_state == 4) + lv_vsync_signal(); + #elif defined(CONFIG_60D) if (self == EVF_STATE && input == 5 && old_state == 5) // evfReadOutDoneInterrupt lv_vsync_signal(); @@ -115,13 +121,14 @@ #elif defined(CONFIG_650D) || defined(CONFIG_700D) || defined(CONFIG_100D) //TODO: Check 700D and 100D if (self == DISPLAY_STATE && (input == INPUT_SET_IMAGE_VRAM_PARAMETER_MUTE_FLIP_CBR)) { lv_vsync_signal(); - } + } #elif defined(CONFIG_EOSM) if (self == EVF_STATE && input == 15 && old_state == 5) { lv_vsync_signal(); } #endif + // sync display filters (for these, we need to redirect display buffers #ifdef DISPLAY_STATE #ifdef CONFIG_CAN_REDIRECT_DISPLAY_BUFFER_EASILY @@ -142,14 +149,16 @@ } #endif #endif - -#ifdef CONFIG_5D2 + +#if defined(CONFIG_5D2) || defined(CONFIG_50D) //|| defined(CONFIG_7D) if (self == LV_STATE && old_state == 2 && input == 2) // lvVdInterrupt { display_filter_lv_vsync(old_state, x, input, z, t); + //~ NotifyBox(5000, "hex: %x", x); + //~ int var = x; } #endif - + int ans = StateTransition(self, x, input, z, t); #ifdef CONFIG_550D @@ -176,11 +185,18 @@ #if defined(CONFIG_7D_MASTER) || defined(CONFIG_7D) if (self == LV_STATE && input==3 && old_state == 3) vignetting_correction_apply_lvmgr(x); + #ifdef CONFIG_7D_MASTER + audio_headphone_run(); + #endif + #endif - + #if !defined(CONFIG_7D_MASTER) && defined(CONFIG_7D) if (self == LV_STATE && input==5 && old_state == 5) - vsync_func(); + { vsync_func(); + //~ NotifyBox(5000, "hex: %d %d", input, old_state); + display_filter_lv_vsync(old_state, x, input, z, t); + } #endif #ifdef EVF_STATE @@ -245,13 +261,21 @@ int old_state = self->current_state; int ans = StateTransition(self, x, input, z, t); int new_state = self->current_state; - + #if defined(CONFIG_5D2) || defined(CONFIG_550D) || defined(CONFIG_7D) // SDSf3:(0) -- 3 sdsMem1toRAWcompress-->(1) // SDSf3:(1) -- 3 sdsMem1toJpegDevelop-->(1) if (old_state == 0 && input == 3 && new_state == 1) raw_buffer_intercept_from_stateobj(); - #endif + + #elif defined(CONFIG_50D) + //~ FrontState - There are only 2 + //~ * FF882F00 - Mem1toJpeg + //~ * FF882C5C - Mem1 to raw + //~ * 9 -> Raw (3) -> 10 -> Jpeg(3) -> 8 + if (old_state == 9 && input == 3 && new_state == 10) + raw_buffer_intercept_from_stateobj(); + #endif return ans; } diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/strobo.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/strobo.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,158 @@ +// +// strobo.c +// +// +// Created by scrax on 19/12/12. +// +// + +#include "dryos.h" +#include "strobo.h" + +uint32_t strobo_settings[PROP_STROBO_SETTINGS_LEN]; +PROP_HANDLER(PROP_STROBO_SETTINGS) +{ + memcpy(strobo_settings, buf, PROP_STROBO_SETTINGS_LEN * 4); +} + +/** call this function when changing to/from manual flash mode...**/ +void strobo_set_status(uint32_t strobo_status) +{ + strobo_settings[STROBO_SETTINGS_STATUS_POS] = strobo_status; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Internal Flash Exposure comp. in custom wireless mode **/ +void strobo_set_excomp_int_w(uint32_t strobo_excomp_int_w) +{ + strobo_settings[STROBO_SETTINGS_EXP_COMP_CUST_INT_WIRELES_POS] = strobo_excomp_int_w; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set External Flash Exposure comp. in custom wireless mode **/ +void strobo_set_excomp_ext_w(uint32_t strobo_excomp_ext_w) +{ + strobo_settings[STROBO_SETTINGS_EXP_COMP_CUST_EXT_WIRELES_POS] = strobo_excomp_ext_w; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Flash output **/ +void strobo_set_flash_out(uint32_t strobo_flash_out) +{ + strobo_settings[STROBO_SETTINGS_FLASH_OUT_POS] = strobo_flash_out; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Group A output **/ +void strobo_set_group_a_out(uint32_t strobo_group_a_out) +{ + strobo_set_flash_out(strobo_group_a_out); + strobo_settings[STROBO_SETTINGS_GROUP_A_OUT_POS] = strobo_group_a_out; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Group B output **/ +void strobo_set_group_b_out(uint32_t strobo_group_b_out) +{ + strobo_settings[STROBO_SETTINGS_GROUP_B_OUT_POS] = strobo_group_b_out; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Group C output **/ +void strobo_set_group_c_out(uint32_t strobo_group_c_out) +{ + strobo_settings[STROBO_SETTINGS_GROUP_C_OUT_POS] = strobo_group_c_out; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Flash Exposure comp. in easy wireless mode **/ +void strobo_set_excomp_easy_w(uint32_t strobo_excomp_easy_w) +{ + strobo_settings[STROBO_SETTINGS_EXP_COMP_EASY_WIRELES_POS] = strobo_excomp_easy_w; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Flash Settings: A:B fire ratio in wireless mode **/ +void strobo_set_group_ab_ratio(uint32_t strobo_group_ab_ratio) +{ + strobo_settings[STROBO_SETTINGS_AB_RATIO_POS] = strobo_group_ab_ratio; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Flash Settings: Grp.C exp.comp **/ +void strobo_set_group_ab_ratio(uint32_t strobo_group_c_exp_comp) +{ + strobo_settings[STROBO_SETTINGS_GROUP_C_EXP_COMP_POS] = strobo_group_c_exp_comp; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Internal Flash Settings: Firing mode normal, easy wireless, custom wireless **/ +void strobo_set_int_mode(uint32_t strobo_int_mode) +{ + strobo_settings[STROBO_SETTINGS_INT_MODE_POS] = strobo_int_mode; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Flash Settings: RATIO MODE **/ +void strobo_set_int_mode(uint32_t strobo_ratio_mode) +{ + strobo_settings[STROBO_SETTINGS_RATIO_MODE_POS] = strobo_ratio_mode; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set Flash Settings: wireless channel **/ +void strobo_set_channel(uint32_t strobo_channel) +{ + strobo_settings[STROBO_SETTINGS_CHANNEL_POS] = strobo_channel; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set the strobo firing to 1st/2nd curtain ...**/ +void strobo_set_sync(uint32_t strobo_type) +{ + strobo_settings[STROBO_SETTINGS_SYNC_POS] = strobo_type; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to enable disable wireless shooting ...**/ +void strobo_set_wireless_status(uint32_t strobo_wireless_status) +{ + strobo_settings[STROBO_SETTINGS_WIRELESS_STATUS_POS] = strobo_wireless_status; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set flash count when in multi flash ...**/ +void strobo_set_flash_count(uint32_t strobo_flash_count) +{ + strobo_settings[STROBO_SETTINGS_MULTI_FLASH_COUNT_POS] = strobo_flash_count; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set freq when in multi flash ...**/ +void strobo_set_flash_freq(uint32_t strobo_flash_freq) +{ + strobo_settings[STROBO_SETTINGS_MULTI_FLASH_FREQ_POS] = strobo_flash_freq; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to set flash mode: ETTL, Manual, Multi ...**/ +void strobo_set_flash_mode(uint32_t strobo_flash_mode) +{ + strobo_settings[STROBO_SETTINGS_FLASH_MODE_POS] = strobo_flash_mode; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to change external flash zoom...**/ +void strobo_set_zoom(uint32_t strobo_zoom) +{ + strobo_settings[STROBO_SETTINGS_ZOOM_POS] = strobo_zoom; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + +/** call this function to change external flash zoom...**/ +void strobo_set_flash_exp_comp(uint32_t strobo_flash_exp_comp) +{ + strobo_settings[STROBO_SETTINGS_FLASH_EXP_COMP_POS] = strobo_flash_exp_comp; + prop_request_change(PROP_STROBO_SETTINGS, &strobo_settings, PROP_STROBO_SETTINGS_LEN) +} + diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/strobo.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/strobo.h Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,134 @@ +// +// strobo.h +// +// +// Created by scrax on 19/12/12. +// +// + +struct flash_info { + int firing; // 0: enable firing, 1: disable_firing + int ettl2_meter; // 0: evaluative, 1: average + int expo_comp; + int zoom; + int mode; //E-TTL II, Manual, Multi + int wireless_func; // Disable, Ext, Ext (A,B,C), Ext+Int, Ext(A,B,C)+Int + int wireless_channel; // (1,2,3,4) + int shutter_sync; // 1st curt., 2nd curt, High Speed + int multi_freq; // (199 = 0xc7, 1 = 0x1) + int multi_count; //(hex like before 1 = 0x1 18 = 0x12) + int internal_output; // Flash power values from 1/1 to 1/128 1/3stop: (2,5,8,a,d,10,12,15,18,1a,1d,20,22,25,28,2a,2d,30,32,35,38) + int external_output; + int group_a_output; // 0x00..0x38: 1/1..1/128 + int group_b_output; + int group_c_output; +}; + + + +#define PROP_STROBO_SETTINGS_LEN (0x22) + +#define STROBO_SETTINGS_STATUS_POS (0x00) +#define STROBO_STATUS_MANUAL 0x03 +#define STROBO_STATUS_OTHERS 0x01 + +#define STROBO_SETTINGS_EXP_COMP_INT_CUST_WIRELES_POS (0x02) +#define STROBO_EXP_COMP_LESS_20 0xf0 +#define STROBO_EXP_COMP_LESS_16 0xf3 +#define STROBO_EXP_COMP_LESS_13 0xf5 +#define STROBO_EXP_COMP_LESS_10 0xf8 +#define STROBO_EXP_COMP_LESS_06 0xfB +#define STROBO_EXP_COMP_LESS_03 0xfD +#define STROBO_EXP_COMP_ZERO_00 0x00 +#define STROBO_EXP_COMP_PLUS_03 0x03 +#define STROBO_EXP_COMP_PLUS_06 0x05 +#define STROBO_EXP_COMP_PLUS_10 0x08 +#define STROBO_EXP_COMP_PLUS_13 0x0B +#define STROBO_EXP_COMP_PLUS_16 0x0D +#define STROBO_EXP_COMP_PLUS_20 0x10 + +#define STROBO_SETTINGS_EXP_COMP_EXT_CUST_WIRELES_POS (0x04) + +#define STROBO_SETTINGS_FLASH_OUT_POS (0x1C) +#define STROBO_SETTINGS_GROUP_A_OUT_POS (0x18) //changing this need to change also FLASH_OUT +#define STROBO_SETTINGS_GROUP_B_OUT_POS (0x06) +#define STROBO_SETTINGS_GROUP_C_OUT_POS (0x08) + +#define STROBO_SETTINGS_EXP_COMP_EASY_WIRELES_POS (0x0C) + +#define STROBO_SETTINGS_AB_RATIO_POS (0x0E) +#define STROBO_AB_RATIO_8_1 0x00 +#define STROBO_AB_RATIO_6_1 0x01 +#define STROBO_AB_RATIO_4_1 0x02 +#define STROBO_AB_RATIO_3_1 0x03 +#define STROBO_AB_RATIO_2_1 0x04 +#define STROBO_AB_RATIO_1b_1 0x05 +#define STROBO_AB_RATIO_1_1 0x06 +#define STROBO_AB_RATIO_1_1b 0x07 +#define STROBO_AB_RATIO_1_2 0x08 +#define STROBO_AB_RATIO_1_3 0x09 +#define STROBO_AB_RATIO_1_4 0x0A +#define STROBO_AB_RATIO_1_6 0x0B +#define STROBO_AB_RATIO_1_8 0x0C + +#define STROBO_SETTINGS_GROUP_C_EXP_COMP_POS (0x11) + +#define STROBO_SETTINGS_INT_MODE_POS (0x13) +#define STROBO_INT_MODE_NORMAL 0x00 +#define STROBO_INT_MODE_EASY_W 0x00 +#define STROBO_INT_MODE_CUSTOM_W 0x00 + +#define STROBO_SETTINGS_RATIO_MODE_POS (0x15) // names can be changed if needed... +#define STROBO_RATIO_MODE_MFOFF_CHALL 0x00 // Master Flash disabled and Channel All +#define STROBO_RATIO_MODE_MFON_CHALL 0x01 // Master Flash enabled and Channel All +#define STROBO_RATIO_MODE_MFOFF_CHA_B 0x02 // Master Flash disabled and Channel A:B +#define STROBO_RATIO_MODE_MFON_CHA_B 0x03 // Master Flash enabled and Channel A:B +#define STROBO_RATIO_MODE_MFOFF_CHA_B_C 0x04 // Master Flash disabled and Channel A:B:C +#define STROBO_RATIO_MODE_MFON_CHA_B_C 0x05 // Master Flash enabled and Channel A:B:C +#define STROBO_RATIO_MODE_WION_EX_IN 0x09 // Wireless Flash enabled EXT:INT +#define STROBO_RATIO_MODE_IWMAN_EX 0x10 // Internal Wireless Manual enabled EXT +#define STROBO_RATIO_MODE_IWETT_EX 0x12 // Internal Wireless ETT-II enabled EXT +#define STROBO_RATIO_MODE_IWON_EXIN 0x19 // Internal Wireless enabled EXT+INT or Custom Wireless Ext. All + Int. +#define STROBO_RATIO_MODE_ICW_EX_IN 0x1B // Internal Custom Wireless enabled EXT:INT + +#define STROBO_SETTINGS_CHANNEL_POS (0x17) +#define STROBO_CHANNEL_1 0x0 +#define STROBO_CHANNEL_2 0x1 +#define STROBO_CHANNEL_3 0x2 +#define STROBO_CHANNEL_4 0x3 + +#define STROBO_SETTINGS_SYNC_POS (0x1A) +#define STROBO_1ST_CURTAIN 0x8 +#define STROBO_2ND_CURTAIN 0xA +#define STROBO_HI_SPEED 0xD + +#define STROBO_SETTINGS_WIRELESS_STATUS_POS (0x1B) +#define STROBO_WIRELESS_STATUS_ON 0x4 +#define STROBO_WIRELESS_STATUS_OFF 0x6 + +#define STROBO_SETTINGS_MULTI_FLASH_COUNT_POS (0x1E) +//#define STROBO_MULTI_FLASH_COUNT_1 0x01 +//#define STROBO_MULTI_FLASH_COUNT_2 0x02 +//... and so on + +#define STROBO_SETTINGS_MULTI_FLASH_FREQ_POS (0x21) +#define STROBO_MULTI_FLASH_FREQ_MIN 0x01 +#define STROBO_MULTI_FLASH_FREQ_MAX 0xC7 + +#define STROBO_SETTINGS_FLASH_MODE_POS (0x25) +#define STROBO_FLASH_MODE_ETTL 0x0 +#define STROBO_FLASH_MODE_MANUAL 0x1 +#define STROBO_FLASH_MODE_MULTI 0x2 + +#define STROBO_SETTINGS_ZOOM_POS (0x26) +#define STROBO_ZOOM_AUTO 0x8 +#define STROBO_ZOOM_24MM 0x3 +#define STROBO_ZOOM_28MM 0x5 +#define STROBO_ZOOM_35MM 0x7 +#define STROBO_ZOOM_50MM 0x9 +#define STROBO_ZOOM_70MM 0xB +#define STROBO_ZOOM_80MM 0xD +#define STROBO_ZOOM_105MM 0xF + +#define STROBO_SETTINGS_FLASH_EXP_COMP_POS (0x29) + diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/tp-spy.c --- a/src/tp-spy.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/tp-spy.c Sun Sep 22 11:41:50 2013 -0500 @@ -84,11 +84,14 @@ { if (!tp_buf) // first call, intercept debug messages { - tp_buf = alloc_dma_memory(BUFF_SIZE); + //~ tp_buf = alloc_dma_memory(BUFF_SIZE); + tp_buf = shoot_malloc(BUFF_SIZE); tp_len = 0; - if (!reloc_tp_buf) reloc_tp_buf = (uintptr_t) AllocateMemory(reloc_tp_len + 64); - if (!reloc_tp_buf2) reloc_tp_buf2 = (uintptr_t) AllocateMemory(reloc_tp_len2 + 64); + //~ if (!reloc_tp_buf) reloc_tp_buf = (uintptr_t) AllocateMemory(reloc_tp_len + 64); + if (!reloc_tp_buf) reloc_tp_buf = (uintptr_t) shoot_malloc(reloc_tp_len + 64); + //~ if (!reloc_tp_buf2) reloc_tp_buf2 = (uintptr_t) AllocateMemory(reloc_tp_len2 + 64); + if (!reloc_tp_buf2) reloc_tp_buf2 = (uintptr_t) shoot_malloc(reloc_tp_len2 + 64); new_TryPostEvent = (void *)reloc( 0, // we have physical memory diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/tweaks.c --- a/src/tweaks.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/tweaks.c Sun Sep 22 11:41:50 2013 -0500 @@ -27,6 +27,7 @@ void ReverseDisplay(); static void upside_down_step(); +static void uniwb_correction_step(); static void warn_step(); extern void display_gain_toggle(void* priv, int delta); @@ -794,7 +795,7 @@ // wait for user request to settle int prev = play_rate_flag; - int pure_play_photo_mode = is_pure_play_photo_mode(); + int pure_play_photo_mode = is_pure_play_photo_mode(); int pure_play_photo_or_movie_mode = is_pure_play_photo_or_movie_mode(); if (prev) while(1) { @@ -815,21 +816,19 @@ NotifyBoxHide(); fake_simple_button(BGMT_Q); // rate image fake_simple_button(BGMT_PRESS_DOWN); - -#ifdef CONFIG_6D //~ it moves too fast to register the second click down otherwise. + #if defined(CONFIG_6D) // Too Fast msleep(200); - #endif - + #endif // for photos, we need to go down 2 steps // for movies, we only need 1 step if (pure_play_photo_mode) { - NotifyBox(500,"PURE PLAY"); + //~ NotifyBox(500,"PURE PLAY"); fake_simple_button(BGMT_PRESS_DOWN); } else { - NotifyBox(500,"STOP PLAY"); - + //~ NotifyBox(500,"STOP PLAY"); + } - NotifyBox(500,"%08x", get_current_dialog_handler()); + //~ NotifyBox(500,"%08x", get_current_dialog_handler()); #ifdef BGMT_UNPRESS_UDLR fake_simple_button(BGMT_UNPRESS_UDLR); @@ -1134,7 +1133,6 @@ static void tweak_task( void* unused) { - //~ do_movie_mode_remap(); movtweak_task_init(); TASK_LOOP @@ -1144,7 +1142,10 @@ if (DISPLAY_IS_ON) display_countdown = 40; else if (display_countdown) display_countdown--; - + #ifdef FEATURE_REMAP + do_movie_mode_remap(); + #endif + msleep(display_countdown || recording || halfshutter_sticky || dofpreview_sticky ? 50 : 500); movtweak_step(); @@ -1326,6 +1327,10 @@ preview_contrast_n_saturation_step(); #endif + #ifdef FEATURE_UNIWB_CORRECTION + uniwb_correction_step(); + #endif + #ifdef FEATURE_COLOR_SCHEME grayscale_menus_step(); #endif @@ -1473,12 +1478,14 @@ static void arrow_key_mode_toggle() { + //~ bmp_printf(FONT_MED, 0, 300, "%X %d %d %d ", get_current_dialog_handler()); + if (arrow_keys_mode >= 10) // temporarily disabled { arrow_keys_mode = arrow_keys_mode - 10; if (is_arrow_mode_ok(arrow_keys_mode)) return; } - + do { arrow_keys_mode = mod(arrow_keys_mode + 1, 5); @@ -1598,7 +1605,7 @@ } #endif - #ifdef CONFIG_5D2 + #if defined(CONFIG_5D2) || defined(CONFIG_7D) if (event->param == BGMT_PICSTYLE) { arrow_key_mode_toggle(); @@ -1622,6 +1629,7 @@ } #endif + if (arrow_keys_mode && liveview_display_idle() && !gui_menu_shown()) { // maybe current mode is no longer enabled in menu @@ -1882,7 +1890,6 @@ static int countdown_for_unknown_button = 0; static int timestamp_for_unknown_button = 0; static int numclicks_for_unknown_button = 0; - void zoom_trick_step() { if (!zoom_trick) return; @@ -1910,13 +1917,12 @@ if ((lv && current_timestamp - timestamp_for_unknown_button >= 300 && numclicks_for_unknown_button == 2) || //~ (PLAY_MODE && is_pure_play_photo_mode() && current_timestamp - timestamp_for_unknown_button >= 100) || (PLAY_OR_QR_MODE && current_timestamp - timestamp_for_unknown_button >= 100)) - { - - // action! - if (zoom_trick == 1) fake_simple_button(BGMT_PRESS_ZOOMIN_MAYBE); - if (zoom_trick == 2) arrow_key_mode_toggle(); - - + { if (zoom_trick==1) + fake_simple_button(BGMT_PRESS_ZOOMIN_MAYBE); + if (zoom_trick ==2) arrow_key_mode_toggle(); + + + timestamp_for_unknown_button = 0; numclicks_for_unknown_button = 0; } @@ -2426,6 +2432,7 @@ CONFIG_INT("bmp.color.scheme", bmp_color_scheme, 0); static CONFIG_INT("lcd.adjust.position", lcd_adjust_position, 0); +static CONFIG_INT("uniwb.correction", uniwb_correction, 7); static int focus_peaking_grayscale_running() { @@ -2442,7 +2449,7 @@ static int is_adjusting_wb() { - #if defined(CONFIG_5D2) || defined(CONFIG_5D3) + #if defined(CONFIG_5D2) || defined(CONFIG_5D3) || defined(CONFIG_7D) // these cameras have a transparent LiveView dialog for adjusting Kelvin white balance // (maybe 7D too) extern thunk LiveViewWbApp_handler; @@ -2622,6 +2629,35 @@ #endif } +#ifdef FEATURE_UNIWB_CORRECTION +static void uniwb_correction_step() +{ + if (ml_shutdown_requested) return; + if (!DISPLAY_IS_ON) return; + if (!lv && !PLAY_OR_QR_MODE) return; + + // uniwb screen correction + int display_wb_register = 0xC0F14174; + int desired_wb = 0; + int current_wb = (int) shamem_read(display_wb_register); + if (uniwb_correction && uniwb_is_active() && !PREVIEW_SATURATION_GRAYSCALE && !focus_peaking_grayscale_running()) + { + int w = (uniwb_correction << 4) & 0xFF; + w = (w << 8) | w; + w = (w | 0xFFFF0000); + desired_wb = w; + } + else + { + desired_wb = 0; + } + if (current_wb != desired_wb) + { + EngDrvOut(display_wb_register, desired_wb); // both LV+PLAY + } +} +#endif + #ifdef FEATURE_LV_BRIGHTNESS_CONTRAST static void preview_show_contrast_curve() { @@ -2987,11 +3023,11 @@ if (ya > os.y0 && ya < os.y_max) { if (!mv || (ya > os.y0 + os.off_169 && ya < os.y_max - os.off_169)) - #ifdef CONFIG_DMA_MEMCPY - dma_memcpy(&dst_buf[LV(0,y)/4], &src_buf[LV(0,ya)/4], 720*2); - #else - memcpy(&dst_buf[LV(0,y)/4], &src_buf[LV(0,ya)/4], 720*2); - #endif + #ifdef CONFIG_DMA_MEMCPY + dma_memcpy(&dst_buf[LV(0,y)/4], &src_buf[LV(0,ya)/4], 720*2); + #else + memcpy(&dst_buf[LV(0,y)/4], &src_buf[LV(0,ya)/4], 720*2); + #endif else yuvcpy_dark(&dst_buf[LV(0,y)/4], &src_buf[LV(0,ya)/4], 720*2, y%2); } @@ -3152,7 +3188,7 @@ info_led_off(); free(defish_lut); } - + defish_draw_lv_color_loop((uint64_t*)src_buf, (uint64_t*)dst_buf, defish_ind); } @@ -3175,8 +3211,12 @@ uint16_t * defish_lut = defish_lut_load(); if (!defish_lut) return; - memcpy(aux_buf, lvram, buf_size); - + #ifdef CONFIG_DMA_MEMCPY + dma_memcpy(aux_buf, lvram, buf_size); + #else + memcpy(aux_buf, lvram, buf_size); + #endif + for (int y = BM2LV_Y(os.y0); y < BM2LV_Y(os.y0 + os.y_ex/2); y++) { for (int x = BM2LV_X(os.x0); x < BM2LV_X(os.x0 + os.x_ex/2); x++) @@ -3266,6 +3306,7 @@ *src_buf = CACHEABLE(YUV422_LV_BUFFER_1); *dst_buf = CACHEABLE(YUV422_LV_BUFFER_2); #endif + } // type 1 filters: compute histogram on filtered image @@ -3294,7 +3335,7 @@ static int display_filter_valid_image = 0; -#if defined(CONFIG_5D2) || defined(CONFIG_50D) +#if defined(CONFIG_5D2) || defined(CONFIG_50D) || defined(CONFIG_7D) static int display_broken = 0; int display_broken_for_mz() { @@ -3343,6 +3384,28 @@ EnableImagePhysicalScreenParameter(); } } + +#elif defined(CONFIG_7D) +//4430 - Debug Flag +//445C + E8 - Current LV or 0 +//455C + F0 - Current Lv or 0 +//x + F4 = LV buffer.. print x, look around + int sync = (MEM(x+0xF4) == YUV422_LV_BUFFER_1); + int hacked = ( MEM(0x4430+0xE8) == MEM(0x4430+0xF0) && MEM(0x4430+0xF0) == MEM(x+0xF4)); + display_broken = hacked; + + if (!display_filter_valid_image) return CBR_RET_CONTINUE; + if (!display_filter_enabled()) { display_filter_valid_image = 0; return CBR_RET_CONTINUE; } + + if (display_filter_enabled()) + { + if (sync || hacked) + { + MEM(0x4430+0xE8) = 0; + YUV422_LV_BUFFER_DISPLAY_ADDR = YUV422_LV_BUFFER_2; // update buffer 1, display buffer 2 + EnableImagePhysicalScreenParameter(); + } + } #elif defined(CONFIG_CAN_REDIRECT_DISPLAY_BUFFER_EASILY) // all new cameras should work with this method if (!display_filter_valid_image) return CBR_RET_CONTINUE; @@ -3573,7 +3636,7 @@ },*/ }, #endif - #if defined(CONFIG_KILL_FLICKER) || defined(FEATURE_SCREEN_LAYOUT) || defined(FEATURE_IMAGE_POSITION) || defined(FEATURE_UPSIDE_DOWN) || defined(FEATURE_IMAGE_ORIENTATION) || defined(FEATURE_AUTO_MIRRORING_HACK) || defined(FEATURE_FORCE_HDMI_VGA) + #if defined(CONFIG_KILL_FLICKER) || defined(FEATURE_SCREEN_LAYOUT) || defined(FEATURE_IMAGE_POSITION) || defined(FEATURE_UPSIDE_DOWN) || defined(FEATURE_IMAGE_ORIENTATION) || defined(FEATURE_AUTO_MIRRORING_HACK) || defined(FEATURE_FORCE_HDMI_VGA) || defined(FEATURE_UNIWB_CORRECTION) { .name = "Advanced settings", .select = menu_open_submenu, @@ -3697,6 +3760,17 @@ .help = "Force low resolution (720x480) on HDMI displays.", }, #endif + #ifdef FEATURE_UNIWB_CORRECTION + { + .name = "UniWB correct", + .priv = &uniwb_correction, + .max = 10, + .choices = (const char *[]) {"OFF", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, + .help = "Removes the green color cast when you use UniWB.", + .edit_mode = EM_MANY_VALUES_LV, + .icon_type = IT_PERCENT_OFF, + }, + #endif MENU_EOL }, }, diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/video_hacksU.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video_hacksU.c Sun Sep 22 11:41:50 2013 -0500 @@ -0,0 +1,225 @@ + +/** \file + * Video Hacks + */ +#include "dryos.h" +#include "bmp.h" +#include "tasks.h" +#include "debug.h" +#include "menu.h" +#include "property.h" +#include "config.h" +#include "gui.h" +#include "lens.h" +#include "mvr.h" + + +#if defined(FEATURE_VIDEO_HACKS) +PROP_INT(PROP_MOVIE_SOUND_RECORD, sound); +#ifdef CONFIG_DIGIC_V +int video_mode[6]; +PROP_HANDLER(PROP_VIDEO_MODE) +{ + memcpy(video_mode, buf, 24); +} +#else +int video_mode[5]; +PROP_HANDLER(PROP_VIDEO_MODE) +{ + memcpy(video_mode, buf, 20); +} +#endif + +int hacked=0; + +#include "cache_hacks.h" + +static CONFIG_INT( "h264.cache_hacks", bitrate_cache_hacks, 0 ); +static CONFIG_INT( "h264.flushing_rate", bitrate_flushing_rate, 4 ); +static CONFIG_INT( "h264.gop_size", bitrate_gop_size, 12 ); +#ifndef CONFIG_DIGIC_V +static CONFIG_INT( "h264.file_size", bitrate_file_size, 1 ); +#endif + +//~ uint32_t bitrate_cache_hacks = 0; +//~ uint32_t bitrate_flushing_rate = 4; +//~ uint32_t bitrate_gop_size = 12; +void patch_all() +{ +#define I_NOOP 0xE1A00000 +#define CMP_R1_R1 0xE1510001 + +#ifdef CONFIG_600D +#define UNK_GOP_LOC 0xFF25516C +#define GOP_MISMATCH_LOC 0xFF048054 +#elif defined CONFIG_1100D +#define UNK_GOP_LOC 0xFF2478E8 +#define GOP_MISMATCH_LOC 0xFF047E4C +#elif defined CONFIG_EOSM +#define UNK_GOP_LOC 0xFF3D6FA0 +#define GOP_MISMATCH_COMP 0xFF0DBFF0 +#endif + +#ifdef UNK_GOP_LOC +cache_fake(UNK_GOP_LOC , I_NOOP, TYPE_ICACHE); +#endif +#ifdef GOP_MISMATCH_LOC +// Movie "Gop Mismatch" +cache_fake(GOP_MISMATCH_LOC , I_NOOP, TYPE_ICACHE); +#endif +#ifdef GOP_MISMATCH_COMP +cache_fake(GOP_MISMATCH_COMP , CMP_R1_R1, TYPE_ICACHE); +#endif + +//~ #ifdef CONFIG_600D //Overrun +//~ cache_fake(0xFF04C6A4 , 0xE1500000, TYPE_ICACHE); +//~ cache_fake(0xFF04C69C , 0xE1500000, TYPE_ICACHE); +//~ #endif +hacked = 1; +} +static MENU_UPDATE_FUNC(bitrate_flushing_rate_update) +{ + MENU_SET_VALUE("%d frames", bitrate_flushing_rate ); + + if(!bitrate_cache_hacks) + { + MENU_SET_WARNING(MENU_WARN_ADVICE, "Video hacks disabled."); + } + if (bitrate_flushing_rate == 1) + MENU_SET_VALUE("OFF"); + +} + +static MENU_UPDATE_FUNC(bitrate_gop_size_update) +{ + MENU_SET_VALUE("%d frames", bitrate_gop_size); + + if(!bitrate_cache_hacks) + { + MENU_SET_WARNING(MENU_WARN_ADVICE, "Video hacks disabled."); + } + if (bitrate_gop_size == 0) + MENU_SET_VALUE("OFF"); +} + +static void +video_hack_task( void* unused ) +{ + uint32_t old_bitrate_cache_hacks = 0; + uint32_t old_bitrate_gop_size = 0; + uint32_t old_bitrate_flushing_rate = 0; + + TASK_LOOP + { + { + /* anything changed? */ + if(bitrate_cache_hacks != old_bitrate_cache_hacks || bitrate_flushing_rate != old_bitrate_flushing_rate || bitrate_gop_size != old_bitrate_gop_size) + { + if(bitrate_cache_hacks) + { if (hacked != 1) patch_all(); + + /* patch flushing rate */ + #if defined(CACHE_HACK_FLUSH_RATE_SLAVE) + if (bitrate_flushing_rate!=1) + cache_fake(CACHE_HACK_FLUSH_RATE_SLAVE, 0xE3A00000 | (bitrate_flushing_rate & 0xFF), TYPE_ICACHE); + #endif + /* set GOP size */ + if (bitrate_gop_size != 0) + { video_mode[3] = bitrate_gop_size; //Gop Length + prop_request_change(PROP_VIDEO_MODE, video_mode, 0); + } +//~ #if 0 + if ( ( sound != 1) && ( (bitrate_flushing_rate!=1) || (bitrate_gop_size != 0)) ) + { int mode = 1; + prop_request_change(PROP_MOVIE_SOUND_RECORD, &mode, 4); + NotifyBox(2000,"Canon sound disabled"); + } +//~ #endif +#ifdef CONFIG_600D // Doesn't revert if video_hacks off TODO works by itself with indicator + if (bitrate_file_size == 2) + { //uint32_t* fsize = (uint32_t*) (0x1E44) + 0x50; + uint32_t* fsize2 = (uint32_t*) (MEM(0x1E44) + 0x144); + *fsize2 = 0x00000003; + } +#endif + } + else + { + /* undo flushing rate */ + #if defined(CACHE_HACK_FLUSH_RATE_SLAVE) + if (bitrate_flushing_rate == 1) + cache_fake(CACHE_HACK_FLUSH_RATE_SLAVE, MEM(CACHE_HACK_FLUSH_RATE_SLAVE), TYPE_ICACHE); + #endif + /* undo GOP size */ + if (bitrate_gop_size == 0) + { + video_mode[3] = video_mode[2]/2; // FPS/2 + prop_request_change(PROP_VIDEO_MODE, video_mode, 0); + } + } +#ifdef CONFIG_600D + if (bitrate_file_size == 1) + { //uint32_t* fsize = (uint32_t*) (0x) + 0x50; + uint32_t* fsize2 = (uint32_t*) (MEM(0x1E44) + 0x144); + *fsize2 = 0x00000000; + } +#endif + old_bitrate_cache_hacks = bitrate_cache_hacks; + old_bitrate_gop_size = bitrate_gop_size; + old_bitrate_flushing_rate = bitrate_flushing_rate; + } + } + + msleep(250); + } +} + +static struct menu_entry video_hack_menus[] = { + { + .name = "Video Hacks", + .priv = &bitrate_cache_hacks, + .max = 1, + .help = "Experimental hacks: flush rate, GOP size. Be careful!", + .depends_on = DEP_MOVIE_MODE, + .children = (struct menu_entry[]) { + { + .name = "Flush rate", + .priv = &bitrate_flushing_rate, + .update = bitrate_flushing_rate_update, + .min = 1, + .max = 50, + .help = "Flush movie buffer every n frames." + }, + { + .name = "GOP size", + .priv = &bitrate_gop_size, + .update = bitrate_gop_size_update, + .min = 0, + .max = 100, + .help = "Set GOP size to n frames." + }, +#ifdef CONFIG_600D + { + .name = "File size", + .priv = &bitrate_file_size, + .min = 1, + .max = 2, + .choices = (const char *[]) {"4GB", "16GB"}, + .help = "Max File Size. Will need EOSMovieFixer.exe" + }, +#endif + MENU_EOL + }, + }, +}; + +void video_hack_init() +{ + cache_lock(); + menu_add( "Movie", video_hack_menus, COUNT(video_hack_menus) ); +} + +INIT_FUNC(__FILE__, video_hack_init); +TASK_CREATE("video_hack_task", video_hack_task, 0, 0x1d, 0x1000 ); + +#endif diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/vram.c --- a/src/vram.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/vram.c Sun Sep 22 11:41:50 2013 -0500 @@ -449,12 +449,11 @@ lut_realloc(&lut_lv2bm); }*/ -#include "bmp.h" - - static inline void * get_yuv422buffer(int offset) { - #if defined(CONFIG_1100D) || defined(CONFIG_6D) + //~ #if defined(CONFIG_1100D) //|| defined(CONFIG_DIGIC_V) || defined(CONFIG_50D) + #ifdef YUV422_LV_BUFFER_DISPLAY_ADDR + //~ NotifyBox(1000, "buf %x", (void*)CACHEABLE(YUV422_LV_BUFFER_DISPLAY_ADDR)); return (void*)CACHEABLE(YUV422_LV_BUFFER_DISPLAY_ADDR); // Good enough #else if (YUV422_LV_BUFFER_DISPLAY_ADDR == YUV422_LV_BUFFER_1) @@ -487,6 +486,7 @@ return get_yuv422buffer(0); } +/* static int fastrefresh_direction = 0; static unsigned old_buffer_pos = 0; @@ -497,17 +497,40 @@ if (old_buffer_pos == YUV422_LV_BUFFER_1 && YUV422_LV_BUFFER_DISPLAY_ADDR == YUV422_LV_BUFFER_3) fastrefresh_direction = 0; old_buffer_pos = YUV422_LV_BUFFER_DISPLAY_ADDR; } - +*/ void* get_fastrefresh_422_buf() { - return get_yuv422buffer(fastrefresh_direction ? 1 : 2); + //~ return get_yuv422buffer(fastrefresh_direction ? 1 : 2); + return get_yuv422buffer(0); } -// Unfortunately this doesn't work on every 1100D model yet :( -static void* get_fastrefresh_422_other_buf() +void* get_fastrefresh_422_other_buf() { - return get_yuv422buffer(fastrefresh_direction ? 2 : 1); + //~ return get_yuv422buffer(fastrefresh_direction ? 2 : 1); + int offset = 1; + if (YUV422_LV_BUFFER_DISPLAY_ADDR == YUV422_LV_BUFFER_1) + offset += 0; + else if (YUV422_LV_BUFFER_DISPLAY_ADDR == YUV422_LV_BUFFER_2) + offset += 1; + else + offset += 2; + + switch (offset) + { + case 0: + case 3: + default: + return (void*)CACHEABLE(YUV422_LV_BUFFER_1); + + case 1: + case 4: + return (void*)CACHEABLE(YUV422_LV_BUFFER_2); + case 2: + case 5: + return (void*)CACHEABLE(YUV422_LV_BUFFER_3); + } + } #ifdef CONFIG_500D diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/vsync-lite.c --- a/src/vsync-lite.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/vsync-lite.c Sun Sep 22 11:41:50 2013 -0500 @@ -15,7 +15,7 @@ void lv_vsync(int mz) { - #if defined(CONFIG_DIGIC_V) || defined(CONFIG_60D) + #if defined(CONFIG_DIGIC_V) /*&& !(defined(CONFIG_EOSM))*/ || defined(CONFIG_60D) || defined(CONFIG_7D) int msg; msg_queue_receive(vsync_msg_queue, (struct event**)&msg, 100); #else diff -r 4b3129d5a739 -r 7a5ccc6c8531 src/zebra.c --- a/src/zebra.c Fri Sep 20 16:56:08 2013 +0300 +++ b/src/zebra.c Sun Sep 22 11:41:50 2013 -0500 @@ -139,7 +139,7 @@ if (is_movie_mode()) return 1; int digic_iso_gain_photo = get_digic_iso_gain_photo(); - return get_expsim() && digic_iso_gain_photo == 1024; + return expsim && digic_iso_gain_photo == 1024; } #ifdef FEATURE_SHOW_OVERLAY_FPS @@ -419,7 +419,7 @@ //~ PROP_HOUTPUT_TYPE handler only fires when Canon overlays are hidden, not restored. //~ So we update lv_disp_mode here instead. #ifdef CONFIG_EOSM - lv_disp_mode = (MEM(0x8A01C + 0x7C) != 3); + lv_disp_mode = (MEM(0x89BAC + 0x7C) != 3); #endif extern int ml_started; @@ -899,7 +899,7 @@ /* define this to check if color channels are identified correctly */ #undef RAW_ZEBRA_TEST - + #ifdef RAW_ZEBRA_TEST { uint32_t* lv = get_yuv422_vram()->vram; @@ -1346,23 +1346,28 @@ BMP_LOCK( bzero32(bvram_mirror_start, BMP_VRAM_SIZE); ) cropmark_cache_dirty = 1; } +//~ #ifdef CONFIG_6D +//~ CONFIG_INT("bvram.mode", bvram_loc, 0); +//~ #endif + + void bvram_mirror_init() { if (!bvram_mirror_start) { - // shoot_malloc is not that stable - //~ #if defined(CONFIG_600D) || defined(CONFIG_1100D) - //~ bvram_mirror_start = (void*)shoot_malloc(BMP_VRAM_SIZE); // there's little memory available in system pool - //~ #else #if defined(RSCMGR_MEMORY_PATCH_END) extern unsigned int ml_reserved_mem; bvram_mirror_start = RESTARTSTART + ml_reserved_mem; - #elif defined(CONFIG_EOSM) + #elif defined(CONFIG_600D) || defined(CONFIG_1100D) //|| defined(CONFIG_6D) + bvram_mirror_start = (void*)shoot_malloc(BMP_VRAM_SIZE); // hsuite + //~ #elif defined(CONFIG_6D) + //~ bvram_mirror_start = (void*)AllocateMemory(BMP_VRAM_SIZE); + //~ bvram_mirror_start = (void*)shoot_malloc(BMP_VRAM_SIZE); // hsuite + #elif defined(CONFIG_EOSM) //|| defined(CONFIG_50D) bvram_mirror_start = (void*)malloc(BMP_VRAM_SIZE); // malloc is big! #else bvram_mirror_start = (void*)AllocateMemory(BMP_VRAM_SIZE); #endif - //~ #endif if (!bvram_mirror_start) { while(1) @@ -1836,8 +1841,11 @@ int w = get_yuv422_vram()->width; int h = get_yuv422_vram()->height; int buf_size = w * h * 2; - memcpy(aux_buf, current_buf, buf_size); - + #ifdef CONFIG_DMA_MEMCPY + dma_memcpy(aux_buf, current_buf, buf_size); + #else + memcpy(aux_buf, current_buf, buf_size); + #endif src_buf = aux_buf; dst_buf = current_buf; } @@ -2313,7 +2321,6 @@ } int k = 0; do { - if (file.mode & ATTR_DIRECTORY) continue; // is a directory if (is_valid_cropmark_filename(file.name)) { if (k >= MAX_CROPMARKS) @@ -2702,10 +2709,13 @@ if( !vram->vram ) return 0; + const uint16_t* vr1 = (void*)YUV422_LV_BUFFER_DISPLAY_ADDR; - const uint16_t* vr2 = (void*)get_fastrefresh_422_buf(); + //~ const uint16_t* vr1 = (void*)YUV422_LV_BUFFER_1; + //~ const uint16_t* vr2 = (void*)get_fastrefresh_422_buf(); + const uint16_t* vr2 = (void*)get_fastrefresh_422_other_buf(); uint8_t * const bm = bmp_vram(); - if (!bm) return 0; + if (!bm) return 0; const unsigned width = vram->width; int x, y; @@ -4235,7 +4245,7 @@ uint16_t* hdr = (uint16_t*) hd->vram; // select buffer where MZ should be written (camera-specific, guesswork) - #if defined(CONFIG_5D2) || defined(CONFIG_EOSM) || defined(CONFIG_50D) + #if defined(CONFIG_5D2) || defined(CONFIG_EOSM) || defined(CONFIG_50D) || defined(CONFIG_7D) /* fixme: ugly hack */ void busy_vsync(int hd, int timeout_ms) { @@ -4249,14 +4259,14 @@ void* new = (void*)shamem_read(hd ? REG_EDMAC_WRITE_HD_ADDR : REG_EDMAC_WRITE_LV_ADDR); if (old != new) break; if (dt > timeout_us) - return 0; + return; for (int i = 0; i < 100; i++) asm("nop"); // don't stress the digic too much } } lvr = (uint16_t*) shamem_read(REG_EDMAC_WRITE_LV_ADDR); busy_vsync(0, 20); #endif - #if defined(CONFIG_DIGIC_V) + #if defined(CONFIG_DIGIC_V) && ! defined(CONFIG_EOSM) lvr = CACHEABLE(YUV422_LV_BUFFER_DISPLAY_ADDR); if (lvr != CACHEABLE(YUV422_LV_BUFFER_1) && lvr != CACHEABLE(YUV422_LV_BUFFER_2) && lvr != CACHEABLE(YUV422_LV_BUFFER_3)) return; #else @@ -4411,17 +4421,15 @@ struct dialog * dialog = current->priv; extern thunk LiveViewApp_handler; extern uintptr_t new_LiveViewApp_handler; - - #if defined(CONFIG_5D3) + #if defined(CONFIG_5D3)// || defined(CONFIG_6D) extern thunk LiveViewLevelApp_handler; #elif defined(CONFIG_DIGIC_V) extern thunk LiveViewShutterApp_handler; #endif - #if defined(CONFIG_6D) extern thunk LiveViewWifiApp_handler; #endif - + //~ NotifyBox(1000, "%X", dialog->handler); return LV_NON_PAUSED && DISPLAY_IS_ON && @@ -4429,10 +4437,10 @@ (// gui_menu_shown() || // force LiveView when menu is active, but hidden ( gui_state == GUISTATE_IDLE && (dialog->handler == (dialog_handler_t) &LiveViewApp_handler || dialog->handler == (dialog_handler_t) new_LiveViewApp_handler - #if defined(CONFIG_5D3) + #if defined(CONFIG_5D3) //|| defined(CONFIG_6D) || dialog->handler == (dialog_handler_t) &LiveViewLevelApp_handler #endif - #if defined(CONFIG_6D) + #if defined(CONFIG_6D) || dialog->handler == (dialog_handler_t) &LiveViewWifiApp_handler #endif //~ for this, check value of get_current_dialog_handler() @@ -4456,6 +4464,7 @@ !is_zoom_mode_so_no_zebras() && !(clearscreen == 1 && (get_halfshutter_pressed() || dofpreview)) && !WAVEFORM_FULLSCREEN; + } #ifdef FEATURE_OVERLAYS_IN_PLAYBACK_MODE @@ -4626,6 +4635,11 @@ } #endif } +#ifdef FEATURE_REC_ON_RESUME +//reconresume +extern int start_recording_on_resume; +static int resumed_due_to_halfshutter = 0; +#endif static int idle_countdown_display_dim = 50; static int idle_countdown_display_off = 50; @@ -4702,7 +4716,7 @@ void idle_wakeup_reset_counters(int reason) // called from handle_buttons { if (ml_shutdown_requested) return; - + // if (reason==0) return; #if 0 NotifyBox(2000, "wakeup: %d ", reason); #endif @@ -4726,6 +4740,20 @@ if (reason == -10 || reason == -11) // focus event (todo: should define constants for those) return; +// if (reason == 19|| reason == 29 || reason == GMT_OLC_INFO_CHANGED ) +// return; + #ifdef FEATURE_REC_ON_RESUME + if(start_recording_on_resume) { + if(reason == BGMT_PRESS_HALFSHUTTER) { + resumed_due_to_halfshutter = 1; + } + } else { + resumed_due_to_halfshutter = 0; + } + #endif + + + #ifdef CONFIG_KILL_FLICKER idle_countdown_killflicker = 10; #endif @@ -4862,12 +4890,26 @@ ASSERT(!(recording && LV_PAUSED)); ASSERT(!DISPLAY_IS_ON); } + + static void idle_display_on() { //~ card_led_blink(5, 50, 50); ResumeLiveView(); display_on(); redraw(); + #ifdef FEATURE_REC_ON_RESUME + //rec on resume + if(start_recording_on_resume) + { + if(lv && is_movie_mode()) + { + schedule_movie_start(); + if (resumed_due_to_halfshutter == 1) + resumed_due_to_halfshutter = 0; + } + } + #endif //~ ASSERT(DISPLAY_IS_ON); // it will take a short time until display will turn on } @@ -5352,7 +5394,7 @@ int mz = should_draw_zoom_overlay(); lv_vsync(mz); - guess_fastrefresh_direction(); + //~ guess_fastrefresh_direction(); #ifdef FEATURE_MAGIC_ZOOM if (mz) @@ -5405,9 +5447,11 @@ #endif #ifdef CONFIG_ELECTRONIC_LEVEL - if (electronic_level && k % 8 == 5) - BMP_LOCK( if (lv) show_electronic_level(); ) - #endif + if ( (electronic_level && k % 8 == 5) && !recording) + BMP_LOCK( if (lv /* && is_movie_mode() */ ) show_electronic_level(); ) + if ( /*!is_movie_mode() ||*/ recording) + disable_electronic_level(); + #endif #ifdef FEATURE_REC_NOTIFY if (k % 8 == 7) rec_notify_continuous(0); @@ -5427,7 +5471,7 @@ int kmm = k % m; if (!gui_menu_shown()) // don't update everything in one step, to reduce magic zoom flicker { - #if defined(CONFIG_550D) || defined(CONFIG_5D2) + #if defined(CONFIG_550D) || defined(CONFIG_5D2) || defined(CONFIG_50D) if (kmm == 0) BMP_LOCK( if (lv) black_bars(); ) #endif @@ -5503,7 +5547,9 @@ { #ifdef CONFIG_KILL_FLICKER if (!get_global_draw()) return; + //~ if (raw_lv_is_enabled()) return; if (!is_movie_mode()) return; + if (lv_dispsize > 1) return; get_yuv422_vram(); if (video_mode_resolution > 1) { @@ -5591,7 +5637,7 @@ (focus_peaking ? 1<<8 : 0) | (zoom_overlay_enabled ? 1<<9 : 0) | (transparent_overlay ? 1<<10: 0) | - //~ (electronic_level ? 1<<11: 0) | + (electronic_level ? 1<<11: 0) | //~ (defish_preview ? 1<<12: 0) | (vectorscope_draw ? 1<<13: 0) | 0; @@ -5623,7 +5669,7 @@ focus_peaking = bits & (1<<8) ? 1 : 0; zoom_overlay_enabled = bits & (1<<9) ? 1 : 0; transparent_overlay = bits & (1<<10)? 1 : 0; - //~ electronic_level = bits & (1<<11)? 1 : 0; + electronic_level = bits & (1<<11)? 1 : 0; //~ defish_preview = bits & (1<<12)? 1 : 0; vectorscope_draw = bits & (1<<13)? 1 : 0; global_draw = global_draw_0 + global_draw_1 * 2; @@ -5992,3 +6038,4 @@ beep(); lv = lv0; } + diff -r 4b3129d5a739 -r 7a5ccc6c8531 tcc/tccrun.c --- a/tcc/tccrun.c Fri Sep 20 16:56:08 2013 +0300 +++ b/tcc/tccrun.c Sun Sep 22 11:41:50 2013 -0500 @@ -170,7 +170,7 @@ s1->runtime_plt_and_got = (char *)(mem + offset); /* double the size of the buffer for got and plt entries XXX: calculate exact size for them? */ - + //~ offset *= 2; /* g3gg0 says it will never happen: