root/platform/s5is/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

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "keyboard.h"
   4 #include "kbd_common.h"
   5 
   6 
   7 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   8 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };;
  10 
  11 #define NEW_SS (0x2000)
  12 
  13 int get_usb_bit()
  14 {
  15         long usb_physw[3];
  16         usb_physw[USB_IDX] = 0;
  17         _kbd_read_keys_r2(usb_physw);
  18         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  19 }
  20 
  21 extern void _GetKbdState(long *dst);
  22 
  23 static char kbd_stack[NEW_SS];
  24 
  25 
  26 KeyMap keymap[] = {
  27         /* tiny bug: key order matters. see kbd_get_pressed_key()
  28          * for example
  29          */
  30 // physw_status[1] total mask: 0x7F3F7860
  31 //      { 1, ??           , 0x80000000 }, // Default 0, unused?
  32         { 1, KEY_MACRO    , 0x40000000 }, 
  33         { 1, KEY_MF       , 0x20000000 }, 
  34         { 1, KEY_ZOOM_IN  , 0x10000000 }, // Zoom_in_fast  = 0x08000000 | 0x10000000
  35 //      { 1, KEY_ZOOMFIN  , 0x08000000 }, // Not defined in CHDK
  36 //      { 1, KEY_ZOOMFOUT , 0x04000000 }, // Not defined in CHDK
  37         { 1, KEY_TIMER    , 0x02000000 }, 
  38         { 1, KEY_ZOOM_OUT , 0x01000000 }, // Zoom_out_fast = 0x04000000 | 0x01000000
  39 //      { 1, ??           , 0x00800000 }, // Default 0, unused?
  40 //      { 1, ??           , 0x00400000 }, // Default 1, unused?
  41         { 1, KEY_RIGHT    , 0x00200000 }, 
  42         { 1, KEY_UP       , 0x00100000 }, 
  43         { 1, KEY_DOWN     , 0x00080000 }, 
  44         { 1, KEY_MENU     , 0x00040000 }, 
  45         { 1, KEY_DISPLAY  , 0x00020000 }, 
  46         { 1, KEY_SET      , 0x00010000 }, 
  47 //      { 1, ??           , 0x00008000 }, // Default 0, unused?
  48         { 1, KEY_ERASE    , 0x00004000 }, 
  49         { 1, KEY_VIDEO    , 0x00002000 }, 
  50         { 1, KEY_LEFT     , 0x00001000 }, 
  51         { 1, KEY_ISO      , 0x00000800 }, 
  52 //      { 1, ??           , 0x00000400 }, // Default 1, unused?
  53 //      { 1, KEY_DISP_ROTA, 0x00000200 }, // Indicates whether or not display is rotated, not defined, though used in CHDK
  54 //   { 1, KEY_DISP_OPEN, 0x00000100 }, // Indicates whether or not display is attached to body (i.e. not 'opened'), not defined, though used in CHDK
  55 //      { 1, ??           , 0x00000080 }, // Default 0, unused?
  56         { 1, KEY_PRINT    , 0x00000040 }, 
  57         { 1, KEY_FLASH    , 0x00000020 }, 
  58 //      { 1, KEY_FL_RAISED, 0x00000010 }, // Indicates whether or not the flash is raised, not defined in CHDK
  59 //      { 1, KEY_MODE_DIAL, 0x0000000F }, // Listed for completeness of the keymap
  60 //   { 1, MODE_DIAL_P         , 0x00000007 },
  61 //   { 1, MODE_DIAL_TV        , 0x00000003 },
  62 //   { 1, MODE_DIAL_AV        , 0x00000002 },
  63 //   { 1, MODE_DIAL_M         , 0x00000006 },
  64 //   { 1, MODE_DIAL_C         , 0x00000004 },
  65 //   { 1, MODE_DIAL_AUTO      , 0x0000000F },
  66 //   { 1, MODE_DIAL_PORTRAIT  , 0x0000000E },
  67 //   { 1, MODE_DIAL_LANDSCAPE , 0x0000000A },
  68 //   { 1, MODE_DIAL_NIGHT     , 0x0000000B },
  69 //   { 1, MODE_DIAL_SPORTS    , 0x00000009 },
  70 //   { 1, MODE_DIAL_SPECIAL   , 0x00000001 },
  71 //   { 1, MODE_DIAL_STITCH    , 0x00000005 },
  72 //   { 1, MODE_DIAL_MOVIE     , 0x0000000D },
  73 //   { 1, MODE_DIAL_EMPTY     , 0x0000000C },
  74 // 0 and 8 appear to be unused
  75 
  76 
  77 // physw_status[0] // 6 listed keys seem to fully cover [0], though some appear to use negative logic so can't be certain.
  78 //      { 0, KEY_OFF       , 0x00020000 }, // Not defined in CHDK
  79 //      { 0, KEY_OPEN_BATT , 0x00008000 }, // Indicates whether or not the battery compartment is about to be opened (slider is a button). Camera does not retract lens, though, shame. Not defined in CHDK
  80 //      { 0, KEY_M_DISPLAY , 0x00000008 }, // Switch to display mode, not defined in CHDK (negative? Default 0, 1 when switching)
  81 //      { 0, KEY_M_SHOOT   , 0x00000004 }, // Switch to shoot mode, not defined in CHDK (negative? Default 0, 1 when switching)
  82 //      { 0, KEY_SHOOT_FULL, 0x00000002 }, // Listed for completeness, this is the 'single' key.
  83         { 0, KEY_SHOOT_FULL, 0x00000003 }, // This is SHOOT_FULL_ONLY | SHOOT_HALF.
  84     { 0, KEY_SHOOT_FULL_ONLY, 0x00000002 }, 
  85         { 0, KEY_SHOOT_HALF, 0x00000001 }, 
  86 
  87 
  88 // physw_status[2]
  89 //      { 2, USB_ATTACH    , 0x00200000 }, // 0 = no USB, 1 = USB attached
  90 //      { 2, FLASH_ATTACH  , 0x00080000 }, // 0 = no flash, 1 = Hotshoe external flash attached
  91 //   { 2, TVOUT_ATTACH  , 0x00040000 }, // 1 = no tvout, 0 = tvout attached
  92 //      { 2, SD_LOCK       , 0x00020000 }, // 0 = unlocked, 1 = locked
  93 
  94 
  95 // I don't really remember whether or not this is correct, listed for completeness
  96 // Shoot mode   = (*((long *)0xC0220200) & 0xD) == 0xD
  97 // Display mode = (*((long *)0xC0220200) & 0xD) == 0x0
  98 
  99         {0, 0, 0 }
 100 };
 101 
 102 
 103 long __attribute__((naked)) wrap_kbd_p1_f();
 104 
 105 
 106 static void __attribute__((noinline)) mykbd_task_proceed()
 107 {
 108         while (physw_run){
 109                 _SleepTask(10);
 110                 
 111                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
 112                         _kbd_p2_f();
 113                 }
 114         }
 115 }
 116 
 117 void __attribute__((naked,noinline)) mykbd_task()
 118 {
 119     /* WARNING
 120      * Stack pointer manipulation performed here!
 121      * This means (but not limited to):
 122      *  function arguments destroyed;
 123      *  function CAN NOT return properly;
 124      *  MUST NOT call or use stack variables before stack
 125      *  is setup properly;
 126      *
 127      */
 128 
 129         register int i;
 130         register long *newstack;
 131 
 132         newstack = (void*)kbd_stack;
 133 
 134         for (i=0;i<NEW_SS/4;i++)
 135                 newstack[i]=0xdededede;
 136 
 137         asm volatile (
 138                 "MOV    SP, %0"
 139                 :: "r"(((char*)newstack)+NEW_SS)
 140                 : "memory"
 141         );
 142 
 143         mykbd_task_proceed();
 144 
 145         /* function can be modified to restore SP here...
 146          */
 147 
 148         _ExitTask();
 149 }
 150 
 151 
 152 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
 153 {
 154 
 155         asm volatile(
 156                 "STMFD   SP!, {R1-R5,LR}\n"
 157                 "MOV     R4, #0\n"
 158 //              "BL      _kbd_read_keys\n"
 159                 "BL      my_kbd_read_keys\n"
 160                 "B       _kbd_p1_f_cont\n"
 161         );
 162         return 0; // shut up the compiler
 163 }
 164 
 165 
 166 void my_kbd_read_keys()
 167 {
 168     kbd_update_key_state();
 169     kbd_update_physw_bits();
 170 }
 171 
 172 void kbd_fetch_data(long *dst)
 173 {
 174     _GetKbdState(dst);
 175     _kbd_read_keys_r2(dst);
 176 }
 177 

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