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

Commit 4ffb7c37 authored by Shantanu Jain's avatar Shantanu Jain Committed by Sudhakar Manapati
Browse files

input: touchscreen: Replace macros used inside the functions



Replace the macros that are used inside the driver function
with dtsi entries.
Remove hrtimer calls which is not being used in the current
driver code.

This patch is propagated from msm-3.10.
(commit: ae83c8954a2462789272078a7e2050ad3168b9be
input: touchscreen: Replace macros used inside the functions)

Change-Id: I29b9ea41df467d0092be8005733016843dc26f60
Signed-off-by: default avatarShantanu Jain <shjain@codeaurora.org>
parent b8907f36
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -52,6 +52,12 @@ Optional properties:
 - goodix,cfg-data5	: Touch screen controller config data group 5. Ask vendor
				to provide that.
 - goodix,fw-name	: Touch screen controller firmware file name.
 - goodix,slide-wakeup	: To specify slide-wakeup property is enabled or not.
 - goodix,dbl-clk-wakeup	: To specify dbl-clk-wakeup property is enabled or not.
 - goodix,change-x2y	: To specify change-x2y property is enabled or not.
 - goodix,driver-send-cfg	: To specify driver-send-cfg property is enabled or not.
 - goodix,have-touch-key	: To specify have-touch-key property is enabled or not.
 - goodix,with-pen	: To specify with-pen property is enabled or not.
Example:
i2c@f9927000 {
		goodix@5d {
@@ -87,5 +93,7 @@ i2c@f9927000 {
				FF FF FF FF FF FF FF 22 22 22
				22 22 22 FF 07 01];
			goodix,fw_name = "gtp_fw.bin";
			goodix,have-touch-key;
			goodix,driver-send-cfg;
		};
};
+283 −286
Original line number Diff line number Diff line
@@ -77,12 +77,6 @@
#define GTP_MAX_TOUCH		5
#define GTP_ESD_CHECK_CIRCLE_MS	2000

#if GTP_HAVE_TOUCH_KEY
static const u16 touch_key_array[] = {KEY_MENU, KEY_HOMEPAGE, KEY_BACK};
#define GTP_MAX_KEY_NUM  (sizeof(touch_key_array)/sizeof(touch_key_array[0]))

#endif

static void gtp_int_sync(struct goodix_ts_data *ts, int ms);
static int gtp_i2c_test(struct i2c_client *client);
static int goodix_power_off(struct goodix_ts_data *ts);
@@ -105,15 +99,14 @@ static void gtp_esd_check_func(struct work_struct *work);
static int gtp_init_ext_watchdog(struct i2c_client *client);
#endif

#if GTP_SLIDE_WAKEUP
enum doze_status {
enum doze {
	DOZE_DISABLED = 0,
	DOZE_ENABLED = 1,
	DOZE_WAKEUP = 2,
};
static enum doze_status = DOZE_DISABLED;
static enum doze doze_status = DOZE_DISABLED;
static s8 gtp_enter_doze(struct goodix_ts_data *ts);
#endif

bool init_done;
static u8 chip_gt9xxs;  /* true if ic is gt9xxs, like gt915s */
u8 grp_cfg_version;
@@ -163,11 +156,11 @@ int gtp_i2c_read(struct i2c_client *client, u8 *buf, int len)
		dev_err(&client->dev, "I2C retry: %d\n", retries + 1);
	}
	if (retries == GTP_I2C_RETRY_5) {
#if GTP_SLIDE_WAKEUP
		if (ts->pdata->slide_wakeup)
			/* reset chip would quit doze mode */
			if (DOZE_ENABLED == doze_status)
				return ret;
#endif

		if (init_done)
			gtp_reset_guitar(ts, 10);
		else
@@ -209,10 +202,10 @@ int gtp_i2c_write(struct i2c_client *client, u8 *buf, int len)
		dev_err(&client->dev, "I2C retry: %d\n", retries + 1);
	}
	if (retries == GTP_I2C_RETRY_5) {
#if GTP_SLIDE_WAKEUP
		if (ts->pdata->slide_wakeup)
			if (DOZE_ENABLED == doze_status)
				return ret;
#endif

		if (init_done)
			gtp_reset_guitar(ts, 10);
		else
@@ -276,10 +269,10 @@ Output:
*********************************************************/
int gtp_send_cfg(struct goodix_ts_data *ts)
{
	int ret;
#if GTP_DRIVER_SEND_CFG
	int retry = 0;
	int ret = 0;
	int retry;

	if (ts->pdata->driver_send_cfg) {
		if (ts->fixed_cfg) {
			dev_dbg(&ts->client->dev,
				"Ic fixed config, no config sent!");
@@ -288,12 +281,13 @@ int gtp_send_cfg(struct goodix_ts_data *ts)
			for (retry = 0; retry < GTP_I2C_RETRY_5; retry++) {
				ret = gtp_i2c_write(ts->client,
					ts->config_data,
				GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH);
					GTP_CONFIG_MAX_LENGTH +
						GTP_ADDR_LENGTH);
				if (ret > 0)
					break;
			}
		}
#endif
	}

	return ret;
}
@@ -353,9 +347,8 @@ Output:
static void gtp_touch_down(struct goodix_ts_data *ts, int id, int x, int y,
		int w)
{
#if GTP_CHANGE_X2Y
	if (ts->pdata->change_x2y)
		swap(x, y);
#endif

	input_mt_slot(ts->input_dev, id);
	input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
@@ -400,9 +393,7 @@ static void goodix_ts_work_func(struct work_struct *work)
	u8 finger = 0;
	static u16 pre_touch;
	static u8 pre_key;
#if GTP_WITH_PEN
	static u8 pre_pen;
#endif
	u8 key_value = 0;
	u8 *coor_data = NULL;
	s32 input_x = 0;
@@ -412,10 +403,7 @@ static void goodix_ts_work_func(struct work_struct *work)
	s32 i = 0;
	int ret = -1;
	struct goodix_ts_data *ts = NULL;

#if GTP_SLIDE_WAKEUP
	u8 doze_buf[3] = {0x81, 0x4B};
#endif

	ts = container_of(work, struct goodix_ts_data, work);
#ifdef CONFIG_GT9XX_TOUCHPANEL_UPDATE
@@ -423,7 +411,7 @@ static void goodix_ts_work_func(struct work_struct *work)
		return;
#endif

#if GTP_SLIDE_WAKEUP
	if (ts->pdata->slide_wakeup) {
		if (DOZE_ENABLED == doze_status) {
			ret = gtp_i2c_read(ts->client, doze_buf, 3);
			if (ret > 0) {
@@ -444,9 +432,11 @@ static void goodix_ts_work_func(struct work_struct *work)
					dev_dbg(&ts->client->dev,
						"Slide(0xBB) To Light up the screen!");
					doze_status = DOZE_WAKEUP;
				input_report_key(ts->input_dev, KEY_POWER, 1);
					input_report_key(ts->input_dev,
								KEY_POWER, 1);
					input_sync(ts->input_dev);
				input_report_key(ts->input_dev, KEY_POWER, 0);
					input_report_key(ts->input_dev,
								KEY_POWER, 0);
					input_sync(ts->input_dev);
					/* clear 0x814B*/
					doze_buf[2] = 0x00;
@@ -455,9 +445,11 @@ static void goodix_ts_work_func(struct work_struct *work)
					dev_dbg(&ts->client->dev,
						"double click to light up the screen!");
					doze_status = DOZE_WAKEUP;
				input_report_key(ts->input_dev, KEY_POWER, 1);
					input_report_key(ts->input_dev,
								KEY_POWER, 1);
					input_sync(ts->input_dev);
				input_report_key(ts->input_dev, KEY_POWER, 0);
					input_report_key(ts->input_dev,
								KEY_POWER, 0);
					input_sync(ts->input_dev);
					/* clear 0x814B */
					doze_buf[2] = 0x00;
@@ -471,7 +463,7 @@ static void goodix_ts_work_func(struct work_struct *work)

			return;
		}
#endif
	}

	ret = gtp_i2c_read(ts->client, point_data, 12);
	if (ret < 0) {
@@ -512,7 +504,7 @@ static void goodix_ts_work_func(struct work_struct *work)

	pre_key = key_value;

#if GTP_WITH_PEN
	if (ts->pdata->with_pen) {
		if (pre_pen && (touch_num == 0)) {
			dev_dbg(&ts->client->dev, "Pen touch UP(Slot)!");
			input_report_key(ts->input_dev, BTN_TOOL_PEN, 0);
@@ -520,7 +512,8 @@ static void goodix_ts_work_func(struct work_struct *work)
			input_report_abs(ts->input_dev, ABS_MT_TRACKING_ID, -1);
			pre_pen = 0;
		}
#endif
	}

	if (pre_touch || touch_num) {
		s32 pos = 0;
		u16 touch_index = 0;
@@ -528,7 +521,7 @@ static void goodix_ts_work_func(struct work_struct *work)
		coor_data = &point_data[3];
		if (touch_num) {
			id = coor_data[pos] & 0x0F;
#if GTP_WITH_PEN
			if (ts->pdata->with_pen) {
				id = coor_data[pos];
				if (id == 128) {
					dev_dbg(&ts->client->dev,
@@ -557,16 +550,16 @@ static void goodix_ts_work_func(struct work_struct *work)
					pre_pen = 1;
					pre_touch = 0;
				}
#endif
			}

			touch_index |= (0x01<<id);
		}

		for (i = 0; i < GTP_MAX_TOUCH; i++) {
#if GTP_WITH_PEN
			if (ts->pdata->with_pen)
				if (pre_pen == 1)
					break;
#endif

			if (touch_index & (0x01<<i)) {
				input_x = coor_data[pos + 1] |
						coor_data[pos + 2] << 8;
@@ -671,7 +664,6 @@ void gtp_reset_guitar(struct goodix_ts_data *ts, int ms)
}

#if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_FB)
#if GTP_SLIDE_WAKEUP
/*******************************************************
Function:
	Enter doze mode for sliding wakeup.
@@ -688,9 +680,9 @@ static s8 gtp_enter_doze(struct goodix_ts_data *ts)
		(u8)(GTP_REG_SLEEP >> 8),
		(u8)GTP_REG_SLEEP, 8};

#if GTP_DBL_CLK_WAKEUP
	if (ts->pdata->dbl_clk_wakeup)
		i2c_control_buf[2] = 0x09;
#endif

	gtp_irq_disable(ts);

	while (retry++ < GTP_I2C_RETRY_3) {
@@ -719,7 +711,6 @@ static s8 gtp_enter_doze(struct goodix_ts_data *ts)
	gtp_irq_enable(ts);
	return ret;
}
#else
/**
 * gtp_enter_sleep - Enter sleep mode
 * @ts: driver private data
@@ -764,7 +755,6 @@ static u8 gtp_enter_sleep(struct goodix_ts_data *ts)
	dev_err(&ts->client->dev, "GTP send sleep cmd failed.\n");
	return ret;
}
#endif /* !GTP_SLIDE_WAKEUP */

/*******************************************************
Function:
@@ -810,25 +800,25 @@ static s8 gtp_wakeup_sleep(struct goodix_ts_data *ts)
				"Wakeup sleep send config success.");
	} else {
err_retry:
#if GTP_SLIDE_WAKEUP
		/* wakeup not by slide */
		if (ts->pdata->slide_wakeup) { /* wakeup not by slide */
			if (DOZE_WAKEUP != doze_status)
				gtp_reset_guitar(ts, 10);
			else
				/* wakeup by slide */
				doze_status = DOZE_DISABLED;
#else
		} else {
			if (chip_gt9xxs == 1) {
				gtp_reset_guitar(ts, 10);
			} else {
			ret = gpio_direction_output(ts->pdata->irq_gpio, 1);
				ret = gpio_direction_output(
						ts->pdata->irq_gpio, 1);
				usleep(5000);
			}
#endif
		}
		ret = gtp_i2c_test(ts->client);
		if (ret == 2) {
			dev_dbg(&ts->client->dev, "GTP wakeup sleep.");
#if (!GTP_SLIDE_WAKEUP)
			if (!ts->pdata->slide_wakeup) {
				if (chip_gt9xxs == 0) {
					gtp_int_sync(ts, 25);
					msleep(20);
@@ -836,7 +826,7 @@ err_retry:
					gtp_init_ext_watchdog(ts->client);
#endif
				}
#endif
			}
			return ret;
		}
		gtp_reset_guitar(ts, 20);
@@ -860,15 +850,14 @@ Output:
static int gtp_init_panel(struct goodix_ts_data *ts)
{
	struct i2c_client *client = ts->client;
	unsigned char *config_data;
	unsigned char *config_data = NULL;
	int ret = -EIO;

#if GTP_DRIVER_SEND_CFG
	int i;
	u8 check_sum = 0;
	u8 opr_buf[16];
	u8 sensor_id = 0;

	if (ts->pdata->driver_send_cfg) {
		for (i = 0; i < GOODIX_MAX_CFG_GROUP; i++)
			dev_dbg(&client->dev, "Config Groups(%d) Lengths: %d",
				i, ts->pdata->config_data_len[i]);
@@ -887,11 +876,12 @@ static int gtp_init_panel(struct goodix_ts_data *ts)
			if (ts->pdata->config_data_len[i])
				break;
		}

		if (i == GOODIX_MAX_CFG_GROUP) {
			sensor_id = 0;
		} else {
		ret = gtp_i2c_read_dbl_check(ts->client, GTP_REG_SENSOR_ID,
			&sensor_id, 1);
			ret = gtp_i2c_read_dbl_check(ts->client,
					GTP_REG_SENSOR_ID, &sensor_id, 1);
			if (SUCCESS == ret) {
				if (sensor_id >= GOODIX_MAX_CFG_GROUP) {
					dev_err(&client->dev,
@@ -908,7 +898,8 @@ static int gtp_init_panel(struct goodix_ts_data *ts)

		dev_info(&client->dev, "Sensor ID selected: %d", sensor_id);

	if (ts->pdata->config_data_len[sensor_id] < GTP_CONFIG_MIN_LENGTH ||
		if (ts->pdata->config_data_len[sensor_id] <
			GTP_CONFIG_MIN_LENGTH ||
			!ts->pdata->config_data[sensor_id]) {
			dev_err(&client->dev,
					"Sensor_ID(%d) matches with NULL or invalid config group!\n",
@@ -922,9 +913,11 @@ static int gtp_init_panel(struct goodix_ts_data *ts)
			if (opr_buf[0] < 90) {
				/* backup group config version */
				grp_cfg_version =
			ts->pdata->config_data[sensor_id][GTP_ADDR_LENGTH];
			ts->pdata->config_data[sensor_id][GTP_ADDR_LENGTH] =
				0x00;
				ts->pdata->
					config_data[sensor_id][GTP_ADDR_LENGTH];
				ts->pdata->
					config_data[sensor_id][GTP_ADDR_LENGTH]
						= 0x00;
				ts->fixed_cfg = 0;
			} else {
				/* treated as fixed config, not send config */
@@ -965,7 +958,7 @@ static int gtp_init_panel(struct goodix_ts_data *ts)

		config_data[ts->gtp_cfg_len] = (~check_sum) + 1;

#else /* DRIVER NOT SEND CONFIG */
	} else { /* DRIVER NOT SEND CONFIG */
		ts->gtp_cfg_len = GTP_CONFIG_MAX_LENGTH;
		ret = gtp_i2c_read(ts->client, config_data,
			ts->gtp_cfg_len + GTP_ADDR_LENGTH);
@@ -976,7 +969,7 @@ static int gtp_init_panel(struct goodix_ts_data *ts)
			ts->abs_y_max = GTP_MAX_HEIGHT;
			ts->int_trigger_type = GTP_INT_TRIGGER;
		}
#endif /* !DRIVER NOT SEND CONFIG */
	} /* !DRIVER NOT SEND CONFIG */

	if ((ts->abs_x_max == 0) && (ts->abs_y_max == 0)) {
		ts->abs_x_max = (config_data[RESOLUTION_LOC + 1] << 8)
@@ -1209,9 +1202,7 @@ static int gtp_request_input_dev(struct goodix_ts_data *ts)
{
	int ret;
	char phys[PHY_BUF_SIZE];
#if GTP_HAVE_TOUCH_KEY
	int index = 0;
#endif

	ts->input_dev = input_allocate_device();
	if (ts->input_dev == NULL) {
@@ -1227,27 +1218,24 @@ static int gtp_request_input_dev(struct goodix_ts_data *ts)
	/* in case of "out of memory" */
	input_mt_init_slots(ts->input_dev, 10, 0);


	if (ts->pdata->have_touch_key) {
		for (index = 0; index < ts->pdata->num_button; index++) {
			input_set_capability(ts->input_dev,
				EV_KEY, ts->pdata->button_map[index]);
		}
	}


#if GTP_SLIDE_WAKEUP
	if (ts->pdata->slide_wakeup)
		input_set_capability(ts->input_dev, EV_KEY, KEY_POWER);
#endif

#if GTP_WITH_PEN
	/* pen support */
	if (ts->pdata->with_pen) {  /* pen support */
		__set_bit(BTN_TOOL_PEN, ts->input_dev->keybit);
		__set_bit(INPUT_PROP_DIRECT, ts->input_dev->propbit);
		__set_bit(INPUT_PROP_POINTER, ts->input_dev->propbit);
#endif
	}

#if GTP_CHANGE_X2Y
	if (ts->pdata->change_x2y)
		swap(ts->abs_x_max, ts->abs_y_max);
#endif

	input_set_abs_params(ts->input_dev, ABS_MT_POSITION_X,
				0, ts->abs_x_max, 0, 0);
@@ -1850,6 +1838,25 @@ static int goodix_parse_dt(struct device *dev,

	pdata->enable_power_off = of_property_read_bool(np,
						"goodix,enable-power-off");

	pdata->have_touch_key = of_property_read_bool(np,
						"goodix,have-touch-key");

	pdata->driver_send_cfg = of_property_read_bool(np,
						"goodix,driver-send-cfg");

	pdata->change_x2y = of_property_read_bool(np,
						"goodix,change-x2y");

	pdata->with_pen = of_property_read_bool(np,
						"goodix,with-pen");

	pdata->slide_wakeup = of_property_read_bool(np,
						"goodix,slide-wakeup");

	pdata->dbl_clk_wakeup = of_property_read_bool(np,
						"goodix,dbl_clk_wakeup");

	/* reset, irq gpio info */
	pdata->reset_gpio = of_get_named_gpio_flags(np, "reset-gpios",
				0, &pdata->reset_gpio_flags);
@@ -2108,8 +2115,6 @@ exit_free_irq:
#endif
	if (ts->use_irq)
		free_irq(client->irq, ts);
	else
		hrtimer_cancel(&ts->timer);
	cancel_work_sync(&ts->work);
	flush_workqueue(ts->goodix_wq);
	destroy_workqueue(ts->goodix_wq);
@@ -2173,8 +2178,6 @@ static int goodix_ts_remove(struct i2c_client *client)
	if (ts) {
		if (ts->use_irq)
			free_irq(client->irq, ts);
		else
			hrtimer_cancel(&ts->timer);

		cancel_work_sync(&ts->work);
		flush_workqueue(ts->goodix_wq);
@@ -2232,13 +2235,11 @@ static int goodix_ts_suspend(struct device *dev)
	gtp_esd_switch(ts->client, SWITCH_OFF);
#endif

#if GTP_SLIDE_WAKEUP
	if (ts->pdata->slide_wakeup) {
		ret = gtp_enter_doze(ts);
#else
	} else {
		if (ts->use_irq)
			gtp_irq_disable(ts);
	else
		hrtimer_cancel(&ts->timer);

		for (i = 0; i < GTP_MAX_TOUCH; i++)
			gtp_touch_up(ts, i);
@@ -2246,9 +2247,9 @@ static int goodix_ts_suspend(struct device *dev)
		input_sync(ts->input_dev);

		ret = gtp_enter_sleep(ts);
#endif
		if (ret < 0)
			dev_err(&ts->client->dev, "GTP early suspend failed.\n");
	}
	/* to avoid waking up while not sleeping,
	 * delay 48 + 10ms to ensure reliability
	 */
@@ -2280,18 +2281,14 @@ static int goodix_ts_resume(struct device *dev)
	mutex_lock(&ts->lock);
	ret = gtp_wakeup_sleep(ts);

#if GTP_SLIDE_WAKEUP
	if (ts->pdata->slide_wakeup)
		doze_status = DOZE_DISABLED;
#endif

	if (ret <= 0)
		dev_err(&ts->client->dev, "GTP resume failed.\n");

	if (ts->use_irq)
		gtp_irq_enable(ts);
	else
		hrtimer_start(&ts->timer,
			ktime_set(1, 0), HRTIMER_MODE_REL);

#if GTP_ESD_PROTECT
	gtp_esd_switch(ts->client, SWITCH_ON);
+6 −9
Original line number Diff line number Diff line
@@ -63,6 +63,12 @@ struct goodix_ts_platform_data {
	u8 *config_data[GOODIX_MAX_CFG_GROUP];
	u32 button_map[MAX_BUTTONS];
	u8 num_button;
	bool have_touch_key;
	bool driver_send_cfg;
	bool change_x2y;
	bool with_pen;
	bool slide_wakeup;
	bool dbl_clk_wakeup;
};
struct goodix_ts_data {
	spinlock_t irq_lock;
@@ -111,16 +117,7 @@ extern u16 total_len;

/***************************PART1:ON/OFF define*******************************/
#define GTP_CUSTOM_CFG			0
#define GTP_CHANGE_X2Y			0
#define GTP_DRIVER_SEND_CFG		1
#define GTP_HAVE_TOUCH_KEY		1
#define GTP_ESD_PROTECT			0
#define GTP_WITH_PEN			0

/* This cannot work when enable-power-off is on */
#define GTP_SLIDE_WAKEUP		0
/* double-click wakeup, function together with GTP_SLIDE_WAKEUP */
#define GTP_DBL_CLK_WAKEUP		0

#define GTP_IRQ_TAB            {\
				IRQ_TYPE_EDGE_RISING,\