Lines Matching +full:fn +full:- +full:keymap
1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (C) 2014-2015 Pali Rohár <pali@kernel.org>
22 #include <linux/input/sparse-keymap.h>
28 #include "dell-smbios.h"
29 #include "dell-wmi-descriptor.h"
30 #include "dell-wmi-privacy.h"
37 #define DELL_EVENT_GUID "9DBB5994-A997-11DA-B012-B622A1EF5492"
74 * Keymap for WMI events of type 0x0000
159 * Originally Matthew Garrett created this dell-wmi driver specially for
190 struct dell_bios_keymap_entry keymap[]; member
197 struct key_entry *keymap; member
245 * Keymap for WMI events of type 0x0010
251 /* Fn-lock switched to function keys */
254 /* Fn-lock switched to multimedia keys */
267 /* Fn-lock */
274 * Radio disable (notify only -- there is no model for which the
285 * a notification. On the XPS 13 9350, this is Fn+F7, and there's
300 * Radio disable (notify only -- there is no model for which the
305 /* Fn-lock */
310 * Keymap for WMI events of type 0x0011
343 * Keymap for WMI events of type 0x0012
350 /* Ultra-performance mode switch request */
353 /* Fn-lock button pressed */
369 __set_bit(EV_SW, (dev)->evbit); in dell_wmi_switch_event()
370 __set_bit(switchid, (dev)->swbit); in dell_wmi_switch_event()
372 (dev)->name = devname; in dell_wmi_switch_event()
373 (dev)->id.bustype = BUS_HOST; in dell_wmi_switch_event()
388 struct dell_wmi_priv *priv = dev_get_drvdata(&wdev->dev); in dell_wmi_process_key()
393 key = sparse_keymap_entry_from_scancode(priv->input_dev, in dell_wmi_process_key()
404 if ((key->keycode == KEY_BRIGHTNESSUP || in dell_wmi_process_key()
405 key->keycode == KEY_BRIGHTNESSDOWN) && in dell_wmi_process_key()
412 if (key->keycode == KEY_KBDILLUMTOGGLE) { in dell_wmi_process_key()
416 dell_wmi_switch_event(&priv->tabletswitch_dev, in dell_wmi_process_key()
425 sparse_keymap_report_entry(priv->input_dev, key, value, true); in dell_wmi_process_key()
433 struct dell_wmi_priv *priv = dev_get_drvdata(&wdev->dev); in dell_wmi_notify()
438 if (obj->type != ACPI_TYPE_BUFFER) { in dell_wmi_notify()
439 pr_warn("bad response type %x\n", obj->type); in dell_wmi_notify()
444 obj->buffer.length, obj->buffer.pointer); in dell_wmi_notify()
446 buffer_entry = (u16 *)obj->buffer.pointer; in dell_wmi_notify()
447 buffer_size = obj->buffer.length/2; in dell_wmi_notify()
462 if (priv->interface_version == 0 && buffer_entry < buffer_end) in dell_wmi_notify()
487 len - 3); in dell_wmi_notify()
496 len - i - 1); in dell_wmi_notify()
504 buffer_entry + 3, len - 3); in dell_wmi_notify()
518 static bool have_scancode(u32 scancode, const struct key_entry *keymap, int len) in have_scancode() argument
523 if (keymap[i].code == scancode) in have_scancode()
534 struct key_entry *keymap; in handle_dmi_entry() local
536 if (results->err || results->keymap) in handle_dmi_entry()
540 if (dm->type != 0xb2) in handle_dmi_entry()
545 hotkey_num = (table->header.length - in handle_dmi_entry()
550 * Historically, dell-wmi would ignore a DMI entry of in handle_dmi_entry()
559 keymap = kcalloc(hotkey_num, sizeof(struct key_entry), GFP_KERNEL); in handle_dmi_entry()
560 if (!keymap) { in handle_dmi_entry()
561 results->err = -ENOMEM; in handle_dmi_entry()
567 &table->keymap[i]; in handle_dmi_entry()
570 u16 keycode = (bios_entry->keycode < in handle_dmi_entry()
572 bios_to_linux_keycode[bios_entry->keycode] : in handle_dmi_entry()
573 (bios_entry->keycode == 0xffff ? KEY_UNKNOWN : KEY_RESERVED); in handle_dmi_entry()
582 bios_entry->scancode, bios_entry->keycode); in handle_dmi_entry()
587 keymap[pos].type = KE_IGNORE; in handle_dmi_entry()
589 keymap[pos].type = KE_KEY; in handle_dmi_entry()
590 keymap[pos].code = bios_entry->scancode; in handle_dmi_entry()
591 keymap[pos].keycode = keycode; in handle_dmi_entry()
596 results->keymap = keymap; in handle_dmi_entry()
597 results->keymap_size = pos; in handle_dmi_entry()
602 struct dell_wmi_priv *priv = dev_get_drvdata(&wdev->dev); in dell_wmi_input_setup()
604 struct key_entry *keymap; in dell_wmi_input_setup() local
607 priv->input_dev = input_allocate_device(); in dell_wmi_input_setup()
608 if (!priv->input_dev) in dell_wmi_input_setup()
609 return -ENOMEM; in dell_wmi_input_setup()
611 priv->input_dev->name = "Dell WMI hotkeys"; in dell_wmi_input_setup()
612 priv->input_dev->id.bustype = BUS_HOST; in dell_wmi_input_setup()
613 priv->input_dev->dev.parent = &wdev->dev; in dell_wmi_input_setup()
617 * Historically, dell-wmi ignored dmi_walk errors. A failure in dell_wmi_input_setup()
621 pr_warn("no DMI; using the old-style hotkey interface\n"); in dell_wmi_input_setup()
629 keymap = kcalloc(dmi_results.keymap_size + in dell_wmi_input_setup()
636 if (!keymap) { in dell_wmi_input_setup()
637 kfree(dmi_results.keymap); in dell_wmi_input_setup()
638 err = -ENOMEM; in dell_wmi_input_setup()
644 keymap[pos] = dmi_results.keymap[i]; in dell_wmi_input_setup()
645 keymap[pos].code |= (0x0010 << 16); in dell_wmi_input_setup()
649 kfree(dmi_results.keymap); in dell_wmi_input_setup()
661 have_scancode(entry->code | (0x0010 << 16), in dell_wmi_input_setup()
662 keymap, dmi_results.keymap_size) in dell_wmi_input_setup()
666 keymap[pos] = *entry; in dell_wmi_input_setup()
667 keymap[pos].code |= (0x0010 << 16); in dell_wmi_input_setup()
673 keymap[pos] = dell_wmi_keymap_type_0011[i]; in dell_wmi_input_setup()
674 keymap[pos].code |= (0x0011 << 16); in dell_wmi_input_setup()
680 keymap[pos] = dell_wmi_keymap_type_0012[i]; in dell_wmi_input_setup()
681 keymap[pos].code |= (0x0012 << 16); in dell_wmi_input_setup()
690 keymap[pos] = dell_wmi_keymap_type_0000[i]; in dell_wmi_input_setup()
694 keymap[pos].type = KE_END; in dell_wmi_input_setup()
696 err = sparse_keymap_setup(priv->input_dev, keymap, NULL); in dell_wmi_input_setup()
698 * Sparse keymap library makes a copy of keymap so we don't need the in dell_wmi_input_setup()
701 kfree(keymap); in dell_wmi_input_setup()
705 err = input_register_device(priv->input_dev); in dell_wmi_input_setup()
712 input_free_device(priv->input_dev); in dell_wmi_input_setup()
718 struct dell_wmi_priv *priv = dev_get_drvdata(&wdev->dev); in dell_wmi_input_destroy()
720 input_unregister_device(priv->input_dev); in dell_wmi_input_destroy()
721 if (priv->tabletswitch_dev) in dell_wmi_input_destroy()
722 input_unregister_device(priv->tabletswitch_dev); in dell_wmi_input_destroy()
738 * cbRes1 Standard return codes (0, -1, -2)
748 return -ENOMEM; in dell_wmi_events_set_enabled()
749 buffer->cmd_class = CLASS_INFO; in dell_wmi_events_set_enabled()
750 buffer->cmd_select = SELECT_APP_REGISTRATION; in dell_wmi_events_set_enabled()
751 buffer->input[0] = 0x10000; in dell_wmi_events_set_enabled()
752 buffer->input[1] = 0x51534554; in dell_wmi_events_set_enabled()
753 buffer->input[3] = enable; in dell_wmi_events_set_enabled()
756 ret = buffer->output[0]; in dell_wmi_events_set_enabled()
772 &wdev->dev, sizeof(struct dell_wmi_priv), GFP_KERNEL); in dell_wmi_probe()
774 return -ENOMEM; in dell_wmi_probe()
775 dev_set_drvdata(&wdev->dev, priv); in dell_wmi_probe()
777 if (!dell_wmi_get_interface_version(&priv->interface_version)) in dell_wmi_probe()
778 return -EPROBE_DEFER; in dell_wmi_probe()
794 .name = "dell-wmi",