root/platform/ixus990_sd970/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. my_kbd_read_keys
  5. jogdial_control
  6. kbd_fetch_data
  7. Get_JogDial
  8. 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 // sd970: CHDKPTP key checking: rmem -i32 0x0000edf8 3
  11 // exectude both for pressed and not pressed state and compare
  12 KeyMap keymap[] = {
  13     /* tiny bug: key order matters. see kbd_get_pressed_key()
  14      * for example
  15      */
  16     { 0, KEY_SET             ,0x00000004 }, // sd970: Found @0xffaf1264, levent 0x08
  17     { 0, KEY_DISPLAY         ,0x00000008 }, // sd970: Found @0xffaf1270, levent 0x0a
  18     { 2, KEY_MENU            ,0x00000001 }, // sd970: Found @0xffaf1288, levent 0x09
  19         { 2, KEY_PRINT           ,0x00000002 }, // checked on sd970
  20     { 2, KEY_ZOOM_IN         ,0x00000004 }, // sd970: Found @0xffaf12a0, levent 0x02
  21     { 2, KEY_ZOOM_OUT        ,0x00000008 }, // sd970: Found @0xffaf12ac, levent 0x03
  22     { 2, KEY_LEFT            ,0x00000010 }, // sd970: Found @0xffaf12b8, levent 0x06
  23     { 2, KEY_RIGHT           ,0x00000020 }, // sd970: Found @0xffaf12c4, levent 0x07
  24     { 2, KEY_DOWN            ,0x00000040 }, // sd970: Found @0xffaf12d0, levent 0x05
  25     { 2, KEY_UP              ,0x00000080 }, // sd970: Found @0xffaf12dc, levent 0x04
  26     { 2, KEY_SHOOT_FULL      ,0x00000300 }, // sd970: Found @0xffaf12f4, levent 0x01
  27     { 2, KEY_SHOOT_FULL_ONLY ,0x00000200 }, // sd970: Found @0xffaf12f4, levent 0x01
  28     { 2, KEY_SHOOT_HALF      ,0x00000100 }, // sd970: Found @0xffaf12e8, levent 0x00
  29 //    { 2, KEY_POWER           ,0x00000400 }, // sd970: Found @0xffaf1300, levent 0x600
  30     { 2, KEY_PLAYBACK        ,0x00000800 }, // sd970: Found @0xffaf130c, levent 0x601
  31     { 0, 0, 0 }
  32 };
  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 int jogdial_stopped=0;
  43 
  44 void kbd_fetch_data(long*);
  45 
  46 long __attribute__((naked)) wrap_kbd_p1_f();
  47 
  48 // no stack manipulation needed here, since we create the task directly
  49 void __attribute__((noinline))
  50 mykbd_task()
  51 {
  52     while (physw_run){
  53         _SleepTask(10);
  54 
  55         if (wrap_kbd_p1_f() == 1){ // autorepeat ?
  56             _kbd_p2_f();
  57         }
  58     }
  59     _ExitTask();
  60 }
  61 
  62 long __attribute__((naked,noinline)) wrap_kbd_p1_f()
  63 {
  64 
  65     asm volatile(
  66                 "STMFD   SP!, {R1-R5,LR}\n"
  67                 "MOV     R4, #0\n"
  68                 "BL      my_kbd_read_keys\n"
  69                 "B       _kbd_p1_f_cont\n"
  70     );
  71     return 0; // shut up the compiler
  72 }
  73 
  74 void my_kbd_read_keys()
  75 {
  76     kbd_update_key_state();
  77 
  78     _kbd_read_keys_r2(physw_status);
  79 
  80     kbd_update_physw_bits();
  81 }
  82 
  83 extern short rear_dial_position;
  84 // jog_position hack does not appear to be needed on older cams
  85 void jogdial_control(int n) {
  86     jogdial_stopped = n;
  87 }
  88 
  89 void kbd_fetch_data(long *dst)
  90 {
  91         //sd970: 0xFF843f6c GetKbdState
  92     volatile long *mmio0 = (void*)0xc0220200;
  93     volatile long *mmio1 = (void*)0xc0220204;
  94     volatile long *mmio2 = (void*)0xc0220208;
  95 
  96     dst[0] = *mmio0;
  97     dst[1] = *mmio1;
  98     dst[2] = *mmio2 & 0xffff;
  99 }
 100 
 101 static short new_jogdial = 0, old_jogdial = 0;
 102 
 103 int Get_JogDial(void){
 104  return (*(int*)0xC0240104)>>16; //sd970: Address checked
 105 }
 106 
 107 long get_jogdial_direction(void) { 
 108  old_jogdial=new_jogdial;
 109  new_jogdial=Get_JogDial();
 110  if (old_jogdial<new_jogdial) return JOGDIAL_LEFT; 
 111  else if (old_jogdial>new_jogdial) return JOGDIAL_RIGHT;
 112  else return 0;
 113 }
 114 
 115 

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