CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
main.c-Dateireferenz
#include "platform.h"
#include "core.h"
#include "conf.h"
#include "gui.h"
#include "gui_draw.h"
#include "histogram.h"
#include "raw.h"
#include "console.h"
#include "shooting.h"
#include "edgeoverlay.h"
#include "module_load.h"
#include "kbd_common.h"
+ Include-Abhängigkeitsdiagramm für main.c:

gehe zum Quellcode dieser Datei

Funktionen

void schedule_memdump ()
 
void dump_memory ()
 
int core_get_free_memory ()
 
void core_rawdata_available ()
 
void core_spytask_can_start ()
 
void script_autostart ()
 
void core_spytask ()
 

Variablen

static char osd_buf [50]
 
volatile int chdk_started_flag =0
 
int no_modules_flag
 
static volatile int spytask_can_start
 
static unsigned int memdmptick = 0
 
volatile int memdmp_delay = 0
 
static volatile long raw_data_available
 

Dokumentation der Funktionen

int core_get_free_memory ( )

Definiert in Zeile 85 der Datei main.c.

86 {
87  cam_meminfo camera_meminfo;
88  GetCombinedMemInfo(&camera_meminfo);
89  return camera_meminfo.free_block_max_size;
90 }
void core_rawdata_available ( )

Definiert in Zeile 95 der Datei main.c.

96 {
98 }
void core_spytask ( )

Definiert in Zeile 115 der Datei main.c.

116 {
117  int cnt = 1;
118  int i=0;
119 #ifdef CAM_HAS_GPS
120  int gps_delay_timer = 200 ;
121  int gps_state = -1 ;
122 #endif
123 #if (OPT_DISABLE_CAM_ERROR)
124  extern void DisableCamError();
125  int dce_cnt=0;
126  int dce_prevmode=0;
127  int dce_nowmode;
128 #endif
129 
130  parse_version(&chdk_version, BUILD_NUMBER, BUILD_SVNREV);
131 
132  // Init camera_info bits that can't be done statically
134 
136 
137 #if !defined(CAM_DRYOS)
138 // create semaphore to protect Canon memory malloc/free/memPartInfo
139 // on VxWorks, spytask should start before any other CHDK tasks
140  extern void canon_malloc_init(void);
142 #endif
143 
144  extern void aram_malloc_init(void);
146 
147  extern void exmem_malloc_init(void);
149 
150 #ifdef CAM_CHDK_PTP
151  extern void init_chdk_ptp_task();
153 #endif
154 
155  while((i++<1000) && !spytask_can_start) msleep(10);
156 
157  started();
158  msleep(50);
159  finished();
160 
161 #if !CAM_DRYOS
162  drv_self_unhide();
163 #endif
164 
165  conf_restore();
166 
167  extern void gui_init();
168  gui_init();
169 
170 #if CAM_CONSOLE_LOG_ENABLED
171  extern void cam_console_init();
172  cam_console_init();
173 #endif
174 
175  static char *chdk_dirs[] =
176  {
177  "A/CHDK",
178  "A/CHDK/FONTS",
179  "A/CHDK/SYMBOLS",
180  "A/CHDK/SCRIPTS",
181  "A/CHDK/LANG",
182  "A/CHDK/BOOKS",
183  "A/CHDK/MODULES",
184  "A/CHDK/MODULES/CFG",
185  "A/CHDK/GRIDS",
186  "A/CHDK/CURVES",
187  "A/CHDK/DATA",
188  "A/CHDK/LOGS",
189  "A/CHDK/EDGE",
190  };
191  for (i = 0; i < (int)(sizeof(chdk_dirs) / sizeof(char*)); i++)
192  mkdir_if_not_exist(chdk_dirs[i]);
193 
194  no_modules_flag = stat("A/CHDK/MODULES/FSELECT.FLT",0) ? 1 : 0 ;
195 
196  // Calculate the value of get_tick_count() when the clock ticks over to the next second
197  // Used to calculate the SubSecondTime value when saving DNG files.
198  long t1, t2;
199  t2 = time(0);
200  do
201  {
202  t1 = t2;
204  t2 = time(0);
205  msleep(10);
206  } while (t1 != t2);
208 
209  // remote autostart
211  {
213  }
215  {
217  conf_save();
219  }
220 
221  shooting_init();
222 
223  // if starting with HDMI connected, suspend drawing for 3s to avoid crashes
224 #ifdef HDMI_HPD_FLAG
225  if(get_hdmi_hpd_physw_mod()) {
226  draw_suspend(3000);
227  }
228 #endif
229 
231  module_run("fwcrc.flt");
232  }
233 
234  while (1)
235  {
236  // Set up camera mode & state variables
237  mode_get();
238 
239 #ifdef CAM_CLEAN_OVERLAY
240  extern void handle_clean_overlay();
241  handle_clean_overlay();
242 #endif
243 
244 #ifdef CAM_UNLOCK_ANALOG_AV_IN_REC
245  extern void handle_analog_av_in_rec();
246  handle_analog_av_in_rec();
247 #endif
248  // update HDMI power override based on mode and remote settings
249 #ifdef CAM_REMOTE_HDMI_POWER_OVERRIDE
250  extern void update_hdmi_power_override(void);
251  update_hdmi_power_override();
252 #endif
253 
254  extern void set_palette();
255  set_palette();
256 
257 #if (OPT_DISABLE_CAM_ERROR)
258  dce_nowmode = camera_info.state.mode_play;
259  if (dce_prevmode==dce_nowmode)
260  { //no mode change
261  dce_cnt++; // overflow is not a concern here
262  }
263  else
264  { //mode has changed
265  dce_cnt=0;
266  }
267  if (dce_cnt==100)
268  { // 1..2s past play <-> rec mode change
269  DisableCamError();
270  }
271  dce_prevmode=dce_nowmode;
272 #endif
273 
274  if ( memdmptick && ((unsigned)get_tick_count() >= memdmptick) )
275  {
276  memdmptick = 0;
277  dump_memory();
278  }
279 
280 #ifdef CAM_HAS_GPS
281  if ( --gps_delay_timer == 0 )
282  {
283  gps_delay_timer = 50 ;
284  if ( gps_state != (int)conf.gps_on_off )
285  {
286  gps_state = (int)conf.gps_on_off ;
287  init_gps_startup(!gps_state) ;
288  }
289  }
290 #endif
291 
292  // Change ALT mode if the KBD task has flagged a state change
294 
295 #ifdef CAM_LOAD_CUSTOM_COLORS
296  // Color palette function
297  extern void load_chdk_palette();
299 #endif
300 
301  if (raw_data_available)
302  {
303  raw_process();
304  extern void hook_raw_save_complete();
306  raw_data_available = 0;
307 #ifdef CAM_HAS_GPS
308  if (((int)conf.gps_on_off == 1) && ((int)conf.gps_waypoint_save == 1)) gps_waypoint();
309 #endif
310 #if defined(CAM_CALC_BLACK_LEVEL)
311  // Reset to default in case used by non-RAW process code (e.g. raw merge)
313 #endif
314  continue;
315  }
316 
318  {
319  if (((cnt++) & 3) == 0)
320  gui_redraw();
321  }
322 
324  {
325  if (conf.show_histo)
327 
329  {
330  // We need to skip first tick because stability
331  if (chdk_started_flag)
332  {
334  }
335  }
336  }
337 
339  {
341  }
342 
343  i = 0;
344 
345 #ifdef DEBUG_PRINT_TO_LCD
346  sprintf(osd_buf, "%d", cnt ); // modify cnt to what you want to display
348 #endif
349 #if defined(OPT_FILEIO_STATS)
350  sprintf(osd_buf, "%3d %3d %3d %3d %3d %3d %3d %4d",
351  camera_info.fileio_stats.fileio_semaphore_errors, camera_info.fileio_stats.close_badfile_count,
352  camera_info.fileio_stats.write_badfile_count, camera_info.fileio_stats.open_count,
353  camera_info.fileio_stats.close_count, camera_info.fileio_stats.open_fail_count,
354  camera_info.fileio_stats.close_fail_count, camera_info.fileio_stats.max_semaphore_timeout);
356 #endif
357 
359  {
360  sprintf(osd_buf, "MD last %-4d min %-4d max %-4d avg %-4d",
364  }
365 
366  // Process async module unload requests
368 
369  msleep(20);
371  }
372 }
void core_spytask_can_start ( )

