root/platform/ixus300_sd4000/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. shutdown
  2. debug_led
  3. camera_set_led
  4. get_flash_params_count
  5. JogDial_CW
  6. JogDial_CCW
  7. vid_bitmap_refresh
  8. vid_get_bitmap_fb
  9. vid_get_viewport_live_fb
  10. vid_get_viewport_fb
  11. vid_get_viewport_fb_d
  12. vid_get_viewport_byte_width
  13. vid_get_viewport_width
  14. vid_get_viewport_display_xoffset
  15. vid_get_viewport_height
  16. vid_get_viewport_display_xoffset_proper
  17. vid_get_viewport_height_proper
  18. vid_get_viewport_buffer_width_proper
  19. vid_get_viewport_fullscreen_height
  20. vid_get_palette_type
  21. vid_get_palette_size
  22. vid_get_aspect_ratio
  23. vid_get_bitmap_active_palette
  24. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 void shutdown() {
   6     volatile long *p = (void*)0xC0223030;    // Red AF Led (front)
   7 
   8     asm(
   9         "MRS     R1, CPSR\n"
  10         "AND     R0, R1, #0x80\n"
  11         "ORR     R1, R1, #0x80\n"
  12         "MSR     CPSR_cf, R1\n"
  13         :::"r1","r0"
  14     );
  15 
  16     *p = 0x44;
  17 
  18     while(1);
  19 }
  20 
  21 #define LED_DEBUG1 0xC0220130      // Green Led (backside)
  22 #define LED_DEBUG2 0xc0220134      // Red Led (backside)
  23 #define LED_DEBUG3 0xC0223030      // Red AF Led (front)
  24 #define LED_AF 0xC0223030
  25 #define DEBUG_LED_DELAY 2500000    // use beforce change CPU speed in boot.c
  26 
  27 
  28 void debug_led(int state) {
  29 
  30     volatile long *p=(void*)LED_DEBUG2;
  31 
  32     if (state)
  33         p[0]=0x46;
  34     else
  35         p[0]=0x44;
  36 
  37     // delay loop
  38     int i;
  39     for (i=0; i<DEBUG_LED_DELAY; i++)
  40         asm("nop\n nop\n");
  41 }
  42 
  43 void camera_set_led(int led, int state, int bright) {  // camera has three LED's (focus assist lamp & and a green/orange combo LED)
  44     static char led_table[3]={0,1,9};
  45     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  46 }
  47 
  48 int get_flash_params_count(void) {
  49     return 148;     // 0x94 = 148
  50 }
  51 
  52 
  53 void JogDial_CW(void) {
  54     _PostLogicalEventForNotPowerType(0x876, 1);  // RotateJogDialRight at levent_table
  55 }
  56 
  57 void JogDial_CCW(void) {
  58     _PostLogicalEventForNotPowerType(0x877, 1);  // RotateJogDialLeft at levent_table
  59 }
  60 
  61 void vid_bitmap_refresh() {
  62     extern int enabled_refresh_physical_screen;
  63     extern int full_screen_refresh;
  64     extern void _LockAndRefresh();   // wrapper function for screen lock
  65     extern void _UnlockAndRefresh();   // wrapper function for screen unlock
  66 
  67     _LockAndRefresh();
  68 
  69     enabled_refresh_physical_screen=1;
  70     full_screen_refresh=3;   // found in ScreenUnlock underneath a CameraLog.c call
  71 
  72     _UnlockAndRefresh();
  73 }
  74 
  75 
  76 // Canon UI Buffers for LiveView
  77 
  78     extern int   active_bitmap_buffer;   // in stub_min.S for ixus300
  79     extern char* bitmap_buffer[];        // in stub_min.S for ixus300
  80 
  81     void *vid_get_bitmap_fb()
  82     {
  83         // Return first bitmap buffer address
  84         return bitmap_buffer[0];
  85     }
  86 
  87 // Canon Viewport buffers for LiveView, histogram, edgeoverlay, zebra , motion detect
  88 
  89     extern char  active_viewport_buffer; // in stub_entry.S for ixus300
  90     extern void* viewport_buffers[];     // in stub_entry.S for ixus300
  91 
  92     void *vid_get_viewport_live_fb()
  93     {
  94         char vp ;
  95         if (camera_info.state.mode_video || (get_movie_status()==VIDEO_RECORD_IN_PROGRESS))
  96             return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  97 
  98         // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  99         // Note that this camera only seems to use 3 buffers (vs 4 on other models). 
 100         // Tests with MD_tune.bas show that returning one buffer back from the current value of active_viewport_buffer works best for motion detect
 101 
 102         vp = active_viewport_buffer ;
 103         return viewport_buffers[ (vp == 0) ? 2 : vp-1 ];
 104     }
 105 
 106     void *vid_get_viewport_fb()   /* redefined */
 107     {
 108         // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
 109         // Offset the return value because the viewport is left justified instead of centered on this camera
 110         return viewport_buffers[0];
 111     }
 112 
 113     void *vid_get_viewport_fb_d() /* redefined */
 114     {
 115         extern char *viewport_fb_d;
 116         return viewport_fb_d;
 117     }
 118 
 119     // Physical width of viewport row in bytes
 120     int vid_get_viewport_byte_width() {
 121         return 960 * 6 / 4;     // IXUS 300 - wide screen LCD is 960 pixels wide, each group of 4 pixels uses 6 bytes (UYVYYY)
 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             // ixus300 has six sizes :  3648x2736 (4:3)   2816x2112 (4:3)    2272x1702 (4:3)  1600x1200  (4:3)  640x480  (4:3)  3648x2048 (16:9)
 144             //   PROPCASE_RESOLUTION :  0                 1                  2                3                 4                8
 145             if (shooting_get_prop(PROPCASE_RESOLUTION ) ==  8 ) return 0 ;      // wide screen mode
 146             return 60 ;                                                         // all other modes
 147         }
 148     }
 149 
 150    long vid_get_viewport_height(){ return 240; } 
 151 
 152 
 153 // Additional Functions for PTP Live View system
 154 
 155     int vid_get_viewport_display_xoffset_proper()   { return vid_get_viewport_display_xoffset() * 2 ; }
 156     int vid_get_viewport_height_proper()            { return 240; }
 157     int vid_get_viewport_buffer_width_proper()      { return 960; }
 158     int vid_get_viewport_fullscreen_height()        { return 240; }
 159     int vid_get_palette_type()                      { return 3; }
 160     int vid_get_palette_size()                      { return 256 * 4; }
 161     int vid_get_aspect_ratio()                      { return 1; }
 162 
 163 
 164 // ** Custom Color Palette **
 165 
 166 extern char** palette_buffer_ptr;
 167 extern int active_palette_buffer;
 168 
 169 void* vid_get_bitmap_active_palette()
 170 {
 171     return palette_buffer_ptr[active_palette_buffer]+8;
 172 }
 173 
 174 void load_chdk_palette()
 175 {
 176     if ((active_palette_buffer == 0) || (active_palette_buffer == 4) || (active_palette_buffer == 7))  //00=rec  04=play  07=menu  03=setmenu (don't override in setmenu as it has no non-overlapping blank palette areas)
 177     {
 178         int *pal = (int *)vid_get_bitmap_active_palette();
 179         if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 180         {
 181             pal[CHDK_COLOR_BASE+0]  = 0x033ADF62;  // Red
 182             pal[CHDK_COLOR_BASE+1]  = 0x0326EA40;  // Dark Red
 183             pal[CHDK_COLOR_BASE+2]  = 0x034CD57F;  // Light Red
 184             pal[CHDK_COLOR_BASE+3]  = 0x0373BFAE;  // Green
 185             pal[CHDK_COLOR_BASE+4]  = 0x034BD6CA;  // Dark Green
 186             pal[CHDK_COLOR_BASE+5]  = 0x0395AB95;  // Light Green
 187             pal[CHDK_COLOR_BASE+6]  = 0x034766F0;  // Blue
 188             pal[CHDK_COLOR_BASE+7]  = 0x031250F3;  // Dark Blue
 189             pal[CHDK_COLOR_BASE+8]  = 0x037F408F;  // Cyan
 190             pal[CHDK_COLOR_BASE+9]  = 0x03512D5B;  // Magenta
 191             pal[CHDK_COLOR_BASE+10] = 0x03A9A917;  // Yellow
 192             pal[CHDK_COLOR_BASE+11] = 0x03819137;  // Dark Yellow
 193             pal[CHDK_COLOR_BASE+12] = 0x03DED115;  // Light Yellow
 194             pal[CHDK_COLOR_BASE+13] = 0x00090000;  // Transparent dark grey
 195 
 196             vid_bitmap_refresh();
 197         }
 198     }
 199 }
 200 

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