diff options
author | Chao Xie <chao.xie@marvell.com> | 2013-05-05 23:24:58 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-06-19 01:56:51 -0400 |
commit | 0a085a9482fa51efb58c9d351ea98e83c5df93fc (patch) | |
tree | 411592ae841ea8b18dce07a7e4bce3fce30fcadc /drivers/input | |
parent | 483180281f0ac60d1138710eb21f4b9961901294 (diff) |
Input: pxa27x-keypad - use matrix_keymap for matrix keys
pxa27x-keypad includes matrix keys. Make use of matrix_keymap
for the matrix keys.
Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/Kconfig | 1 | ||||
-rw-r--r-- | drivers/input/keyboard/pxa27x_keypad.c | 35 |
2 files changed, 24 insertions, 12 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 37c366623fc0..706e11bb6a32 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -451,6 +451,7 @@ config KEYBOARD_OPENCORES | |||
451 | config KEYBOARD_PXA27x | 451 | config KEYBOARD_PXA27x |
452 | tristate "PXA27x/PXA3xx keypad support" | 452 | tristate "PXA27x/PXA3xx keypad support" |
453 | depends on PXA27x || PXA3xx || ARCH_MMP | 453 | depends on PXA27x || PXA3xx || ARCH_MMP |
454 | select INPUT_MATRIXKMAP | ||
454 | help | 455 | help |
455 | Enable support for PXA27x/PXA3xx keypad controller. | 456 | Enable support for PXA27x/PXA3xx keypad controller. |
456 | 457 | ||
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c index b674e7aca404..5b2d8764dd37 100644 --- a/drivers/input/keyboard/pxa27x_keypad.c +++ b/drivers/input/keyboard/pxa27x_keypad.c | |||
@@ -118,25 +118,30 @@ struct pxa27x_keypad { | |||
118 | unsigned int direct_key_mask; | 118 | unsigned int direct_key_mask; |
119 | }; | 119 | }; |
120 | 120 | ||
121 | static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) | 121 | static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) |
122 | { | 122 | { |
123 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; | 123 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; |
124 | struct input_dev *input_dev = keypad->input_dev; | 124 | struct input_dev *input_dev = keypad->input_dev; |
125 | const struct matrix_keymap_data *keymap_data = | ||
126 | pdata ? pdata->matrix_keymap_data : NULL; | ||
125 | unsigned short keycode; | 127 | unsigned short keycode; |
126 | int i; | 128 | int i; |
129 | int error; | ||
127 | 130 | ||
128 | for (i = 0; i < pdata->matrix_key_map_size; i++) { | 131 | error = matrix_keypad_build_keymap(keymap_data, NULL, |
129 | unsigned int key = pdata->matrix_key_map[i]; | 132 | pdata->matrix_key_rows, |
130 | unsigned int row = KEY_ROW(key); | 133 | pdata->matrix_key_cols, |
131 | unsigned int col = KEY_COL(key); | 134 | keypad->keycodes, input_dev); |
132 | unsigned int scancode = MATRIX_SCAN_CODE(row, col, | 135 | if (error) |
133 | MATRIX_ROW_SHIFT); | 136 | return error; |
134 | 137 | ||
135 | keycode = KEY_VAL(key); | 138 | /* |
136 | keypad->keycodes[scancode] = keycode; | 139 | * The keycodes may not only include matrix keys but also the direct |
137 | __set_bit(keycode, input_dev->keybit); | 140 | * or rotary keys. |
138 | } | 141 | */ |
142 | input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); | ||
139 | 143 | ||
144 | /* For direct keys. */ | ||
140 | for (i = 0; i < pdata->direct_key_num; i++) { | 145 | for (i = 0; i < pdata->direct_key_num; i++) { |
141 | keycode = pdata->direct_key_map[i]; | 146 | keycode = pdata->direct_key_map[i]; |
142 | keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = keycode; | 147 | keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = keycode; |
@@ -178,6 +183,8 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) | |||
178 | } | 183 | } |
179 | 184 | ||
180 | __clear_bit(KEY_RESERVED, input_dev->keybit); | 185 | __clear_bit(KEY_RESERVED, input_dev->keybit); |
186 | |||
187 | return 0; | ||
181 | } | 188 | } |
182 | 189 | ||
183 | static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) | 190 | static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) |
@@ -555,7 +562,11 @@ static int pxa27x_keypad_probe(struct platform_device *pdev) | |||
555 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | 562 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
556 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); | 563 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
557 | 564 | ||
558 | pxa27x_keypad_build_keycode(keypad); | 565 | error = pxa27x_keypad_build_keycode(keypad); |
566 | if (error) { | ||
567 | dev_err(&pdev->dev, "failed to build keycode\n"); | ||
568 | goto failed_put_clk; | ||
569 | } | ||
559 | 570 | ||
560 | if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || | 571 | if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || |
561 | (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) { | 572 | (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) { |