mirror of
https://github.com/revyos/thead-kernel.git
synced 2026-06-21 09:12:26 +02:00
hall: i2c-hid: When the Hall sensor cover is triggered, the keyboard and touchpad functions are disabled to prevent accidental triggering of the keyboard and touchpad causing system wake-up.
This commit is contained in:
@@ -66,6 +66,10 @@ static bool debug;
|
||||
module_param(debug, bool, 0444);
|
||||
MODULE_PARM_DESC(debug, "print a lot of debug information");
|
||||
|
||||
#ifdef CONFIG_HS_MH248
|
||||
extern bool get_hall_status(void);
|
||||
#endif
|
||||
|
||||
#define i2c_hid_dbg(ihid, fmt, arg...) \
|
||||
do { \
|
||||
if (debug) \
|
||||
@@ -1235,6 +1239,7 @@ static int i2c_hid_suspend(struct device *dev)
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct i2c_hid *ihid = i2c_get_clientdata(client);
|
||||
struct hid_device *hid = ihid->hid;
|
||||
bool hall_open = true;
|
||||
int ret;
|
||||
int wake_status;
|
||||
|
||||
@@ -1247,8 +1252,6 @@ static int i2c_hid_suspend(struct device *dev)
|
||||
/* Save some power */
|
||||
i2c_hid_set_power(client, I2C_HID_PWR_SLEEP);
|
||||
|
||||
// disable_irq(client->irq);
|
||||
|
||||
if (device_may_wakeup(&client->dev)) {
|
||||
wake_status = enable_irq_wake(client->irq);
|
||||
if (!wake_status)
|
||||
@@ -1258,9 +1261,16 @@ static int i2c_hid_suspend(struct device *dev)
|
||||
wake_status);
|
||||
} else {
|
||||
regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
|
||||
ihid->pdata.supplies);
|
||||
ihid->pdata.supplies);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_HS_MH248
|
||||
hall_open = get_hall_status();
|
||||
#endif
|
||||
|
||||
if(!hall_open) {
|
||||
disable_irq(client->irq);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1289,7 +1299,7 @@ static int i2c_hid_resume(struct device *dev)
|
||||
wake_status);
|
||||
}
|
||||
|
||||
// enable_irq(client->irq);
|
||||
enable_irq(client->irq);
|
||||
|
||||
/* Instead of resetting device, simply powers the device on. This
|
||||
* solves "incomplete reports" on Raydium devices 2386:3118 and
|
||||
|
||||
@@ -31,11 +31,23 @@ struct mh248_para {
|
||||
struct notifier_block fb_notif;
|
||||
struct mutex ops_lock;
|
||||
struct input_dev *hall_input;
|
||||
bool is_open;
|
||||
int is_suspend;
|
||||
int gpio_pin;
|
||||
int irq;
|
||||
int active_value;
|
||||
};
|
||||
struct mh248_para *g_mh248;
|
||||
|
||||
bool get_hall_status(void)
|
||||
{
|
||||
if(g_mh248) {
|
||||
return g_mh248->is_open;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
EXPORT_SYMBOL(get_hall_status);
|
||||
|
||||
static int hall_fb_notifier_callback(struct notifier_block *self,
|
||||
unsigned long action, void *data)
|
||||
@@ -72,12 +84,14 @@ static irqreturn_t hall_mh248_interrupt(int irq, void *dev_id)
|
||||
//input_report_key(mh248->hall_input, KEY_SLEEP, 1);
|
||||
//input_sync(mh248->hall_input);
|
||||
//input_report_key(mh248->hall_input, KEY_SLEEP, 0);
|
||||
mh248->is_open = false;
|
||||
input_report_switch(mh248->hall_input, SW_LID, 1);
|
||||
input_sync(mh248->hall_input);
|
||||
} else if ((gpio_value == mh248->active_value) ) {
|
||||
//input_report_key(mh248->hall_input, KEY_WAKEUP, 1);
|
||||
//input_sync(mh248->hall_input);
|
||||
//input_report_key(mh248->hall_input, KEY_WAKEUP, 0);
|
||||
mh248->is_open = true;
|
||||
input_report_switch(mh248->hall_input, SW_LID, 0);
|
||||
input_sync(mh248->hall_input);
|
||||
}
|
||||
@@ -97,8 +111,9 @@ static int hall_mh248_probe(struct platform_device *pdev)
|
||||
if (!mh248)
|
||||
return -ENOMEM;
|
||||
|
||||
g_mh248 = mh248;
|
||||
mh248->dev = &pdev->dev;
|
||||
|
||||
mh248->is_open = true;
|
||||
mh248->gpio_pin = of_get_named_gpio_flags(np, "irq-gpio",
|
||||
0, &irq_flags);
|
||||
if (!gpio_is_valid(mh248->gpio_pin)) {
|
||||
|
||||
Reference in New Issue
Block a user