root/platform/g10/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_viewport_width
  9. vid_get_viewport_height
  10. vid_get_viewport_yscale
  11. vid_get_palette_type
  12. vid_get_palette_size
  13. vid_get_viewport_height_proper
  14. vid_get_viewport_fullscreen_height
  15. vid_get_bitmap_active_palette
  16. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 void vid_bitmap_refresh()    // G10 : ixus980_sd990 version seems to work well
   6 {
   7         _ScreenLock();
   8     _RefreshPhysicalScreen(1);
   9 }
  10 
  11 
  12 void shutdown()    // G10 sub_FF829EC8
  13 {
  14         volatile long *p = (void*)0xC022001C;    // G10 @ 0xFF829EE4,0xFF829EE8 & 0xFF829EEC 
  15         
  16         asm(
  17                 "MRS     R1, CPSR\n"
  18                 "AND     R0, R1, #0x80\n"
  19                 "ORR     R1, R1, #0x80\n"
  20                 "MSR     CPSR_cf, R1\n"
  21                 :::"r1","r0");
  22         
  23         *p = 0x44;  // power off.
  24         
  25         while(1);
  26 }
  27 
  28 
  29 // 0xC02200D0  G10 ISO select dial LED
  30 // 0xC02200D4  G10 direct print button LED
  31 // 0xC02200D8  G10 exposure compensation dial LED
  32 // 0xC02200DC  G10 power LED
  33 // 0xC0220130  G10 Upper Indicator Orange (looks yellow if both upper indicators lit)
  34 // 0xC0220134  G10 Upper Indicator Green
  35 // 0xC0220138  G10 Lower Indicator Yellow
  36 #define LED_PR  0xC02200D4      //  G10 direct print button LED
  37 
  38 void debug_led(int state)
  39 {
  40   *(int*)LED_PR=state ? 0x46 : 0x44;
  41 }
  42 
  43 // G10 has 8 led values - tested with uBasic  set_led n, 1   (no brightness control implemented)
  44 // set_led led_table  LED
  45 // ======= =========  =====================
  46 //   0         0      Upper indicator Green
  47 //   1         1      Upper indicator Orange
  48 //   2         2      Lower indicator Yellow
  49 //   3         3      Power LED Green
  50 //   4         8      Blue print button LED
  51 //   5         9      AF Assist Lamp (also index 9&10)
  52 //   6         14     ISO LED
  53 //   7         15     EV LED
  54 
  55 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  56  static char led_table[8]={0,1,2,3,8,9,14,15};
  57  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  58 }
  59 
  60 int get_flash_params_count(void){
  61  return 0x78 ;          // G10 per SD990 & finsig2 - _sub_FF971C10__PropertyTableManagerCore.c__6 value at 0xff971c50 in 1.02a
  62  // found in GetParameterData
  63 }
  64 
  65 void JogDial_CW(void){
  66  _PostLogicalEventForNotPowerType(0x874, 1);  // RotateJogDialRight (G10 1.02A table @ FFB43EEC)
  67 }
  68 
  69 void JogDial_CCW(void){
  70  _PostLogicalEventForNotPowerType(0x875, 1);  // RotateJogDialLeft (G10 1.02A table @ FFB43EF8)
  71 }
  72 
  73 // Viewport and Bitmap values that shouldn't change across firmware versions.
  74 // Values that may change are in lib.c for each firmware version.
  75 
  76 int vid_get_viewport_width()
  77 {
  78         return 360 ;   //  G10
  79 }
  80 
  81 long vid_get_viewport_height()
  82 {
  83    return 240;    //  G10
  84 }
  85 
  86 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  87 int vid_get_viewport_yscale() {
  88         return 2;               // G10 viewport is 480 pixels high
  89 }
  90 
  91 // looks like 256 byte from sub_FF8F3270
  92 int vid_get_palette_type() { return 3; }
  93 int vid_get_palette_size() { return 256*4; }
  94 
  95 // TODO actual value probably varies in some cases
  96 int vid_get_viewport_height_proper() { return 480; }
  97 int vid_get_viewport_fullscreen_height() { return 480; }
  98 
  99 void *vid_get_bitmap_active_palette()
 100 {
 101     extern int active_palette_buffer;
 102     extern char** palette_buffer_ptr;
 103     return palette_buffer_ptr[active_palette_buffer]+16;
 104 }
 105 
 106 void load_chdk_palette()
 107 {
 108     extern char** palette_buffer_ptr;
 109     extern int active_palette_buffer;
 110 
 111     if ((active_palette_buffer == 0) || (active_palette_buffer == 1))
 112     {
 113         int *pal = (int*)vid_get_bitmap_active_palette();
 114         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 115         {
 116             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 117             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 118             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 119             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 120             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 121             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 122             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 123             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 124             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 125             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 126             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 127             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 128             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 129             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 130 
 131             // extern char palette_control;
 132             // palette_control = 1;
 133             vid_bitmap_refresh();
 134         }
 135     }
 136 }
 137 

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