linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] Add the support of the touchscreen keypad of tsc2007 .
@ 2011-03-27  9:46 wanlong.gao
  2011-03-31  1:36 ` Harry Wei
  2011-03-31  5:33 ` Dmitry Torokhov
  0 siblings, 2 replies; 6+ messages in thread
From: wanlong.gao @ 2011-03-27  9:46 UTC (permalink / raw)
  To: dmitry.torokhov, w.sang, rpurdie, broonie, khali
  Cc: linux-input, linux-kernel, jiaweiwei.xiyou, Wanlong Gao

From: Wanlong Gao <wanlong.gao@gmail.com>

Many touchscreens support touch-keypad .
Open the definition of the TOUCHSCREEN_TSC2007_WITH_KEYPAD, you can
open the support of the touchscreen's keypad .
We can add the support of the touchscreen keypad in the driver.
In this patch , add the ts_key_pos array to determine the position
of the key's X. And the ts_key_sensitivity can use to detemine the
key's sensitivity. You can modify the ts_key_pos array for you own
touchscreen keys . And modify the ts_key_sensitivity for you own
key's sensitivity .
If you want to modify the ts_key_map, change the position of the
keys ,too.

Signed-off-by: Wanlong Gao <wanlong.gao@gmail.com>
---
 drivers/input/touchscreen/tsc2007.c |   48 +++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 80467f2..8f70fca 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -83,6 +83,51 @@ struct tsc2007 {
 	void			(*clear_penirq)(void);
 };
 
+/*
+#define	TOUCHSCREEN_TSC2007_WITH_KEYPAD
+*/
+#ifndef	TOUCHSCREEN_TSC2007_WITH_KEYPAD
+static void ts_key_set_capacity(struct input_dev *input) {};
+static void ts_key_up(struct input_dev *input) {};
+static void ts_key_event(struct input_dev *input, u16 x, u16 y) {};
+#else
+static int ts_key_pos[] = {700, 1650, 2550, 3500};
+static int ts_key_map[] = {KEY_MENU, KEY_HOME, KEY_BACK, KEY_SEARCH};
+/* you can modify this value to change the touch_key's sensitivity */
+static int ts_key_sensitivity = 50;
+
+static void ts_key_set_capacity(struct input_dev *input)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(ts_key_map); i++) {
+		input_set_capability(input, EV_KEY, ts_key_map[i]);
+	}
+}
+
+/* you must have an input_sync() followed this func . */
+static void ts_key_up(struct input_dev *input)
+{
+	int i;
+	for (i = 0; i < ARRAY_SIZE(ts_key_map); i++) {
+		input_report_key(input, ts_key_map[i], 0);
+	}
+}
+
+static void ts_key_event(struct input_dev *input, u16 x, u16 y)
+{
+	int i;
+	if (y > MAX_12BIT) {
+		for (i = 0; i < ARRAY_SIZE(ts_key_pos); i++) {
+			if ((x > (ts_key_pos[i] - ts_key_sensitivity)) &&
+				(x < (ts_key_pos[i] + ts_key_sensitivity))) {
+				input_report_key(input, ts_key_map[i], 1);
+				input_sync(input);
+			}
+		}
+	}
+}
+#endif
+
 static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
 {
 	s32 data;
@@ -149,6 +194,7 @@ static void tsc2007_send_up_event(struct tsc2007 *tsc)
 
 	input_report_key(input, BTN_TOUCH, 0);
 	input_report_abs(input, ABS_PRESSURE, 0);
+	ts_key_up(input);
 	input_sync(input);
 }
 
@@ -201,6 +247,7 @@ static void tsc2007_work(struct work_struct *work)
 		if (!ts->pendown) {
 			dev_dbg(&ts->client->dev, "DOWN\n");
 
+			ts_key_event(input, tc.x, tc.y);
 			input_report_key(input, BTN_TOUCH, 1);
 			ts->pendown = true;
 		}
@@ -308,6 +355,7 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
 	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
 	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
 	input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0);
+	ts_key_set_capacity(input_dev);
 
 	if (pdata->init_platform_hw)
 		pdata->init_platform_hw();
-- 
1.7.3


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

* Re: [PATCH V2] Add the support of the touchscreen keypad of tsc2007 .
  2011-03-27  9:46 [PATCH V2] Add the support of the touchscreen keypad of tsc2007 wanlong.gao
@ 2011-03-31  1:36 ` Harry Wei
  2011-03-31  5:33 ` Dmitry Torokhov
  1 sibling, 0 replies; 6+ messages in thread
From: Harry Wei @ 2011-03-31  1:36 UTC (permalink / raw)
  To: wanlong.gao
  Cc: khali, broonie, rpurdie, w.sang, dmitry.torokhov, linux-kernel,
	linux-input

