input: pxa27x-keypad: bug fix of getting scan code
Subsystems (2)
PATCH 1/1 input: pxa27x-keypad: bug fix of getting scan code
From: Chao Xie <[email protected]>
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 asMATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
It is not correct. Fix it asMATRIX_SCAN_CODE(row, col, keypad->row_shift);
row_shift is calculated from pdata->matrix_key_rows.
--- drivers/input/keyboard/pxa27x_keypad.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/input/keyboard/pxa27x_keypad.c +5 -1
@@ -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));
Signature · 1 line
1.8.3.2
Dmitry Torokhov
maintainerPATCH 1/1 input: pxa27x-keypad: bug fix of getting scan code
Quoted 10 lines · Chao Xie
From: Chao Xie <[email protected]>
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);
Quoted 8 lines
But the scan code is gotten as
MATRIX_SCAN_CODE(row, col, MATRIX_ROW_SHIFT);
It is not correct. Fix it asMATRIX_SCAN_CODE(row, col, keypad->row_shift);
row_shiftis calculated frompdata->matrix_key_rows.Signed-off-by Chao Xie <[email protected]>
Applied with minor edits, thank you.
Signature · 1 line
Dmitry