* [PATCH] input: pxa27x-keypad: bug fix of getting scan code
@ 2014-01-27 4:41 Chao Xie
2014-05-14 6:12 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Chao Xie @ 2014-01-27 4:41 UTC (permalink / raw)
To: linux-input, dmitry.torokhov, linux-arm-kernel, xiechao.mail; +Cc: Chao Xie
From: Chao Xie <chao.xie@marvell.com>
The rows of pxa27x-keypad used by each boards are not fixed.
So in the driver, it will get the rows from DT and register
the keymap as:
matrix_keypad_build_keymap(keymap_data, NULL,
pdata->matrix_key_rows,
pdata->matrix_key_cols,
keypad->keycodes, input_dev);
But the scan code is gotten as
MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
It is not correct. Fix it as
MATRIX_SCAN_CODE(row, col, keypad->row_shift);
row_shift is calculated from pdata->matrix_key_rows.
Signed-off-by: Chao Xie <chao.xie@marvell.com>
---
drivers/input/keyboard/pxa27x_keypad.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index d8241ba..8da3eb0 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -113,6 +113,7 @@ struct pxa27x_keypad {
/* state row bits of each column scan */
uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS];
+ uint32_t row_shift;
uint32_t direct_key_state;
unsigned int direct_key_mask;
@@ -139,6 +140,7 @@ static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad,
pdata->matrix_key_rows = rows;
pdata->matrix_key_cols = cols;
+ keypad->row_shift = get_count_order(pdata->matrix_key_cols);
error = matrix_keypad_build_keymap(NULL, NULL,
pdata->matrix_key_rows,
pdata->matrix_key_cols,
@@ -359,6 +361,7 @@ static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
if (error)
return error;
+ keypad->row_shift = get_count_order(pdata->matrix_key_cols);
/*
* The keycodes may not only include matrix keys but also the direct
* or rotary keys.
@@ -467,7 +470,8 @@ scan:
if ((bits_changed & (1 << row)) == 0)
continue;
- code = MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
+ code = MATRIX_SCAN_CODE(row, col, keypad->row_shift);
+
input_event(input_dev, EV_MSC, MSC_SCAN, code);
input_report_key(input_dev, keypad->keycodes[code],
new_state[col] & (1 << row));
--
1.8.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] input: pxa27x-keypad: bug fix of getting scan code
2014-01-27 4:41 [PATCH] input: pxa27x-keypad: bug fix of getting scan code Chao Xie
@ 2014-05-14 6:12 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2014-05-14 6:12 UTC (permalink / raw)
To: Chao Xie; +Cc: linux-input, linux-arm-kernel, xiechao.mail
On Mon, Jan 27, 2014 at 12:41:37PM +0800, Chao Xie wrote:
> From: Chao Xie <chao.xie@marvell.com>
>
> The rows of pxa27x-keypad used by each boards are not fixed.
> So in the driver, it will get the rows from DT and register
> the keymap as:
> matrix_keypad_build_keymap(keymap_data, NULL,
> pdata->matrix_key_rows,
> pdata->matrix_key_cols,
> keypad->keycodes, input_dev);
>
> But the scan code is gotten as
> MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
> It is not correct. Fix it as
> MATRIX_SCAN_CODE(row, col, keypad->row_shift);
>
> row_shift is calculated from pdata->matrix_key_rows.
>
> Signed-off-by: Chao Xie <chao.xie@marvell.com>
Applied with minor edits, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-14 6:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 4:41 [PATCH] input: pxa27x-keypad: bug fix of getting scan code Chao Xie
2014-05-14 6:12 ` Dmitry Torokhov
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).