On Sun, Mar 27, 2011 at 05:46:32PM +0800, wanlong.gao@gmail.com wrote:
> From: Wanlong Gao <wanlong.gao@gmail.com>
> 
> Many touchscreens support touch-keypad .
> Open the definition of the TOUCHSCREEN_TSC2007_WITH_KEYPAD, you can
> open the support of the touchscreen's keypad .
> We can add the support of the touchscreen keypad in the driver.
> In this patch , add the ts_key_pos array to determine the position
> of the key's X. And the ts_key_sensitivity can use to detemine the
> key's sensitivity. You can modify the ts_key_pos array for you own
> touchscreen keys . And modify the ts_key_sensitivity for you own
> key's sensitivity .
> If you want to modify the ts_key_map, change the position of the
> keys ,too.
> 
> Signed-off-by: Wanlong Gao <wanlong.gao@gmail.com>
Reviewed-by: Harry Wei <harryxiyou@gmail.com>
> ---
>  drivers/input/touchscreen/tsc2007.c |   48 +++++++++++++++++++++++++++++++++++
>  1 files changed, 48 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 80467f2..8f70fca 100644
> --- a/drivers/input/touchscreen/tsc2007.c
> +++ b/drivers/input/touchscreen/tsc2007.c
> @@ -83,6 +83,51 @@ struct tsc2007 {
>  	void			(*clear_penirq)(void);
>  };
>  
> +/*
> +#define	TOUCHSCREEN_TSC2007_WITH_KEYPAD
> +*/
> +#ifndef	TOUCHSCREEN_TSC2007_WITH_KEYPAD
> +static void ts_key_set_capacity(struct input_dev *input) {};
> +static void ts_key_up(struct input_dev *input) {};
> +static void ts_key_event(struct input_dev *input, u16 x, u16 y) {};
> +#else
> +static int ts_key_pos[] = {700, 1650, 2550, 3500};
> +static int ts_key_map[] = {KEY_MENU, KEY_HOME, KEY_BACK, KEY_SEARCH};
> +/* you can modify this value to change the touch_key's sensitivity */
> +static int ts_key_sensitivity = 50;
> +
> +static void ts_key_set_capacity(struct input_dev *input)
> +{
> +	int i;
> +	for (i = 0; i < ARRAY_SIZE(ts_key_map); i++) {
> +		input_set_capability(input, EV_KEY, ts_key_map[i]);
> +	}
You only have one statement after 'for-recycle', so it should program
like following.
for (i = 0; i < ARRAY_SIZE(ts_key_map); i++)
	input_set_capability(input, EV_KEY, ts_key_map[i]);
> +}
> +
> +/* you must have an input_sync() followed this func . */
> +static void ts_key_up(struct input_dev *input)
> +{
> +	int i;
> +	for (i = 0; i < ARRAY_SIZE(ts_key_map); i++) {
> +		input_report_key(input, ts_key_map[i], 0);
> +	}
for (i = 0; i < ARRAY_SIZE(ts_key_map); i++)
	input_report_key(input, ts_key_map[i], 0);
> +}
> +
> +static void ts_key_event(struct input_dev *input, u16 x, u16 y)
> +{
> +	int i;
> +	if (y > MAX_12BIT) {
> +		for (i = 0; i < ARRAY_SIZE(ts_key_pos); i++) {
> +			if ((x > (ts_key_pos[i] - ts_key_sensitivity)) &&
> +				(x < (ts_key_pos[i] + ts_key_sensitivity))) {
> +				input_report_key(input, ts_key_map[i], 1);
> +				input_sync(input);
> +			}
> +		}
> +	}
> +}
> +#endif
> +
>  static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
>  {
>  	s32 data;
> @@ -149,6 +194,7 @@ static void tsc2007_send_up_event(struct tsc2007 *tsc)
>  
>  	input_report_key(input, BTN_TOUCH, 0);
>  	input_report_abs(input, ABS_PRESSURE, 0);
> +	ts_key_up(input);
>  	input_sync(input);
>  }
>  
> @@ -201,6 +247,7 @@ static void tsc2007_work(struct work_struct *work)
>  		if (!ts->pendown) {
>  			dev_dbg(&ts->client->dev, "DOWN\n");
>  
> +			ts_key_event(input, tc.x, tc.y);
>  			input_report_key(input, BTN_TOUCH, 1);
>  			ts->pendown = true;
>  		}
> @@ -308,6 +355,7 @@ static int __devinit tsc2007_probe(struct i2c_client *client,
>  	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, 0, 0);
>  	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, 0, 0);
>  	input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT, 0, 0);
> +	ts_key_set_capacity(input_dev);
>  
>  	if (pdata->init_platform_hw)
>  		pdata->init_platform_hw();
> -- 
> 1.7.3
> 

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

* Re: [PATCH V2] Add the support of the touchscreen keypad of tsc2007 .
  2011-03-27  9:46 [PATCH V2] Add the support of the touchscreen keypad of tsc2007 wanlong.gao
  2011-03-31  1:36 ` Harry Wei
@ 2011-03-31  5:33 ` Dmitry Torokhov
  2011-03-31  8:49   ` Richard Purdie
  2011-03-31 12:08   ` Re: [PATCH V2] Add the support of the touchscreen keypad of tsc2007 wanlong.gao
  1 sibling, 2 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2011-03-31  5:33 UTC (permalink / raw)
  To: wanlong.gao
  Cc: w.sang, rpurdie, broonie, khali, linux-input, linux-kernel,
	jiaweiwei.xiyou

