root/platform/sx400is/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. hook_raw_image_addr
  2. camera_jpeg_count_str
  3. vid_bitmap_refresh
  4. shutdown
  5. vid_get_bitmap_fb
  6. get_flash_params_count
  7. debug_led
  8. camera_set_led
  9. vid_get_viewport_fb
  10. vid_get_viewport_fb_d
  11. vid_get_viewport_live_fb
  12. vid_get_viewport_width
  13. vid_get_viewport_height
  14. vid_get_viewport_display_xoffset
  15. vid_get_palette_type
  16. vid_get_palette_size
  17. vid_get_bitmap_active_buffer
  18. vid_get_bitmap_active_palette
  19. load_chdk_palette
  20. _MakeAFScan
  21. state_check_for_movie_af

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 char *hook_raw_image_addr()
   6 {
   7     return (char*)0x42fb5130; //Found @0xff8758cc and 0xffa655d8 (Search for A/%08x.CRW)
   8 }
   9 
  10 char *camera_jpeg_count_str()
  11 {
  12     extern char jpeg_count_str[];
  13     return jpeg_count_str;
  14 }
  15 
  16 void vid_bitmap_refresh()
  17 {
  18     extern int full_screen_refresh;
  19     extern void _ScreenLock();
  20     extern void _ScreenUnlock();
  21 
  22     full_screen_refresh |= 3;
  23     _ScreenLock();
  24     _ScreenUnlock();
  25 }
  26 
  27 #define LED_PR 0xC022302C
  28 #define AF_LED 0xC0223030
  29 void shutdown()
  30 {
  31     extern void _TurnOffE1(void);
  32     _TurnOffE1();
  33     while(1);
  34 }
  35 
  36 void *vid_get_bitmap_fb()        { return (void*)0x40711000; }             // Found @0xff865754
  37 int get_flash_params_count(void) { return 0xd4; }                          // Found @0xff9c7eb4
  38 
  39 void debug_led(int state)
  40 {
  41     volatile long *p=(void*)LED_PR;
  42     if (state)
  43         p[0]=0x46;
  44     else
  45         p[0]=0x44;
  46 }
  47 
  48 // SX400IS has two 'lights' - Power LED, and AF assist lamp
  49 // Power Led = first entry in table (led 0)
  50 // AF Assist Lamp = second entry in table (led 1)
  51 // State
  52 // 0 = LED Off
  53 // 1 = LED On
  54 // 2 = LED blinks slowly
  55 // 3 = LED blinks fast
  56 // 5 = LED blinks fast (3 times)
  57 void camera_set_led(int led, int state, int bright) {
  58     static char led_table[]={0,4}; // status, AF
  59     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  60 }
  61 
  62 void *vid_get_viewport_fb()      { return (void*)0x40866b80; }             // Found @0xffba1ce8
  63 void *vid_get_viewport_fb_d()
  64 {
  65     extern char *viewport_fb_d;
  66     return viewport_fb_d;
  67 }
  68 
  69 extern char active_viewport_buffer;
  70 extern void* viewport_buffers[];
  71 
  72 void *vid_get_viewport_live_fb()
  73 {
  74     if (MODE_IS_VIDEO(mode_get()) || is_video_recording())
  75         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  76 
  77     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  78     // verified -1 gives best response
  79     return viewport_buffers[(active_viewport_buffer-1)&3];
  80 }
  81 
  82 int vid_get_viewport_width()
  83 {
  84     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  85     {
  86         return 360;
  87     }
  88     extern int _GetVRAMHPixelsSize();
  89     return _GetVRAMHPixelsSize() >> 1;
  90 }
  91 
  92 
  93 long vid_get_viewport_height()
  94 {
  95 
  96     int m = mode_get();
  97     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
  98 
  99     if (MODE_IS_VIDEO(m) || is_video_recording())
 100         return 240;
 101 
 102     if ((m & MODE_MASK) != MODE_PLAY)
 103     {
 104         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 105         if (aspect_ratio==1 || aspect_ratio==2)
 106             return 240;
 107     }
 108     extern int _GetVRAMVPixelsSize();
 109     return ((m & MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize();
 110 }
 111 
 112 // viewport width offset table for each aspect ratio
 113 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 114 static long vp_xo[4] = { 0, 0, 0, 44 };        // should all be even values for edge overlay
 115 
 116 int vid_get_viewport_display_xoffset()
 117 {
 118     int m = mode_get();
 119     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 120 
 121     if ((m & MODE_MASK) != MODE_PLAY) {
 122         return (vp_xo[aspect_ratio]);
 123     }
 124     else
 125         return 0;
 126 }
 127 
 128 //int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset()<<1; }
 129 //int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset()<<1; }
 130 //int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * 2; }
 131 //int vid_get_viewport_fullscreen_height()        { return 240; }
 132 //int vid_get_viewport_fulllscreen_width()        { return 720; }
 133 int vid_get_palette_type()                      { return 3; }
 134 int vid_get_palette_size()                      { return 256 * 4; }
 135 
 136 // Defined in stubs_min.S
 137 extern int active_bitmap_buffer;
 138 extern char* bitmap_buffer[];
 139 void *vid_get_bitmap_active_buffer()
 140 {
 141     return bitmap_buffer[active_bitmap_buffer];
 142 }
 143 
 144 void *vid_get_bitmap_active_palette()
 145 {
 146     extern int active_palette_buffer;
 147     extern int** palette_buffer_ptr;
 148     int *p = palette_buffer_ptr[active_palette_buffer];
 149     // active_palette_buffer can point at null when
 150     // func and menu are opened for the first time
 151     if(!p) {
 152         p = palette_buffer_ptr[0]; // rec mode buffer appears to always be initialized
 153     }
 154     return (p+1);
 155 }
 156 
 157 // Function to load CHDK custom colors into active Canon palette
 158 void load_chdk_palette()
 159 {
 160     extern int active_palette_buffer;
 161     // Only load for the standard record and playback palettes
 162     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 163     {
 164         int *pal = (int*)vid_get_bitmap_active_palette();
 165         if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 166         {
 167             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 168             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 169             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 170             pal[CHDK_COLOR_BASE+5]  = 0x3F73BFAE;  // Green
 171             pal[CHDK_COLOR_BASE+6]  = 0x3F4BD6CA;  // Dark Green
 172             pal[CHDK_COLOR_BASE+7]  = 0x3F95AB95;  // Light Green
 173             pal[CHDK_COLOR_BASE+8]  = 0x3F4766F0;  // Blue
 174             pal[CHDK_COLOR_BASE+9]  = 0x3F1250F3;  // Dark Blue
 175             pal[CHDK_COLOR_BASE+10]  = 0x3F7F408F;  // Cyan
 176             pal[CHDK_COLOR_BASE+11]  = 0x3F512D5B;  // Magenta
 177             pal[CHDK_COLOR_BASE+12] = 0x3FA9A917;  // Yellow
 178             pal[CHDK_COLOR_BASE+13] = 0x3F819137;  // Dark Yellow
 179             pal[CHDK_COLOR_BASE+14] = 0x3FDED115;  // Light Yellow
 180             pal[CHDK_COLOR_BASE+15] = 0x00090000;  // Transparent dark grey
 181 
 182             extern char palette_control;
 183             palette_control = 1;
 184             vid_bitmap_refresh();
 185         }
 186     }
 187 }
 188 
 189 // following routines help preventing the "invisible af lock" caused by the movie af scan hack
 190 static int af_locked_in_movierec = 0;
 191 
 192 void _MakeAFScan(int *a, int b) {
 193     _DoAFLock();
 194     af_locked_in_movierec = 1;
 195 }
 196 
 197 void state_check_for_movie_af() {
 198     if ((get_movie_status() != VIDEO_RECORD_IN_PROGRESS) && af_locked_in_movierec) {
 199         af_locked_in_movierec = 0;
 200         _UnlockAF();
 201     }
 202 }

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