linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali.rohar@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Matthew Garrett <mjg59@srcf.ucam.org>
Cc: linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	linux-hotplug@vger.kernel.org, "Matthew Garrett" <mjg@redhat.com>,
	linux-kernel@vger.kernel.org, "Pali Rohár" <pali.rohar@gmail.com>
Subject: [PATCH 2/2] dell-wmi: Add support for Fn key combinations
Date: Sat, 17 May 2014 16:43:37 +0200	[thread overview]
Message-ID: <1400337817-14473-3-git-send-email-pali.rohar@gmail.com> (raw)
In-Reply-To: <1400337817-14473-1-git-send-email-pali.rohar@gmail.com>

Bios DMI table contains scancodes for some Fn key combinations. But
corresponding keycodes in DMI table have same value 255. And dell-wmi driver
map value 255 to KEY_PROG3. This means that it is not possible to distinguish
between Fn key combinations (e.g Fn+Q and Fn+W), because kernel reports for all
of them only KEY_PROG3.

This patch adding new table for mapping Bios DMI scancodes to linux keycodes
when bios DMI keycode is set to "generic" keycode 255. So different Fn key
combinations will have different keycodes.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 drivers/platform/x86/dell-wmi.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
index 390e8e3..c54d675 100644
--- a/drivers/platform/x86/dell-wmi.c
+++ b/drivers/platform/x86/dell-wmi.c
@@ -140,7 +140,27 @@ static const u16 bios_to_linux_keycode[256] __initconst = {
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 -212,6 +232,11 @@ static const struct key_entry * __init dell_wmi_prepare_new_keymap(void)
 		keymap[i].keycode = bios_entry->keycode < 256 ?
 				    bios_to_linux_keycode[bios_entry->keycode] :
 				    KEY_RESERVED;
+		if (bios_entry->keycode == 255 && bios_entry->scancode < 256)
+			keymap[i].keycode =
+				scancode_to_linux_keycode[bios_entry->scancode];
+		if (!keymap[i].keycode)
+			keymap[i].keycode = KEY_RESERVED;
 	}
 
 	keymap[hotkey_num].type = KE_END;
-- 
1.7.9.5

      parent reply	other threads:[~2014-05-17 14:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201405171639.45722@pali>
2014-05-17 14:43 ` [PATCH 0/2] dell-wmi: Add support for Fn key combinations Pali Rohár
2014-05-17 14:43   ` [PATCH 1/2] Input: Add keycodes for some missing " Pali Rohár
2014-05-17 20:30     ` Dmitry Torokhov
2014-05-17 20:38       ` Pali Rohár
2014-05-17 21:32         ` Dmitry Torokhov
2014-05-17 14:43   ` Pali Rohár [this message]

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=1400337817-14473-3-git-send-email-pali.rohar@gmail.com \
    --to=pali.rohar@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-hotplug@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=mjg@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).