root/platform/sx730hs/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. get_hdmi_hpd_bit
  3. get_analog_av_bit
  4. wrap_kbd_p1_f
  5. mykbd_task
  6. get_dial_hw_position
  7. get_jogdial_direction
  8. handle_jogdial
  9. jogdial_control
  10. my_kbd_read_keys
  11. 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 
  12 int get_usb_bit() {
  13     long usb_physw[3];
  14     usb_physw[USB_IDX] = 0;
  15     _kbd_read_keys_r2(usb_physw);
  16     return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;
  17 }
  18 
  19 #if CAM_REMOTE_HDMI_HPD 
  20 int get_hdmi_hpd_bit() {
  21     long hpd_physw[3];
  22     hpd_physw[HDMI_HPD_IDX] = 0;
  23     _GetKbdState(hpd_physw);
  24     return( ((hpd_physw[HDMI_HPD_IDX] & HDMI_HPD_FLAG)==HDMI_HPD_FLAG)?0:1) ;
  25 }
  26 #endif
  27 
  28 #if CAM_REMOTE_ANALOG_AV
  29 int get_analog_av_bit() {
  30     long av_physw[3];
  31     av_physw[ANALOG_AV_IDX] = 0;
  32     _GetKbdState(av_physw);
  33     return( ((av_physw[ANALOG_AV_IDX] & ANALOG_AV_FLAG)==ANALOG_AV_FLAG)?0:1) ;
  34 }
  35 #endif
  36 
  37 // from sig finder
  38 KeyMap keymap[] = {
  39     { 0, KEY_MENU            ,0x00000020 }, // Found @0xfc637e40, levent 0x15
  40     { 0, KEY_UP              ,0x00000040 }, // Found @0xfc637e48, levent 0x06
  41     { 0, KEY_DOWN            ,0x00000080 }, // Found @0xfc637e50, levent 0x07
  42     { 0, KEY_RIGHT           ,0x00000100 }, // Found @0xfc637e58, levent 0x09
  43     { 0, KEY_SET             ,0x00000200 }, // Found @0xfc637e60, levent 0x0a
  44     { 0, KEY_LEFT            ,0x00000400 }, // Found @0xfc637e68, levent 0x08
  45     { 0, KEY_PLAYBACK        ,0x00000800 }, // Found @0xfc637e70, levent 0x101
  46     { 0, KEY_ERASE           ,0x00001000 }, // Found @0xfc637e78, levent 0x0b
  47     { 0, KEY_VIDEO           ,0x00002000 }, // Found @0xfc637e80, levent 0x02
  48     { 0, KEY_WIFI            ,0x00010000 }, // Found @0xfc637e88, levent 0x103
  49     { 0, KEY_ZOOM_OUT        ,0x00000004 }, // full speed
  50     { 0, KEY_ZOOM_OUT        ,0x00000002 }, // low speed
  51     { 0, KEY_ZOOM_IN         ,0x00000010 }, // full speed
  52     { 0, KEY_ZOOM_IN         ,0x00000008 }, // low speed
  53 //  { 0, KEY_POWER           ,0x00020000 }, // Found @0xfc637e90, levent 0x100
  54     { 1, KEY_SHOOT_FULL      ,0x00000c00 }, // Found @0xfc637ed0, levent 0x01
  55     { 1, KEY_SHOOT_FULL_ONLY ,0x00000800 }, // Found @0xfc637ed0, levent 0x01
  56     { 1, KEY_SHOOT_HALF      ,0x00000400 }, // Found @0xfc637ec8, levent 0x00
  57 
  58     { 0, 0, 0 }
  59 };
  60 
  61 
  62 // no battery door switch, cam runs with door open, no physw change
  63 
  64 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  65 
  66     asm volatile(
  67         "push    {r1-r7, lr}\n"
  68         "movs    r4, #0\n"
  69         "bl      my_kbd_read_keys\n"
  70         "b       kbd_p1_f_cont_my\n" // extra hook needed for shutter keys, see boot.c
  71 //        "b       _kbd_p1_f_cont\n"
  72     );
  73 
  74     return 0;
  75 }
  76 
  77 // no stack manipulation needed here, since we create the task directly
  78 void __attribute__((noinline)) mykbd_task() {
  79     extern void kbd_p2_f_my();
  80 
  81     while (physw_run) {
  82         _SleepTask(physw_sleep_delay);
  83 
  84         int r = wrap_kbd_p1_f();
  85         if (r == 1) {
  86 #ifdef CAM_HAS_JOGDIAL
  87             kbd_p2_f_my();                      // replacement of _kbd_p2_f (in sub/<fwver>/boot.c)
  88 #else
  89             _kbd_p2_f();
  90 #endif
  91         }
  92     }
  93 
  94     _ExitTask();
  95 }
  96 
  97 
  98 // jogdial hw counters (19 bits) are at 0xd9854004 and 0xd9855004, use fw func to read + sign extend them
  99 // 0x7fff8 .. 0x7fffc .. 0 (start pos) .. 4
 100 // intermediate positions are also available, but they are ignored by the fw for a good reason
 101 // directions reversed compared to sx710
 102 #ifdef CAM_HAS_JOGDIAL
 103 extern int _get_dial_hw_position(int dial);
 104 #define DIAL_HW_REAR  4
 105 int get_dial_hw_position(int dial)
 106 {
 107     // mask low bits
 108     return _get_dial_hw_position(dial)&~3;
 109 }
 110 int jogdial_stopped=0;
 111 
 112 extern long dial_positions[2];
 113 
 114 long get_jogdial_direction(void) {
 115     static int new_jogdial=0, old_jogdial=0;
 116     
 117     old_jogdial=new_jogdial;
 118     new_jogdial=get_dial_hw_position(DIAL_HW_REAR);
 119 
 120     if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT; 
 121     else if (old_jogdial>new_jogdial) return JOGDIAL_LEFT;
 122     else return 0;
 123 }
 124 
 125 int handle_jogdial() {
 126     // return 0 to prevent fw dial handler
 127     if (jogdial_stopped) {
 128         // update positions in RAM
 129         dial_positions[0] = dial_positions[1] = get_dial_hw_position(DIAL_HW_REAR);
 130         return 0;
 131     }
 132     return 1;
 133 }
 134 
 135 void jogdial_control(int c) {
 136     jogdial_stopped = c;
 137 }
 138 #endif
 139 
 140 int physw_override;
 141 
 142 void my_kbd_read_keys() {
 143     if(kbd_update_key_state()) {
 144         physw_override = 0;
 145     } else {
 146         // behavior of fc506140 (fw 100d) varies depending on value set by caller fc589620
 147         // if -1, shutter half and full shoot are ignored. Used in override in boot.c
 148         physw_override = -1;
 149     }
 150     kbd_update_physw_bits();
 151 }
 152 
 153 void kbd_fetch_data(long *dst)
 154 {
 155     _GetKbdState(dst);
 156     _kbd_read_keys_r2(dst);
 157 }

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