All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anisse Astier <anisse@astier.eu>
To: Maxim Mikityanskiy <maxtram95@gmail.com>
Cc: platform-driver-x86@vger.kernel.org, jlee@suse.com
Subject: Re: [PATCH v4 11/12] msi-wmi: Introduced quirk_last_pressed
Date: Thu, 20 Dec 2012 18:02:20 +0100	[thread overview]
Message-ID: <20121220180220.627277d2@destiny.ordissimo> (raw)
In-Reply-To: <1355592696-15454-12-git-send-email-maxtram95@gmail.com>

On Sat, 15 Dec 2012 19:31:35 +0200, Maxim Mikityanskiy <maxtram95@gmail.com> wrote :

> Introduced quirk_last_pressed variable that would indicate if
> last_pressed is used or not. Also converted last_pressed to simple
> variable in order to allow keymap to be non-contiguous.
> 
> Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
Acked-by: Anisse Astier <anisse@astier.eu>
> ---
>  drivers/platform/x86/msi-wmi.c | 54 ++++++++++++++++++++++--------------------
>  1 file changed, 28 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
> index 3a60619..739bd4d 100644
> --- a/drivers/platform/x86/msi-wmi.c
> +++ b/drivers/platform/x86/msi-wmi.c
> @@ -43,8 +43,7 @@ MODULE_ALIAS("wmi:" MSIWMI_BIOS_GUID);
>  MODULE_ALIAS("wmi:" MSIWMI_EVENT_GUID);
>  
>  enum msi_scancodes {
> -	MSI_SCANCODE_BASE	= 0xD0,
> -	MSI_KEY_BRIGHTNESSUP	= MSI_SCANCODE_BASE,
> +	MSI_KEY_BRIGHTNESSUP	= 0xD0,
>  	MSI_KEY_BRIGHTNESSDOWN,
>  	MSI_KEY_VOLUMEUP,
>  	MSI_KEY_VOLUMEDOWN,
> @@ -58,7 +57,9 @@ static struct key_entry msi_wmi_keymap[] = {
>  	{ KE_KEY, MSI_KEY_MUTE,			{KEY_MUTE} },
>  	{ KE_END, 0 }
>  };
> -static ktime_t last_pressed[ARRAY_SIZE(msi_wmi_keymap) - 1];
> +
> +static ktime_t last_pressed;
> +static bool quirk_last_pressed;
>  
>  static const char *event_wmi_guid;
>  
> @@ -153,7 +154,6 @@ static void msi_wmi_notify(u32 value, void *context)
>  	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
>  	static struct key_entry *key;
>  	union acpi_object *obj;
> -	ktime_t cur;
>  	acpi_status status;
>  
>  	status = wmi_get_event_data(value, &response);
> @@ -169,12 +169,15 @@ static void msi_wmi_notify(u32 value, void *context)
>  		pr_debug("Eventcode: 0x%x\n", eventcode);
>  		key = sparse_keymap_entry_from_scancode(msi_wmi_input_dev,
>  				eventcode);
> -		if (key) {
> -			ktime_t diff;
> -			cur = ktime_get_real();
> -			diff = ktime_sub(cur, last_pressed[key->code -
> -					MSI_SCANCODE_BASE]);
> -			/* Ignore event if the same event happened in a 50 ms
> +		if (!key) {
> +			pr_info("Unknown key pressed - %x\n", eventcode);
> +			goto msi_wmi_notify_exit;
> +		}
> +
> +		if (quirk_last_pressed) {
> +			ktime_t cur = ktime_get_real();
> +			ktime_t diff = ktime_sub(cur, last_pressed);
> +			/* Ignore event if any event happened in a 50 ms
>  			   timeframe -> Key press may result in 10-20 GPEs */
>  			if (ktime_to_us(diff) < 1000 * 50) {
>  				pr_debug("Suppressed key event 0x%X - "
> @@ -182,21 +185,19 @@ static void msi_wmi_notify(u32 value, void *context)
>  					 key->code, ktime_to_us(diff));
>  				goto msi_wmi_notify_exit;
>  			}
> -			last_pressed[key->code - MSI_SCANCODE_BASE] = cur;
> -
> -			if (key->type == KE_KEY &&
> -			/* Brightness is served via acpi video driver */
> -			(backlight ||
> -			(key->code != MSI_KEY_BRIGHTNESSUP &&
> -			key->code != MSI_KEY_BRIGHTNESSDOWN))) {
> -				pr_debug("Send key: 0x%X - "
> -					 "Input layer keycode: %d\n",
> -					 key->code, key->keycode);
> -				sparse_keymap_report_entry(msi_wmi_input_dev,
> -						key, 1, true);
> -			}
> -		} else
> -			pr_info("Unknown key pressed - %x\n", eventcode);
> +			last_pressed = cur;
> +		}
> +
> +		if (key->type == KE_KEY &&
> +		/* Brightness is served via acpi video driver */
> +		(backlight ||
> +		(key->code != MSI_KEY_BRIGHTNESSUP &&
> +		key->code != MSI_KEY_BRIGHTNESSDOWN))) {
> +			pr_debug("Send key: 0x%X - Input layer keycode: %d\n",
> +				 key->code, key->keycode);
> +			sparse_keymap_report_entry(msi_wmi_input_dev, key, 1,
> +						   true);
> +		}
>  	} else
>  		pr_info("Unknown event received\n");
>  
> @@ -250,7 +251,7 @@ static int __init msi_wmi_input_setup(void)
>  	if (err)
>  		goto err_free_keymap;
>  
> -	memset(last_pressed, 0, sizeof(last_pressed));
> +	last_pressed = ktime_set(0, 0);
>  
>  	return 0;
>  
> @@ -281,6 +282,7 @@ static int __init msi_wmi_init(void)
>  
>  		pr_debug("Event handler installed\n");
>  		event_wmi_guid = MSIWMI_EVENT_GUID;
> +		quirk_last_pressed = true;
>  	}
>  
>  	if (wmi_has_guid(MSIWMI_BIOS_GUID) && !acpi_video_backlight_support()) {

  parent reply	other threads:[~2012-12-20 17:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-15 17:31 [PATCH v4 00/12] Add MSI Wind U90/U100 support Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 01/12] msi-laptop: Use proper return codes instead of -1 Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 02/12] msi-laptop: Work around gcc warning Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 03/12] msi-laptop: merge quirk tables to one Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 04/12] msi-laptop: Add MSI Wind U90/U100 support Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 05/12] msi-laptop: Add missing ABI documentation Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 06/12] msi-laptop: Disable brightness control for new EC Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 07/12] msi-wmi: Fix memory leak Maxim Mikityanskiy
2012-12-15 17:31 ` [PATCH v4 08/12] msi-wmi: Avoid repeating constants Maxim Mikityanskiy
2012-12-20 16:59   ` Anisse Astier
2012-12-15 17:31 ` [PATCH v4 09/12] msi-wmi: Use enums for scancodes Maxim Mikityanskiy
2012-12-20 17:01   ` Anisse Astier
2012-12-15 17:31 ` [PATCH v4 10/12] msi-wmi: Make keys and backlight independent Maxim Mikityanskiy
2012-12-17  9:04   ` joeyli
2012-12-20 17:01   ` Anisse Astier
2012-12-15 17:31 ` [PATCH v4 11/12] msi-wmi: Introduced quirk_last_pressed Maxim Mikityanskiy
2012-12-17  9:56   ` joeyli
2012-12-20 17:02   ` Anisse Astier [this message]
2012-12-15 17:31 ` [PATCH v4 12/12] msi-wmi: Add MSI Wind support Maxim Mikityanskiy
2012-12-17 10:00   ` joeyli
2012-12-20 17:02   ` Anisse Astier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121220180220.627277d2@destiny.ordissimo \
    --to=anisse@astier.eu \
    --cc=jlee@suse.com \
    --cc=maxtram95@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.