Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: f28af984e771 ("Input: mt6779-keypad - add MediaTek keypad driver")
Co-developed-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20220707075236.126631-2-mkorpershoek@baylibre.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Mattijs Korpershoek and committed by
Dmitry Torokhov
d6ed5258 436d2190

+5 -3
+5 -3
drivers/input/keyboard/mt6779-keypad.c
··· 42 42 const unsigned short *keycode = keypad->input_dev->keycode; 43 43 DECLARE_BITMAP(new_state, MTK_KPD_NUM_BITS); 44 44 DECLARE_BITMAP(change, MTK_KPD_NUM_BITS); 45 - unsigned int bit_nr; 45 + unsigned int bit_nr, key; 46 46 unsigned int row, col; 47 47 unsigned int scancode; 48 48 unsigned int row_shift = get_count_order(keypad->n_cols); ··· 61 61 if (bit_nr % 32 >= 16) 62 62 continue; 63 63 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 + 66 68 scancode = MATRIX_SCAN_CODE(row, col, row_shift); 67 69 /* 1: not pressed, 0: pressed */ 68 70 pressed = !test_bit(bit_nr, new_state);