Definiert in Zeile 100 der Datei main.c.

100  {
101  spytask_can_start = 1;
102 }
void dump_memory ( )

Definiert in Zeile 40 der Datei main.c.

41 {
42  int fd;
43  static int cnt=1;
44  static char fn[32];
45 
46  // zero size means all RAM
47  if (conf.memdmp_size == 0) conf.memdmp_size = (unsigned int)camera_info.maxramaddr + 1;
48  // enforce RAM area
49  if ((unsigned int)conf.memdmp_start > (unsigned int)camera_info.maxramaddr)
50  conf.memdmp_start = 0;
51  if ( (unsigned int)conf.memdmp_start + (unsigned int)conf.memdmp_size > ((unsigned int)camera_info.maxramaddr+1) )
52  conf.memdmp_size = (unsigned int)camera_info.maxramaddr + 1 - (unsigned int)conf.memdmp_start;
53 
54  started();
55  // try to avoid hanging the camera
56  if ( !is_video_recording() ) {
57  mkdir("A/DCIM");
58  mkdir("A/DCIM/100CANON");
59  fd = -1;
60  do {
61  sprintf(fn, "A/DCIM/100CANON/CRW_%04d.JPG", cnt++);
62  if (stat(fn,0) != 0) {
63  fd = open(fn, O_WRONLY|O_CREAT, 0777);
64  break;
65  }
66  } while(cnt<9999);
67  if (fd>=0) {
68  if ( conf.memdmp_start == 0 ) {
69  long val0 = *((long*)(0|CAM_UNCACHED_BIT));
70  write(fd, &val0, 4);
71  if (conf.memdmp_size > 4) {
72  write(fd, (void*)4, conf.memdmp_size - 4);
73  }
74  }
75  else {
76  write(fd, (void*)conf.memdmp_start, conf.memdmp_size);
77  }
78  close(fd);
79  }
81  }
82  finished();
83 }
void schedule_memdump ( )

Definiert in Zeile 35 der Datei main.c.

36 {
38 }
void script_autostart ( )

Definiert in Zeile 105 der Datei main.c.

106 {
107  // Tell keyboard task we are in <ALT> mode
108  enter_alt(0);
109  // We were called from the GUI task so switch to <ALT> mode before switching to Script mode
111  // Switch to script mode and start the script running
112  script_start_gui( 1 );
113 }

Variablen-Dokumentation

volatile int chdk_started_flag =0

Definiert in Zeile 26 der Datei main.c.

volatile int memdmp_delay = 0

Definiert in Zeile 33 der Datei main.c.

unsigned int memdmptick = 0
static

Definiert in Zeile 32 der Datei main.c.

int no_modules_flag

Definiert in Zeile 28 der Datei main.c.

char osd_buf[50]
static

Definiert in Zeile 22 der Datei main.c.

volatile long raw_data_available
static

Definiert in Zeile 92 der Datei main.c.

volatile int spytask_can_start
static

Definiert in Zeile 30 der Datei main.c.