root/platform/ixus175_elph180/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. debug_led
  2. shutdown
  3. camera_set_led
  4. vid_get_viewport_fb
  5. camera_jpeg_count_str
  6. get_flash_params_count
  7. vid_get_bitmap_fb
  8. vid_get_bitmap_active_buffer
  9. vid_get_bitmap_active_palette
  10. vid_get_viewport_yscale
  11. vid_get_viewport_width
  12. vid_get_viewport_height
  13. vid_get_viewport_yoffset
  14. vid_get_viewport_height_proper
  15. vid_get_viewport_fullscreen_height
  16. vid_get_viewport_fb_d
  17. vid_get_viewport_live_fb
  18. hook_raw_image_addr
  19. vid_bitmap_refresh
  20. vid_get_palette_type
  21. vid_get_palette_size
  22. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_PR 0xc022d1fc
   6 #define LED_AF 0xc022d200
   7 
   8 
   9 void debug_led(int state)
  10 {
  11         *(int*)LED_PR=state ? 0x93d800 : 0x83dc00;
  12 }
  13 
  14 void shutdown()
  15 {
  16     extern void _TurnOffE1(void);
  17     _TurnOffE1();
  18     while(1);
  19 }
  20 
  21 // Power Led = first entry in table (led 0)
  22 // AF Assist Lamp = second entry in table (led 1)
  23 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  24     static char led_table[2]={0,4};
  25     if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
  26 }
  27 
  28 void *vid_get_viewport_fb()      { return (void*)0x40866b80; }             // Found @0xffb93e14
  29 char *camera_jpeg_count_str()    { return (char*)0x000d77d4; }             // Found @0xffa13d38
  30 int get_flash_params_count(void) { return 0xF1; }                          // Found @0xff9c3e58
  31 
  32 extern int active_bitmap_buffer;
  33 extern char* bitmap_buffer[];
  34 
  35 void *vid_get_bitmap_fb()        { return (void*)0x40711000; }             // Found @0xff86689c
  36 
  37 void *vid_get_bitmap_active_buffer() {
  38     return bitmap_buffer[active_bitmap_buffer&1];
  39 }
  40 
  41 // Palette colour tables  found @ 0xffbec15c
  42 void *vid_get_bitmap_active_palette()
  43 {
  44     extern int active_palette_buffer;
  45     extern int** palette_buffer_ptr;
  46     int *p = palette_buffer_ptr[active_palette_buffer];
  47     if(!p) {
  48         p = palette_buffer_ptr[0];
  49     }
  50     return (p+1);
  51 }
  52 
  53 extern int _GetVRAMHPixelsSize(void);
  54 extern int _GetVRAMVPixelsSize(void);
  55 extern int _GetVideoOutType(void);
  56 
  57 // playback is 480 / 576 for NTSC / PAL respectively
  58 int vid_get_viewport_yscale() {
  59     if (camera_info.state.mode_play && _GetVideoOutType() != 0) {
  60         return 2;
  61     }
  62     return 1;
  63 }
  64 
  65 //taken from n
  66 int vid_get_viewport_width()
  67 {
  68     if (camera_info.state.mode_play)
  69     {
  70         return 360;
  71     }
  72     return _GetVRAMHPixelsSize() >> 1;
  73 }
  74 
  75 long vid_get_viewport_height()
  76 {
  77   if (camera_info.state.mode_play)
  78   {
  79        if(_GetVideoOutType() == 2) { // PAL
  80            return 288; // 576
  81        }
  82        // rec or NTSC
  83        return 240;
  84   }
  85   return _GetVRAMVPixelsSize();
  86 }
  87 
  88 int vid_get_viewport_yoffset()
  89 {
  90     if (camera_info.state.mode_play)
  91     {
  92         return 0;
  93     }
  94     // no distinct video mode, video uses its own aspect ratio, not still ratio of current mode
  95     if (is_video_recording())
  96     {
  97         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) { // 640x480
  98             return 0;// 4:3 video, no offset
  99         } else {
 100             return 30; // 16:9 video
 101         }
 102     }
 103     // UI doesn't have aspect ratio setting, but setting image size to W sets aspect prop to 16:9
 104     if(shooting_get_prop(PROPCASE_ASPECT_RATIO) == 1) {
 105         return 30;
 106     }
 107     return 0;
 108 }
 109 
 110 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * vid_get_viewport_yscale(); }
 111 
 112 int vid_get_viewport_fullscreen_height()
 113 {
 114     if (camera_info.state.mode_play) {
 115         int vot = _GetVideoOutType();
 116         if(vot == 2) {
 117             return 576; // PAL in playback is 576
 118         } else if(vot == 1) {
 119             return 480; // NTSC is 480
 120         } else {
 121             return 240; // normal is 240
 122         }
 123     } else {
 124         return 240;
 125     }
 126 }
 127 
 128 void *vid_get_viewport_fb_d()
 129 {
 130     extern char *viewport_fb_d;
 131     return viewport_fb_d;
 132 }
 133 
 134 void *vid_get_viewport_live_fb()
 135 {
 136     extern char active_viewport_buffer;
 137     extern void* viewport_buffers[];
 138 
 139     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 140     // unlike earlier cams, video recording appears to use 4 buffers, like still mode
 141     // verified -1 gives best response (50 .. 90 ms)
 142     return viewport_buffers[(active_viewport_buffer-1)&3];
 143 }
 144 
 145 char *hook_raw_image_addr()
 146 {
 147     return (char*) 0x43727660;  //found by campare "JPEG BUFF" at FFB95894 and compare to ixus 160
 148 }
 149 
 150 void vid_bitmap_refresh()
 151 {
 152     extern int full_screen_refresh;
 153     extern void _ScreenLock();
 154     extern void _ScreenUnlock();
 155 
 156     full_screen_refresh |= 3;
 157     _ScreenLock();
 158     _ScreenUnlock();
 159 }
 160 
 161 int vid_get_palette_type()   { return 5; }
 162 int vid_get_palette_size()   { return 256 * 4 ; }
 163 
 164 #ifdef CAM_LOAD_CUSTOM_COLORS
 165 // Function to load CHDK custom colors into active Canon palette
 166 void load_chdk_palette()
 167 {
 168     extern int active_palette_buffer;
 169         // Only load for the standard record and playback palettes
 170         if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
 171     {
 172         int *pal = (int*)vid_get_bitmap_active_palette();
 173 
 174 
 175         if (pal[CHDK_COLOR_BASE+0] != 0x3F3ADF62)
 176         {
 177             pal[CHDK_COLOR_BASE+0]  = 0x3F3ADF62;  // Red
 178             pal[CHDK_COLOR_BASE+1]  = 0x3F26EA40;  // Dark Red
 179             pal[CHDK_COLOR_BASE+2]  = 0x3F4CD57F;  // Light Red
 180             pal[CHDK_COLOR_BASE+3]  = 0x3F73BFAE;  // Green
 181             pal[CHDK_COLOR_BASE+4]  = 0x3F4BD6CA;  // Dark Green
 182             pal[CHDK_COLOR_BASE+5]  = 0x3F95AB95;  // Light Green
 183             pal[CHDK_COLOR_BASE+6]  = 0x3F4766F0;  // Blue
 184             pal[CHDK_COLOR_BASE+7]  = 0x3F1250F3;  // Dark Blue
 185             pal[CHDK_COLOR_BASE+8]  = 0x3F7F408F;  // Cyan
 186             pal[CHDK_COLOR_BASE+9]  = 0x3F512D5B;  // Magenta
 187             pal[CHDK_COLOR_BASE+10] = 0x3FA9A917;  // Yellow
 188             pal[CHDK_COLOR_BASE+11] = 0x3F819137;  // Dark Yellow
 189             pal[CHDK_COLOR_BASE+12] = 0x3FDED115;  // Light Yellow
 190             pal[CHDK_COLOR_BASE+13] = 0x00090000;  // Transparent dark grey
 191 
 192             extern char palette_control;
 193             palette_control = 1;
 194             vid_bitmap_refresh();
 195         }
 196     }
 197 }
 198 #endif

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