omap3-pandora-kernel: Add AUFS2 shim and keypad 'WIP' code.
[openpandora.oe.git] / recipes / linux / omap3-pandora-kernel / keypad / 0007-some-hackish-Fn-handling-for-testing.patch
1 From fc359f9dd7efd346c070950320dda62ae671519f Mon Sep 17 00:00:00 2001
2 From: Grazvydas Ignotas <notasas@gmail.com>
3 Date: Thu, 5 Nov 2009 12:52:23 +0200
4 Subject: [PATCH 7/7] some hackish Fn handling for testing
5
6 ---
7  arch/arm/mach-omap2/board-omap3pandora-input.c |   47 ++++++++++++++++++++++++
8  drivers/input/keyboard/twl4030_keypad.c        |   39 +++++++++++++++++---
9  2 files changed, 81 insertions(+), 5 deletions(-)
10
11 diff --git a/arch/arm/mach-omap2/board-omap3pandora-input.c b/arch/arm/mach-omap2/board-omap3pandora-input.c
12 index ce9df0e..3d530cf 100644
13 --- a/arch/arm/mach-omap2/board-omap3pandora-input.c
14 +++ b/arch/arm/mach-omap2/board-omap3pandora-input.c
15 @@ -31,6 +31,9 @@
16  /* hardware debounce, (value + 1) * 31us */
17  #define GPIO_DEBOUNCE_TIME 0x7f
18  
19 +/* HACK: this requires patched twl4030_keypad driver */
20 +#define FNKEY(row, col, code) KEY((row + 8), col, code)
21 +
22  static int omap3pandora_keymap[] = {
23         /* row, col, code */
24         KEY(0, 0, KEY_9),
25 @@ -76,6 +79,50 @@ static int omap3pandora_keymap[] = {
26         KEY(7, 2, KEY_Q),
27         KEY(7, 3, KEY_LEFTSHIFT),
28         KEY(7, 4, KEY_COMMA),
29 +       /* Fn keys */
30 +       FNKEY(0, 0, KEY_F9),
31 +       FNKEY(0, 1, KEY_F8),
32 +       FNKEY(0, 2, KEY_BRIGHTNESSUP),
33 +       FNKEY(0, 3, KEY_F13),           /* apostrophe, differs from Fn-A? */
34 +       FNKEY(0, 4, KEY_DOLLAR),
35 +       FNKEY(0, 5, KEY_EURO),
36 +       FNKEY(1, 0, KEY_F10),
37 +       FNKEY(1, 1, KEY_F7),
38 +       FNKEY(1, 2, KEY_BRIGHTNESSDOWN),
39 +       FNKEY(1, 3, KEY_GRAVE),
40 +       FNKEY(1, 4, KEY_F14),           /* pipe/bar */
41 +       FNKEY(1, 5, KEY_TAB),
42 +       FNKEY(2, 0, KEY_INSERT),
43 +       FNKEY(2, 1, KEY_F6),
44 +       FNKEY(2, 2, KEY_F15),           /* dash */
45 +       FNKEY(2, 3, KEY_EQUAL),
46 +       FNKEY(2, 4, KEY_F16),           /* # (pound/hash) */
47 +       FNKEY(2, 5, KEY_FN),
48 +       FNKEY(3, 0, KEY_F11),
49 +       FNKEY(3, 1, KEY_F5),
50 +       FNKEY(3, 2, KEY_F17),           /* ! */
51 +       FNKEY(3, 3, KEY_KPPLUS),
52 +       FNKEY(3, 4, KEY_BACKSLASH),
53 +       FNKEY(4, 0, KEY_F12),
54 +       FNKEY(4, 1, KEY_F4),
55 +       FNKEY(4, 2, KEY_RIGHTBRACE),
56 +       FNKEY(4, 3, KEY_KPMINUS),
57 +       FNKEY(4, 4, KEY_QUESTION),
58 +       FNKEY(5, 0, KEY_F18),           /* £ (pound) */
59 +       FNKEY(5, 1, KEY_F3),
60 +       FNKEY(5, 2, KEY_LEFTBRACE),
61 +       FNKEY(5, 3, KEY_F19),           /* " */
62 +       FNKEY(5, 4, KEY_SLASH),
63 +       FNKEY(6, 0, KEY_YEN),
64 +       FNKEY(6, 1, KEY_F2),
65 +       FNKEY(6, 2, KEY_F20),           /* @ */
66 +       FNKEY(6, 3, KEY_APOSTROPHE),
67 +       FNKEY(6, 4, KEY_F21),           /* : */
68 +       FNKEY(7, 0, KEY_ENTER),
69 +       FNKEY(7, 1, KEY_F1),
70 +       FNKEY(7, 2, KEY_ESC),
71 +       FNKEY(7, 3, KEY_CAPSLOCK),
72 +       FNKEY(7, 4, KEY_SEMICOLON),
73  };
74  
75  static struct matrix_keymap_data board_map_data = {
76 diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
77 index 99bb58d..74485d6 100644
78 --- a/drivers/input/keyboard/twl4030_keypad.c
79 +++ b/drivers/input/keyboard/twl4030_keypad.c
80 @@ -52,7 +52,7 @@
81  #define TWL4030_MAX_ROWS       8       /* TWL4030 hard limit */
82  #define TWL4030_MAX_COLS       8
83  #define TWL4030_ROW_SHIFT      3
84 -#define TWL4030_KEYMAP_SIZE    (TWL4030_MAX_ROWS * TWL4030_MAX_COLS)
85 +#define TWL4030_KEYMAP_SIZE    (TWL4030_MAX_ROWS * 2 * TWL4030_MAX_COLS)
86  
87  struct twl4030_keypad {
88         unsigned short  keymap[TWL4030_KEYMAP_SIZE];
89 @@ -61,6 +61,9 @@ struct twl4030_keypad {
90         unsigned        n_cols;
91         unsigned        irq;
92  
93 +       unsigned        fn_down:1;
94 +       unsigned        fn_sticked:1;
95 +
96         struct device *dbg_dev;
97         struct input_dev *input;
98  };
99 @@ -226,7 +229,8 @@ static void twl4030_kp_scan(struct twl4030_keypad *kp, bool release_all)
100                         continue;
101  
102                 for (col = 0; col < kp->n_cols; col++) {
103 -                       int code;
104 +                       int code, kcode, is_down;
105 +                       int code2;
106  
107                         if (!(changed & (1 << col)))
108                                 continue;
109 @@ -236,9 +240,34 @@ static void twl4030_kp_scan(struct twl4030_keypad *kp, bool release_all)
110                                 "press" : "release");
111  
112                         code = MATRIX_SCAN_CODE(row, col, TWL4030_ROW_SHIFT);
113 +                       kcode = kp->keymap[code];
114 +                       is_down = (new_state[row] & (1 << col)) ? 1 : 0;
115 +
116 +                       dev_dbg(kp->dbg_dev, "code:     %d %d\n", code, kcode);
117 +                       /* Fn handling */
118 +                       if (kcode == KEY_FN) {
119 +                               kp->fn_down = is_down;
120 +                               kp->fn_sticked |= is_down;
121 +                       } else if (kp->fn_down || kp->fn_sticked) {
122 +                               /* make sure other function is up */
123 +                               input_event(input, EV_MSC, MSC_SCAN, code);
124 +                               input_report_key(input, kcode, 0);
125 +
126 +                               code = MATRIX_SCAN_CODE(row + TWL4030_MAX_ROWS,
127 +                                       col, TWL4030_ROW_SHIFT);
128 +                               kcode = kp->keymap[code];
129 +
130 +                               kp->fn_sticked = 0;
131 +                       } else {
132 +                               code2 = MATRIX_SCAN_CODE(row + TWL4030_MAX_ROWS,
133 +                                       col, TWL4030_ROW_SHIFT);
134 +                               input_event(input, EV_MSC, MSC_SCAN, code2);
135 +                               input_report_key(input, kp->keymap[code2], 0);
136 +                       }
137 +
138 +                       dev_dbg(kp->dbg_dev, "code(fn): %d %d\n", code, kcode);
139                         input_event(input, EV_MSC, MSC_SCAN, code);
140 -                       input_report_key(input, kp->keymap[code],
141 -                                        new_state[row] & (1 << col));
142 +                       input_report_key(input, kcode, is_down);
143                 }
144                 kp->kp_state[row] = new_state[row];
145         }
146 @@ -371,7 +400,7 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev)
147  
148         input_set_capability(input, EV_MSC, MSC_SCAN);
149  
150 -       input->name             = "TWL4030 Keypad";
151 +       input->name             = "omap_twl4030keypad";
152         input->phys             = "twl4030_keypad/input0";
153         input->dev.parent       = &pdev->dev;
154  
155 -- 
156 1.6.3.1
157