acer-wmi: Respect framebuffer blanking in backlight
[linux-2.6-microblaze.git] / drivers / misc / acer-wmi.c
index 74d12b4..e35825f 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/dmi.h>
+#include <linux/fb.h>
 #include <linux/backlight.h>
 #include <linux/leds.h>
 #include <linux/platform_device.h>
@@ -174,7 +175,7 @@ static struct wmi_interface *interface;
 struct quirk_entry {
        u8 wireless;
        u8 mailled;
-       u8 brightness;
+       s8 brightness;
        u8 bluetooth;
 };
 
@@ -198,6 +199,10 @@ static int dmi_matched(const struct dmi_system_id *dmi)
 static struct quirk_entry quirk_unknown = {
 };
 
+static struct quirk_entry quirk_acer_aspire_1520 = {
+       .brightness = -1,
+};
+
 static struct quirk_entry quirk_acer_travelmate_2490 = {
        .mailled = 1,
 };
@@ -208,6 +213,24 @@ static struct quirk_entry quirk_medion_md_98300 = {
 };
 
 static struct dmi_system_id acer_quirks[] = {
+       {
+               .callback = dmi_matched,
+               .ident = "Acer Aspire 1360",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
+               },
+               .driver_data = &quirk_acer_aspire_1520,
+       },
+       {
+               .callback = dmi_matched,
+               .ident = "Acer Aspire 1520",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1520"),
+               },
+               .driver_data = &quirk_acer_aspire_1520,
+       },
        {
                .callback = dmi_matched,
                .ident = "Acer Aspire 3100",
@@ -217,6 +240,15 @@ static struct dmi_system_id acer_quirks[] = {
                },
                .driver_data = &quirk_acer_travelmate_2490,
        },
+       {
+               .callback = dmi_matched,
+               .ident = "Acer Aspire 3610",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 3610"),
+               },
+               .driver_data = &quirk_acer_travelmate_2490,
+       },
        {
                .callback = dmi_matched,
                .ident = "Acer Aspire 5100",
@@ -226,6 +258,15 @@ static struct dmi_system_id acer_quirks[] = {
                },
                .driver_data = &quirk_acer_travelmate_2490,
        },
+       {
+               .callback = dmi_matched,
+               .ident = "Acer Aspire 5610",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
+               },
+               .driver_data = &quirk_acer_travelmate_2490,
+       },
        {
                .callback = dmi_matched,
                .ident = "Acer Aspire 5630",
@@ -534,7 +575,8 @@ static acpi_status AMW0_set_capabilities(void)
         * appear to use the same EC register for brightness, even if they
         * differ for wireless, etc
         */
-       interface->capability |= ACER_CAP_BRIGHTNESS;
+       if (quirks->brightness >= 0)
+               interface->capability |= ACER_CAP_BRIGHTNESS;
 
        return AE_OK;
 }
@@ -761,11 +803,11 @@ enum led_brightness value)
 }
 
 static struct led_classdev mail_led = {
-       .name = "acer-mail:green",
+       .name = "acer-wmi::mail",
        .brightness_set = mail_led_set,
 };
 
-static int __init acer_led_init(struct device *dev)
+static int __devinit acer_led_init(struct device *dev)
 {
        return led_classdev_register(dev, &mail_led);
 }
@@ -789,7 +831,15 @@ static int read_brightness(struct backlight_device *bd)
 
 static int update_bl_status(struct backlight_device *bd)
 {
-       set_u32(bd->props.brightness, ACER_CAP_BRIGHTNESS);
+       int intensity = bd->props.brightness;
+
+       if (bd->props.power != FB_BLANK_UNBLANK)
+               intensity = 0;
+       if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+               intensity = 0;
+
+       set_u32(intensity, ACER_CAP_BRIGHTNESS);
+
        return 0;
 }
 
@@ -798,7 +848,7 @@ static struct backlight_ops acer_bl_ops = {
        .update_status = update_bl_status,
 };
 
-static int __init acer_backlight_init(struct device *dev)
+static int __devinit acer_backlight_init(struct device *dev)
 {
        struct backlight_device *bd;
 
@@ -811,13 +861,14 @@ static int __init acer_backlight_init(struct device *dev)
 
        acer_backlight_device = bd;
 
+       bd->props.power = FB_BLANK_UNBLANK;
+       bd->props.brightness = max_brightness;
        bd->props.max_brightness = max_brightness;
-       bd->props.brightness = read_brightness(NULL);
        backlight_update_status(bd);
        return 0;
 }
 
-static void __exit acer_backlight_exit(void)
+static void acer_backlight_exit(void)
 {
        backlight_device_unregister(acer_backlight_device);
 }
@@ -1041,6 +1092,8 @@ static int __init acer_wmi_init(void)
        printk(ACER_INFO "Acer Laptop ACPI-WMI Extras version %s\n",
                        ACER_WMI_VERSION);
 
+       find_quirks();
+
        /*
         * Detect which ACPI-WMI interface we're using.
         */
@@ -1052,11 +1105,12 @@ static int __init acer_wmi_init(void)
 
        if (wmi_has_guid(WMID_GUID2) && interface) {
                if (ACPI_FAILURE(WMID_set_capabilities())) {
-                       printk(ACER_ERR "Unable to detect available devices\n");
+                       printk(ACER_ERR "Unable to detect available WMID "
+                                       "devices\n");
                        return -ENODEV;
                }
        } else if (!wmi_has_guid(WMID_GUID2) && interface) {
-               printk(ACER_ERR "Unable to detect available devices\n");
+               printk(ACER_ERR "No WMID device detection method found\n");
                return -ENODEV;
        }
 
@@ -1064,21 +1118,18 @@ static int __init acer_wmi_init(void)
                interface = &AMW0_interface;
 
                if (ACPI_FAILURE(AMW0_set_capabilities())) {
-                       printk(ACER_ERR "Unable to detect available devices\n");
+                       printk(ACER_ERR "Unable to detect available AMW0 "
+                                       "devices\n");
                        return -ENODEV;
                }
        }
 
-       if (wmi_has_guid(AMW0_GUID1)) {
-               if (ACPI_FAILURE(AMW0_find_mailled()))
-                       printk(ACER_ERR "Unable to detect mail LED\n");
-       }
-
-       find_quirks();
+       if (wmi_has_guid(AMW0_GUID1))
+               AMW0_find_mailled();
 
        if (!interface) {
-               printk(ACER_ERR "No or unsupported WMI interface, unable to ");
-               printk(KERN_CONT "load.\n");
+               printk(ACER_ERR "No or unsupported WMI interface, unable to "
+                               "load\n");
                return -ENODEV;
        }