root/platform/ixus120_sd940/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. camera_jpeg_count_str
  2. vid_bitmap_refresh
  3. shutdown
  4. debug_led
  5. camera_set_led
  6. get_flash_params_count
  7. vid_turn_off_updates
  8. vid_turn_on_updates
  9. vid_get_viewport_width
  10. vid_get_viewport_height
  11. vid_get_palette_type
  12. vid_get_palette_size
  13. vid_get_bitmap_active_palette
  14. vid_get_bitmap_active_buffer
  15. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_GREEN  0xC0220130
   6 #define LED_ORANGE 0xC0220134
   7 #define LED_AF     0xC0223030
   8 
   9 char *camera_jpeg_count_str()
  10 {
  11     extern char jpeg_count_str[];
  12         return jpeg_count_str;
  13 }
  14 
  15 extern int enabled_refresh_physical_screen;
  16 
  17 void vid_bitmap_refresh()
  18 {
  19         enabled_refresh_physical_screen=1;
  20         
  21         *(int*)0x8BB0=3;        // apparently not firmware specific (checked in 1.02c,1.03b,1.03c)
  22                                                 // set in three function called by RefreshPhysicalScreen
  23 
  24         _RefreshPhysicalScreen(1);
  25 
  26 }
  27 
  28 
  29 void shutdown()
  30 {
  31         volatile long *p = (void*)LED_AF;
  32 
  33         asm(
  34                 "MRS     R1, CPSR\n"
  35                 "AND     R0, R1, #0x80\n"
  36                 "ORR     R1, R1, #0x80\n"
  37                 "MSR     CPSR_cf, R1\n"
  38                 :::"r1","r0");
  39 
  40         *p = 0x44;  // power off.
  41 
  42         while(1);
  43 }
  44 
  45 
  46 void debug_led(int state)
  47 {
  48  *(int*)LED_ORANGE=state ? 0x46 : 0x44;
  49 }
  50 
  51 // ixus120_sd940 has three LEDs - a dual LED green/orange on back panel and an AF led above lens
  52 
  53 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  54  static char led_table[3]={0,1,9};
  55  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  56 }
  57 
  58 int get_flash_params_count(void){
  59  return 120;
  60 }
  61 
  62 void vid_turn_off_updates()
  63 {
  64   _ScreenLock();
  65 }
  66 
  67 void vid_turn_on_updates()
  68 {
  69   _RefreshPhysicalScreen(1);
  70 }
  71 
  72 int vid_get_viewport_width()
  73 {
  74         return 360;
  75 }
  76 
  77 long vid_get_viewport_height()          
  78 {               
  79         return 240;
  80 }               
  81 
  82 // Functions for PTP Live View system
  83 int vid_get_palette_type()                      { return 3 ; }          // 1,2,3,4,or 5
  84 int vid_get_palette_size()                      { return 256 * 4 ; }    // 16*4 or 256*4
  85 
  86 void *vid_get_bitmap_active_palette()
  87 {
  88     extern int active_palette_buffer;
  89     extern char** palette_buffer_ptr;
  90     return palette_buffer_ptr[active_palette_buffer]+8;
  91 }
  92 
  93 void *vid_get_bitmap_active_buffer()
  94 {
  95     return (void*)(*(int*)(0x53dc+0x18)); //"Add: %p Width : %ld Hight : %ld", 
  96                                           //       100e: sub_ff8f290c
  97                                           // 101a, 102c: sub_ff8f2928
  98                                           //      103b : sub_ff8f2934
  99                                           //      103c : sub_ff8f2984
 100 }
 101 
 102 
 103 void load_chdk_palette()
 104 {
 105     extern char** palette_buffer_ptr;
 106     extern int active_palette_buffer;
 107 
 108     if ((active_palette_buffer == 0) || (active_palette_buffer == 5)|| (active_palette_buffer == 8))  // Note : palette 4 (Canon Set Button Menu) colors conflict so not included here
 109     {
 110         int *pal = (int*)vid_get_bitmap_active_palette();
 111         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 112         {
 113             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 114             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 115             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 116             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 117             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 118             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 119             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 120             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 121             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 122             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 123             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 124             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 125             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 126             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 127 
 128             vid_bitmap_refresh();
 129         }
 130     }
 131 }
 132 

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