linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: egalax: Send touch end event when is about to suspend
@ 2013-12-11  0:03 Felipe F. Tonello
  2013-12-15 10:40 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe F. Tonello @ 2013-12-11  0:03 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-input, Andy Shevchenko, Sachin Kamat, Heiko Abraham,
	Dmitry Torokhov, Felipe F. Tonello

From: "Felipe F. Tonello" <eu@felipetonello.com>

This is useful to report for users of this device that don't know anything
about the suspension of the device. So users will receive a touch end event
when the device is about to suspend, making it more user friendly.

One example of users is the X Server with the evdev input driver. This patch
make sure that the X server will propagate a touch end event to its windows.

Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
---
 drivers/input/touchscreen/egalax_ts.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 054d225..1f21f0d 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -63,6 +63,7 @@
 struct egalax_ts {
 	struct i2c_client		*client;
 	struct input_dev		*input_dev;
+	bool					ids_in_use[MAX_SUPPORT_POINTS];
 };
 
 static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
@@ -117,6 +118,8 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
 	input_mt_report_pointer_emulation(input_dev, true);
 	input_sync(input_dev);
 
+	ts->ids_in_use[id] = down;
+
 	return IRQ_HANDLED;
 }
 
@@ -247,9 +250,22 @@ static int egalax_ts_suspend(struct device *dev)
 		0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0
 	};
 	struct i2c_client *client = to_i2c_client(dev);
-	int ret;
+	struct egalax_ts *ts = i2c_get_clientdata(client);
+	int ret, id;
 
 	ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN);
+
+	/* We send a touch end event (for the ids in use) if the egalax module is
+	   about to be turned off. */
+	for (id = 0; id < MAX_SUPPORT_POINTS; ++id) {
+		if (ts->ids_in_use[id]) {
+			input_mt_slot(ts->input_dev, id);
+			input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);
+			input_mt_report_pointer_emulation(ts->input_dev, true);
+			input_sync(ts->input_dev);
+		}
+	}
+
 	return ret > 0 ? 0 : ret;
 }
 
-- 
1.8.3.1


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

* Re: [PATCH] input: egalax: Send touch end event when is about to suspend
  2013-12-11  0:03 [PATCH] input: egalax: Send touch end event when is about to suspend Felipe F. Tonello
@ 2013-12-15 10:40 ` Dmitry Torokhov
  2013-12-16 23:45   ` Felipe Ferreri Tonello
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2013-12-15 10:40 UTC (permalink / raw)
  To: Felipe F. Tonello
  Cc: linux-kernel, linux-input, Andy Shevchenko, Sachin Kamat,
	Heiko Abraham

Hi Felipe,

On Tue, Dec 10, 2013 at 04:03:16PM -0800, Felipe F. Tonello wrote:
> From: "Felipe F. Tonello" <eu@felipetonello.com>
> 
> This is useful to report for users of this device that don't know anything
> about the suspension of the device. So users will receive a touch end event
> when the device is about to suspend, making it more user friendly.
> 
> One example of users is the X Server with the evdev input driver. This patch
> make sure that the X server will propagate a touch end event to its windows.
> 

Hmm, I would argue we need to do this in input core, similarly to what
we do for the keys, so that all drivers would benefit from the change.

Thanks.

> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
> ---
>  drivers/input/touchscreen/egalax_ts.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
> index 054d225..1f21f0d 100644
> --- a/drivers/input/touchscreen/egalax_ts.c
> +++ b/drivers/input/touchscreen/egalax_ts.c
> @@ -63,6 +63,7 @@
>  struct egalax_ts {
>  	struct i2c_client		*client;
>  	struct input_dev		*input_dev;
> +	bool					ids_in_use[MAX_SUPPORT_POINTS];
>  };
>  
>  static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
> @@ -117,6 +118,8 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
>  	input_mt_report_pointer_emulation(input_dev, true);
>  	input_sync(input_dev);
>  
> +	ts->ids_in_use[id] = down;
> +
>  	return IRQ_HANDLED;
>  }
>  
> @@ -247,9 +250,22 @@ static int egalax_ts_suspend(struct device *dev)
>  		0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0
>  	};
>  	struct i2c_client *client = to_i2c_client(dev);
> -	int ret;
> +	struct egalax_ts *ts = i2c_get_clientdata(client);
> +	int ret, id;
>  
>  	ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN);
> +
> +	/* We send a touch end event (for the ids in use) if the egalax module is
> +	   about to be turned off. */
> +	for (id = 0; id < MAX_SUPPORT_POINTS; ++id) {
> +		if (ts->ids_in_use[id]) {
> +			input_mt_slot(ts->input_dev, id);
> +			input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);
> +			input_mt_report_pointer_emulation(ts->input_dev, true);
> +			input_sync(ts->input_dev);
> +		}
> +	}
> +
>  	return ret > 0 ? 0 : ret;
>  }
>  
> -- 
> 1.8.3.1
> 

-- 
Dmitry

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

* Re: [PATCH] input: egalax: Send touch end event when is about to suspend
  2013-12-15 10:40 ` Dmitry Torokhov
@ 2013-12-16 23:45   ` Felipe Ferreri Tonello
  2013-12-30  0:36     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Felipe Ferreri Tonello @ 2013-12-16 23:45 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-kernel, linux-input, Andy Shevchenko, Sachin Kamat,
	Heiko Abraham

