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

Commit 1c9c9664 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "input: touchscreen: nt36xxx: Add callback from drm_panel"

parents 1348be0d 3235976b
Loading
Loading
Loading
Loading
+375 −319
Original line number Diff line number Diff line
@@ -26,10 +26,9 @@
#include <linux/of_gpio.h>
#include <linux/of_irq.h>

#if defined(CONFIG_FB)
#ifdef CONFIG_DRM_MSM
#include <linux/msm_drm_notify.h>
#endif
#if defined(CONFIG_DRM_PANEL)
#include <drm/drm_panel.h>
#elif defined(CONFIG_FB)
#include <linux/notifier.h>
#include <linux/fb.h>
#elif defined(CONFIG_HAS_EARLYSUSPEND)
@@ -61,17 +60,19 @@ extern void nvt_mp_proc_deinit(void);

struct nvt_ts_data *ts;

#if defined(CONFIG_DRM_PANEL)
static struct drm_panel *active_panel;
#endif

#if BOOT_UPDATE_FIRMWARE
static struct workqueue_struct *nvt_fwu_wq;
extern void Boot_Update_Firmware(struct work_struct *work);
#endif

#if defined(CONFIG_FB)
#ifdef _MSM_DRM_NOTIFY_H_
#if defined(CONFIG_DRM_PANEL)
static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data);
#else
#elif defined(CONFIG_FB)
static int nvt_fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data);
#endif
#elif defined(CONFIG_HAS_EARLYSUSPEND)
static void nvt_ts_early_suspend(struct early_suspend *h);
static void nvt_ts_late_resume(struct early_suspend *h);
@@ -106,11 +107,11 @@ const uint16_t gesture_key_array[] = {
static uint8_t bTouchIsAwake = 0;

/*******************************************************
Description:
	Novatek touchscreen irq enable/disable function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen irq enable/disable function.
 *
 * return:
 *     n.a.
 *******************************************************/
static void nvt_irq_enable(bool enable)
{
@@ -133,11 +134,11 @@ static void nvt_irq_enable(bool enable)
}

/*******************************************************
Description:
	Novatek touchscreen i2c read function.

return:
	Executive outcomes. 2---succeed. -5---I/O error
 * Description:
 *     Novatek touchscreen i2c read function.
 *
 * return:
 *     Executive outcomes. 2---succeed. -5---I/O error
 *******************************************************/
int32_t CTP_I2C_READ(struct i2c_client *client, uint16_t address, uint8_t *buf,
		uint16_t len)
@@ -177,11 +178,11 @@ int32_t CTP_I2C_READ(struct i2c_client *client, uint16_t address, uint8_t *buf,
}

/*******************************************************
Description:
	Novatek touchscreen i2c write function.

return:
	Executive outcomes. 1---succeed. -5---I/O error
 * Description:
 *     Novatek touchscreen i2c write function.
 *
 * return:
 *     Executive outcomes. 1---succeed. -5---I/O error
 *******************************************************/
int32_t CTP_I2C_WRITE(struct i2c_client *client, uint16_t address, uint8_t *buf,
		uint16_t len)
@@ -215,12 +216,12 @@ int32_t CTP_I2C_WRITE(struct i2c_client *client, uint16_t address, uint8_t *buf,
}

/*******************************************************
Description:
	Novatek touchscreen set index/page/addr address.

return:
	Executive outcomes. 0---succeed. -5---access fail.
*******************************************************/
 * Description:
 *     Novatek touchscreen set index/page/addr address.
 *
 * return:
 *     Executive outcomes. 0---succeed. -5---access fail.
 ********************************************************/
int32_t nvt_set_page(uint16_t i2c_addr, uint32_t addr)
{
	uint8_t buf[4] = {0};
@@ -233,12 +234,12 @@ int32_t nvt_set_page(uint16_t i2c_addr, uint32_t addr)
}

/*******************************************************
Description:
	Novatek touchscreen reset MCU then into idle mode
    function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen reset MCU then into idle mode
 * function.
 *
 * return:
 *     n.a.
 *******************************************************/
void nvt_sw_reset_idle(void)
{
@@ -253,11 +254,11 @@ void nvt_sw_reset_idle(void)
}

/*******************************************************
Description:
	Novatek touchscreen reset MCU (boot) function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen reset MCU (boot) function.
 *
 * return:
 *     n.a.
 *******************************************************/
void nvt_bootloader_reset(void)
{
@@ -277,11 +278,11 @@ void nvt_bootloader_reset(void)
}

/*******************************************************
Description:
	Novatek touchscreen clear FW status function.

return:
	Executive outcomes. 0---succeed. -1---fail.
 * Description:
 *     Novatek touchscreen clear FW status function.
 *
 * return:
 *     Executive outcomes. 0---succeed. -1---fail.
 *******************************************************/
int32_t nvt_clear_fw_status(void)
{
@@ -318,11 +319,11 @@ int32_t nvt_clear_fw_status(void)
}

/*******************************************************
Description:
	Novatek touchscreen check FW status function.

return:
	Executive outcomes. 0---succeed. -1---failed.
 * Description:
 *     Novatek touchscreen check FW status function.
 *
 * return:
 *     Executive outcomes. 0---succeed. -1---failed.
 *******************************************************/
int32_t nvt_check_fw_status(void)
{
@@ -354,12 +355,12 @@ int32_t nvt_check_fw_status(void)
}

/*******************************************************
Description:
	Novatek touchscreen check FW reset state function.

return:
	Executive outcomes. 0---succeed. -1---failed.
*******************************************************/
 * Description:
 *     Novatek touchscreen check FW reset state function.
 *
 * return:
 *     Executive outcomes. 0---succeed. -1---failed.
 ******************************************************/
int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state)
{
	uint8_t buf[8] = {0};
@@ -392,12 +393,12 @@ int32_t nvt_check_fw_reset_state(RST_COMPLETE_STATE check_reset_state)
}

