diff options
| -rw-r--r-- | drivers/input/keyboard/matrix_keypad.c | 15 | ||||
| -rw-r--r-- | drivers/input/keyboard/w90p910_keypad.c | 16 | ||||
| -rw-r--r-- | include/linux/input/matrix_keypad.h | 32 |
3 files changed, 37 insertions, 26 deletions
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c index 541b981ff075..91cfe5170265 100644 --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c | |||
| @@ -319,7 +319,6 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev) | |||
| 319 | struct input_dev *input_dev; | 319 | struct input_dev *input_dev; |
| 320 | unsigned short *keycodes; | 320 | unsigned short *keycodes; |
| 321 | unsigned int row_shift; | 321 | unsigned int row_shift; |
| 322 | int i; | ||
| 323 | int err; | 322 | int err; |
| 324 | 323 | ||
| 325 | pdata = pdev->dev.platform_data; | 324 | pdata = pdev->dev.platform_data; |
| @@ -363,18 +362,10 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev) | |||
| 363 | 362 | ||
| 364 | input_dev->keycode = keycodes; | 363 | input_dev->keycode = keycodes; |
| 365 | input_dev->keycodesize = sizeof(*keycodes); | 364 | input_dev->keycodesize = sizeof(*keycodes); |
| 366 | input_dev->keycodemax = pdata->num_row_gpios << keypad->row_shift; | 365 | input_dev->keycodemax = pdata->num_row_gpios << row_shift; |
| 367 | |||
| 368 | for (i = 0; i < keymap_data->keymap_size; i++) { | ||
| 369 | unsigned int key = keymap_data->keymap[i]; | ||
| 370 | unsigned int row = KEY_ROW(key); | ||
| 371 | unsigned int col = KEY_COL(key); | ||
| 372 | unsigned short code = KEY_VAL(key); | ||
| 373 | 366 | ||
| 374 | keycodes[MATRIX_SCAN_CODE(row, col, row_shift)] = code; | 367 | matrix_keypad_build_keymap(keymap_data, row_shift, |
| 375 | __set_bit(code, input_dev->keybit); | 368 | input_dev->keycode, input_dev->keybit); |
| 376 | } | ||
| 377 | __clear_bit(KEY_RESERVED, input_dev->keybit); | ||
| 378 | 369 | ||
| 379 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); | 370 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
| 380 | input_set_drvdata(input_dev, keypad); | 371 | input_set_drvdata(input_dev, keypad); |
diff --git a/drivers/input/keyboard/w90p910_keypad.c b/drivers/input/keyboard/w90p910_keypad.c index b8598ae124ee..2d03dd0f9e07 100644 --- a/drivers/input/keyboard/w90p910_keypad.c +++ b/drivers/input/keyboard/w90p910_keypad.c | |||
| @@ -126,7 +126,6 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev) | |||
| 126 | struct resource *res; | 126 | struct resource *res; |
| 127 | int irq; | 127 | int irq; |
| 128 | int error; | 128 | int error; |
| 129 | int i; | ||
| 130 | 129 | ||
| 131 | if (!pdata) { | 130 | if (!pdata) { |
| 132 | dev_err(&pdev->dev, "no platform data defined\n"); | 131 | dev_err(&pdev->dev, "no platform data defined\n"); |
| @@ -197,19 +196,8 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev) | |||
| 197 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | 196 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); |
| 198 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); | 197 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
| 199 | 198 | ||
| 200 | for (i = 0; i < keymap_data->keymap_size; i++) { | 199 | matrix_keypad_build_keymap(keymap_data, W90P910_ROW_SHIFT, |
| 201 | unsigned int key = keymap_data->keymap[i]; | 200 | input_dev->keycode, input_dev->keybit); |
| 202 | unsigned int row = KEY_ROW(key); | ||
| 203 | unsigned int col = KEY_COL(key); | ||
| 204 | unsigned short keycode = KEY_VAL(key); | ||
| 205 | unsigned int scancode = MATRIX_SCAN_CODE(row, col, | ||
| 206 | W90P910_ROW_SHIFT); | ||
| 207 | |||
| 208 | keypad->keymap[scancode] = keycode; | ||
| 209 | __set_bit(keycode, input_dev->keybit); | ||
| 210 | } | ||
| 211 | __clear_bit(KEY_RESERVED, input_dev->keybit); | ||
| 212 | |||
| 213 | 201 | ||
| 214 | error = request_irq(keypad->irq, w90p910_keypad_irq_handler, | 202 | error = request_irq(keypad->irq, w90p910_keypad_irq_handler, |
| 215 | IRQF_DISABLED, pdev->name, keypad); | 203 | IRQF_DISABLED, pdev->name, keypad); |
diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h index 15d5903af2dd..b3cd42d50e16 100644 --- a/include/linux/input/matrix_keypad.h +++ b/include/linux/input/matrix_keypad.h | |||
| @@ -63,4 +63,36 @@ struct matrix_keypad_platform_data { | |||
| 63 | bool wakeup; | 63 | bool wakeup; |
| 64 | }; | 64 | }; |
| 65 | 65 | ||
| 66 | /** | ||
| 67 | * matrix_keypad_build_keymap - convert platform keymap into matrix keymap | ||
| 68 | * @keymap_data: keymap supplied by the platform code | ||
| 69 | * @row_shift: number of bits to shift row value by to advance to the next | ||
| 70 | * line in the keymap | ||
| 71 | * @keymap: expanded version of keymap that is suitable for use by | ||
| 72 | * matrix keyboad driver | ||
| 73 | * @keybit: pointer to bitmap of keys supported by input device | ||
| 74 | * | ||
| 75 | * This function converts platform keymap (encoded with KEY() macro) into | ||
| 76 | * an array of keycodes that is suitable for using in a standard matrix | ||
| 77 | * keyboard driver that uses row and col as indices. | ||
| 78 | */ | ||
| 79 | static inline void | ||
| 80 | matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | ||
| 81 | unsigned int row_shift, | ||
| 82 | unsigned short *keymap, unsigned long *keybit) | ||
| 83 | { | ||
| 84 | int i; | ||
| 85 | |||
| 86 | for (i = 0; i < keymap_data->keymap_size; i++) { | ||
| 87 | unsigned int key = keymap_data->keymap[i]; | ||
| 88 | unsigned int row = KEY_ROW(key); | ||
| 89 | unsigned int col = KEY_COL(key); | ||
| 90 | unsigned short code = KEY_VAL(key); | ||
| 91 | |||
| 92 | keymap[MATRIX_SCAN_CODE(row, col, row_shift)] = code; | ||
| 93 | __set_bit(code, keybit); | ||
| 94 | } | ||
| 95 | __clear_bit(KEY_RESERVED, keybit); | ||
| 96 | } | ||
| 97 | |||
| 66 | #endif /* _MATRIX_KEYPAD_H */ | 98 | #endif /* _MATRIX_KEYPAD_H */ |
