root/platform/s80/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. core_hook_task_create
  2. core_hook_task_delete
  3. spytask
  4. task_start_hook
  5. remount_filesystem
  6. init_file_modules_hook
  7. capt_seq_hook
  8. physw_hook
  9. movie_record_hook
  10. task_JogDial_hook
  11. my_ncmp
  12. createHook
  13. deleteHook
  14. startup
  15. get_vbatt_min
  16. get_vbatt_max
  17. get_effective_focal_length
  18. get_focal_length
  19. get_zoom_x

   1 #include "camera.h"
   2 #include "lolevel.h"
   3 #include "platform.h"
   4 #include "core.h"
   5 #include "keyboard.h"
   6 
   7 /* Ours stuff */
   8 extern long link_bss_start;
   9 extern long link_bss_end;
  10 extern void boot();
  11 
  12 static void core_hook_task_create(__attribute__ ((unused))void *tcb)
  13 {
  14 }
  15 
  16 static void core_hook_task_delete(void *tcb)
  17 {
  18     char *name = (char*)(*(long*)((char*)tcb+0x34));
  19     if (strcmp(name,"tInitFileM")==0) core_spytask_can_start();
  20 }
  21 
  22 
  23 static int stop_hooking;
  24 
  25 static void (*task_prev)(
  26     long p0,    long p1,    long p2,    long p3,    long p4,
  27     long p5,    long p6,    long p7,    long p8,    long p9);
  28 
  29 static void (*init_file_modules_prev)(
  30     long p0,    long p1,    long p2,    long p3,    long p4,
  31     long p5,    long p6,    long p7,    long p8,    long p9);
  32 
  33 
  34 
  35 void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
  36 {
  37     (void)ua; (void)ub; (void)uc; (void)ud; (void)ue; (void)uf;
  38     core_spytask();
  39 }
  40 
  41 
  42 static void task_start_hook(
  43     long p0,    long p1,    long p2,    long p3,    long p4,
  44     long p5,    long p6,    long p7,    long p8,    long p9)
  45 {
  46     _CreateTask("SpyTask", 0x19, 0x2000, spytask, 0);
  47 
  48     task_prev(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 );
  49 }
  50 
  51 
  52 static void remount_filesystem()
  53 {
  54     _Unmount_FileSystem();
  55     _Mount_FileSystem();
  56 }
  57 
  58 
  59 static void init_file_modules_hook(
  60     long p0,    long p1,    long p2,    long p3,    long p4,
  61     long p5,    long p6,    long p7,    long p8,    long p9)
  62 {
  63     remount_filesystem();
  64     init_file_modules_prev(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9 );
  65 }
  66 
  67 
  68 static void capt_seq_hook(
  69     long p0,    long p1,    long p2,    long p3,    long p4,
  70     long p5,    long p6,    long p7,    long p8,    long p9)
  71 {
  72     (void)p0; (void)p1; (void)p2; (void)p3; (void)p4; (void)p5; (void)p6; (void)p7; (void)p8; (void)p9;
  73     capt_seq_task();
  74 }
  75 
  76 
  77 static void physw_hook(
  78     long p0,    long p1,    long p2,    long p3,    long p4,
  79     long p5,    long p6,    long p7,    long p8,    long p9)
  80 {
  81     (void)p0; (void)p1; (void)p2; (void)p3; (void)p4; (void)p5; (void)p6; (void)p7; (void)p8; (void)p9;
  82     mykbd_task();
  83 }
  84 
  85 static void movie_record_hook(
  86     long p0,    long p1,    long p2,    long p3,    long p4,
  87     long p5,    long p6,    long p7,    long p8,    long p9)
  88 {
  89     (void)p0; (void)p1; (void)p2; (void)p3; (void)p4; (void)p5; (void)p6; (void)p7; (void)p8; (void)p9;
  90     movie_record_task();
  91 }
  92 
  93 extern void task_JogDial_my();
  94 
  95 static void task_JogDial_hook(
  96     long p0,    long p1,    long p2,    long p3,    long p4,
  97     long p5,    long p6,    long p7,    long p8,    long p9)
  98 {
  99     (void)p0; (void)p1; (void)p2; (void)p3; (void)p4; (void)p5; (void)p6; (void)p7; (void)p8; (void)p9;
 100     task_JogDial_my();
 101 }
 102 
 103 static int my_ncmp(const char *s1, const char *s2, long len)
 104 {
 105     int i;
 106     for (i=0;i<len;i++){
 107         if (s1[i] != s2[i])
 108             return 1;
 109     }
 110     return 0;
 111 }
 112 
 113 void createHook (void *pNewTcb)
 114 {
 115     char *name = (char*)(*(long*)((char*)pNewTcb+0x34));
 116     long *entry = (long*)((char*)pNewTcb+0x74);
 117 
 118     // always hook first task creation
 119     // to create SpyProc
 120     if (!stop_hooking){
 121         task_prev = (void*)(*entry);
 122         *entry = (long)task_start_hook;
 123         stop_hooking = 1;
 124     } else {
 125         // hook/replace another tasks
 126         if (my_ncmp(name, "tPhySw", 6) == 0){
 127             *entry = (long)physw_hook;
 128         }
 129         
 130         if (my_ncmp(name, "tInitFileM", 10) == 0){
 131             init_file_modules_prev = (void*)(*entry);
 132         #if CAM_MULTIPART
 133             *entry = (long)init_file_modules_task;
 134         #else
 135             *entry = (long)init_file_modules_hook;
 136         #endif
 137         }
 138         
 139         if (my_ncmp(name, "tCaptSeqTa", 10) == 0){
 140             *entry = (long)capt_seq_hook;
 141         }
 142         
 143         if (my_ncmp(name, "tJogDial", 8) == 0){
 144             *entry = (long)task_JogDial_hook;
 145         }
 146         
 147         if (my_ncmp(name, "tMovieReco", 10) == 0){
 148         #if CAM_CHDK_HAS_EXT_VIDEO_MENU
 149             *entry = (long)movie_record_hook;
 150         #endif
 151         }
 152         
 153         #if CAM_EXT_TV_RANGE
 154         if (my_ncmp(name, "tExpDrvTas", 10) == 0){
 155             *entry = (long)exp_drv_task;
 156         }
 157         #endif
 158         
 159         core_hook_task_create(pNewTcb);
 160     }
 161 }
 162 
 163 void deleteHook (void *pTcb)
 164 {
 165     core_hook_task_delete(pTcb);
 166 }
 167 
 168 void startup()
 169 {
 170     long *bss = &link_bss_start;
 171 
 172     // sanity check
 173     if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
 174         started();
 175         shutdown();
 176     }
 177 
 178     // initialize .bss senment
 179     while (bss<&link_bss_end)
 180         *bss++ = 0;
 181 
 182     boot();
 183 }
 184 
 185 /*********************************************************************/
 186 
 187 long get_vbatt_min()
 188 {
 189     return 6700;
 190 }
 191 
 192 long get_vbatt_max()
 193 {
 194     return 8100;
 195 }
 196 
 197 // Focus length table in firmware @0xfffe41f4
 198 #define NUM_FL      9   // 0 - 8, entries in firmware
 199 #define NUM_DATA    3   // 3 words each entry, first is FL
 200 extern int focus_len_table[NUM_FL*NUM_DATA];
 201 
 202 // Conversion factor lens FL --> 35mm equiv
 203 // lens      35mm     CF
 204 // ----      ----     --
 205 // 5.8       28       ( 28/ 5.8) * 580 = 2800  (min FL)
 206 // 20.7      100      (100/20.7) * 580 = 2800  (max FL)
 207 #define CF_EFL      2800
 208 #define CF_EFL_DIV  580
 209 
 210 const int zoom_points = NUM_FL;
 211 
 212 int get_effective_focal_length(int zp) {
 213     return (CF_EFL*get_focal_length(zp))/CF_EFL_DIV;
 214 }
 215 
 216 int get_focal_length(int zp) {
 217     if (zp < 0) zp = 0;
 218     else if (zp >= NUM_FL) zp = NUM_FL-1;
 219     return focus_len_table[zp*NUM_DATA];
 220 }
 221 
 222 int get_zoom_x(int zp) {
 223     return get_focal_length(zp)*10/focus_len_table[0];
 224 }
 225 
 226 /*
 227 playrec_mode:
 228 3 when switched into play mode while in record mode
 229 2 record mode
 230 4 in recmode menu
 231 5 when recmode overlay animation is activated by the jogdial
 232 0 when switched on in play mode
 233 */

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