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

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