root/platform/ixus255_elph330hs/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. vid_bitmap_refresh
  2. shutdown
  3. debug_led
  4. camera_set_led
  5. camera_jpeg_count_str
  6. get_flash_params_count
  7. vid_get_bitmap_fb
  8. vid_get_viewport_fb
  9. vid_get_viewport_fb_d
  10. vid_get_viewport_live_fb
  11. hook_raw_image_addr
  12. hook_alt_raw_image_addr
  13. vid_get_viewport_yscale
  14. vid_get_viewport_width
  15. vid_get_viewport_height
  16. vid_get_viewport_xoffset
  17. vid_get_viewport_display_xoffset
  18. vid_get_viewport_yoffset
  19. vid_get_viewport_display_yoffset
  20. vid_get_viewport_display_yoffset_proper
  21. vid_get_viewport_height_proper
  22. vid_get_viewport_fullscreen_height
  23. vid_get_palette_type
  24. vid_get_palette_size
  25. vid_get_bitmap_active_buffer
  26. vid_get_bitmap_active_palette
  27. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 void vid_bitmap_refresh()
   6 {
   7     extern int full_screen_refresh;
   8     extern void _ScreenLock();
   9     extern void _ScreenUnlock();
  10 
  11     full_screen_refresh |= 3;
  12     _ScreenLock();
  13     _ScreenUnlock();
  14 }
  15 
  16 // TODO not really complete, last call from task_Bye
  17 void shutdown()
  18 {
  19     extern void _finish_shutdown(void);
  20     _finish_shutdown();
  21     while(1);
  22 }
  23 
  24 
  25 #define LED_PR 0xc022c020 // Green (only non-AF)
  26 
  27 void debug_led(int state)
  28 {
  29     volatile long *p=(void*)LED_PR;
  30     if (state)
  31         p[0]=0x93d800;
  32     else
  33         p[0]=0x83dc00;
  34 }
  35 
  36 void camera_set_led(int led, int state, int bright) {
  37  static char led_table[]={0,12}; // status, AF
  38  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  39 }
  40 
  41 char *camera_jpeg_count_str()    { return (char*)0x00181248; }             // Found @0xff2b4948
  42 
  43 int get_flash_params_count(void) { return 0x91; }                          // Found @0xff244ba4
  44 
  45 
  46 void *vid_get_bitmap_fb()        { return (void*)0x406c5000; }             // Found @0xff08dfd0
  47 void *vid_get_viewport_fb()      { return (void*)0x4081ab80; }             // Found @0xff49c3ac
  48 void *vid_get_viewport_fb_d()
  49 {
  50     extern char *viewport_fb_d;
  51     return viewport_fb_d;
  52 }
  53 
  54 void *vid_get_viewport_live_fb()
  55 {
  56     extern char active_viewport_buffer;
  57     extern void* viewport_buffers[];
  58 
  59     // no distinct video mode
  60     if (/*mode_is_video(mode_get())*/ get_movie_status() == VIDEO_RECORD_IN_PROGRESS)
  61         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  62     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  63     // verified -1 gives best response
  64     return viewport_buffers[(active_viewport_buffer-1)&3];
  65 }
  66 
  67 
  68 char *hook_raw_image_addr()
  69 {
  70     if (*((int*)(0x3a74)) != 0)     // 0x3a68 (@0xff0ba60c) + 0xc (@0xff0ba638)
  71         return (char*)0x4adb23c0;   // Found @0xff5e3444
  72     else
  73         return (char*)0x44000000;
  74 }
  75 
  76 char *hook_alt_raw_image_addr()
  77 {
  78     if (*((int*)(0x3a74)) == 0)
  79         return (char*)0x4adb23c0;
  80     else
  81         return (char*)0x44000000;
  82 }
  83 
  84 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  85 int vid_get_viewport_yscale() {
  86         return 2;
  87 }
  88 
  89 int vid_get_viewport_width()
  90 {
  91     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  92     {
  93         return 360;
  94     }
  95     extern int _GetVRAMHPixelsSize();
  96     return _GetVRAMHPixelsSize() >> 1;
  97 }
  98 
  99 long vid_get_viewport_height()
 100 {
 101     if ((mode_get() & MODE_MASK) == MODE_PLAY)
 102     {
 103         return 240;
 104     }
 105     extern int _GetVRAMVPixelsSize();
 106     return _GetVRAMVPixelsSize() >> 1;
 107 }
 108 
 109 // viewport width offset table for each image size
 110 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 111 static long vp_xo[5] = { 0, 0, 0, 44 };                         // should all be even values for edge overlay
 112 
 113 // elph130 appears to use display offsets exclusively in X
 114 int vid_get_viewport_xoffset()
 115 {
 116     return 0;
 117 }
 118 
 119 int vid_get_viewport_display_xoffset()
 120 {
 121     int m = mode_get();
 122     if ((m & MODE_MASK) == MODE_PLAY)
 123     {
 124         return 0;
 125     }
 126     else if ((m & MODE_SHOOTING_MASK) == MODE_STITCH)
 127     {
 128         if (shooting_get_prop(PROPCASE_STITCH_DIRECTION) == 0)      // Direction check
 129             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 130                 return 40;
 131             else
 132                 return 140;
 133         else
 134             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 135                 return 140;
 136             else
 137                 return 40;
 138     }
 139     else
 140     {
 141             return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 142     }
 143 }
 144 
 145 // viewport height offset table for each image size
 146 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 147 static long vp_yo[5] = { 0, 30, 13, 0 };
 148 
 149 int vid_get_viewport_yoffset()
 150 {
 151     int m = mode_get();
 152     if ((m & MODE_MASK) == MODE_PLAY)
 153     {
 154         return 0;
 155     }
 156     else if ((m & MODE_SHOOTING_MASK) == MODE_STITCH)
 157     {
 158         return 0;
 159     }
 160     // no distinct video mode
 161     else if (/*mode_is_video(m)*/ get_movie_status() == VIDEO_RECORD_IN_PROGRESS)
 162     {
 163         return 30;
 164     }
 165     else
 166     {
 167             return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 168     }
 169 }
 170 
 171 int vid_get_viewport_display_yoffset()
 172 {
 173     int m = mode_get();
 174     if ((m & MODE_MASK) == MODE_PLAY)
 175     {
 176         return 0;
 177     }
 178     else if ((m & MODE_SHOOTING_MASK) == MODE_STITCH)
 179     {
 180         return 72;
 181     }
 182     else if (/*mode_is_video(m)*/ get_movie_status() == VIDEO_RECORD_IN_PROGRESS)
 183     {
 184         return 30;
 185     }
 186     else
 187     {
 188             return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 189     }
 190 }
 191 
 192 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() * 2; }
 193 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * 2; }
 194 int vid_get_viewport_fullscreen_height()        { return 480; }
 195 
 196 int vid_get_palette_type()                      { return 3; }
 197 int vid_get_palette_size()                      { return 256 * 4; }
 198 
 199 // Defined in stubs_min.S
 200 extern int active_bitmap_buffer;
 201 extern char* bitmap_buffer[];
 202 void *vid_get_bitmap_active_buffer()
 203 {
 204     return bitmap_buffer[active_bitmap_buffer];
 205 }
 206 
 207 void *vid_get_bitmap_active_palette()
 208 {
 209     extern int active_palette_buffer;
 210     extern int** palette_buffer_ptr;
 211     int *p = palette_buffer_ptr[active_palette_buffer];
 212     // active_palette_buffer can point at null when
 213     // func and menu are opened for the first time
 214     if(!p) {
 215         p = palette_buffer_ptr[0]; // rec mode buffer appears to always be initialized
 216     }
 217     return (p+1);
 218 }
 219 
 220 // TODO void load_chdk_palette(), palette_control not found
 221 // Function to load CHDK custom colors into active Canon palette
 222 void load_chdk_palette()
 223 {
 224     extern int active_palette_buffer;
 225     // Only load for the standard record and playback palettes
 226     // 0 = rec, 4 = func menu, 5 = playback, 6 = menu (play or rec), 
 227     if ((active_palette_buffer == 0) || (active_palette_buffer == 5) || (active_palette_buffer == 4))
 228     {
 229         int *pal = (int*)vid_get_bitmap_active_palette();
 230         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 231         {
 232             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 233             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 234             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 235             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 236             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 237             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 238             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 239             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 240             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 241             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 242             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 243             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 244             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 245 
 246             extern char palette_control;
 247             palette_control = 1; // note appears to be a bitmask, bit 2 is also used
 248             vid_bitmap_refresh();
 249         }
 250     }
 251 }

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