From: "Pali Rohár" <pali.rohar@gmail.com>
To: Andy Lutomirski <luto@kernel.org>
Cc: platform-driver-x86@vger.kernel.org,
Matthew Garrett <mjg59@srcf.ucam.org>
Subject: Re: [PATCH 1/3] dell_wmi: Support new hotkeys on the XPS 13 Skylake
Date: Sat, 14 Nov 2015 10:27:04 +0100 [thread overview]
Message-ID: <20151114092704.GA25957@pali> (raw)
In-Reply-To: <db83b63cc163ecc640d5d1c5554f8aa87beaadfc.1447479930.git.luto@kernel.org>
On Friday 13 November 2015 21:49:30 Andy Lutomirski wrote:
> The XPS 13 Skylake has an rfkill button and a switchvideomode button
> that aren't enumerated in the DMI table AFAICT. Add a table listing
> extra un-enumerated hotkeys. To avoid breaking things that worked
> before, these un-enumerated hotkeys won't be used if the DMI table
> maps them to something else.
>
Do you have any (Dell) documentation which specify list of these wmi
codes send to dell-wmi driver?
> This also adds the Fn-lock key as a KE_IGNORE entry.
>
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
> drivers/platform/x86/dell-wmi.c | 48 +++++++++++++++++++++++++++++++++++------
> 1 file changed, 41 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c
> index f2d77fe696ac..5be1abec4f64 100644
> --- a/drivers/platform/x86/dell-wmi.c
> +++ b/drivers/platform/x86/dell-wmi.c
> @@ -142,6 +142,16 @@ static const u16 bios_to_linux_keycode[256] __initconst = {
> 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_PROG3
> };
>
> +/* These are applied if the hk table is present and doesn't override them. */
> +static const struct key_entry dell_wmi_extra_keymap[] __initconst = {
> + /* Fn-lock -- no action is required by the kernel. */
> + { KE_IGNORE, 0x151, { KEY_RESERVED } },
> +
> + /* Keys that need our help (on XPS 13 Skylake and maybe others. */
> + { KE_KEY, 0x152, { KEY_SWITCHVIDEOMODE } },
> + { KE_KEY, 0x153, { KEY_RFKILL } },
On more Dell laptops rfkill events are handed by ACPI driver
dell-rbtn.ko. Are you sure that dell-rbtn.ko does not send keypress
event and you really need it from dell-wmi? We already masked KEY_RFKILL
in dell-wmi to prevent double events...
> +};
> +
> static struct input_dev *dell_wmi_input_dev;
>
> static void dell_wmi_process_key(int reported_key)
> @@ -300,9 +310,10 @@ static const struct key_entry * __init dell_wmi_prepare_new_keymap(void)
> int hotkey_num = (dell_bios_hotkey_table->header.length - 4) /
> sizeof(struct dell_bios_keymap_entry);
> struct key_entry *keymap;
> - int i;
> + int i, pos = 0, num_bios_keys;
>
> - keymap = kcalloc(hotkey_num + 1, sizeof(struct key_entry), GFP_KERNEL);
> + keymap = kcalloc(hotkey_num + ARRAY_SIZE(dell_wmi_extra_keymap),
> + sizeof(struct key_entry), GFP_KERNEL);
> if (!keymap)
> return NULL;
>
> @@ -314,14 +325,37 @@ static const struct key_entry * __init dell_wmi_prepare_new_keymap(void)
> KEY_RESERVED;
>
> if (keycode == KEY_KBDILLUMTOGGLE)
> - keymap[i].type = KE_IGNORE;
> + keymap[pos].type = KE_IGNORE;
> else
> - keymap[i].type = KE_KEY;
> - keymap[i].code = bios_entry->scancode;
> - keymap[i].keycode = keycode;
> + keymap[pos].type = KE_KEY;
> + keymap[pos].code = bios_entry->scancode;
> + keymap[pos].keycode = keycode;
> +
> + pos++;
> + }
> +
> + num_bios_keys = pos;
> +
> + for (i = 0; i < ARRAY_SIZE(dell_wmi_extra_keymap); i++) {
> + int j;
> +
> + /*
> + * Check if we've already found this scancode. This takes
> + * quadratic time, but it doesn't matter unless the list
> + * of extra keys gets very long.
> + */
> + for (j = 0; j < num_bios_keys; j++)
> + if (keymap[j].code == dell_wmi_extra_keymap[i].code)
> + goto skip;
Rather move this code into separate boolean function and for return
value here. This will prevent using hacky goto...
> +
> + keymap[pos] = dell_wmi_extra_keymap[i];
> + pos++;
> +
> +skip:
> + ;
> }
>
> - keymap[hotkey_num].type = KE_END;
> + keymap[pos].type = KE_END;
>
> return keymap;
> }
--
Pali Rohár
pali.rohar@gmail.com
next prev parent reply other threads:[~2015-11-14 9:27 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-14 5:49 [PATCH 0/3] dell_wmi: XPS 13 Skylake support and misc stuff Andy Lutomirski
2015-11-14 5:49 ` [PATCH 1/3] dell_wmi: Support new hotkeys on the XPS 13 Skylake Andy Lutomirski
2015-11-14 9:27 ` Pali Rohár [this message]
2015-11-14 15:48 ` Andy Lutomirski
2015-11-14 16:13 ` Pali Rohár
[not found] ` <CALCETrWss=zCWhNkR2S_oi_m3W1xNO+UL_-uOnOVeLh5WHsDgQ@mail.gmail.com>
2015-11-17 8:36 ` Pali Rohár
2015-11-17 19:03 ` Andy Lutomirski
2015-11-18 3:44 ` Andy Lutomirski
2015-11-18 21:24 ` Andy Lutomirski
2015-11-19 8:19 ` Pali Rohár
2015-11-21 0:06 ` Darren Hart
2015-11-21 0:11 ` Pali Rohár
2015-11-21 0:12 ` Andy Lutomirski
2015-11-22 2:04 ` D. Jared Dominguez
2015-11-23 14:53 ` Pali Rohár
2016-01-21 10:17 ` Pali Rohár
2016-01-22 0:08 ` Mario Limonciello
2016-01-22 0:13 ` Andy Lutomirski
2016-01-22 8:26 ` Pali Rohár
2016-01-22 15:58 ` Mario Limonciello
2016-01-22 17:11 ` Pali Rohár
2015-11-14 5:49 ` [PATCH 2/3] dell_wmi: Use a C99-style array for bios_to_linux_keycode Andy Lutomirski
2015-11-14 9:30 ` Pali Rohár
2015-11-21 0:09 ` Darren Hart
2015-11-21 0:20 ` Pali Rohár
2015-11-21 0:26 ` Darren Hart
2015-11-21 0:28 ` Andy Lutomirski
2015-11-14 5:49 ` [PATCH 3/3] dell_wmi: Improve unknown hotkey handling Andy Lutomirski
2015-11-14 9:33 ` Pali Rohár
2015-11-17 1:35 ` Andy Lutomirski
2015-11-21 0:29 ` Darren Hart
2015-11-21 0:34 ` Andy Lutomirski
2015-11-21 0:41 ` Pali Rohár
2015-11-21 0:44 ` Andy Lutomirski
2015-11-21 0:14 ` Darren Hart
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=20151114092704.GA25957@pali \
--to=pali.rohar@gmail.com \
--cc=luto@kernel.org \
--cc=mjg59@srcf.ucam.org \
--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