root/platform/sx130is/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. debug_led
  2. debug_wait
  3. debug_blink
  4. debug_blink_red
  5. vid_bitmap_refresh
  6. shutdown
  7. camera_set_led
  8. get_flash_params_count
  9. JogDial_CW
  10. JogDial_CCW
  11. vid_get_palette_type
  12. vid_get_palette_size
  13. vid_get_bitmap_active_buffer
  14. vid_get_bitmap_active_palette

   1 /*
   2 *********************
   3 SX130IS
   4 ********************** 
   5 */
   6 
   7 /*
   8 SX130
   9 LED address:
  10 same as sx210
  11 orange 0xC0220010
  12 green  0xC0220014
  13 AF      0xC022000C
  14 */
  15 #define LED_AF          0xC022000C
  16 #define LED_ORANGE      0xC0220010
  17 #define LED_GREEN       0xC0220014
  18 
  19 #define DELAY 300000
  20 
  21 #define LED_ON          *((long*) LED_GREEN) = 0x46
  22 #define LED_OFF         *((long*) LED_GREEN) = 0x44
  23 
  24 #define LED_ON_RED              *((long*) LED_ORANGE) = 0x46
  25 #define LED_OFF_RED             *((long*) LED_ORANGE) = 0x44
  26 
  27 #define LED_ON_AF               *((long*) LED_AF) = 0x46
  28 #define LED_OFF_AF              *((long*) LED_AF) = 0x44
  29 
  30 void debug_led(int state)
  31 {
  32     if (state)
  33                 LED_ON;
  34     else
  35                 LED_OFF;
  36 } 
  37 
  38 void debug_wait()
  39 {
  40         int counter;
  41 
  42         counter = DELAY; 
  43         while (counter--) { asm("nop\n nop\n"); };
  44 }
  45 
  46 
  47 void debug_blink()
  48 {
  49         //led on
  50         LED_ON;
  51         debug_wait();
  52 
  53         //led off
  54         LED_OFF;
  55         debug_wait();
  56 }
  57 
  58 void debug_blink_red()
  59 {
  60         //led on
  61         LED_ON_RED;
  62         debug_wait();
  63 
  64         //led off
  65         LED_OFF_RED;
  66         debug_wait();
  67 }
  68 
  69 
  70 /*      
  71 void debug_my_blink()
  72 {
  73         volatile long *p = (void*)LED_GREEN;                    // turned off later, so assumed to be power
  74         volatile long *p2 = (void*)LED_AF;                      // turned off later, so assumed to be power
  75         int counter;
  76 
  77         // DEBUG: blink led
  78         //led on
  79         counter = DELAY; 
  80         *p = 0x46; 
  81         while (counter--) { asm("nop\n nop\n"); };
  82         *p2 = 0x46;
  83         //led off
  84         counter = DELAY; 
  85         *p = 0x44; 
  86         while (counter--) { asm("nop\n nop\n"); };
  87         *p2= 0x44;
  88         
  89 }
  90 */ 
  91 
  92 #include "platform.h"
  93 #include "lolevel.h"
  94 
  95 /*
  96 void vid_bitmap_refresh()
  97 {
  98          extern int enabled_refresh_physical_screen; // screen lock counter
  99          extern void _ScreenUnlock();
 100 
 101 //     _LockAndRefresh();
 102          _ScreenLock();
 103         enabled_refresh_physical_screen=1;
 104 //      full_screen_refresh=3; //found in ScreenUnlock underneath a CameraLog.c call sub_FFA02598       //sx210
 105         _ScreenUnlock();
 106 //      _UnlockAndRefresh();    
 107 }
 108 */
 109 
 110 // Testing another refresh method
 111 void vid_bitmap_refresh()
 112 {
 113         extern int enabled_refresh_physical_screen;
 114         extern int full_screen_refresh;
 115 
 116         // i've tried refreshphysical screen (screen unlock) and that caused the canon and
 117         // function menu to not display at all. This seems to work and is called in a similar
 118         // way in other places where original OSD should be refreshed.
 119         extern void _LockAndRefresh(); // wrapper function for screen lock
 120         extern void _UnlockAndRefresh(); // wrapper function for screen unlock
 121 
 122         _LockAndRefresh();
 123 
 124         enabled_refresh_physical_screen=1;
 125         full_screen_refresh |= 3; 
 126 
 127         _UnlockAndRefresh();
 128 }
 129 
 130 void shutdown()
 131 {
 132         volatile long *p = (void*)0xC022001C;    
 133         
 134         asm(
 135                 "MRS     R1, CPSR\n"
 136                 "AND     R0, R1, #0x80\n"
 137                 "ORR     R1, R1, #0x80\n"
 138                 "MSR     CPSR_cf, R1\n"
 139                 :::"r1","r0");
 140         
 141         *p = 0x44;  // power off.
 142         
 143         while(1);
 144 }
 145 
 146 
 147 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
 148  static char led_table[3]={0,1,9};
 149  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
 150 }
 151 
 152 int get_flash_params_count(void){
 153  return 0x9a; 
 154 }
 155 
 156 void JogDial_CW(void){
 157  _PostLogicalEventForNotPowerType(0x874, 1);  // RotateJogDialRight
 158 }
 159 
 160 void JogDial_CCW(void){
 161  _PostLogicalEventForNotPowerType(0x875, 1);  // RotateJogDialLeft
 162 }
 163 
 164 
 165 #if defined(CAM_CHDK_PTP_LIVE_VIEW)
 166 // Functions for PTP Live View system
 167 
 168 int vid_get_palette_type()                      { return 3; }
 169 int vid_get_palette_size()                      { return 256 * 4; }
 170 
 171 void *vid_get_bitmap_active_buffer()
 172 {
 173     extern int active_bitmap_buffer;
 174     extern char* bitmap_buffer[];
 175     return bitmap_buffer[active_bitmap_buffer];
 176 }
 177 
 178 void *vid_get_bitmap_active_palette()
 179 {
 180     extern int active_palette_buffer;
 181     extern char* palette_buffer[];
 182     void* p = palette_buffer[active_palette_buffer];
 183     // Don't add offset if value is 0
 184     if (p) p += 8;
 185     return p;
 186 }
 187 #endif

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