asus_acpi: add support for F3Sa
[sfrench/cifs-2.6.git] / drivers / acpi / asus_acpi.c
index 31ad70a6e22eb3074261b757fc7d831b841c9bed..d25ef961415cefdeebab67ac29f5a5f49d87ff18 100644 (file)
@@ -56,7 +56,6 @@
 #define ACPI_HOTK_NAME          "Asus Laptop ACPI Extras Driver"
 #define ACPI_HOTK_CLASS         "hotkey"
 #define ACPI_HOTK_DEVICE_NAME   "Hotkey"
-#define ACPI_HOTK_HID           "ATK0100"
 
 /*
  * Some events we use, same for all Asus
@@ -141,7 +140,9 @@ struct asus_hotk {
                W5A,            //W5A
                W3V,            //W3030V
                xxN,            //M2400N, M3700N, M5200N, M6800N, S1300N, S5200N
+               A4S,            //Z81sp
                //(Centrino)
+               F3Sa,
                END_MODEL
        } model;                //Models currently supported
        u16 event_count[128];   //count for each event TODO make this better
@@ -397,7 +398,29 @@ static struct model_data model_conf[END_MODEL] = {
         .brightness_set = "SPLV",
         .brightness_get = "GPLV",
         .display_set = "SDSP",
-        .display_get = "\\ADVG"}
+       .display_get = "\\ADVG"},
+
+       {
+               .name              = "A4S",
+               .brightness_set    = "SPLV",
+               .brightness_get    = "GPLV",
+               .mt_bt_switch      = "BLED",
+               .mt_wled           = "WLED"
+       },
+
+       {
+               .name           = "F3Sa",
+               .mt_bt_switch   = "BLED",
+               .mt_wled        = "WLED",
+               .mt_mled        = "MLED",
+               .brightness_get = "GPLV",
+               .brightness_set = "SPLV",
+               .mt_lcd_switch  = "\\_SB.PCI0.SBRG.EC0._Q10",
+               .lcd_status     = "\\_SB.PCI0.SBRG.EC0.RPIN",
+               .display_get    = "\\ADVG",
+               .display_set    = "SDSP",
+       },
+
 };
 
 /* procdir we use */
@@ -416,14 +439,20 @@ static struct acpi_table_header *asus_info;
 static struct asus_hotk *hotk;
 
 /*
- * The hotkey driver declaration
+ * The hotkey driver and autoloading declaration
  */
 static int asus_hotk_add(struct acpi_device *device);
 static int asus_hotk_remove(struct acpi_device *device, int type);
