root/platform/ixus95_sd1200/main.c

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

DEFINITIONS

This source file includes following definitions.
  1. startup
  2. get_effective_focal_length
  3. get_focal_length
  4. get_zoom_x
  5. get_vbatt_min
  6. get_vbatt_max
  7. hook_tyWriteOrig
  8. cam_console_init

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "core.h"
   4 #include "keyboard.h"
   5 
   6 #include "sd1200_debug.h"
   7 
   8 extern long link_bss_start;
   9 extern long link_bss_end;
  10 extern void boot();
  11 
  12 
  13 void startup()
  14 {
  15     long *bss = &link_bss_start;
  16 
  17     // sanity check (pointless with automemiso)
  18     if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
  19         started();
  20         shutdown();
  21     }
  22 
  23     // initialize .bss senment
  24     while (bss<&link_bss_end)
  25         *bss++ = 0;
  26     boot();
  27 }
  28 
  29 
  30 //// TODO setting the DP button as a shortcut to movie in canon menu
  31 //// gives a value of (current mode)+1024 while movie is recording, unless
  32 //// already in movie mode
  33 //static struct {
  34 //      int hackmode;
  35 //      int canonmode;
  36 //} modemap[] = {
  37 //    { MODE_AUTO,               32768 },
  38 //    { MODE_M,                  32769 },
  39 //    { MODE_P,                  32772 },
  40 //    { MODE_PORTRAIT,           0x800D },
  41 //    { MODE_NIGHT_SNAPSHOT,     0x800B },
  42 //    { MODE_KIDS_PETS,          0x8010 },
  43 //    { MODE_INDOOR,             0x8011 },
  44 //    { MODE_SUNSET,             0x4012 },
  45 //    { MODE_FOLIAGE,            0x4013 },
  46 //    { MODE_SNOW,               0x4014 },
  47 //    { MODE_BEACH,              0x4015 },
  48 //    { MODE_FIREWORK,           0x4016 },
  49 //    { MODE_NIGHT_SCENE,        0x4006 }, //AKA Long Shutter
  50 //    { MODE_UNDERWATER,         0x4017 },
  51 //    { MODE_AQUARIUM,           0x4018 },
  52 //    { MODE_ISO_3200,           0x401D },
  53 //    { MODE_DIGITAL_MACRO,      0x4208 },
  54 //    { MODE_COLOR_ACCENT,       0x421B },
  55 //    { MODE_COLOR_SWAP,         0x421C },
  56 //    { MODE_STITCH,             0x420A },
  57 //  //{ MODE_QUICK,              33312 },
  58 //
  59 //    { MODE_VIDEO_STD,          0xA29  },
  60 //    { MODE_VIDEO_COLOR_ACCENT, 0xA27  },
  61 //    { MODE_VIDEO_COLOR_SWAP,   0xA28  },
  62 //};
  63 //
  64 //#define MODESCNT (sizeof(modemap)/sizeof(modemap[0]))
  65 
  66 
  67 // Focus length table in firmware @0xfffe2a8c
  68 #define NUM_FL      7   // 0 - 6, entries in firmware
  69 #define NUM_DATA    3   // 3 words each entry, first is FL
  70 extern int focus_len_table[NUM_FL*NUM_DATA];
  71 
  72 // Conversion factor lens FL --> 35mm equiv
  73 // lens      35mm     CF
  74 // ----      ----     --
  75 // 6.2       35       ( 35/ 6.2) * 62 = 350  (min FL)
  76 // 18.6      105      (105/18.6) * 62 = 350  (max FL)
  77 #define CF_EFL      350
  78 #define CF_EFL_DIV  62
  79 
  80 const int zoom_points = NUM_FL;
  81 
  82 int get_effective_focal_length(int zp) {
  83     return (CF_EFL*get_focal_length(zp))/CF_EFL_DIV;
  84 }
  85 
  86 int get_focal_length(int zp) {
  87     if (zp < 0) zp = 0;
  88     else if (zp >= NUM_FL) zp = NUM_FL-1;
  89     return focus_len_table[zp*NUM_DATA];
  90 }
  91 
  92 int get_zoom_x(int zp) {
  93     return get_focal_length(zp)*10/focus_len_table[0];
  94 }
  95 
  96 ///*
  97 //physw_ bit OK
  98 //*/
  99 //int mode_get2() {
 100 //    int mode, i, t=0xFF;
 101 //    mode  = (physw_status[1] & 0x00000001)?MODE_REC:MODE_PLAY;
 102 //
 103 //    _GetPropertyCase(PROPCASE_SHOOTING_MODE, &t, 4);
 104 //    for (i=0; i<MODESCNT; ++i) {
 105 //      if (modemap[i].canonmode == t) {
 106 //          return (mode | (modemap[i].hackmode & MODE_SHOOTING_MASK));
 107 //      }
 108 //    }
 109 //    return (mode);
 110 //}
 111 
 112 long get_vbatt_min()
 113 {
 114     return 3425; // hnikesch on forum
 115 }
 116 
 117 long get_vbatt_max()
 118 {
 119     return 4000; // fresh off charger slightly greater
 120 }
 121 
 122 #if CAM_CONSOLE_LOG_ENABLED
 123 
 124 #define DEV_HDR_WRITE_OFFSET (0x14C/4)
 125 
 126 typedef int DEV_HDR;
 127 
 128 int (*_tyWriteOrig)(DEV_HDR *hdr, char *buf, int len);
 129 
 130 
 131 int hook_tyWriteOrig(DEV_HDR *hdr, char *buf, int len)
 132 {
 133         // Slow, but stable writes
 134         FILE *fd = fopen("A/stdout.txt", "a");
 135         if (fd) {
 136             fwrite(buf, 1, len, fd);
 137             fclose(fd);
 138         }
 139 
 140     return _tyWriteOrig(hdr, buf, len);
 141 
 142 }
 143 
 144 void cam_console_init()
 145 {
 146     DEV_HDR *DRV_struct;
 147 
 148     DRV_struct = _iosDevFind("/tyCo/0", 0);
 149 
 150     _tyWriteOrig = (void*)DRV_struct[DEV_HDR_WRITE_OFFSET];
 151 
 152         FILE *fd = fopen("A/chdklog.txt", "a");
 153         if (fd) {
 154             // can't be used with "Fut" API
 155             //fprintf(fd, "DRV_struct: %x, _tyWriteOrig: %x\n", DRV_struct, _tyWriteOrig);
 156             char buf[256];
 157             int buflen = sprintf(buf, "DRV_struct: %x, _tyWriteOrig: %x\n", DRV_struct, _tyWriteOrig);
 158             fwrite(buf, 1, buflen, fd);
 159         }
 160 
 161         FILE *fdout = fopen("A/stdout.txt", "r");
 162         if (fdout)
 163         {
 164         DRV_struct[DEV_HDR_WRITE_OFFSET] = (int)hook_tyWriteOrig;
 165         fclose(fdout);
 166             // fprintf(fd, "tyWrite replaced, camera log enabled\n");
 167             fwrite("tyWrite replaced, camera log enabled\n", 1, sizeof("tyWrite replaced, camera log enabled\n"), fd);
 168     }
 169 
 170         if (fd)
 171         {
 172             fclose(fd);
 173         }
 174 
 175 }
 176 
 177 #endif

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