root/platform/ixus310_elph500hs/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. camera_jpeg_count_str
  4. vid_bitmap_refresh
  5. shutdown
  6. debug_led
  7. camera_set_led
  8. get_flash_params_count
  9. vid_get_viewport_fb
  10. vid_get_viewport_live_fb
  11. vid_get_viewport_fb_d
  12. vid_get_bitmap_fb
  13. vid_get_viewport_byte_width
  14. vid_get_viewport_yscale
  15. vid_get_viewport_width
  16. vid_get_viewport_display_xoffset
  17. vid_get_viewport_height
  18. vid_get_viewport_display_xoffset_proper
  19. vid_get_viewport_height_proper
  20. vid_get_viewport_buffer_width_proper
  21. vid_get_viewport_fullscreen_height
  22. vid_get_palette_type
  23. vid_get_palette_size
  24. vid_get_aspect_ratio
  25. vid_get_bitmap_active_buffer
  26. vid_get_bitmap_active_palette
  27. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 
   6 extern  int     active_raw_buffer;
   7 extern  char*   raw_buffers[];
   8 
   9 char *hook_raw_image_addr()
  10 {
  11     return raw_buffers[active_raw_buffer*3];
  12 }
  13 
  14 char *hook_alt_raw_image_addr()
  15 {
  16     return raw_buffers[(active_raw_buffer^1)*3];
  17 }
  18 
  19 
  20 char *camera_jpeg_count_str()
  21 {
  22     extern char jpeg_count_str[];
  23         return jpeg_count_str;
  24 }
  25 
  26 
  27 void vid_bitmap_refresh()
  28 {
  29         extern int full_screen_refresh;
  30         extern void _ScreenUnlock();
  31         extern void _ScreenLock();
  32 
  33         full_screen_refresh |= 3;
  34         _ScreenLock();
  35         _ScreenUnlock();
  36 }
  37 
  38 
  39 void shutdown()
  40 {
  41         volatile long *p = (void*)0xC022001C;    
  42         
  43         asm(
  44                 "MRS     R1, CPSR\n"
  45                 "AND     R0, R1, #0x80\n"
  46                 "ORR     R1, R1, #0x80\n"
  47                 "MSR     CPSR_cf, R1\n"
  48                 :::"r1","r0");
  49         
  50         *p = 0x44;  // power off.
  51         
  52         while(1);
  53 }
  54 
  55 #define LED_PR 0xC0220110       // Power Indicator
  56 
  57 void debug_led(int state)
  58 {
  59  *(int*)LED_PR=state ? 0x46 : 0x44;
  60 }
  61 
  62 // IXUS 310 has 2 led values
  63 // 0/7 - Power LED (Green)
  64 // 1/11 - AF Assist Lamp
  65 void camera_set_led(int led, int state, int bright) {
  66  static char led_table[2]={7,11};
  67  _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  68 }
  69 
  70 int get_flash_params_count(void){
  71  return 0xA0;   // found in GetParameterData
  72 }
  73 
  74 // Viewport and Bitmap values that shouldn't change across firmware versions.
  75 // Values that may change are in lib.c for each firmware version.
  76 
  77 // Defined in stubs_min.S
  78 extern char active_viewport_buffer;
  79 extern void* viewport_buffers[];
  80 
  81 void *vid_get_viewport_fb()
  82 {
  83     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  84     // Offset the return value because the viewport is left justified instead of centered on this camera
  85     return viewport_buffers[0];
  86 }
  87 
  88 void *vid_get_viewport_live_fb()
  89 {
  90     if (camera_info.state.mode_video || (get_movie_status()==VIDEO_RECORD_IN_PROGRESS))
  91         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  92 
  93     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  94     // Offset the return value because the viewport is left justified instead of centered on this camera
  95     return viewport_buffers[(active_viewport_buffer-1)&3];
  96 }
  97 
  98 void *vid_get_viewport_fb_d()
  99 {
 100     extern char *viewport_fb_d;
 101         return viewport_fb_d;
 102 }
 103 
 104 // Defined in stubs_min.S
 105 extern int active_bitmap_buffer;
 106 extern char* bitmap_buffer[];
 107 
 108 void *vid_get_bitmap_fb()
 109 {
 110     // Return first bitmap buffer address
 111     return bitmap_buffer[0];
 112 }
 113 
 114 // Physical width of viewport row in bytes
 115 int vid_get_viewport_byte_width() {
 116         return 960 * 6 / 4;     // IXUS 310 - wide screen LCD is 960 pixels wide, each group of 4 pixels uses 6 bytes (UYVYYY)
 117 }
 118 
 119 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
 120 int vid_get_viewport_yscale() {
 121         return 2;               // IXUS 310 viewport is 480 pixels high
 122 }
 123 
 124 int vid_get_viewport_width()
 125 {
 126         if (camera_info.state.mode_play)
 127     {
 128         return 480;
 129     }
 130     extern int _GetVRAMHPixelsSize();
 131     return _GetVRAMHPixelsSize() >> 1;
 132 }
 133 
 134 int vid_get_viewport_display_xoffset()
 135 {
 136         if (camera_info.state.mode_play)
 137     {
 138         return 0;
 139     }
 140     else 
 141     {
 142         // viewport width offset table for each image size
 143             // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
 144             static long vp_w[5] = { 60, 0, 36, 104 };                           // should all be even values for edge overlay
 145             return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
 146     }
 147 }
 148 
 149 long vid_get_viewport_height(){ return 240; }
 150 
 151 // Functions for PTP Live View system
 152 
 153 int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() * 2; }
 154 int vid_get_viewport_height_proper()            { return 480; }
 155 int vid_get_viewport_buffer_width_proper()      { return 960; }
 156 int vid_get_viewport_fullscreen_height()        { return 480; }
 157 int vid_get_palette_type()                      { return 3; }
 158 int vid_get_palette_size()                      { return 256 * 4; }
 159 int vid_get_aspect_ratio()                      { return 1; }
 160 
 161 void *vid_get_bitmap_active_buffer()
 162 {
 163     return bitmap_buffer[active_bitmap_buffer];
 164 }
 165 
 166 void *vid_get_bitmap_active_palette()
 167 {
 168     extern int active_palette_buffer;
 169     extern char* palette_buffer[];
 170     return (palette_buffer[active_palette_buffer]+8);
 171 }
 172 
 173 // Function to load CHDK custom colors into active Canon palette
 174 void load_chdk_palette()
 175 {
 176     extern int active_palette_buffer;
 177     // Only load for the standard record and playback palettes
 178     if ((active_palette_buffer == 0) || (active_palette_buffer == 16))
 179     {
 180         int *pal = (int*)vid_get_bitmap_active_palette();
 181         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 182         {
 183             pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 184             pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 185             pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 186             pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 187             pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 188             pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 189             pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 190             pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 191             pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 192             pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 193             pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 194             pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 195             pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 196             pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 197 
 198             extern char palette_control;
 199             palette_control = 1;
 200             vid_bitmap_refresh();
 201         }
 202     }
 203 }

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