root/platform/g11/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. camera_jpeg_count_str
  8. hook_raw_image_addr
  9. vid_bitmap_refresh
  10. vid_get_bitmap_fb
  11. vid_get_viewport_fb
  12. vid_get_viewport_width
  13. vid_get_viewport_height
  14. vid_get_viewport_yscale
  15. vid_get_viewport_fb_d
  16. vid_get_viewport_live_fb
  17. vid_get_palette_type
  18. vid_get_palette_size
  19. vid_get_bitmap_active_palette

   1 #include "platform.h"
   2 #include "lolevel.h"
   3 
   4 void shutdown()
   5 {
   6     volatile long *p = (void*)0xC0220240; // G11
   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     *p = 0x44;
  16 
  17     while(1);
  18 }
  19 
  20 
  21 #define LED_PR 0xC0220128 //EV LED
  22 
  23 void debug_led(int state)
  24 {
  25     volatile long *p=(void*)LED_PR;
  26     if (state)
  27         p[0]=0x46;
  28     else
  29         p[0]=0x44;
  30 }
  31 
  32 /*
  33 0 Upper LED near EVF in Green
  34 1 Upper LED near EVF in Orange
  35 2 Lower LED near EVF
  36 3 LED in power button
  37 4 AF assist LED
  38 5 LED next to ISO Dial
  39 6 LED next EV +/- Dial 
  40 */
  41 void camera_set_led(int led, int state, int bright) {
  42         static char led_table[7]={0,1,2,3,10,14,15};
  43     _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
  44 }
  45 
  46 int get_flash_params_count(void) { return 0x84; }                          // Found @0xff9968bc
  47 
  48 void JogDial_CW(void){
  49  _PostLogicalEventForNotPowerType(0x874, 1);  // RotateJogDialRight
  50 }
  51 
  52 void JogDial_CCW(void){
  53  _PostLogicalEventForNotPowerType(0x875, 1);  // RotateJogDialLeft
  54 }
  55 
  56 
  57 char *camera_jpeg_count_str()
  58 {
  59     extern char jpeg_count_str[];
  60         return jpeg_count_str;
  61 }
  62 
  63 char *hook_raw_image_addr()
  64 {
  65     return (char*)0x41C0F460;  // G11 search for aCrwaddressLxCr " CrwAddress %lx, CrwSize H %ld V %ld\r" 0x41c0f460 0xEA0 0xAE0
  66                                                            // or for aCrawBuffP      DCB "CRAW BUFF       %p",0
  67 }
  68 
  69 void vid_bitmap_refresh()
  70 {
  71          extern int enabled_refresh_physical_screen; // screen lock counter
  72          extern void _ScreenUnlock();
  73 
  74          _ScreenLock();
  75           enabled_refresh_physical_screen = 1;
  76          _ScreenUnlock();
  77 }
  78 
  79 void *vid_get_bitmap_fb()       
  80 {
  81         return (void*)0x40471000; // G11 OK 100j loc_FF85A4BC ir 0xFF85A4C0 (at end of function DispCon_ShowBlackChart
  82 }
  83 
  84 void *vid_get_viewport_fb()
  85 {
  86         
  87                 return (void*)0x40587700;
  88 /*
  89 100j
  90 ROM:FFB067B0 28 12 9F E5                             LDR     R1, =0x40587700 ; Load from Memory
  91 ROM:FFB067B4 20 02 9F E5                             LDR     R0, =0x7E900    ; Load from Memory
  92 ROM:FFB067B8 00 10 84 E5                             STR     R1, [R4]        ; Store to Memory
  93 ROM:FFB067BC 04 00 84 E5                             STR     R0, [R4,#4]     ; Store to Memory
  94 ROM:FFB067C0 95 0F 8F E2                             ADR     R0, aVramAddressP ; "VRAM Address  : %p\r"
  95 */
  96 
  97 }
  98 
  99 // Viewport and Bitmap values that shouldn't change across firmware versions.
 100 // Values that may change are in lib.c for each firmware version.
 101 
 102 int vid_get_viewport_width()
 103 {
 104         return 360;
 105 }
 106 
 107 long vid_get_viewport_height()
 108 {
 109    return 240;
 110 }
 111 
 112 // Y multiplier for cameras with 480 pixel high viewports (CHDK code assumes 240)
 113 int vid_get_viewport_yscale() {
 114         return 2;               // G11 viewport is 480 pixels high
 115 }
 116 
 117 void *vid_get_viewport_fb_d()
 118 {
 119     extern char *viewport_fb_d;
 120         return viewport_fb_d;
 121 }
 122 
 123 void *vid_get_viewport_live_fb()
 124 {
 125     extern char active_viewport_buffer;
 126     extern void* viewport_buffers[];
 127 
 128     int buf = active_viewport_buffer-1;
 129     if(buf < 0) {
 130         buf = 2;
 131     }
 132     // Hopefully return the most recently used viewport buffer so that motion detect, histogram, zebra and edge overly are using current image data
 133     return viewport_buffers[buf];
 134 }
 135 
 136 // Functions for PTP Live View system
 137 int vid_get_palette_type()                      { return 3 ; }          // 1,2,3,4,or 5
 138 int vid_get_palette_size()                      { return 256 * 4 ; }    // 16*4 or 256*4
 139 
 140 void *vid_get_bitmap_active_palette()
 141 {
 142     extern int active_palette_buffer;
 143     extern char** palette_buffer_ptr;
 144     return palette_buffer_ptr[active_palette_buffer]+8;
 145 }

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