Lines Matching +full:push +full:- +full:button

1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*-*-linux-c-*-*/
10 Adrian Yee <brewt-fujitsu@brewt.org>
12 Templated from msi-laptop.c and thinkpad_acpi.c which is copyright
18 * fujitsu-laptop.c - Fujitsu laptop support, providing access to additional
22 * This driver implements a vendor-specific backlight control interface for
27 * P8010. It should work on most P-series and S-series Lifebooks, but
48 #include <linux/input/sparse-keymap.h>
68 /* FUNC interface - command values */
74 /* FUNC interface - responses */
77 /* FUNC interface - status flags */
85 /* FUNC interface - LED control */
95 /* FUNC interface - backlight power control */
112 static int use_alt_lcd_levels = -1;
154 status = acpi_evaluate_integer(device->handle, "FUNC", &arg_list, in call_fext_func()
157 acpi_handle_err(device->handle, "Failed to evaluate FUNC\n"); in call_fext_func()
158 return -ENODEV; in call_fext_func()
161 acpi_handle_debug(device->handle, in call_fext_func()
176 case -1: in set_lcd_level()
177 if (acpi_has_method(device->handle, "SBL2")) in set_lcd_level()
190 acpi_handle_debug(device->handle, "set lcd level via %s [%d]\n", method, in set_lcd_level()
193 if (level < 0 || level >= priv->max_brightness) in set_lcd_level()
194 return -EINVAL; in set_lcd_level()
196 status = acpi_execute_simple_method(device->handle, method, level); in set_lcd_level()
198 acpi_handle_err(device->handle, "Failed to evaluate %s\n", in set_lcd_level()
200 return -ENODEV; in set_lcd_level()
203 priv->brightness_level = level; in set_lcd_level()
214 acpi_handle_debug(device->handle, "get lcd level via GBLL\n"); in get_lcd_level()
216 status = acpi_evaluate_integer(device->handle, "GBLL", NULL, &state); in get_lcd_level()
220 priv->brightness_level = state & 0x0fffffff; in get_lcd_level()
222 return priv->brightness_level; in get_lcd_level()
231 acpi_handle_debug(device->handle, "get max lcd level via RBLL\n"); in get_max_brightness()
233 status = acpi_evaluate_integer(device->handle, "RBLL", NULL, &state); in get_max_brightness()
235 return -1; in get_max_brightness()
237 priv->max_brightness = state; in get_max_brightness()
239 return priv->max_brightness; in get_max_brightness()
248 return b->props.power == FB_BLANK_POWERDOWN ? 0 : get_lcd_level(device); in bl_get_brightness()
256 if (b->props.power == FB_BLANK_POWERDOWN) in bl_update_status()
264 return set_lcd_level(device, b->props.brightness); in bl_update_status()
277 if (!(priv->flags_supported & FLAG_LID)) in lid_show()
279 if (priv->flags_state & FLAG_LID) in lid_show()
290 if (!(priv->flags_supported & FLAG_DOCK)) in dock_show()
292 if (priv->flags_state & FLAG_DOCK) in dock_show()
303 if (!(priv->flags_supported & FLAG_RFKILL)) in radios_show()
305 if (priv->flags_state & FLAG_RFKILL) in radios_show()
328 .name = "fujitsu-laptop",
345 priv->input = devm_input_allocate_device(&device->dev); in acpi_fujitsu_bl_input_setup()
346 if (!priv->input) in acpi_fujitsu_bl_input_setup()
347 return -ENOMEM; in acpi_fujitsu_bl_input_setup()
349 snprintf(priv->phys, sizeof(priv->phys), "%s/video/input0", in acpi_fujitsu_bl_input_setup()
352 priv->input->name = acpi_device_name(device); in acpi_fujitsu_bl_input_setup()
353 priv->input->phys = priv->phys; in acpi_fujitsu_bl_input_setup()
354 priv->input->id.bustype = BUS_HOST; in acpi_fujitsu_bl_input_setup()
355 priv->input->id.product = 0x06; in acpi_fujitsu_bl_input_setup()
357 ret = sparse_keymap_setup(priv->input, keymap_backlight, NULL); in acpi_fujitsu_bl_input_setup()
361 return input_register_device(priv->input); in acpi_fujitsu_bl_input_setup()
368 .brightness = priv->brightness_level, in fujitsu_backlight_register()
369 .max_brightness = priv->max_brightness - 1, in fujitsu_backlight_register()
374 bd = devm_backlight_device_register(&device->dev, "fujitsu-laptop", in fujitsu_backlight_register()
375 &device->dev, device, in fujitsu_backlight_register()
380 priv->bl_device = bd; in fujitsu_backlight_register()
391 return -ENODEV; in acpi_fujitsu_bl_add()
393 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); in acpi_fujitsu_bl_add()
395 return -ENOMEM; in acpi_fujitsu_bl_add()
400 device->driver_data = priv; in acpi_fujitsu_bl_add()
406 priv->max_brightness = FUJITSU_LCD_N_LEVELS; in acpi_fujitsu_bl_add()
424 acpi_handle_info(device->handle, "unsupported event [0x%x]\n", in acpi_fujitsu_bl_notify()
426 sparse_keymap_report_event(priv->input, -1, 1, true); in acpi_fujitsu_bl_notify()
430 oldb = priv->brightness_level; in acpi_fujitsu_bl_notify()
432 newb = priv->brightness_level; in acpi_fujitsu_bl_notify()
434 acpi_handle_debug(device->handle, in acpi_fujitsu_bl_notify()
435 "brightness button event [%i -> %i]\n", oldb, newb); in acpi_fujitsu_bl_notify()
443 sparse_keymap_report_event(priv->input, oldb < newb, 1, true); in acpi_fujitsu_bl_notify()
481 pr_info("Identified laptop model '%s'\n", id->ident); in fujitsu_laptop_dmi_keymap_override()
482 keymap = id->driver_data; in fujitsu_laptop_dmi_keymap_override()
522 priv->input = devm_input_allocate_device(&device->dev); in acpi_fujitsu_laptop_input_setup()
523 if (!priv->input) in acpi_fujitsu_laptop_input_setup()
524 return -ENOMEM; in acpi_fujitsu_laptop_input_setup()
526 snprintf(priv->phys, sizeof(priv->phys), "%s/input0", in acpi_fujitsu_laptop_input_setup()
529 priv->input->name = acpi_device_name(device); in acpi_fujitsu_laptop_input_setup()
530 priv->input->phys = priv->phys; in acpi_fujitsu_laptop_input_setup()
531 priv->input->id.bustype = BUS_HOST; in acpi_fujitsu_laptop_input_setup()
534 ret = sparse_keymap_setup(priv->input, keymap, NULL); in acpi_fujitsu_laptop_input_setup()
538 return input_register_device(priv->input); in acpi_fujitsu_laptop_input_setup()
546 priv->pf_device = platform_device_alloc("fujitsu-laptop", -1); in fujitsu_laptop_platform_add()
547 if (!priv->pf_device) in fujitsu_laptop_platform_add()
548 return -ENOMEM; in fujitsu_laptop_platform_add()
550 platform_set_drvdata(priv->pf_device, priv); in fujitsu_laptop_platform_add()
552 ret = platform_device_add(priv->pf_device); in fujitsu_laptop_platform_add()
556 ret = sysfs_create_group(&priv->pf_device->dev.kobj, in fujitsu_laptop_platform_add()
564 platform_device_del(priv->pf_device); in fujitsu_laptop_platform_add()
566 platform_device_put(priv->pf_device); in fujitsu_laptop_platform_add()
575 sysfs_remove_group(&priv->pf_device->dev.kobj, in fujitsu_laptop_platform_remove()
577 platform_device_unregister(priv->pf_device); in fujitsu_laptop_platform_remove()
583 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in logolamp_set()
602 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in logolamp_get()
619 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in kblamps_set()
631 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in kblamps_get()
644 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in radio_led_set()
656 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in radio_led_get()
668 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in eco_led_set()
682 struct acpi_device *device = to_acpi_device(cdev->dev->parent); in eco_led_get()
699 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); in acpi_fujitsu_laptop_leds_register()
701 return -ENOMEM; in acpi_fujitsu_laptop_leds_register()
703 led->name = "fujitsu::logolamp"; in acpi_fujitsu_laptop_leds_register()
704 led->brightness_set_blocking = logolamp_set; in acpi_fujitsu_laptop_leds_register()
705 led->brightness_get = logolamp_get; in acpi_fujitsu_laptop_leds_register()
706 ret = devm_led_classdev_register(&device->dev, led); in acpi_fujitsu_laptop_leds_register()
714 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); in acpi_fujitsu_laptop_leds_register()
716 return -ENOMEM; in acpi_fujitsu_laptop_leds_register()
718 led->name = "fujitsu::kblamps"; in acpi_fujitsu_laptop_leds_register()
719 led->brightness_set_blocking = kblamps_set; in acpi_fujitsu_laptop_leds_register()
720 led->brightness_get = kblamps_get; in acpi_fujitsu_laptop_leds_register()
721 ret = devm_led_classdev_register(&device->dev, led); in acpi_fujitsu_laptop_leds_register()
727 * Some Fujitsu laptops have a radio toggle button in place of a slide in acpi_fujitsu_laptop_leds_register()
730 * S7110, S8420; the first one has a radio toggle button, the other in acpi_fujitsu_laptop_leds_register()
733 * whether given model has a radio toggle button. in acpi_fujitsu_laptop_leds_register()
735 if (priv->flags_supported & BIT(17)) { in acpi_fujitsu_laptop_leds_register()
736 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); in acpi_fujitsu_laptop_leds_register()
738 return -ENOMEM; in acpi_fujitsu_laptop_leds_register()
740 led->name = "fujitsu::radio_led"; in acpi_fujitsu_laptop_leds_register()
741 led->brightness_set_blocking = radio_led_set; in acpi_fujitsu_laptop_leds_register()
742 led->brightness_get = radio_led_get; in acpi_fujitsu_laptop_leds_register()
743 led->default_trigger = "rfkill-any"; in acpi_fujitsu_laptop_leds_register()
744 ret = devm_led_classdev_register(&device->dev, led); in acpi_fujitsu_laptop_leds_register()
757 led = devm_kzalloc(&device->dev, sizeof(*led), GFP_KERNEL); in acpi_fujitsu_laptop_leds_register()
759 return -ENOMEM; in acpi_fujitsu_laptop_leds_register()
761 led->name = "fujitsu::eco_led"; in acpi_fujitsu_laptop_leds_register()
762 led->brightness_set_blocking = eco_led_set; in acpi_fujitsu_laptop_leds_register()
763 led->brightness_get = eco_led_get; in acpi_fujitsu_laptop_leds_register()
764 ret = devm_led_classdev_register(&device->dev, led); in acpi_fujitsu_laptop_leds_register()
777 priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL); in acpi_fujitsu_laptop_add()
779 return -ENOMEM; in acpi_fujitsu_laptop_add()
786 device->driver_data = priv; in acpi_fujitsu_laptop_add()
789 spin_lock_init(&priv->fifo_lock); in acpi_fujitsu_laptop_add()
790 ret = kfifo_alloc(&priv->fifo, RINGBUFFERSIZE * sizeof(int), in acpi_fujitsu_laptop_add()
801 acpi_handle_debug(device->handle, "Discarded %i ringbuffer entries\n", in acpi_fujitsu_laptop_add()
804 priv->flags_supported = call_fext_func(device, FUNC_FLAGS, 0x0, 0x0, in acpi_fujitsu_laptop_add()
809 if (priv->flags_supported == UNSUPPORTED_CMD) in acpi_fujitsu_laptop_add()
810 priv->flags_supported = 0; in acpi_fujitsu_laptop_add()
812 if (priv->flags_supported) in acpi_fujitsu_laptop_add()
813 priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, in acpi_fujitsu_laptop_add()
817 acpi_handle_info(device->handle, "BTNI: [0x%x]\n", in acpi_fujitsu_laptop_add()
821 if (fujitsu_bl && fujitsu_bl->bl_device && in acpi_fujitsu_laptop_add()
825 fujitsu_bl->bl_device->props.power = FB_BLANK_POWERDOWN; in acpi_fujitsu_laptop_add()
827 fujitsu_bl->bl_device->props.power = FB_BLANK_UNBLANK; in acpi_fujitsu_laptop_add()
845 kfifo_free(&priv->fifo); in acpi_fujitsu_laptop_add()
856 kfifo_free(&priv->fifo); in acpi_fujitsu_laptop_remove()
866 ret = kfifo_in_locked(&priv->fifo, (unsigned char *)&scancode, in acpi_fujitsu_laptop_press()
867 sizeof(scancode), &priv->fifo_lock); in acpi_fujitsu_laptop_press()
869 dev_info(&priv->input->dev, "Could not push scancode [0x%x]\n", in acpi_fujitsu_laptop_press()
873 sparse_keymap_report_event(priv->input, scancode, 1, false); in acpi_fujitsu_laptop_press()
874 dev_dbg(&priv->input->dev, "Push scancode into ringbuffer [0x%x]\n", in acpi_fujitsu_laptop_press()
884 ret = kfifo_out_locked(&priv->fifo, (unsigned char *)&scancode, in acpi_fujitsu_laptop_release()
885 sizeof(scancode), &priv->fifo_lock); in acpi_fujitsu_laptop_release()
888 sparse_keymap_report_event(priv->input, scancode, 0, false); in acpi_fujitsu_laptop_release()
889 dev_dbg(&priv->input->dev, in acpi_fujitsu_laptop_release()
902 acpi_handle_info(device->handle, "Unsupported event [0x%x]\n", in acpi_fujitsu_laptop_notify()
904 sparse_keymap_report_event(priv->input, -1, 1, true); in acpi_fujitsu_laptop_notify()
908 if (priv->flags_supported) in acpi_fujitsu_laptop_notify()
909 priv->flags_state = call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, in acpi_fujitsu_laptop_notify()
916 if (sparse_keymap_entry_from_scancode(priv->input, scancode)) in acpi_fujitsu_laptop_notify()
921 acpi_handle_info(device->handle, in acpi_fujitsu_laptop_notify()
926 * First seen on the Skylake-based Lifebook E736/E746/E756), the in acpi_fujitsu_laptop_notify()
931 if (priv->flags_supported & (FLAG_SOFTKEYS)) { in acpi_fujitsu_laptop_notify()
935 sparse_keymap_report_event(priv->input, BIT(i), 1, true); in acpi_fujitsu_laptop_notify()
1026 MODULE_PARM_DESC(use_alt_lcd_levels, "Interface used for setting LCD brightness level (-1 = auto, 0…