root/platform/a1300/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_bitmap_refresh
  7. vid_get_bitmap_active_palette
  8. load_chdk_palette
  9. vid_get_palette_type
  10. vid_get_palette_size
  11. vid_get_bitmap_active_buffer
  12. _MakeAFScan
  13. state_check_for_movie_af

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_PR 0xC0220120
   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      *(int*)LED_PR=state ? 0x46 : 0x44;
  28 }
  29 
  30 // A810 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 // State
  34 // 0 = LED Off
  35 // 1 = LED On
  36 // 2 = LED blinks slowly
  37 // 3 = LED blinks fast
  38 // 5 = LED blinks fast (3 times)
  39 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  40     static char led_table[2]={0,4};
  41     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  42 }
  43 
  44 int vid_get_viewport_width()
  45 {
  46     return 360;
  47 }
  48 
  49 long vid_get_viewport_height()
  50 {
  51     return 240;
  52 }
  53 
  54 void vid_bitmap_refresh() {
  55 
  56     extern int full_screen_refresh;
  57     extern void _ScreenLock();
  58     extern void _ScreenUnlock();
  59 
  60     full_screen_refresh |= 3;
  61     _ScreenLock();
  62     _ScreenUnlock();
  63 }
  64 
  65 void *vid_get_bitmap_active_palette() {
  66     extern int active_palette_buffer;
  67     extern char* palette_buffer[];
  68     void* p = palette_buffer[active_palette_buffer];
  69     // Don't add offset if value is 0
  70     if (p) p += 4;
  71     return p;
  72 }
  73 
  74 #ifdef CAM_LOAD_CUSTOM_COLORS
  75 // Function to load CHDK custom colors into active Canon palette
  76  
  77 void load_chdk_palette() {
  78 
  79     extern int active_palette_buffer;
  80     // Only load for the standard record and playback palettes
  81     if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
  82     {
  83         int *pal = (int*)vid_get_bitmap_active_palette();
  84         if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
  85         {
  86             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
  87             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
  88             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
  89             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
  90             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
  91             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
  92             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
  93             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
  94             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
  95             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
  96             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
  97             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
  98             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
  99             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 100 
 101             extern char palette_control;
 102             palette_control = 1;
 103             vid_bitmap_refresh();
 104         }
 105     }
 106 }
 107 #endif
 108 
 109 // Functions for PTP Live View system
 110 // 256 entry palette based on 100b sub_FF909B0C
 111 int vid_get_palette_type()                      { return 3; }
 112 int vid_get_palette_size()                      { return 256 * 4; }
 113 
 114 void *vid_get_bitmap_active_buffer()
 115 {
 116     return (void*)(*(int*)(0x5400+0x18)); //found @ loc_ff909bb0 a810 100b
 117 }
 118 
 119 // following routines help preventing the "invisible af lock" caused by the movie af scan hack
 120 
 121 static int af_locked_in_movierec = 0;
 122 
 123 void _MakeAFScan(__attribute__ ((unused))int *a, __attribute__ ((unused))int b) {
 124     _DoAFLock();
 125     af_locked_in_movierec = 1;
 126 }
 127 
 128 void state_check_for_movie_af() {
 129     if ((get_movie_status() != VIDEO_RECORD_IN_PROGRESS) && af_locked_in_movierec) {
 130         af_locked_in_movierec = 0;
 131         _UnlockAF();
 132     }
 133 }

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