root/platform/sx530hs/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. hook_raw_image_addr
  2. hook_alt_raw_image_addr
  3. vid_bitmap_refresh
  4. shutdown
  5. vid_get_bitmap_fb
  6. get_flash_params_count
  7. vid_get_viewport_fb
  8. camera_jpeg_count_str
  9. debug_led
  10. camera_set_led
  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_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_palette
  24. vid_get_bitmap_active_buffer
  25. JogDial_CW
  26. JogDial_CCW

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 extern  int     active_raw_buffer;
   6 extern  char*   raw_buffers[];
   7 
   8 char *hook_raw_image_addr()
   9 {
  10     return raw_buffers[active_raw_buffer & 1];
  11 }
  12 
  13 char *hook_alt_raw_image_addr()
  14 {
  15     return raw_buffers[((active_raw_buffer & 1)^1)];
  16 }
  17 
  18 //char *camera_jpeg_count_str() jeronymo
  19 //{
  20 //    extern char jpeg_count_str[];
  21 //    return jpeg_count_str;
  22 //}
  23 
  24 void vid_bitmap_refresh()
  25 {
  26     extern int full_screen_refresh;
  27     extern void _ScreenLock();
  28     extern void _ScreenUnlock();
  29 
  30     full_screen_refresh |= 3;
  31     _ScreenLock();
  32     _ScreenUnlock();
  33 }
  34 
  35 #define LED_PR 0xC022D1FC
  36 #define AF_LED 0xC022D034
  37 void shutdown()
  38 {
  39     extern void _TurnOffE1(void);
  40     _TurnOffE1();
  41     while(1);
  42 }
  43 void *vid_get_bitmap_fb()        { return (void*)0x40711000; }             // Found @0xff06e5f8
  44 int get_flash_params_count(void) { return 0xdc; }                          // Found @0xff23513c
  45 void *vid_get_viewport_fb()      { return (void*)0x40866b80; }             // Found @0xff4d2e04
  46 
  47 char *camera_jpeg_count_str()
  48 {
  49     extern char jpeg_count_str[];
  50     return jpeg_count_str;
  51 }
  52 
  53 void debug_led(int state)
  54 {
  55     volatile long *p=(void*)LED_PR;
  56     if (state)
  57         p[0]=0x93d800;
  58     else
  59         p[0]=0x83dc00;
  60 }
  61 
  62 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
  63     static char led_table[]={0,12}; // status, AF
  64     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  65 }
  66 
  67 extern char active_viewport_buffer;
  68 extern void* viewport_buffers[];
  69 
  70 void *vid_get_viewport_fb_d()
  71 {
  72     extern char *viewport_fb_d;
  73     return viewport_fb_d;    
  74 }
  75 
  76 void *vid_get_viewport_live_fb()
  77 {
  78     //if (MODE_IS_VIDEO(mode_get()) || is_video_recording())
  79     //    return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  80 
  81     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  82     // verified -1 gives best response
  83     return viewport_buffers[(active_viewport_buffer-1)&3];
  84 }
  85 
  86 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  87 int vid_get_viewport_yscale() {
  88     return 2;
  89 }
  90 
  91 int vid_get_viewport_width()
  92 {
  93     if (camera_info.state.mode_play)
  94     {
  95         return 360;
  96     }
  97     extern int _GetVRAMHPixelsSize();
  98     return _GetVRAMHPixelsSize() >> 1;
  99 }
 100 
 101 long vid_get_viewport_height()
 102 {
 103 
 104     int m = mode_get();
 105     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 106 
 107     if (MODE_IS_VIDEO(m) || is_video_recording())
 108         return 240;
 109 
 110     if ((m & MODE_MASK) != MODE_PLAY) 
 111     {
 112         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 113         if (aspect_ratio==1 || aspect_ratio==2)
 114             return 240;
 115     }
 116     extern int _GetVRAMVPixelsSize();    
 117     return ((m & MODE_MASK) == MODE_PLAY)?240:_GetVRAMVPixelsSize()>>1;
 118 }
 119 
 120 // viewport width offset table for each aspect ratio
 121 // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 122 static long vp_xo[4] = { 0, 0, 0, 44 };        // should all be even values for edge overlay
 123 
 124 int vid_get_viewport_display_xoffset()
 125 {
 126     int m = mode_get();
 127     int aspect_ratio=shooting_get_prop(PROPCASE_ASPECT_RATIO);
 128 
 129     if ((m & MODE_MASK) != MODE_PLAY) {
 130         return (vp_xo[aspect_ratio]);
 131     }
 132     else
 133         return 0;
 134 }
 135 
 136 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset()<<1; }
 137 int vid_get_viewport_display_yoffset_proper()   { return vid_get_viewport_display_yoffset()<<1; }
 138 int vid_get_viewport_height_proper()            { return vid_get_viewport_height() * 2; }
 139 int vid_get_viewport_fullscreen_height()        { return 480; }
 140 int vid_get_palette_type()                      { return 3; }
 141 int vid_get_palette_size()                      { return 256 * 4; }
 142 
 143 void *vid_get_bitmap_active_palette()
 144 {
 145     extern void *palette_buffer_ptr;
 146     return palette_buffer_ptr;
 147 }
 148 
 149 extern int active_bitmap_buffer;
 150 extern char* bitmap_buffer[];
 151 
 152 void *vid_get_bitmap_active_buffer() {
 153     return bitmap_buffer[active_bitmap_buffer&1];
 154 }
 155 
 156 
 157 
 158 
 159 //TODO-----------------------------------------------------------------------------------
 160 void JogDial_CW(void)
 161 {
 162     _PostLogicalEventToUI(0x872, 1);  // RotateJogDialRight (in table @ ????, fw 1.01a)
 163 }
 164 
 165 void JogDial_CCW(void)
 166 {
 167     _PostLogicalEventToUI(0x873, 1);  // RotateJogDialLeft (in table @ ???, fw 1.01a)
 168 }

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