root/platform/m3/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. mykbd_task_proceed
  3. mykbd_task
  4. get_jogdial_counter
  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 
  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 
  20 //EOS M3  addr = 0xD20BF4A0
  21 KeyMap keymap[] = {
  22 //    { 0, KEY_PLAYBACK        ,0x00000002 }, // inverted physw_status[0]
  23     { 1, KEY_SHOOT_FULL      ,0x00040001 },
  24     { 1, KEY_SHOOT_FULL_ONLY ,0x00000001 },
  25     { 1, KEY_SHOOT_HALF      ,0x00040000 },
  26     { 1, KEY_ZOOM_OUT        ,0x00001000 }, // AE Lock / Index (playback zoom out)
  27     { 1, KEY_ZOOM_IN         ,0x00000800 }, // AF Adjust / Magnify (playback zoom in)
  28     { 1, KEY_VIDEO           ,0x00000008 },
  29     { 1, KEY_MENU            ,0x00000010 },
  30     { 1, KEY_DISPLAY         ,0x00000400 }, // INFO button (lower left)
  31     { 1, KEY_UP              ,0x00000020 },
  32     { 1, KEY_DOWN            ,0x00000040 },
  33     { 1, KEY_RIGHT           ,0x00000080 },
  34     { 1, KEY_LEFT            ,0x00000100 },
  35     { 1, KEY_SET             ,0x00000200 },
  36         { 1, KEY_PRINT           ,0x00002000 },
  37 //      { 0, KEY_MFN             ,0x00002000 },
  38 
  39 //      addr = 0xD20BF4A0 + 0x38
  40 //      { 0, SD_lock             ,0x20000000 },
  41 
  42     { 0, 0, 0 }
  43 };
  44 
  45 
  46 
  47 /* void __attribute__((naked,noinline)) my2_kbd_read_keys() {
  48 
  49     asm volatile(
  50 "      ldr     r2, =physw_status\n"
  51 "      movs    r0, #2\n"
  52 "      movs    r1, #0\n"
  53 "      push    {r4,lr}\n"
  54 "       loc_fc083e7e:\n"
  55 "      str.w   r1, [r2,r0,lsl#2]\n"
  56 "      subs    r0, r0, #1\n"
  57 "      bpl     loc_fc083e7e\n"
  58 "      ldr     r0, =physw_status\n"
  59 "      BL      _GetKbdState\n"
  60 "      pop.w   {r4,lr}\n"
  61 "      ldr     r0, =physw_status\n"
  62 
  63 "      ldr     r1, [r0,#4]\n"
  64 "          bic.w   r1, r1, #0x20000000\n" //clear SD LOCK bit
  65 "      str     r1, [r0,#4]\n"
  66 
  67 "      b.w     _kbd_read_keys_r2\n"
  68     );
  69 
  70 } */
  71 
  72 /* long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  73 
  74     asm volatile(
  75         "push    {r1-r7, lr}\n"
  76         "movs    r4, #0\n"
  77         "bl      my_kbd_read_keys\n"
  78 //        "bl      my2_kbd_read_keys\n"
  79         "b       _kbd_p1_f_cont\n"
  80     );
  81     return 0;
  82 } */
  83 
  84 
  85 
  86 static void __attribute__((noinline)) mykbd_task_proceed() {
  87 
  88     extern void kbd_p2_f_my();
  89         extern long wrap_kbd_p1_f();
  90 
  91     while (physw_run) {
  92         _SleepTask(physw_sleep_delay);
  93                 if ( wrap_kbd_p1_f() == 1) {
  94 //            kbd_p2_f_my();                      // replacement of _kbd_p2_f (in sub/<fwver>/boot.c)
  95                   _kbd_p2_f();                      // replacement of _kbd_p2_f (in sub/<fwver>/boot.c)
  96         }
  97     }
  98 }
  99 
 100 // no stack manipulation needed here, since we create the task directly
 101 void __attribute__((naked,noinline)) mykbd_task() {
 102     mykbd_task_proceed();
 103 
 104     _ExitTask();
 105 }
 106 
 107 // sx280 jogdial hw counter (19 bits) 0xd9854004
 108 // 0x7fff8 .. 0x7fffc .. 0 (start pos) .. 4
 109 // intermediate positions are also available, but they are ignored by the fw for a good reason
 110 
 111 int jogdial_stopped=0;
 112 
 113 extern long jog_position[2];
 114 extern long jog_hw_pos;
 115 
 116 int get_jogdial_counter() {
 117     int p;
 118     p = jog_hw_pos & 0x7fffc;
 119     if (p > 0x3fffc) {
 120         p |= 0xfff80000;
 121     }
 122     return p;
 123 }
 124 
 125 long get_jogdial_direction(void) {
 126     static int new_jogdial=0, old_jogdial=0;
 127 
 128     old_jogdial=new_jogdial;
 129     new_jogdial=get_jogdial_counter();
 130     if (old_jogdial>new_jogdial) return JOGDIAL_LEFT;
 131     else if (old_jogdial<new_jogdial) return JOGDIAL_RIGHT;
 132     else return 0;
 133 }
 134 
 135 int handle_jogdial() {
 136     // return 0 to prevent fw jogdial handler
 137     if (jogdial_stopped) {
 138         // update jog position in RAM
 139         jog_position[0] = jog_position[1] = get_jogdial_counter();
 140         return 0;
 141     }
 142     return 1;
 143 }
 144 
 145 void jogdial_control(int c) {
 146     jogdial_stopped = c;
 147 }
 148 
 149 void my_kbd_read_keys() {
 150     kbd_update_key_state();
 151     kbd_update_physw_bits();
 152 }
 153 
 154 void kbd_fetch_data(long *dst)
 155 {
 156     _GetKbdState(dst);
 157     _kbd_read_keys_r2(dst);
 158 }
 159 
 160 

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