Change matrix-keymap helper to be out-of-line, like sparse keymap, allow the helper perform basic keymap validation and return errors, and prepare for device tree support.
Unified · Split
| @@ -25,10 +25,6 @@ config INPUT · 24 unmodified lines | ||
| 25 | 25 | |
| 26 | 26 | if INPUT |
| 27 | 27 | |
| 28 | −config INPUT_OF_MATRIX_KEYMAP | |
| 29 | − depends on USE_OF | |
| 30 | − bool | |
| 31 | − | |
| 32 | 28 | config INPUT_FF_MEMLESS |
| 33 | 29 | tristate "Support for memoryless force-feedback devices" |
| 34 | 30 | help |
| @@ -68,6 +64,19 @@ config INPUT_SPARSEKMAP · 33 unmodified lines | ||
| 68 | 64 | To compile this driver as a module, choose M here: the |
| 69 | 65 | module will be called sparse-keymap. |
| 70 | 66 | |
| 67 | +config INPUT_MATRIXKMAP | |
| 68 | + tristate "Matrix keymap support library" | |
| 69 | + help | |
| 70 | + Say Y here if you are using a driver for an input | |
| 71 | + device that uses matrix keymap. This option is only | |
| 72 | + useful for out-of-tree drivers since in-tree drivers | |
| 73 | + select it automatically. | |
| 74 | + | |
| 75 | + If unsure, say N. | |
| 76 | + | |
| 77 | + To compile this driver as a module, choose M here: the | |
| 78 | + module will be called matrix-keymap. | |
| 79 | + | |
| 71 | 80 | comment "Userland interfaces" |
| 72 | 81 | |
| 73 | 82 | config INPUT_MOUSEDEV |
| @@ -10,6 +10,7 @@ input-core-y := input.o input-compat.o input-mt.o ff-core.o · 9 unmodified lines | ||
| 10 | 10 | obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o |
| 11 | 11 | obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o |
| 12 | 12 | obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o |
| 13 | +obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o | |
| 13 | 14 | |
| 14 | 15 | obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o |
| 15 | 16 | obj-$(CONFIG_INPUT_JOYDEV) += joydev.o |
| @@ -24,4 +25,3 @@ obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/ · 8 unmodified lines | ||
| 24 | 25 | obj-$(CONFIG_INPUT_MISC) += misc/ |
| 25 | 26 | |
| 26 | 27 | obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o |
| 27 | −obj-$(CONFIG_INPUT_OF_MATRIX_KEYMAP) += of_keymap.o | |
| @@ -166,6 +166,7 @@ config KEYBOARD_LKKBD · 165 unmodified lines | ||
| 166 | 166 | config KEYBOARD_EP93XX |
| 167 | 167 | tristate "EP93xx Matrix Keypad support" |
| 168 | 168 | depends on ARCH_EP93XX |
| 169 | + select INPUT_MATRIXKMAP | |
| 169 | 170 | help |
| 170 | 171 | Say Y here to enable the matrix keypad on the Cirrus EP93XX. |
| 171 | 172 | |
| @@ -224,6 +225,7 @@ config KEYBOARD_TCA6416 · 52 unmodified lines | ||
| 224 | 225 | config KEYBOARD_TCA8418 |
| 225 | 226 | tristate "TCA8418 Keypad Support" |
| 226 | 227 | depends on I2C |
| 228 | + select INPUT_MATRIXKMAP | |
| 227 | 229 | help |
| 228 | 230 | This driver implements basic keypad functionality |
| 229 | 231 | for keys connected through TCA8418 keypad decoder. |
| @@ -240,6 +242,7 @@ config KEYBOARD_TCA8418 · 10 unmodified lines | ||
| 240 | 242 | config KEYBOARD_MATRIX |
| 241 | 243 | tristate "GPIO driven matrix keypad support" |
| 242 | 244 | depends on GENERIC_GPIO |
| 245 | + select INPUT_MATRIXKMAP | |
| 243 | 246 | help |
| 244 | 247 | Enable support for GPIO driven matrix keypad. |
| 245 | 248 | |
| @@ -312,6 +315,7 @@ config KEYBOARD_LM8323 · 66 unmodified lines | ||
| 312 | 315 | config KEYBOARD_LM8333 |
| 313 | 316 | tristate "LM8333 keypad chip" |
| 314 | 317 | depends on I2C |
| 318 | + select INPUT_MATRIXKMAP | |
| 315 | 319 | help |
| 316 | 320 | If you say yes here you get support for the National Semiconductor |
| 317 | 321 | LM8333 keypad controller. |
| @@ -376,6 +380,7 @@ config KEYBOARD_MPR121 · 58 unmodified lines | ||
| 376 | 380 | config KEYBOARD_IMX |
| 377 | 381 | tristate "IMX keypad support" |
| 378 | 382 | depends on ARCH_MXC |
| 383 | + select INPUT_MATRIXKMAP | |
| 379 | 384 | help |
| 380 | 385 | Enable support for IMX keypad port. |
| 381 | 386 | |
| @@ -394,6 +399,7 @@ config KEYBOARD_NEWTON · 12 unmodified lines | ||
| 394 | 399 | config KEYBOARD_NOMADIK |
| 395 | 400 | tristate "ST-Ericsson Nomadik SKE keyboard" |
| 396 | 401 | depends on PLAT_NOMADIK |
| 402 | + select INPUT_MATRIXKMAP | |
| 397 | 403 | help |
| 398 | 404 | Say Y here if you want to use a keypad provided on the SKE controller |
| 399 | 405 | used on the Ux500 and Nomadik platforms |
| @@ -404,7 +410,7 @@ config KEYBOARD_NOMADIK · 4 unmodified lines | ||
| 404 | 410 | config KEYBOARD_TEGRA |
| 405 | 411 | tristate "NVIDIA Tegra internal matrix keyboard controller support" |
| 406 | 412 | depends on ARCH_TEGRA |
| 407 | − select INPUT_OF_MATRIX_KEYMAP if USE_OF | |
| 413 | + select INPUT_MATRIXKMAP | |
| 408 | 414 | help |
| 409 | 415 | Say Y here if you want to use a matrix keyboard connected directly |
| 410 | 416 | to the internal keyboard controller on Tegra SoCs. |
| @@ -442,6 +448,7 @@ config KEYBOARD_PXA930_ROTARY · 31 unmodified lines | ||
| 442 | 448 | config KEYBOARD_PMIC8XXX |
| 443 | 449 | tristate "Qualcomm PMIC8XXX keypad support" |
| 444 | 450 | depends on MFD_PM8XXX |
| 451 | + select INPUT_MATRIXKMAP | |
| 445 | 452 | help |
| 446 | 453 | Say Y here if you want to enable the driver for the PMIC8XXX |
| 447 | 454 | keypad provided as a reference design from Qualcomm. This is intended |
| @@ -453,6 +460,7 @@ config KEYBOARD_PMIC8XXX · 5 unmodified lines | ||
| 453 | 460 | config KEYBOARD_SAMSUNG |
| 454 | 461 | tristate "Samsung keypad support" |
| 455 | 462 | depends on HAVE_CLK |
| 463 | + select INPUT_MATRIXKMAP | |
| 456 | 464 | help |
| 457 | 465 | Say Y here if you want to use the keypad on your Samsung mobile |
| 458 | 466 | device. |
| @@ -495,6 +503,7 @@ config KEYBOARD_SH_KEYSC · 36 unmodified lines | ||
| 495 | 503 | config KEYBOARD_STMPE |
| 496 | 504 | tristate "STMPE keypad support" |
| 497 | 505 | depends on MFD_STMPE |
| 506 | + select INPUT_MATRIXKMAP | |
| 498 | 507 | help |
| 499 | 508 | Say Y here if you want to use the keypad controller on STMPE I/O |
| 500 | 509 | expanders. |
| @@ -515,6 +524,7 @@ config KEYBOARD_DAVINCI · 14 unmodified lines | ||
| 515 | 524 | config KEYBOARD_OMAP |
| 516 | 525 | tristate "TI OMAP keypad support" |
| 517 | 526 | depends on (ARCH_OMAP1 || ARCH_OMAP2) |
| 527 | + select INPUT_MATRIXKMAP | |
| 518 | 528 | help |
| 519 | 529 | Say Y here if you want to use the OMAP keypad. |
| 520 | 530 | |
| @@ -523,6 +533,7 @@ config KEYBOARD_OMAP · 2 unmodified lines | ||
| 523 | 533 | |
| 524 | 534 | config KEYBOARD_OMAP4 |
| 525 | 535 | tristate "TI OMAP4+ keypad support" |
| 536 | + select INPUT_MATRIXKMAP | |
| 526 | 537 | help |
| 527 | 538 | Say Y here if you want to use the OMAP4+ keypad. |
| 528 | 539 | |
| @@ -532,6 +543,7 @@ config KEYBOARD_OMAP4 · 3 unmodified lines | ||
| 532 | 543 | config KEYBOARD_SPEAR |
| 533 | 544 | tristate "ST SPEAR keyboard support" |
| 534 | 545 | depends on PLAT_SPEAR |
| 546 | + select INPUT_MATRIXKMAP | |
| 535 | 547 | help |
| 536 | 548 | Say Y here if you want to use the SPEAR keyboard. |
| 537 | 549 | |
| @@ -541,6 +553,7 @@ config KEYBOARD_SPEAR · 3 unmodified lines | ||
| 541 | 553 | config KEYBOARD_TC3589X |
| 542 | 554 | tristate "TC3589X Keypad support" |
| 543 | 555 | depends on MFD_TC3589X |
| 556 | + select INPUT_MATRIXKMAP | |
| 544 | 557 | help |
| 545 | 558 | Say Y here if you want to use the keypad controller on |
| 546 | 559 | TC35892/3 I/O expander. |
| @@ -551,6 +564,7 @@ config KEYBOARD_TC3589X · 4 unmodified lines | ||
| 551 | 564 | config KEYBOARD_TNETV107X |
| 552 | 565 | tristate "TI TNETV107X keypad support" |
| 553 | 566 | depends on ARCH_DAVINCI_TNETV107X |
| 567 | + select INPUT_MATRIXKMAP | |
| 554 | 568 | help |
| 555 | 569 | Say Y here if you want to use the TNETV107X keypad. |
| 556 | 570 | |
| @@ -560,6 +574,7 @@ config KEYBOARD_TNETV107X · 3 unmodified lines | ||
| 560 | 574 | config KEYBOARD_TWL4030 |
| 561 | 575 | tristate "TI TWL4030/TWL5030/TPS659x0 keypad support" |
| 562 | 576 | depends on TWL4030_CORE |
| 577 | + select INPUT_MATRIXKMAP | |
| 563 | 578 | help |
| 564 | 579 | Say Y here if your board use the keypad controller on |
| 565 | 580 | TWL4030 family chips. It's safe to say enable this |
| @@ -583,6 +598,7 @@ config KEYBOARD_XTKBD · 17 unmodified lines | ||
| 583 | 598 | config KEYBOARD_W90P910 |
| 584 | 599 | tristate "W90P910 Matrix Keypad support" |
| 585 | 600 | depends on ARCH_W90X900 |
| 601 | + select INPUT_MATRIXKMAP | |
| 586 | 602 | help |
| 587 | 603 | Say Y here to enable the matrix keypad on evaluation board |
| 588 | 604 | based on W90P910. |
| @@ -303,19 +303,16 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) · 302 unmodified lines | ||
| 303 | 303 | input_dev->open = ep93xx_keypad_open; |
| 304 | 304 | input_dev->close = ep93xx_keypad_close; |
| 305 | 305 | input_dev->dev.parent = &pdev->dev; |
| 306 | − input_dev->keycode = keypad->keycodes; | |
| 307 | − input_dev->keycodesize = sizeof(keypad->keycodes[0]); | |
| 308 | − input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); | |
| 309 | 306 | |
| 310 | − input_set_drvdata(input_dev, keypad); | |
| 307 | + err = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 308 | + EP93XX_MATRIX_ROWS, EP93XX_MATRIX_COLS, | |
| 309 | + keypad->keycodes, input_dev); | |
| 310 | + if (err) | |
| 311 | + goto failed_free_dev; | |
| 311 | 312 | |
| 312 | − input_dev->evbit[0] = BIT_MASK(EV_KEY); | |
| 313 | 313 | if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT) |
| 314 | − input_dev->evbit[0] |= BIT_MASK(EV_REP); | |
| 315 | − | |
| 316 | − matrix_keypad_build_keymap(keymap_data, 3, | |
| 317 | − input_dev->keycode, input_dev->keybit); | |
| 318 | − platform_set_drvdata(pdev, keypad); | |
| 314 | + __set_bit(EV_REP, input_dev->evbit); | |
| 315 | + input_set_drvdata(input_dev, keypad); | |
| 319 | 316 | |
| 320 | 317 | err = request_irq(keypad->irq, ep93xx_keypad_irq_handler, |
| 321 | 318 | 0, pdev->name, keypad); |
| @@ -326,6 +323,7 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev) · 4 unmodified lines | ||
| 326 | 323 | if (err) |
| 327 | 324 | goto failed_free_irq; |
| 328 | 325 | |
| 326 | + platform_set_drvdata(pdev, keypad); | |
| 329 | 327 | device_init_wakeup(&pdev->dev, 1); |
| 330 | 328 | |
| 331 | 329 | return 0; |
| @@ -481,7 +481,7 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev) · 480 unmodified lines | ||
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) || |
| 484 | − keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) { | |
| 484 | + keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) { | |
| 485 | 485 | dev_err(&pdev->dev, |
| 486 | 486 | "invalid key data (too many rows or colums)\n"); |
| 487 | 487 | error = -EINVAL; |
| @@ -496,14 +496,17 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev) · 8 unmodified lines | ||
| 496 | 496 | input_dev->dev.parent = &pdev->dev; |
| 497 | 497 | input_dev->open = imx_keypad_open; |
| 498 | 498 | input_dev->close = imx_keypad_close; |
| 499 | − input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | |
| 500 | − input_dev->keycode = keypad->keycodes; | |
| 501 | − input_dev->keycodesize = sizeof(keypad->keycodes[0]); | |
| 502 | − input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); | |
| 503 | 499 | |
| 504 | − matrix_keypad_build_keymap(keymap_data, MATRIX_ROW_SHIFT, | |
| 505 | − keypad->keycodes, input_dev->keybit); | |
| 500 | + error = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 501 | + MAX_MATRIX_KEY_ROWS, | |
| 502 | + MAX_MATRIX_KEY_COLS, | |
| 503 | + keypad->keycodes, input_dev); | |
| 504 | + if (error) { | |
| 505 | + dev_err(&pdev->dev, "failed to build keymap\n"); | |
| 506 | + goto failed_clock_put; | |
| 507 | + } | |
| 506 | 508 | |
| 509 | + __set_bit(EV_REP, input_dev->evbit); | |
| 507 | 510 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
| 508 | 511 | input_set_drvdata(input_dev, keypad); |
| 509 | 512 | |
| @@ -29,9 +29,9 @@ · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | #define LM8333_FIFO_TRANSFER_SIZE 16 |
| 31 | 31 | |
| 32 | −#define LM8333_ROW_SHIFT 4 | |
| 33 | 32 | #define LM8333_NUM_ROWS 8 |
| 34 | − | |
| 33 | +#define LM8333_NUM_COLS 16 | |
| 34 | +#define LM8333_ROW_SHIFT 4 | |
| 35 | 35 | |
| 36 | 36 | struct lm8333 { |
| 37 | 37 | struct i2c_client *client; |
| @@ -159,14 +159,13 @@ static int __devinit lm8333_probe(struct i2c_client *client, · 121 unmodified lines | ||
| 159 | 159 | input->dev.parent = &client->dev; |
| 160 | 160 | input->id.bustype = BUS_I2C; |
| 161 | 161 | |
| 162 | − input->keycode = lm8333->keycodes; | |
| 163 | − input->keycodesize = sizeof(lm8333->keycodes[0]); | |
| 164 | − input->keycodemax = ARRAY_SIZE(lm8333->keycodes); | |
| 165 | − input->evbit[0] = BIT_MASK(EV_KEY); | |
| 166 | 162 | input_set_capability(input, EV_MSC, MSC_SCAN); |
| 167 | 163 | |
| 168 | − matrix_keypad_build_keymap(pdata->matrix_data, LM8333_ROW_SHIFT, | |
| 169 | − input->keycode, input->keybit); | |
| 164 | + err = matrix_keypad_build_keymap(pdata->matrix_data, NULL, | |
| 165 | + LM8333_NUM_ROWS, LM8333_NUM_COLS, | |
| 166 | + lm8333->keycodes, input); | |
| 167 | + if (err) | |
| 168 | + goto free_mem; | |
| 170 | 169 | |
| 171 | 170 | if (pdata->debounce_time) { |
| 172 | 171 | err = lm8333_write8(lm8333, LM8333_DEBOUNCE, |
| @@ -437,19 +437,18 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev) · 436 unmodified lines | ||
| 437 | 437 | input_dev->name = pdev->name; |
| 438 | 438 | input_dev->id.bustype = BUS_HOST; |
| 439 | 439 | input_dev->dev.parent = &pdev->dev; |
| 440 | − input_dev->evbit[0] = BIT_MASK(EV_KEY); | |
| 441 | − if (!pdata->no_autorepeat) | |
| 442 | − input_dev->evbit[0] |= BIT_MASK(EV_REP); | |
| 443 | 440 | input_dev->open = matrix_keypad_start; |
| 444 | 441 | input_dev->close = matrix_keypad_stop; |
| 445 | 442 | |
| 446 | − input_dev->keycode = keypad->keycodes; | |
| 447 | − input_dev->keycodesize = sizeof(keypad->keycodes[0]); | |
| 448 | − input_dev->keycodemax = pdata->num_row_gpios << row_shift; | |
| 449 | − | |
| 450 | − matrix_keypad_build_keymap(keymap_data, row_shift, | |
| 451 | − input_dev->keycode, input_dev->keybit); | |
| 443 | + err = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 444 | + pdata->num_row_gpios, | |
| 445 | + pdata->num_col_gpios, | |
| 446 | + keypad->keycodes, input_dev); | |
| 447 | + if (err) | |
| 448 | + goto err_free_mem; | |
| 452 | 449 | |
| 450 | + if (!pdata->no_autorepeat) | |
| 451 | + __set_bit(EV_REP, input_dev->evbit); | |
| 453 | 452 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
| 454 | 453 | input_set_drvdata(input_dev, keypad); |
| 455 | 454 | |
| @@ -39,7 +39,8 @@ · 38 unmodified lines | ||
| 39 | 39 | #define SKE_KPRISA (0x1 << 2) |
| 40 | 40 | |
| 41 | 41 | #define SKE_KEYPAD_ROW_SHIFT 3 |
| 42 | −#define SKE_KPD_KEYMAP_SIZE (8 * 8) | |
| 42 | +#define SKE_KPD_NUM_ROWS 8 | |
| 43 | +#define SKE_KPD_NUM_COLS 8 | |
| 43 | 44 | |
| 44 | 45 | /* keypad auto scan registers */ |
| 45 | 46 | #define SKE_ASR0 0x20 |
| @@ -63,7 +64,7 @@ struct ske_keypad { · 17 unmodified lines | ||
| 63 | 64 | void __iomem *reg_base; |
| 64 | 65 | struct input_dev *input; |
| 65 | 66 | const struct ske_keypad_platform_data *board; |
| 66 | − unsigned short keymap[SKE_KPD_KEYMAP_SIZE]; | |
| 67 | + unsigned short keymap[SKE_KPD_NUM_ROWS * SKE_KPD_NUM_COLS]; | |
| 67 | 68 | struct clk *clk; |
| 68 | 69 | spinlock_t ske_keypad_lock; |
| 69 | 70 | }; |
| @@ -261,19 +262,18 @@ static int __init ske_keypad_probe(struct platform_device *pdev) · 191 unmodified lines | ||
| 261 | 262 | input->name = "ux500-ske-keypad"; |
| 262 | 263 | input->dev.parent = &pdev->dev; |
| 263 | 264 | |
| 264 | − input->keycode = keypad->keymap; | |
| 265 | − input->keycodesize = sizeof(keypad->keymap[0]); | |
| 266 | − input->keycodemax = ARRAY_SIZE(keypad->keymap); | |
| 265 | + error = matrix_keypad_build_keymap(plat->keymap_data, NULL, | |
| 266 | + SKE_KPD_NUM_ROWS, SKE_KPD_NUM_COLS, | |
| 267 | + keypad->keymap, input); | |
| 268 | + if (error) { | |
| 269 | + dev_err(&pdev->dev, "Failed to build keymap\n"); | |
| 270 | + goto err_iounmap; | |
| 271 | + } | |
| 267 | 272 | |
| 268 | 273 | input_set_capability(input, EV_MSC, MSC_SCAN); |
| 269 | − | |
| 270 | − __set_bit(EV_KEY, input->evbit); | |
| 271 | 274 | if (!plat->no_autorepeat) |
| 272 | 275 | __set_bit(EV_REP, input->evbit); |
| 273 | 276 | |
| 274 | − matrix_keypad_build_keymap(plat->keymap_data, SKE_KEYPAD_ROW_SHIFT, | |
| 275 | − input->keycode, input->keybit); | |
| 276 | − | |
| 277 | 277 | clk_enable(keypad->clk); |
| 278 | 278 | |
| 279 | 279 | /* go through board initialization helpers */ |
| @@ -61,6 +61,7 @@ struct omap_kp { · 60 unmodified lines | ||
| 61 | 61 | unsigned int cols; |
| 62 | 62 | unsigned long delay; |
| 63 | 63 | unsigned int debounce; |
| 64 | + unsigned short keymap[]; | |
| 64 | 65 | }; |
| 65 | 66 | |
| 66 | 67 | static DECLARE_TASKLET_DISABLED(kp_tasklet, omap_kp_tasklet, 0); |
| @@ -316,13 +317,6 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) · 249 unmodified lines | ||
| 316 | 317 | if (!cpu_is_omap24xx()) |
| 317 | 318 | omap_writew(1, OMAP1_MPUIO_BASE + OMAP_MPUIO_KBD_MASKIT); |
| 318 | 319 | |
| 319 | − input_dev->keycode = &omap_kp[1]; | |
| 320 | − input_dev->keycodesize = sizeof(unsigned short); | |
| 321 | − input_dev->keycodemax = keycodemax; | |
| 322 | − | |
| 323 | − if (pdata->rep) | |
| 324 | − __set_bit(EV_REP, input_dev->evbit); | |
| 325 | − | |
| 326 | 320 | if (pdata->delay) |
| 327 | 321 | omap_kp->delay = pdata->delay; |
| 328 | 322 | |
| @@ -371,9 +365,6 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) · 42 unmodified lines | ||
| 371 | 365 | goto err2; |
| 372 | 366 | |
| 373 | 367 | /* setup input device */ |
| 374 | − __set_bit(EV_KEY, input_dev->evbit); | |
| 375 | − matrix_keypad_build_keymap(pdata->keymap_data, row_shift, | |
| 376 | − input_dev->keycode, input_dev->keybit); | |
| 377 | 368 | input_dev->name = "omap-keypad"; |
| 378 | 369 | input_dev->phys = "omap-keypad/input0"; |
| 379 | 370 | input_dev->dev.parent = &pdev->dev; |
| @@ -383,6 +374,15 @@ static int __devinit omap_kp_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 383 | 374 | input_dev->id.product = 0x0001; |
| 384 | 375 | input_dev->id.version = 0x0100; |
| 385 | 376 | |
| 377 | + if (pdata->rep) | |
| 378 | + __set_bit(EV_REP, input_dev->evbit); | |
| 379 | + | |
| 380 | + ret = matrix_keypad_build_keymap(pdata->keymap_data, NULL, | |
| 381 | + pdata->rows, pdata->cols, | |
| 382 | + omap_kp->keymap, input_dev); | |
| 383 | + if (ret < 0) | |
| 384 | + goto err3; | |
| 385 | + | |
| 386 | 386 | ret = input_register_device(omap_kp->input); |
| 387 | 387 | if (ret < 0) { |
| 388 | 388 | printk(KERN_ERR "Unable to register omap-keypad input device\n"); |
| @@ -322,20 +322,19 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) · 321 unmodified lines | ||
| 322 | 322 | input_dev->open = omap4_keypad_open; |
| 323 | 323 | input_dev->close = omap4_keypad_close; |
| 324 | 324 | |
| 325 | − input_dev->keycode = keypad_data->keymap; | |
| 326 | − input_dev->keycodesize = sizeof(keypad_data->keymap[0]); | |
| 327 | − input_dev->keycodemax = max_keys; | |
| 325 | + error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, | |
| 326 | + pdata->rows, pdata->cols, | |
| 327 | + keypad_data->keymap, input_dev); | |
| 328 | + if (error) { | |
| 329 | + dev_err(&pdev->dev, "failed to build keymap\n"); | |
| 330 | + goto err_free_input; | |
| 331 | + } | |
| 328 | 332 | |
| 329 | − __set_bit(EV_KEY, input_dev->evbit); | |
| 330 | 333 | __set_bit(EV_REP, input_dev->evbit); |
| 331 | − | |
| 332 | 334 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
| 333 | 335 | |
| 334 | 336 | input_set_drvdata(input_dev, keypad_data); |
| 335 | 337 | |
| 336 | − matrix_keypad_build_keymap(pdata->keymap_data, row_shift, | |
| 337 | − input_dev->keycode, input_dev->keybit); | |
| 338 | − | |
| 339 | 338 | error = request_irq(keypad_data->irq, omap4_keypad_interrupt, |
| 340 | 339 | IRQF_TRIGGER_RISING, |
| 341 | 340 | "omap4-keypad", keypad_data); |
| @@ -626,21 +626,21 @@ static int __devinit pmic8xxx_kp_probe(struct platform_device *pdev) · 625 unmodified lines | ||
| 626 | 626 | kp->input->id.product = 0x0001; |
| 627 | 627 | kp->input->id.vendor = 0x0001; |
| 628 | 628 | |
| 629 | − kp->input->evbit[0] = BIT_MASK(EV_KEY); | |
| 630 | − | |
| 631 | − if (pdata->rep) | |
| 632 | − __set_bit(EV_REP, kp->input->evbit); | |
| 633 | − | |
| 634 | − kp->input->keycode = kp->keycodes; | |
| 635 | − kp->input->keycodemax = PM8XXX_MATRIX_MAX_SIZE; | |
| 636 | − kp->input->keycodesize = sizeof(kp->keycodes); | |
| 637 | 629 | kp->input->open = pmic8xxx_kp_open; |
| 638 | 630 | kp->input->close = pmic8xxx_kp_close; |
| 639 | 631 | |
| 640 | − matrix_keypad_build_keymap(keymap_data, PM8XXX_ROW_SHIFT, | |
| 641 | − kp->input->keycode, kp->input->keybit); | |
| 632 | + rc = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 633 | + PM8XXX_MAX_ROWS, PM8XXX_MAX_COLS, | |
| 634 | + kp->keycodes, kp->input); | |
| 635 | + if (rc) { | |
| 636 | + dev_err(&pdev->dev, "failed to build keymap\n"); | |
| 637 | + goto err_get_irq; | |
| 638 | + } | |
| 642 | 639 | |
| 640 | + if (pdata->rep) | |
| 641 | + __set_bit(EV_REP, kp->input->evbit); | |
| 643 | 642 | input_set_capability(kp->input, EV_MSC, MSC_SCAN); |
| 643 | + | |
| 644 | 644 | input_set_drvdata(kp->input, kp); |
| 645 | 645 | |
| 646 | 646 | /* initialize keypad state */ |
| @@ -454,23 +454,23 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev) · 453 unmodified lines | ||
| 454 | 454 | input_dev->name = pdev->name; |
| 455 | 455 | input_dev->id.bustype = BUS_HOST; |
| 456 | 456 | input_dev->dev.parent = &pdev->dev; |
| 457 | − input_set_drvdata(input_dev, keypad); | |
| 458 | 457 | |
| 459 | 458 | input_dev->open = samsung_keypad_open; |
| 460 | 459 | input_dev->close = samsung_keypad_close; |
| 461 | 460 | |
| 462 | − input_dev->evbit[0] = BIT_MASK(EV_KEY); | |
| 463 | − if (!pdata->no_autorepeat) | |
| 464 | − input_dev->evbit[0] |= BIT_MASK(EV_REP); | |
| 461 | + error = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 462 | + pdata->rows, pdata->cols, | |
| 463 | + keypad->keycodes, input_dev); | |
| 464 | + if (error) { | |
| 465 | + dev_err(&pdev->dev, "failed to build keymap\n"); | |
| 466 | + goto err_put_clk; | |
| 467 | + } | |
| 465 | 468 | |
| 466 | 469 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
| 470 | + if (!pdata->no_autorepeat) | |
| 471 | + __set_bit(EV_REP, input_dev->evbit); | |
| 467 | 472 | |
| 468 | − input_dev->keycode = keypad->keycodes; | |
| 469 | − input_dev->keycodesize = sizeof(keypad->keycodes[0]); | |
| 470 | − input_dev->keycodemax = pdata->rows << row_shift; | |
| 471 | − | |
| 472 | − matrix_keypad_build_keymap(keymap_data, row_shift, | |
| 473 | − input_dev->keycode, input_dev->keybit); | |
| 473 | + input_set_drvdata(input_dev, keypad); | |
| 474 | 474 | |
| 475 | 475 | keypad->irq = platform_get_irq(pdev, 0); |
| 476 | 476 | if (keypad->irq < 0) { |
| @@ -49,7 +49,9 @@ · 48 unmodified lines | ||
| 49 | 49 | #define KEY_VALUE 0x00FFFFFF |
| 50 | 50 | #define ROW_MASK 0xF0 |
| 51 | 51 | #define COLUMN_MASK 0x0F |
| 52 | −#define ROW_SHIFT 4 | |
| 52 | +#define NUM_ROWS 16 | |
| 53 | +#define NUM_COLS 16 | |
| 54 | + | |
| 53 | 55 | #define KEY_MATRIX_SHIFT 6 |
| 54 | 56 | |
| 55 | 57 | struct spear_kbd { |
| @@ -60,7 +62,7 @@ struct spear_kbd { · 4 unmodified lines | ||
| 60 | 62 | unsigned int irq; |
| 61 | 63 | unsigned int mode; |
| 62 | 64 | unsigned short last_key; |
| 63 | − unsigned short keycodes[256]; | |
| 65 | + unsigned short keycodes[NUM_ROWS * NUM_COLS]; | |
| 64 | 66 | }; |
| 65 | 67 | |
| 66 | 68 | static irqreturn_t spear_kbd_interrupt(int irq, void *dev_id) |
| @@ -212,18 +214,17 @@ static int __devinit spear_kbd_probe(struct platform_device *pdev) · 145 unmodified lines | ||
| 212 | 214 | input_dev->open = spear_kbd_open; |
| 213 | 215 | input_dev->close = spear_kbd_close; |
| 214 | 216 | |
| 215 | − __set_bit(EV_KEY, input_dev->evbit); | |
| 217 | + error = matrix_keypad_build_keymap(keymap, NULL, NUM_ROWS, NUM_COLS, | |
| 218 | + kbd->keycodes, input_dev); | |
| 219 | + if (error) { | |
| 220 | + dev_err(&pdev->dev, "Failed to build keymap\n"); | |
| 221 | + goto err_put_clk; | |
| 222 | + } | |
| 223 | + | |
| 216 | 224 | if (pdata->rep) |
| 217 | 225 | __set_bit(EV_REP, input_dev->evbit); |
| 218 | 226 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
| 219 | 227 | |
| 220 | − input_dev->keycode = kbd->keycodes; | |
| 221 | − input_dev->keycodesize = sizeof(kbd->keycodes[0]); | |
| 222 | − input_dev->keycodemax = ARRAY_SIZE(kbd->keycodes); | |
| 223 | − | |
| 224 | − matrix_keypad_build_keymap(keymap, ROW_SHIFT, | |
| 225 | − input_dev->keycode, input_dev->keybit); | |
| 226 | − | |
| 227 | 228 | input_set_drvdata(input_dev, kbd); |
| 228 | 229 | |
| 229 | 230 | error = request_irq(irq, spear_kbd_interrupt, 0, "keyboard", kbd); |
| @@ -289,19 +289,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev) · 288 unmodified lines | ||
| 289 | 289 | input->id.bustype = BUS_I2C; |
| 290 | 290 | input->dev.parent = &pdev->dev; |
| 291 | 291 | |
| 292 | − input_set_capability(input, EV_MSC, MSC_SCAN); | |
| 292 | + ret = matrix_keypad_build_keymap(plat->keymap_data, NULL, | |
| 293 | + STMPE_KEYPAD_MAX_ROWS, | |
| 294 | + STMPE_KEYPAD_MAX_COLS, | |
| 295 | + keypad->keymap, input); | |
| 296 | + if (ret) | |
| 297 | + goto out_freeinput; | |
| 293 | 298 | |
| 294 | − __set_bit(EV_KEY, input->evbit); | |
| 299 | + input_set_capability(input, EV_MSC, MSC_SCAN); | |
| 295 | 300 | if (!plat->no_autorepeat) |
| 296 | 301 | __set_bit(EV_REP, input->evbit); |
| 297 | 302 | |
| 298 | − input->keycode = keypad->keymap; | |
| 299 | − input->keycodesize = sizeof(keypad->keymap[0]); | |
| 300 | − input->keycodemax = ARRAY_SIZE(keypad->keymap); | |
| 301 | − | |
| 302 | − matrix_keypad_build_keymap(plat->keymap_data, STMPE_KEYPAD_ROW_SHIFT, | |
| 303 | − input->keycode, input->keybit); | |
| 304 | − | |
| 305 | 303 | for (i = 0; i < plat->keymap_data->keymap_size; i++) { |
| 306 | 304 | unsigned int key = plat->keymap_data->keymap[i]; |
| 307 | 305 | |
| @@ -78,7 +78,7 @@ · 77 unmodified lines | ||
| 78 | 78 | * @input: pointer to input device object |
| 79 | 79 | * @board: keypad platform device |
| 80 | 80 | * @krow: number of rows |
| 81 | − * @kcol: number of coloumns | |
| 81 | + * @kcol: number of columns | |
| 82 | 82 | * @keymap: matrix scan code table for keycodes |
| 83 | 83 | * @keypad_stopped: holds keypad status |
| 84 | 84 | */ |
| @@ -333,23 +333,22 @@ static int __devinit tc3589x_keypad_probe(struct platform_device *pdev) · 248 unmodified lines | ||
| 333 | 333 | input->name = pdev->name; |
| 334 | 334 | input->dev.parent = &pdev->dev; |
| 335 | 335 | |
| 336 | − input->keycode = keypad->keymap; | |
| 337 | − input->keycodesize = sizeof(keypad->keymap[0]); | |
| 338 | − input->keycodemax = ARRAY_SIZE(keypad->keymap); | |
| 339 | − | |
| 340 | 336 | input->open = tc3589x_keypad_open; |
| 341 | 337 | input->close = tc3589x_keypad_close; |
| 342 | 338 | |
| 343 | − input_set_drvdata(input, keypad); | |
| 339 | + error = matrix_keypad_build_keymap(plat->keymap_data, NULL, | |
| 340 | + TC3589x_MAX_KPROW, TC3589x_MAX_KPCOL, | |
| 341 | + keypad->keymap, input); | |
| 342 | + if (error) { | |
| 343 | + dev_err(&pdev->dev, "Failed to build keymap\n"); | |
| 344 | + goto err_free_mem; | |
| 345 | + } | |
| 344 | 346 | |
| 345 | 347 | input_set_capability(input, EV_MSC, MSC_SCAN); |
| 346 | − | |
| 347 | − __set_bit(EV_KEY, input->evbit); | |
| 348 | 348 | if (!plat->no_autorepeat) |
| 349 | 349 | __set_bit(EV_REP, input->evbit); |
| 350 | 350 | |
| 351 | − matrix_keypad_build_keymap(plat->keymap_data, 0x3, | |
| 352 | − input->keycode, input->keybit); | |
| 351 | + input_set_drvdata(input, keypad); | |
| 353 | 352 | |
| 354 | 353 | error = request_threaded_irq(irq, NULL, |
| 355 | 354 | tc3589x_keypad_irq, plat->irqtype, |
| @@ -342,21 +342,20 @@ static int __devinit tca8418_keypad_probe(struct i2c_client *client, · 341 unmodified lines | ||
| 342 | 342 | input->id.product = 0x001; |
| 343 | 343 | input->id.version = 0x0001; |
| 344 | 344 | |
| 345 | − input->keycode = keypad_data->keymap; | |
| 346 | − input->keycodesize = sizeof(keypad_data->keymap[0]); | |
| 347 | − input->keycodemax = max_keys; | |
| 345 | + error = matrix_keypad_build_keymap(pdata->keymap_data, NULL, | |
| 346 | + pdata->rows, pdata->cols, | |
| 347 | + keypad_data->keymap, input); | |
| 348 | + if (error) { | |
| 349 | + dev_dbg(&client->dev, "Failed to build keymap\n"); | |
| 350 | + goto fail2; | |
| 351 | + } | |
| 348 | 352 | |
| 349 | − __set_bit(EV_KEY, input->evbit); | |
| 350 | 353 | if (pdata->rep) |
| 351 | 354 | __set_bit(EV_REP, input->evbit); |
| 352 | − | |
| 353 | 355 | input_set_capability(input, EV_MSC, MSC_SCAN); |
| 354 | 356 | |
| 355 | 357 | input_set_drvdata(input, keypad_data); |
| 356 | 358 | |
| 357 | − matrix_keypad_build_keymap(pdata->keymap_data, row_shift, | |
| 358 | − input->keycode, input->keybit); | |
| 359 | − | |
| 360 | 359 | if (pdata->irq_is_gpio) |
| 361 | 360 | client->irq = gpio_to_irq(client->irq); |
| 362 | 361 | |
| @@ -686,6 +686,7 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) · 685 unmodified lines | ||
| 686 | 686 | int num_rows = 0; |
| 687 | 687 | unsigned int debounce_cnt; |
| 688 | 688 | unsigned int scan_time_rows; |
| 689 | + unsigned int keymap_rows; | |
| 689 | 690 | |
| 690 | 691 | if (!pdata) |
| 691 | 692 | pdata = tegra_kbc_dt_parse_pdata(pdev); |
| @@ -757,29 +758,34 @@ static int __devinit tegra_kbc_probe(struct platform_device *pdev) · 65 unmodified lines | ||
| 757 | 758 | kbc->repoll_dly = KBC_ROW_SCAN_DLY + scan_time_rows + pdata->repeat_cnt; |
| 758 | 759 | kbc->repoll_dly = DIV_ROUND_UP(kbc->repoll_dly, KBC_CYCLE_MS); |
| 759 | 760 | |
| 761 | + kbc->wakeup_key = pdata->wakeup_key; | |
| 762 | + kbc->use_fn_map = pdata->use_fn_map; | |
| 763 | + kbc->use_ghost_filter = pdata->use_ghost_filter; | |
| 764 | + | |
| 760 | 765 | input_dev->name = pdev->name; |
| 761 | 766 | input_dev->id.bustype = BUS_HOST; |
| 762 | 767 | input_dev->dev.parent = &pdev->dev; |
| 763 | 768 | input_dev->open = tegra_kbc_open; |
| 764 | 769 | input_dev->close = tegra_kbc_close; |
| 765 | 770 | |
| 766 | − input_set_drvdata(input_dev, kbc); | |
| 767 | − | |
| 768 | − input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | |
| 769 | − input_set_capability(input_dev, EV_MSC, MSC_SCAN); | |
| 770 | − | |
| 771 | − input_dev->keycode = kbc->keycode; | |
| 772 | − input_dev->keycodesize = sizeof(kbc->keycode[0]); | |
| 773 | − input_dev->keycodemax = KBC_MAX_KEY; | |
| 771 | + keymap_rows = KBC_MAX_KEY; | |
| 774 | 772 | if (pdata->use_fn_map) |
| 775 | − input_dev->keycodemax *= 2; | |
| 773 | + keymap_rows *= 2; | |
| 776 | 774 | |
| 777 | − kbc->use_fn_map = pdata->use_fn_map; | |
| 778 | − kbc->use_ghost_filter = pdata->use_ghost_filter; | |
| 779 | 775 | keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; |
| 780 | − matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT, | |
| 781 | − input_dev->keycode, input_dev->keybit); | |
| 782 | − kbc->wakeup_key = pdata->wakeup_key; | |
| 776 | + | |
| 777 | + err = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 778 | + keymap_rows, KBC_MAX_COL, | |
| 779 | + kbc->keycode, input_dev); | |
| 780 | + if (err) { | |
| 781 | + dev_err(&pdev->dev, "failed to build keymap\n"); | |
| 782 | + goto err_put_clk; | |
| 783 | + } | |
| 784 | + | |
| 785 | + __set_bit(EV_REP, input_dev->evbit); | |
| 786 | + input_set_capability(input_dev, EV_MSC, MSC_SCAN); | |
| 787 | + | |
| 788 | + input_set_drvdata(input_dev, kbc); | |
| 783 | 789 | |
| 784 | 790 | err = request_irq(kbc->irq, tegra_kbc_isr, |
| 785 | 791 | IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc); |
| @@ -247,15 +247,11 @@ static int __devinit keypad_probe(struct platform_device *pdev) · 246 unmodified lines | ||
| 247 | 247 | error = -ENOMEM; |
| 248 | 248 | goto error_input; |
| 249 | 249 | } |
| 250 | − input_set_drvdata(kp->input_dev, kp); | |
| 251 | 250 | |
| 252 | 251 | kp->input_dev->name = pdev->name; |
| 253 | 252 | kp->input_dev->dev.parent = &pdev->dev; |
| 254 | 253 | kp->input_dev->open = keypad_start; |
| 255 | 254 | kp->input_dev->close = keypad_stop; |
| 256 | − kp->input_dev->evbit[0] = BIT_MASK(EV_KEY); | |
| 257 | − if (!pdata->no_autorepeat) | |
| 258 | − kp->input_dev->evbit[0] |= BIT_MASK(EV_REP); | |
| 259 | 255 | |
| 260 | 256 | clk_enable(kp->clk); |
| 261 | 257 | rev = keypad_read(kp, rev); |
| @@ -264,15 +260,20 @@ static int __devinit keypad_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 264 | 260 | kp->input_dev->id.version = ((rev >> 16) & 0xfff); |
| 265 | 261 | clk_disable(kp->clk); |
| 266 | 262 | |
| 267 | − kp->input_dev->keycode = kp->keycodes; | |
| 268 | − kp->input_dev->keycodesize = sizeof(kp->keycodes[0]); | |
| 269 | − kp->input_dev->keycodemax = kp->rows << kp->row_shift; | |
| 270 | − | |
| 271 | − matrix_keypad_build_keymap(keymap_data, kp->row_shift, kp->keycodes, | |
| 272 | − kp->input_dev->keybit); | |
| 263 | + error = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 264 | + kp->rows, kp->cols, | |
| 265 | + kp->keycodes, kp->input_dev); | |
| 266 | + if (error) { | |
| 267 | + dev_err(dev, "Failed to build keymap\n"); | |
| 268 | + goto error_reg; | |
| 269 | + } | |
| 273 | 270 | |
| 271 | + if (!pdata->no_autorepeat) | |
| 272 | + kp->input_dev->evbit[0] |= BIT_MASK(EV_REP); | |
| 274 | 273 | input_set_capability(kp->input_dev, EV_MSC, MSC_SCAN); |
| 275 | 274 | |
| 275 | + input_set_drvdata(kp->input_dev, kp); | |
| 276 | + | |
| 276 | 277 | error = input_register_device(kp->input_dev); |
| 277 | 278 | if (error < 0) { |
| 278 | 279 | dev_err(dev, "Could not register input device\n"); |
| @@ -361,14 +361,6 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev) · 360 unmodified lines | ||
| 361 | 361 | kp->irq = platform_get_irq(pdev, 0); |
| 362 | 362 | |
| 363 | 363 | /* setup input device */ |
| 364 | − __set_bit(EV_KEY, input->evbit); | |
| 365 | − | |
| 366 | − /* Enable auto repeat feature of Linux input subsystem */ | |
| 367 | − if (pdata->rep) | |
| 368 | − __set_bit(EV_REP, input->evbit); | |
| 369 | − | |
| 370 | − input_set_capability(input, EV_MSC, MSC_SCAN); | |
| 371 | − | |
| 372 | 364 | input->name = "TWL4030 Keypad"; |
| 373 | 365 | input->phys = "twl4030_keypad/input0"; |
| 374 | 366 | input->dev.parent = &pdev->dev; |
| @@ -378,12 +370,19 @@ static int __devinit twl4030_kp_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 378 | 370 | input->id.product = 0x0001; |
| 379 | 371 | input->id.version = 0x0003; |
| 380 | 372 | |
| 381 | − input->keycode = kp->keymap; | |
| 382 | − input->keycodesize = sizeof(kp->keymap[0]); | |
| 383 | − input->keycodemax = ARRAY_SIZE(kp->keymap); | |
| 373 | + error = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 374 | + TWL4030_MAX_ROWS, | |
| 375 | + 1 << TWL4030_ROW_SHIFT, | |
| 376 | + kp->keymap, input); | |
| 377 | + if (error) { | |
| 378 | + dev_err(kp->dbg_dev, "Failed to build keymap\n"); | |
| 379 | + goto err1; | |
| 380 | + } | |
| 384 | 381 | |
| 385 | − matrix_keypad_build_keymap(keymap_data, TWL4030_ROW_SHIFT, | |
| 386 | − input->keycode, input->keybit); | |
| 382 | + input_set_capability(input, EV_MSC, MSC_SCAN); | |
| 383 | + /* Enable auto repeat feature of Linux input subsystem */ | |
| 384 | + if (pdata->rep) | |
| 385 | + __set_bit(EV_REP, input->evbit); | |
| 387 | 386 | |
| 388 | 387 | error = input_register_device(input); |
| 389 | 388 | if (error) { |
| @@ -42,7 +42,8 @@ · 41 unmodified lines | ||
| 42 | 42 | #define KGET_RAW(n) (((n) & KEY0R) >> 3) |
| 43 | 43 | #define KGET_COLUMN(n) ((n) & KEY0C) |
| 44 | 44 | |
| 45 | −#define W90P910_MAX_KEY_NUM (8 * 8) | |
| 45 | +#define W90P910_NUM_ROWS 8 | |
| 46 | +#define W90P910_NUM_COLS 8 | |
| 46 | 47 | #define W90P910_ROW_SHIFT 3 |
| 47 | 48 | |
| 48 | 49 | struct w90p910_keypad { |
| @@ -51,7 +52,7 @@ struct w90p910_keypad { · 2 unmodified lines | ||
| 51 | 52 | struct input_dev *input_dev; |
| 52 | 53 | void __iomem *mmio_base; |
| 53 | 54 | int irq; |
| 54 | − unsigned short keymap[W90P910_MAX_KEY_NUM]; | |
| 55 | + unsigned short keymap[W90P910_NUM_ROWS * W90P910_NUM_COLS]; | |
| 55 | 56 | }; |
| 56 | 57 | |
| 57 | 58 | static void w90p910_keypad_scan_matrix(struct w90p910_keypad *keypad, |
| @@ -190,17 +191,13 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev) · 132 unmodified lines | ||
| 190 | 191 | input_dev->close = w90p910_keypad_close; |
| 191 | 192 | input_dev->dev.parent = &pdev->dev; |
| 192 | 193 | |
| 193 | − input_dev->keycode = keypad->keymap; | |
| 194 | − input_dev->keycodesize = sizeof(keypad->keymap[0]); | |
| 195 | − input_dev->keycodemax = ARRAY_SIZE(keypad->keymap); | |
| 196 | − | |
| 197 | − input_set_drvdata(input_dev, keypad); | |
| 198 | − | |
| 199 | − input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | |
| 200 | − input_set_capability(input_dev, EV_MSC, MSC_SCAN); | |
| 201 | − | |
| 202 | − matrix_keypad_build_keymap(keymap_data, W90P910_ROW_SHIFT, | |
| 203 | − input_dev->keycode, input_dev->keybit); | |
| 194 | + error = matrix_keypad_build_keymap(keymap_data, NULL, | |
| 195 | + W90P910_NUM_ROWS, W90P910_NUM_COLS, | |
| 196 | + keypad->keymap, input_dev); | |
| 197 | + if (error) { | |
| 198 | + dev_err(&pdev->dev, "failed to build keymap\n"); | |
| 199 | + goto failed_put_clk; | |
| 200 | + } | |
| 204 | 201 | |
| 205 | 202 | error = request_irq(keypad->irq, w90p910_keypad_irq_handler, |
| 206 | 203 | 0, pdev->name, keypad); |
| @@ -209,6 +206,10 @@ static int __devinit w90p910_keypad_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 209 | 206 | goto failed_put_clk; |
| 210 | 207 | } |
| 211 | 208 | |
| 209 | + __set_bit(EV_REP, input_dev->evbit); | |
| 210 | + input_set_capability(input_dev, EV_MSC, MSC_SCAN); | |
| 211 | + input_set_drvdata(input_dev, keypad); | |
| 212 | + | |
| 212 | 213 | /* Register the input device */ |
| 213 | 214 | error = input_register_device(input_dev); |
| 214 | 215 | if (error) { |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | − * Helpers for open firmware matrix keyboard bindings | |
| 2 | + * Helpers for matrix keyboard bindings | |
| 3 | 3 | * |
| 4 | 4 | * Copyright (C) 2012 Google, Inc |
| 5 | 5 | * |
| @@ -21,11 +21,65 @@ · 15 unmodified lines | ||
| 21 | 21 | #include <linux/types.h> |
| 22 | 22 | #include <linux/input.h> |
| 23 | 23 | #include <linux/of.h> |
| 24 | −#include <linux/input/matrix_keypad.h> | |
| 25 | 24 | #include <linux/export.h> |
| 26 | 25 | #include <linux/gfp.h> |
| 27 | 26 | #include <linux/slab.h> |
| 27 | +#include <linux/input/matrix_keypad.h> | |
| 28 | + | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * matrix_keypad_build_keymap - convert platform keymap into matrix keymap | |
| 32 | + * @keymap_data: keymap supplied by the platform code | |
| 33 | + * @keymap_name: name of device tree property containing keymap (if device | |
| 34 | + * tree support is enabled). | |
| 35 | + * @rows: number of rows in target keymap array | |
| 36 | + * @cols: number of cols in target keymap array | |
| 37 | + * @keymap: expanded version of keymap that is suitable for use by | |
| 38 | + * matrix keyboard driver | |
| 39 | + * @input_dev: input devices for which we are setting up the keymap | |
| 40 | + * | |
| 41 | + * This function converts platform keymap (encoded with KEY() macro) into | |
| 42 | + * an array of keycodes that is suitable for using in a standard matrix | |
| 43 | + * keyboard driver that uses row and col as indices. | |
| 44 | + */ | |
| 45 | +int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | |
| 46 | + const char *keymap_name, | |
| 47 | + unsigned int rows, unsigned int cols, | |
| 48 | + unsigned short *keymap, | |
| 49 | + struct input_dev *input_dev) | |
| 50 | +{ | |
| 51 | + unsigned int row_shift = get_count_order(cols); | |
| 52 | + int i; | |
| 53 | + | |
| 54 | + input_dev->keycode = keymap; | |
| 55 | + input_dev->keycodesize = sizeof(*keymap); | |
| 56 | + input_dev->keycodemax = rows << row_shift; | |
| 57 | + | |
| 58 | + __set_bit(EV_KEY, input_dev->evbit); | |
| 59 | + | |
| 60 | + for (i = 0; i < keymap_data->keymap_size; i++) { | |
| 61 | + unsigned int key = keymap_data->keymap[i]; | |
| 62 | + unsigned int row = KEY_ROW(key); | |
| 63 | + unsigned int col = KEY_COL(key); | |
| 64 | + unsigned short code = KEY_VAL(key); | |
| 65 | + | |
| 66 | + if (row >= rows || col >= cols) { | |
| 67 | + dev_err(input_dev->dev.parent, | |
| 68 | + "%s: invalid keymap entry %d (row: %d, col: %d, rows: %d, cols: %d)\n", | |
| 69 | + __func__, i, row, col, rows, cols); | |
| 70 | + return -EINVAL; | |
| 71 | + } | |
| 72 | + | |
| 73 | + keymap[MATRIX_SCAN_CODE(row, col, row_shift)] = code; | |
| 74 | + __set_bit(code, input_dev->keybit); | |
| 75 | + } | |
| 76 | + __clear_bit(KEY_RESERVED, input_dev->keybit); | |
| 77 | + | |
| 78 | + return 0; | |
| 79 | +} | |
| 80 | +EXPORT_SYMBOL(matrix_keypad_build_keymap); | |
| 28 | 81 | |
| 82 | +#ifdef CONFIG_OF | |
| 29 | 83 | struct matrix_keymap_data * |
| 30 | 84 | matrix_keyboard_of_fill_keymap(struct device_node *np, |
| 31 | 85 | const char *propname) |
| @@ -85,3 +139,4 @@ void matrix_keyboard_of_free_keymap(const struct matrix_keymap_data *kd) · 53 unmodified lines | ||
| 85 | 139 | } |
| 86 | 140 | } |
| 87 | 141 | EXPORT_SYMBOL_GPL(matrix_keyboard_of_free_keymap); |
| 142 | +#endif | |
| @@ -75,39 +75,13 @@ struct matrix_keypad_platform_data { · 74 unmodified lines | ||
| 75 | 75 | bool no_autorepeat; |
| 76 | 76 | }; |
| 77 | 77 | |
| 78 | −/** | |
| 79 | − * matrix_keypad_build_keymap - convert platform keymap into matrix keymap | |
| 80 | − * @keymap_data: keymap supplied by the platform code | |
| 81 | − * @row_shift: number of bits to shift row value by to advance to the next | |
| 82 | − * line in the keymap | |
| 83 | − * @keymap: expanded version of keymap that is suitable for use by | |
| 84 | − * matrix keyboad driver | |
| 85 | − * @keybit: pointer to bitmap of keys supported by input device | |
| 86 | − * | |
| 87 | − * This function converts platform keymap (encoded with KEY() macro) into | |
| 88 | − * an array of keycodes that is suitable for using in a standard matrix | |
| 89 | − * keyboard driver that uses row and col as indices. | |
| 90 | − */ | |
| 91 | −static inline void | |
| 92 | −matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | |
| 93 | − unsigned int row_shift, | |
| 94 | − unsigned short *keymap, unsigned long *keybit) | |
| 95 | −{ | |
| 96 | − int i; | |
| 97 | − | |
| 98 | − for (i = 0; i < keymap_data->keymap_size; i++) { | |
| 99 | − unsigned int key = keymap_data->keymap[i]; | |
| 100 | − unsigned int row = KEY_ROW(key); | |
| 101 | − unsigned int col = KEY_COL(key); | |
| 102 | − unsigned short code = KEY_VAL(key); | |
| 103 | − | |
| 104 | − keymap[MATRIX_SCAN_CODE(row, col, row_shift)] = code; | |
| 105 | − __set_bit(code, keybit); | |
| 106 | − } | |
| 107 | − __clear_bit(KEY_RESERVED, keybit); | |
| 108 | −} | |
| 78 | +int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | |
| 79 | + const char *keymap_name, | |
| 80 | + unsigned int rows, unsigned int cols, | |
| 81 | + unsigned short *keymap, | |
| 82 | + struct input_dev *input_dev); | |
| 109 | 83 | |
| 110 | −#ifdef CONFIG_INPUT_OF_MATRIX_KEYMAP | |
| 84 | +#ifdef CONFIG_OF | |
| 111 | 85 | struct matrix_keymap_data * |
| 112 | 86 | matrix_keyboard_of_fill_keymap(struct device_node *np, const char *propname); |
| 113 | 87 | |