Lines Matching +full:button +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * button.c - ACPI Button Driver
9 #define pr_fmt(fmt) "ACPI: button: " fmt
22 #include <acpi/button.h>
24 #define ACPI_BUTTON_CLASS "button"
30 #define ACPI_BUTTON_DEVICE_NAME_POWER "Power Button"
34 #define ACPI_BUTTON_DEVICE_NAME_SLEEP "Sleep Button"
56 MODULE_DESCRIPTION("ACPI Button Driver");
72 /* GP-electronic T701, _LID method points to a floating GPIO */
160 .name = "button",
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()
206 struct acpi_button *button = acpi_driver_data(device); in acpi_lid_notify_state() local
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()
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()
300 struct acpi_button *button = acpi_driver_data(device); in acpi_button_add_fs() local
305 if (button->type != ACPI_BUTTON_TYPE_LID) in acpi_button_add_fs()
310 return -EEXIST; in acpi_button_add_fs()
313 /* create /proc/acpi/button */ in acpi_button_add_fs()
316 return -ENODEV; in acpi_button_add_fs()
318 /* create /proc/acpi/button/lid */ in acpi_button_add_fs()
321 ret = -ENODEV; in acpi_button_add_fs()
325 /* create /proc/acpi/button/lid/LID/ */ in acpi_button_add_fs()
328 ret = -ENODEV; in acpi_button_add_fs()
332 /* create /proc/acpi/button/lid/LID/state */ in acpi_button_add_fs()
337 ret = -ENODEV; in acpi_button_add_fs()
359 struct acpi_button *button = acpi_driver_data(device); in acpi_button_remove_fs() local
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()
404 struct acpi_button *button = acpi_driver_data(device); in acpi_lid_initialize_state() local
418 button->lid_state_initialized = true; in acpi_lid_initialize_state()
424 struct acpi_button *button; in acpi_lid_notify() local
427 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", in acpi_lid_notify()
432 button = acpi_driver_data(device); in acpi_lid_notify()
433 if (!button->lid_state_initialized) in acpi_lid_notify()
442 struct acpi_button *button; 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()
454 button = acpi_driver_data(device); 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()
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()
486 struct acpi_button *button = acpi_driver_data(device); in acpi_button_suspend() local
488 button->suspended = true; in acpi_button_suspend()
496 struct acpi_button *button = acpi_driver_data(device); 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()
519 struct acpi_button *button = acpi_driver_data(device); in acpi_lid_input_open() local
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()
531 struct acpi_button *button; in acpi_button_add() local
540 return -ENODEV; in acpi_button_add()
542 button = kzalloc(sizeof(struct acpi_button), GFP_KERNEL); in acpi_button_add()
543 if (!button) 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()
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()
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()
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()
649 device_init_wakeup(&device->dev, true); in acpi_button_add()
658 kfree(button); in acpi_button_add()
664 struct acpi_button *button = acpi_driver_data(device); in acpi_button_remove() local
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()
686 kfree(button); 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()