root/platform/a1100/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. _GetBatteryTemperature
  7. load_chdk_palette
  8. vid_get_palette_type
  9. vid_get_palette_size
  10. vid_get_bitmap_active_palette
  11. vid_get_viewport_width_proper
  12. vid_get_viewport_height_proper

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_DP      0xC02200CC    // direct-print (blue)
   6 #define LED_FLASH   0xC02200D8    // Triggers flash
   7 #define LED_AF      0xC02200DC    // Auto-focus LED
   8 
   9 void vid_bitmap_refresh()
  10 {
  11  extern int enabled_refresh_physical_screen;
  12  enabled_refresh_physical_screen=1;
  13  _RefreshPhysicalScreen(1);
  14 }
  15 
  16 
  17 void shutdown()
  18 {
  19     volatile long *p = (void*)0xC022001C;    
  20     
  21     asm(
  22         "MRS     R1, CPSR\n"
  23         "AND     R0, R1, #0x80\n"
  24         "ORR     R1, R1, #0x80\n"
  25         "MSR     CPSR_cf, R1\n"
  26         :::"r1","r0");
  27 
  28     *p = 0x44;  // power off.
  29 
  30     while(1);
  31 }
  32 
  33 
  34 void debug_led(int state)
  35 {
  36  *(int*)LED_DP=state ? 0x46 : 0x44;
  37 }
  38 
  39 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  40  static char led_table[]={7,9};
  41  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  42 }
  43 
  44 int get_flash_params_count(void){
  45  return 122; 
  46 }
  47 
  48 /*
  49 GetBatteryTemperature usually will get back temperature of battery compartment/batteries. GetBatteryTemperature is implemented in Canon's firmware for SX120IS.
  50 Firmware entry point is identified but function is not usable. 
  51 Camera will crash if Canon's GetBatteryTemperature is called by CHDK.
  52 To avoid a crash Canon's GetBatteryTemperature must not called. As long CHDK general code do not distinguish between cameras that support or don't support GetBatteryTemperature, 
  53 this function will be implemented as specific CHDK-code. It returns always with -99
  54 This overrides original canon entry point from stubs_entry.S
  55 */
  56 int _GetBatteryTemperature()
  57 {
  58       return -99;
  59 }
  60 
  61 // Function to load CHDK custom colors into active Canon palette
  62 void load_chdk_palette() {
  63 
  64     extern int active_palette_buffer;
  65     // Only load for the standard record and playback palettes
  66     if ((active_palette_buffer == 0) || (active_palette_buffer == 1))
  67     {
  68         int *pal = (int*)vid_get_bitmap_active_palette();
  69         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
  70         {
  71             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
  72             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
  73             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
  74             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
  75             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
  76             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
  77             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
  78             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
  79             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
  80             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
  81             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
  82             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
  83             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
  84             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
  85 
  86             //extern char palette_control;
  87             //palette_control = 1;
  88             vid_bitmap_refresh();
  89         }
  90     }
  91 }
  92 
  93 // Functions for PTP Live View system
  94 int vid_get_palette_type()                      { return 3; }
  95 int vid_get_palette_size()                      { return 256 * 4; }
  96 
  97 void *vid_get_bitmap_active_palette()
  98 {
  99     extern int active_palette_buffer;
 100     extern char** palette_buffer_ptr;
 101     return (palette_buffer_ptr[active_palette_buffer]+16);
 102 }
 103 
 104 // copied from D10
 105 extern int _GetVRAMHPixelsSize();
 106 extern int _GetVRAMVPixelsSize();
 107 
 108 int vid_get_viewport_width_proper() { 
 109     return ((mode_get()&MODE_MASK) == MODE_PLAY)?720:_GetVRAMHPixelsSize();
 110 }
 111 int vid_get_viewport_height_proper() {
 112     return ((mode_get()&MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize();
 113 }

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