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, __attribute__ ((unused))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     void* p = palette_buffer[active_palette_buffer];
  96     // Don't add offset if value is 0
  97     if (p) p += 8;
  98     return p;
  99 }
 100 
 101 extern char active_viewport_buffer;
 102 extern void* viewport_buffers[];
 103 
 104 void *vid_get_viewport_fb()
 105 {
 106     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
 107     return viewport_buffers[0];
 108 }
 109 
 110 void *vid_get_viewport_live_fb()
 111 {
 112     int b = (active_viewport_buffer-1)&3;
 113     if ((b == 3) && (camera_info.state.mode_video || is_video_recording()))
 114         b = 2;  // Video only seems to use the first 3 viewport buffers.
 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[b];
 118 }
 119 
 120 
 121 #ifdef CAM_LOAD_CUSTOM_COLORS
 122 // Function to load CHDK custom colors into active Canon palette
 123 
 124 void load_chdk_palette() {
 125 
 126         extern int active_palette_buffer;
 127         // Only load for the standard record (0) and playback (4) palettes
 128         if ((active_palette_buffer == 0) || (active_palette_buffer == 4))
 129         {
 130             int *pal = (int*)vid_get_bitmap_active_palette();
 131             if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 132             {
 133                 pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 134                 pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 135                 pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 136                 pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 137                 pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 138                 pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 139                 pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 140                 pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 141                 pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 142                 pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 143                 pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 144                 pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 145                 pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 146 
 147                 extern char palette_control;
 148                 palette_control = 1;
 149                 vid_bitmap_refresh();
 150             }
 151 
 152 /*          // completely transparent palette for special use
 153             int n;
 154             if (pal[0] != 0) {
 155                 for (n=0; n<256; n++) {
 156                     pal[n] = 0;
 157                 }
 158                 extern char palette_control;
 159                 palette_control = 1;
 160                 vid_bitmap_refresh();
 161             }
 162 */
 163         }
 164 }
 165 #endif
 166 
 167 // following routines help preventing the "invisible af lock" caused by the movie af scan hack
 168 
 169 static int af_locked_in_movierec = 0;
 170 
 171 void _MakeAFScan(__attribute__ ((unused))int *a, __attribute__ ((unused))int b) {
 172     _DoAFLock();
 173     af_locked_in_movierec = 1;
 174 }
 175 
 176 void state_check_for_movie_af() {
 177     if ((get_movie_status() != VIDEO_RECORD_IN_PROGRESS) && af_locked_in_movierec) {
 178         af_locked_in_movierec = 0;
 179         _UnlockAF();
 180     }
 181 }

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