summaryrefslogtreecommitdiffstats
path: root/include/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 /include/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 'include/input')
-rw-r--r--include/input/matrix_keypad.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/input/matrix_keypad.h b/include/input/matrix_keypad.h
new file mode 100644
index 0000000000..77b00c0882
--- /dev/null
+++ b/include/input/matrix_keypad.h
@@ -0,0 +1,35 @@
+#ifndef _MATRIX_KEYPAD_H
+#define _MATRIX_KEYPAD_H
+
+#define MATRIX_MAX_ROWS 32
+#define MATRIX_MAX_COLS 32
+
+#define KEY(row, col, val) ((((row) & (MATRIX_MAX_ROWS - 1)) << 24) |\
+ (((col) & (MATRIX_MAX_COLS - 1)) << 16) |\
+ ((val) & 0xffff))
+
+#define KEY_ROW(k) (((k) >> 24) & 0xff)
+#define KEY_COL(k) (((k) >> 16) & 0xff)
+#define KEY_VAL(k) ((k) & 0xffff)
+
+#define MATRIX_SCAN_CODE(row, col, row_shift) (((row) << (row_shift)) + (col))
+
+/**
+ * struct matrix_keymap_data - keymap for matrix keyboards
+ * @keymap: pointer to array of uint32 values encoded with KEY() macro
+ * representing keymap
+ * @keymap_size: number of entries (initialized) in this keymap
+ *
+ * This structure is supposed to be used by platform code to supply
+ * keymaps to drivers that implement matrix-like keypads/keyboards.
+ */
+struct matrix_keymap_data {
+ const uint32_t *keymap;
+ unsigned int keymap_size;
+};
+
+int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
+ unsigned int row_shift,
+ unsigned short *keymap);
+
+#endif /* _MATRIX_KEYPAD_H */