]> xenbits.xensource.com Git - people/aperard/linux-chromebook.git/commitdiff
CHROMIUM: Input: atmel_mxt_ts - mxt_stop on lid close
authorBenson Leung <bleung@chromium.org>
Sat, 26 Jan 2013 01:45:56 +0000 (17:45 -0800)
committerBenson Leung <bleung@chromium.org>
Tue, 29 Jan 2013 06:11:09 +0000 (22:11 -0800)
This is an x86 specific change for the short term.
When the lid is closed, issue an mxt_stop to turn off scanning
to prevent the lid from affecting the touch device and causing
stray touches.

Signed-off-by: Benson Leung <bleung@chromium.org>
BUG=chrome-os-partner:17465
TEST=From test mode, run evtest, and watch the atmel_mxt device.
Close and open the lid. Make sure there are no touch data comes
from the atmel driver when the lid is being closed.

Change-Id: Ic022b6f44feaa309eb13f677f69809d6ef3f9b91
Reviewed-on: https://gerrit.chromium.org/gerrit/42080
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Benson Leung <bleung@chromium.org>
Tested-by: Benson Leung <bleung@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/42212
Reviewed-by: Danielle Drew <ddrew@chromium.org>
drivers/input/touchscreen/atmel_mxt_ts.c

index 3fdc51387cbe2c4264fa2ef8fcc6c3d3a193dc3b..e05235c29ff795ae280857f441cc55db77fa6c14 100644 (file)
 #include <linux/slab.h>
 #include <linux/uaccess.h>
 
+#if defined(CONFIG_ACPI_BUTTON)
+#include <acpi/button.h>
+#endif
+
+
 /* Version */
 #define MXT_VER_20             20
 #define MXT_VER_21             21
@@ -386,6 +391,11 @@ struct mxt_data {
 
        /* map for the tracking id currently being used */
        bool current_id[MXT_MAX_FINGER];
+
+#if defined(CONFIG_ACPI_BUTTON)
+       /* notifier block for acpi_lid_notifier */
+       struct notifier_block lid_notifier;
+#endif
 };
 
 /* global root node of the atmel_mxt_ts debugfs directory. */
@@ -2458,6 +2468,24 @@ static void mxt_input_close(struct input_dev *dev)
        mxt_stop(data);
 }
 
+#if defined(CONFIG_ACPI_BUTTON)
+static int mxt_lid_notify(struct notifier_block *nb, unsigned long val,
+                          void *unused)
+{
+       struct mxt_data *data = container_of(nb, struct mxt_data, lid_notifier);
+
+       if (mxt_in_bootloader(data))
+               return NOTIFY_OK;
+
+       if (val == 0)
+               mxt_stop(data);
+       else
+               mxt_start(data);
+
+       return NOTIFY_OK;
+}
+#endif
+
 static int mxt_input_dev_create(struct mxt_data *data)
 {
        struct input_dev *input_dev;
@@ -2700,6 +2728,14 @@ static int __devinit mxt_probe(struct i2c_client *client,
 
        async_schedule(mxt_initialize_async, data);
 
+#if defined(CONFIG_ACPI_BUTTON)
+       data->lid_notifier.notifier_call = mxt_lid_notify;
+       if (acpi_lid_notifier_register(&data->lid_notifier)) {
+               pr_info("lid notifier registration failed\n");
+               data->lid_notifier.notifier_call = NULL;
+       }
+#endif
+
        return 0;
 
 err_free_object:
@@ -2720,6 +2756,10 @@ static int __devexit mxt_remove(struct i2c_client *client)
        free_irq(data->irq, data);
        if (data->input_dev)
                input_unregister_device(data->input_dev);
+#if defined(CONFIG_ACPI_BUTTON)
+       if (data->lid_notifier.notifier_call)
+               acpi_lid_notifier_unregister(&data->lid_notifier);
+#endif
        kfree(data->object_table);
        kfree(data->fw_file);
        kfree(data->config_file);
@@ -2813,6 +2853,15 @@ static int mxt_suspend(struct device *dev)
                dev_err(dev, "Save T9 ctrl config failed, %d\n", ret);
        data->T9_ctrl_valid = (ret == 0);
 
+#if defined(CONFIG_ACPI_BUTTON)
+       ret = acpi_lid_open();
+       if (ret == 0) {
+               /* lid is closed. set T9_ctrl to operational on resume */
+               data->T9_ctrl = MXT_TOUCH_CTRL_OPERATIONAL;
+               data->T9_ctrl_valid = true;
+       }
+#endif
+
        /*
         *  For tpads, save T42 and T19 ctrl registers if may wakeup,
         *  enable large object suppression, and disable button wake.