asus-wmi: Add callback for hotkey filtering
[pandora-kernel.git] / drivers / platform / x86 / asus-wmi.c
index 65b66aa..cea9fdc 100644 (file)
@@ -797,8 +797,8 @@ exit:
  * Hwmon device
  */
 static ssize_t asus_hwmon_pwm1(struct device *dev,
-                           struct device_attribute *attr,
-                           char *buf)
+                              struct device_attribute *attr,
+                              char *buf)
 {
        struct asus_wmi *asus = dev_get_drvdata(dev);
        u32 value;
@@ -809,7 +809,7 @@ static ssize_t asus_hwmon_pwm1(struct device *dev,
        if (err < 0)
                return err;
 
-       value |= 0xFF;
+       value &= 0xFF;
 
        if (value == 1) /* Low Speed */
                value = 85;
@@ -869,7 +869,7 @@ static mode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj,
                 * - reverved bits are non-zero
                 * - sfun and presence bit are not set
                 */
-               if (value != ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000
+               if (value == ASUS_WMI_UNSUPPORTED_METHOD || value & 0xFFF80000
                    || (!asus->sfun && !(value & ASUS_WMI_DSTS_PRESENCE_BIT)))
                        ok = false;
        }
@@ -904,6 +904,7 @@ static int asus_wmi_hwmon_init(struct asus_wmi *asus)
                pr_err("Could not register asus hwmon device\n");
                return PTR_ERR(hwmon);
        }
+       dev_set_drvdata(hwmon, asus);
        asus->hwmon_device = hwmon;
        result = sysfs_create_group(&hwmon->kobj, &hwmon_attribute_group);
        if (result)
@@ -1060,6 +1061,8 @@ static void asus_wmi_notify(u32 value, void *context)
        acpi_status status;
        int code;
        int orig_code;
+       unsigned int key_value = 1;
+       bool autorelease = 1;
 
        status = wmi_get_event_data(value, &response);
        if (status != AE_OK) {
@@ -1075,6 +1078,13 @@ static void asus_wmi_notify(u32 value, void *context)
        code = obj->integer.value;
        orig_code = code;
 
+       if (asus->driver->key_filter) {
+               asus->driver->key_filter(asus->driver, &code, &key_value,
+                                        &autorelease);
+               if (code == ASUS_WMI_KEY_IGNORE)
+                       goto exit;
+       }
+
        if (code >= NOTIFY_BRNUP_MIN && code <= NOTIFY_BRNUP_MAX)
                code = NOTIFY_BRNUP_MIN;
        else if (code >= NOTIFY_BRNDOWN_MIN &&
@@ -1084,7 +1094,8 @@ static void asus_wmi_notify(u32 value, void *context)
        if (code == NOTIFY_BRNUP_MIN || code == NOTIFY_BRNDOWN_MIN) {
                if (!acpi_video_backlight_support())
                        asus_wmi_backlight_notify(asus, orig_code);
-       } else if (!sparse_keymap_report_event(asus->inputdev, code, 1, true))
+       } else if (!sparse_keymap_report_event(asus->inputdev, code,
+                                              key_value, autorelease))
                pr_info("Unknown key %x pressed\n", code);
 
 exit: