root/platform/ixus265_elph340hs/lib.c

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

DEFINITIONS

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

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_PR 0xc022d1fc
   6 #define LED_AF 0xc022d1b0
   7 
   8 void debug_led(int state)
   9 {
  10         *(int*)LED_PR=state ? 0x93d800 : 0x83dc00;
  11 }
  12 
  13 
  14 extern  int     active_raw_buffer;
  15 extern  char*   raw_buffers[];
  16 
  17 char *hook_raw_image_addr()
  18 {
  19     return raw_buffers[active_raw_buffer & 1];
  20 }
  21 
  22 char *hook_alt_raw_image_addr()
  23 {
  24     return raw_buffers[((active_raw_buffer & 1)^1)];
  25 }
  26 
  27 
  28 
  29 char *camera_jpeg_count_str()
  30 {
  31     extern char jpeg_count_str[];
  32     return jpeg_count_str;
  33 }
  34 
  35 void vid_bitmap_refresh()
  36 {
  37     extern int full_screen_refresh;
  38     extern void _ScreenLock();
  39     extern void _ScreenUnlock();
  40 
  41     full_screen_refresh |= 3;
  42     _ScreenLock();
  43     _ScreenUnlock();
  44 }
  45 
  46 
  47 void shutdown()
  48 {
  49     extern void _TurnOffE1(void);
  50     _TurnOffE1();
  51     while(1);
  52 }
  53 
  54 
  55 int get_flash_params_count(void) { return 0xa6; }
  56 
  57 
  58 
  59 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  60     static char led_table[]={0,4}; // status, AF
  61     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  62 }
  63 
  64 
  65 void *vid_get_bitmap_fb()        { return (void*)0x406f1000; }             // Found @0xff0689e0
  66 void *vid_get_viewport_fb()      { return (void*)0x40846b80; }             // Found @0xff4d5154
  67 
  68 void *vid_get_viewport_fb_d()
  69 {
  70     extern char *viewport_fb_d;
  71     return viewport_fb_d;
  72 }
  73 
  74 
  75 extern char active_viewport_buffer;
  76 extern void* viewport_buffers[];
  77 
  78 void *vid_get_viewport_live_fb()
  79 {
  80     // camera appears to use 8 buffers
  81     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  82     return viewport_buffers[(active_viewport_buffer-1)&7];
  83 }
  84 
  85 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  86 // camera appears to use 240 when recording FHD video and Fisheye mode, 480 otherwise
  87 int vid_get_viewport_yscale() {
  88     if (camera_info.state.mode_play) {
  89         return 2;
  90     }
  91     if (is_video_recording()) {
  92         // FHD video
  93         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 5) {
  94             return 1;
  95         }
  96         return 2;
  97     }
  98     if (camera_info.state.mode_shooting == MODE_FISHEYE) {
  99         return 1;
 100     }
 101     return 2;
 102 }
 103 
 104 int vid_get_viewport_width()
 105 {
 106     if (camera_info.state.mode_play)
 107     {
 108         return 360;
 109     }
 110     extern int _GetVRAMHPixelsSize();
 111     return _GetVRAMHPixelsSize() >> 1;
 112 }
 113 
 114 long vid_get_viewport_height()
 115 {
 116     if(camera_info.state.mode_play) {
 117         return 240;
 118     }
 119     extern int _GetVRAMVPixelsSize();
 120     // FHD video is apparently 180 on a 240 display
 121     int h = _GetVRAMVPixelsSize();
 122     if (vid_get_viewport_yscale() == 1) {
 123         return h;
 124     }
 125 
 126     return h>>1;
 127 }
 128 
 129 // viewport width offset table for each aspect ratio
 130 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 131 static long vp_xo[4] = { 0, 0, 0, 44 };        // should all be even values for edge overlay
 132 
 133 int vid_get_viewport_display_xoffset()
 134 {
 135     if(camera_info.state.mode_play) {
 136         return 0;
 137     }
 138     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 139 
 140     return (vp_xo[aspect_ratio]);
 141 }
 142 
 143 // viewport height offset table for each image size
 144 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 145 static long vp_yo[5] = { 0, 30, 13, 0 };
 146 
 147 int vid_get_viewport_yoffset()
 148 {
 149     if (camera_info.state.mode_play)
 150     {
 151         return 0;
 152     }
 153     if (is_video_recording())
 154     {
 155         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) { // 640x480
 156             return 0;// 4:3 video, no offset
 157         } else {
 158             return 30; // 16:9 video
 159         }
 160     }
 161     return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 162 }
 163 
 164 int vid_get_viewport_display_yoffset()
 165 {
 166     if (camera_info.state.mode_play)
 167     {
 168         return 0;
 169     }
 170     if (is_video_recording())
 171     {
 172         if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 2) { // 640x480
 173             return 0;// 4:3 video, no offset
 174         } else {
 175             return 30;
 176         }
 177     }
 178     return vp_yo[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 179 }
 180 
 181 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset()<<1; }
 182 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset() * vid_get_viewport_yscale(); }
 183 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * vid_get_viewport_yscale(); }
 184 
 185 int vid_get_viewport_fullscreen_height()
 186 {
 187     return 240 * vid_get_viewport_yscale();
 188 }
 189 
 190 int vid_get_palette_type()                      { return 3; }
 191 int vid_get_palette_size()                      { return 256 * 4; }
 192 
 193 // Defined in stubs_min.S
 194 extern int active_bitmap_buffer;
 195 extern char* bitmap_buffer[];
 196 void *vid_get_bitmap_active_buffer()
 197 {
 198     return bitmap_buffer[active_bitmap_buffer&1];
 199 }
 200 
 201 void *vid_get_bitmap_active_palette()
 202 {
 203     extern void *palette_buffer_ptr;
 204     return palette_buffer_ptr;
 205 }
 206 

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