| 1 | #include "platform.h" |
|---|
| 2 | #include "core.h" |
|---|
| 3 | #include "conf.h" |
|---|
| 4 | #include "keyboard.h" |
|---|
| 5 | #include "stdlib.h" |
|---|
| 6 | #include "gui.h" |
|---|
| 7 | #include "histogram.h" |
|---|
| 8 | #include "raw.h" |
|---|
| 9 | #include "motion_detector.h" |
|---|
| 10 | #ifdef OPT_EDGEOVERLAY |
|---|
| 11 | #include "edgeoverlay.h" |
|---|
| 12 | #endif |
|---|
| 13 | static int raw_need_postprocess; |
|---|
| 14 | static volatile int spytask_can_start; |
|---|
| 15 | |
|---|
| 16 | void core_hook_task_create(void *tcb) |
|---|
| 17 | { |
|---|
| 18 | } |
|---|
| 19 | |
|---|
| 20 | void core_hook_task_delete(void *tcb) |
|---|
| 21 | { |
|---|
| 22 | char *name = (char*)(*(long*)((char*)tcb+0x34)); |
|---|
| 23 | if (strcmp(name,"tInitFileM")==0) core_spytask_can_start(); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | long core_get_noise_reduction_value() |
|---|
| 28 | { |
|---|
| 29 | return conf.raw_nr; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | void dump_memory() |
|---|
| 34 | { |
|---|
| 35 | int fd; |
|---|
| 36 | static int cnt=1; |
|---|
| 37 | static char fn[32]; |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | started(); |
|---|
| 41 | mkdir("A/DCIM"); |
|---|
| 42 | mkdir("A/DCIM/100CANON"); |
|---|
| 43 | sprintf(fn, "A/DCIM/100CANON/CRW_%04d.JPG", cnt++); |
|---|
| 44 | fd = open(fn, O_WRONLY|O_CREAT, 0777); |
|---|
| 45 | if (fd) { |
|---|
| 46 | #ifdef CAMERA_ixus65_sd630 // Zero is not readable on ixus65! |
|---|
| 47 | write(fd, (int*)0xFFFF0000, 4); |
|---|
| 48 | write(fd, (int*)4, 0x1900-4); |
|---|
| 49 | #else |
|---|
| 50 | write(fd, (void*)0, 0x1900); |
|---|
| 51 | #endif |
|---|
| 52 | write(fd, (void*)0x1900, 32*1024*1024-0x1900); |
|---|
| 53 | close(fd); |
|---|
| 54 | } |
|---|
| 55 | vid_bitmap_refresh(); |
|---|
| 56 | finished(); |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | static volatile long raw_data_available; |
|---|
| 60 | |
|---|
| 61 | /* called from another process */ |
|---|
| 62 | void core_rawdata_available() |
|---|
| 63 | { |
|---|
| 64 | raw_data_available = 1; |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | void core_spytask_can_start() { |
|---|
| 68 | spytask_can_start = 1; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | void core_spytask() |
|---|
| 72 | { |
|---|
| 73 | int cnt = 1; |
|---|
| 74 | int i=0; |
|---|
| 75 | |
|---|
| 76 | raw_need_postprocess = 0; |
|---|
| 77 | |
|---|
| 78 | spytask_can_start=0; |
|---|
| 79 | |
|---|
| 80 | while((i++<250) && !spytask_can_start) msleep(10); |
|---|
| 81 | |
|---|
| 82 | started(); |
|---|
| 83 | msleep(50); |
|---|
| 84 | finished(); |
|---|
| 85 | drv_self_unhide(); |
|---|
| 86 | |
|---|
| 87 | conf_restore(); |
|---|
| 88 | gui_init(); |
|---|
| 89 | |
|---|
| 90 | #if CAM_CONSOLE_LOG_ENABLED |
|---|
| 91 | console_init(); |
|---|
| 92 | #endif |
|---|
| 93 | |
|---|
| 94 | mkdir("A/CHDK"); |
|---|
| 95 | mkdir("A/CHDK/FONTS"); |
|---|
| 96 | mkdir("A/CHDK/SYMBOLS"); |
|---|
| 97 | mkdir("A/CHDK/SCRIPTS"); |
|---|
| 98 | mkdir("A/CHDK/LANG"); |
|---|
| 99 | mkdir("A/CHDK/BOOKS"); |
|---|
| 100 | mkdir("A/CHDK/GRIDS"); |
|---|
| 101 | #ifdef OPT_CURVES |
|---|
| 102 | mkdir("A/CHDK/CURVES"); |
|---|
| 103 | #endif |
|---|
| 104 | mkdir("A/CHDK/DATA"); |
|---|
| 105 | mkdir("A/CHDK/LOGS"); |
|---|
| 106 | #ifdef OPT_EDGEOVERLAY |
|---|
| 107 | mkdir("A/CHDK/EDGE"); |
|---|
| 108 | #endif |
|---|
| 109 | auto_started = 0; |
|---|
| 110 | |
|---|
| 111 | if (conf.script_startup==1) script_autostart(); // remote autostart |
|---|
| 112 | if (conf.script_startup==2) { |
|---|
| 113 | conf.script_startup=0; |
|---|
| 114 | conf_save(); |
|---|
| 115 | script_autostart(); |
|---|
| 116 | } |
|---|
| 117 | while (1){ |
|---|
| 118 | |
|---|
| 119 | if (raw_data_available){ |
|---|
| 120 | raw_need_postprocess = raw_savefile(); |
|---|
| 121 | hook_raw_save_complete(); |
|---|
| 122 | raw_data_available = 0; |
|---|
| 123 | continue; |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | if (state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) { |
|---|
| 127 | if (((cnt++) & 3) == 0) |
|---|
| 128 | gui_redraw(); |
|---|
| 129 | |
|---|
| 130 | histogram_process(); |
|---|
| 131 | #ifdef OPT_EDGEOVERLAY |
|---|
| 132 | if(conf.edge_overlay_thresh && conf.edge_overlay_enable) edge_overlay(); |
|---|
| 133 | #endif |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | if ((state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) && (!shooting_in_progress())) { |
|---|
| 137 | state_shooting_progress = SHOOTING_PROGRESS_DONE; |
|---|
| 138 | if (raw_need_postprocess) raw_postprocess(); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | msleep(20); |
|---|
| 142 | } |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | |
|---|