root/platform/s100/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. shutdown_soft
  6. JogDial_CW
  7. JogDial_CCW
  8. vid_get_viewport_live_fb
  9. vid_get_viewport_yscale
  10. vid_get_viewport_width
  11. vid_get_viewport_xoffset
  12. vid_get_viewport_display_xoffset
  13. vid_get_viewport_height
  14. vp_yoffset
  15. vid_get_viewport_yoffset
  16. vid_get_viewport_display_yoffset
  17. vid_get_viewport_display_xoffset_proper
  18. vid_get_viewport_display_yoffset_proper
  19. vid_get_viewport_height_proper
  20. vid_get_viewport_fullscreen_height
  21. vid_get_palette_type
  22. vid_get_palette_size
  23. vid_get_bitmap_active_buffer
  24. vid_get_bitmap_active_palette
  25. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 static char*    frame_buffer[2];
   6 
   7 void vid_bitmap_refresh()
   8 {
   9         extern int full_screen_refresh;
  10         extern void _ScreenUnlock();
  11         extern void _ScreenLock();
  12 
  13         full_screen_refresh |= 3;
  14         _ScreenLock();
  15         _ScreenUnlock();
  16 }
  17 
  18 void shutdown()
  19 {
  20         volatile long *p = (void*)0xC022001C;
  21 
  22         asm(
  23                 "MRS     R1, CPSR\n"
  24                 "AND     R0, R1, #0x80\n"
  25                 "ORR     R1, R1, #0x80\n"
  26                 "MSR     CPSR_cf, R1\n"
  27                 :::"r1","r0");
  28 
  29         *p = 0x44;  // power off.
  30 
  31         while(1);
  32 }
  33 
  34 #define LED_PR 0xC022C30C       // Power LED (@FF15B178 & @FF15B1CC)
  35 
  36 void debug_led(int state)
  37 {
  38         // using power LED, which defaults to on
  39         // for debugging turn LED off if state is 1 and on for state = 0
  40         // leaves LED on at end of debugging
  41     volatile long *p = (void*)LED_PR;
  42     *p = (*p & 0xFFFFFFCF) | ((state) ? 0x00 : 0x20);
  43 }
  44 
  45 // S100 has two 'lights' - Power LED, and AF assist lamp
  46 // Power Led = first entry in table (led 0)
  47 // AF Assist Lamp = second entry in table (led 1)
  48 void camera_set_led(int led, int state, int bright) {
  49  static char led_table[2]={7,10};
  50  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  51 }
  52 
  53 void shutdown_soft()
  54 {
  55    _PostLogicalEventForNotPowerType(0x1005,0);
  56 }
  57 
  58 void JogDial_CW(void){
  59         _PostLogicalEventToUI(0x872, 1);  // RotateJogDialRight (levent_table)
  60 }
  61 
  62 void JogDial_CCW(void){
  63         _PostLogicalEventToUI(0x873, 1);  // RotateJogDialLeft (levent_table)
  64 }
  65 
  66 void *vid_get_viewport_live_fb() // use sigfinder's address
  67 {
  68     return vid_get_viewport_fb();
  69 }
  70 
  71 // Defined in stubs_min.S
  72 extern int active_bitmap_buffer;
  73 extern char* bitmap_buffer[];
  74 
  75 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  76 int vid_get_viewport_yscale() {
  77         return 2;
  78 }
  79 
  80 int vid_get_viewport_width()
  81 {
  82     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  83     {
  84         return 360;
  85     }
  86     extern int _GetVRAMHPixelsSize();
  87     return _GetVRAMHPixelsSize() >> 1;
  88 }
  89 
  90 // viewport width offset table for each image size
  91 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
  92 static long vp_xo[5] = { 0, 0, 0, 44, 72 };                             // should all be even values for edge overlay
  93 
  94 int vid_get_viewport_xoffset()
  95 {
  96     if ((mode_get() & MODE_MASK) == MODE_PLAY)
  97     {
  98         return 0;
  99     }
 100     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16909) // Stitch mode
 101     {
 102         return 0;
 103     }
 104     else
 105     {
 106         return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 107     }
 108 }
 109 
 110 int vid_get_viewport_display_xoffset()
 111 {
 112     if ((mode_get() & MODE_MASK) == MODE_PLAY)
 113     {
 114         return 0;
 115     }
 116     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16909) // Stitch mode
 117     {
 118         if (shooting_get_prop(PROPCASE_STITCH_DIRECTION) == 0)      // Direction check
 119             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 120                 return 40;
 121             else
 122                 return 140;
 123         else
 124             if (shooting_get_prop(PROPCASE_STITCH_SEQUENCE) == 0)   // Shot already taken?
 125                 return 140;
 126             else
 127                 return 40;
 128     }
 129     else
 130     {
 131         return vp_xo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 132     }
 133 }
 134 
 135 long vid_get_viewport_height()
 136 {
 137     if ((mode_get() & MODE_MASK) == MODE_PLAY)
 138     {
 139         return 240;
 140     }
 141     extern int _GetVRAMVPixelsSize();
 142     return _GetVRAMVPixelsSize() >> 1;
 143 }
 144 
 145 static int vp_yoffset(int stitch)
 146 {
 147     // viewport height offset table for each image size
 148     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1, 4 = 4:5
 149     static long vp_yo[5] = { 0, 30, 13, 0, 0 };
 150 
 151     int m = mode_get();
 152     if ((m & MODE_MASK) == MODE_PLAY)
 153     {
 154         return 0;
 155     }
 156     else if (shooting_get_prop(PROPCASE_SHOOTING_MODE) == 16908) // Stitch mode
 157     {
 158         return stitch;
 159     }
 160     else if (mode_is_video(m))
 161     {
 162         return 30;
 163     }
 164     else
 165     {
 166             return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 167     }
 168 }
 169 
 170 int vid_get_viewport_yoffset()
 171 {
 172     return vp_yoffset(0);
 173 }
 174 
 175 int vid_get_viewport_display_yoffset()
 176 {
 177     return vp_yoffset(72);
 178 }
 179 
 180 // Functions for PTP Live View system
 181 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() * 2; }
 182 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() * 2; }
 183 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * 2; }
 184 int vid_get_viewport_fullscreen_height()        { return 480; }
 185 int vid_get_palette_type()                      { return 5; }
 186 int vid_get_palette_size()                      { return 256 * 4; }
 187 
 188 void *vid_get_bitmap_active_buffer()
 189 {
 190     return bitmap_buffer[active_bitmap_buffer];
 191 }
 192 
 193 void *vid_get_bitmap_active_palette()
 194 {
 195      extern int active_palette_buffer;
 196      extern char* palette_buffer[];
 197      return (palette_buffer[active_palette_buffer]+4);
 198 }
 199 
 200 // Function to load CHDK custom colors into active Canon palette
 201 void load_chdk_palette()
 202 {
 203     extern int active_palette_buffer;
 204     // Only load for the standard record and playback palettes
 205     if ((active_palette_buffer == 0) || (active_palette_buffer == 3))
 206     {
 207         int *pal = (int*)vid_get_bitmap_active_palette();
 208         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 209         {
 210             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 211             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 212             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 213             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 214             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 215             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 216             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 217             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 218             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 219             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 220             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 221             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 222             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 223             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 224 
 225             extern char palette_control;
 226             palette_control = 1;
 227             vid_bitmap_refresh();
 228         }
 229     }
 230 }

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