Hi Dmitry,

On 12/15/2013 02:40 AM, Dmitry Torokhov wrote:
> Hi Felipe,
>
> On Tue, Dec 10, 2013 at 04:03:16PM -0800, Felipe F. Tonello wrote:
>> From: "Felipe F. Tonello" <eu@felipetonello.com>
>>
>> This is useful to report for users of this device that don't know anything
>> about the suspension of the device. So users will receive a touch end event
>> when the device is about to suspend, making it more user friendly.
>>
>> One example of users is the X Server with the evdev input driver. This patch
>> make sure that the X server will propagate a touch end event to its windows.
>>
>
> Hmm, I would argue we need to do this in input core, similarly to what
> we do for the keys, so that all drivers would benefit from the change.
>
> Thanks.

I agree with you. I didn't do in this case because previous patches that 
I had to change core functionality were declined due the fact it's hard 
to maintain backwards compatibility.

Do you recommend me something in this case?

Thanks for your answer.

Felipe

>
>> Signed-off-by: Felipe F. Tonello <eu@felipetonello.com>
>> ---
>>   drivers/input/touchscreen/egalax_ts.c | 18 +++++++++++++++++-
>>   1 file changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
>> index 054d225..1f21f0d 100644
>> --- a/drivers/input/touchscreen/egalax_ts.c
>> +++ b/drivers/input/touchscreen/egalax_ts.c
>> @@ -63,6 +63,7 @@
>>   struct egalax_ts {
>>   	struct i2c_client		*client;
>>   	struct input_dev		*input_dev;
>> +	bool					ids_in_use[MAX_SUPPORT_POINTS];
>>   };
>>
>>   static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
>> @@ -117,6 +118,8 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
>>   	input_mt_report_pointer_emulation(input_dev, true);
>>   	input_sync(input_dev);
>>
>> +	ts->ids_in_use[id] = down;
>> +
>>   	return IRQ_HANDLED;
>>   }
>>
>> @@ -247,9 +250,22 @@ static int egalax_ts_suspend(struct device *dev)
>>   		0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0
>>   	};
>>   	struct i2c_client *client = to_i2c_client(dev);
>> -	int ret;
>> +	struct egalax_ts *ts = i2c_get_clientdata(client);
>> +	int ret, id;
>>
>>   	ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN);
>> +
>> +	/* We send a touch end event (for the ids in use) if the egalax module is
>> +	   about to be turned off. */
>> +	for (id = 0; id < MAX_SUPPORT_POINTS; ++id) {
>> +		if (ts->ids_in_use[id]) {
>> +			input_mt_slot(ts->input_dev, id);
>> +			input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, false);
>> +			input_mt_report_pointer_emulation(ts->input_dev, true);
>> +			input_sync(ts->input_dev);
>> +		}
>> +	}
>> +
>>   	return ret > 0 ? 0 : ret;
>>   }
>>
>> --
>> 1.8.3.1
>>
>

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

* Re: [PATCH] input: egalax: Send touch end event when is about to suspend
  2013-12-16 23:45   ` Felipe Ferreri Tonello
@ 2013-12-30  0:36     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2013-12-30  0:36 UTC (permalink / raw)
  To: Felipe Ferreri Tonello
  Cc: linux-kernel, linux-input, Andy Shevchenko, Sachin Kamat,
	Heiko Abraham

Hi Felipe,

On Mon, Dec 16, 2013 at 03:45:58PM -0800, Felipe Ferreri Tonello wrote:
> Hi Dmitry,
> 
> On 12/15/2013 02:40 AM, Dmitry Torokhov wrote:
> >Hi Felipe,
> >
> >On Tue, Dec 10, 2013 at 04:03:16PM -0800, Felipe F. Tonello wrote:
> >>From: "Felipe F. Tonello" <eu@felipetonello.com>
> >>
> >>This is useful to report for users of this device that don't know anything
> >>about the suspension of the device. So users will receive a touch end event
> >>when the device is about to suspend, making it more user friendly.
> >>
> >>One example of users is the X Server with the evdev input driver. This patch
> >>make sure that the X server will propagate a touch end event to its windows.
> >>
> >
> >Hmm, I would argue we need to do this in input core, similarly to what
> >we do for the keys, so that all drivers would benefit from the change.
> >
> >Thanks.
> 
> I agree with you. I didn't do in this case because previous patches
> that I had to change core functionality were declined due the fact
> it's hard to maintain backwards compatibility.
> 
> Do you recommend me something in this case?

I am not sure why your other patches were declined, but I think in this
particular case it makes sense to move this functionality into input
core as many multitouch drivers would need it.

Thanks.

-- 
Dmitry

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

end of thread, other threads:[~2013-12-30  0:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11  0:03 [PATCH] input: egalax: Send touch end event when is about to suspend Felipe F. Tonello
2013-12-15 10:40 ` Dmitry Torokhov
2013-12-16 23:45   ` Felipe Ferreri Tonello
2013-12-30  0:36     ` Dmitry Torokhov

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).