static int platform_probe(struct platform_device *dev) { struct backlight_properties props; int ret; mutex_init(&dev_priv.mutex); INIT_DELAYED_WORK(&dev_priv.work, brightness_work); ret = lp8550_probe(); if (ret) return ret; ret = lp8550_save(); if (ret) return ret; memset(&props, 0, sizeof(struct backlight_properties)); props.max_brightness = 255; props.type = BACKLIGHT_FIRMWARE; props.power = 0; /* Power is on */ backlight_device = backlight_device_register("mba6x_backlight", NULL, NULL, &backlight_ops, &props); if (IS_ERR(backlight_device)) { pr_err("mba6x_bl: Failed to register backlight device\n"); return PTR_ERR(backlight_device); } backlight_device->props.brightness = INIT_BRIGHTNESS; backlight_update_status(backlight_device); acpi_video_dmi_promote_vendor(); acpi_video_unregister(); #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0) backlight_register_notifier(&backlight_nb); #endif return 0; }
/* * Determine which type of backlight interface to use on this system, * First check cmdline, then dmi quirks, then do autodetect. * * The autodetect order is: * 1) Is the acpi-video backlight interface supported -> * no, use a vendor interface * 2) Is this a win8 "ready" BIOS and do we have a native interface -> * yes, use a native interface * 3) Else use the acpi-video interface * * Arguably the native on win8 check should be done first, but that would * be a behavior change, which may causes issues. */ enum acpi_backlight_type acpi_video_get_backlight_type(void) { static DEFINE_MUTEX(init_mutex); static bool init_done; static long video_caps; /* Parse cmdline, dmi and acpi only once */ mutex_lock(&init_mutex); if (!init_done) { acpi_video_parse_cmdline(); dmi_check_system(video_detect_dmi_table); acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, find_video, NULL, &video_caps, NULL); INIT_WORK(&backlight_notify_work, acpi_video_backlight_notify_work); backlight_nb.notifier_call = acpi_video_backlight_notify; backlight_nb.priority = 0; if (backlight_register_notifier(&backlight_nb) == 0) backlight_notifier_registered = true; init_done = true; } mutex_unlock(&init_mutex); if (acpi_backlight_cmdline != acpi_backlight_undef) return acpi_backlight_cmdline; if (acpi_backlight_dmi != acpi_backlight_undef) return acpi_backlight_dmi; if (!(video_caps & ACPI_VIDEO_BACKLIGHT)) return acpi_backlight_vendor; if (acpi_osi_is_win8() && backlight_device_registered(BACKLIGHT_RAW)) return acpi_backlight_native; return acpi_backlight_video; }