root/platform/sx30/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. hook_raw_image_addr
  2. hook_alt_raw_image_addr
  3. camera_jpeg_count_str
  4. vid_bitmap_refresh
  5. shutdown
  6. debug_led
  7. camera_set_led
  8. get_flash_params_count
  9. JogDial_CW
  10. JogDial_CCW
  11. vid_get_viewport_fb
  12. vid_get_viewport_live_fb
  13. vid_get_viewport_fb_d
  14. vid_get_bitmap_fb
  15. vid_get_viewport_width
  16. vid_get_viewport_display_xoffset
  17. vid_get_viewport_height
  18. vp_yoffset
  19. vid_get_viewport_yoffset
  20. vid_get_viewport_display_yoffset
  21. vid_get_viewport_display_xoffset_proper
  22. vid_get_viewport_height_proper
  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 
   6 extern  int     active_raw_buffer;
   7 extern  char*   raw_buffers[];
   8 
   9 char *hook_raw_image_addr()
  10 {
  11     return raw_buffers[active_raw_buffer*3];
  12 }
  13 
  14 char *hook_alt_raw_image_addr()
  15 {
  16     return raw_buffers[(active_raw_buffer^1)*3];
  17 }
  18 
  19 
  20 char *camera_jpeg_count_str()
  21 {
  22     extern char jpeg_count_str[];
  23         return jpeg_count_str;
  24 }
  25 
  26 
  27 void vid_bitmap_refresh()
  28 {
  29         extern int full_screen_refresh;
  30         extern void _ScreenUnlock();
  31         extern void _ScreenLock();
  32 
  33         full_screen_refresh |= 3;
  34         _ScreenLock();
  35         _ScreenUnlock();
  36 }
  37 
  38 
  39 void shutdown()
  40 {
  41         volatile long *p = (void*)0xC022001C;    
  42         
  43         asm(
  44                 "MRS     R1, CPSR\n"
  45                 "AND     R0, R1, #0x80\n"
  46                 "ORR     R1, R1, #0x80\n"
  47                 "MSR     CPSR_cf, R1\n"
  48                 :::"r1","r0");
  49         
  50         *p = 0x44;  // power off.
  51         
  52         while(1);
  53 }
  54 
  55 #define LED_PR 0xC0220134       // Power LED
  56 
  57 // TODO = this uses power LED, need to disable later (so power LED doesn't flicker)
  58 void debug_led(int state)
  59 {
  60  //*(int*)LED_PR=state ? 0x46 : 0x44;
  61 }
  62 
  63 // SX30 has two 'lights' - Power LED, and AF assist lamp
  64 // Power Led = first entry in table (led 0)
  65 // AF Assist Lamp = second entry in table (led 1)
  66 void camera_set_led(int led, int state, int bright) {
  67  static char led_table[2]={3,9};
  68  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  69 }
  70 
  71 int get_flash_params_count(void){
  72  return 0x9a;   // found in GetParameterData ??? 
  73 }
  74 
  75 void JogDial_CW(void){
  76  _PostLogicalEventForNotPowerType(0x86E, 1);  // RotateJogDialRight (in table @ FFC0E88C, fw 1.00h)
  77 }
  78 
  79 void JogDial_CCW(void){
  80  _PostLogicalEventForNotPowerType(0x86F, 1);  // RotateJogDialLeft (in table @ FFC0E88C, fw 1.00h)
  81 }
  82 
  83 // Viewport and Bitmap values that shouldn't change across firmware versions.
  84 // Values that may change are in lib.c for each firmware version.
  85 
  86 // Defined in stubs_min.S
  87 extern char active_viewport_buffer;
  88 extern void* viewport_buffers[];
  89 
  90 void *vid_get_viewport_fb()
  91 {
  92     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  93     return viewport_buffers[0];
  94 }
  95 
  96 void *vid_get_viewport_live_fb()
  97 {
  98     if (camera_info.state.mode_video || (get_movie_status()==VIDEO_RECORD_IN_PROGRESS))
  99         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
 100 
 101     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 102     return viewport_buffers[(active_viewport_buffer-1)&3];
 103 }
 104 
 105 void *vid_get_viewport_fb_d()
 106 {
 107     extern char *viewport_fb_d;
 108         return viewport_fb_d;
 109 }
 110 
 111 // Defined in stubs_min.S
 112 extern int active_bitmap_buffer;
 113 extern char* bitmap_buffer[];
 114 
 115 void *vid_get_bitmap_fb()
 116 {
 117     // Return first bitmap buffer address
 118     return bitmap_buffer[0];
 119 }
 120 
 121 int vid_get_viewport_width()
 122 {
 123     if (camera_info.state.mode_play)
 124     {
 125         return 360;
 126     }
 127     extern int _GetVRAMHPixelsSize();
 128     return _GetVRAMHPixelsSize() >> 1;
 129 }
 130 
 131 int vid_get_viewport_display_xoffset()
 132 {
 133     if (camera_info.state.mode_play)
 134     {
 135         return 0;
 136     }
 137     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16908) // Stitch mode
 138     {
 139         if (shooting_get_prop(PROPCASE_STITCH_DIRECTION) == 0)      // Direction check
 140             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 141                 return 40;
 142             else
 143                 return 140;
 144         else
 145             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 146                 return 140;
 147             else
 148                 return 40;
 149     }
 150     else
 151     {
 152         return 0;
 153     }
 154 }
 155 
 156 long vid_get_viewport_height()
 157 {
 158     if (camera_info.state.mode_play)
 159     {
 160         return 240;
 161     }
 162     extern int _GetVRAMVPixelsSize();
 163     return _GetVRAMVPixelsSize();
 164 }
 165 
 166 static int vp_yoffset(int stitch)
 167 {
 168     if (camera_info.state.mode_play)
 169     {
 170         return 0;
 171     }
 172     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16908) // Stitch mode
 173     {
 174         return stitch;
 175     }
 176     else if (camera_info.state.mode_video)
 177     {
 178         return 30;
 179     }
 180     else if (shooting_get_prop(PROPCASE_ASPECT_RATIO) == 1)     // Wide screen top & bottom 30 pixels not used in viewport
 181                 return 30;
 182         return 0;
 183 }
 184 
 185 int vid_get_viewport_yoffset()
 186 {
 187     return vp_yoffset(0);
 188 }
 189 
 190 int vid_get_viewport_display_yoffset()
 191 {
 192     return vp_yoffset(72);
 193 }
 194 
 195 // Functions for PTP Live View system
 196 
 197 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() * 2; }
 198 int vid_get_viewport_height_proper()            { return vid_get_viewport_height(); }
 199 int vid_get_palette_type()                      { return 3; }
 200 int vid_get_palette_size()                      { return 256 * 4; }
 201 
 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 char* palette_buffer[];
 211     return (palette_buffer[active_palette_buffer]+8);
 212 }
 213 
 214 // Function to load CHDK custom colors into active Canon palette
 215 void load_chdk_palette()
 216 {
 217     extern int active_palette_buffer;
 218     // Only load for the standard record and playback palettes
 219     if ((active_palette_buffer == 0) || (active_palette_buffer == 4) || (active_palette_buffer == 6))
 220     {
 221         int *pal = (int*)vid_get_bitmap_active_palette();
 222         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 223         {
 224             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 225             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 226             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 227             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 228             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 229             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 230             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 231             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 232             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 233             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 234             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 235             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 236             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 237             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 238 
 239             extern char palette_control;
 240             palette_control = 1;
 241             vid_bitmap_refresh();
 242         }
 243     }
 244 }

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