root/platform/a1200/lib.c

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

DEFINITIONS

This source file includes following definitions.
  1. shutdown
  2. debug_led
  3. camera_set_led
  4. vid_get_viewport_width
  5. vid_get_viewport_height
  6. vid_get_viewport_xoffset
  7. vid_get_viewport_yoffset
  8. vid_get_viewport_fb
  9. vid_get_viewport_live_fb
  10. vid_get_palette_type
  11. vid_get_palette_size
  12. vid_get_bitmap_active_palette
  13. load_chdk_palette

   1 #include "platform.h"
   2 #include "platform_palette.h"
   3 #include "lolevel.h"
   4 
   5 #define LED_GR     0xC0220014
   6 #define LED_OR     0xC0220010
   7 #define LED_AF     0xC022000C
   8 
   9 void shutdown() {
  10 
  11     volatile long *p = (void*)LED_AF;
  12 
  13     asm(
  14         "MRS     R1, CPSR\n"
  15         "AND     R0, R1, #0x80\n"
  16         "ORR     R1, R1, #0x80\n"
  17         "MSR     CPSR_cf, R1\n"
  18         :::"r1","r0");
  19 
  20     *p = 0x44;  // power off.
  21 
  22     while(1);
  23 }
  24 
  25 void debug_led(int state) {
  26 
  27     *(int*)LED_OR=state ? 0x46 : 0x44;
  28 }
  29 
  30 void camera_set_led(int led, int state, int bright) {
  31 
  32     static char led_table[3]={0,1,9};
  33     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  34 }
  35 
  36 int vid_get_viewport_width() {
  37 
  38     // viewport width table for each image size
  39     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  40     //static long vp_w[4] = { 360, 360, 360, 360 };
  41     //return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  42     return(360);
  43 }
  44 
  45 long vid_get_viewport_height() {
  46 
  47     // viewport height table for each image size
  48     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  49     // static long vp_h[4] = { 240, 240, 240, 240 };
  50     // return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  51     return( 240 );
  52 }
  53 
  54 int vid_get_viewport_xoffset() {
  55 
  56     // viewport width offset table for each image size
  57     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  58     //static long vp_w[4] = { 0, 0, 0, 0 };               // should all be even values for edge overlay
  59     //return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  60     return( 0 ) ;
  61 }
  62 
  63 int vid_get_viewport_yoffset() {
  64 
  65     // viewport height offset table for each image size
  66     // 0 = 4:3, 1 = 16:9, 2 = 3:2, 3 = 1:1
  67     // static long vp_h[4] = { 0, 0, 0, 0 };
  68     // return vp_h[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
  69     return ( 0 ) ;
  70 }
  71 
  72 extern char active_viewport_buffer;
  73 extern void* viewport_buffers[];
  74 
  75 void *vid_get_viewport_fb()
  76 {
  77     // Return first viewport buffer - for case when vid_get_viewport_live_fb not defined
  78     return viewport_buffers[0];
  79 }
  80 
  81 void *vid_get_viewport_live_fb()
  82 {
  83     if (MODE_IS_VIDEO(mode_get()))
  84         return viewport_buffers[0];     // Video only seems to use the first viewport buffer.
  85 
  86    // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
  87     return viewport_buffers[(active_viewport_buffer-1)&3];
  88 }
  89 
  90 // Functions for PTP Live View system
  91 // 256 entry palette based on 100b sub_FF909B0C
  92 int vid_get_palette_type()                      { return 3; }
  93 int vid_get_palette_size()                      { return 256 * 4; }
  94    
  95 // Function to load CHDK custom colors into active Canon palette
  96 
  97 void *vid_get_bitmap_active_palette() {
  98         extern int active_palette_buffer;
  99         extern char* palette_buffer[];
 100         return (palette_buffer[active_palette_buffer]+8);
 101 }
 102 
 103 void load_chdk_palette() {
 104 
 105         extern int active_palette_buffer;
 106         // Only load for the standard record and playback palettes
 107         if ((active_palette_buffer == 0) || (active_palette_buffer == 4))
 108         {
 109                 int *pal = (int*)vid_get_bitmap_active_palette();
 110                 if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
 111                 {
 112                         pal[CHDK_COLOR_BASE+0]  = 0x33ADF62;  // Red
 113                         pal[CHDK_COLOR_BASE+1]  = 0x326EA40;  // Dark Red
 114                         pal[CHDK_COLOR_BASE+2]  = 0x34CD57F;  // Light Red
 115                         pal[CHDK_COLOR_BASE+3]  = 0x373BFAE;  // Green
 116                         pal[CHDK_COLOR_BASE+4]  = 0x34BD6CA;  // Dark Green
 117                         pal[CHDK_COLOR_BASE+5]  = 0x395AB95;  // Light Green
 118                         pal[CHDK_COLOR_BASE+6]  = 0x34766F0;  // Blue
 119                         pal[CHDK_COLOR_BASE+7]  = 0x31250F3;  // Dark Blue
 120                         pal[CHDK_COLOR_BASE+8]  = 0x37F408F;  // Cyan
 121                         pal[CHDK_COLOR_BASE+9]  = 0x3512D5B;  // Magenta
 122                         pal[CHDK_COLOR_BASE+10] = 0x3A9A917;  // Yellow
 123                         pal[CHDK_COLOR_BASE+11] = 0x3819137;  // Dark Yellow
 124                         pal[CHDK_COLOR_BASE+12] = 0x3DED115;  // Light Yellow
 125                         pal[CHDK_COLOR_BASE+13] = 0x0090000;  // Transparent dark grey
 126 
 127                         extern char palette_control;
 128                         palette_control = 1;
 129                         vid_bitmap_refresh();
 130         }
 131     }
 132 }

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