linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/4] Input: atmel_mxt_ts - Convert to MT protocol B
@ 2011-03-07  8:54 Joonyoung Shim
  2011-03-10 11:10 ` Henrik Rydberg
  0 siblings, 1 reply; 3+ messages in thread
From: Joonyoung Shim @ 2011-03-07  8:54 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, iiro.valkonen, rydberg, kyungmin.park

Atmel touchscreen chips can use MT protocol B because they can assign
unique id to ABS_MT_TRACKING_ID from finger id provided by hardware.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
---
 drivers/input/touchscreen/atmel_mxt_ts.c |   37 ++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index fd1fda5..7da71d9 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -203,6 +203,7 @@
 
 /* Touchscreen absolute values */
 #define MXT_MAX_AREA		0xff
+#define MXT_MAX_TRACKING_ID	0xff
 
 #define MXT_MAX_FINGER		10
 
@@ -238,6 +239,7 @@ struct mxt_finger {
 	int x;
 	int y;
 	int area;
+	int trkid;
 };
 
 /* Each client has this additional data */
@@ -504,19 +506,19 @@ static void mxt_input_report(struct mxt_data *data, int single_id)
 		if (!finger[id].status)
 			continue;
 
-		input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
-				finger[id].status != MXT_RELEASE ?
-				finger[id].area : 0);
-		input_report_abs(input_dev, ABS_MT_POSITION_X,
-				finger[id].x);
-		input_report_abs(input_dev, ABS_MT_POSITION_Y,
-				finger[id].y);
-		input_mt_sync(input_dev);
-
-		if (finger[id].status == MXT_RELEASE)
-			finger[id].status = 0;
-		else
+		input_mt_slot(input_dev, id);
+		input_report_abs(input_dev, ABS_MT_TRACKING_ID,
+				finger[id].trkid);
+		if (finger[id].status != MXT_RELEASE) {
 			finger_num++;
+			input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
+					finger[id].area);
+			input_report_abs(input_dev, ABS_MT_POSITION_X,
+					finger[id].x);
+			input_report_abs(input_dev, ABS_MT_POSITION_Y,
+					finger[id].y);
+		} else
+			finger[id].status = 0;
 	}
 
 	input_report_key(input_dev, BTN_TOUCH, finger_num > 0);
@@ -538,6 +540,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
 	int x;
 	int y;
 	int area;
+	static int trkid;
 
 	/* Check the touch is present on the screen */
 	if (!(status & MXT_DETECT)) {
@@ -545,6 +548,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
 			dev_dbg(dev, "[%d] released\n", id);
 
 			finger[id].status = MXT_RELEASE;
+			finger[id].trkid = -1;
 			mxt_input_report(data, id);
 		}
 		return;
@@ -572,6 +576,8 @@ static void mxt_input_touchevent(struct mxt_data *data,
 	finger[id].x = x;
 	finger[id].y = y;
 	finger[id].area = area;
+	if (finger[id].trkid < 0)
+		finger[id].trkid = trkid++ & MXT_MAX_TRACKING_ID;
 
 	mxt_input_report(data, id);
 }
@@ -790,8 +796,12 @@ static int mxt_initialize(struct mxt_data *data)
 	struct i2c_client *client = data->client;
 	struct mxt_info *info = &data->info;
 	int error;
+	int i;
 	u8 val;
 
+	for (i = 0; i < MXT_MAX_FINGER; i++)
+		data->finger[i].trkid = -1;
+
 	error = mxt_get_info(data);
 	if (error)
 		return error;
@@ -1091,6 +1101,9 @@ static int __devinit mxt_probe(struct i2c_client *client,
 			     0, data->y_size, 0, 0);
 
 	/* For multi touch */
+	input_mt_create_slots(input_dev, MXT_MAX_FINGER);
+	input_set_abs_params(input_dev, ABS_MT_TRACKING_ID,
+			     0, MXT_MAX_TRACKING_ID, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
 			     0, MXT_MAX_AREA, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
-- 
1.7.0.4


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

* Re: [PATCH 4/4] Input: atmel_mxt_ts - Convert to MT protocol B
  2011-03-07  8:54 [PATCH 4/4] Input: atmel_mxt_ts - Convert to MT protocol B Joonyoung Shim
@ 2011-03-10 11:10 ` Henrik Rydberg
  2011-03-11  6:41   ` Joonyoung Shim
  0 siblings, 1 reply; 3+ messages in thread
From: Henrik Rydberg @ 2011-03-10 11:10 UTC (permalink / raw)
  To: Joonyoung Shim; +Cc: dmitry.torokhov, linux-input, iiro.valkonen, kyungmin.park

Hi Joonyoung,

> Atmel touchscreen chips can use MT protocol B because they can assign
> unique id to ABS_MT_TRACKING_ID from finger id provided by hardware.
> 
> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>

Thanks for making this change. Please see comments inline.

> ---
>  drivers/input/touchscreen/atmel_mxt_ts.c |   37 ++++++++++++++++++++---------
>  1 files changed, 25 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
> index fd1fda5..7da71d9 100644
> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
> @@ -203,6 +203,7 @@
>  
>  /* Touchscreen absolute values */
>  #define MXT_MAX_AREA		0xff
> +#define MXT_MAX_TRACKING_ID	0xff

Instead, include <linux/input/mt.h>

>  #define MXT_MAX_FINGER		10
>  
> @@ -238,6 +239,7 @@ struct mxt_finger {
>  	int x;
>  	int y;
>  	int area;
> +	int trkid;

The tracking id is now handled in the input core, so it can be dropped here.

>  };
>  
>  /* Each client has this additional data */
> @@ -504,19 +506,19 @@ static void mxt_input_report(struct mxt_data *data, int single_id)
>  		if (!finger[id].status)
>  			continue;
>  
> -		input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
> -				finger[id].status != MXT_RELEASE ?
> -				finger[id].area : 0);
> -		input_report_abs(input_dev, ABS_MT_POSITION_X,
> -				finger[id].x);
> -		input_report_abs(input_dev, ABS_MT_POSITION_Y,
> -				finger[id].y);
> -		input_mt_sync(input_dev);
> -
> -		if (finger[id].status == MXT_RELEASE)
> -			finger[id].status = 0;
> -		else
> +		input_mt_slot(input_dev, id);
> +		input_report_abs(input_dev, ABS_MT_TRACKING_ID,
> +				finger[id].trkid);

Replace the line above with (possibly using a temp variable instead)

input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, finger[id].status != MXT_RELEASE);


> +		if (finger[id].status != MXT_RELEASE) {

>  			finger_num++;
> +			input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
> +					finger[id].area);
> +			input_report_abs(input_dev, ABS_MT_POSITION_X,
> +					finger[id].x);
> +			input_report_abs(input_dev, ABS_MT_POSITION_Y,
> +					finger[id].y);
> +		} else
> +			finger[id].status = 0;
>  	}
>  
>  	input_report_key(input_dev, BTN_TOUCH, finger_num > 0);
> @@ -538,6 +540,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
>  	int x;
>  	int y;
>  	int area;
> +	static int trkid;

drop

>  
>  	/* Check the touch is present on the screen */
>  	if (!(status & MXT_DETECT)) {
> @@ -545,6 +548,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
>  			dev_dbg(dev, "[%d] released\n", id);
>  
>  			finger[id].status = MXT_RELEASE;
> +			finger[id].trkid = -1;

drop

>  			mxt_input_report(data, id);
>  		}
>  		return;
> @@ -572,6 +576,8 @@ static void mxt_input_touchevent(struct mxt_data *data,
>  	finger[id].x = x;
>  	finger[id].y = y;
>  	finger[id].area = area;
> +	if (finger[id].trkid < 0)
> +		finger[id].trkid = trkid++ & MXT_MAX_TRACKING_ID;

drop

>  
>  	mxt_input_report(data, id);
>  }
> @@ -790,8 +796,12 @@ static int mxt_initialize(struct mxt_data *data)
>  	struct i2c_client *client = data->client;
>  	struct mxt_info *info = &data->info;
>  	int error;
> +	int i;

drop

>  	u8 val;
>  
> +	for (i = 0; i < MXT_MAX_FINGER; i++)
> +		data->finger[i].trkid = -1;
> +

drop

>  	error = mxt_get_info(data);
>  	if (error)
>  		return error;
> @@ -1091,6 +1101,9 @@ static int __devinit mxt_probe(struct i2c_client *client,
>  			     0, data->y_size, 0, 0);
>  
>  	/* For multi touch */
> +	input_mt_create_slots(input_dev, MXT_MAX_FINGER);
> +	input_set_abs_params(input_dev, ABS_MT_TRACKING_ID,
> +			     0, MXT_MAX_TRACKING_ID, 0, 0);

Replace with

input_mt_init_slots(input_dev, MXT_MAX_FINGER);

>  	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
>  			     0, MXT_MAX_AREA, 0, 0);
>  	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
> -- 
> 1.7.0.4

Thanks,
Henrik

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

* Re: [PATCH 4/4] Input: atmel_mxt_ts - Convert to MT protocol B
  2011-03-10 11:10 ` Henrik Rydberg
