Disable s2w/dt2w when magnetic cover is used

Signed-off-by: flar2 <asegaert@gmail.com>
This commit is contained in:
flar2 2013-11-26 16:11:44 -05:00 committed by followmsi
parent 2e419eac16
commit 7bce0c4ac7
3 changed files with 53 additions and 1 deletions

View file

@ -12,6 +12,8 @@
#include <linux/gpio_event.h>
#include <linux/gpio.h>
#include <linux/sweep2wake.h>
#define LID_DEBUG 0
#define CONVERSION_TIME_MS 50
@ -113,6 +115,9 @@ static void lid_report_function(struct work_struct *dat)
input_report_switch(lid_indev, SW_LID, !value);
input_sync(lid_indev);
if (value == 0)
lid_closed = 1;
LID_NOTICE("SW_LID report value = %d\n", value);
}

View file

@ -214,6 +214,7 @@ static DEFINE_MUTEX(s2w_lock);
static bool scr_suspended = false;
static int pwrkey_suspend = 1;
static int lid_suspend = 1;
static int s2w_orientation = 0;
static int shortsweep = 0;
static int dt2w_switch = 1;
@ -550,6 +551,20 @@ static int __init get_pwr_key_opt(char *pwr_key)
__setup("pwr_key=", get_pwr_key_opt);
static int __init get_lid_suspend_opt(char *lid_sus)
{
if (strcmp(lid_sus, "0") == 0) {
lid_suspend = 0;
} else if (strcmp(lid_sus, "1") == 0) {
lid_suspend = 1;
} else {
lid_suspend = 0;
}
return 1;
}
__setup("lid_sus=", get_lid_suspend_opt);
/* end sweep2wake */
@ -795,6 +810,28 @@ static ssize_t elan_ktf3k_pwrkey_suspend_dump(struct device *dev,
static DEVICE_ATTR(pwrkey_suspend, (S_IWUSR|S_IRUGO),
elan_ktf3k_pwrkey_suspend_show, elan_ktf3k_pwrkey_suspend_dump);
static ssize_t elan_ktf3k_lid_suspend_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
size_t count = 0;
count += sprintf(buf, "%d\n", lid_suspend);
return count;
}
static ssize_t elan_ktf3k_lid_suspend_dump(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
if (buf[0] >= '0' && buf[0] <= '1' && buf[1] == '\n')
if (lid_suspend != buf[0] - '0')
lid_suspend = buf[0] - '0';
return count;
}
static DEVICE_ATTR(lid_suspend, (S_IWUSR|S_IRUGO),
elan_ktf3k_lid_suspend_show, elan_ktf3k_lid_suspend_dump);
static ssize_t elan_ktf3k_orientation_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@ -963,6 +1000,7 @@ static struct attribute *elan_attr[] = {
&dev_attr_doubletap2wake.attr,
&dev_attr_shortsweep.attr,
&dev_attr_pwrkey_suspend.attr,
&dev_attr_lid_suspend.attr,
&dev_attr_orientation.attr,
NULL
};
@ -1012,6 +1050,11 @@ static int elan_ktf3k_touch_sysfs_init(void)
touch_debug(DEBUG_ERROR, "[elan]%s: sysfs_create_group failed\n", __func__);
return ret;
}
ret = sysfs_create_file(android_touch_kobj, &dev_attr_lid_suspend.attr);
if (ret) {
touch_debug(DEBUG_ERROR, "[elan]%s: sysfs_create_group failed\n", __func__);
return ret;
}
ret = sysfs_create_file(android_touch_kobj, &dev_attr_orientation.attr);
if (ret) {
touch_debug(DEBUG_ERROR, "[elan]%s: sysfs_create_group failed\n", __func__);
@ -1029,6 +1072,7 @@ static void elan_touch_sysfs_deinit(void)
sysfs_remove_file(android_touch_kobj, &dev_attr_doubletap2wake.attr);
sysfs_remove_file(android_touch_kobj, &dev_attr_shortsweep.attr);
sysfs_remove_file(android_touch_kobj, &dev_attr_pwrkey_suspend.attr);
sysfs_remove_file(android_touch_kobj, &dev_attr_lid_suspend.attr);
sysfs_remove_file(android_touch_kobj, &dev_attr_orientation.attr);
kobject_del(android_touch_kobj);
}
@ -2283,8 +2327,9 @@ static int elan_ktf3k_ts_suspend(struct i2c_client *client, pm_message_t mesg)
enable_irq(client->irq);
/*s2w*/
if(((s2w_switch != 1 && !dt2w_switch) || (pwrkey_suspend && pwr_key_pressed)) && work_lock == 0) {
if(((s2w_switch != 1 && !dt2w_switch) || (lid_suspend && lid_closed) || (pwrkey_suspend && pwr_key_pressed)) && work_lock == 0) {
pwr_key_pressed = 0;
lid_closed = 0;
rc = elan_ktf3k_ts_set_power_state(client, PWR_STATE_DEEP_SLEEP);
}
/*s2w*/
@ -2330,6 +2375,7 @@ static int elan_ktf3k_ts_resume(struct i2c_client *client)
scr_suspended = false;
pwr_key_pressed = 0;
lid_closed = 0;
/* end s2w */
return 0;

View file

@ -21,3 +21,4 @@
extern void sweep2wake_setdev(struct input_dev * input_device);
extern int pwr_key_pressed;
extern int lid_closed;