Hi Wanlong,

On Sun, Mar 27, 2011 at 05:46:32PM +0800, wanlong.gao@gmail.com wrote:
> From: Wanlong Gao <wanlong.gao@gmail.com>
> 
> Many touchscreens support touch-keypad .
> Open the definition of the TOUCHSCREEN_TSC2007_WITH_KEYPAD, you can
> open the support of the touchscreen's keypad .
> We can add the support of the touchscreen keypad in the driver.
> In this patch , add the ts_key_pos array to determine the position
> of the key's X. And the ts_key_sensitivity can use to detemine the
> key's sensitivity. You can modify the ts_key_pos array for you own
> touchscreen keys . And modify the ts_key_sensitivity for you own
> key's sensitivity .
> If you want to modify the ts_key_map, change the position of the
> keys ,too.

No, this kind of data transformation does not belong to a driver (or,
really in kernel). It is in no way TSC2007 specific (any touchscreen
could be used in place of TSC2007 here).

Do it in userspace and either loop the events back into kernel (after
parsing) via uinput or feed directly into your framework.

Thanks.

-- 
Dmitry

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

* Re: [PATCH V2] Add the support of the touchscreen keypad of tsc2007 .
  2011-03-31  5:33 ` Dmitry Torokhov
@ 2011-03-31  8:49   ` Richard Purdie
  2011-03-31 12:21     ` Re: [PATCH V2] Add the support of the touchscreen keypad oftsc2007 wanlong.gao
  2011-03-31 12:08   ` Re: [PATCH V2] Add the support of the touchscreen keypad of tsc2007 wanlong.gao
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2011-03-31  8:49 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: wanlong.gao, w.sang, broonie, khali, linux-input, linux-kernel,
	jiaweiwei.xiyou

On Wed, 2011-03-30 at 22:33 -0700, Dmitry Torokhov wrote:
> Hi Wanlong,
> 
> On Sun, Mar 27, 2011 at 05:46:32PM +0800, wanlong.gao@gmail.com wrote:
> > From: Wanlong Gao <wanlong.gao@gmail.com>
> > 
> > Many touchscreens support touch-keypad .
> > Open the definition of the TOUCHSCREEN_TSC2007_WITH_KEYPAD, you can
> > open the support of the touchscreen's keypad .
> > We can add the support of the touchscreen keypad in the driver.
> > In this patch , add the ts_key_pos array to determine the position
> > of the key's X. And the ts_key_sensitivity can use to detemine the
> > key's sensitivity. You can modify the ts_key_pos array for you own
> > touchscreen keys . And modify the ts_key_sensitivity for you own
> > key's sensitivity .
> > If you want to modify the ts_key_map, change the position of the
> > keys ,too.
> 
> No, this kind of data transformation does not belong to a driver (or,
> really in kernel). It is in no way TSC2007 specific (any touchscreen
> could be used in place of TSC2007 here).
> 
> Do it in userspace and either loop the events back into kernel (after
> parsing) via uinput or feed directly into your framework.

There is even code out there already which does exactly that:

http://svn.o-hand.com/view/misc/trunk/zaurusd/apps/tskeys/tskeys.c?rev=415&view=markup

Cheers,

Richard


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

* Re: Re: [PATCH V2] Add the support of the touchscreen keypad of tsc2007 .
  2011-03-31  5:33 ` Dmitry Torokhov
  2011-03-31  8:49   ` Richard Purdie
@ 2011-03-31 12:08   ` wanlong.gao
  1 sibling, 0 replies; 6+ messages in thread
From: wanlong.gao @ 2011-03-31 12:08 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: w.sang, rpurdie, broonie, khali, linux-input, linux-kernel,
	jiaweiwei.xiyou

Thank you for your comments, and benefited a lot.


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

* Re: Re: [PATCH V2] Add the support of the touchscreen keypad oftsc2007 .
  2011-03-31  8:49   ` Richard Purdie
@ 2011-03-31 12:21     ` wanlong.gao
  0 siblings, 0 replies; 6+ messages in thread
From: wanlong.gao @ 2011-03-31 12:21 UTC (permalink / raw)
  To: Richard Purdie, Dmitry Torokhov
  Cc: w.sang, broonie, khali, linux-input, linux-kernel,
	jiaweiwei.xiyou

Oh, cheers and thanks for the author .


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

end of thread, other threads:[~2011-03-31 12:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-27  9:46 [PATCH V2] Add the support of the touchscreen keypad of tsc2007 wanlong.gao
2011-03-31  1:36 ` Harry Wei
2011-03-31  5:33 ` Dmitry Torokhov
2011-03-31  8:49   ` Richard Purdie
2011-03-31 12:21     ` Re: [PATCH V2] Add the support of the touchscreen keypad oftsc2007 wanlong.gao
2011-03-31 12:08   ` Re: [PATCH V2] Add the support of the touchscreen keypad of tsc2007 wanlong.gao

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