Skip to content

Commit

Permalink
Input: matrix-keymap - uninline and prepare for device tree support
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Dmitry Torokhov committed May 11, 2012
1 parent d0a3457 commit 1932811
Show file tree
Hide file tree
Showing 22 changed files with 265 additions and 209 deletions.
17 changes: 13 additions & 4 deletions drivers/input/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ config INPUT

if INPUT

config INPUT_OF_MATRIX_KEYMAP
depends on USE_OF
bool

config INPUT_FF_MEMLESS
tristate "Support for memoryless force-feedback devices"
help
Expand Down Expand Up @@ -68,6 +64,19 @@ config INPUT_SPARSEKMAP
To compile this driver as a module, choose M here: the
module will be called sparse-keymap.

config INPUT_MATRIXKMAP
tristate "Matrix keymap support library"
help
Say Y here if you are using a driver for an input
device that uses matrix keymap. This option is only
useful for out-of-tree drivers since in-tree drivers
select it automatically.

If unsure, say N.

To compile this driver as a module, choose M here: the
module will be called matrix-keymap.

comment "Userland interfaces"

config INPUT_MOUSEDEV
Expand Down
2 changes: 1 addition & 1 deletion drivers/input/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ input-core-y := input.o input-compat.o input-mt.o ff-core.o
obj-$(CONFIG_INPUT_FF_MEMLESS) += ff-memless.o
obj-$(CONFIG_INPUT_POLLDEV) += input-polldev.o
obj-$(CONFIG_INPUT_SPARSEKMAP) += sparse-keymap.o
obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o

obj-$(CONFIG_INPUT_MOUSEDEV) += mousedev.o
obj-$(CONFIG_INPUT_JOYDEV) += joydev.o
Expand All @@ -24,4 +25,3 @@ obj-$(CONFIG_INPUT_TOUCHSCREEN) += touchscreen/
obj-$(CONFIG_INPUT_MISC) += misc/

obj-$(CONFIG_INPUT_APMPOWER) += apm-power.o
obj-$(CONFIG_INPUT_OF_MATRIX_KEYMAP) += of_keymap.o
18 changes: 17 additions & 1 deletion drivers/input/keyboard/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ config KEYBOARD_LKKBD
config KEYBOARD_EP93XX
tristate "EP93xx Matrix Keypad support"
depends on ARCH_EP93XX
select INPUT_MATRIXKMAP
help
Say Y here to enable the matrix keypad on the Cirrus EP93XX.

Expand Down Expand Up @@ -224,6 +225,7 @@ config KEYBOARD_TCA6416
config KEYBOARD_TCA8418
tristate "TCA8418 Keypad Support"
depends on I2C
select INPUT_MATRIXKMAP
help
This driver implements basic keypad functionality
for keys connected through TCA8418 keypad decoder.
Expand All @@ -240,6 +242,7 @@ config KEYBOARD_TCA8418
config KEYBOARD_MATRIX
tristate "GPIO driven matrix keypad support"
depends on GENERIC_GPIO
select INPUT_MATRIXKMAP
help
Enable support for GPIO driven matrix keypad.

Expand Down Expand Up @@ -312,6 +315,7 @@ config KEYBOARD_LM8323
config KEYBOARD_LM8333
tristate "LM8333 keypad chip"
depends on I2C
select INPUT_MATRIXKMAP
help
If you say yes here you get support for the National Semiconductor
LM8333 keypad controller.
Expand Down Expand Up @@ -376,6 +380,7 @@ config KEYBOARD_MPR121
config KEYBOARD_IMX
tristate "IMX keypad support"
depends on ARCH_MXC
select INPUT_MATRIXKMAP
help
Enable support for IMX keypad port.

Expand All @@ -394,6 +399,7 @@ config KEYBOARD_NEWTON
config KEYBOARD_NOMADIK
tristate "ST-Ericsson Nomadik SKE keyboard"
depends on PLAT_NOMADIK
select INPUT_MATRIXKMAP
help
Say Y here if you want to use a keypad provided on the SKE controller
used on the Ux500 and Nomadik platforms
Expand All @@ -404,7 +410,7 @@ config KEYBOARD_NOMADIK
config KEYBOARD_TEGRA
tristate "NVIDIA Tegra internal matrix keyboard controller support"
depends on ARCH_TEGRA
select INPUT_OF_MATRIX_KEYMAP if USE_OF
select INPUT_MATRIXKMAP
help
Say Y here if you want to use a matrix keyboard connected directly
to the internal keyboard controller on Tegra SoCs.
Expand Down Expand Up @@ -442,6 +448,7 @@ config KEYBOARD_PXA930_ROTARY
config KEYBOARD_PMIC8XXX
tristate "Qualcomm PMIC8XXX keypad support"
depends on MFD_PM8XXX
select INPUT_MATRIXKMAP
help
Say Y here if you want to enable the driver for the PMIC8XXX
keypad provided as a reference design from Qualcomm. This is intended
Expand All @@ -453,6 +460,7 @@ config KEYBOARD_PMIC8XXX
config KEYBOARD_SAMSUNG
tristate "Samsung keypad support"
depends on HAVE_CLK
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the keypad on your Samsung mobile
device.
Expand Down Expand Up @@ -495,6 +503,7 @@ config KEYBOARD_SH_KEYSC
config KEYBOARD_STMPE
tristate "STMPE keypad support"
depends on MFD_STMPE
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the keypad controller on STMPE I/O
expanders.
Expand All @@ -515,6 +524,7 @@ config KEYBOARD_DAVINCI
config KEYBOARD_OMAP
tristate "TI OMAP keypad support"
depends on (ARCH_OMAP1 || ARCH_OMAP2)
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the OMAP keypad.