/*******************************************************
Description:
	Novatek touchscreen get novatek project id information
	function.

return:
	Executive outcomes. 0---success. -1---fail.
 * Description:
 *     Novatek touchscreen get novatek project id information
 * function.
 *
 * return:
 *     Executive outcomes. 0---success. -1---fail.
 *******************************************************/
int32_t nvt_read_pid(void)
{
@@ -479,20 +480,21 @@ int32_t nvt_get_fw_info(void)
}

/*******************************************************
  Create Device Node (Proc Entry)
 * Create Device Node (Proc Entry)
 *******************************************************/
#if NVT_TOUCH_PROC
static struct proc_dir_entry *NVT_proc_entry;
#define DEVICE_NAME	"NVTflash"

/*******************************************************
Description:
	Novatek touchscreen /proc/NVTflash read function.

return:
	Executive outcomes. 2---succeed. -5,-14---failed.
 * Description:
 *     Novatek touchscreen /proc/NVTflash read function.
 *
 * return:
 *     Executive outcomes. 2---succeed. -5,-14---failed.
 *******************************************************/
static ssize_t nvt_flash_read(struct file *file, char __user *buff, size_t count, loff_t *offp)
static ssize_t nvt_flash_read(struct file *file, char __user *buff,
	size_t count, loff_t *offp)
{
	uint8_t str[68] = {0};
	int32_t ret = -1;
@@ -567,11 +569,11 @@ static ssize_t nvt_flash_read(struct file *file, char __user *buff, size_t count
}

/*******************************************************
Description:
	Novatek touchscreen /proc/NVTflash open function.

return:
	Executive outcomes. 0---succeed. -12---failed.
 * Description:
 *     Novatek touchscreen /proc/NVTflash open function.
 *
 * return:
 *     Executive outcomes. 0---succeed. -12---failed.
 *******************************************************/
static int32_t nvt_flash_open(struct inode *inode, struct file *file)
{
@@ -590,11 +592,11 @@ static int32_t nvt_flash_open(struct inode *inode, struct file *file)
}

/*******************************************************
Description:
	Novatek touchscreen /proc/NVTflash close function.

return:
	Executive outcomes. 0---succeed.
 * Description:
 *     Novatek touchscreen /proc/NVTflash close function.
 *
 * return:
 *     Executive outcomes. 0---succeed.
 *******************************************************/
static int32_t nvt_flash_close(struct inode *inode, struct file *file)
{
@@ -612,11 +614,11 @@ static const struct file_operations nvt_flash_fops = {
};

/*******************************************************
Description:
	Novatek touchscreen /proc/NVTflash initial function.

return:
	Executive outcomes. 0---succeed. -12---failed.
 * Description:
 *     Novatek touchscreen /proc/NVTflash initial function.
 *
 * return:
 *     Executive outcomes. 0---succeed. -12---failed.
 *******************************************************/
static int32_t nvt_flash_proc_init(void)
{
@@ -636,11 +638,11 @@ static int32_t nvt_flash_proc_init(void)
}

/*******************************************************
Description:
	Novatek touchscreen /proc/NVTflash deinitial function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen /proc/NVTflash deinitial function.
 *
 * return:
 *     n.a.
 *******************************************************/
static void nvt_flash_proc_deinit(void)
{
@@ -673,11 +675,11 @@ static void nvt_flash_proc_deinit(void)
#define FUNCPAGE_GESTURE         1

/*******************************************************
Description:
	Novatek touchscreen wake up gesture key report function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen wake up gesture key report function.
 *
 * return:
 *     n.a.
 *******************************************************/
void nvt_ts_wakeup_gesture_report(uint8_t gesture_id, uint8_t *data)
{
@@ -762,11 +764,11 @@ void nvt_ts_wakeup_gesture_report(uint8_t gesture_id, uint8_t *data)
#endif

/*******************************************************
Description:
	Novatek touchscreen parse device tree function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen parse device tree function.
 *
 * return:
 *     n.a.
 *******************************************************/
#ifdef CONFIG_OF
static void nvt_parse_dt(struct device *dev)
@@ -792,11 +794,11 @@ static void nvt_parse_dt(struct device *dev)
#endif

/*******************************************************
Description:
	Novatek touchscreen config and request gpio

return:
	Executive outcomes. 0---succeed. not 0---failed.
 * Description:
 *     Novatek touchscreen config and request gpio
 *
 * return:
 *     Executive outcomes. 0---succeed. not 0---failed.
 *******************************************************/
static int nvt_gpio_config(struct nvt_ts_data *ts)
{
@@ -833,11 +835,11 @@ static int nvt_gpio_config(struct nvt_ts_data *ts)
}

/*******************************************************
Description:
	Novatek touchscreen deconfig gpio

return:
	n.a.
 * Description:
 *     Novatek touchscreen deconfig gpio
 *
 * return:
 *     n.a.
 *******************************************************/
static void nvt_gpio_deconfig(struct nvt_ts_data *ts)
{
@@ -901,11 +903,11 @@ static void nvt_esd_check_func(struct work_struct *work)

#define POINT_DATA_LEN 65
/*******************************************************
Description:
	Novatek touchscreen work function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen work function.
 *
 * return:
 *     n.a.
 *******************************************************/
static irqreturn_t nvt_ts_work_func(int irq, void *data)
{
@@ -936,14 +938,6 @@ static irqreturn_t nvt_ts_work_func(int irq, void *data)
		NVT_ERR("CTP_I2C_READ failed.(%d)\n", ret);
		goto XFER_ERROR;
	}
/*
	//--- dump I2C buf ---
	for (i = 0; i < 10; i++) {
		printk("%02X %02X %02X %02X %02X %02X  ",
			point_data[1+i*6], point_data[2+i*6], point_data[3+i*6], point_data[4+i*6], point_data[5+i*6], point_data[6+i*6]);
	}
	printk("\n");
*/

	if (nvt_fw_recovery(point_data)) {
#if NVT_TOUCH_ESD_PROTECT
@@ -1060,11 +1054,11 @@ static irqreturn_t nvt_ts_work_func(int irq, void *data)
}

/*******************************************************
Description:
	Novatek touchscreen check and stop crc reboot loop.

return:
	n.a.
 * Description:
 *     Novatek touchscreen check and stop crc reboot loop.
 *
 * return:
 *     n.a.
*******************************************************/
void nvt_stop_crc_reboot(void)
{
@@ -1115,18 +1109,18 @@ void nvt_stop_crc_reboot(void)
				break;
		}
		if (retry == 0)
			NVT_ERR("CRC auto reboot is not able to be stopped! buf[1]=0x%02X\n", buf[1]);
			NVT_ERR("CRC auto reboot is not able to be stopped!\n");
	}

	return;
}

/*******************************************************
Description:
	Novatek touchscreen check chip version trim function.

return:
	Executive outcomes. 0---NVT IC. -1---not NVT IC.
 * Description:
 *     Novatek touchscreen check chip version trim function.
 *
 * return:
 *     Executive outcomes. 0---NVT IC. -1---not NVT IC.
 *******************************************************/
static int8_t nvt_ts_check_chip_ver_trim(void)
{
@@ -1203,34 +1197,74 @@ static int8_t nvt_ts_check_chip_ver_trim(void)
	return ret;
}

/*******************************************************
Description:
	Novatek touchscreen driver probe function.
#if defined(CONFIG_DRM_PANEL)
static int nvt_ts_check_dt(struct device_node *np)
{
	int i;
	int count;
	struct device_node *node;
	struct drm_panel *panel;

return:
	Executive outcomes. 0---succeed. negative---failed
*******************************************************/
static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_id *id)
	count = of_count_phandle_with_args(np, "panel", NULL);
	if (count <= 0)
		return 0;

	for (i = 0; i < count; i++) {
		node = of_parse_phandle(np, "panel", i);
		panel = of_drm_find_panel(node);
		of_node_put(node);
		if (!IS_ERR(panel)) {
			active_panel = panel;
			pr_err(" %s:find\n", __func__);
			return 0;
		}
	}

	pr_err(" %s: not find\n", __func__);
	return -ENODEV;
}

static int nvt_ts_check_default_tp(struct device_node *dt, const char *prop)
{
	int32_t ret = 0;
#if ((TOUCH_KEY_NUM > 0) || WAKEUP_GESTURE)
	int32_t retry = 0;
#endif
	const char *active_tp[3 + 1] = {NULL, NULL, NULL, NULL};
	int count;
	int ret;

	NVT_LOG("start\n");
	count = of_property_count_strings(dt->parent, prop);
	if (count <= 0 || count > 3)
		return -ENODEV;

	ts = kmalloc(sizeof(struct nvt_ts_data), GFP_KERNEL);
	if (ts == NULL) {
		NVT_ERR("failed to allocated memory for nvt ts data\n");
		return -ENOMEM;
	ret = of_property_read_string_array(dt->parent, prop,
			(const char **)&active_tp, count);
	if (ret < 0) {
		pr_err(" %s:fail to read %s %d\n", __func__, prop, ret);
		return -ENODEV;
	}

	ts->client = client;
	i2c_set_clientdata(client, ts);
	if (!of_device_compatible_match(dt, active_tp)) {
		pr_err(" %s:no match compatible: %s, %s %s\n",
			__func__, active_tp[0]);
		return -ENODEV;
	}

	//---parse dts---
	nvt_parse_dt(&client->dev);
	return 0;
}
#endif

/*******************************************************
 * Description:
 *     Novatek touchscreen driver probe function.
 *
 * return:
 *     Executive outcomes. 0---succeed. negative---failed
 *******************************************************/
static int32_t nvt_ts_late_probe(struct i2c_client *client,
	const struct i2c_device_id *id)
{
	int32_t ret = 0;
#if ((TOUCH_KEY_NUM > 0) || WAKEUP_GESTURE)
	int32_t retry = 0;
#endif
	//---request and config GPIOs---
	ret = nvt_gpio_config(ts);
	if (ret) {
@@ -1238,19 +1272,6 @@ static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_i
		goto err_gpio_config_failed;
	}

	//---check i2c func.---
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		NVT_ERR("i2c_check_functionality failed. (no I2C_FUNC_I2C)\n");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}

	mutex_init(&ts->lock);
	mutex_init(&ts->xbuf_lock);

	// need 10ms delay after POR(power on reset)
	msleep(10);

	//---check chip version trim---
	ret = nvt_ts_check_chip_ver_trim();
	if (ret) {
@@ -1397,33 +1418,6 @@ static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_i
	}
#endif

#if defined(CONFIG_FB)
#ifdef _MSM_DRM_NOTIFY_H_
	ts->drm_notif.notifier_call = nvt_drm_notifier_callback;
	ret = msm_drm_register_client(&ts->drm_notif);
	if(ret) {
		NVT_ERR("register drm_notifier failed. ret=%d\n", ret);
		goto err_register_drm_notif_failed;
	}
#else
	ts->fb_notif.notifier_call = nvt_fb_notifier_callback;
	ret = fb_register_client(&ts->fb_notif);
	if(ret) {
		NVT_ERR("register fb_notifier failed. ret=%d\n", ret);
		goto err_register_fb_notif_failed;
	}
#endif
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = nvt_ts_early_suspend;
	ts->early_suspend.resume = nvt_ts_late_resume;
	ret = register_early_suspend(&ts->early_suspend);
	if(ret) {
		NVT_ERR("register early suspend failed. ret=%d\n", ret);
		goto err_register_early_suspend_failed;
	}
#endif

	bTouchIsAwake = 1;
	NVT_LOG("end\n");

@@ -1431,20 +1425,6 @@ static int32_t nvt_ts_probe(struct i2c_client *client, const struct i2c_device_i

	return 0;

#if defined(CONFIG_FB)
#ifdef _MSM_DRM_NOTIFY_H_
	if (msm_drm_unregister_client(&ts->drm_notif))
		NVT_ERR("Error occurred while unregistering drm_notifier.\n");
err_register_drm_notif_failed:
#else
	if (fb_unregister_client(&ts->fb_notif))
		NVT_ERR("Error occurred while unregistering fb_notifier.\n");
err_register_fb_notif_failed:
#endif
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	unregister_early_suspend(&ts->early_suspend);
err_register_early_suspend_failed:
#endif
#if NVT_TOUCH_MP
nvt_mp_proc_deinit();
err_mp_proc_init_failed:
@@ -1487,38 +1467,114 @@ nvt_flash_proc_deinit();
	}
err_input_dev_alloc_failed:
err_chipvertrim_failed:
	mutex_destroy(&ts->xbuf_lock);
	mutex_destroy(&ts->lock);
err_check_functionality_failed:
	nvt_gpio_deconfig(ts);
err_gpio_config_failed:
	i2c_set_clientdata(client, NULL);
	if (ts) {
		kfree(ts);
		ts = NULL;
	}
	return ret;
}

/*******************************************************
Description:
	Novatek touchscreen driver release function.
 * Description:
 *     Novatek touchscreen driver probe function.
 *
 * return:
 *     Executive outcomes. 0---succeed. negative---failed
 *******************************************************/
static int32_t nvt_ts_probe(struct i2c_client *client,
	const struct i2c_device_id *id)
{
	int32_t ret = 0;
#if defined(CONFIG_DRM)
	struct device_node *dp = client->dev.of_node;
#endif

return:
	Executive outcomes. 0---succeed.
	NVT_LOG("start\n");

#if defined(CONFIG_DRM)
	if (nvt_ts_check_dt(dp)) {
		if (!nvt_ts_check_default_tp(dp, "qcom,i2c-touch-active"))
			ret = -EPROBE_DEFER;
		else
			ret = -ENODEV;

		return ret;
	}
#endif

	ts = devm_kzalloc(&client->dev, sizeof(struct nvt_ts_data), GFP_KERNEL);
	if (ts == NULL) {
		NVT_ERR("failed to allocated memory for nvt ts data\n");
		return -ENOMEM;
	}

	ts->client = client;
	i2c_set_clientdata(client, ts);

	//---parse dts---
	nvt_parse_dt(&client->dev);

	//---check i2c func.---
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		NVT_ERR("i2c_check_functionality failed. (no I2C_FUNC_I2C)\n");
		return  -ENODEV;
	}

	mutex_init(&ts->lock);
	mutex_init(&ts->xbuf_lock);

	ts->id = id;

#if defined(CONFIG_DRM)
	ts->drm_notif.notifier_call = nvt_drm_notifier_callback;

	if (active_panel &&
		drm_panel_notifier_register(active_panel,
			&ts->drm_notif) < 0) {
		NVT_ERR("register notifier failed!\n");
		goto err_register_drm_notif_failed;
	}
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	ts->early_suspend.suspend = nvt_ts_early_suspend;
	ts->early_suspend.resume = nvt_ts_late_resume;
	ret = register_early_suspend(&ts->early_suspend);
	if (ret) {
		NVT_ERR("register early suspend failed. ret=%d\n", ret);
		goto err_register_early_suspend_failed;
	}
#endif

	NVT_LOG("end\n");
	return 0;

#if defined(CONFIG_DRM)
	if (active_panel)
		drm_panel_notifier_unregister(active_panel, &ts->drm_notif);
err_register_drm_notif_failed:

#elif defined(CONFIG_HAS_EARLYSUSPEND)
	unregister_early_suspend(&ts->early_suspend);
err_register_early_suspend_failed:
#endif

	return -ENODEV;
}

