root/platform/a1400/lib.c

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

DEFINITIONS

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

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 
   6 char *camera_jpeg_count_str()
   7 {
   8     extern char jpeg_count_str[];
   9     return jpeg_count_str;
  10 }
  11 
  12 #define LED_PR 0xC0220120
  13 void shutdown()
  14 {
  15     extern void _TurnOffE1(void);
  16     _TurnOffE1();
  17     while(1);
  18 }
  19 
  20 void debug_led(int state)
  21 {
  22     // using power LED, which defaults to on
  23     // for debugging turn LED off if state is 1 and on for state = 0
  24      *(int*)LED_PR=state ? 0x46 : 0x44;
  25 }
  26 
  27 // A1400 has three 'lights' - Power (Green) LED, Orange LED and AF assist lamp
  28 // Green Led = first entry in table (led 0)
  29 // Orange Led = first entry in table (led 0)
  30 // AF Assist Lamp = second entry in table (led 1)
  31 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  32     static char led_table[3]={0,1,4};
  33     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  34 }
  35 
  36 int get_flash_params_count(void){ return 0x91; }
  37 char *hook_raw_image_addr()      {return (char*) 0x420e5c30;}   //Found @0xffb16a34 a1400 100b
  38 
  39 int vid_get_viewport_width()     { return 360;  }
  40 long vid_get_viewport_height()   { return 240;  }
  41 
  42 
  43 // Viewport and Bitmap values that shouldn't change across firmware versions.
  44 // Values that may change are in lib.c for each firmware version.
  45 void *vid_get_bitmap_fb()        { return (void*)0x40431000; }   // Found @0xff85ce98
  46 void *vid_get_viewport_fb()      { return (void*)0x40586b80; }   // Found @0xffb1511c
  47 
  48 void *vid_get_viewport_fb_d()
  49 {
  50     extern char *viewport_fb_d;
  51     return viewport_fb_d;
  52 }
  53 
  54 //To do
  55 void *vid_get_viewport_live_fb()
  56 {
  57     extern char active_viewport_buffer;
  58     extern void* viewport_buffers[];
  59 
  60     if (MODE_IS_VIDEO(mode_get()) || is_video_recording())
  61         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  62 
  63     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  64     // verified -1 gives best response
  65     return viewport_buffers[(active_viewport_buffer-1)&3];
  66 }
  67 
  68 
  69 void vid_bitmap_refresh()
  70 {
  71     extern int full_screen_refresh;
  72     extern void _ScreenLock();
  73     extern void _ScreenUnlock();
  74 
  75     full_screen_refresh |= 3;
  76     _ScreenLock();
  77     _ScreenUnlock();
  78 }
  79 
  80 void *vid_get_bitmap_active_palette() // from ixus140_elph130
  81 {
  82     extern int active_palette_buffer;
  83     extern int** palette_buffer_ptr;
  84     int *p = palette_buffer_ptr[active_palette_buffer];
  85     // active_palette_buffer can point at null when
  86     // func and menu are opened for the first time
  87     if(!p) {
  88         p = palette_buffer_ptr[0]; // rec mode buffer appears to always be initialized
  89     }
  90     return (p+1);
  91 }
  92 
  93 #ifdef CAM_LOAD_CUSTOM_COLORS
  94 // Function to load CHDK custom colors into active Canon palette
  95 
  96 void load_chdk_palette() {
  97 
  98     extern int active_palette_buffer;
  99     // Only load for the standard record and playback palettes
 100     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 101     {
 102         int *pal = (int*)vid_get_bitmap_active_palette();
 103         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 104         {
 105             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 106             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 107             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 108             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 109             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 110             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 111             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 112             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 113             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 114             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 115             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 116             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 117             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 118             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 119 
 120             extern char palette_control;
 121             palette_control = 1;
 122             vid_bitmap_refresh();
 123         }
 124     }
 125 }
 126 #endif
 127 
 128 // Functions for PTP Live View system
 129 int vid_get_palette_type()                      { return 3; }
 130 int vid_get_palette_size()                      { return 256 * 4; }
 131 
 132 void *vid_get_bitmap_active_buffer()
 133 {
 134     return (void*)(*(int*)(0x5AE0+0x18)); //found @ loc_FF92292C a1400 100b
 135 }

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