root/platform/ixus110_sd960/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. vid_get_viewport_width_proper
  9. vid_get_viewport_height_proper
  10. vid_get_viewport_byte_width
  11. vid_get_viewport_height
  12. vid_get_viewport_width
  13. vid_get_viewport_display_xoffset
  14. vid_get_viewport_fullscreen_height
  15. vid_get_viewport_buffer_width_proper
  16. vid_get_palette_type
  17. vid_get_palette_size
  18. vid_get_aspect_ratio
  19. vid_get_bitmap_active_palette
  20. load_chdk_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 
  28 #define LED_PR 0xc0220130 // green? LED, other (red?) is 0xc0220134
  29 
  30 void debug_led(int state) //mix orange instead of the boring green
  31 {
  32     volatile long *p=(void*)LED_PR;
  33     if (state)
  34         p[0]=p[1]=0x46;
  35     else
  36         p[0]=p[1]=0x44;
  37 }
  38 
  39 int get_flash_params_count(void){
  40  return 0x7a;
  41 }
  42 
  43 //TODO ixus110
  44 /*
  45 D10 has 3 led values
  46 0/0 - Upper indicator Green
  47 1/1 - Upper indicator Orange
  48 2/9 - AF
  49 10-11 appears to also drive AF, but using the same codepath as non AF leds (no assert on invalid)
  50 note, LEDDrive returns 3 on invalid params otherwise 0
  51 second param 0 = solid on, 1 = off, 2-7 blink patterns
  52 2: continuous ~1 blink/sec
  53 3: continuous fast blink
  54 4: continuous medium blink (2/sec ?) 
  55 5: burst of 3? fast blinks
  56 6: continuous slow blinks
  57 7: if led was off 1 very fast blink. depends on previous state
  58 8: no obvious effect, but returns 0 for AF
  59 >8: If used with AF ASSERT!! LEDDrv.c Line 215, otherwise returns 3
  60 */
  61 void camera_set_led(int led, int state, int bright) {
  62  static char led_table[]={0,1,9};
  63  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  64 }
  65 
  66 void JogDial_CW(void){
  67  _PostLogicalEventForNotPowerType(0x874, 2);  // RotateJogDialRight
  68 }
  69 
  70 void JogDial_CCW(void){
  71  _PostLogicalEventForNotPowerType(0x875, 2);  // RotateJogDialLeft
  72 }
  73 
  74 
  75 extern int _GetVRAMHPixelsSize();
  76 extern int _GetVRAMVPixelsSize();
  77 
  78 int vid_get_viewport_width_proper() { 
  79     return ((mode_get()&MODE_MASK) == MODE_PLAY)?960:_GetVRAMHPixelsSize();
  80 }
  81 
  82 int vid_get_viewport_height_proper() {
  83     return ((mode_get()&MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize();
  84 }
  85 /*
  86 int vid_get_viewport_fullscreen_height() {
  87     // except for stitch, always full screen
  88     int m = mode_get();
  89     if((m&MODE_MASK) != MODE_PLAY && (m&MODE_SHOOTING_MASK) == MODE_STITCH) {
  90         return 240;
  91     }
  92     return vid_get_viewport_height_proper();
  93 }
  94 int vid_get_viewport_fullscreen_width() {
  95     // except for stitch, always full screen
  96     int m = mode_get();
  97     if((m&MODE_MASK) != MODE_PLAY && (m&MODE_SHOOTING_MASK) == MODE_STITCH) {
  98         return 960;
  99     }
 100     return vid_get_viewport_width_proper();
 101 }*/
 102 
 103 // Physical width of viewport row in bytes, needs to be implemented for wide displays
 104 int vid_get_viewport_byte_width() {
 105     return 960 * 6 / 4;
 106 } 
 107 
 108 
 109 long vid_get_viewport_height()
 110 {
 111     return 240;
 112 }
 113 /*
 114 [0x4610] 0 when wide screen, 1 when 4:3 with side bars
 115 */
 116 int vid_get_viewport_width() // based on: http://chdk.setepontos.com/index.php?topic=5045.msg94252#msg94252
 117 {
 118     int modegot = mode_get();
 119     if( (modegot & MODE_MASK) == MODE_PLAY ) {
 120         return 480;
 121     }
 122     // if widescreen, photo and video modes
 123     if( ( ( shooting_get_prop(PROPCASE_RESOLUTION) == 8 ) && ( !MODE_IS_VIDEO(modegot) ) ) ||
 124         ( ( MODE_IS_VIDEO(modegot) ) && ( shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 4 ) ) )
 125         return 480;
 126     else
 127         return 360;
 128 } 
 129 
 130 int vid_get_viewport_display_xoffset()
 131 {
 132     int modegot = mode_get();
 133     if( (modegot & MODE_MASK) == MODE_PLAY ) {
 134         return 0;
 135     }
 136     // if widescreen, photo and video modes
 137     if( ( ( shooting_get_prop(PROPCASE_RESOLUTION) == 8 ) && ( !MODE_IS_VIDEO(modegot) ) ) ||
 138         ( ( MODE_IS_VIDEO(modegot) ) && ( shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 4 ) ) )
 139         return 0;
 140     else
 141         return 60;
 142 } 
 143 
 144 //int vid_get_viewport_height_proper()            { return 240; }
 145 int vid_get_viewport_fullscreen_height()        { return 240; }
 146 int vid_get_viewport_buffer_width_proper()      { return 960; }
 147 int vid_get_palette_type()                      { return 3; }
 148 int vid_get_palette_size()                      { return 256 * 4; }
 149 int vid_get_aspect_ratio()                      { return 1; } 
 150 
 151 
 152 void *vid_get_bitmap_active_palette()
 153 {
 154     extern int active_palette_buffer;
 155     extern int** palette_buffer_ptr;
 156     return (palette_buffer_ptr[active_palette_buffer]+0x3);
 157 }
 158 
 159 #ifdef CAM_LOAD_CUSTOM_COLORS
 160 // Function to load CHDK custom colors into active Canon palette
 161  
 162 void load_chdk_palette() {
 163 
 164     extern int active_palette_buffer;
 165     // Only load for the standard record and playback palettes
 166     if ((active_palette_buffer == 0) || (active_palette_buffer == 2))
 167     {
 168         int *pal = (int*)vid_get_bitmap_active_palette();
 169         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 170         {
 171             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 172             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 173             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 174             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 175             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 176             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 177             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 178             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 179             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 180             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 181             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 182             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 183             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 184             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 185 
 186             extern char palette_control;
 187             palette_control = 1;
 188             vid_bitmap_refresh();
 189         }
 190     }
 191 }
 192 #endif

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