All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch
@ 2015-03-17 14:00 Javier Martinez Canillas
  2015-03-17 14:00 ` [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object Javier Martinez Canillas
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Javier Martinez Canillas @ 2015-03-17 14:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, Chung-yih Wang,
	linux-input, linux-kernel, Javier Martinez Canillas

Hello Dmitry,

This is a resend of the T100 muli-touch object type support for the Atmel
maXTouch touchscreen driver. Old chips use the T9 multi-touch object type
while newer chips use this T100 multi-touch object type which is currenty
not supported by the driver.

Nick Dyer posted his patch to add T100 support a couple of times, the last
one being 3 months ago [0]. Ben suggested using ABS_MT_DISTANCE to handle
fingers hovering and pointed to Chung-yih Wang work [1] in the ChromiumOS
downstream tree. Nick said he would work on that and re-post but he didn't.

Using ABS_MT_DISTANCE to indicate contact hovering is also suggested in
Documentation/input/multi-touch-protocol.txt so I took Nick's patch, rebased
on top of linux-next, refactored a bit to remove some code duplication and
addressed Ben concerns by integrating Chung-yih's work to report hovering
using ABS_MT_DISTANCE.

The series is composed of the following patches:

Nick Dyer (1):
  Input: atmel_mxt_ts - Implement support for T100 touch object

Sjoerd Simons (1):
  Input: atmel_mxt_ts - Split out touchpad initialisation logic

 drivers/input/touchscreen/atmel_mxt_ts.c | 371 +++++++++++++++++++++++++++----
 1 file changed, 330 insertions(+), 41 deletions(-)

Patch #1 adds the support for the T100 touch object and patch #2 is a
cleanup to simplify the driver's input device initialization function.

The series were tested on an Exynos5800 Peach Pi which needs T100 support
and on an Exynos5420 Peach Pit to be sure that T9 is still working.

Best regards,
Javier

[0]: https://lkml.org/lkml/2014/12/9/523
[1]: https://chromium-review.googlesource.com/#/c/219280/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object
  2015-03-17 14:00 [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch Javier Martinez Canillas
@ 2015-03-17 14:00 ` Javier Martinez Canillas
  2015-04-06 20:10   ` Dmitry Torokhov
  2015-08-06 10:51   ` Dirk Behme
  2015-03-17 14:00 ` [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic Javier Martinez Canillas
  2015-03-27 20:29 ` [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch Javier Martinez Canillas
  2 siblings, 2 replies; 11+ messages in thread
From: Javier Martinez Canillas @ 2015-03-17 14:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, Chung-yih Wang,
	linux-input, linux-kernel, Javier Martinez Canillas

From: Nick Dyer <nick.dyer@itdev.co.uk>

Add support for the new T100 object which replaces the previous
T9 multitouch touchscreen object in recent maXTouch devices.
T100 provides improved reporting with selectable auxiliary
information, and a type field for hover/stylus/glove reporting.

The hovering finger support was based on Chung-Yih's work in
the ChromiumOS downstream kernel:

https://chromium-review.googlesource.com/#/c/219280/

Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
Acked-by: Yufeng Shen <miletus@chromium.org>
[javier: Factor out T9 and T100 init functions and rework hover support]
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 323 +++++++++++++++++++++++++++++--
 1 file changed, 302 insertions(+), 21 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 95ee92a91bd2..749371761669 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -79,6 +79,7 @@
 #define MXT_SPT_DIGITIZER_T43		43
 #define MXT_SPT_MESSAGECOUNT_T44	44
 #define MXT_SPT_CTECONFIG_T46		46
+#define MXT_TOUCH_MULTITOUCHSCREEN_T100 100
 
 /* MXT_GEN_MESSAGE_T5 object */
 #define MXT_RPTID_NOMSG		0xff
@@ -185,6 +186,36 @@ struct t9_range {
 #define MXT_RESET_VALUE		0x01
 #define MXT_BACKUP_VALUE	0x55
 
+/* T100 Multiple Touch Touchscreen */
+#define MXT_T100_CTRL		0
+#define MXT_T100_CFG1		1
+#define MXT_T100_TCHAUX		3
+#define MXT_T100_XRANGE		13
+#define MXT_T100_YRANGE		24
+
+#define MXT_T100_CFG_SWITCHXY	(1 << 5)
+
+#define MXT_T100_TCHAUX_VECT	(1 << 0)
+#define MXT_T100_TCHAUX_AMPL	(1 << 1)
+#define MXT_T100_TCHAUX_AREA	(1 << 2)
+
+#define MXT_T100_DETECT		(1 << 7)
+#define MXT_T100_TYPE_MASK	0x70
+
+enum t100_type {
+	MXT_T100_TYPE_FINGER		= 1,
+	MXT_T100_TYPE_PASSIVE_STYLUS	= 2,
+	MXT_T100_TYPE_HOVERING_FINGER	= 4,
+	MXT_T100_TYPE_GLOVE		= 5,
+	MXT_T100_TYPE_LARGE_TOUCH	= 6,
+};
+
+#define MXT_DISTANCE_ACTIVE_TOUCH	0
+#define MXT_DISTANCE_HOVERING		1
+
+#define MXT_TOUCH_MAJOR_DEFAULT	1
+#define MXT_PRESSURE_DEFAULT	1
+
 /* Delay times */
 #define MXT_BACKUP_TIME		50	/* msec */
 #define MXT_RESET_TIME		200	/* msec */
@@ -244,6 +275,9 @@ struct mxt_data {
 	unsigned int max_y;
 	bool in_bootloader;
 	u16 mem_size;
+	u8 t100_aux_ampl;
+	u8 t100_aux_area;
+	u8 t100_aux_vect;
 	u8 max_reportid;
 	u32 config_crc;
 	u32 info_crc;
@@ -253,6 +287,7 @@ struct mxt_data {
 	bool update_input;
 	u8 last_message_count;
 	u8 num_touchids;
+	u8 multitouch;
 
 	/* Cached parameters from object table */
 	u16 T5_address;
@@ -264,6 +299,8 @@ struct mxt_data {
 	u8 T9_reportid_max;
 	u8 T19_reportid;
 	u16 T44_address;
+	u8 T100_reportid_min;
+	u8 T100_reportid_max;
 
 	/* for fw update in bootloader */
 	struct completion bl_completion;
@@ -771,6 +808,108 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
 	data->update_input = true;
 }
 
+static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
+{
+	struct device *dev = &data->client->dev;
+	struct input_dev *input_dev = data->input_dev;
+	int id;
+	u8 status;
+	u8 type = 0;
+	int x;
+	int y;
+	int distance = 0;
+	int tool = 0;
+	u8 major = 0;
+	u8 pressure = 0;
+	u8 orientation = 0;
+
+	id = message[0] - data->T100_reportid_min - 2;
+
+	/* ignore SCRSTATUS events */
+	if (id < 0)
+		return;
+
+	status = message[1];
+	x = (message[3] << 8) | message[2];
+	y = (message[5] << 8) | message[4];
+
+	if (status & MXT_T100_DETECT) {
+		type = (status & MXT_T100_TYPE_MASK) >> 4;
+
+		switch (type) {
+		case MXT_T100_TYPE_HOVERING_FINGER:
+			tool = MT_TOOL_FINGER;
+			distance = MXT_DISTANCE_HOVERING;
+
+			if (data->t100_aux_vect)
+				orientation = message[data->t100_aux_vect];
+
+			break;
+		case MXT_T100_TYPE_FINGER:
+		case MXT_T100_TYPE_GLOVE:
+			tool = MT_TOOL_FINGER;
+			distance = MXT_DISTANCE_ACTIVE_TOUCH;
+
+			if (data->t100_aux_area)
+				major = message[data->t100_aux_area];
+
+			if (data->t100_aux_ampl)
+				pressure = message[data->t100_aux_ampl];
+
+			if (data->t100_aux_vect)
+				orientation = message[data->t100_aux_vect];
+
+			break;
+		case MXT_T100_TYPE_PASSIVE_STYLUS:
+			tool = MT_TOOL_PEN;
+
+			/* Passive stylus is reported with size zero so
+			 * hardcode */
+			major = MXT_TOUCH_MAJOR_DEFAULT;
+
+			if (data->t100_aux_ampl)
+				pressure = message[data->t100_aux_ampl];
+
+			break;
+		case MXT_T100_TYPE_LARGE_TOUCH:
+			/* Ignore suppressed touch */
+			break;
+		default:
+			dev_dbg(dev, "Unexpected T100 type\n");
+			return;
+		}
+	}
+
+	/*
+	 * Values reported should be non-zero if tool is touching the
+	 * device
+	 */
+	if (!pressure && type != MXT_T100_TYPE_HOVERING_FINGER)
+		pressure = MXT_PRESSURE_DEFAULT;
+
+	input_mt_slot(input_dev, id);
+
+	if (status & MXT_T100_DETECT) {
+		dev_dbg(dev, "[%u] type:%u x:%u y:%u a:%02X p:%02X v:%02X\n",
+			id, type, x, y, major, pressure, orientation);
+
+		input_mt_report_slot_state(input_dev, tool, 1);
+		input_report_abs(input_dev, ABS_MT_POSITION_X, x);
+		input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
+		input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, major);
+		input_report_abs(input_dev, ABS_MT_PRESSURE, pressure);
+		input_report_abs(input_dev, ABS_MT_DISTANCE, distance);
+		input_report_abs(input_dev, ABS_MT_ORIENTATION, orientation);
+	} else {
+		dev_dbg(dev, "[%u] release\n", id);
+
+		/* close out slot */
+		input_mt_report_slot_state(input_dev, 0, 0);
+	}
+
+	data->update_input = true;
+}
+
 static int mxt_proc_message(struct mxt_data *data, u8 *message)
 {
 	u8 report_id = message[0];
@@ -789,6 +928,9 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
 	} else if (report_id >= data->T9_reportid_min
 	    && report_id <= data->T9_reportid_max) {
 		mxt_proc_t9_message(data, message);
+	} else if (report_id >= data->T100_reportid_min
+	    && report_id <= data->T100_reportid_max) {
+		mxt_proc_t100_message(data, message);
 	} else if (report_id == data->T19_reportid) {
 		mxt_input_button(data, message);
 		data->update_input = true;
@@ -1411,6 +1553,8 @@ static void mxt_free_object_table(struct mxt_data *data)
 	data->T9_reportid_max = 0;
 	data->T19_reportid = 0;
 	data->T44_address = 0;
+	data->T100_reportid_min = 0;
+	data->T100_reportid_max = 0;
 	data->max_reportid = 0;
 }
 
@@ -1487,6 +1631,7 @@ static int mxt_get_object_table(struct mxt_data *data)
 			data->T7_address = object->start_address;
 			break;
 		case MXT_TOUCH_MULTI_T9:
+			data->multitouch = MXT_TOUCH_MULTI_T9;
 			data->T9_reportid_min = min_id;
 			data->T9_reportid_max = max_id;
 			data->num_touchids = object->num_report_ids
@@ -1498,6 +1643,13 @@ static int mxt_get_object_table(struct mxt_data *data)
 		case MXT_SPT_GPIOPWM_T19:
 			data->T19_reportid = min_id;
 			break;
+		case MXT_TOUCH_MULTITOUCHSCREEN_T100:
+			data->multitouch = MXT_TOUCH_MULTITOUCHSCREEN_T100;
+			data->T100_reportid_min = min_id;
+			data->T100_reportid_max = max_id;
+			/* first two report IDs reserved */
+			data->num_touchids = object->num_report_ids - 2;
+			break;
 		}
 
 		end_address = object->start_address
@@ -1582,10 +1734,88 @@ static int mxt_read_t9_resolution(struct mxt_data *data)
 	return 0;
 }
 
+static int mxt_read_t100_config(struct mxt_data *data)
+{
+	struct i2c_client *client = data->client;
+	int error;
+	struct mxt_object *object;
+	u16 range_x, range_y;
+	u8 cfg, tchaux;
+	u8 aux;
+
+	object = mxt_get_object(data, MXT_TOUCH_MULTITOUCHSCREEN_T100);
+	if (!object)
+		return -EINVAL;
+
+	error = __mxt_read_reg(client,
+			       object->start_address + MXT_T100_XRANGE,
+			       sizeof(range_x), &range_x);
+	if (error)
+		return error;
+
+	le16_to_cpus(range_x);
+
+	error = __mxt_read_reg(client,
+			       object->start_address + MXT_T100_YRANGE,
+			       sizeof(range_y), &range_y);
+	if (error)
+		return error;
+
+	le16_to_cpus(range_y);
+
+	error =  __mxt_read_reg(client,
+				object->start_address + MXT_T100_CFG1,
+				1, &cfg);
+	if (error)
+		return error;
+
+	error =  __mxt_read_reg(client,
+				object->start_address + MXT_T100_TCHAUX,
+				1, &tchaux);
+	if (error)
+		return error;
+
+	/* Handle default values */
+	if (range_x == 0)
+		range_x = 1023;
+
+	if (range_y == 0)
+		range_y = 1023;
+
+	if (cfg & MXT_T100_CFG_SWITCHXY) {
+		data->max_x = range_y;
+		data->max_y = range_x;
+	} else {
+		data->max_x = range_x;
+		data->max_y = range_y;
+	}
+
+	/* allocate aux bytes */
+	aux = 6;
+
+	if (tchaux & MXT_T100_TCHAUX_VECT)
+		data->t100_aux_vect = aux++;
+
+	if (tchaux & MXT_T100_TCHAUX_AMPL)
+		data->t100_aux_ampl = aux++;
+
+	if (tchaux & MXT_T100_TCHAUX_AREA)
+		data->t100_aux_area = aux++;
+
+	dev_dbg(&client->dev,
+		"T100 aux mappings vect:%u ampl:%u area:%u\n",
+		data->t100_aux_vect, data->t100_aux_ampl, data->t100_aux_area);
+
+	dev_info(&client->dev,
+		 "T100 Touchscreen size X%uY%u\n", data->max_x, data->max_y);
+
+	return 0;
+}
+
 static int mxt_input_open(struct input_dev *dev);
 static void mxt_input_close(struct input_dev *dev);
 
-static int mxt_initialize_t9_input_device(struct mxt_data *data)
+static int mxt_initialize_input_device(struct mxt_data *data)
 {
 	struct device *dev = &data->client->dev;
 	const struct mxt_platform_data *pdata = data->pdata;
@@ -1595,9 +1825,23 @@ static int mxt_initialize_t9_input_device(struct mxt_data *data)
 	unsigned int mt_flags = 0;
 	int i;
 
-	error = mxt_read_t9_resolution(data);
-	if (error)
-		dev_warn(dev, "Failed to initialize T9 resolution\n");
+	switch (data->multitouch) {
+	case MXT_TOUCH_MULTI_T9:
+		num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1;
+		error = mxt_read_t9_resolution(data);
+		if (error)
+			dev_warn(dev, "Failed to initialize T9 resolution\n");
+		break;
+	case MXT_TOUCH_MULTITOUCHSCREEN_T100:
+		num_mt_slots = data->num_touchids;
+		error = mxt_read_t100_config(data);
+		if (error)
+			dev_warn(dev, "Failed to read T100 config\n");
+		break;
+	default:
+		dev_err(dev, "Invalid multitouch object\n");
+		return -EINVAL;
+	}
 
 	input_dev = input_allocate_device();
 	if (!input_dev) {
@@ -1612,9 +1856,8 @@ static int mxt_initialize_t9_input_device(struct mxt_data *data)
 	input_dev->open = mxt_input_open;
 	input_dev->close = mxt_input_close;
 
-	__set_bit(EV_ABS, input_dev->evbit);
-	__set_bit(EV_KEY, input_dev->evbit);
-	__set_bit(BTN_TOUCH, input_dev->keybit);
+	set_bit(EV_ABS, input_dev->evbit);
+	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
 
 	if (pdata->t19_num_keys) {
 		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
@@ -1641,25 +1884,61 @@ static int mxt_initialize_t9_input_device(struct mxt_data *data)
 			     0, data->max_x, 0, 0);
 	input_set_abs_params(input_dev, ABS_Y,
 			     0, data->max_y, 0, 0);
-	input_set_abs_params(input_dev, ABS_PRESSURE,
-			     0, 255, 0, 0);
+
+	if (data->multitouch == MXT_TOUCH_MULTI_T9 ||
+	    (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+	     data->t100_aux_ampl))
+		input_set_abs_params(input_dev, ABS_PRESSURE,
+				     0, 255, 0, 0);
 
 	/* For multi touch */
-	num_mt_slots = data->T9_reportid_max - data->T9_reportid_min + 1;
 	error = input_mt_init_slots(input_dev, num_mt_slots, mt_flags);
 	if (error) {
 		dev_err(dev, "Error %d initialising slots\n", error);
 		goto err_free_mem;
 	}
 
-	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
-			     0, MXT_MAX_AREA, 0, 0);
+	if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100) {
+		input_set_abs_params(input_dev, ABS_MT_TOOL_TYPE, 0,
+				     MT_TOOL_MAX, 0, 0);
+
+		input_set_abs_params(input_dev, ABS_MT_DISTANCE,
+				     MXT_DISTANCE_ACTIVE_TOUCH,
+				     MXT_DISTANCE_HOVERING,
+				     0, 0);
+	}
+
 	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
 			     0, data->max_x, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
 			     0, data->max_y, 0, 0);
