root/platform/ixus230_elph310hs/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. get_flash_params_count
  6. vid_get_viewport_fb
  7. vid_get_viewport_live_fb
  8. vid_get_viewport_yscale
  9. vid_get_viewport_width
  10. vid_get_viewport_xoffset
  11. vid_get_viewport_height
  12. vid_get_viewport_yoffset
  13. vid_get_viewport_display_xoffset
  14. vid_get_viewport_display_xoffset_proper
  15. vid_get_viewport_height_proper
  16. vid_get_viewport_buffer_width_proper
  17. vid_get_viewport_fullscreen_height
  18. vid_get_palette_type
  19. vid_get_palette_size
  20. vid_get_aspect_ratio
  21. vid_get_bitmap_active_buffer
  22. vid_get_bitmap_active_palette

   1 #include "platform.h"
   2 #include "lolevel.h"
   3 
   4 void vid_bitmap_refresh()
   5 {
   6         extern int full_screen_refresh;
   7         extern void _ScreenLock(); // wrapper function for screen lock
   8         extern void _ScreenUnlock(); // wrapper function for screen unlock
   9 
  10         full_screen_refresh |= 3; //found in ScreenUnlock
  11         _ScreenLock();  
  12         _ScreenUnlock();
  13 }
  14 
  15 void shutdown()
  16 {
  17         volatile long *p = (void*)0xC022001C;
  18 
  19         asm(
  20                 "MRS     R1, CPSR\n"
  21                 "AND     R0, R1, #0x80\n"
  22                 "ORR     R1, R1, #0x80\n"
  23                 "MSR     CPSR_cf, R1\n"
  24                 :::"r1","r0");
  25 
  26         *p = 0x44;  // power off.
  27 
  28         while(1);
  29 }
  30 
  31 #define LED_PR 0xC0220130
  32 
  33 void debug_led(int state)
  34 {
  35  *(int*)LED_PR=state ? 0x46 : 0x44;
  36 }
  37 
  38 void camera_set_led(int led, int state, int bright) {
  39  static char led_table[2]={0,9};
  40  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  41 }
  42 
  43 int get_flash_params_count(void){
  44  return 0x9F;  //@FF1B4C5C in GetParameterData
  45 }
  46 
  47 // Viewport and Bitmap values that shouldn't change across firmware versions.
  48 // Values that may change are in lib.c for each firmware version.
  49 
  50 // Defined in stubs_min.S
  51 extern char active_viewport_buffer;
  52 extern void* viewport_buffers[];
  53 
  54 void *vid_get_viewport_fb()
  55 {
  56     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  57     // Offset the return value because the viewport is left justified instead of centered on this camera
  58     return viewport_buffers[0];
  59 }
  60 
  61 void *vid_get_viewport_live_fb()
  62 {
  63     if (MODE_IS_VIDEO(mode_get()) || (get_movie_status()==VIDEO_RECORD_IN_PROGRESS))
  64         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  65 
  66     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  67     // Offset the return value because the viewport is left justified instead of centered on this camera
  68     return viewport_buffers[(active_viewport_buffer-1)&3];
  69 }
  70 
  71 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
  72 int vid_get_viewport_yscale() {
  73         return 2;               // ixus230/ixus3310 viewport is 480 pixels high
  74 }
  75 
  76 int vid_get_viewport_width()
  77 {
  78         // viewport width table for each image size
  79         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  80         static long vp_w[5] = { 360, 360, 360, 272 };
  81         return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  82 }
  83 
  84 int vid_get_viewport_xoffset()
  85 {
  86         // viewport width offset table for each image size
  87         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  88         static long vp_w[5] = { 0, 0, 0, 44 };                          // should all be even values for edge overlay
  89         return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  90 }
  91 
  92 long vid_get_viewport_height()
  93 {
  94         // viewport height table for each image size
  95         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  96         static long vp_h[5] = { 240, 180, 214, 240 };
  97         return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  98 }
  99 
 100 int vid_get_viewport_yoffset()
 101 {
 102         // viewport height offset table for each image size
 103         // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 104         static long vp_h[5] = { 0, 30, 13, 0 };
 105         return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 106 }
 107 
 108 int vid_get_viewport_display_xoffset()
 109 {
 110         if ((mode_get() & MODE_MASK) == MODE_PLAY)
 111     {
 112         return 0;
 113     }
 114     else 
 115     {
 116         // viewport width offset table for each image size
 117             // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 118         static long vp_w[5] = { 0, 0, 0, 0 };    // should all be even values for edge overlay
 119             return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 120     }
 121 }
 122 
 123 // Functions for PTP Live View system
 124 
 125 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() * 2; }
 126 int vid_get_viewport_height_proper()            { return 480; }
 127 int vid_get_viewport_buffer_width_proper()      { return 960; }
 128 int vid_get_viewport_fullscreen_height()        { return 480; }
 129 int vid_get_palette_type()                      { return 3; }
 130 int vid_get_palette_size()                      { return 256 * 4; }
 131 int vid_get_aspect_ratio()                      { return 1; }
 132 
 133 // Defined in stubs_entry.S
 134 extern int active_bitmap_buffer;
 135 extern char* bitmap_buffer[];
 136 
 137 void *vid_get_bitmap_active_buffer()
 138 {
 139     return bitmap_buffer[active_bitmap_buffer];
 140 }
 141 
 142 void *vid_get_bitmap_active_palette()
 143 {
 144     extern int active_palette_buffer;
 145     extern char* palette_buffer[];
 146     return (palette_buffer[active_palette_buffer]+8);
 147 }

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