root/platform/sx210is/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. wrap_kbd_p1_f
  5. my_kbd_read_keys
  6. kbd_fetch_data
  7. jogdial_control
  8. Get_JogDial
  9. get_jogdial_direction

   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 KeyMap keymap[] = {
  11 
  12                 //play button doesn't alter anything here...????
  13 
  14                 //door open a19b -> 219b
  15                 //power b -> 3
  16         { 0, KEY_SHOOT_FULL     , 0x00002002 },
  17         { 0, KEY_SHOOT_FULL_ONLY        , 0x00000002 },  //   b ->    9
  18         { 0, KEY_SHOOT_HALF     , 0x00002000 },  //a19b -> 819b
  19         { 0, KEY_UP                 , 0x00000080 },  // 9b -> 1b
  20         { 0, KEY_DOWN           , 0x00000100 },  // 19b -> 09b
  21         { 0, KEY_PLAYBACK       , 0x00800000 }, // Found @0xffb6586c, levent 0x601 
  22 
  23 //                             0x000FC005   #1 Mask
  24 //      { 1, KEY_UP                      , 0x00000400 },  // fff -> bff
  25 //      { 1, KEY_DOWN                , 0x00000800 },  // fff -> 7ff
  26         { 1, KEY_LEFT                , 0x00008000 },  // ffff -> efff --> 6fff (hard)  test ef3f ->633f
  27         { 1, KEY_RIGHT               , 0x00004000 },  // ffff -> dfff --> 9fff (hard)  test df3f ->d73f  -> f7ff -> ffff was 4000
  28 //      { 1, KEY_UP_SOFT         , 0x00000400 },  // fff -> bff     //Must add to keyboard.h for use
  29 //      { 1, KEY_DOWN_SOFT           , 0x00000800 },  // fff -> 7ff     //Must add to keyboard.h for use
  30 //      { 1, KEY_LEFT_SOFT           , 0x00001000 },  // ffff -> efff   //Must add to keyboard.h for use
  31 //      { 1, KEY_RIGHT_SOFT          , 0x00002000 },  // ffff -> dfff   //Must add to keyboard.h for use
  32         { 1, KEY_SET                 , 0x00010000 },  // ASM1989 tested (JH) - fffff -> effff
  33 //      { 1, KEY_ZOOM_IN_FASTER  , 0x00000008 },  // f -> 3 (fast) (ORd in with normal)   //Must add to keyboard.h for use
  34 //      { 1, KEY_ZOOM_OUT_FASTER , 0x00000002 },  // f -> c (fast) (ORd in with normal)   //Must add to keyboard.h for use
  35         { 1, KEY_ZOOM_IN         , 0x00000004 },  // f -> b (slow)
  36         { 1, KEY_ZOOM_OUT        , 0x00000001 },  // f -> e (slow)
  37         { 1, KEY_MENU                , 0x00040000 },  // ASM1989 tested (JH) - fffff -> bffff
  38         { 1, KEY_DISPLAY         , 0x00020000 },  // ASM1989 tested (JH) - fffff -> dffff
  39         { 1, KEY_PRINT               , 0x00080000 },  // ASM1989 tested (JH) - fffff -> 7ffff
  40         { 1, KEY_VIDEO               , 0x00080000 },
  41     { 0, 0, 0 }
  42 };
  43 /*
  44 In Review mode   physw_status      0      1      2
  45 iddle   <>   880a19b   <>   fff3f   <>   400000
  46 
  47 
  48 hard press
  49 right   <>   880a19b   <>   fd73f   <>   400000
  50 left   <>   880a19b   <>   f633f   <>   400000
  51 up   <>   880a11b   <>   feb3f   <>   400000
  52 down   <>   880a09b   <>   fe73f   <>   400000
  53 
  54 
  55 iddle Manual   <>   880a19b   <>   fff3f   <>   400000
  56 iddle AV   <>   880a19b   <>   fff1f   <>   400000
  57 iddle TV   <>   880a19b   <>   fff5f   <>   400000
  58 iddle P   <>   880a19b   <>   fffdf   <>   400000
  59 iddle auto   <>   880a19b   <>   fffff   <>   400000
  60 iddle heart   <>   880a19b   <>   fff7f   <>   400000
  61 iddle portriat   <>   880a19b   <>   ffe7f   <>   400000
  62 iddle landscap   <>   880a19b   <>   ffeff   <>   400000
  63 iddle mountain   <>   880a19b   <>   ffe9f   <>   400000
  64 iddle dog   <>   880a19b   <>   ffcdf   <>   400000
  65 iddle fireworks   <>   880a19b   <>   ffddf   <>   400000
  66 iddle SCN   <>   880a19b   <>   ffdff   <>   400000
  67 iddle video   <>   880a19b   <>   ffddf   <>   400000
  68 iddle none   <>   880a19b   <>   ffebf   <>   400000
  69 */
  70 
  71 #define NEW_SS (0x2000)
  72 
  73 static char kbd_stack[NEW_SS];
  74 
  75 int get_usb_bit() 
  76 {
  77         long usb_physw[3];
  78         usb_physw[USB_IDX] = 0;
  79         _kbd_read_keys_r2(usb_physw);
  80         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  81 }
  82 
  83 
  84 int jogdial_stopped=0;
  85 
  86 long __attribute__((naked)) wrap_kbd_p1_f();
  87 
  88 static void __attribute__((noinline)) mykbd_task_proceed() {
  89     while (physw_run) {
  90         _SleepTask(10);
  91 
  92         if (wrap_kbd_p1_f() == 1) {   // autorepeat ?
  93             _kbd_p2_f();
  94         }
  95     }
  96 }
  97 
  98 void __attribute__((naked,noinline)) mykbd_task() {
  99     /* WARNING
 100      * Stack pointer manipulation performed here!
 101      * This means (but not limited to):
 102      *  function arguments destroyed;
 103      *  function CAN NOT return properly;
 104      *  MUST NOT call or use stack variables before stack
 105      *  is setup properly;
 106      *
 107      */
 108 
 109         register int i;
 110         register long *newstack;
 111 
 112         newstack = (void*)kbd_stack;
 113 
 114         for (i=0;i<NEW_SS/4;i++)
 115                 newstack[i]=0xdededede;
 116 
 117         asm volatile (
 118                 "MOV    SP, %0"
 119                 :: "r"(((char*)newstack)+NEW_SS)
 120                 : "memory"
 121         );
 122 
 123 
 124 
 125         mykbd_task_proceed();
 126 
 127 /* function can be modified to restore SP here...
 128          */
 129 
 130         _ExitTask();
 131 }
 132 
 133 // ROM:FF83484C, like SX110
 134 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
 135     asm volatile(
 136                 "STMFD   SP!, {R1-R5,LR}\n"
 137                 "MOV     R4, #0\n"
 138 //                "BL      _kbd_read_keys\n"
 139                 "BL      my_kbd_read_keys\n"     // +
 140                 "B       _kbd_p1_f_cont\n"       // continue at ROM:FF834858
 141     );
 142     return 0;   // shut up the compiler
 143 }
 144 
 145 extern void _GetKbdState(long *dst);
 146 
 147 void my_kbd_read_keys() {
 148     kbd_update_key_state();
 149     kbd_update_physw_bits();
 150 }
 151 
 152 void kbd_fetch_data(long *dst)
 153 {
 154     _GetKbdState(dst);
 155     _kbd_read_keys_r2(dst);
 156 }
 157 
 158 void jogdial_control(int n) {
 159     // this camera did not have jog_position defined
 160     /*
 161     if (jogdial_stopped && !n) {
 162         // If re-enabling jogdial set the task code current & previous positions to the actual
 163         // dial positions so that the change won't get processed by the firmware
 164         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 165     }
 166     */
 167     jogdial_stopped = n;
 168 }
 169 
 170 int Get_JogDial(void) {
 171     return (*(int*)0xC0240104)>>16;     // 0xC0240000 + 0x104
 172 }
 173 
 174 static int new_jogdial=0, old_jogdial=0;
 175 
 176 long get_jogdial_direction(void) {
 177     old_jogdial=new_jogdial;
 178     new_jogdial=Get_JogDial();
 179 
 180     if (old_jogdial<new_jogdial) {
 181         //return JOGDIAL_LEFT;
 182         return JOGDIAL_RIGHT;
 183     } else if (old_jogdial>new_jogdial) {
 184         return JOGDIAL_LEFT;
 185         //return JOGDIAL_RIGHT;
 186     } else {
 187         return 0;
 188     }
 189 }
 190 

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