diff mbox

tsc2007: Add z1 lower threshold

Message ID 1276259816.12874.5.camel@debian (mailing list archive)
State New, archived
Headers show

Commit Message

Richard Röjfors June 11, 2010, 12:36 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index be23780..fffa448 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -75,6 +75,7 @@  struct tsc2007 {
 
 	u16			model;
 	u16			x_plate_ohms;
+	u16			z1_low_threshold;
 
 	bool			pendown;
 	int			irq;
@@ -129,7 +130,7 @@  static u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
 	if (tc->x == MAX_12BIT)
 		tc->x = 0;
 
-	if (likely(tc->x && tc->z1)) {
+	if (likely(tc->x && (tc->z1 > tsc->z1_low_threshold))) {
 		/* compute touch pressure resistance using equation #1 */
 		rt = tc->z2 - tc->z1;
 		rt *= tc->x;
@@ -292,6 +293,7 @@  static int __devinit tsc2007_probe(struct i2c_client *client,
 
 	ts->model             = pdata->model;
 	ts->x_plate_ohms      = pdata->x_plate_ohms;
+	ts->z1_low_threshold  = pdata->z1_low_threshold;
 	ts->get_pendown_state = pdata->get_pendown_state;
 	ts->clear_penirq      = pdata->clear_penirq;
 
diff --git a/include/linux/i2c/tsc2007.h b/include/linux/i2c/tsc2007.h
index c6361fb..75b75fb 100644
--- a/include/linux/i2c/tsc2007.h
+++ b/include/linux/i2c/tsc2007.h
@@ -3,13 +3,27 @@ 
 
 /* linux/i2c/tsc2007.h */
 
+/**
+ * struct tsc2007_platform_data - Platform data of the TSC2007 driver
+ *
+ * @model:		Touch controller model, currently 2003 or 2007.
+ * @x_plate_ohms:	X-Plate resistance.
+ * @z1_low_threshold:	All measured Z1 values below or equal to the threshold
+ *			are regarded as 0.
+ * @get_pendown_state:	Optional callback used to check if the film is touched.
+ *			Can be useful since the pressure value can fluctuate for
+ *			quite a while after lifting the pen.
+ * @clear_penirq:	Optional callback clear 2nd level interrupt source.
+ * @init_platform_hw:	Optional callback to initialise the hardware.
+ * @exit_platform_hw:	Optional callback to de-initialise the hardware.
+ */
 struct tsc2007_platform_data {
-	u16	model;				/* 2007. */
+	u16	model;
 	u16	x_plate_ohms;
+	u16	z1_low_threshold;
 
 	int	(*get_pendown_state)(void);
-	void	(*clear_penirq)(void);		/* If needed, clear 2nd level
-						   interrupt source */
+	void	(*clear_penirq)(void);
 	int	(*init_platform_hw)(void);
 	void	(*exit_platform_hw)(void);
 };