Expand All @@ -523,6 +533,7 @@ config KEYBOARD_OMAP

config KEYBOARD_OMAP4
tristate "TI OMAP4+ keypad support"
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the OMAP4+ keypad.

Expand All @@ -532,6 +543,7 @@ config KEYBOARD_OMAP4
config KEYBOARD_SPEAR
tristate "ST SPEAR keyboard support"
depends on PLAT_SPEAR
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the SPEAR keyboard.

Expand All @@ -541,6 +553,7 @@ config KEYBOARD_SPEAR
config KEYBOARD_TC3589X
tristate "TC3589X Keypad support"
depends on MFD_TC3589X
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the keypad controller on
TC35892/3 I/O expander.
Expand All @@ -551,6 +564,7 @@ config KEYBOARD_TC3589X
config KEYBOARD_TNETV107X
tristate "TI TNETV107X keypad support"
depends on ARCH_DAVINCI_TNETV107X
select INPUT_MATRIXKMAP
help
Say Y here if you want to use the TNETV107X keypad.

Expand All @@ -560,6 +574,7 @@ config KEYBOARD_TNETV107X
config KEYBOARD_TWL4030
tristate "TI TWL4030/TWL5030/TPS659x0 keypad support"
depends on TWL4030_CORE
select INPUT_MATRIXKMAP
help
Say Y here if your board use the keypad controller on
TWL4030 family chips. It's safe to say enable this
Expand All @@ -583,6 +598,7 @@ config KEYBOARD_XTKBD
config KEYBOARD_W90P910
tristate "W90P910 Matrix Keypad support"
depends on ARCH_W90X900
select INPUT_MATRIXKMAP
help
Say Y here to enable the matrix keypad on evaluation board
based on W90P910.
Expand Down
18 changes: 8 additions & 10 deletions drivers/input/keyboard/ep93xx_keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,19 +303,16 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
input_dev->open = ep93xx_keypad_open;
input_dev->close = ep93xx_keypad_close;
input_dev->dev.parent = &pdev->dev;
input_dev->keycode = keypad->keycodes;
input_dev->keycodesize = sizeof(keypad->keycodes[0]);
input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);

input_set_drvdata(input_dev, keypad);
err = matrix_keypad_build_keymap(keymap_data, NULL,
EP93XX_MATRIX_ROWS, EP93XX_MATRIX_COLS,
keypad->keycodes, input_dev);
if (err)
goto failed_free_dev;

input_dev->evbit[0] = BIT_MASK(EV_KEY);
if (keypad->pdata->flags & EP93XX_KEYPAD_AUTOREPEAT)
input_dev->evbit[0] |= BIT_MASK(EV_REP);

matrix_keypad_build_keymap(keymap_data, 3,
input_dev->keycode, input_dev->keybit);
platform_set_drvdata(pdev, keypad);
__set_bit(EV_REP, input_dev->evbit);
input_set_drvdata(input_dev, keypad);

err = request_irq(keypad->irq, ep93xx_keypad_irq_handler,
0, pdev->name, keypad);
Expand All @@ -326,6 +323,7 @@ static int __devinit ep93xx_keypad_probe(struct platform_device *pdev)
if (err)
goto failed_free_irq;

platform_set_drvdata(pdev, keypad);
device_init_wakeup(&pdev->dev, 1);

return 0;
Expand Down
17 changes: 10 additions & 7 deletions drivers/input/keyboard/imx_keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev)
}

if (keypad->rows_en_mask > ((1 << MAX_MATRIX_KEY_ROWS) - 1) ||
keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
keypad->cols_en_mask > ((1 << MAX_MATRIX_KEY_COLS) - 1)) {
dev_err(&pdev->dev,
"invalid key data (too many rows or colums)\n");
error = -EINVAL;
Expand All @@ -496,14 +496,17 @@ static int __devinit imx_keypad_probe(struct platform_device *pdev)
input_dev->dev.parent = &pdev->dev;
input_dev->open = imx_keypad_open;
input_dev->close = imx_keypad_close;
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
input_dev->keycode = keypad->keycodes;
input_dev->keycodesize = sizeof(keypad->keycodes[0]);
input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);

