Lines Matching +full:input +full:- +full:only
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * button.c - ACPI Button Driver
18 #include <linux/input.h>
72 /* GP-electronic T701, _LID method points to a floating GPIO */
102 * Medion Akoya E2215T, notification of the LID device only
113 * Medion Akoya E2228T, notification of the LID device only
125 * only happens on close, not on open and _LID always returns closed.
172 struct input_dev *input; member
173 char phys[32]; /* for input device */
182 static long lid_init_state = -1;
197 status = acpi_evaluate_integer(device->handle, "_LID", NULL, &lid_state); in acpi_lid_evaluate_state()
199 return -ENODEV; in acpi_lid_evaluate_state()
214 * So "last_time" is only updated after a timeout or an actual in acpi_lid_notify_state()
218 button->last_state != !!state) in acpi_lid_notify_state()
223 next_report = ktime_add(button->last_time, in acpi_lid_notify_state()
225 if (button->last_state == !!state && in acpi_lid_notify_state()
248 * But SW_LID is typed as input switch event, the input in acpi_lid_notify_state()
267 input_report_switch(button->input, in acpi_lid_notify_state()
269 input_sync(button->input); in acpi_lid_notify_state()
275 acpi_handle_debug(device->handle, "ACPI LID %s\n", in acpi_lid_notify_state()
277 input_report_switch(button->input, SW_LID, !state); in acpi_lid_notify_state()
278 input_sync(button->input); in acpi_lid_notify_state()
279 button->last_state = !!state; in acpi_lid_notify_state()
280 button->last_time = ktime_get(); in acpi_lid_notify_state()
289 struct acpi_device *device = seq->private; in acpi_button_state_seq_show()
304 /* procfs I/F for ACPI lid device only */ in acpi_button_add_fs()
305 if (button->type != ACPI_BUTTON_TYPE_LID) in acpi_button_add_fs()
310 return -EEXIST; in acpi_button_add_fs()
316 return -ENODEV; in acpi_button_add_fs()
321 ret = -ENODEV; in acpi_button_add_fs()
328 ret = -ENODEV; in acpi_button_add_fs()
337 ret = -ENODEV; in acpi_button_add_fs()
361 if (button->type != ACPI_BUTTON_TYPE_LID) in acpi_button_remove_fs()
381 return -ENODEV; in acpi_lid_open()
397 acpi_pm_wakeup_event(&device->dev); in acpi_lid_update_state()
418 button->lid_state_initialized = true; in acpi_lid_initialize_state()
427 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", in acpi_lid_notify()
433 if (!button->lid_state_initialized) in acpi_lid_notify()
443 struct input_dev *input; in acpi_button_notify() local
447 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", in acpi_button_notify()
452 acpi_pm_wakeup_event(&device->dev); in acpi_button_notify()
455 if (button->suspended) in acpi_button_notify()
458 input = button->input; in acpi_button_notify()
459 keycode = test_bit(KEY_SLEEP, input->keybit) ? KEY_SLEEP : KEY_POWER; in acpi_button_notify()
461 input_report_key(input, keycode, 1); in acpi_button_notify()
462 input_sync(input); in acpi_button_notify()
463 input_report_key(input, keycode, 0); in acpi_button_notify()
464 input_sync(input); in acpi_button_notify()
466 acpi_bus_generate_netlink_event(device->pnp.device_class, in acpi_button_notify()
467 dev_name(&device->dev), in acpi_button_notify()
468 event, ++button->pushed); in acpi_button_notify()
488 button->suspended = true; in acpi_button_suspend()
494 struct input_dev *input; in acpi_button_resume() local
498 button->suspended = false; in acpi_button_resume()
499 if (button->type == ACPI_BUTTON_TYPE_LID) { in acpi_button_resume()
500 button->last_state = !!acpi_lid_evaluate_state(device); in acpi_button_resume()
501 button->last_time = ktime_get(); in acpi_button_resume()
505 if (button->type == ACPI_BUTTON_TYPE_POWER) { in acpi_button_resume()
506 input = button->input; in acpi_button_resume()
507 input_report_key(input, KEY_WAKEUP, 1); in acpi_button_resume()
508 input_sync(input); in acpi_button_resume()
509 input_report_key(input, KEY_WAKEUP, 0); in acpi_button_resume()
510 input_sync(input); in acpi_button_resume()
516 static int acpi_lid_input_open(struct input_dev *input) in acpi_lid_input_open() argument
518 struct acpi_device *device = input_get_drvdata(input); in acpi_lid_input_open()
521 button->last_state = !!acpi_lid_evaluate_state(device); in acpi_lid_input_open()
522 button->last_time = ktime_get(); in acpi_lid_input_open()
532 struct input_dev *input; in acpi_button_add() local
540 return -ENODEV; in acpi_button_add()
544 return -ENOMEM; in acpi_button_add()
546 device->driver_data = button; in acpi_button_add()
548 button->input = input = input_allocate_device(); in acpi_button_add()
549 if (!input) { in acpi_button_add()
550 error = -ENOMEM; in acpi_button_add()
559 button->type = ACPI_BUTTON_TYPE_POWER; in acpi_button_add()
566 button->type = ACPI_BUTTON_TYPE_SLEEP; in acpi_button_add()
572 button->type = ACPI_BUTTON_TYPE_LID; in acpi_button_add()
577 input->open = acpi_lid_input_open; in acpi_button_add()
580 error = -ENODEV; in acpi_button_add()
587 input_free_device(input); in acpi_button_add()
591 snprintf(button->phys, sizeof(button->phys), "%s/button/input0", hid); in acpi_button_add()
593 input->name = name; in acpi_button_add()
594 input->phys = button->phys; in acpi_button_add()
595 input->id.bustype = BUS_HOST; in acpi_button_add()
596 input->id.product = button->type; in acpi_button_add()
597 input->dev.parent = &device->dev; in acpi_button_add()
599 switch (button->type) { in acpi_button_add()
601 input_set_capability(input, EV_KEY, KEY_POWER); in acpi_button_add()
602 input_set_capability(input, EV_KEY, KEY_WAKEUP); in acpi_button_add()
606 input_set_capability(input, EV_KEY, KEY_SLEEP); in acpi_button_add()
610 input_set_capability(input, EV_SW, SW_LID); in acpi_button_add()
614 input_set_drvdata(input, device); in acpi_button_add()
615 error = input_register_device(input); in acpi_button_add()
619 switch (device->device_type) { in acpi_button_add()
631 status = acpi_install_notify_handler(device->handle, in acpi_button_add()
637 error = -ENODEV; in acpi_button_add()
641 if (button->type == ACPI_BUTTON_TYPE_LID) { in acpi_button_add()
643 * This assumes there's only one lid device, or if there are in acpi_button_add()
644 * more we only care about the last one... in acpi_button_add()
649 device_init_wakeup(&device->dev, true); in acpi_button_add()
654 input_unregister_device(input); in acpi_button_add()
666 switch (device->device_type) { in acpi_button_remove()
676 acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, in acpi_button_remove()
677 button->type == ACPI_BUTTON_TYPE_LID ? in acpi_button_remove()
685 input_unregister_device(button->input); in acpi_button_remove()
713 buf[c - 1] = '\n'; /* Replace the final space with a newline */ in param_get_lid_init_state()
727 if (lid_init_state == -1) { in acpi_button_register_driver()
730 lid_init_state = (long)dmi_id->driver_data; in acpi_button_register_driver()
738 * capable kernels booted in non-ACPI mode if the return value of in acpi_button_register_driver()