root/platform/a2400/lib.c

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

DEFINITIONS

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

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_PR 0xC0220120
   6 //#define LED_AF 0xC0223030
   7 
   8 void shutdown()
   9 {
  10         volatile long *p = (void*)LED_PR;
  11 
  12         asm(
  13                 "MRS     R1, CPSR\n"
  14                 "AND     R0, R1, #0x80\n"
  15                 "ORR     R1, R1, #0x80\n"
  16                 "MSR     CPSR_cf, R1\n"
  17                 :::"r1","r0");
  18 
  19         *p = 0x44;  // power off.
  20 
  21         while(1);
  22 }
  23 
  24 void debug_led(int state)
  25 {
  26         // using power LED, which defaults to on
  27         // for debugging turn LED off if state is 1 and on for state = 0
  28         // leaves LED on at end of debugging
  29      *(int*)LED_PR=state ? 0x46 : 0x44;
  30 }
  31 
  32 // To do: Check this!!!
  33 // A2400 has two 'lights' - Power LED, and AF assist lamp
  34 // Power Led = first entry in table (led 0)
  35 // AF Assist Lamp = second entry in table (led 1)
  36 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  37         static char led_table[2]={0,4};
  38     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  39 }
  40 
  41 int get_flash_params_count(void) { return 0xa6; }
  42 
  43 int vid_get_viewport_width()
  44 {
  45     return 360;
  46 }
  47 
  48 long vid_get_viewport_height()
  49 {
  50     return 240;
  51 }
  52 
  53 
  54 // Defined in stubs_entry.S
  55 extern char active_viewport_buffer;
  56 extern void* viewport_buffers[];
  57 
  58 void *vid_get_viewport_fb()
  59 {
  60     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  61     return viewport_buffers[0];
  62 }
  63 
  64 void *vid_get_viewport_live_fb()
  65 {
  66     if (MODE_IS_VIDEO(mode_get()))
  67         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  68 
  69     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  70     return viewport_buffers[(active_viewport_buffer-1)&3];
  71 }
  72 
  73 
  74 void vid_bitmap_refresh() 
  75 {
  76         extern int full_screen_refresh;
  77     extern void _ScreenLock();
  78     extern void _ScreenUnlock();
  79 
  80         full_screen_refresh |= 3;
  81     _ScreenLock();
  82     _ScreenUnlock();
  83 }
  84 
  85 void *vid_get_bitmap_active_palette() {
  86     extern int active_palette_buffer;
  87     extern char* palette_buffer[];
  88     void* p = palette_buffer[active_palette_buffer];
  89     // Don't add offset if value is 0
  90     if (p) p += 4;
  91     return p;
  92 }
  93 
  94 #ifdef CAM_LOAD_CUSTOM_COLORS
  95 // Function to load CHDK custom colors into active Canon palette
  96  
  97 void load_chdk_palette() {
  98 
  99         extern int active_palette_buffer;
 100         // Only load for the standard record and playback palettes
 101         if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 102         {
 103                 int *pal = (int*)vid_get_bitmap_active_palette();
 104                 if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 105                 {                
 106                         pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 107                         pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 108                         pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 109                         pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 110                         pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 111                         pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 112                         pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 113                         pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 114                         pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 115                         pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 116                         pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 117                         pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 118                         pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 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*)(0x546C+0x18)); //Found @ loc_FF90B408 a2400 100e
 135 }

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