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

Commit f5872e1b authored by chenx's avatar chenx Committed by Fei Mao
Browse files

input: touchscreen: Update ST touch driver



Update ST touch driver for chip type FTM4

Signed-off-by: default avatarchenx <chenxiang0527@thundersoft.com>
Git-commit: 2e1337310abee3a24bf37fc1211924b7f756af98
Git-repo: https://source.codeaurora.org/quic/la/kernel/msm-4.14/commit/?h=caf/tsoft/STMicroelectronics_ctp_V4.1.0_FTM4&id=2e1337310abee3a24bf37fc1211924b7f756af98


CRs-Fixed: 2210870
Change-Id:Ib0910350cc7a3c0b02222b46cfe28584a8828d25
Signed-off-by: default avatarFei Mao <feim1@codeaurora.org>
parent a8cbba84
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -2,8 +2,24 @@
# STMicroelectronics touchscreen driver configuration
#

#config TOUCHSCREEN_ST
#	bool "STMicroelectronics Touchscreen Driver"
#	default n
#	depends on I2C
#	help
#	  Say Y here if you have a STMicroelectronics Touchscreen.
#	  If unsure, say N.
#

#if TOUCHSCREEN_ST

config TOUCHSCREEN_ST_I2C
	tristate "STMicroelectronics i2c touchscreen"
	#tristate "STMicroelectronics i2c touchscreen"
	string "STMicroelectronics ts directory name"
	default "st"
	depends on TOUCHSCREEN_ST
	help
	 This enables support for ST touch panel over I2C based touchscreens.

#endif
+1 −1
Original line number Diff line number Diff line
@@ -2,4 +2,4 @@
## Makefile for the STMicroelectronics touchscreen driver.
#

obj-$(CONFIG_TOUCHSCREEN_ST_I2C) += fts.o fts_gui.o fts_driver_test.o fts_lib/
obj-$(CONFIG_TOUCHSCREEN_ST) += fts.o fts_gui.o fts_driver_test.o fts_lib/
+3283 −792

File changed.

Preview size limit exceeded, changes collapsed.

+197 −127
Original line number Diff line number Diff line
/*
 * fts.c
 *
 * FTS Capacitive touch screen controller (FingerTipS)
 *
 * Copyright (C) 2016, STMicroelectronics Limited.
 * Authors: AMG(Analog Mems Group)
 * Copyright (C) 2016-2018, STMicroelectronics Limited.
 * Authors: AMG(Analog Mems Group) <marco.cali@st.com>
 *
 *
 *		marco.cali@st.com
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published by
 * the Free Software Foundation.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _LINUX_FTS_I2C_H_
#define _LINUX_FTS_I2C_H_

/*#include <linux/wakelock.h>*/
#include <linux/pm_wakeup.h>

#include "fts_lib/ftsSoftware.h"
#include "fts_lib/ftsHardware.h"
#include "fts_lib/ftsGesture.h"

#define FTS_POWER_ON     1
#define FTS_POWER_OFF    0

/****************** CONFIGURATION SECTION ******************/
/* #define PHONE_KEY */

/* #define PHONE_GESTURE */
/**** CODE CONFIGURATION ****/

#define SCRIPTLESS
#define FTS_TS_DRV_NAME      "fts"
#define FTS_TS_DRV_VERSION   "4.2.14" /* version */

#define SCRIPTLESS /*allow to work in scriptless mode with the GUI*/
#ifdef SCRIPTLESS
#define SCRIPTLESS_DEBUG
/* uncomment this macro definition to print debug
/**
 * uncomment this macro definition to print debug
 * message for script less  support
 */
#endif

#define DRIVER_TEST

#define FW_H_FILE
/* #define FW_H_FILE */ /*include the FW as header file*/
#ifdef FW_H_FILE
	#define FW_SIZE_NAME myArray_size
	#define FW_ARRAY_NAME myArray
#endif

#define LIMITS_H_FILE
/*#define LIMITS_H_FILE*/ /*include the limits file as header file*/
#ifdef LIMITS_H_FILE
	#define LIMITS_SIZE_NAME myArray2_size
	#define LIMITS_ARRAY_NAME myArray2
#endif

#define FTS_TS_DRV_NAME					 "fts"
#define FTS_TS_DRV_VERSION				  "4.1.0"
/**** END ****/


/**** FEATURES USED IN THE IC ***/
#define PHONE_KEY /*enable the keys*/

