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

Commit b3169ad9 authored by Vevek Venkatesan's avatar Vevek Venkatesan
Browse files

input: touchscreen: add fix in driver to support VMAP_STACK



Add fix in hxchipset Himax touchscreen driver, to support
VMAP_STACK security feature and minor correction in Makefile.

Change-Id: I05d05d22088e82c1ab808e86521949a682963174
Signed-off-by: default avatarVevek Venkatesan <vevekv@codeaurora.org>
parent af207bbd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -106,4 +106,4 @@ obj-$(CONFIG_TOUCHSCREEN_ZFORCE) += zforce_ts.o
obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)	+= colibri-vf50-ts.o
obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023)	+= rohm_bu21023.o
obj-$(CONFIG_TOUCHSCREEN_ST)		+= st/
obj-$(CONFIG_TOUCHSCREEN_HIMAX_CHIPSET)»       += hxchipset/
obj-$(CONFIG_TOUCHSCREEN_HIMAX_CHIPSET)	+= hxchipset/
+5 −4
Original line number Diff line number Diff line
@@ -986,7 +986,7 @@ static int himax_touch_get(struct himax_ts_data *ts, uint8_t *buf, int ts_path,
			|| (HX_ESD_RESET_ACTIVATE)
#endif
			) {
			if (!g_core_fp.fp_read_event_stack(buf, 128)) {
			if (!g_core_fp.fp_read_event_stack(buf, HX_REPORT_SZ)) {
				E("%s: can't read data from chip!\n", __func__);
				ts_status = HX_TS_GET_DATA_FAIL;
				goto END_FUNCTION;
@@ -1013,7 +1013,7 @@ static int himax_touch_get(struct himax_ts_data *ts, uint8_t *buf, int ts_path,
		break;
#endif
	case HX_REPORT_COORD_RAWDATA:
		if (!g_core_fp.fp_read_event_stack(buf, 128)) {
		if (!g_core_fp.fp_read_event_stack(buf, HX_REPORT_SZ)) {
			E("%s: can't read data from chip!\n", __func__);
			ts_status = HX_TS_GET_DATA_FAIL;
			goto END_FUNCTION;
@@ -1750,7 +1750,7 @@ int himax_report_data(struct himax_ts_data *ts, int ts_path, int ts_status)
static int himax_ts_operation(struct himax_ts_data *ts, int ts_path, int ts_status)
{
	uint8_t hw_reset_check[2];
	uint8_t buf[128];
	uint8_t buf[HX_REPORT_SZ];

	memset(buf, 0x00, sizeof(buf));
	memset(hw_reset_check, 0x00, sizeof(hw_reset_check));
@@ -1895,7 +1895,7 @@ int himax_fb_register(struct himax_ts_data *ts)
	int ret = 0;

	I(" %s in\n", __func__);
	ts->fb_notif.notifier_call = fb_notifier_callback;
	ts->fb_notif.notifier_call = drm_notifier_callback;
	ret = msm_drm_register_client(&ts->fb_notif);
	if (ret)
		E(" Unable to register fb_notifier: %d\n", ret);
@@ -2230,6 +2230,7 @@ void himax_chip_common_deinit(void)
	kfree(hx_touch_data);
	kfree(ic_data);
	kfree(ts->pdata);
	kfree(ts->report_i2c_data);
	kfree(ts);
	probe_fail_flag = 0;
}
+2 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@
#define HX_FINGER_ON 1
#define HX_FINGER_LEAVE	2

#define HX_REPORT_SZ 128

enum HX_TS_PATH {
	HX_REPORT_COORD = 1,
@@ -363,6 +364,7 @@ struct himax_ts_data {
	struct work_struct ito_test_work;
#endif

	uint8_t *report_i2c_data;
};

struct himax_debug {
+81 −17
Original line number Diff line number Diff line
@@ -168,7 +168,10 @@ int himax_parse_dt(struct himax_ts_data *ts, struct himax_i2c_platform_data *pda
int himax_bus_read(uint8_t command, uint8_t *data, uint32_t length, uint8_t toRetry)
{
	int retry;
	struct i2c_client *client = private_ts->client;
	bool reallocate = false;
	struct himax_ts_data *ts = private_ts;
	uint8_t *buf = ts->report_i2c_data;
	struct i2c_client *client = ts->client;
	struct i2c_msg msg[] = {
		{
			.addr = client->addr,
@@ -180,11 +183,22 @@ int himax_bus_read(uint8_t command, uint8_t *data, uint32_t length, uint8_t toRe
			.addr = client->addr,
			.flags = I2C_M_RD,
			.len = length,
			.buf = data,
			.buf = buf,
		}
	};

	mutex_lock(&private_ts->rw_lock);
	if (length > HX_REPORT_SZ * 2) {
		E("%s: data length too large %d!\n", __func__, length);
		buf = kmalloc(length, GFP_KERNEL);
		if (!buf) {
			E("%s: failed realloc buf %d\n", __func__, length);
			return -EIO;
		}
		reallocate = true;
		msg[1].buf = buf;
	}

	mutex_lock(&ts->rw_lock);

	for (retry = 0; retry < toRetry; retry++) {
		if (i2c_transfer(client->adapter, msg, 2) == 2)
@@ -196,19 +210,26 @@ int himax_bus_read(uint8_t command, uint8_t *data, uint32_t length, uint8_t toRe
	if (retry == toRetry) {
		E("%s: i2c_read_block retry over %d\n", __func__, toRetry);
		i2c_error_count = toRetry;
		mutex_unlock(&private_ts->rw_lock);
		mutex_unlock(&ts->rw_lock);
		return -EIO;
	}

	mutex_unlock(&private_ts->rw_lock);
	memcpy(data, buf, length);
	mutex_unlock(&ts->rw_lock);

	if (reallocate)
		kfree(buf);

	return 0;
}

int himax_bus_write(uint8_t command, uint8_t *data, uint32_t length, uint8_t toRetry)
{
	int retry;
	uint8_t buf[length + 1];
	struct i2c_client *client = private_ts->client;
	bool reallocate = false;
	struct himax_ts_data *ts = private_ts;
	uint8_t *buf = ts->report_i2c_data;
	struct i2c_client *client = ts->client;
	struct i2c_msg msg[] = {
		{
			.addr = client->addr,
@@ -218,7 +239,17 @@ int himax_bus_write(uint8_t command, uint8_t *data, uint32_t length, uint8_t toR
		}
	};

	mutex_lock(&private_ts->rw_lock);
	if (length + 1 > HX_REPORT_SZ * 2) {
		E("%s: data length too large %d!\n", __func__, length + 1);
		buf = kmalloc(length + 1, GFP_KERNEL);
		if (!buf) {
			E("%s: failed realloc buf %d\n", __func__, length + 1);
			return -EIO;
		}
		reallocate = true;
	}

	mutex_lock(&ts->rw_lock);
	buf[0] = command;
	memcpy(buf + 1, data, length);

@@ -232,11 +263,15 @@ int himax_bus_write(uint8_t command, uint8_t *data, uint32_t length, uint8_t toR
	if (retry == toRetry) {
		E("%s: i2c_write_block retry over %d\n", __func__, toRetry);
		i2c_error_count = toRetry;
		mutex_unlock(&private_ts->rw_lock);
		mutex_unlock(&ts->rw_lock);
		return -EIO;
	}

	mutex_unlock(&private_ts->rw_lock);
	mutex_unlock(&ts->rw_lock);

	if (reallocate)
		kfree(buf);

	return 0;
}

@@ -248,7 +283,9 @@ int himax_bus_write_command(uint8_t command, uint8_t toRetry)
int himax_bus_master_write(uint8_t *data, uint32_t length, uint8_t toRetry)
{
	int retry;
	uint8_t buf[length];
	bool reallocate = false;
	struct himax_ts_data *ts = private_ts;
	uint8_t *buf = ts->report_i2c_data;
	struct i2c_client *client = private_ts->client;
	struct i2c_msg msg[] = {
		{
@@ -259,7 +296,17 @@ int himax_bus_master_write(uint8_t *data, uint32_t length, uint8_t toRetry)
		}
	};

	mutex_lock(&private_ts->rw_lock);
	if (length > HX_REPORT_SZ * 2) {
		E("%s: data length too large %d!\n", __func__, length);
		buf = kmalloc(length, GFP_KERNEL);
		if (!buf) {
			E("%s: failed realloc buf %d\n", __func__, length);
			return -EIO;
		}
		reallocate = true;
	}

	mutex_lock(&ts->rw_lock);
	memcpy(buf, data, length);

	for (retry = 0; retry < toRetry; retry++) {
@@ -272,11 +319,15 @@ int himax_bus_master_write(uint8_t *data, uint32_t length, uint8_t toRetry)
	if (retry == toRetry) {
		E("%s: i2c_write_block retry over %d\n", __func__, toRetry);
		i2c_error_count = toRetry;
		mutex_unlock(&private_ts->rw_lock);
		mutex_unlock(&ts->rw_lock);
		return -EIO;
	}

	mutex_unlock(&private_ts->rw_lock);
	mutex_unlock(&ts->rw_lock);

	if (reallocate)
		kfree(buf);

	return 0;
}

@@ -641,7 +692,8 @@ static int himax_common_resume(struct device *dev)

#if defined(CONFIG_DRM)

int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data)
int drm_notifier_callback(struct notifier_block *self,
				unsigned long event, void *data)
{
	struct msm_drm_notifier *evdata = data;
	int *blank;
@@ -676,7 +728,8 @@ int fb_notifier_callback(struct notifier_block *self, unsigned long event, void

#elif defined(CONFIG_FB)

int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data)
int fb_notifier_callback(struct notifier_block *self,
				unsigned long event, void *data)
{
	struct fb_event *evdata = data;
	int *blank;
@@ -741,6 +794,13 @@ int himax_chip_common_probe(struct i2c_client *client, const struct i2c_device_i
	mutex_init(&ts->rw_lock);
	private_ts = ts;

	ts->report_i2c_data = kmalloc(HX_REPORT_SZ * 2, GFP_KERNEL);
	if (ts->report_i2c_data == NULL) {
		E("%s: allocate report_i2c_data failed\n", __func__);
		ret = -ENOMEM;
		goto err_report_i2c_data;
	}

	/*
	 * ts chip initialization is deferred till FB_UNBLACK event;
	 * probe is considered pending till then.
@@ -752,7 +812,12 @@ int himax_chip_common_probe(struct i2c_client *client, const struct i2c_device_i
		goto err_fb_notify_reg_failed;
#endif

	return ret;

err_fb_notify_reg_failed:
	kfree(ts->report_i2c_data);
err_report_i2c_data:
	kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:

@@ -762,7 +827,6 @@ int himax_chip_common_probe(struct i2c_client *client, const struct i2c_device_i
int himax_chip_common_remove(struct i2c_client *client)
{
	himax_chip_common_deinit();

	return 0;
}

+6 −2
Original line number Diff line number Diff line
@@ -125,8 +125,12 @@ extern uint8_t himax_int_gpio_read(int pinnum);
extern int himax_gpio_power_config(struct himax_i2c_platform_data *pdata);


#if defined(CONFIG_DRM) || defined(CONFIG_FB)
	extern int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data);
#if defined(CONFIG_DRM)
	extern int drm_notifier_callback(struct notifier_block *self,
					unsigned long event, void *data);
#elif defined(CONFIG_FB)
	extern int fb_notifier_callback(struct notifier_block *self,
					unsigned long event, void *data);
#endif

#if defined(HX_PLATFOME_DEFINE_KEY)