root/platform/a2100/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. mykbd_task
  3. wrap_kbd_p1_f
  4. kbd_fetch_data
  5. my_kbd_read_keys

   1 /*
   2 ###########################################################
   3 ###########################################################
   4 #############[ FINISHED ] #################################
   5 ###########################################################
   6 ###########################################################
   7 */
   8 
   9 
  10 #include "lolevel.h"
  11 #include "platform.h"
  12 #include "keyboard.h"
  13 #include "kbd_common.h"
  14 
  15 // changed for A2100IS
  16 #define LED_PWR 0xC0220014      // A2100IS Green - power led 
  17 #define LED_DP 0xC0220018               // A2100IS Blue - Direct Print led 
  18 #define LED_AF 0xC022000C               // A2100IS Red - AutoFocus led 
  19 #define DELAY 5000000
  20 
  21 /* 
  22 // #define KEYS_MASK0 (0x00000000)
  23 // #define KEYS_MASK1 (0x11111111)
  24 // #define KEYS_MASK2 (0x00000001) 
  25 
  26 // PS2_orig: 0x7f1424eb
  27 // PS2_mod:  0x  1404eb
  28 // MSK: 0x07000000
  29 // DFF: 0x7f002000
  30 
  31 
  32 // originally:
  33 // PS1: 0x3000{1,9,d}882
  34 // PS2: 0x7f{1,0}424eb
  35 // PS3: 0x224f3e
  36 
  37 //aftermod:
  38 // #define KEYS_MASK1 (0x07000000)
  39 // #define KEYS_MASK2 (0x00000F48) 
  40 // PS1: 0x30001882
  41 // PS2: 0x{_,1}404eb
  42 // PS3: 0x20400c
  43 
  44 // on PWR_BTN press PS3:        0x20404c
  45 // on SHOOT HALF press PS3:     0x204008
  46 // on SHOOT FULL press PS3:     0x204000
  47 // on PLAY press PS3:           0x20408c
  48 
  49 // #define KEYS_MASK0 (0x00000003)
  50 // #define KEYS_MASK1 (0x000FFE18)
  51 // #define KEYS_MASK2 (0x00000000) 
  52 
  53 
  54 // #define KEYS_MASK0 (0x00000000)
  55 // #define KEYS_MASK1 (0x7000000)
  56 // #define KEYS_MASK2 (0xF48) 
  57 
  58 
  59 
  60 orig:
  61 PS1: 0x30001882
  62 PS2: 0x7f0424eb
  63 PS3: 0x224f3e
  64                                                          0x7f0424eb
  65 Disp btn pressed:               PS2: 0x7b0424eb
  66 Menu btn pressed:               PS2: 0x7d0424eb
  67 DP btn   pressed:               PS2: 0x770424eb
  68 FUNC set pressed:               PS2: 0x7e0424eb
  69 
  70 // with commented functions:
  71 PS1: 0x20000102
  72 PS2: 0x7f0025a3
  73 PS3: 0x224f3e
  74 
  75 // with custom reader:
  76 PS1: 0x30001882
  77 PS2: 0x1404eb
  78 PS3: 0x22400c
  79 
  80 PS2df: 0x7EF02000
  81 PS3df:    f32   
  82 
  83   1000000000000000000000000
  84  10000000000000000000000000
  85 100000000000000000000000000
  86 111000000000000000000000000
  87 
  88 KEY_MASK1=7000000
  89 KEY_MASK2=F3C
  90        10000
  91       100000
  92    100000000
  93   1000000000
  94  10000000000
  95 100000000000
  96         1100
  97         1000
  98          100 
  99 111100111100 = F3C
 100 */
 101 
 102 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
 103 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
 104 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
 105 
 106 extern void _GetKbdState(long*);
 107 
 108 
 109 
 110 
 111 int get_usb_bit() {
 112         long usb_physw[3];
 113         usb_physw[USB_IDX] = 0;
 114         _kbd_read_keys_r2(usb_physw);
 115         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
 116 }
 117 
 118 
 119 
 120 /*
 121 PS2: 0xFF1424EB
 122 
 123 On "Smile" PS2: 0xEF1424EB
 124 on DP           PS2:0xF71424EB
 125 @0xffe71624, levent 0x08 0x1010238, 8, 1,
 126 
 127 
 128 PS3 normal:       0x204f3f
 129 PS3 on PLAY     : 0x204fbf
 130 
 131 
 132 
 133   { 1, KEY_PRINT         ,0x08000000 }, // Found manually
 134 */
 135 KeyMap keymap[] = {
 136    { 1, KEY_SET             ,0x01000000 }, // Found @0xffe71624, levent 0x08 0x1010238, 8, 1,
 137    { 1, KEY_MENU            ,0x02000000 }, // Found @0xffe71630, levent 0x09
 138    { 1, KEY_DISPLAY         ,0x04000000 }, // Found @0xffe7163c, levent 0x0a 0x101023A, 0xA, 1
 139    { 1, KEY_PRINT           ,0x08000000 }, // Found manually
 140    { 1, KEY_FACE            ,0x10000000 }, // Found manually
 141    { 2, KEY_ZOOM_IN         ,0x00000010 }, // Found @0xffe716b4, levent 0x02
 142    { 2, KEY_ZOOM_OUT        ,0x00000020 }, // Found @0xffe716c0, levent 0x03 0x1010245, 3, 1
 143    { 2, KEY_UP              ,0x00000100 }, // Found @0xffe716e4, levent 0x04 0x1010248, 4, 1,
 144    { 2, KEY_DOWN            ,0x00000200 }, // Found @0xffe716f0, levent 0x05 0x1010249, 5, 1
 145    { 2, KEY_RIGHT           ,0x00000400 }, // Found @0xffe716fc, levent 0x07
 146    { 2, KEY_LEFT            ,0x00000800 }, // Found @0xffe71708, levent 0x06
 147    { 2, KEY_SHOOT_FULL      ,0x0000000c }, // Found @0xffe716a8, levent 0x01
 148    { 2, KEY_SHOOT_FULL_ONLY ,0x00000008 }, // Found @0xffe716a8, levent 0x01
 149    { 2, KEY_SHOOT_HALF      ,0x00000004 }, // Found @0xffe7169c, levent 0x00
 150    { 0, 0, 0 }
 151 };
 152 
 153 long __attribute__((naked)) wrap_kbd_p1_f() ;
 154 
 155 // no stack manipulation needed here, since we create the task directly
 156 void __attribute__((noinline)) mykbd_task() {
 157 // volatile long *p1 = (void*)LED_PWR;
 158 // volatile long *p2 = (void*)LED_DP;
 159 // int counter; 
 160 // // DEBUG: blink led
 161 // counter = DELAY; *p1 = 0x46;*p2 = 0x46;  while (counter--) { asm("nop\n nop\n"); };
 162 // counter = DELAY; *p1 = 0x44;*p2 = 0x44;  while (counter--) { asm("nop\n nop\n"); }; 
 163 
 164         while (physw_run){
 165                 _SleepTask(10) ;  //    *((int*)(0x1c30+0x14)));
 166 /*
 167                 // asm volatile (
 168                 // "LDR R5, =0xC0220018\n"
 169                 // "MOV R6, #0x46\n"
 170                 // "STR R6,[R5]\n"
 171                 // );
 172                 // counter = 2000000; while (counter--) { asm("nop\n nop\n"); };
 173                 // asm volatile (
 174                 // "LDR R5, =0xC0220018\n"
 175                 // "MOV R6, #0x44\n"
 176                 // "STR R6,[R5]\n"
 177                 // );
 178                 // counter = 2000000; while (counter--) { asm("nop\n nop\n"); };
 179 */
 180                 
 181                  if (wrap_kbd_p1_f() == 1){ // autorepeat ?
 182                         _kbd_p2_f();
 183                  }
 184         }
 185 
 186     _ExitTask();
 187 }
 188 
 189 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
 190         asm volatile(
 191                 "STMFD   SP!, {R1-R5,LR}\n"
 192                 "MOV     R4, #0\n"
 193         //      "BL      _kbd_read_keys \n"
 194                 "BL             my_kbd_read_keys\n" // replaced temporary
 195                 "B       _kbd_p1_f_cont\n"
 196         );
 197         return 0; // shut up the compiler
 198 }
 199 
 200 
 201 void kbd_fetch_data(long *dst){
 202         _GetKbdState(dst);
 203         
 204 
 205         /* Get the rest of the buttons */
 206         // NSTUB(kbd_read_keys                           ,0xffc11a0c) //109
 207         // NSTUB(kbd_read_keys_r2                        ,0xffc304dc) //109
 208         _kbd_read_keys_r2(dst); // without this PS3 is almost empty: PS3: 0x400c
 209 
 210     /*
 211     volatile long *mmio0 = (void*)0xc0220200;
 212     volatile long *mmio1 = (void*)0xc0220204;
 213     volatile long *mmio2 = (void*)0xc0220208;
 214 
 215     dst[0] = *mmio0;
 216     dst[1] = *mmio1;// | 0x7EF02000;
 217     dst[2] = *mmio2;// | 0xf32;
 218 //  dst[2] = *mmio2;
 219 */
 220 }
 221 
 222 void my_kbd_read_keys() {
 223         _kbd_pwr_on();  // i.e. kbd_pwr_on      ROM:FFC11A28                 BL      _sub_FFC30B94__PhySwGpio.c__0 ; LOCATION: PhySwGpio.c:0
 224     kbd_update_key_state();
 225     kbd_update_physw_bits();
 226 // _kbd_pwr_off();
 227 }
 228 
 229 

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