root/platform/generic/shooting.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. shooting_expo_param_override
  2. shooting_expo_iso_override
  3. register_pt_hooks

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "keyboard.h"
   5 #include "math.h"
   6 #include "conf.h"
   7 
   8 #ifndef CAM_FILE_COUNTER_IS_VAR
   9 #ifndef PARAM_FILE_COUNTER
  10 #       error Please define PARAM_FILE_COUNTER in platform/CAMERA/shooting.c!
  11 #endif
  12 #endif
  13 
  14 #define AV96_MIN (aperture_sizes_table[0].prop_id)
  15 
  16 const unsigned int SS_SIZE  = sizeof(shutter_speeds_table)/sizeof(shutter_speeds_table[0]);
  17 const unsigned int AS_SIZE  = sizeof(aperture_sizes_table)/sizeof(aperture_sizes_table[0]);
  18 const unsigned int ISO_SIZE = sizeof(iso_table)/sizeof(iso_table[0]);
  19 const unsigned int MODESCNT = sizeof(modemap)/sizeof(modemap[0]);
  20 
  21 #ifndef CAM_FILE_COUNTER_IS_VAR
  22 const unsigned int param_file_counter = PARAM_FILE_COUNTER;
  23 #endif
  24 
  25 //-------------------------------------------------------------------
  26 
  27 // Note: shooting functions moved to core/shooting.c
  28 //       this compiles them as THUMB code to save space
  29 
  30 //-------------------------------------------------------------------
  31 
  32 //***********************
  33 /*
  34 
  35 static char debug_str[60];
  36 
  37 void debug_char(char * deb_str)
  38 {
  39  short debug_str_length=strlen(debug_str);
  40  if     (debug_str_length>50) strcpy(debug_str, "");
  41  sprintf(debug_str+debug_str_length, "%s", deb_str);
  42 }
  43 
  44 void debug_init()
  45 {
  46  strcpy(debug_str, "");
  47 }
  48 
  49 
  50 void debug_int(int deb_str)
  51 {
  52  short debug_str_length=strlen(debug_str);
  53  if     (debug_str_length>50) strcpy(debug_str, "");
  54  sprintf(debug_str+debug_str_length, "%d", deb_str);
  55 }
  56 
  57 
  58 void debug(char * deb_str, int deb_int)
  59 {
  60  short debug_str_length=strlen(debug_str);
  61  if     (debug_str_length>50) strcpy(debug_str, "");
  62  sprintf(debug_str+debug_str_length, "%s", deb_str);
  63  sprintf(debug_str+strlen(debug_str), "%d", deb_int);
  64 }
  65 
  66 char * get_debug()
  67 {
  68  return debug_str;
  69 }
  70 */
  71 //***********************
  72 
  73 // Core override function
  74 void __attribute__((naked,noinline)) shooting_expo_param_override(void)
  75 {
  76     // Save registers
  77     asm volatile("STMFD   SP!, {R0-R12,LR}\n");
  78 
  79     // Call thumb code version in core/shooting.c
  80     extern void shooting_expo_param_override_thumb();
  81     shooting_expo_param_override_thumb();
  82 
  83     // Restore registers
  84     asm volatile("LDMFD   SP!, {R0-R12,PC}\n");
  85 }
  86 
  87 // Override ISO settings only
  88 // need to do this before exposure calc for ISO, as well as after on some cameras
  89 void __attribute__((naked,noinline)) shooting_expo_iso_override(void)
  90 {
  91     // Save registers
  92     asm volatile("STMFD   SP!, {R0-R12,LR}\n");
  93 
  94     // Call thumb code version in core/shooting.c
  95     extern void shooting_expo_iso_override_thumb(void);
  96     shooting_expo_iso_override_thumb();
  97 
  98     // Restore registers
  99     asm volatile("LDMFD   SP!, {R0-R12,PC}\n");
 100 }
 101 
 102 // this can be used to create event procedure "hooks" at certain points in the camera firmware
 103 // as described in http://chdk.setepontos.com/index.php/topic,5690.0.html
 104 // not currently used
 105 #if 0
 106 //extern unsigned _ExecuteEventProcedure(const char *name,...);
 107 extern int overridden_PT_CompleteFileWrite();
 108 
 109 // ExecuteEventProducedure isn't safe to call from thumb on all cams
 110 // since there's not much else here, not worth running through call_func_ptr
 111 int register_pt_hooks() {
 112     // older cams only have SystemEventInit
 113     // TODO these probably don't support PT_CompleteFileWrite anyway
 114     if(_ExecuteEventProcedure("SystemEventInit") == -1) {
 115         if(_ExecuteEventProcedure("System.Create") == -1) {
 116             return 1;
 117         }
 118     }
 119     if(_ExecuteEventProcedure("RegisterProductTestEvent") == -1) {
 120         if(_ExecuteEventProcedure("SS.Create") == -1) {
 121             return 2;
 122         }
 123     }
 124     // check if PT_CompleteFileWrite eventproc was registered by above
 125     // if not registered, firmware returns -1
 126     // default PT_ComleteFileWrite normally returns 0, 
 127     // arg will handle if it just does a BX LR
 128     if(_ExecuteEventProcedure("PT_CompleteFileWrite",0) == -1) {
 129         return 4;
 130     }
 131     // note override must be in ARM code
 132     if(_ExecuteEventProcedure("ExportToEventProcedure","PT_CompleteFileWrite",overridden_PT_CompleteFileWrite) == -1) {
 133         return 3;
 134     }
 135     //_LogCameraEvent(0x120,"pt hook(s) registered");
 136     return 0;
 137 }
 138 #endif

/* [<][>][^][v][top][bottom][index][help] */