Lines Matching +full:default +full:- +full:brightness +full:- +full:level
1 // SPDX-License-Identifier: GPL-2.0
3 * Generic Loongson processor based LAPTOP/ALL-IN-ONE driver
20 #include <linux/input/sparse-keymap.h>
26 /* 1. Driver-wide structs and misc. variables */
32 #define ACPI_LAPTOP_NAME "loongson-laptop"
100 default: in acpi_evalf()
127 default: in acpi_evalf()
142 return -EIO; in hotkey_status_get()
151 if (!sub_driver || !sub_driver->notify) in dispatch_acpi_notify()
153 sub_driver->notify(sub_driver, event); in dispatch_acpi_notify()
160 if (!*sub_driver->handle) in setup_acpi_notify()
163 sub_driver->device = acpi_fetch_acpi_dev(*sub_driver->handle); in setup_acpi_notify()
164 if (!sub_driver->device) { in setup_acpi_notify()
165 pr_err("acpi_fetch_acpi_dev(%s) failed\n", sub_driver->name); in setup_acpi_notify()
166 return -ENODEV; in setup_acpi_notify()
169 sub_driver->device->driver_data = sub_driver; in setup_acpi_notify()
170 sprintf(acpi_device_class(sub_driver->device), "%s/%s", in setup_acpi_notify()
171 ACPI_LAPTOP_ACPI_EVENT_PREFIX, sub_driver->name); in setup_acpi_notify()
173 status = acpi_install_notify_handler(*sub_driver->handle, in setup_acpi_notify()
174 sub_driver->type, dispatch_acpi_notify, sub_driver); in setup_acpi_notify()
178 "handling %s events\n", sub_driver->name); in setup_acpi_notify()
181 sub_driver->name, acpi_format_exception(status)); in setup_acpi_notify()
183 return -ENODEV; in setup_acpi_notify()
185 sub_driver->acpi_notify_installed = 1; in setup_acpi_notify()
204 pr_warn("Loongson_backlight: resume brightness failed") : in loongson_hotkey_resume()
205 pr_info("Loongson_backlight: resume brightness %d\n", bd->props.brightness); in loongson_hotkey_resume()
212 if (test_bit(SW_LID, generic_inputdev->swbit)) { in loongson_hotkey_resume()
214 return -EIO; in loongson_hotkey_resume()
217 * When the system is awakened by other wake-up sources, in loongson_hotkey_resume()
229 if (test_bit(SW_LID, generic_inputdev->sw) && !(status & (1 << SW_LID))) { in loongson_hotkey_resume()
245 hotkey_handle = ACPI_HANDLE(&pdev->dev); in loongson_hotkey_probe()
248 return -ENODEV; in loongson_hotkey_probe()
262 .name = "loongson-hotkey",
280 return -1; in hotkey_map()
283 for (index = 0; index < pack->package.count; index++) { in hotkey_map()
286 sub_pack = &pack->package.elements[index]; in hotkey_map()
288 element = &sub_pack->package.elements[0]; in hotkey_map()
289 hotkey_keycode_map[index].type = element->integer.value; in hotkey_map()
290 element = &sub_pack->package.elements[1]; in hotkey_map()
291 hotkey_keycode_map[index].code = element->integer.value; in hotkey_map()
292 element = &sub_pack->package.elements[2]; in hotkey_map()
293 hotkey_keycode_map[index].keycode = element->integer.value; in hotkey_map()
302 return -EIO; in hotkey_backlight_set()
312 return -ENXIO; in ec_get_brightness()
315 return -EIO; in ec_get_brightness()
320 static int ec_set_brightness(int level) in ec_set_brightness() argument
326 return -ENXIO; in ec_set_brightness()
328 if (!acpi_evalf(hotkey_handle, NULL, "ECBS", "vd", level)) in ec_set_brightness()
329 ret = -EIO; in ec_set_brightness()
334 static int ec_backlight_level(u8 level) in ec_backlight_level() argument
339 return -ENXIO; in ec_backlight_level()
342 return -EIO; in ec_backlight_level()
344 if ((status < 0) || (level > status)) in ec_backlight_level()
348 return -EIO; in ec_backlight_level()
350 if ((status < 0) || (level < status)) in ec_backlight_level()
353 return level; in ec_backlight_level()
366 return -EIO; in ec_backlight_set_power()
375 int ret = 0, lvl = ec_backlight_level(bd->props.brightness); in loongson_laptop_backlight_update()
378 return -EIO; in loongson_laptop_backlight_update()
381 return -EIO; in loongson_laptop_backlight_update()
396 int level; in loongson_laptop_get_brightness() local
398 level = ec_get_brightness(); in loongson_laptop_get_brightness()
399 if (level < 0) in loongson_laptop_get_brightness()
400 return -EIO; in loongson_laptop_get_brightness()
402 return level; in loongson_laptop_get_brightness()
418 return -EIO; in laptop_backlight_register()
427 props.brightness = ec_get_brightness(); in laptop_backlight_register()
486 ke->sw.value = !!(status & (1 << ke->sw.code)); in event_notify()
500 if (!sub_driver || !sub_driver->driver) in generic_subdriver_init()
501 return -EINVAL; in generic_subdriver_init()
503 ret = platform_driver_register(sub_driver->driver); in generic_subdriver_init()
505 return -EINVAL; in generic_subdriver_init()
507 if (sub_driver->init) { in generic_subdriver_init()
508 ret = sub_driver->init(sub_driver); in generic_subdriver_init()
513 if (sub_driver->notify) { in generic_subdriver_init()
515 if (ret == -ENODEV) { in generic_subdriver_init()
533 if (sub_driver->acpi_notify_installed) { in generic_subdriver_exit()
534 acpi_remove_notify_handler(*sub_driver->handle, in generic_subdriver_exit()
535 sub_driver->type, dispatch_acpi_notify); in generic_subdriver_exit()
536 sub_driver->acpi_notify_installed = 0; in generic_subdriver_exit()
538 platform_driver_unregister(sub_driver->driver); in generic_subdriver_exit()
558 return -ENODEV; in generic_acpi_laptop_init()
563 return -ENODEV; in generic_acpi_laptop_init()
571 return -ENOMEM; in generic_acpi_laptop_init()
575 generic_inputdev->name = in generic_acpi_laptop_init()
576 "Loongson Generic Laptop/All-in-One Extra Buttons"; in generic_acpi_laptop_init()
577 generic_inputdev->phys = ACPI_LAPTOP_NAME "/input0"; in generic_acpi_laptop_init()
578 generic_inputdev->id.bustype = BUS_HOST; in generic_acpi_laptop_init()
579 generic_inputdev->dev.parent = NULL; in generic_acpi_laptop_init()
586 while (--i >= 0) in generic_acpi_laptop_init()
595 while (--i >= 0) in generic_acpi_laptop_init()
604 pr_info("Loongson Laptop used, init brightness is 0x%x\n", status); in generic_acpi_laptop_init()
607 pr_err("Loongson Laptop: laptop-backlight device register failed\n"); in generic_acpi_laptop_init()
634 MODULE_DESCRIPTION("Loongson Laptop/All-in-One ACPI Driver");