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, __attribute__ ((unused))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     int i = active_viewport_buffer - 1;
 107     // video appears to only use 3 buffers
 108     if (camera_info.state.mode_video || is_video_recording()) {
 109         if(i < 0) {
 110             i = 2;
 111         }
 112     } else if(i < 0) {
 113         i = 3;
 114     }
 115 
 116     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 117     return viewport_buffers[i];
 118 }
 119 
 120 void *vid_get_viewport_fb_d()
 121 {
 122     extern char *viewport_fb_d;
 123     return viewport_fb_d;
 124 }
 125 
 126 
 127 extern int active_bitmap_buffer;
 128 extern char* bitmap_buffer[];
 129 
 130 void *vid_get_bitmap_fb()
 131 {
 132     // Return first bitmap buffer address
 133     return bitmap_buffer[0];
 134 }
 135 
 136 
 137 void vid_bitmap_refresh()
 138 {
 139     extern int full_screen_refresh;
 140     extern void _ScreenLock();
 141     extern void _ScreenUnlock();
 142 
 143     full_screen_refresh |= 3;
 144     _ScreenLock();
 145     _ScreenUnlock();
 146 }
 147 
 148 void *vid_get_bitmap_active_palette()
 149 {
 150     extern int active_palette_buffer;
 151     extern int** palette_buffer_ptr;
 152     int *p = palette_buffer_ptr[active_palette_buffer];
 153     // active_palette_buffer can point at null when
 154     // func and menu are opened for the first time
 155     if(!p) {
 156         p = palette_buffer_ptr[0];
 157         if(!p) {
 158             return (void *)0;
 159         }
 160     }
 161     return (p+1);
 162 }
 163 
 164 void *vid_get_bitmap_active_buffer()
 165 {
 166     return bitmap_buffer[active_bitmap_buffer];
 167 }
 168 
 169 #ifdef CAM_LOAD_CUSTOM_COLORS
 170 // Function to load CHDK custom colors into active Canon palette
 171 
 172 void load_chdk_palette()
 173 {
 174     extern int active_palette_buffer;
 175     // Only load for the standard record and playback palettes
 176     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 177     {
 178         int *pal = (int*)vid_get_bitmap_active_palette();
 179         if (pal && pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 180         {
 181             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 182             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 183             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 184             pal[CHDK_COLOR_BASE+3]  = 0x3F73BFAE;  // Green
 185             pal[CHDK_COLOR_BASE+4]  = 0x3F4BD6CA;  // Dark Green
 186             pal[CHDK_COLOR_BASE+5]  = 0x3F95AB95;  // Light Green
 187             pal[CHDK_COLOR_BASE+6]  = 0x3F4766F0;  // Blue
 188             pal[CHDK_COLOR_BASE+7]  = 0x3F1250F3;  // Dark Blue
 189             pal[CHDK_COLOR_BASE+8]  = 0x3F7F408F;  // Cyan
 190             pal[CHDK_COLOR_BASE+9]  = 0x3F512D5B;  // Magenta
 191             pal[CHDK_COLOR_BASE+10] = 0x3FA9A917;  // Yellow
 192             pal[CHDK_COLOR_BASE+11] = 0x3F819137;  // Dark Yellow
 193             pal[CHDK_COLOR_BASE+12] = 0x3FDED115;  // Light Yellow
 194 
 195             extern char palette_control;
 196             palette_control = 1;
 197             vid_bitmap_refresh();
 198         }
 199     }
 200 }
 201 #endif
 202 
 203 // Functions for PTP Live View system
 204 int vid_get_palette_type()                      { return 3; }
 205 int vid_get_palette_size()                      { return 256 * 4; }

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