/*******************************************************
 * Description:
 *     Novatek touchscreen driver release function.
 *
 * return:
 *     Executive outcomes. 0---succeed.
 *******************************************************/
static int32_t nvt_ts_remove(struct i2c_client *client)
{
	NVT_LOG("Removing driver...\n");

#if defined(CONFIG_FB)
#ifdef _MSM_DRM_NOTIFY_H_
	if (msm_drm_unregister_client(&ts->drm_notif))
		NVT_ERR("Error occurred while unregistering drm_notifier.\n");
#else
#if defined(CONFIG_DRM_PANEL)
	if (active_panel)
		drm_panel_notifier_unregister(active_panel, &ts->drm_notif);
#elif defined(CONFIG_FB)
	if (fb_unregister_client(&ts->fb_notif))
		NVT_ERR("Error occurred while unregistering fb_notifier.\n");
#endif
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	unregister_early_suspend(&ts->early_suspend);
#endif
@@ -1583,14 +1639,12 @@ static void nvt_ts_shutdown(struct i2c_client *client)

	nvt_irq_enable(false);

#if defined(CONFIG_FB)
#ifdef _MSM_DRM_NOTIFY_H_
	if (msm_drm_unregister_client(&ts->drm_notif))
		NVT_ERR("Error occurred while unregistering drm_notifier.\n");
#else
#if defined(CONFIG_DRM_PANEL)
	if (active_panel)
		drm_panel_notifier_unregister(active_panel, &ts->drm_notif);
#elif defined(CONFIG_FB)
	if (fb_unregister_client(&ts->fb_notif))
		NVT_ERR("Error occurred while unregistering fb_notifier.\n");
#endif
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	unregister_early_suspend(&ts->early_suspend);
#endif
@@ -1628,11 +1682,11 @@ static void nvt_ts_shutdown(struct i2c_client *client)
}

