root/platform/ixus125_elph110hs/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. get_flash_params_count
  5. shutdown
  6. debug_led
  7. camera_set_led
  8. vid_get_viewport_fb_d
  9. vid_get_viewport_fb
  10. vid_get_viewport_live_fb
  11. vid_get_viewport_yscale
  12. vid_get_viewport_width
  13. vid_get_viewport_height
  14. vid_get_viewport_xoffset
  15. vid_get_viewport_display_xoffset
  16. vid_get_viewport_yoffset
  17. vid_get_viewport_display_yoffset
  18. vid_get_viewport_display_yoffset_proper
  19. vid_get_viewport_height_proper
  20. vid_get_viewport_fullscreen_height
  21. vid_bitmap_refresh
  22. vid_get_bitmap_active_palette
  23. vid_get_palette_type
  24. vid_get_palette_size
  25. vid_get_bitmap_fb
  26. vid_get_bitmap_active_buffer
  27. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 extern  int     active_raw_buffer;
   6 extern  char*   raw_buffers[];
   7 
   8 char *hook_raw_image_addr()
   9 {
  10     return raw_buffers[active_raw_buffer];
  11 }
  12 
  13 char *hook_alt_raw_image_addr()
  14 {
  15     return raw_buffers[(active_raw_buffer^1)];
  16 }
  17 
  18 
  19 char *camera_jpeg_count_str()
  20 {
  21     extern char jpeg_count_str[];
  22         return jpeg_count_str;
  23 }
  24 
  25 int get_flash_params_count(void)
  26 {
  27     return 0xa6;
  28 }
  29 
  30 //To do: find this LED address
  31 //#define LED_PR 0xC0220160
  32 
  33 void shutdown()
  34 {
  35 //      volatile long *p = (void*)LED_PR;
  36 
  37         asm(
  38                 "MRS     R1, CPSR\n"
  39                 "AND     R0, R1, #0x80\n"
  40                 "ORR     R1, R1, #0x80\n"
  41                 "MSR     CPSR_cf, R1\n"
  42                 :::"r1","r0");
  43 
  44 //      *p = 0x44;  // power off.
  45 
  46         while(1);
  47 }
  48 
  49 void debug_led(int state)
  50 {
  51         // using power LED, which defaults to on
  52         // for debugging turn LED off if state is 1 and on for state = 0
  53         // leaves LED on at end of debugging
  54 //     *(int*)LED_PR=state ? 0x46 : 0x44;
  55 }
  56 
  57 // To do: fix this.
  58 // IXUS125  has two 'lights'??? - Power LED, and AF assist lamp
  59 // Power Led = first entry in table (led 0) ???
  60 // AF Assist Lamp = second entry in table (led 1) ????
  61 void camera_set_led(int led, int state, int bright) {
  62         static char led_table[2]={0,4};
  63     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  64 }
  65 
  66 // Viewport and Bitmap values that shouldn't change across firmware versions.
  67 // Values that may change are in lib.c for each firmware version.
  68 void *vid_get_viewport_fb_d()
  69 {
  70     extern char *viewport_fb_d;
  71     return viewport_fb_d;
  72 }
  73 
  74 // Defined in stubs_entry.S
  75 extern char active_viewport_buffer;
  76 extern void* viewport_buffers[];
  77 
  78 void *vid_get_viewport_fb()
  79 {
  80     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  81     return viewport_buffers[0];
  82 }
  83 
  84 void *vid_get_viewport_live_fb()
  85 {
  86     if (camera_info.state.mode_video || is_video_recording())
  87         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  88 
  89     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  90     return viewport_buffers[(active_viewport_buffer-1)&3];
  91 }
  92 
  93 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  94 int vid_get_viewport_yscale() {
  95     return 2;
  96 }
  97 
  98 int vid_get_viewport_width()
  99 {
 100     if (camera_info.state.mode_play)
 101     {
 102         return 360;
 103     }
 104     extern int _GetVRAMHPixelsSize();
 105     return _GetVRAMHPixelsSize() >> 1;
 106 }
 107 
 108 long vid_get_viewport_height()
 109 {
 110     if (camera_info.state.mode_play)
 111     {
 112         return 240;
 113     }
 114     extern int _GetVRAMVPixelsSize();
 115     return _GetVRAMVPixelsSize() >> 1;
 116 }
 117 
 118 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 119 static long vp_xo[5] = { 0, 0, 0, 44 };                         // should all be even values for edge overlay
 120 
 121 // guessed same as elph130
 122 int vid_get_viewport_xoffset()
 123 {
 124     return 0;
 125 }
 126 
 127 int vid_get_viewport_display_xoffset()
 128 {
 129     if (camera_info.state.mode_play)
 130     {
 131         return 0;
 132     }
 133     else if (camera_info.state.mode_shooting == MODE_STITCH) // guessed based on elph130
 134     {
 135         if (shooting_get_prop(PROPCASE_STITCH_DIRECTION) == 0)      // Direction check
 136             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 137                 return 40;
 138             else
 139                 return 140;
 140         else
 141             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 142                 return 140;
 143             else
 144                 return 40;
 145     }
 146     else if (camera_info.state.mode_video || is_video_recording()) {
 147         return 0;
 148     }
 149     else
 150     {
 151             return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 152     }
 153 }
 154 
 155 // viewport height offset table for each image size
 156 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 157 static long vp_yo[5] = { 0, 30, 13, 0 };
 158 
 159 int vid_get_viewport_yoffset()
 160 {
 161     if (camera_info.state.mode_play)
 162     {
 163         return 0;
 164     }
 165     else if (camera_info.state.mode_shooting == MODE_STITCH) // guessed based on elph130
 166     {
 167         return 0;
 168     }
 169     else if (camera_info.state.mode_video || is_video_recording())
 170     {
 171         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) { // 640x480
 172             return 0;// 4:3 video, no offset
 173         } else {
 174             return 30; // 16:9 video
 175         }
 176     }
 177     else
 178     {
 179             return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 180     }
 181 }
 182 
 183 int vid_get_viewport_display_yoffset()
 184 {
 185     if (camera_info.state.mode_play)
 186     {
 187         return 0;
 188     }
 189     else if (camera_info.state.mode_shooting == MODE_STITCH) // guessed based on elph130
 190     {
 191         return 72;
 192     }
 193     else if (camera_info.state.mode_video || is_video_recording())
 194     {
 195         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) { // 640x480
 196             return 0;// 4:3 video, no offset
 197         } else {
 198             return 30; // 16:9 video
 199         }
 200     }
 201     else
 202     {
 203             return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 204     }
 205 }
 206 
 207 
 208 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() * 2; }
 209 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * 2; }
 210 int vid_get_viewport_fullscreen_height()        { return 480; }
 211 
 212 void vid_bitmap_refresh() {
 213 
 214     extern int full_screen_refresh;
 215     extern void _ScreenLock();
 216     extern void _ScreenUnlock();
 217 
 218     full_screen_refresh |= 3;
 219     _ScreenLock();
 220     _ScreenUnlock();
 221 }
 222 
 223 void *vid_get_bitmap_active_palette() {
 224         extern int active_palette_buffer;
 225         extern char* palette_buffer[];
 226         return (palette_buffer[active_palette_buffer]+4);
 227 }
 228 
 229 
 230 // Functions for PTP Live View system
 231 // 256 entry palette based on 100b sub_FF926708 ixus115 101a
 232 int vid_get_palette_type()                      { return 3; }
 233 int vid_get_palette_size()                      { return 256 * 4; }
 234 
 235 // Defined in stubs_entry.S
 236 extern int active_bitmap_buffer;
 237 extern char* bitmap_buffer[];
 238 
 239 void *vid_get_bitmap_fb() {
 240     // Return first bitmap buffer address
 241     return bitmap_buffer[0];
 242 }
 243 
 244 void *vid_get_bitmap_active_buffer() {
 245     return bitmap_buffer[active_bitmap_buffer];
 246 }
 247 
 248 #ifdef CAM_LOAD_CUSTOM_COLORS
 249 // Function to load CHDK custom colors into active Canon palette
 250 void load_chdk_palette()
 251 {
 252     extern int active_palette_buffer;
 253     // Only load for the standard record and playback palettes
 254     //rec=0, set menu=4, play=5, menu=6
 255     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 256     {
 257         int *pal = (int*)vid_get_bitmap_active_palette();
 258         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 259         {
 260             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 261             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 262             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 263             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 264             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 265             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 266             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 267             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 268             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 269             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 270             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 271             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 272             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 273             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 274 
 275             extern char palette_control;
 276             palette_control = 1;
 277             vid_bitmap_refresh();
 278         }
 279     }
 280 }
 281 #endif

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