Re: [PATCHv2 4/3] Input: omap4-keypad - scan the keys in two phases to detect lost key-up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 28, 2020 at 10:02:43AM -0800, Tony Lindgren wrote:
> In addition to handling errata i689 for idle with state, we must also
> check for lost key up interrupts on fast key presses.
> 
> For example rapidly pressing shift-shift-j can sometimes produce a J
> instead of j. Let's fix the issue by scanning the keyboard in two
> phases. First we scan for any key up events that we may have missed,
> and then we scan for key down events.
> 
> Cc: Arthur Demchenkov <spinal.by@xxxxxxxxx>
> Cc: Merlijn Wajer <merlijn@xxxxxxxxxx>
> Cc: Pavel Machek <pavel@xxxxxx>
> Cc: Sebastian Reichel <sre@xxxxxxxxxx>
> Signed-off-by: Tony Lindgren <tony@xxxxxxxxxxx>
> ---
>  drivers/input/keyboard/omap4-keypad.c | 48 ++++++++++++++++++---------
>  1 file changed, 32 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c
> --- a/drivers/input/keyboard/omap4-keypad.c
> +++ b/drivers/input/keyboard/omap4-keypad.c
> @@ -109,6 +109,34 @@ static void kbd_write_irqreg(struct omap4_keypad *keypad_data,
>  		     keypad_data->base + keypad_data->irqreg_offset + offset);
>  }
>  
> +static void omap4_keypad_scan_state(struct omap4_keypad *keypad_data,
> +				    unsigned char *key_state,
> +				    bool down)
> +{
> +	struct input_dev *input_dev = keypad_data->input;
> +	unsigned int col, row, code, changed;
> +	bool key_down;
> +
> +	for (row = 0; row < keypad_data->rows; row++) {
> +		changed = key_state[row] ^ keypad_data->key_state[row];
> +		if (!changed)
> +			continue;
> +
> +		for (col = 0; col < keypad_data->cols; col++) {
> +			if (changed & (1 << col)) {


Looking at all too this, key state is 64 bit value, so if we make it a
bitmap and use "for_each_set_bit()" we can simplify this scanning code.

Thanks.

-- 
Dmitry



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux