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

Commit 33a5869c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "input: focaltech_touch: Add wakeup gestures support"

parents 0e2c35ee 5e4a1c62
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ Optional properties:
 - focaltech,keys 			: array of key code.
 - focaltech,key-y-coord 	: y coordinate for the keys.
 - focaltech,key-x-coords	: array of x coordinates for the keys.
 - focaltech,wakeup-gestures-en	: enable wakeup gestures.

Example:
	i2c@f9923000{
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@
 * Gesture function enable
 * default: disable
 */
#define FTS_GESTURE_EN                          0
#define FTS_GESTURE_EN                          1

/*
 * ESD check & protection
+26 −19
Original line number Diff line number Diff line
@@ -648,7 +648,7 @@ static int fts_read_touchdata(struct fts_ts_data *data)
#if FTS_GESTURE_EN
	u8 state;

	if (data->suspended) {
	if (data->suspended && data->pdata->wakeup_gestures_en) {
		fts_i2c_read_reg(data->client, FTS_REG_GESTURE_EN, &state);
		if (state == 1) {
			fts_gesture_readdata(data->client);
@@ -989,6 +989,8 @@ static int fts_parse_dt(struct device *dev, struct fts_ts_platform_data *pdata)
		pdata->max_touch_number = FTS_MAX_POINTS;
	}

	pdata->wakeup_gestures_en = of_property_read_bool(np,
			"focaltech,wakeup-gestures-en");

	FTS_FUNC_EXIT();
	return 0;
@@ -1310,6 +1312,7 @@ static int fts_ts_suspend(struct device *dev)
#endif

#if FTS_GESTURE_EN
	if (data->pdata->wakeup_gestures_en) {
		retval = fts_gesture_suspend(data->client);
		if (retval == 0) {
			/* Enter into gesture mode(suspend) */
@@ -1320,6 +1323,7 @@ static int fts_ts_suspend(struct device *dev)
			FTS_FUNC_EXIT();
			return 0;
		}
	}
#endif

#if FTS_PSENSOR_EN
@@ -1376,16 +1380,19 @@ static int fts_ts_resume(struct device *dev)
#endif

#if FTS_GESTURE_EN
	if (data->pdata->wakeup_gestures_en) {
		if (fts_gesture_resume(data->client) == 0) {
			int err;

			err = disable_irq_wake(data->client->irq);
			if (err)
			FTS_ERROR("%s: disable_irq_wake failed", __func__);
				FTS_ERROR("%s: disable_irq_wake failed",
						__func__);
			data->suspended = false;
			FTS_FUNC_EXIT();
			return 0;
		}
	}
#endif

#if FTS_PSENSOR_EN
+1 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ struct fts_ts_platform_data {
	u32 x_min;
	u32 y_min;
	u32 max_touch_number;
	bool wakeup_gestures_en;
};

struct ts_event {
+23 −9
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@
#define FTS_GESTRUE_POINTS                      255
#define FTS_GESTRUE_POINTS_HEADER               8

#define GESTURE_SMALL_AREA      0x25    /* TP Coverage < 50% */
#define GESTURE_LARGE_AREA      0x26    /* TP Coverage > 50% */

/*****************************************************************************
 * Private enumerations, structures and unions using typedef
 *****************************************************************************/
@@ -423,11 +426,21 @@ int fts_gesture_readdata(struct i2c_client *client)
		return ret;
	}

	/* FW recognize gesture */
	if (fts_gesture_fw()) {
	memcpy(fts_gesture_data.header, buf, FTS_GESTRUE_POINTS_HEADER);
	gestrue_id = buf[0];
	pointnum = buf[1];

	if (gestrue_id == GESTURE_SMALL_AREA) {
		FTS_INFO("[GESTURE] Wakeup gesture.");
		input_report_key(fts_input_dev, KEY_POWER, 1);
		input_sync(fts_input_dev);
		input_report_key(fts_input_dev, KEY_POWER, 0);
		input_sync(fts_input_dev);

	} else if (gestrue_id == GESTURE_LARGE_AREA) {
		FTS_INFO("[GESTURE] Large object detected.");
	} else if (fts_gesture_fw()) {
		/* FW recognize gesture */
		read_bytes = ((int)pointnum) * 4 + 2;
		buf[0] = FTS_REG_GESTURE_OUTPUT_ADDRESS;
		FTS_DEBUG("[GESTURE]PointNum=%d", pointnum);
@@ -448,12 +461,13 @@ int fts_gesture_readdata(struct i2c_client *client)
				| (((s16) buf[3 + (4 * i + 2)]) & 0xFF);
		}

		FTS_FUNC_EXIT();
		return 0;
	}

	FTS_ERROR("[GESTURE]IC 0x%x need gesture lib to support gestures.",
	} else {
		FTS_ERROR("[GESTURE]IC 0x%x need lib to support gestures.",
							chip_types.chip_idh);
	}

	FTS_FUNC_EXIT();

	return 0;
}