root/platform/ixus990_sd970/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. vid_bitmap_refresh
  2. shutdown
  3. debug_led
  4. get_flash_params_count
  5. camera_set_led
  6. JogDial_CW
  7. JogDial_CCW
  8. load_chdk_palette
  9. vid_get_viewport_width_proper
  10. vid_get_viewport_height_proper
  11. vid_get_viewport_width
  12. vid_get_viewport_height
  13. vid_get_viewport_fullscreen_width
  14. vid_get_viewport_fullscreen_height
  15. vid_get_palette_type
  16. vid_get_palette_size
  17. vid_get_bitmap_active_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 void vid_bitmap_refresh()
   6 {
   7         _ScreenLock();
   8     _RefreshPhysicalScreen(1);
   9 }
  10 
  11 void shutdown()
  12 {
  13     volatile long *p = (void*)0xc022001C; // from task_by (not really complete)
  14 
  15     asm(
  16          "MRS     R1, CPSR\n"
  17          "AND     R0, R1, #0x80\n"
  18          "ORR     R1, R1, #0x80\n"
  19          "MSR     CPSR_cf, R1\n"
  20          :::"r1","r0");
  21 
  22     *p = 0x44;
  23 
  24     while(1);
  25 }
  26 
  27 // found at 0xff8d03f0 for sd970 which matched 0xff8cab9c on sd780 which referenced to 0xc0220128 originally
  28 #define LED_PR 0xC0220134
  29 
  30 void debug_led(int state)
  31 {
  32     volatile long *p=(void*)LED_PR;
  33     if (state)
  34         p[0]=0x46;
  35     else
  36         p[0]=0x44;
  37 }
  38 
  39 int get_flash_params_count(void) { return 0x7a; }  // sd970: Found @0xff94ce88
  40 // values for sd970 found by experiment in CHDKPTP
  41 // using "=set_led(0,1)"  first parameter: LED number, second: state of the LED: 1 on, 0 off, others blink
  42 void camera_set_led(int led, int state, int bright) {
  43  static char led_table[]={0, // green
  44                           1, // orange, right
  45                           2, // yellow, left
  46                           // 3,4,5,6,7,
  47                           8, // blue
  48                           9 // af
  49                           };
  50  if((unsigned)led < sizeof(led_table))
  51   _LEDDrive(led_table[led], state<=1 ? !state : state);
  52 // _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  53 }
  54 
  55 // 0x874 and 0x875 values may be camera model dependent, search them in firmware (in pair with RotateJogDialRight(Left)) strings.
  56 // sd970: table "PrintMenu" @ ffb8060e, fw 1.00A
  57 void JogDial_CW(void){
  58  _PostLogicalEventForNotPowerType(0x874, 1);  // sd970: RotateJogDialRight (in table "PrintMenu" @ ffb81b5a, fw 1.00A)
  59 }
  60 void JogDial_CCW(void){
  61  _PostLogicalEventForNotPowerType(0x875, 1);  // sd970: RotateJogDialLeft (in table "PrintMenu" @ ffb81ad3, fw 1.00A)
  62 }
  63 
  64 // sd970: The palette replaces the hues of blue used for gradients on menu buttons
  65 // that works consistently though Rec / Func, Play and Canon Menu have no CHDK Palette
  66 void load_chdk_palette()
  67 {
  68     extern int active_palette_buffer;
  69 
  70     if ((active_palette_buffer == 0) || (active_palette_buffer == 1)) 
  71     {
  72         int *pal = (int*)vid_get_bitmap_active_palette();
  73         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
  74         {
  75             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
  76             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
  77             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
  78             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
  79             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
  80             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
  81             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
  82             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
  83             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
  84             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
  85             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
  86             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
  87             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
  88             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
  89 
  90             vid_bitmap_refresh();
  91         }
  92     }
  93 }
  94 
  95 // Viewport and Bitmap values that shouldn't change across firmware versions.
  96 // Values that may change are in lib.c for each firmware version.
  97 extern int _GetVRAMHPixelsSize();
  98 extern int _GetVRAMVPixelsSize();
  99 
 100 // Fixes 320 Video for CHDKPTP, maybe more?
 101 int vid_get_viewport_width_proper() {
 102     return ((mode_get()&MODE_MASK) == MODE_PLAY)?720:_GetVRAMHPixelsSize();
 103 }
 104 int vid_get_viewport_height_proper() {
 105     return ((mode_get()&MODE_MASK) == MODE_PLAY)?480:_GetVRAMVPixelsSize();
 106 }
 107 
 108 int vid_get_viewport_width() { return vid_get_viewport_width_proper(); }
 109 long vid_get_viewport_height() { return vid_get_viewport_height_proper(); }
 110 //I don't know if these get used
 111 int vid_get_viewport_fullscreen_width() { return vid_get_viewport_width_proper(); }
 112 int vid_get_viewport_fullscreen_height() { return vid_get_viewport_height_proper(); }
 113 
 114 
 115 // sd970: PTP display stuff
 116 int vid_get_palette_type() { return 3; }
 117 int vid_get_palette_size() { return 256 * 4; }
 118 
 119 void *vid_get_bitmap_active_palette()
 120 {
 121     extern int active_palette_buffer;
 122     extern char** palette_buffer_ptr;
 123     return palette_buffer_ptr[active_palette_buffer]+12;
 124 }

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