root/platform/sx20/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. my_blinkk
  2. get_usb_bit
  3. mykbd_task_proceed
  4. mykbd_task
  5. wrap_kbd_p1_f
  6. my_kbd_read_keys
  7. kbd_fetch_data
  8. jogdial_control
  9. Get_JogDial
  10. 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 extern void _platformsub_kbd_fetch_data(long*);
  11 
  12 
  13 #if 0
  14 void my_blinkk(void) {
  15         int i;
  16 //      while(1) {
  17                 *((volatile int *) 0xC02200B6) = 0x46; // Turn on LED
  18                 for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  19 
  20                 *((volatile int *) 0xC02200B6) = 0x44; // Turn off LED
  21                 for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  22 
  23                 *((volatile int *) 0xC02200B6) = 0x46; // Turn on LED
  24                 for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  25 
  26                 *((volatile int *) 0xC02200B6) = 0x44; // Turn off LED
  27                 for (i=0; i<0x900000; i++) { asm volatile ( "nop\n" ); }
  28 //      }
  29 }
  30 #endif 
  31 
  32 #define NEW_SS (0x2000)
  33 
  34 int get_usb_bit() 
  35 {
  36         long usb_physw[3];
  37         usb_physw[USB_IDX] = 0;
  38         _kbd_read_keys_r2(usb_physw);
  39         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  40 }
  41 
  42 static char kbd_stack[NEW_SS];
  43 
  44 KeyMap keymap[] = {
  45         /* tiny bug: key order matters. see kbd_get_pressed_key()
  46          * for example
  47          */
  48 
  49         { 0, KEY_SHOOT_FULL     , 0x00000003 },
  50     { 0, KEY_SHOOT_FULL_ONLY, 0x00000002 },
  51         { 0, KEY_SHOOT_HALF     , 0x00000001 },
  52 
  53         { 1, KEY_UP             , 0x00000400 },
  54         { 1, KEY_DOWN           , 0x00000800 },
  55         { 1, KEY_LEFT           , 0x00002000 },
  56         { 1, KEY_RIGHT          , 0x00001000 },
  57         { 1, KEY_SET            , 0x00000100 },
  58         { 1, KEY_ZOOM_IN        , 0x00008000 },
  59         { 1, KEY_ZOOM_OUT       , 0x00040000 },
  60         { 1, KEY_MENU           , 0x00004000 },
  61         { 1, KEY_DISPLAY        , 0x00000200 },
  62         { 1, KEY_PRINT          , 0x00800000 },
  63         { 1, KEY_ERASE          , 0x00000080 },
  64         { 1, KEY_EXPO_CORR      , 0x00000040 },
  65         { 1, KEY_FLASH          , 0x00100000 },
  66         { 1, KEY_VIDEO          , 0x00000020 },
  67         { 0, 0, 0 } 
  68 };
  69 
  70 
  71 long __attribute__((naked)) wrap_kbd_p1_f();
  72 
  73 
  74 static void __attribute__((noinline)) mykbd_task_proceed()
  75 {
  76         while (physw_run){
  77                 _SleepTask(10);
  78 
  79                 if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  80                         _kbd_p2_f();
  81                 }
  82         }
  83 }
  84 
  85 void __attribute__((naked,noinline)) mykbd_task()
  86 {
  87     /* WARNING
  88      * Stack pointer manipulation performed here!
  89      * This means (but not limited to):
  90      *  function arguments destroyed;
  91      *  function CAN NOT return properly;
  92      *  MUST NOT call or use stack variables before stack
  93      *  is setup properly;
  94      *
  95      */
  96 
  97         register int i;
  98         register long *newstack;
  99 
 100         newstack = (void*)kbd_stack;
 101 
 102         for (i=0;i<NEW_SS/4;i++)
 103                 newstack[i]=0xdededede;
 104 
 105         asm volatile (
 106                 "MOV    SP, %0"
 107                 :: "r"(((char*)newstack)+NEW_SS)
 108                 : "memory"
 109         );
 110 
 111         mykbd_task_proceed();
 112 
 113         /* function can be modified to restore SP here...
 114          */
 115 
 116         _ExitTask();
 117 }
 118 
 119 
 120 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
 121 {
 122         asm volatile(
 123                 "STMFD   SP!, {R1-R5,LR}\n"
 124                 "MOV     R4, #0\n"
 125                 "BL      my_kbd_read_keys\n"
 126                 "B       _kbd_p1_f_cont\n"
 127         );
 128         return 0; // shut up the compiler
 129 }
 130 
 131 int jogdial_stopped=0;
 132 
 133 void my_kbd_read_keys()
 134 {
 135     kbd_update_key_state();
 136 
 137     _kbd_read_keys_r2(physw_status);
 138 
 139     kbd_update_physw_bits();
 140 }
 141 
 142 void kbd_fetch_data(long *dst) 
 143 {
 144     _platformsub_kbd_fetch_data(dst);
 145 }
 146 
 147 
 148 
 149 void jogdial_control(int n) {
 150     // this camera did not have jog_position defined
 151     /*
 152     if (jogdial_stopped && !n) {
 153         // If re-enabling jogdial set the task code current & previous positions to the actual
 154         // dial positions so that the change won't get processed by the firmware
 155         jog_position[0] = jog_position[2] = rear_dial_position;   // Rear dial
 156     }
 157     */
 158     jogdial_stopped = n;
 159 }
 160 
 161 static int new_jogdial=0, old_jogdial=0;
 162 
 163 int Get_JogDial(void){
 164  return (*(int*)0xC0240104)>>16;
 165 }
 166 
 167 long get_jogdial_direction(void) {
 168  old_jogdial=new_jogdial;
 169  new_jogdial=Get_JogDial();
 170  if (old_jogdial<new_jogdial) return JOGDIAL_LEFT;
 171  else if (old_jogdial>new_jogdial) return JOGDIAL_RIGHT;
 172  else return 0;
 173 }

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