Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25af9ff9 authored by Shantanu Jain's avatar Shantanu Jain
Browse files

input: touchscreen: send WAKEUP event properly in ITE Tech driver



Send WAKEUP event properly in ITE Tech touch driver when device
is in suspend mode.
The driver maintins a boolean state for sending the WAKEUP event.
When user taps the screen for touch-to-wake feature, the irq
handler for ITE Tech touch driver is scheduled after the ITE tech
resume function. Due to this the boolean state gets reset.
So this change handles this use-case properly.

CRs-Fixed: 1020680
Change-Id: Ifc1d00a42ecffe7aad65d99dadcdf170c56129a7
Signed-off-by: default avatarShantanu Jain <shjain@codeaurora.org>
parent 0c3a23a4
Loading
Loading
Loading
Loading
+36 −21
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@
#define PD_FLAGS_DATA_TYPE_BITS		0xF0
/* other types (like chip-detected gestures) exist but we do not care */
#define PD_FLAGS_DATA_TYPE_TOUCH	0x00
#define PD_FLAGS_IDLE_TO_ACTIVE		0x10
/* a bit for each finger data that is valid (from lsb to msb) */
#define PD_FLAGS_HAVE_FINGERS		0x07
#define PD_PALM_FLAG_BIT		0x01
@@ -137,15 +138,15 @@
#define PINCTRL_STATE_RELEASE	"pmx_ts_release"

struct finger_data {
	uint8_t xLo;
	uint8_t hi;
	uint8_t yLo;
	uint8_t pressure;
	u8 xLo;
	u8 hi;
	u8 yLo;
	u8 pressure;
}  __packed;

struct point_data {
	uint8_t flags;
	uint8_t palm;
	u8 flags;
	u8 gesture_id;
	struct finger_data fd[3];
}  __packed;

@@ -179,7 +180,7 @@ struct it7260_ts_data {
	const struct it7260_ts_platform_data *pdata;
	struct regulator *vdd;
	struct regulator *avdd;
	bool device_needs_wakeup;
	bool in_low_power_mode;
	bool suspended;
	bool fw_upgrade_result;
	bool cfg_upgrade_result;
@@ -743,18 +744,19 @@ out:
static int it7260_ts_chip_low_power_mode(struct it7260_ts_data *ts_data,
					const u8 sleep_type)
{
	const uint8_t cmd_sleep[] = {CMD_PWR_CTL, 0x00, sleep_type};
	uint8_t dummy;
	const u8 cmd_sleep[] = {CMD_PWR_CTL, 0x00, sleep_type};
	u8 dummy;
	int ret;

	if (sleep_type)
		it7260_i2c_write_no_ready_check(ts_data, BUF_COMMAND, cmd_sleep,
					sizeof(cmd_sleep));
		ret = it7260_i2c_write_no_ready_check(ts_data, BUF_COMMAND,
					cmd_sleep, sizeof(cmd_sleep));
	else
		it7260_i2c_read_no_ready_check(ts_data, BUF_QUERY, &dummy,
		ret = it7260_i2c_read_no_ready_check(ts_data, BUF_QUERY, &dummy,
						sizeof(dummy));

	msleep(WAIT_CHANGE_MODE);
	return 0;
	return (ret == IT_I2C_WRITE_RET ? 0 : ret);
}

static ssize_t sysfs_fw_upgrade_store(struct device *dev,
@@ -1226,18 +1228,28 @@ static irqreturn_t it7260_ts_threaded_handler(int irq, void *devid)
		 * schedule a work that tells the pm core to relax once the CPU
		 * cores are up.
		 */
		if (ts_data->device_needs_wakeup) {
		if ((pt_data.flags & PD_FLAGS_DATA_TYPE_BITS) ==
				PD_FLAGS_IDLE_TO_ACTIVE &&
				pt_data.gesture_id == 0) {
			pm_stay_awake(&ts_data->client->dev);
			input_report_key(input_dev, KEY_WAKEUP, 1);
			input_sync(input_dev);
			input_report_key(input_dev, KEY_WAKEUP, 0);
			input_sync(input_dev);
			schedule_work(&ts_data->work_pm_relax);
			return IRQ_HANDLED;
		} else {
			dev_dbg(&ts_data->client->dev,
				"Ignore the touch data\n");
		}
		return IRQ_HANDLED;
	}

	palm_detected = pt_data.palm & PD_PALM_FLAG_BIT;
	/*
	 * Check if touch data also includes any palm gesture or not.
	 * If palm gesture is detected, then send the keycode parsed
	 * from the DT.
	 */
	palm_detected = pt_data.gesture_id & PD_PALM_FLAG_BIT;
	if (palm_detected && ts_data->pdata->palm_detect_en) {
		input_report_key(input_dev,
				ts_data->pdata->palm_detect_keycode, 1);
@@ -2084,7 +2096,7 @@ static int it7260_ts_resume(struct device *dev)
	int retval;

	if (device_may_wakeup(dev)) {
		if (ts_data->device_needs_wakeup) {
		if (ts_data->in_low_power_mode) {
			/* Set active current for the avdd regulator */
			if (ts_data->pdata->avdd_lpm_cur) {
				retval = reg_set_optimum_mode_check(
@@ -2095,7 +2107,7 @@ static int it7260_ts_resume(struct device *dev)
					retval);
			}

			ts_data->device_needs_wakeup = false;
			ts_data->in_low_power_mode = false;
			disable_irq_wake(ts_data->client->irq);
		}
		return 0;
@@ -2130,10 +2142,13 @@ static int it7260_ts_suspend(struct device *dev)
	}

	if (device_may_wakeup(dev)) {
		if (!ts_data->device_needs_wakeup) {
		if (!ts_data->in_low_power_mode) {
			/* put the device in low power idle mode */
			it7260_ts_chip_low_power_mode(ts_data,
			retval = it7260_ts_chip_low_power_mode(ts_data,
						PWR_CTL_LOW_POWER_MODE);
			if (retval)
				dev_err(dev, "Can't go to low power mode %d\n",
						retval);

			/* Set lpm current for avdd regulator */
			if (ts_data->pdata->avdd_lpm_cur) {
@@ -2145,7 +2160,7 @@ static int it7260_ts_suspend(struct device *dev)
						retval);
			}

			ts_data->device_needs_wakeup = true;
			ts_data->in_low_power_mode = true;
			enable_irq_wake(ts_data->client->irq);
		}
		return 0;