#define PHONE_GESTURE /*allow to use the gestures*/
#ifdef PHONE_GESTURE
	#define USE_GESTURE_MASK
	#define USE_CUSTOM_GESTURES
#endif

#define USE_ONE_FILE_NODE
/*allow to enable/disable all the features just using one file node*/

#define EDGE_REJ
/*allow edge rej feature (comment to disable)*/

#define CORNER_REJ
/*allow corn rej feature (comment to disable)*/

#define EDGE_PALM_REJ
/*allow edge palm rej feature (comment to disable)*/

#define CHARGER_MODE
/*allow charger mode feature (comment to disable)*/

#define GLOVE_MODE
/*allow glove mode feature (comment to disable)*/

#define VR_MODE
/*allow vr mode feature (comment to disable)*/

#define COVER_MODE
/*allow cover mode feature (comment to disable)*/

#define STYLUS_MODE
/*allow stylus mode feature (comment to disable)*/

#define USE_NOISE_PARAM
/*set noise params during resume (comment to disable)*/

/**** END ****/


/**** PANEL SPECIFICATION ****/
#define X_AXIS_MAX           1440
#define X_AXIS_MIN           0
#define Y_AXIS_MAX						  2560
#define Y_AXIS_MAX           2880
#define Y_AXIS_MIN           0

#define PRESSURE_MIN         0
#define PRESSURE_MAX         127

#define FINGER_MAX						  10
#define STYLUS_MAX						  1
#define TOUCH_ID_MAX				(FINGER_MAX + STYLUS_MAX)
#define TOUCH_ID_MAX         10

#define AREA_MIN             PRESSURE_MIN
#define AREA_MAX             PRESSURE_MAX
/**** END ****/

/*********************************************************/

@@ -82,10 +135,16 @@
/*
 * Configuration mode
 */
#define MODE_NORMAL							0
#define MODE_GESTURE				1
#define MODE_GLOVE				2
#define MODE_SENSEOFF				3
/**
 * bitmask which can assume the value defined as
 * features in ftsSoftware.h or the following values
 */

#define MODE_NOTHING         0x00000000
#define MODE_SENSEON         0x10000000
#define MODE_SENSEOFF        0x20000000
#define FEAT_GESTURE         0x40000000


/*
 * Status Event Field:
@@ -99,10 +158,12 @@
#define FTS_WATER_MODE_ON           0x07
#define FTS_WATER_MODE_OFF          0x08


#define EXP_FN_WORK_DELAY_MS 1000

#define CMD_STR_LEN          32


#ifdef SCRIPTLESS
/*
 * I2C Command Read/Write Function
@@ -113,27 +174,32 @@

#define TSP_BUF_SIZE         4096

/*add by guchong*/
#ifdef PHONE_GESTURE
extern u16 gesture_coordinates_x[GESTURE_COORDS_REPORT_MAX];
extern u16 gesture_coordinates_y[GESTURE_COORDS_REPORT_MAX];
extern int gesture_coords_reported;
extern struct mutex gestureMask_mutex;
#endif

struct fts_i2c_platform_data {
	int (*power)(bool on);
	int irq_gpio;
	int reset_gpio;
	const char *pwr_reg_name;
	const char *bus_reg_name;

};

/*
 * Forward declaration
 */
struct fts_ts_info;
extern char tag[8];

/*
 * Dispatch event handler
 */
typedef unsigned char * (*event_dispatch_handler_t)
typedef void (*event_dispatch_handler_t)
		(struct fts_ts_info *info, unsigned char *data);

/*
 * struct fts_ts_info - FTS capacitive touch screen device information
 * @dev:                  Pointer to the structure device
@@ -141,24 +207,34 @@ typedef unsigned char * (*event_dispatch_handler_t)
 * @input_dev             Input device structure
 * @work                  Work thread
 * @event_wq              Event queue for work thread
 * @cmd_done              Asyncronous command notification
 * @event_dispatch_table  Event dispatch table handlers
 * @fw_version            Firmware version
 * @attrs                 SysFS attributes
 * @mode                  Device operating mode
 * @mode                  Device operating mode (bitmask)
 * @touch_id              Bitmask for touch id (mapped to input slots)
 * @buttons               Bitmask for buttons status
 * @stylus_id             Bitmask for tracking the stylus touches
 * (mapped using the touchId)
 * @timer                 Timer when operating in polling mode
 * @early_suspend         Structure for early suspend functions
 * @power                 Power on/off routine
 * @bdata                 HW info retrived from device tree
 * @pwr_reg               DVDD power regulator
 * @bus_reg               AVDD power regulator
 * @resume_bit            Indicate if screen off/on
 * @fwupdate_stat         Store the result of a fw update triggered by the host
 * @notifier              Used for be notified from a suspend/resume event
 * @sensor_sleep          true susped was called, false resume was called
 * @wakelock              Wake Lock struct
 * @input_report_mutex    mutex for handling the pressure of keys
 * @series of switches    to store the enabling status of a particular
 * feature from the host
 */

