source: trunk/core/main.c @ 957

Revision 957, 2.9 KB checked in by reyalp, 3 years ago (diff)

ptp support based on mweerden's proposal in http://chdk.setepontos.com/index.php/topic,4338.msg52984.html#msg52984
this is currently disabled by default. See http://chdk.setepontos.com/index.php/topic,4338.msg55942.html#msg55942 for additional information

  • Property svn:eol-style set to native
Line 
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
13static int raw_need_postprocess;
14static volatile int spytask_can_start;
15
16void core_hook_task_create(void *tcb)
17{
18}
19
20void core_hook_task_delete(void *tcb)
21{
22char *name = (char*)(*(long*)((char*)tcb+0x34));
23 if (strcmp(name,"tInitFileM")==0) core_spytask_can_start();
24}
25
26
27long core_get_noise_reduction_value()
28{
29    return conf.raw_nr;
30}
31
32
33void 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// TODO actual memory size is larger than 32 MB on many cameras!
53            write(fd, (void*)0x1900, 32*1024*1024-0x1900);
54            close(fd);
55        }
56    vid_bitmap_refresh();
57    finished();
58}
59
60static volatile long raw_data_available;
61
62/* called from another process */
63void core_rawdata_available()
64{
65    raw_data_available = 1;
66}
67
68void core_spytask_can_start() {
69        spytask_can_start = 1;
70}
71
72void core_spytask()
73{
74    int cnt = 1;
75    int i=0;
76
77    raw_need_postprocess = 0;
78
79    spytask_can_start=0;
80
81#ifdef CAM_CHDK_PTP
82        init_chdk_ptp_task();
83#endif
84
85    while((i++<400) && !spytask_can_start) msleep(10);
86
87    started();
88    msleep(50);
89    finished();
90    drv_self_unhide();
91
92    conf_restore();
93    gui_init();
94
95#if CAM_CONSOLE_LOG_ENABLED
96    console_init();
97#endif
98
99    mkdir("A/CHDK");
100    mkdir("A/CHDK/FONTS");
101    mkdir("A/CHDK/SYMBOLS");
102    mkdir("A/CHDK/SCRIPTS");
103    mkdir("A/CHDK/LANG");
104    mkdir("A/CHDK/BOOKS");
105    mkdir("A/CHDK/GRIDS");
106#ifdef OPT_CURVES
107    mkdir("A/CHDK/CURVES");
108#endif
109    mkdir("A/CHDK/DATA");
110    mkdir("A/CHDK/LOGS");
111#ifdef OPT_EDGEOVERLAY
112    mkdir("A/CHDK/EDGE");
113#endif
114    auto_started = 0;
115
116    if (conf.script_startup==1) script_autostart();                             // remote autostart
117        if (conf.script_startup==2) {
118                conf.script_startup=0;
119                conf_save();
120                script_autostart();
121        }
122    while (1){
123
124        if (raw_data_available){
125            raw_need_postprocess = raw_savefile();
126            hook_raw_save_complete();
127            raw_data_available = 0;
128            continue;
129        }
130
131        if (state_shooting_progress != SHOOTING_PROGRESS_PROCESSING) {
132            if (((cnt++) & 3) == 0)
133                gui_redraw();
134
135            histogram_process();
136#ifdef OPT_EDGEOVERLAY
137        if(conf.edge_overlay_thresh && conf.edge_overlay_enable) edge_overlay();
138#endif
139        }
140
141        if ((state_shooting_progress == SHOOTING_PROGRESS_PROCESSING) && (!shooting_in_progress())) {
142            state_shooting_progress = SHOOTING_PROGRESS_DONE;
143            if (raw_need_postprocess) raw_postprocess();
144        }
145
146        msleep(20);
147    }
148}
149
150
151
152
Note: See TracBrowser for help on using the repository browser.