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

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