+static const struct acpi_device_id asus_device_ids[] = {
+       {"ATK0100", 0},
+       {"", 0},
+};
+MODULE_DEVICE_TABLE(acpi, asus_device_ids);
+
 static struct acpi_driver asus_hotk_driver = {
-       .name = ACPI_HOTK_NAME,
+       .name = "asus_acpi",
        .class = ACPI_HOTK_CLASS,
-       .ids = ACPI_HOTK_HID,
+       .ids = asus_device_ids,
        .ops = {
                .add = asus_hotk_add,
                .remove = asus_hotk_remove,
@@ -695,15 +724,8 @@ static int get_lcd_state(void)
 {
        int lcd = 0;
 
-       if (hotk->model != L3H) {
-               /* We don't have to check anything if we are here */
-               if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd))
-                       printk(KERN_WARNING
-                              "Asus ACPI: Error reading LCD status\n");
-
-               if (hotk->model == L2D)
-                       lcd = ~lcd;
-       } else {                /* L3H and the like have to be handled differently */
+       if (hotk->model == L3H) {
+               /* L3H and the like have to be handled differently */
                acpi_status status = 0;
                struct acpi_object_list input;
                union acpi_object mt_params[2];
@@ -730,6 +752,32 @@ static int get_lcd_state(void)
                if (out_obj.type == ACPI_TYPE_INTEGER)
                        /* That's what the AML code does */
                        lcd = out_obj.integer.value >> 8;
+       } else if (hotk->model == F3Sa) {
+               unsigned long tmp;
+               union acpi_object param;
+               struct acpi_object_list input;
+               acpi_status status;
+
+               /* Read pin 11 */
+               param.type = ACPI_TYPE_INTEGER;
+               param.integer.value = 0x11;
+               input.count = 1;
+               input.pointer = &param;
+
+               status = acpi_evaluate_integer(NULL, hotk->methods->lcd_status,
+                                               &input, &tmp);
+               if (status != AE_OK)
+                       return -1;
+
+               lcd = tmp;
+       } else {
+               /* We don't have to check anything if we are here */
+               if (!read_acpi_int(NULL, hotk->methods->lcd_status, &lcd))
+                       printk(KERN_WARNING
+                              "Asus ACPI: Error reading LCD status\n");
+
+               if (hotk->model == L2D)
+                       lcd = ~lcd;
        }
 
        return (lcd & 1);
@@ -838,7 +886,7 @@ out:
 
 static int set_brightness_status(struct backlight_device *bd)
 {
-       return set_brightness(bd->props->brightness);
+       return set_brightness(bd->props.brightness);
 }
 
 static int
@@ -1054,7 +1102,7 @@ static void asus_hotk_notify(acpi_handle handle, u32 event, void *data)
                hotk->brightness = (event & ~((u32) BR_DOWN));
        }
 
-       acpi_bus_generate_event(hotk->device, event,
+       acpi_bus_generate_proc_event(hotk->device, event,
                                hotk->event_count[event % 128]++);
 
        return;
@@ -1117,6 +1165,10 @@ static int asus_model_match(char *model)
                return W3V;
        else if (strncmp(model, "W5A", 3) == 0)
                return W5A;
+       else if (strncmp(model, "A4S", 3) == 0)
+               return A4S;
+       else if (strncmp(model, "F3Sa", 4) == 0)
+               return F3Sa;
        else
                return END_MODEL;
 }
@@ -1175,6 +1227,7 @@ static int asus_hotk_get_info(void)
                        break;
                default:
                        kfree(model);
+                       model = NULL;
                        break;
                }
        }
@@ -1340,14 +1393,12 @@ static int asus_hotk_remove(struct acpi_device *device, int type)
        return 0;
 }
 
-static struct backlight_properties asus_backlight_data = {
-        .owner          = THIS_MODULE,
+static struct backlight_ops asus_backlight_data = {
         .get_brightness = read_brightness,
         .update_status  = set_brightness_status,
-        .max_brightness = 15,
 };
 
-static void __exit asus_acpi_exit(void)
+static void asus_acpi_exit(void)
 {
        if (asus_backlight_device)
                backlight_device_unregister(asus_backlight_device);
@@ -1365,10 +1416,6 @@ static int __init asus_acpi_init(void)
        if (acpi_disabled)
                return -ENODEV;
 
-       if (!acpi_specific_hotkey_enabled) {
-               printk(KERN_ERR "Using generic hotkey driver\n");
-               return -ENODEV;
-       }
        asus_proc_dir = proc_mkdir(PROC_ASUS, acpi_root_dir);
        if (!asus_proc_dir) {
                printk(KERN_ERR "Asus ACPI: Unable to create /proc entry\n");
@@ -1392,7 +1439,7 @@ static int __init asus_acpi_init(void)
        if (!asus_hotk_found) {
                acpi_bus_unregister_driver(&asus_hotk_driver);
                remove_proc_entry(PROC_ASUS, acpi_root_dir);
-               return result;
+               return -ENODEV;
        }
 
        asus_backlight_device = backlight_device_register("asus",NULL,NULL,
@@ -1401,7 +1448,9 @@ static int __init asus_acpi_init(void)
                printk(KERN_ERR "Could not register asus backlight device\n");
                asus_backlight_device = NULL;
                asus_acpi_exit();
+               return -ENODEV;
        }
+        asus_backlight_device->props.max_brightness = 15;
 
        return 0;
 }