summaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-01-13 11:12:58 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2016-01-13 16:28:06 +0100
commit6639c98acc98ec2103c215800b4d63dbea843248 (patch)
tree8186cc42aad6d63fd07bdafd70b0efb4be0920ec /drivers/input
parentf3bf60efcb029d2a325926bc5f98b8ae27b2b0b1 (diff)
downloadbarebox-6639c98acc98ec2103c215800b4d63dbea843248.tar.gz
barebox-6639c98acc98ec2103c215800b4d63dbea843248.tar.xz
input: move matrix_keypad_build_keymap() to C file
Future additions will make the function too big to live as a static inline function. Move to a C file and while at it, move matrix_keypad.h to include/input/ where it belongs to. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/Kconfig4
-rw-r--r--drivers/input/Makefile1
-rw-r--r--drivers/input/imx_keypad.c2
-rw-r--r--drivers/input/matrix-keymap.c42
4 files changed, 48 insertions, 1 deletions
diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index b840df2ed5..24c3bd758c 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -8,6 +8,9 @@ menu "Input device support"
config INPUT
bool
+config INPUT_MATRIXKMAP
+ bool
+
config KEYBOARD_GPIO
bool "GPIO Buttons"
depends on GENERIC_GPIO
@@ -24,6 +27,7 @@ config KEYBOARD_GPIO
config KEYBOARD_IMX_KEYPAD
bool "IMX Keypad"
depends on ARCH_IMX
+ select INPUT_MATRIXKMAP
select POLLER
help
This driver implements support for buttons connected
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index b9e5a5db2f..7d2c1945f7 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -1,4 +1,5 @@
obj-$(CONFIG_INPUT) += input.o
+obj-$(CONFIG_INPUT_MATRIXKMAP) += matrix-keymap.o
obj-$(CONFIG_KEYBOARD_USB) += usb_kbd.o
obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o
diff --git a/drivers/input/imx_keypad.c b/drivers/input/imx_keypad.c
index 272b8367df..b0282f2f8c 100644
--- a/drivers/input/imx_keypad.c
+++ b/drivers/input/imx_keypad.c
@@ -46,7 +46,7 @@
#include <poller.h>
#include <kfifo.h>
#include <malloc.h>
-#include <matrix_keypad.h>
+#include <input/matrix_keypad.h>
#include <linux/err.h>
/*
diff --git a/drivers/input/matrix-keymap.c b/drivers/input/matrix-keymap.c
new file mode 100644
index 0000000000..d56eccc29e
--- /dev/null
+++ b/drivers/input/matrix-keymap.c
@@ -0,0 +1,42 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <common.h>
+#include <input/matrix_keypad.h>
+
+/**
+ * matrix_keypad_build_keymap - convert platform keymap into matrix keymap
+ * @keymap_data: keymap supplied by the platform code
+ * @row_shift: number of bits to shift row value by to advance to the next
+ * line in the keymap
+ * @keymap: expanded version of keymap that is suitable for use by
+ * matrix keyboad driver
+ * This function converts platform keymap (encoded with KEY() macro) into
+ * an array of keycodes that is suitable for using in a standard matrix
+ * keyboard driver that uses row and col as indices.
+ */
+int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
+ unsigned int row_shift,
+ unsigned short *keymap)
+{
+ int i;
+
+ for (i = 0; i < keymap_data->keymap_size; i++) {
+ unsigned int key = keymap_data->keymap[i];
+ unsigned int row = KEY_ROW(key);
+ unsigned int col = KEY_COL(key);
+ unsigned short code = KEY_VAL(key);
+
+ keymap[MATRIX_SCAN_CODE(row, col, row_shift)] = code;
+ }
+
+ return 0;
+}