/*******************************************************
Description:
	Novatek touchscreen driver suspend function.

return:
	Executive outcomes. 0---succeed.
 * Description:
 *     Novatek touchscreen driver suspend function.
 *
 * return:
 *     Executive outcomes. 0---succeed.
 *******************************************************/
static int32_t nvt_ts_suspend(struct device *dev)
{
@@ -1704,29 +1758,30 @@ static int32_t nvt_ts_suspend(struct device *dev)
}

/*******************************************************
Description:
	Novatek touchscreen driver resume function.

return:
	Executive outcomes. 0---succeed.
 * Description:
 *     Novatek touchscreen driver resume function.
 *
 * return:
 *     Executive outcomes. 0---succeed.
 *******************************************************/
static int32_t nvt_ts_resume(struct device *dev)
{
	if (bTouchIsAwake) {
		NVT_LOG("Touch is already resume\n");
	NVT_LOG("start\n");

	if (bTouchIsAwake || ts->fw_ver == 0) {
		nvt_ts_late_probe(ts->client, ts->id);
		NVT_LOG("nvt_ts_late_probe\n");
		return 0;
	}

	mutex_lock(&ts->lock);

	NVT_LOG("start\n");

	// please make sure display reset(RESX) sequence and mipi dsi cmds sent before this
	// make sure display reset(RESX) sequence and dsi cmds sent before this
#if NVT_TOUCH_SUPPORT_HW_RST
	gpio_set_value(ts->reset_gpio, 1);
#endif

	// need to uncomment the following code for NT36672, NT36772 IC due to no boot-load when RESX/TP_RESX
	// NT36772 IC due to no boot-load when RESX/TP_RESX
	// nvt_bootloader_reset();
	if (nvt_check_fw_reset_state(RESET_STATE_REK)) {
		NVT_ERR("FW is not ready! Try to bootloader reset...\n");
@@ -1753,38 +1808,39 @@ static int32_t nvt_ts_resume(struct device *dev)
	return 0;
}


#if defined(CONFIG_FB)
#ifdef _MSM_DRM_NOTIFY_H_
static int nvt_drm_notifier_callback(struct notifier_block *self, unsigned long event, void *data)
#if defined(CONFIG_DRM_PANEL)
static int nvt_drm_notifier_callback(struct notifier_block *self,
	unsigned long event, void *data)
{
	struct msm_drm_notifier *evdata = data;
	struct drm_panel_notifier *evdata = data;
	int *blank;
	struct nvt_ts_data *ts =
		container_of(self, struct nvt_ts_data, drm_notif);

	if (!evdata || (evdata->id != 0))
	if (!evdata || !evdata->data || !ts)
		return 0;

	if (evdata->data && ts) {
	blank = evdata->data;
		if (event == MSM_DRM_EARLY_EVENT_BLANK) {
			if (*blank == MSM_DRM_BLANK_POWERDOWN) {

	if (event == DRM_PANEL_EARLY_EVENT_BLANK) {
		if (*blank == DRM_PANEL_BLANK_POWERDOWN) {
			NVT_LOG("event=%lu, *blank=%d\n", event, *blank);
			nvt_ts_suspend(&ts->client->dev);
		}
		} else if (event == MSM_DRM_EVENT_BLANK) {
			if (*blank == MSM_DRM_BLANK_UNBLANK) {
	} else if (event == DRM_PANEL_EVENT_BLANK) {
		if (*blank == DRM_PANEL_BLANK_UNBLANK) {
			NVT_LOG("event=%lu, *blank=%d\n", event, *blank);
			nvt_ts_resume(&ts->client->dev);
		}
	}
	}

	return 0;
}
#else
static int nvt_fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data)

#elif defined(CONFIG_FB)

static int nvt_fb_notifier_callback(struct notifier_block *self,
	unsigned long event, void *data)
{
	struct fb_event *evdata = data;
	int *blank;
@@ -1807,14 +1863,14 @@ static int nvt_fb_notifier_callback(struct notifier_block *self, unsigned long e

	return 0;
}
#endif

#elif defined(CONFIG_HAS_EARLYSUSPEND)
/*******************************************************
Description:
	Novatek touchscreen driver early suspend function.

return:
	n.a.
 * Description:
 *     Novatek touchscreen driver early suspend function.
 *
 * return:
 *     n.a.
 *******************************************************/
static void nvt_ts_early_suspend(struct early_suspend *h)
{
@@ -1822,12 +1878,12 @@ static void nvt_ts_early_suspend(struct early_suspend *h)
}

/*******************************************************
Description:
	Novatek touchscreen driver late resume function.

return:
	n.a.
*******************************************************/
 * Description:
 *     Novatek touchscreen driver late resume function.
 *
 * return:
 *     n.a.
 * *******************************************************/
static void nvt_ts_late_resume(struct early_suspend *h)
{
	nvt_ts_resume(ts->client);
@@ -1860,11 +1916,11 @@ static struct i2c_driver nvt_i2c_driver = {
};

/*******************************************************
Description:
	Driver Install function.

return:
	Executive Outcomes. 0---succeed. not 0---failed.
 * Description:
 *     Driver Install function.
 *
 * return:
 *     Executive Outcomes. 0---succeed. not 0---failed.
 ********************************************************/
static int32_t __init nvt_driver_init(void)
{
@@ -1885,19 +1941,19 @@ static int32_t __init nvt_driver_init(void)
}

/*******************************************************
Description:
	Driver uninstall function.

return:
	n.a.
 * Description:
 *     Driver uninstall function.
 *
 * return:
 *     n.a.
 ********************************************************/
static void __exit nvt_driver_exit(void)
{
	i2c_del_driver(&nvt_i2c_driver);
}

//late_initcall(nvt_driver_init);
module_init(nvt_driver_init);
late_initcall(nvt_driver_init);
//module_init(nvt_driver_init);
module_exit(nvt_driver_exit);

MODULE_DESCRIPTION("Novatek Touchscreen Driver");
+4 −5
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ extern const uint16_t touch_key_array[TOUCH_KEY_NUM];
#define TOUCH_FORCE_NUM 1000

/* Enable only when module have tp reset pin and connected to host */
#define NVT_TOUCH_SUPPORT_HW_RST 0
#define NVT_TOUCH_SUPPORT_HW_RST 1

//---Customerized func.---
#define NVT_TOUCH_PROC 1
@@ -95,12 +95,11 @@ struct nvt_ts_data {
	struct delayed_work nvt_fwu_work;
	uint16_t addr;
	int8_t phys[32];
#if defined(CONFIG_FB)
#ifdef _MSM_DRM_NOTIFY_H_
	const struct i2c_device_id *id;
#if defined(CONFIG_DRM_PANEL)
	struct notifier_block drm_notif;
#else
#elif defined(CONFIG_FB)
	struct notifier_block fb_notif;
#endif
#elif defined(CONFIG_HAS_EARLYSUSPEND)
	struct early_suspend early_suspend;
#endif