From: Chao Xie <chao.xie@marvell.com>
To: dmitry.torokhov@gmail.com, arnd@arndb.de, eric.y.miao@gmail.com,
haojian.zhuang@gmail.com, drwyrm@gmail.com, stefan@openezx.org,
laforge@openezx.org, robert.jarzmik@free.fr,
marek.vasut@gmail.com, sleep_walker@suse.cz, slapin@ossfans.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
xiechao.mail@gmail.com
Cc: Chao Xie <chao.xie@marvell.com>
Subject: [PATCH V3 1/5] input: pxa27x-keypad: use matrix_keymap for matrix keyes
Date: Mon, 17 Jun 2013 23:56:14 -0400 [thread overview]
Message-ID: <1371527778-5236-2-git-send-email-chao.xie@marvell.com> (raw)
In-Reply-To: <1371527778-5236-1-git-send-email-chao.xie@marvell.com>
pxa27x-keypad includes matrix keyes. Make use of matrix_keymap
for the matrix keyes.
Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
drivers/input/keyboard/Kconfig | 1 +
drivers/input/keyboard/pxa27x_keypad.c | 36 +++++++++++++++++---------
include/linux/platform_data/keypad-pxa27x.h | 1 +
3 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 37c3666..706e11b 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -451,6 +451,7 @@ config KEYBOARD_OPENCORES
config KEYBOARD_PXA27x
tristate "PXA27x/PXA3xx keypad support"
depends on PXA27x || PXA3xx || ARCH_MMP
+ select INPUT_MATRIXKMAP
help
Enable support for PXA27x/PXA3xx keypad controller.
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index b674e7a..947d657 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -118,25 +118,29 @@ struct pxa27x_keypad {
unsigned int direct_key_mask;
};
-static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
+static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
{
struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct input_dev *input_dev = keypad->input_dev;
unsigned short keycode;
- int i;
+ int ret, i;
+ const struct matrix_keymap_data *keymap_data =
+ pdata ? pdata->matrix_keymap_data : NULL;
- for (i = 0; i < pdata->matrix_key_map_size; i++) {
- unsigned int key = pdata->matrix_key_map[i];
- unsigned int row = KEY_ROW(key);
- unsigned int col = KEY_COL(key);
- unsigned int scancode = MATRIX_SCAN_CODE(row, col,
- MATRIX_ROW_SHIFT);
+ ret = matrix_keypad_build_keymap(keymap_data, NULL,
+ pdata->matrix_key_rows,
+ pdata->matrix_key_cols,
+ keypad->keycodes, input_dev);
+ if (ret)
+ return ret;
- keycode = KEY_VAL(key);
- keypad->keycodes[scancode] = keycode;
- __set_bit(keycode, input_dev->keybit);
- }
+ /*
+ * The keycodes may not only includes matrix key but also the direct
+ * key or rotary key.
+ */
+ input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
+ /* For direct key. */
for (i = 0; i < pdata->direct_key_num; i++) {
keycode = pdata->direct_key_map[i];
keypad->keycodes[MAX_MATRIX_KEY_NUM + i] = keycode;
@@ -178,6 +182,8 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
}
__clear_bit(KEY_RESERVED, input_dev->keybit);
+
+ return 0;
}
static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad)
@@ -555,7 +561,11 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);
input_set_capability(input_dev, EV_MSC, MSC_SCAN);
- pxa27x_keypad_build_keycode(keypad);
+ error = pxa27x_keypad_build_keycode(keypad);
+ if (error) {
+ dev_err(&pdev->dev, "failed to build keycode\n");
+ goto failed_put_clk;
+ }
if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) ||
(pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) {
diff --git a/include/linux/platform_data/keypad-pxa27x.h b/include/linux/platform_data/keypad-pxa27x.h
index 5ce8d5e6..0db423b 100644
--- a/include/linux/platform_data/keypad-pxa27x.h
+++ b/include/linux/platform_data/keypad-pxa27x.h
@@ -36,6 +36,7 @@
struct pxa27x_keypad_platform_data {
/* code map for the matrix keys */
+ const struct matrix_keymap_data *matrix_keymap_data;
unsigned int matrix_key_rows;
unsigned int matrix_key_cols;
unsigned int *matrix_key_map;
--
1.7.4.1
next prev parent reply other threads:[~2013-06-18 3:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 3:56 [PATCH V3 0/5] input: pxa27x-keypad: enhancement and device tree support Chao Xie
2013-06-18 3:56 ` Chao Xie [this message]
2013-06-22 15:24 ` [PATCH V3 1/5] input: pxa27x-keypad: use matrix_keymap for matrix keyes Mike Dunn
2013-06-18 3:56 ` [PATCH V3 2/5] arm: mmp: use matrix_keymap for all boards Chao Xie
2013-06-18 3:56 ` [PATCH V3 3/5] arm: pxa: " Chao Xie
2013-06-18 14:02 ` Arnd Bergmann
2013-06-22 15:26 ` Mike Dunn
2013-06-18 3:56 ` [PATCH V3 4/5] input: pxa27x-keypad: remove the unused members at platform data Chao Xie
2013-06-18 3:56 ` [PATCH V3 5/5] input: pxa27x-keypad: add device tree support Chao Xie
2013-06-19 8:22 ` Marek Vasut
2013-06-19 8:38 ` Chao Xie
2013-06-19 9:25 ` Arnd Bergmann
2013-06-19 11:13 ` Gerhard Sittig
2013-06-20 2:01 ` Chao Xie
2013-06-20 9:06 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371527778-5236-2-git-send-email-chao.xie@marvell.com \
--to=chao.xie@marvell.com \
--cc=arnd@arndb.de \
--cc=dmitry.torokhov@gmail.com \
--cc=drwyrm@gmail.com \
--cc=eric.y.miao@gmail.com \
--cc=haojian.zhuang@gmail.com \
--cc=laforge@openezx.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marek.vasut@gmail.com \
--cc=robert.jarzmik@free.fr \
--cc=slapin@ossfans.org \
--cc=sleep_walker@suse.cz \
--cc=stefan@openezx.org \
--cc=xiechao.mail@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).