@ 2011-03-11  6:41   ` Joonyoung Shim
  0 siblings, 0 replies; 3+ messages in thread
From: Joonyoung Shim @ 2011-03-11  6:41 UTC (permalink / raw)
  To: Henrik Rydberg; +Cc: dmitry.torokhov, linux-input, iiro.valkonen, kyungmin.park

On 2011-03-10 오후 8:10, Henrik Rydberg wrote:
> Hi Joonyoung,
>
>> Atmel touchscreen chips can use MT protocol B because they can assign
>> unique id to ABS_MT_TRACKING_ID from finger id provided by hardware.
>>
>> Signed-off-by: Joonyoung Shim<jy0922.shim@samsung.com>
>
> Thanks for making this change. Please see comments inline.
>

Hi, Henrik.

I missed your MT protocol B API changes.
I will resend modified patch.

Thanks for your review.

>> ---
>>   drivers/input/touchscreen/atmel_mxt_ts.c |   37 ++++++++++++++++++++---------
>>   1 files changed, 25 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
>> index fd1fda5..7da71d9 100644
>> --- a/drivers/input/touchscreen/atmel_mxt_ts.c
>> +++ b/drivers/input/touchscreen/atmel_mxt_ts.c
>> @@ -203,6 +203,7 @@
>>
>>   /* Touchscreen absolute values */
>>   #define MXT_MAX_AREA		0xff
>> +#define MXT_MAX_TRACKING_ID	0xff
>
> Instead, include<linux/input/mt.h>
>
>>   #define MXT_MAX_FINGER		10
>>
>> @@ -238,6 +239,7 @@ struct mxt_finger {
>>   	int x;
>>   	int y;
>>   	int area;
>> +	int trkid;
>
> The tracking id is now handled in the input core, so it can be dropped here.
>
>>   };
>>
>>   /* Each client has this additional data */
>> @@ -504,19 +506,19 @@ static void mxt_input_report(struct mxt_data *data, int single_id)
>>   		if (!finger[id].status)
>>   			continue;
>>
>> -		input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
>> -				finger[id].status != MXT_RELEASE ?
>> -				finger[id].area : 0);
>> -		input_report_abs(input_dev, ABS_MT_POSITION_X,
>> -				finger[id].x);
>> -		input_report_abs(input_dev, ABS_MT_POSITION_Y,
>> -				finger[id].y);
>> -		input_mt_sync(input_dev);
>> -
>> -		if (finger[id].status == MXT_RELEASE)
>> -			finger[id].status = 0;
>> -		else
>> +		input_mt_slot(input_dev, id);
>> +		input_report_abs(input_dev, ABS_MT_TRACKING_ID,
>> +				finger[id].trkid);
>
> Replace the line above with (possibly using a temp variable instead)
>
> input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, finger[id].status != MXT_RELEASE);
>
>
>> +		if (finger[id].status != MXT_RELEASE) {
>
>>   			finger_num++;
>> +			input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR,
>> +					finger[id].area);
>> +			input_report_abs(input_dev, ABS_MT_POSITION_X,
>> +					finger[id].x);
>> +			input_report_abs(input_dev, ABS_MT_POSITION_Y,
>> +					finger[id].y);
>> +		} else
>> +			finger[id].status = 0;
>>   	}
>>
>>   	input_report_key(input_dev, BTN_TOUCH, finger_num>  0);
>> @@ -538,6 +540,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
>>   	int x;
>>   	int y;
>>   	int area;
>> +	static int trkid;
>
> drop
>
>>
>>   	/* Check the touch is present on the screen */
>>   	if (!(status&  MXT_DETECT)) {
>> @@ -545,6 +548,7 @@ static void mxt_input_touchevent(struct mxt_data *data,
>>   			dev_dbg(dev, "[%d] released\n", id);
>>
>>   			finger[id].status = MXT_RELEASE;
>> +			finger[id].trkid = -1;
>
> drop
>
>>   			mxt_input_report(data, id);
>>   		}
>>   		return;
>> @@ -572,6 +576,8 @@ static void mxt_input_touchevent(struct mxt_data *data,
>>   	finger[id].x = x;
>>   	finger[id].y = y;
>>   	finger[id].area = area;
>> +	if (finger[id].trkid<  0)
>> +		finger[id].trkid = trkid++&  MXT_MAX_TRACKING_ID;
>
> drop
>
>>
>>   	mxt_input_report(data, id);
>>   }
>> @@ -790,8 +796,12 @@ static int mxt_initialize(struct mxt_data *data)
>>   	struct i2c_client *client = data->client;
>>   	struct mxt_info *info =&data->info;
>>   	int error;
>> +	int i;
>
> drop
>
>>   	u8 val;
>>
>> +	for (i = 0; i<  MXT_MAX_FINGER; i++)
>> +		data->finger[i].trkid = -1;
>> +
>
> drop
>
>>   	error = mxt_get_info(data);
>>   	if (error)
>>   		return error;
>> @@ -1091,6 +1101,9 @@ static int __devinit mxt_probe(struct i2c_client *client,
>>   			     0, data->y_size, 0, 0);
>>
>>   	/* For multi touch */
>> +	input_mt_create_slots(input_dev, MXT_MAX_FINGER);
>> +	input_set_abs_params(input_dev, ABS_MT_TRACKING_ID,
>> +			     0, MXT_MAX_TRACKING_ID, 0, 0);
>
> Replace with
>
> input_mt_init_slots(input_dev, MXT_MAX_FINGER);
>
>>   	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
>>   			     0, MXT_MAX_AREA, 0, 0);
>>   	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
>> --
>> 1.7.0.4
>
> Thanks,
> Henrik
>

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2011-03-11  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-07  8:54 [PATCH 4/4] Input: atmel_mxt_ts - Convert to MT protocol B Joonyoung Shim
2011-03-10 11:10 ` Henrik Rydberg
2011-03-11  6:41   ` Joonyoung Shim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).