root/platform/ixus115_elph100hs/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. get_flash_params_count
  6. vid_get_viewport_width
  7. vid_get_viewport_xoffset
  8. vid_get_viewport_height
  9. vid_get_viewport_yoffset
  10. vid_get_palette_type
  11. vid_get_palette_size
  12. vid_get_bitmap_active_palette
  13. vid_get_viewport_fb
  14. vid_get_viewport_live_fb
  15. load_chdk_palette
  16. _MakeAFScan
  17. state_check_for_movie_af

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 
   6 void vid_bitmap_refresh()
   7 {
   8         extern int full_screen_refresh;
   9         extern void _LockAndRefresh(); // wrapper function for screen lock
  10         extern void _UnlockAndRefresh(); // wrapper function for screen unlock
  11 
  12         full_screen_refresh |= 3; //found in ScreenUnlock
  13         _LockAndRefresh();
  14         _UnlockAndRefresh();
  15 }
  16 
  17 
  18 void shutdown()
  19 {
  20         volatile long *p = (void*)0xC022001C;
  21 
  22         asm(
  23                 "MRS     R1, CPSR\n"
  24                 "AND     R0, R1, #0x80\n"
  25                 "ORR     R1, R1, #0x80\n"
  26                 "MSR     CPSR_cf, R1\n"
  27                 :::"r1","r0");
  28 
  29         *p = 0x44;  // power off.
  30 
  31         while(1);
  32 }
  33 
  34 #define LED_PR 0xC0220130 //elph100
  35 
  36 
  37 void debug_led(int state)
  38 {
  39  *(int*)LED_PR=state ? 0x46 : 0x44;
  40 }
  41 
  42 void camera_set_led(int led, int state, int bright) {
  43         static char led_table[2]={0,9};
  44         _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  45 }
  46 
  47 int get_flash_params_count(void){
  48         return 0xa0;  //@FF9ADCAC near to "BIC     R4, R4, #0x8000" & "PropertyTableManagerCore.c" or 0x80
  49 }
  50 
  51 // Viewport and Bitmap values that shouldn't change across firmware versions.
  52 // Values that may change are in lib.c for each firmware version.
  53 
  54 
  55 int vid_get_viewport_width()
  56 {
  57         // viewport width table for each image size
  58         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  59         static long vp_w[4] = { 360, 360, 360, 270 };//{ 360, 480, 360, 272 };
  60         return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  61 }
  62 
  63 int vid_get_viewport_xoffset()
  64 {
  65         // viewport width offset table for each image size
  66         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  67         static long vp_w[4] = {0, 0, 0, 44};//{ 60, 0, 36, 104 };                               // should all be even values for edge overlay
  68         return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  69 }
  70 
  71 long vid_get_viewport_height()
  72 {
  73         // viewport height table for each image size
  74         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  75         static long vp_h[4] = { 240, 180, 214, 240};//{ 240, 240, 240, 240 };
  76         return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  77 }
  78 
  79 int vid_get_viewport_yoffset()
  80 {
  81         // viewport height offset table for each image size
  82         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  83         static long vp_h[4] = { 0, 30, 13, 0 };
  84         return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  85 }
  86 
  87 // Functions for PTP Live View system
  88 // 256 entry palette based on 100b sub_FF926708 ixus115 101a
  89 int vid_get_palette_type()                      { return 3; }
  90 int vid_get_palette_size()                      { return 256 * 4; }
  91 
  92 void *vid_get_bitmap_active_palette() {
  93         extern int active_palette_buffer;
  94         extern char* palette_buffer[];
  95         return (palette_buffer[active_palette_buffer]+8);
  96 }
  97 
  98 extern char active_viewport_buffer;
  99 extern void* viewport_buffers[];
 100 
 101 void *vid_get_viewport_fb()
 102 {
 103     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
 104     return viewport_buffers[0];
 105 }
 106 
 107 void *vid_get_viewport_live_fb()
 108 {
 109     if (camera_info.state.mode_video)
 110         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
 111 
 112    // Hopefully return the most recently used viewport buffer
 113     return viewport_buffers[(active_viewport_buffer-1)&3];
 114 }
 115 
 116 #ifdef CAM_LOAD_CUSTOM_COLORS
 117 // Function to load CHDK custom colors into active Canon palette
 118  
 119 void load_chdk_palette() {
 120 
 121         extern int active_palette_buffer;
 122         // Only load for the standard record (0) and playback (4) palettes
 123         if ((active_palette_buffer == 0) || (active_palette_buffer == 4))
 124         {
 125             int *pal = (int*)vid_get_bitmap_active_palette();
 126             if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 127             {
 128                 pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 129                 pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 130                 pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 131                 pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 132                 pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 133                 pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 134                 pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 135                 pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 136                 pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 137                 pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 138                 pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 139                 pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 140                 pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 141 
 142                 extern char palette_control;
 143                 palette_control = 1;
 144                 vid_bitmap_refresh();
 145             }
 146 
 147 /*          // completely transparent palette for special use
 148             int n;
 149             if (pal[0] != 0) {
 150                 for (n=0; n<256; n++) {
 151                     pal[n] = 0;
 152                 }
 153                 extern char palette_control;
 154                 palette_control = 1;
 155                 vid_bitmap_refresh();
 156             }
 157 */
 158         }
 159 }
 160 #endif
 161 
 162 // following routines help preventing the "invisible af lock" caused by the movie af scan hack
 163 
 164 static int af_locked_in_movierec = 0;
 165 
 166 void _MakeAFScan(int *a, int b) {
 167     _DoAFLock();
 168     af_locked_in_movierec = 1;
 169 }
 170 
 171 void state_check_for_movie_af() {
 172     if ((get_movie_status() != VIDEO_RECORD_IN_PROGRESS) && af_locked_in_movierec) {
 173         af_locked_in_movierec = 0;
 174         _UnlockAF();
 175     }
 176 }

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