root/platform/sx700hs/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. wrap_kbd_p1_f
  3. mykbd_task
  4. get_dial_hw_position
  5. get_jogdial_direction
  6. handle_jogdial
  7. jogdial_control
  8. my_kbd_read_keys
  9. kbd_fetch_data

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "keyboard.h"
   4 #include "kbd_common.h"
   5 
   6 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   7 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   8 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 
  10 extern void _GetKbdState(long*);
  11 extern void _LogCameraEvent(int id, const char *fmt,...);
  12 
  13 
  14 
  15 int get_usb_bit() {
  16     long usb_physw[3];
  17     usb_physw[USB_IDX] = 0;
  18     _kbd_read_keys_r2(usb_physw);
  19     return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;
  20 }
  21 
  22 KeyMap keymap[] = {
  23 //    { 0, KEY_POWER           ,0x00000001 }, // Found @0xfc5693dc, levent 0x100
  24     { 0, KEY_PLAYBACK        ,0x00000002 }, // Found @0xfc5693e4, levent 0x101
  25     { 0, KEY_SHOOT_FULL      ,0x0000000c }, // Found @0xfc5693f4, levent 0x01
  26     { 0, KEY_SHOOT_FULL_ONLY ,0x00000008 }, // Found @0xfc5693f4, levent 0x01
  27     { 0, KEY_SHOOT_HALF      ,0x00000004 }, // Found @0xfc5693ec, levent 0x00
  28     { 0, KEY_VIDEO           ,0x00000100 }, // Found @0xfc5693fc, levent 0x02
  29     { 0, KEY_MENU            ,0x00000200 }, // Found @0xfc569404, levent 0x0e
  30     { 0, KEY_DISPLAY         ,0x00002000 }, // Found @0xfc56940c, levent 0x0d
  31     { 0, KEY_UP              ,0x00004000 }, // Found @0xfc569414, levent 0x06
  32     { 0, KEY_DOWN            ,0x00008000 }, // Found @0xfc56941c, levent 0x07
  33     { 0, KEY_RIGHT           ,0x00010000 }, // Found @0xfc569424, levent 0x09
  34     { 1, KEY_LEFT            ,0x00000004 }, // Found @0xfc56942c, levent 0x08
  35     { 1, KEY_SET             ,0x00000008 }, // Found @0xfc569434, levent 0x0a
  36 //
  37     { 1, KEY_WIFI            ,0x00000020 },
  38     { 1, KEY_FRAMING_ASSIST  ,0x00000010 },
  39     { 2, KEY_ZOOM_IN         ,0x00000002 }, // full speed
  40     { 2, KEY_ZOOM_IN         ,0x00000004 }, // low speed
  41     { 2, KEY_ZOOM_OUT        ,0x00000008 }, // full speed
  42     { 2, KEY_ZOOM_OUT        ,0x00000010 }, // low speed
  43     { 0, 0, 0 }
  44 };
  45 
  46 // flash open word 1, 0x00000200 = open
  47 // no battery door switch, cam runs with door open, no physw change
  48 
  49 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  50 
  51     asm volatile(
  52         "push    {r1-r7, lr}\n"
  53         "movs    r4, #0\n"
  54         "bl      my_kbd_read_keys\n"
  55         "b       _kbd_p1_f_cont\n"
  56     );
  57 
  58     return 0;
  59 }
  60 
  61 // no stack manipulation needed here, since we create the task directly
  62 void __attribute__((noinline)) mykbd_task() {
  63     extern void kbd_p2_f_my();
  64     while (physw_run) {
  65         _SleepTask(physw_sleep_delay);
  66 
  67         if (wrap_kbd_p1_f() == 1) {
  68 #ifdef CAM_HAS_JOGDIAL
  69             kbd_p2_f_my();                      // replacement of _kbd_p2_f (in sub/<fwver>/boot.c)
  70 #else
  71             _kbd_p2_f();
  72 #endif
  73         }
  74     }
  75 
  76     _ExitTask();
  77 }
  78 
  79 // Copied from sx710hs
  80 // jogdial hw counters (19 bits) are at 0xd9854004 and 0xd9855004, use fw func t
  81 // o read + sign extend them
  82 // 0x7fff8 .. 0x7fffc .. 0 (start pos) .. 4
  83 // intermediate positions are also available, but they are ignored by the fw for
  84 //  a good reason
  85 #ifdef CAM_HAS_JOGDIAL
  86 extern int _get_dial_hw_position(int dial);
  87 #define DIAL_HW_REAR  4
  88 int get_dial_hw_position(int dial)
  89 {
  90     // mask low bits
  91     return _get_dial_hw_position(dial)&~3;
  92 }
  93 int jogdial_stopped=0;
  94 
  95 extern long dial_positions[2];
  96 
  97 long get_jogdial_direction(void) {
  98     static int new_jogdial=0, old_jogdial=0;
  99     
 100     old_jogdial=new_jogdial;
 101     new_jogdial=get_dial_hw_position(DIAL_HW_REAR);
 102 
 103 // Reverse directions
 104 //    if (old_jogdial>new_jogdial) return JOGDIAL_RIGHT; 
 105 //    else if (old_jogdial<new_jogdial) return JOGDIAL_LEFT;
 106     if (old_jogdial>new_jogdial) return JOGDIAL_LEFT; 
 107     else if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT;
 108     else return 0;
 109 }
 110 
 111 int handle_jogdial() {
 112     // return 0 to prevent fw dial handler
 113     if (jogdial_stopped) {
 114         // update positions in RAM
 115         dial_positions[0] = dial_positions[1] = get_dial_hw_position(DIAL_HW_REAR);
 116         return 0;
 117     }
 118     return 1;
 119 }
 120 
 121 void jogdial_control(int c) {
 122     jogdial_stopped = c;
 123 }
 124 #endif
 125 
 126 void my_kbd_read_keys() {
 127     kbd_update_key_state();
 128     kbd_update_physw_bits();
 129 }
 130 
 131 void kbd_fetch_data(long *dst)
 132 {
 133     _GetKbdState(dst);
 134     _kbd_read_keys_r2(dst);
 135 }

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