-	input_set_abs_params(input_dev, ABS_MT_PRESSURE,
-			     0, 255, 0, 0);
+
+	if (data->multitouch == MXT_TOUCH_MULTI_T9 ||
+	    (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+	     data->t100_aux_area))
+		input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
+				     0, MXT_MAX_AREA, 0, 0);
+
+	if (data->multitouch == MXT_TOUCH_MULTI_T9 ||
+	    (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+	     data->t100_aux_ampl))
+		input_set_abs_params(input_dev, ABS_MT_PRESSURE,
+				     0, 255, 0, 0);
+
+	if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+	    data->t100_aux_vect)
+		input_set_abs_params(input_dev, ABS_MT_ORIENTATION,
+				     0, 255, 0, 0);
+
+	if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+	    data->t100_aux_ampl)
+		input_set_abs_params(input_dev, ABS_MT_PRESSURE,
+				     0, 255, 0, 0);
+
+	if (data->multitouch == MXT_TOUCH_MULTITOUCHSCREEN_T100 &&
+	    data->t100_aux_vect)
+		input_set_abs_params(input_dev, ABS_MT_ORIENTATION,
+				     0, 255, 0, 0);
 
 	input_set_drvdata(input_dev, data);
 
@@ -1765,9 +2044,13 @@ static int mxt_configure_objects(struct mxt_data *data,
 			dev_warn(dev, "Error %d updating config\n", error);
 	}
 
