root/platform/sx160is/lib.c

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

DEFINITIONS

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

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 char *hook_raw_image_addr() {
   6     return (char*) 0x420F6420; //Found @0xffb5a2f4  search for "BJPEG BUFF"
   7 }
   8 
   9 // no battery temp
  10 int _GetBatteryTemperature()     { return -99;}
  11 
  12 char *camera_jpeg_count_str()
  13 {
  14     extern char jpeg_count_str[];
  15     return jpeg_count_str;
  16 }
  17 
  18 void shutdown()
  19 {
  20     extern void __attribute__((noreturn)) _finish_shutdown(void);
  21     _finish_shutdown();
  22 }
  23 
  24 #define LED_PR 0xC0220120
  25 void debug_led(int state)
  26 {
  27     // using power LED, which defaults to on
  28     // for debugging turn LED off if state is 1 and on for state = 0
  29     *(int*)LED_PR=state ? 0x46 : 0x44;
  30 }
  31 
  32 // SX160 IS has two 'lights' - Power LED, and AF assist lamp
  33 // Power Led = first entry in table (led 0)
  34 // AF Assist Lamp = second entry in table (led 1)
  35 void camera_set_led(int led, int state, int bright) {
  36     static char led_table[2]={0,4};
  37     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  38 }
  39 
  40 int get_flash_params_count(void)
  41 {
  42     return 0xA6;
  43 }
  44 
  45 void JogDial_CW(void)
  46 {
  47     _PostLogicalEventToUI(0x872, 1);  // RotateJogDialRight (in table @ ffc1b298, fw 1.00a)
  48 }
  49 
  50 void JogDial_CCW(void)
  51 {
  52     _PostLogicalEventToUI(0x873, 1);  // RotateJogDialLeft (in table @ ffc1b2a4, fw 1.00a)
  53 }
  54 
  55 int vid_get_viewport_width()
  56 {
  57     if (camera_info.state.mode_play)
  58     {
  59         return 360;
  60     }
  61     extern int _GetVRAMHPixelsSize();
  62     return _GetVRAMHPixelsSize() >> 1;
  63 }
  64 
  65 long vid_get_viewport_height()
  66 {
  67     if (camera_info.state.mode_play)
  68     {
  69         return 240;
  70     }
  71     extern int _GetVRAMVPixelsSize();
  72     return _GetVRAMVPixelsSize();
  73 
  74 }
  75 
  76 // only X offset appears to be required, for 1:1
  77 // buffer and display
  78 int vid_get_viewport_xoffset()
  79 {
  80     if (camera_info.state.mode_play)
  81     {
  82         return 0;
  83     }
  84     if (camera_info.state.mode_video || is_video_recording()) {
  85         return 0;
  86     }
  87     if(shooting_get_prop(PROPCASE_ASPECT_RATIO) == 3) { // 1:1 appears to use X offset
  88         return 44;
  89     }
  90     return 0;
  91 }
  92 
  93 // Viewport and Bitmap values that shouldn't change across firmware versions.
  94 // Values that may change are in lib.c for each firmware version.
  95 extern char active_viewport_buffer;
  96 extern void* viewport_buffers[];
  97 
  98 void *vid_get_viewport_fb()
  99 {
 100     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
 101     return viewport_buffers[0];
 102 }
 103 
 104 void *vid_get_viewport_live_fb()
 105 {
 106     if (camera_info.state.mode_video || is_video_recording())
 107         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
 108 
 109     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 110     return viewport_buffers[(active_viewport_buffer-1)&3];
 111 }
 112 
 113 void *vid_get_viewport_fb_d()
 114 {
 115     extern char *viewport_fb_d;
 116     return viewport_fb_d;
 117 }
 118 
 119 
 120 extern int active_bitmap_buffer;
 121 extern char* bitmap_buffer[];
 122 
 123 void *vid_get_bitmap_fb()
 124 {
 125     // Return first bitmap buffer address
 126     return bitmap_buffer[0];
 127 }
 128 
 129 
 130 void vid_bitmap_refresh()
 131 {
 132     extern int full_screen_refresh;
 133     extern void _ScreenLock();
 134     extern void _ScreenUnlock();
 135 
 136     full_screen_refresh |= 3;
 137     _ScreenLock();
 138     _ScreenUnlock();
 139 }
 140 
 141 void *vid_get_bitmap_active_palette()
 142 {
 143     extern int active_palette_buffer;
 144     extern char* palette_buffer[];
 145     return (palette_buffer[active_palette_buffer]+4);
 146 }
 147 
 148 void *vid_get_bitmap_active_buffer()
 149 {
 150     return bitmap_buffer[active_bitmap_buffer];
 151 }
 152 
 153 #ifdef CAM_LOAD_CUSTOM_COLORS
 154 // Function to load CHDK custom colors into active Canon palette
 155 
 156 void load_chdk_palette()
 157 {
 158     extern int active_palette_buffer;
 159     // Only load for the standard record and playback palettes
 160     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 161     {
 162         int *pal = (int*)vid_get_bitmap_active_palette();
 163         if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 164         {
 165             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 166             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 167             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 168             pal[CHDK_COLOR_BASE+3]  = 0x3F73BFAE;  // Green
 169             pal[CHDK_COLOR_BASE+4]  = 0x3F4BD6CA;  // Dark Green
 170             pal[CHDK_COLOR_BASE+5]  = 0x3F95AB95;  // Light Green
 171             pal[CHDK_COLOR_BASE+6]  = 0x3F4766F0;  // Blue
 172             pal[CHDK_COLOR_BASE+7]  = 0x3F1250F3;  // Dark Blue
 173             pal[CHDK_COLOR_BASE+8]  = 0x3F7F408F;  // Cyan
 174             pal[CHDK_COLOR_BASE+9]  = 0x3F512D5B;  // Magenta
 175             pal[CHDK_COLOR_BASE+10] = 0x3FA9A917;  // Yellow
 176             pal[CHDK_COLOR_BASE+11] = 0x3F819137;  // Dark Yellow
 177             pal[CHDK_COLOR_BASE+12] = 0x3FDED115;  // Light Yellow
 178 
 179             extern char palette_control;
 180             palette_control = 1;
 181             vid_bitmap_refresh();
 182         }
 183     }
 184 }
 185 #endif
 186 
 187 // Functions for PTP Live View system
 188 int vid_get_palette_type()                      { return 3; }
 189 int vid_get_palette_size()                      { return 256 * 4; }

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