root/platform/sx200is/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. vid_bitmap_refresh
  2. shutdown
  3. debug_led
  4. camera_set_led
  5. get_flash_params_count
  6. JogDial_CW
  7. JogDial_CCW
  8. vid_get_bitmap_active_palette
  9. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 //from ixus870_sd880
   6 void vid_bitmap_refresh()
   7 {
   8  extern int enabled_refresh_physical_screen; // screen lock counter
   9  int old_val = enabled_refresh_physical_screen;
  10  if ( old_val == 0 )
  11  {
  12    _ScreenLock(); // make sure code is called at least once
  13  } else {
  14    enabled_refresh_physical_screen=1; // forces actual redraw
  15  }
  16  _RefreshPhysicalScreen(1); // unlock/refresh
  17 
  18  // restore original situation
  19  if ( old_val > 0 )
  20  {
  21    _ScreenLock();
  22    enabled_refresh_physical_screen = old_val;
  23  }
  24 }
  25 
  26 
  27 void shutdown()
  28 {
  29         volatile long *p = (void*)0xC022001C;    
  30         
  31         asm(
  32                 "MRS     R1, CPSR\n"
  33                 "AND     R0, R1, #0x80\n"
  34                 "ORR     R1, R1, #0x80\n"
  35                 "MSR     CPSR_cf, R1\n"
  36                 :::"r1","r0");
  37         
  38         *p = 0x44;  // power off.
  39         
  40         while(1);
  41 }
  42 
  43 #define LED_PR 0xC0220138
  44 
  45 void debug_led(int state)
  46 {
  47  *(int*)LED_PR=state ? 0x46 : 0x44;
  48 }
  49 
  50 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  51  static char led_table[5]={4,5,7,8,9};
  52  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  53 }
  54 
  55 int get_flash_params_count(void){
  56  return 120; 
  57 }
  58 
  59 void JogDial_CW(void){
  60  _PostLogicalEventForNotPowerType(0x874, 1);  // RotateJogDialRight
  61 }
  62 
  63 void JogDial_CCW(void){
  64  _PostLogicalEventForNotPowerType(0x875, 1);  // RotateJogDialLeft
  65 }
  66 
  67 void *vid_get_bitmap_active_palette()
  68 {
  69     extern int active_palette_buffer;
  70     extern int** palette_buffer_ptr;
  71     return (palette_buffer_ptr[active_palette_buffer]+0x3);
  72 }
  73 
  74 // Function to load CHDK custom colors into active Canon palette
  75 void load_chdk_palette()
  76 {
  77     extern int active_palette_buffer;
  78     // Only load for the standard record and playback palettes
  79     if ((active_palette_buffer == 0) || (active_palette_buffer == 2) || (active_palette_buffer == 3))
  80     {
  81         int *pal = (int*)vid_get_bitmap_active_palette();
  82         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
  83         {
  84             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
  85             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
  86             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
  87             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
  88             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
  89             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
  90             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
  91             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
  92             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
  93             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
  94             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
  95             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
  96             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
  97             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent Dark Grey
  98 
  99             extern char palette_control;
 100             palette_control = 1;
 101             vid_bitmap_refresh();
 102         }
 103     }
 104 }

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