-	error = mxt_initialize_t9_input_device(data);
-	if (error)
-		return error;
+	if (data->multitouch) {
+		error = mxt_initialize_input_device(data);
+		if (error)
+			return error;
+	} else {
+		dev_warn(dev, "No touch object detected\n");
+	}
 
 	dev_info(dev,
 		 "Family: %u Variant: %u Firmware V%u.%u.%02X Objects: %u\n",
@@ -2044,15 +2327,13 @@ static const struct attribute_group mxt_attr_group = {
 static void mxt_start(struct mxt_data *data)
 {
 	/* Touch enable */
-	mxt_write_object(data,
-			MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0x83);
+	mxt_write_object(data, data->multitouch, MXT_TOUCH_CTRL, 0x83);
 }
 
 static void mxt_stop(struct mxt_data *data)
 {
 	/* Touch disable */
-	mxt_write_object(data,
-			MXT_TOUCH_MULTI_T9, MXT_TOUCH_CTRL, 0);
+	mxt_write_object(data, data->multitouch, MXT_TOUCH_CTRL, 0);
 }
 
 static int mxt_input_open(struct input_dev *dev)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic
  2015-03-17 14:00 [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch Javier Martinez Canillas
  2015-03-17 14:00 ` [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object Javier Martinez Canillas
@ 2015-03-17 14:00 ` Javier Martinez Canillas
  2015-04-06 20:30   ` Dmitry Torokhov
  2015-03-27 20:29 ` [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch Javier Martinez Canillas
  2 siblings, 1 reply; 11+ messages in thread
From: Javier Martinez Canillas @ 2015-03-17 14:00 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, Chung-yih Wang,
	linux-input, linux-kernel, Javier Martinez Canillas

From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

If the "linux,gpio-keymap" DT property is defined, the T19 keys are configured
and the device is setup as a touchpad rather than a touchscreen. The logic is
part of the input device initialization routine but it can be factored out to
its own function to simplify the former.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 48 +++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 749371761669..e2e55cf857cb 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1815,15 +1815,40 @@ static int mxt_read_t100_config(struct mxt_data *data)
 static int mxt_input_open(struct input_dev *dev);
 static void mxt_input_close(struct input_dev *dev);
 
+static bool mxt_initialize_t19(struct input_dev *input_dev,
+			       struct mxt_data *data)
+{
+	const struct mxt_platform_data *pdata = data->pdata;
+	int i;
+
+	if (pdata->t19_num_keys) {
+		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
+
+		for (i = 0; i < pdata->t19_num_keys; i++)
+			if (pdata->t19_keymap[i] != KEY_RESERVED)
+				input_set_capability(input_dev, EV_KEY,
+						     pdata->t19_keymap[i]);
+
+		input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
+		input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
+		input_abs_set_res(input_dev, ABS_MT_POSITION_X,
+				  MXT_PIXELS_PER_MM);
+		input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
+				  MXT_PIXELS_PER_MM);
+
+		input_dev->name = "Atmel maXTouch Touchpad";
+		return true;
+	}
+	return false;
+}
+
 static int mxt_initialize_input_device(struct mxt_data *data)
 {
 	struct device *dev = &data->client->dev;
-	const struct mxt_platform_data *pdata = data->pdata;
 	struct input_dev *input_dev;
 	int error;
 	unsigned int num_mt_slots;
 	unsigned int mt_flags = 0;
-	int i;
 
 	switch (data->multitouch) {
 	case MXT_TOUCH_MULTI_T9:
@@ -1859,26 +1884,9 @@ static int mxt_initialize_input_device(struct mxt_data *data)
 	set_bit(EV_ABS, input_dev->evbit);
 	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
 
-	if (pdata->t19_num_keys) {
-		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
-
-		for (i = 0; i < pdata->t19_num_keys; i++)
-			if (pdata->t19_keymap[i] != KEY_RESERVED)
-				input_set_capability(input_dev, EV_KEY,
-						     pdata->t19_keymap[i]);
-
+	if (mxt_initialize_t19(input_dev, data))
 		mt_flags |= INPUT_MT_POINTER;
 
-		input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
-		input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
-		input_abs_set_res(input_dev, ABS_MT_POSITION_X,
-				  MXT_PIXELS_PER_MM);
-		input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
-				  MXT_PIXELS_PER_MM);
-
-		input_dev->name = "Atmel maXTouch Touchpad";
-	}
-
 	/* For single touch */
 	input_set_abs_params(input_dev, ABS_X,
 			     0, data->max_x, 0, 0);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch
  2015-03-17 14:00 [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch Javier Martinez Canillas
  2015-03-17 14:00 ` [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object Javier Martinez Canillas
  2015-03-17 14:00 ` [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic Javier Martinez Canillas
@ 2015-03-27 20:29 ` Javier Martinez Canillas
  2 siblings, 0 replies; 11+ messages in thread
From: Javier Martinez Canillas @ 2015-03-27 20:29 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, Chung-yih Wang,
	linux-input, linux-kernel

Hello Dmitry,

On 03/17/2015 03:00 PM, Javier Martinez Canillas wrote:
> 
> This is a resend of the T100 muli-touch object type support for the Atmel
> maXTouch touchscreen driver. Old chips use the T9 multi-touch object type
> while newer chips use this T100 multi-touch object type which is currenty
> not supported by the driver.
> 
> Nick Dyer posted his patch to add T100 support a couple of times, the last
> one being 3 months ago [0]. Ben suggested using ABS_MT_DISTANCE to handle
> fingers hovering and pointed to Chung-yih Wang work [1] in the ChromiumOS
> downstream tree. Nick said he would work on that and re-post but he didn't.
> 
> Using ABS_MT_DISTANCE to indicate contact hovering is also suggested in
> Documentation/input/multi-touch-protocol.txt so I took Nick's patch, rebased
> on top of linux-next, refactored a bit to remove some code duplication and
> addressed Ben concerns by integrating Chung-yih's work to report hovering
> using ABS_MT_DISTANCE.
> 
> The series is composed of the following patches:
> 
> Nick Dyer (1):
>   Input: atmel_mxt_ts - Implement support for T100 touch object
> 
> Sjoerd Simons (1):
>   Input: atmel_mxt_ts - Split out touchpad initialisation logic
> 
>  drivers/input/touchscreen/atmel_mxt_ts.c | 371 +++++++++++++++++++++++++++----
>  1 file changed, 330 insertions(+), 41 deletions(-)
> 
> Patch #1 adds the support for the T100 touch object and patch #2 is a
> cleanup to simplify the driver's input device initialization function.
> 
> The series were tested on an Exynos5800 Peach Pi which needs T100 support
> and on an Exynos5420 Peach Pit to be sure that T9 is still working.
> 

Any comments about this series?

Best regards,
Javier


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object
  2015-03-17 14:00 ` [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object Javier Martinez Canillas
@ 2015-04-06 20:10   ` Dmitry Torokhov
  2015-08-06 10:51   ` Dirk Behme
  1 sibling, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-04-06 20:10 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, Chung-yih Wang,
	linux-input, linux-kernel

Hi Javier,

On Tue, Mar 17, 2015 at 03:00:45PM +0100, Javier Martinez Canillas wrote:
> From: Nick Dyer <nick.dyer@itdev.co.uk>
> 
> Add support for the new T100 object which replaces the previous
> T9 multitouch touchscreen object in recent maXTouch devices.
> T100 provides improved reporting with selectable auxiliary
> information, and a type field for hover/stylus/glove reporting.
> 
> The hovering finger support was based on Chung-Yih's work in
> the ChromiumOS downstream kernel:
> 
> https://chromium-review.googlesource.com/#/c/219280/
> 
> Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
> Acked-by: Yufeng Shen <miletus@chromium.org>
> [javier: Factor out T9 and T100 init functions and rework hover support]
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> ---
>  drivers/input/touchscreen/atmel_mxt_ts.c | 323 +++++++++++++++++++++++++++++--
>  1 file changed, 302 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index 95ee92a91bd2..749371761669 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -79,6 +79,7 @@
>  #define MXT_SPT_DIGITIZER_T43		43
>  #define MXT_SPT_MESSAGECOUNT_T44	44
>  #define MXT_SPT_CTECONFIG_T46		46
> +#define MXT_TOUCH_MULTITOUCHSCREEN_T100 100
>  
>  /* MXT_GEN_MESSAGE_T5 object */
>  #define MXT_RPTID_NOMSG		0xff
> @@ -185,6 +186,36 @@ struct t9_range {
>  #define MXT_RESET_VALUE		0x01
>  #define MXT_BACKUP_VALUE	0x55
>  
> +/* T100 Multiple Touch Touchscreen */
> +#define MXT_T100_CTRL		0
> +#define MXT_T100_CFG1		1
> +#define MXT_T100_TCHAUX		3
> +#define MXT_T100_XRANGE		13
> +#define MXT_T100_YRANGE		24
> +
> +#define MXT_T100_CFG_SWITCHXY	(1 << 5)
> +
> +#define MXT_T100_TCHAUX_VECT	(1 << 0)
> +#define MXT_T100_TCHAUX_AMPL	(1 << 1)
> +#define MXT_T100_TCHAUX_AREA	(1 << 2)
> +
> +#define MXT_T100_DETECT		(1 << 7)

I'll change these to BIT(x).

> +#define MXT_T100_TYPE_MASK	0x70
> +
> +enum t100_type {
> +	MXT_T100_TYPE_FINGER		= 1,
> +	MXT_T100_TYPE_PASSIVE_STYLUS	= 2,
> +	MXT_T100_TYPE_HOVERING_FINGER	= 4,
> +	MXT_T100_TYPE_GLOVE		= 5,
> +	MXT_T100_TYPE_LARGE_TOUCH	= 6,
> +};
> +
> +#define MXT_DISTANCE_ACTIVE_TOUCH	0
> +#define MXT_DISTANCE_HOVERING		1
> +
> +#define MXT_TOUCH_MAJOR_DEFAULT	1
> +#define MXT_PRESSURE_DEFAULT	1
> +
>  /* Delay times */
>  #define MXT_BACKUP_TIME		50	/* msec */
>  #define MXT_RESET_TIME		200	/* msec */
> @@ -244,6 +275,9 @@ struct mxt_data {
>  	unsigned int max_y;
>  	bool in_bootloader;
>  	u16 mem_size;
> +	u8 t100_aux_ampl;
> +	u8 t100_aux_area;
> +	u8 t100_aux_vect;
>  	u8 max_reportid;
>  	u32 config_crc;
>  	u32 info_crc;
> @@ -253,6 +287,7 @@ struct mxt_data {
>  	bool update_input;
>  	u8 last_message_count;
>  	u8 num_touchids;
> +	u8 multitouch;
>  
>  	/* Cached parameters from object table */
>  	u16 T5_address;
> @@ -264,6 +299,8 @@ struct mxt_data {
>  	u8 T9_reportid_max;
>  	u8 T19_reportid;
>  	u16 T44_address;
> +	u8 T100_reportid_min;
> +	u8 T100_reportid_max;
>  
>  	/* for fw update in bootloader */
>  	struct completion bl_completion;
> @@ -771,6 +808,108 @@ static void mxt_proc_t9_message(struct mxt_data *data, u8 *message)
>  	data->update_input = true;
>  }
>  
> +static void mxt_proc_t100_message(struct mxt_data *data, u8 *message)
> +{
> +	struct device *dev = &data->client->dev;
> +	struct input_dev *input_dev = data->input_dev;
> +	int id;
> +	u8 status;
> +	u8 type = 0;
> +	int x;
> +	int y;
> +	int distance = 0;
> +	int tool = 0;
> +	u8 major = 0;
> +	u8 pressure = 0;
> +	u8 orientation = 0;
> +
> +	id = message[0] - data->T100_reportid_min - 2;
> +
> +	/* ignore SCRSTATUS events */
> +	if (id < 0)
> +		return;
> +
> +	status = message[1];
> +	x = (message[3] << 8) | message[2];
> +	y = (message[5] << 8) | message[4];

This looks like job for get_unaligned_le16().

> +
> +	if (status & MXT_T100_DETECT) {
> +		type = (status & MXT_T100_TYPE_MASK) >> 4;
> +
> +		switch (type) {
> +		case MXT_T100_TYPE_HOVERING_FINGER:
> +			tool = MT_TOOL_FINGER;
> +			distance = MXT_DISTANCE_HOVERING;
> +
> +			if (data->t100_aux_vect)
> +				orientation = message[data->t100_aux_vect];
> +
> +			break;
> +		case MXT_T100_TYPE_FINGER:
> +		case MXT_T100_TYPE_GLOVE:
> +			tool = MT_TOOL_FINGER;
> +			distance = MXT_DISTANCE_ACTIVE_TOUCH;
> +
> +			if (data->t100_aux_area)
> +				major = message[data->t100_aux_area];
> +
> +			if (data->t100_aux_ampl)
> +				pressure = message[data->t100_aux_ampl];
> +
> +			if (data->t100_aux_vect)
> +				orientation = message[data->t100_aux_vect];
> +
> +			break;
> +		case MXT_T100_TYPE_PASSIVE_STYLUS:
> +			tool = MT_TOOL_PEN;
> +
> +			/* Passive stylus is reported with size zero so
> +			 * hardcode */
> +			major = MXT_TOUCH_MAJOR_DEFAULT;
> +
> +			if (data->t100_aux_ampl)
> +				pressure = message[data->t100_aux_ampl];
> +
> +			break;
> +		case MXT_T100_TYPE_LARGE_TOUCH:
> +			/* Ignore suppressed touch */
> +			break;
> +		default:
> +			dev_dbg(dev, "Unexpected T100 type\n");
> +			return;
> +		}
> +	}
> +
> +	/*
> +	 * Values reported should be non-zero if tool is touching the
> +	 * device
> +	 */
> +	if (!pressure && type != MXT_T100_TYPE_HOVERING_FINGER)
> +		pressure = MXT_PRESSURE_DEFAULT;
> +
> +	input_mt_slot(input_dev, id);
> +
> +	if (status & MXT_T100_DETECT) {
> +		dev_dbg(dev, "[%u] type:%u x:%u y:%u a:%02X p:%02X v:%02X\n",
> +			id, type, x, y, major, pressure, orientation);
> +
> +		input_mt_report_slot_state(input_dev, tool, 1);
> +		input_report_abs(input_dev, ABS_MT_POSITION_X, x);
> +		input_report_abs(input_dev, ABS_MT_POSITION_Y, y);
> +		input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, major);
> +		input_report_abs(input_dev, ABS_MT_PRESSURE, pressure);
> +		input_report_abs(input_dev, ABS_MT_DISTANCE, distance);
> +		input_report_abs(input_dev, ABS_MT_ORIENTATION, orientation);
> +	} else {
> +		dev_dbg(dev, "[%u] release\n", id);
> +
> +		/* close out slot */
> +		input_mt_report_slot_state(input_dev, 0, 0);
> +	}
> +
> +	data->update_input = true;
> +}
> +
>  static int mxt_proc_message(struct mxt_data *data, u8 *message)
>  {
>  	u8 report_id = message[0];
> @@ -789,6 +928,9 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message)
>  	} else if (report_id >= data->T9_reportid_min
>  	    && report_id <= data->T9_reportid_max) {
>  		mxt_proc_t9_message(data, message);
> +	} else if (report_id >= data->T100_reportid_min
> +	    && report_id <= data->T100_reportid_max) {
> +		mxt_proc_t100_message(data, message);
>  	} else if (report_id == data->T19_reportid) {
>  		mxt_input_button(data, message);
>  		data->update_input = true;
> @@ -1411,6 +1553,8 @@ static void mxt_free_object_table(struct mxt_data *data)
>  	data->T9_reportid_max = 0;
>  	data->T19_reportid = 0;
>  	data->T44_address = 0;
> +	data->T100_reportid_min = 0;
> +	data->T100_reportid_max = 0;
>  	data->max_reportid = 0;
>  }
>  
> @@ -1487,6 +1631,7 @@ static int mxt_get_object_table(struct mxt_data *data)
>  			data->T7_address = object->start_address;
>  			break;
>  		case MXT_TOUCH_MULTI_T9:
> +			data->multitouch = MXT_TOUCH_MULTI_T9;
>  			data->T9_reportid_min = min_id;
>  			data->T9_reportid_max = max_id;
>  			data->num_touchids = object->num_report_ids
> @@ -1498,6 +1643,13 @@ static int mxt_get_object_table(struct mxt_data *data)
>  		case MXT_SPT_GPIOPWM_T19:
>  			data->T19_reportid = min_id;
>  			break;
> +		case MXT_TOUCH_MULTITOUCHSCREEN_T100:
> +			data->multitouch = MXT_TOUCH_MULTITOUCHSCREEN_T100;
> +			data->T100_reportid_min = min_id;
> +			data->T100_reportid_max = max_id;
> +			/* first two report IDs reserved */
> +			data->num_touchids = object->num_report_ids - 2;
> +			break;
>  		}
>  
>  		end_address = object->start_address
> @@ -1582,10 +1734,88 @@ static int mxt_read_t9_resolution(struct mxt_data *data)
>  	return 0;
>  }
>  
> +static int mxt_read_t100_config(struct mxt_data *data)
> +{
> +	struct i2c_client *client = data->client;
> +	int error;
> +	struct mxt_object *object;
> +	u16 range_x, range_y;
> +	u8 cfg, tchaux;
> +	u8 aux;
> +
> +	object = mxt_get_object(data, MXT_TOUCH_MULTITOUCHSCREEN_T100);
> +	if (!object)
> +		return -EINVAL;
> +
> +	error = __mxt_read_reg(client,
> +			       object->start_address + MXT_T100_XRANGE,
> +			       sizeof(range_x), &range_x);
> +	if (error)
> +		return error;
> +
> +	le16_to_cpus(range_x);

Needs to be "le16_to_cpus(&range_x);" - note "&" or it will likely fail
compilation on big endians, or won't work right there.

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic
  2015-03-17 14:00 ` [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic Javier Martinez Canillas
@ 2015-04-06 20:30   ` Dmitry Torokhov
  0 siblings, 0 replies; 11+ messages in thread
From: Dmitry Torokhov @ 2015-04-06 20:30 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, Chung-yih Wang,
	linux-input, linux-kernel

On Tue, Mar 17, 2015 at 03:00:46PM +0100, Javier Martinez Canillas wrote:
> From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> 
> If the "linux,gpio-keymap" DT property is defined, the T19 keys are configured
> and the device is setup as a touchpad rather than a touchscreen. The logic is
> part of the input device initialization routine but it can be factored out to
> its own function to simplify the former.
> 
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> ---
>  drivers/input/touchscreen/atmel_mxt_ts.c | 48 +++++++++++++++++++-------------
>  1 file changed, 28 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index 749371761669..e2e55cf857cb 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -1815,15 +1815,40 @@ static int mxt_read_t100_config(struct mxt_data *data)
>  static int mxt_input_open(struct input_dev *dev);
>  static void mxt_input_close(struct input_dev *dev);
>  
> +static bool mxt_initialize_t19(struct input_dev *input_dev,
> +			       struct mxt_data *data)

I renamed it as mxt_set_up_as_touchpad() and made void, otherwise
applied.

Thanks.

> +{
> +	const struct mxt_platform_data *pdata = data->pdata;
> +	int i;
> +
> +	if (pdata->t19_num_keys) {
> +		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
> +
> +		for (i = 0; i < pdata->t19_num_keys; i++)
> +			if (pdata->t19_keymap[i] != KEY_RESERVED)
> +				input_set_capability(input_dev, EV_KEY,
> +						     pdata->t19_keymap[i]);
> +
> +		input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
> +		input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
> +		input_abs_set_res(input_dev, ABS_MT_POSITION_X,
> +				  MXT_PIXELS_PER_MM);
> +		input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
> +				  MXT_PIXELS_PER_MM);
> +
> +		input_dev->name = "Atmel maXTouch Touchpad";
> +		return true;
> +	}
> +	return false;
> +}
> +
>  static int mxt_initialize_input_device(struct mxt_data *data)
>  {
>  	struct device *dev = &data->client->dev;
> -	const struct mxt_platform_data *pdata = data->pdata;
>  	struct input_dev *input_dev;
>  	int error;
>  	unsigned int num_mt_slots;
>  	unsigned int mt_flags = 0;
> -	int i;
>  
>  	switch (data->multitouch) {
>  	case MXT_TOUCH_MULTI_T9:
> @@ -1859,26 +1884,9 @@ static int mxt_initialize_input_device(struct mxt_data *data)
>  	set_bit(EV_ABS, input_dev->evbit);
>  	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
>  
> -	if (pdata->t19_num_keys) {
> -		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
> -
> -		for (i = 0; i < pdata->t19_num_keys; i++)
> -			if (pdata->t19_keymap[i] != KEY_RESERVED)
> -				input_set_capability(input_dev, EV_KEY,
> -						     pdata->t19_keymap[i]);
> -
> +	if (mxt_initialize_t19(input_dev, data))
>  		mt_flags |= INPUT_MT_POINTER;
>  
> -		input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
> -		input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
> -		input_abs_set_res(input_dev, ABS_MT_POSITION_X,
> -				  MXT_PIXELS_PER_MM);
> -		input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
> -				  MXT_PIXELS_PER_MM);
> -
> -		input_dev->name = "Atmel maXTouch Touchpad";
> -	}
> -
>  	/* For single touch */
>  	input_set_abs_params(input_dev, ABS_X,
>  			     0, data->max_x, 0, 0);
> -- 
> 2.1.4
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object
  2015-03-17 14:00 ` [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object Javier Martinez Canillas
  2015-04-06 20:10   ` Dmitry Torokhov
@ 2015-08-06 10:51   ` Dirk Behme
  2015-08-06 11:11     ` Sjoerd Simons
  1 sibling, 1 reply; 11+ messages in thread
From: Dirk Behme @ 2015-08-06 10:51 UTC (permalink / raw)
  To: Javier Martinez Canillas, Dmitry Torokhov
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, Chung-yih Wang,
	linux-input, linux-kernel

On 17.03.2015 15:00, Javier Martinez Canillas wrote:
> From: Nick Dyer <nick.dyer@itdev.co.uk>
>
> Add support for the new T100 object which replaces the previous
> T9 multitouch touchscreen object in recent maXTouch devices.
> T100 provides improved reporting with selectable auxiliary
> information, and a type field for hover/stylus/glove reporting.
>
> The hovering finger support was based on Chung-Yih's work in
> the ChromiumOS downstream kernel:
>
> https://chromium-review.googlesource.com/#/c/219280/
>
> Signed-off-by: Nick Dyer <nick.dyer@itdev.co.uk>
> Acked-by: Yufeng Shen <miletus@chromium.org>
> [javier: Factor out T9 and T100 init functions and rework hover support]
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> ---
>   drivers/input/touchscreen/atmel_mxt_ts.c | 323 +++++++++++++++++++++++++++++--
>   1 file changed, 302 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index 95ee92a91bd2..749371761669 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
...
> @@ -1612,9 +1856,8 @@ static int mxt_initialize_t9_input_device(struct mxt_data *data)
>   	input_dev->open = mxt_input_open;
>   	input_dev->close = mxt_input_close;
>
> -	__set_bit(EV_ABS, input_dev->evbit);
> -	__set_bit(EV_KEY, input_dev->evbit);
> -	__set_bit(BTN_TOUCH, input_dev->keybit);
> +	set_bit(EV_ABS, input_dev->evbit);
> +	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);


Having this patch in mainline as commit 
b23157dc74272ac8ebffd1a566e3e822dbc3e65f [1] breaks our Atmel touch.

It seems that above

+	set_bit(EV_ABS, input_dev->evbit);

is missing in the version which went into mainline? Re-adding it makes 
it work for us, again.

Opinions?

Best regards

Dirk

[1] 
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/input/touchscreen/atmel_mxt_ts.c?id=b23157dc74272ac8ebffd1a566e3e822dbc3e65f




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object
  2015-08-06 10:51   ` Dirk Behme
@ 2015-08-06 11:11     ` Sjoerd Simons
  2015-08-06 11:19       ` Javier Martinez Canillas
  0 siblings, 1 reply; 11+ messages in thread
From: Sjoerd Simons @ 2015-08-06 11:11 UTC (permalink / raw)
  To: Dirk Behme, Dmitry Torokhov, Javier Martinez Canillas
  Cc: Henrik Rydberg, Nick Dyer, Doug Anderson, Olof Johansson,
	Yufeng Shen, Benson Leung, Chung-yih Wang, linux-input,
	linux-kernel

+ Corrected Javiers e-mail address. 
On Thu, 2015-08-06 at 12:51 +0200, Dirk Behme wrote:
> On 17.03.2015 15:00, Javier Martinez Canillas wrote:
> > 
> Having this patch in mainline as commit 
> b23157dc74272ac8ebffd1a566e3e822dbc3e65f [1] breaks our Atmel touch.
> 
> It seems that above
> 
> +	set_bit(EV_ABS, input_dev->evbit);
> 
> is missing in the version which went into mainline? Re-adding it 
> makes 
> it work for us, again.
> 
> Opinions?

In mainline the EV_ABS bit automatically gets set as soon as
input_set_abs_params get called. 

If you're using this patch on an older kernel you should backport
2c9a9cfec04f2c6ed7b4e607cd53ca903b2c4642 as well.

-- 
Sjoerd Simons
Collabora Ltd.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object
  2015-08-06 11:11     ` Sjoerd Simons
@ 2015-08-06 11:19       ` Javier Martinez Canillas
  2015-08-06 13:02         ` Nick Dyer
  0 siblings, 1 reply; 11+ messages in thread
From: Javier Martinez Canillas @ 2015-08-06 11:19 UTC (permalink / raw)
  To: Sjoerd Simons, Dirk Behme, Dmitry Torokhov
  Cc: Henrik Rydberg, Nick Dyer, Doug Anderson, Olof Johansson,
	Yufeng Shen, Benson Leung, Chung-yih Wang, linux-input,
	linux-kernel

Hello,

On 08/06/2015 01:11 PM, Sjoerd Simons wrote:
> + Corrected Javiers e-mail address. 
> On Thu, 2015-08-06 at 12:51 +0200, Dirk Behme wrote:
>> On 17.03.2015 15:00, Javier Martinez Canillas wrote:
>>>
>> Having this patch in mainline as commit 
>> b23157dc74272ac8ebffd1a566e3e822dbc3e65f [1] breaks our Atmel touch.
>>
>> It seems that above
>>
>> +	set_bit(EV_ABS, input_dev->evbit);
>>
>> is missing in the version which went into mainline? Re-adding it 
>> makes 
>> it work for us, again.
>>
>> Opinions?
> 
> In mainline the EV_ABS bit automatically gets set as soon as
> input_set_abs_params get called. 
> 
> If you're using this patch on an older kernel you should backport
> 2c9a9cfec04f2c6ed7b4e607cd53ca903b2c4642 as well.
> 

That's correct. The reason why the original patch had that it's
because it was forward ported from an older kernel and I missed
that detail when doing the rebase.

Best regards,
-- 
Javier Martinez Canillas
Open Source Group
Samsung Research America

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object
  2015-08-06 11:19       ` Javier Martinez Canillas
@ 2015-08-06 13:02         ` Nick Dyer
  0 siblings, 0 replies; 11+ messages in thread
From: Nick Dyer @ 2015-08-06 13:02 UTC (permalink / raw)
  To: Javier Martinez Canillas, Sjoerd Simons, Dirk Behme, Dmitry Torokhov
  Cc: Henrik Rydberg, Doug Anderson, Olof Johansson, Yufeng Shen,
	Benson Leung, Chung-yih Wang, linux-input, linux-kernel



On 06/08/15 12:19, Javier Martinez Canillas wrote:
>> In mainline the EV_ABS bit automatically gets set as soon as
>> input_set_abs_params get called. 
>>
>> If you're using this patch on an older kernel you should backport
>> 2c9a9cfec04f2c6ed7b4e607cd53ca903b2c4642 as well.
>>
> That's correct. The reason why the original patch had that it's
> because it was forward ported from an older kernel and I missed
> that detail when doing the rebase.
>
Yes, I've spotted the same issue myself.

I do keep a list of API breaks that affect this driver here:
https://github.com/atmel-maxtouch/linux/wiki/Driver-Integration#branches

(there's the MT protocol A to B change as well, at about 2.6.39)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic
  2014-12-15 10:39 Javier Martinez Canillas
@ 2014-12-15 10:39 ` Javier Martinez Canillas
  0 siblings, 0 replies; 11+ messages in thread
From: Javier Martinez Canillas @ 2014-12-15 10:39 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Henrik Rydberg, Nick Dyer, Sjoerd Simons, Doug Anderson,
	Olof Johansson, Yufeng Shen, Benson Leung, linux-input,
	linux-samsung-soc, Javier Martinez Canillas

From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

If the "linux,gpio-keymap" DT property is defined, the T19 keys are configured
and the device is setup as a touchpad rather than a touchscreen. The logic is
part of the input device initialization routine but it can be factored out to
its own function to simplify the former.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
[javier: Adapt to latest driver changes and modify commit message accordingly]
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
 drivers/input/touchscreen/atmel_mxt_ts.c | 48 +++++++++++++++++++-------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index aaa9e07..01fda60 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1756,15 +1756,40 @@ static int mxt_read_t100_config(struct mxt_data *data)
 static int mxt_input_open(struct input_dev *dev);
 static void mxt_input_close(struct input_dev *dev);
 
+static bool mxt_initialize_t19(struct input_dev *input_dev,
+			       struct mxt_data *data)
+{
+	const struct mxt_platform_data *pdata = data->pdata;
+	int i;
+
+	if (pdata->t19_num_keys) {
+		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
+
+		for (i = 0; i < pdata->t19_num_keys; i++)
+			if (pdata->t19_keymap[i] != KEY_RESERVED)
+				input_set_capability(input_dev, EV_KEY,
+						     pdata->t19_keymap[i]);
+
+		input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
+		input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
+		input_abs_set_res(input_dev, ABS_MT_POSITION_X,
+				  MXT_PIXELS_PER_MM);
+		input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
+				  MXT_PIXELS_PER_MM);
+
+		input_dev->name = "Atmel maXTouch Touchpad";
+		return true;
+	}
+	return false;
+}
+
 static int mxt_initialize_input_device(struct mxt_data *data, int multitouch)
 {
 	struct device *dev = &data->client->dev;
-	const struct mxt_platform_data *pdata = data->pdata;
 	struct input_dev *input_dev;
 	int error;
 	unsigned int num_mt_slots;
 	unsigned int mt_flags = 0;
-	int i;
 
 	switch (multitouch) {
 	case MXT_TOUCH_MULTI_T9:
@@ -1800,26 +1825,9 @@ static int mxt_initialize_input_device(struct mxt_data *data, int multitouch)
 	set_bit(EV_ABS, input_dev->evbit);
 	input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
 
-	if (pdata->t19_num_keys) {
-		__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
-
-		for (i = 0; i < pdata->t19_num_keys; i++)
-			if (pdata->t19_keymap[i] != KEY_RESERVED)
-				input_set_capability(input_dev, EV_KEY,
-						     pdata->t19_keymap[i]);
-
+	if (mxt_initialize_t19(input_dev, data))
 		mt_flags |= INPUT_MT_POINTER;
 
-		input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
-		input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
-		input_abs_set_res(input_dev, ABS_MT_POSITION_X,
-				  MXT_PIXELS_PER_MM);
-		input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
-				  MXT_PIXELS_PER_MM);
-
-		input_dev->name = "Atmel maXTouch Touchpad";
-	}
-
 	/* For single touch */
 	input_set_abs_params(input_dev, ABS_X,
 			     0, data->max_x, 0, 0);
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-08-06 13:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17 14:00 [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch Javier Martinez Canillas
2015-03-17 14:00 ` [PATCH 1/2] Input: atmel_mxt_ts - Implement support for T100 touch object Javier Martinez Canillas
2015-04-06 20:10   ` Dmitry Torokhov
2015-08-06 10:51   ` Dirk Behme
2015-08-06 11:11     ` Sjoerd Simons
2015-08-06 11:19       ` Javier Martinez Canillas
2015-08-06 13:02         ` Nick Dyer
2015-03-17 14:00 ` [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic Javier Martinez Canillas
2015-04-06 20:30   ` Dmitry Torokhov
2015-03-27 20:29 ` [PATCH 0/2] Input: atmel_mxt_ts - Add support for T100 multi-touch Javier Martinez Canillas
  -- strict thread matches above, loose matches on Subject: below --
2014-12-15 10:39 Javier Martinez Canillas
2014-12-15 10:39 ` [PATCH 2/2] Input: atmel_mxt_ts - Split out touchpad initialisation logic Javier Martinez Canillas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.