root/platform/sx210is/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_byte_width
  9. vid_get_viewport_width
  10. vid_get_viewport_display_xoffset
  11. vid_get_viewport_height
  12. vid_get_viewport_display_yoffset
  13. vid_get_viewport_buffer_width_proper
  14. vid_get_palette_type
  15. vid_get_palette_size
  16. vid_get_aspect_ratio
  17. vid_get_viewport_width_proper
  18. vid_get_viewport_height_proper
  19. vid_get_viewport_live_fb
  20. vid_get_bitmap_active_palette

   1 #include "platform.h"
   2 #include "lolevel.h"
   3 
   4 /*
   5 void vid_bitmap_refresh() //ASM1989
   6 {
   7  extern int enabled_refresh_physical_screen;
   8  enabled_refresh_physical_screen=1;
   9  *(int*)0x9D08=3;//this is set somewhere in a function called by RefreshPhysicalScreen, should be easy to find
  10  _RefreshPhysicalScreen(1);
  11 }
  12 
  13 */
  14 
  15 
  16 void vid_bitmap_refresh()
  17 {
  18         extern int enabled_refresh_physical_screen;
  19         extern int full_screen_refresh;
  20 
  21         // i've tried refreshphysical screen (screen unlock) and that caused the canon and
  22         // function menu to not display at all. This seems to work and is called in a similar
  23         // way in other places where original OSD should be refreshed.
  24         extern void _LockAndRefresh(); // wrapper function for screen lock
  25         extern void _UnlockAndRefresh(); // wrapper function for screen unlock
  26 
  27         _LockAndRefresh();
  28 
  29         enabled_refresh_physical_screen=1;
  30         full_screen_refresh=3; //found in ScreenUnlock underneath a CameraLog.c call sub_FFA02598
  31 
  32         _UnlockAndRefresh();
  33 }
  34 
  35 
  36 
  37 
  38 void shutdown()
  39 {
  40         volatile long *p = (void*)0xC022001C;
  41 
  42         asm(
  43                 "MRS     R1, CPSR\n"
  44                 "AND     R0, R1, #0x80\n"
  45                 "ORR     R1, R1, #0x80\n"
  46                 "MSR     CPSR_cf, R1\n"
  47                 :::"r1","r0");
  48 
  49         *p = 0x44;  // power off.
  50 
  51         while(1);
  52 }
  53 
  54 #define LED_PR 0xC0220130    // -> C0223030 front led ASM1989 08.24.2010 found at  FF8E73F0  in sx200 was FF91E09C
  55 
  56 
  57 void debug_led(int state)
  58 {
  59  *(int*)LED_PR=state ? 0x46 : 0x44;
  60 }
  61 
  62 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  63  static char led_table[5]={4,5,7,8,9};
  64  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  65 }
  66 
  67 int get_flash_params_count(void){
  68  return 120;
  69 }
  70 
  71 void JogDial_CW(void){
  72  _PostLogicalEventForNotPowerType(0x876, 2);  // RotateJogDialRight
  73 }
  74 
  75 void JogDial_CCW(void){
  76  _PostLogicalEventForNotPowerType(0x877, 2);  // RotateJogDialLeft
  77 }
  78 
  79 
  80 //ASm1989 like sx30 testing
  81 
  82 // Viewport and Bitmap values that shouldn't change across firmware versions.
  83 // Values that may change are in lib.c for each firmware version.
  84 
  85 // Physical width of viewport row in bytes
  86 int vid_get_viewport_byte_width() {
  87         return 960 * 6 / 4;     // SX210IS - wide screen LCD is 960 pixels wide, each group of 4 pixels uses 6 bytes (UYVYYY)
  88 }
  89 
  90 //This cam is 0 -> 16:9,  1 -> 4:3
  91 
  92 int vid_get_viewport_width()
  93 {
  94         // viewport width table for each image size
  95         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
  96         //static long vp_w[5] = { 480, 360, 360, 272, 216 };
  97         
  98         // 0 = 16:9, 1 = 4:3
  99         // somehow, prop PROPCASE_ASPECT_RATIO doesn't work
 100         //static long vp_w[5] =  { 480, 360, 360, 272, 216 };
 101         //return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 102         
 103         // if widescreen, photo and video modes
 104         if( ( (shooting_get_prop(PROPCASE_RESOLUTION) == 8) && (!MODE_IS_VIDEO(mode_get())) ) ||
 105             ( (MODE_IS_VIDEO(mode_get())) && (shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 4) ) )
 106                 return 480;
 107         else
 108                 return 360;
 109 }
 110 
 111 int vid_get_viewport_display_xoffset()
 112 {
 113         // viewport width offset table for each image size
 114         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
 115         //static long vp_w[5] = { 0, 60, 0, 44, 72 };
 116         
 117         // 0 = 16:9, 1 = 4:3
 118         // see vid_get_viewport_width()
 119         //static long vp_w[5] = { 0, 60, 0, 44, 72 };                           // should all be even values for edge overlay
 120         //return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 121 
 122         // if widescreen, photo and video modes
 123         if( ( (shooting_get_prop(PROPCASE_RESOLUTION) == 8) && (!MODE_IS_VIDEO(mode_get())) ) ||
 124             ( (MODE_IS_VIDEO(mode_get())) && (shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 4) ) )
 125                 return 0;
 126         else
 127                 return 60;
 128 }
 129 
 130 long vid_get_viewport_height()
 131 {
 132         // viewport height table for each image size
 133         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
 134         //static long vp_h[5] = { 240, 240, 214, 240, 240 };
 135         //return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 136         // is always 240 on sx210is
 137         return 240;
 138 }
 139 
 140 int vid_get_viewport_display_yoffset()
 141 {
 142         // viewport height offset table for each image size
 143         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
 144         //static long vp_h[5] = { 0, 0, 13, 0, 0 };
 145         //return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 146         return 0;
 147 }
 148 
 149 int vid_get_viewport_buffer_width_proper()      { return 960; }
 150 int vid_get_palette_type()                      { return 3; }
 151 int vid_get_palette_size()                      { return 256 * 4; }
 152 int vid_get_aspect_ratio()                      { return 1; }
 153 extern int _GetVRAMHPixelsSize();
 154 extern int _GetVRAMVPixelsSize();
 155 
 156 int vid_get_viewport_width_proper() {
 157     return ((mode_get()&MODE_MASK) == MODE_PLAY)?960:_GetVRAMHPixelsSize();
 158 }
 159 
 160 int vid_get_viewport_height_proper() {
 161     return ((mode_get()&MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize();
 162 }
 163 
 164 // Defined in stubs_min.S
 165 extern char active_viewport_buffer;
 166 extern void* viewport_buffers[];
 167 
 168 void *vid_get_viewport_live_fb()
 169 {
 170 /*
 171 ffb64808: 0x40547700
 172 ffb6480c: 0x405c6000
 173 ffb64810: 0x40644900
 174 ffb64814: 0x409de0d0
 175 ffb64818: 0x417f4030
 176 ffb6481c: 0x41872930
 177 ffb64820: 0x418f1230
 178 ffb64824: 0x4196fb30
 179 */
 180     unsigned char buff = active_viewport_buffer;
 181     if (buff == 0) {
 182         buff = 2;
 183     }
 184     else {
 185         buff--;
 186     }
 187     return viewport_buffers[buff];
 188 }
 189 
 190 void *vid_get_bitmap_active_palette()
 191 {
 192     extern int active_palette_buffer;
 193     extern int** palette_buffer_ptr;
 194     return (palette_buffer_ptr[active_palette_buffer]+0x3);
 195 }

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