Lines Matching +full:button +full:-
1 // SPDX-License-Identifier: GPL-2.0+
3 * Intel HID event & 5 button array driver
12 #include <linux/input/sparse-keymap.h>
20 TABLET_SW_AUTO = -1,
29 "Enable 5 Button Array support. "
30 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
35 "Enable SW_TABLET_MODE reporting -1:auto 0:off 1:at-first-event 2:at-probe. "
36 "If you need this please report this to: platform-driver-x86@vger.kernel.org");
58 /* 1: LSuper (Page 0x07, usage 0xE3) -- unclear what to do */
59 /* 2: Toggle SW_ROTATE_LOCK -- easy to implement if seen in wild */
68 /* 13 has two different meanings in the spec -- ignore it. */
76 /* 27: wake -- needs special handling */
80 /* 5 button array notification value. */
135 * Some convertible use the intel-hid ACPI interface to report SW_TABLET_MODE,
144 DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible 15-df0xxx"),
187 #define HID_EVENT_FILTER_UUID "eeec56b3-4442-408f-a792-4edd4d758054"
281 *result = obj->integer.value; in intel_hid_evaluate_method()
306 switch (obj->buffer.length) { in intel_hid_init_dsm()
309 intel_hid_dsm_fn_mask = *(u16 *)obj->buffer.pointer; in intel_hid_init_dsm()
312 intel_hid_dsm_fn_mask = *obj->buffer.pointer; in intel_hid_init_dsm()
330 /* Enable|disable features - power button is always enabled */ in intel_hid_set_enable()
335 return -EIO; in intel_hid_set_enable()
348 if (!priv->array) in intel_button_array_enable()
354 dev_warn(device, "failed to get button capability\n"); in intel_button_array_enable()
358 /* Enable|disable features - power button is always enabled */ in intel_button_array_enable()
361 dev_warn(device, "failed to set button capability\n"); in intel_button_array_enable()
369 priv->wakeup_mode = true; in intel_hid_pm_prepare()
378 priv->wakeup_mode = false; in intel_hid_pm_complete()
414 struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); in intel_hid_input_setup()
417 priv->input_dev = devm_input_allocate_device(&device->dev); in intel_hid_input_setup()
418 if (!priv->input_dev) in intel_hid_input_setup()
419 return -ENOMEM; in intel_hid_input_setup()
421 ret = sparse_keymap_setup(priv->input_dev, intel_hid_keymap, NULL); in intel_hid_input_setup()
425 priv->input_dev->name = "Intel HID events"; in intel_hid_input_setup()
426 priv->input_dev->id.bustype = BUS_HOST; in intel_hid_input_setup()
428 return input_register_device(priv->input_dev); in intel_hid_input_setup()
433 struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); in intel_button_array_input_setup()
436 /* Setup input device for 5 button array */ in intel_button_array_input_setup()
437 priv->array = devm_input_allocate_device(&device->dev); in intel_button_array_input_setup()
438 if (!priv->array) in intel_button_array_input_setup()
439 return -ENOMEM; in intel_button_array_input_setup()
441 ret = sparse_keymap_setup(priv->array, intel_array_keymap, NULL); in intel_button_array_input_setup()
445 priv->array->name = "Intel HID 5 button array"; in intel_button_array_input_setup()
446 priv->array->id.bustype = BUS_HOST; in intel_button_array_input_setup()
448 return input_register_device(priv->array); in intel_button_array_input_setup()
453 struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); in intel_hid_switches_setup()
456 priv->switches = devm_input_allocate_device(&device->dev); in intel_hid_switches_setup()
457 if (!priv->switches) in intel_hid_switches_setup()
458 return -ENOMEM; in intel_hid_switches_setup()
460 __set_bit(EV_SW, priv->switches->evbit); in intel_hid_switches_setup()
461 __set_bit(SW_TABLET_MODE, priv->switches->swbit); in intel_hid_switches_setup()
463 priv->switches->name = "Intel HID switches"; in intel_hid_switches_setup()
464 priv->switches->id.bustype = BUS_HOST; in intel_hid_switches_setup()
465 return input_register_device(priv->switches); in intel_hid_switches_setup()
470 struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); in report_tablet_mode_state()
471 acpi_handle handle = ACPI_HANDLE(&device->dev); in report_tablet_mode_state()
479 input_report_switch(priv->switches, SW_TABLET_MODE, m); in report_tablet_mode_state()
480 input_sync(priv->switches); in report_tablet_mode_state()
505 struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); in notify_handler()
514 if (!priv->switches && enable_sw_tablet_mode == TABLET_SW_AT_EVENT && in notify_handler()
516 dev_info(&device->dev, "switch event received, enable switches supports\n"); in notify_handler()
522 if (priv->wakeup_mode) { in notify_handler()
524 * Needed for wakeup from suspend-to-idle to work on some in notify_handler()
525 * platforms that don't expose the 5-button array, but still in notify_handler()
526 * send notifies with the power button event code to this in notify_handler()
527 * device object on power button actions while suspended. in notify_handler()
533 * Some devices send (duplicate) tablet-mode events when moved in notify_handler()
540 report_tablet_mode_event(priv->switches, event); in notify_handler()
544 /* Wake up on 5-button array events only. */ in notify_handler()
545 if (event == 0xc0 || !priv->array) in notify_handler()
548 if (!sparse_keymap_entry_from_scancode(priv->array, event)) { in notify_handler()
549 dev_info(&device->dev, "unknown event 0x%x\n", event); in notify_handler()
554 pm_wakeup_hard_event(&device->dev); in notify_handler()
561 * the 5-button array, but still send notifies with power button in notify_handler()
562 * event code to this device object on power button actions. in notify_handler()
564 * Report the power button press and release. in notify_handler()
566 if (!priv->array) { in notify_handler()
568 input_report_key(priv->input_dev, KEY_POWER, 1); in notify_handler()
569 input_sync(priv->input_dev); in notify_handler()
574 input_report_key(priv->input_dev, KEY_POWER, 0); in notify_handler()
575 input_sync(priv->input_dev); in notify_handler()
580 if (report_tablet_mode_event(priv->switches, event)) in notify_handler()
583 /* 0xC0 is for HID events, other values are for 5 button array */ in notify_handler()
585 if (!priv->array || in notify_handler()
586 !sparse_keymap_report_event(priv->array, event, 1, true)) in notify_handler()
587 dev_dbg(&device->dev, "unknown event 0x%x\n", event); in notify_handler()
593 dev_warn(&device->dev, "failed to get event index\n"); in notify_handler()
597 if (!sparse_keymap_report_event(priv->input_dev, ev_index, 1, true)) in notify_handler()
598 dev_dbg(&device->dev, "unknown event index 0x%llx\n", in notify_handler()
604 acpi_handle handle = ACPI_HANDLE(&device->dev); in button_array_present()
609 /* Check presence of 5 button array or v2 power button */ in button_array_present()
628 acpi_handle handle = ACPI_HANDLE(&device->dev); in intel_hid_probe()
637 dev_warn(&device->dev, "failed to read mode\n"); in intel_hid_probe()
638 return -ENODEV; in intel_hid_probe()
647 dev_info(&device->dev, "platform is not in simple mode\n"); in intel_hid_probe()
648 return -ENODEV; in intel_hid_probe()
651 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); in intel_hid_probe()
653 return -ENOMEM; in intel_hid_probe()
654 dev_set_drvdata(&device->dev, priv); in intel_hid_probe()
672 /* Setup 5 button array */ in intel_hid_probe()
674 dev_info(&device->dev, "platform supports 5 button array\n"); in intel_hid_probe()
677 pr_err("Failed to setup Intel 5 button array hotkeys\n"); in intel_hid_probe()
682 dev_info(&device->dev, "platform supports switches\n"); in intel_hid_probe()
695 return -EBUSY; in intel_hid_probe()
697 err = intel_hid_set_enable(&device->dev, true); in intel_hid_probe()
701 intel_button_array_enable(&device->dev, true); in intel_hid_probe()
704 * Call button load method to enable HID power button in intel_hid_probe()
706 * a button array too. in intel_hid_probe()
709 dev_warn(&device->dev, "failed to enable HID power button\n"); in intel_hid_probe()
711 device_init_wakeup(&device->dev, true); in intel_hid_probe()
728 acpi_handle handle = ACPI_HANDLE(&device->dev); in intel_hid_remove()
730 device_init_wakeup(&device->dev, false); in intel_hid_remove()
732 intel_hid_set_enable(&device->dev, false); in intel_hid_remove()
733 intel_button_array_enable(&device->dev, false); in intel_hid_remove()
738 .name = "intel-hid",
765 dev_info(&dev->dev, in check_acpi_dev()
766 "intel-hid: created platform device\n"); in check_acpi_dev()