Skip to content

Commit d6ed525

Browse files
Mattijs Korpershoekdtor
authored andcommitted
Input: mt6779-keypad - match hardware matrix organization
The MediaTek keypad has a set of bits representing keys, from KEY0 to KEY77, arranged in 5 chunks of 15 bits split into 5 32-bit registers. In our implementation, we simply decided to use register number as row and offset in the register as column when encoding our "matrix". Because of this, we can have a 5x32 matrix which does not match the hardware at all, which is confusing. Change the row/column calculation to match the hardware. Fixes: f28af98 ("Input: mt6779-keypad - add MediaTek keypad driver") Co-developed-by: Fabien Parent <[email protected]> Signed-off-by: Fabien Parent <[email protected]> Signed-off-by: Mattijs Korpershoek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 436d219 commit d6ed525

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/input/keyboard/mt6779-keypad.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static irqreturn_t mt6779_keypad_irq_handler(int irq, void *dev_id)
4242
const unsigned short *keycode = keypad->input_dev->keycode;
4343
DECLARE_BITMAP(new_state, MTK_KPD_NUM_BITS);
4444
DECLARE_BITMAP(change, MTK_KPD_NUM_BITS);
45-
unsigned int bit_nr;
45+
unsigned int bit_nr, key;
4646
unsigned int row, col;
4747
unsigned int scancode;
4848
unsigned int row_shift = get_count_order(keypad->n_cols);
@@ -61,8 +61,10 @@ static irqreturn_t mt6779_keypad_irq_handler(int irq, void *dev_id)
6161
if (bit_nr % 32 >= 16)
6262
continue;
6363

64-
row = bit_nr / 32;
65-
col = bit_nr % 32;
64+
key = bit_nr / 32 * 16 + bit_nr % 32;
65+
row = key / 9;
66+
col = key % 9;
67+
6668
scancode = MATRIX_SCAN_CODE(row, col, row_shift);
6769
/* 1: not pressed, 0: pressed */
6870
pressed = !test_bit(bit_nr, new_state);

0 commit comments

Comments
 (0)