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

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