struct fts_ts_info {
	struct device            *dev;
	struct i2c_client        *client;
	struct input_dev         *input_dev;

	struct work_struct       work;
	struct work_struct       suspend_work;
	struct work_struct       resume_work;
	struct workqueue_struct  *event_wq;

	struct delayed_work      fwu_work;
@@ -167,19 +243,20 @@ struct fts_ts_info {

	event_dispatch_handler_t *event_dispatch_table;

		unsigned int			  fw_version;
		unsigned int			  config_id;

	struct attribute_group    attrs;

	unsigned int              mode;
	unsigned long             touch_id;
		unsigned int			  buttons;
#ifdef STYLUS_MODE
	unsigned long             stylus_id;
#endif


#ifdef FTS_USE_POLLING_MODE
	struct hrtimer            timer;
#endif


#ifdef SCRIPTLESS
	/*I2C cmd*/
	struct device             *i2c_cmd_dev;
@@ -191,50 +268,41 @@ struct fts_ts_info {
#ifdef DRIVER_TEST
	struct device             *test_cmd_dev;
#endif

	int (*power)(bool on);

	struct fts_i2c_platform_data *bdata;
	struct regulator          *pwr_reg;
	struct regulator          *bus_reg;

		bool fw_force;
		int debug_enable;

	int resume_bit;
	int fwupdate_stat;
		int touch_debug;

	struct notifier_block notifier;
	bool sensor_sleep;
		bool stay_awake;
	struct wakeup_source wakeup_source;

	/* input lock */
	struct mutex input_report_mutex;

		/* switches */
	/*switches for features*/
	int gesture_enabled;
	int glove_enabled;

	int charger_enabled;
	int stylus_enabled;
	int vr_enabled;
	int cover_enabled;
	int edge_rej_enabled;
	int corner_rej_enabled;
	int edge_palm_rej_enabled;
};

typedef enum {
	ERR_ITO_NO_ERR,			/* < 0 No ITO Error */
	ERR_ITO_PANEL_OPEN_FORCE,	/* < 1 Panel Open Force */
	ERR_ITO_PANEL_OPEN_SENSE,	/* < 2 Panel Open Sense */
	ERR_ITO_F2G,			/* < 3 Force short to ground */
	ERR_ITO_S2G,			/* < 4 Sense short to ground */
	ERR_ITO_F2VDD,			/* < 5 Force short to VDD */
	ERR_ITO_S2VDD,			/* < 6 Sense short to VDD */
	ERR_ITO_P2P_FORCE,		/* < 7 Pin to Pin short (Force) */
	ERR_ITO_P2P_SENSE,		/* < 8 Pin to Pin short (Sense) */
} errItoSubTypes_t;
extern struct chipInfo ftsInfo;

int fts_chip_powercycle(struct fts_ts_info *info);
int fts_chip_powercycle2(struct fts_ts_info *info, unsigned long sleep);
int fts_get_fw_version(struct fts_ts_info *info);
extern unsigned int le_to_uint(const unsigned char *ptr);
extern unsigned int be_to_uint(const unsigned char *ptr);
/*int fts_get_fw_version(struct fts_ts_info *info);*/
/*extern unsigned int le_to_uint(const unsigned char *ptr);*/
/*extern unsigned int be_to_uint(const unsigned char *ptr);*/
extern int input_register_notifier_client(struct notifier_block *nb);
extern int input_unregister_notifier_client(struct notifier_block *nb);

@@ -246,4 +314,6 @@ extern struct attribute_group i2c_cmd_attr_group;
extern struct attribute_group	test_cmd_attr_group;
#endif


#endif
+762 −557

File changed.

Preview size limit exceeded, changes collapsed.

Loading