root/platform/a3400/lib.c

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

DEFINITIONS

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

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_PR 0xC0220120  //check this address
   6 
   7 void shutdown()
   8 {
   9         volatile long *p = (void*)LED_PR;
  10 
  11         asm(
  12                 "MRS     R1, CPSR\n"
  13                 "AND     R0, R1, #0x80\n"
  14                 "ORR     R1, R1, #0x80\n"
  15                 "MSR     CPSR_cf, R1\n"
  16                 :::"r1","r0");
  17 
  18         *p = 0x44;  // power off.
  19 
  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         // leaves LED on at end of debugging
  28      *(int*)LED_PR=state ? 0x46 : 0x44;
  29 }
  30 
  31 // A3400IS has two 'lights' - Power LED, and AF assist lamp
  32 // Power Led = first entry in table (led 0)
  33 // AF Assist Lamp = second entry in table (led 1)
  34 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  35     static char led_table[2]={0,4};
  36     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  37 }
  38 
  39 int vid_get_viewport_width()
  40 {
  41     return 360;
  42 }
  43 
  44 long vid_get_viewport_height()
  45 {
  46     return 240;
  47 }
  48 
  49 // Defined in stubs_entry.S
  50 extern char active_viewport_buffer;
  51 extern void* viewport_buffers[];
  52 
  53 void *vid_get_viewport_fb()
  54 {
  55     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  56     return viewport_buffers[0];
  57 }
  58 
  59 void *vid_get_viewport_live_fb()
  60 {
  61     if (MODE_IS_VIDEO(mode_get()))
  62         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  63 
  64     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  65     return viewport_buffers[(active_viewport_buffer-1)&3];
  66 }
  67 
  68 void vid_bitmap_refresh() {
  69 
  70     extern int full_screen_refresh;
  71     extern void _ScreenLock();
  72     extern void _ScreenUnlock();
  73 
  74     full_screen_refresh |= 3;
  75     _ScreenLock();
  76     _ScreenUnlock();
  77 }
  78 
  79 void *vid_get_bitmap_active_palette() {
  80     extern int active_palette_buffer;
  81     extern char* palette_buffer[];
  82     void* p = palette_buffer[active_palette_buffer & 7];
  83     // Don't add offset if value is 0
  84     if (p) p += 4;
  85     return p;
  86 }
  87 
  88 #ifdef CAM_LOAD_CUSTOM_COLORS
  89 // Function to load CHDK custom colors into active Canon palette
  90 // To do:
  91 void load_chdk_palette() {
  92 
  93         extern int active_palette_buffer;
  94         // Only load for the standard record and playback palettes
  95         if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
  96         {
  97                 int *pal = (int*)vid_get_bitmap_active_palette();
  98                 if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
  99                 {                
 100                         pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 101                         pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 102                         pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 103                         pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 104                         pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 105                         pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 106                         pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 107                         pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 108                         pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 109                         pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 110                         pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 111                         pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 112                         pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 113                         pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 114 
 115                         extern char palette_control;
 116                         palette_control = 1;
 117                         vid_bitmap_refresh();
 118         }
 119     }
 120 }
 121 #endif
 122 
 123 // Functions for PTP Live View system
 124 int vid_get_palette_type()                      { return 3; }
 125 int vid_get_palette_size()                      { return 256 * 4; }
 126 
 127 void *vid_get_bitmap_active_buffer()
 128 {
 129     return (void*)(*(int*)(0x54C4+0x18)); //Found @ loc_FF90CC3C a3400.101a  Not tested
 130 }
 131 
 132 // following routines help preventing the "invisible af lock" caused by the movie af scan hack
 133 
 134 static int af_locked_in_movierec = 0;
 135 
 136 void _MakeAFScan(__attribute__ ((unused))int *a, __attribute__ ((unused))int b) {
 137     _DoAFLock();
 138     af_locked_in_movierec = 1;
 139 }
 140 
 141 void state_check_for_movie_af() {
 142     if ((get_movie_status() != VIDEO_RECORD_IN_PROGRESS) && af_locked_in_movierec) {
 143         af_locked_in_movierec = 0;
 144         _UnlockAF();
 145     }
 146 }

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