matrix_keypad_build_keymap(keymap_data, MATRIX_ROW_SHIFT,
keypad->keycodes, input_dev->keybit);
error = matrix_keypad_build_keymap(keymap_data, NULL,
MAX_MATRIX_KEY_ROWS,
MAX_MATRIX_KEY_COLS,
keypad->keycodes, input_dev);
if (error) {
dev_err(&pdev->dev, "failed to build keymap\n");
goto failed_clock_put;
}

__set_bit(EV_REP, input_dev->evbit);
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
input_set_drvdata(input_dev, keypad);

Expand Down
15 changes: 7 additions & 8 deletions drivers/input/keyboard/lm8333.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

#define LM8333_FIFO_TRANSFER_SIZE 16

#define LM8333_ROW_SHIFT 4
#define LM8333_NUM_ROWS 8

#define LM8333_NUM_COLS 16
#define LM8333_ROW_SHIFT 4

struct lm8333 {
struct i2c_client *client;
Expand Down Expand Up @@ -159,14 +159,13 @@ static int __devinit lm8333_probe(struct i2c_client *client,
input->dev.parent = &client->dev;
input->id.bustype = BUS_I2C;

input->keycode = lm8333->keycodes;
input->keycodesize = sizeof(lm8333->keycodes[0]);
input->keycodemax = ARRAY_SIZE(lm8333->keycodes);
input->evbit[0] = BIT_MASK(EV_KEY);
input_set_capability(input, EV_MSC, MSC_SCAN);

matrix_keypad_build_keymap(pdata->matrix_data, LM8333_ROW_SHIFT,
input->keycode, input->keybit);
err = matrix_keypad_build_keymap(pdata->matrix_data, NULL,
LM8333_NUM_ROWS, LM8333_NUM_COLS,
lm8333->keycodes, input);
if (err)
goto free_mem;

if (pdata->debounce_time) {
err = lm8333_write8(lm8333, LM8333_DEBOUNCE,
Expand Down
17 changes: 8 additions & 9 deletions drivers/input/keyboard/matrix_keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,19 +437,18 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
input_dev->name = pdev->name;
input_dev->id.bustype = BUS_HOST;
input_dev->dev.parent = &pdev->dev;
input_dev->evbit[0] = BIT_MASK(EV_KEY);
if (!pdata->no_autorepeat)
input_dev->evbit[0] |= BIT_MASK(EV_REP);
input_dev->open = matrix_keypad_start;
input_dev->close = matrix_keypad_stop;

input_dev->keycode = keypad->keycodes;
input_dev->keycodesize = sizeof(keypad->keycodes[0]);
input_dev->keycodemax = pdata->num_row_gpios << row_shift;

matrix_keypad_build_keymap(keymap_data, row_shift,
input_dev->keycode, input_dev->keybit);
err = matrix_keypad_build_keymap(keymap_data, NULL,
pdata->num_row_gpios,
pdata->num_col_gpios,
keypad->keycodes, input_dev);
if (err)
goto err_free_mem;

if (!pdata->no_autorepeat)
__set_bit(EV_REP, input_dev->evbit);
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
input_set_drvdata(input_dev, keypad);

Expand Down
20 changes: 10 additions & 10 deletions drivers/input/keyboard/nomadik-ske-keypad.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#define SKE_KPRISA (0x1 << 2)

#define SKE_KEYPAD_ROW_SHIFT 3
#define SKE_KPD_KEYMAP_SIZE (8 * 8)
#define SKE_KPD_NUM_ROWS 8
#define SKE_KPD_NUM_COLS 8

/* keypad auto scan registers */
#define SKE_ASR0 0x20
Expand All @@ -63,7 +64,7 @@ struct ske_keypad {
void __iomem *reg_base;
struct input_dev *input;
const struct ske_keypad_platform_data *board;
unsigned short keymap[SKE_KPD_KEYMAP_SIZE];
unsigned short keymap[SKE_KPD_NUM_ROWS * SKE_KPD_NUM_COLS];
struct clk *clk;
spinlock_t ske_keypad_lock;
};
Expand Down Expand Up @@ -261,19 +262,18 @@ static int __init ske_keypad_probe(struct platform_device *pdev)
input->name = "ux500-ske-keypad";
input->dev.parent = &pdev->dev;

input->keycode = keypad->keymap;
input->keycodesize = sizeof(keypad->keymap[0]);
input->keycodemax = ARRAY_SIZE(keypad->keymap);
error = matrix_keypad_build_keymap(plat->keymap_data, NULL,
SKE_KPD_NUM_ROWS, SKE_KPD_NUM_COLS,
keypad->keymap, input);
if (error) {
dev_err(&pdev->dev, "Failed to build keymap\n");
goto err_iounmap;
}

input_set_capability(input, EV_MSC, MSC_SCAN);

__set_bit(EV_KEY, input->evbit);
if (!plat->no_autorepeat)
__set_bit(EV_REP, input->evbit);

matrix_keypad_build_keymap(plat->keymap_data, SKE_KEYPAD_ROW_SHIFT,
input->keycode, input->keybit);

clk_enable(keypad->clk);

/* go through board initialization helpers */
Expand Down
Loading

0 comments on commit 1932811

Please sign in to comment.