root/platform/ixus700_sd500/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. mykbd_task_proceed
  2. mykbd_task_proceed_2
  3. mykbd_task
  4. wrap_kbd_p1_f
  5. my_kbd_read_keys
  6. usb_power_status_override

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "conf.h"
   4 #include "core.h"
   5 #include "keyboard.h"
   6 #include "kbd_common.h"
   7 
   8 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  10 long kbd_mod_state [3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
  11 
  12 KeyMap keymap[] = {
  13     /* tiny bug: key order matters. see kbd_get_pressed_key()
  14      * for example
  15      */
  16         {1, KEY_UP      , 0x00000020 },
  17         {1, KEY_DOWN    , 0x00000040 },
  18         {1, KEY_LEFT    , 0x00000080 },
  19         {1, KEY_RIGHT   , 0x00000100 },
  20         {1, KEY_SET     , 0x00000200 },
  21         {1, KEY_SHOOT_FULL, 0x00000006 }, // note 6 here!
  22     {1, KEY_SHOOT_FULL_ONLY, 0x00000004 }, 
  23         {1, KEY_SHOOT_HALF, 0x00000002 },
  24         {1, KEY_ZOOM_IN , 0x00000008 },
  25         {1, KEY_ZOOM_OUT        , 0x00000010 },
  26         {1, KEY_MENU    , 0x00000400 },
  27         {1, KEY_DISPLAY , 0x00000800 },
  28         {1, KEY_PRINT   , 0x00002000 },
  29         {0, 0, 0 }
  30 };
  31 
  32 
  33 #define NEW_SS (0x2000)
  34 
  35 static char kbd_stack[NEW_SS];
  36 
  37 extern void _platformsub_kbd_fetch_data(long*);
  38 long __attribute__((naked)) wrap_kbd_p1_f();
  39 void __attribute__((naked,noinline)) mykbd_task_proceed_2();
  40 extern void h_kbd_p2_f();
  41 
  42 
  43 static void __attribute__((noinline)) mykbd_task_proceed()
  44 {
  45     asm volatile(
  46                  "STMFD   SP!, {R4,LR}\n"
  47                  "B       mykbd_task_proceed_2\n"
  48         );
  49 }
  50 
  51 
  52 
  53 
  54 void __attribute__((noinline)) mykbd_task_proceed_2()
  55 {
  56     asm volatile(
  57 "loc_FF828ED8:\n"
  58                  "MOV     R0, #0xA\n"
  59                  "BL      _SleepTask\n"
  60                  "BL      wrap_kbd_p1_f\n"
  61                  "CMP     R0, #1\n"
  62                  "BNE     loc_FF828ED8\n"
  63                  "B       h_kbd_p2_f\n"
  64         );
  65 }
  66 
  67 
  68 void __attribute__((naked,noinline))
  69 mykbd_task(long ua, long ub, long uc, long ud, long ue, long uf)
  70 {
  71     /* WARNING
  72      * Stack pointer manipulation performed here!
  73      * This means (but not limited to):
  74      *  function arguments destroyed;
  75      *  function CAN NOT return properly;
  76      *  MUST NOT call or use stack variables before stack
  77      *  is setup properly;
  78      *
  79      */
  80 
  81     register int i;
  82     register long *newstack;
  83 
  84     newstack = (void*)kbd_stack;
  85 
  86     for (i=0;i<NEW_SS/4;i++)
  87         newstack[i]=0xdededede;
  88 
  89     asm volatile (
  90         "MOV    SP, %0"
  91         :: "r"(((char*)newstack)+NEW_SS)
  92         : "memory"
  93     );
  94 
  95     mykbd_task_proceed();
  96 
  97     /* function can be modified to restore SP here...
  98      */
  99 
 100     _ExitTask();
 101 }
 102 
 103 
 104 
 105 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
 106 {
 107 //    kbd_prev_state[0] = kbd_new_state[0];
 108     kbd_prev_state[1] = kbd_new_state[1];
 109 //    kbd_prev_state[2] = kbd_new_state[2];
 110 
 111     asm volatile(
 112                  "STMFD   SP!, {R4-R10,LR}\n"
 113                  "LDR     R4, =physw_status-0x10\n"
 114                  "SUB     SP, SP, #0x18\n"
 115                  "BL      _kbd_p1_1\n"
 116                  "BL      _kbd_p1_2\n"
 117                  "MOV     R0, #0x32\n"
 118                  "BL      _kbd_p1_3\n"
 119                  "MOV     R0, R4\n"
 120                  "BL      _platformsub_kbd_fetch_data_my\n"
 121                  "B       _kbd_p1_f_cont\n"
 122 
 123     );
 124     return 0; // shut up the compiler
 125 }
 126 
 127 
 128 
 129 long my_kbd_read_keys(long x)
 130 {
 131  
 132  kbd_new_state[1]=x & 0xFFFF;
 133  if (kbd_process() == 0) return x; else return (kbd_new_state[1]&~KEYS_MASK1) | (kbd_mod_state[1] & KEYS_MASK1);
 134 }
 135 
 136 extern int forced_usb_port;
 137 int usb_power_status_override(int status){
 138     if (forced_usb_port) {
 139         return status | USB_MASK;
 140     }
 141         if (conf.remote_enable) {
 142                 return status &~USB_MASK;
 143         }
 144     return status;
 145 }

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