Skip to contentSkip to conversation

Input: goodix: Add support for capacitive home button found on some x86 tablets

PATCH Superseded Sergei A. Trusov 4 participants 11 messages Jun 17, 2017 – Jun 20, 2017

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: goodix: Add support for capacitive home button found on some x86 tablets

On some x86 tablets with a goodix touchscreen the windows logo on the front is a capacitive home button. Touching this button results in a touch with bit 4 of the 0th byte set, while normally only the lower 4 bits are used to indicate the number of touches.

Detect this and report a KEY_LEFTMETA press when this happens. Note the hardware might support more than one button, the number of a button is reported by the 'id' byte of coor_data. Now we ignore button id.

---
 drivers/input/touchscreen/goodix.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/input/touchscreen/goodix.c +15 -5
index 240b16f3ee97..a4c17c461792 100644
@@ -76,6 +76,10 @@ struct goodix_ts_data {
 #define MAX_CONTACTS_LOC	5
 #define TRIGGER_LOC		6
 
+#define GOODIX_TOUCH_NUM_MASK		0x0f
+#define GOODIX_SOFTBUTTON_MASK		0x10
+#define GOODIX_SOFTBUTTON1		KEY_LEFTMETA
+
 static const unsigned long goodix_irq_flags[] = {
 	IRQ_TYPE_EDGE_RISING,
 	IRQ_TYPE_EDGE_FALLING,
@@ -208,7 +212,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
 	if (!(data[0] & 0x80))
 		return -EAGAIN;
 
-	touch_num = data[0] & 0x0f;
+	touch_num = data[0] & GOODIX_TOUCH_NUM_MASK;
 	if (touch_num > ts->max_touch_num)
 		return -EPROTO;
 
@@ -223,7 +227,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
 			return error;
 	}
 
-	return touch_num;
+	return data[0];
 }
 
 static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
@@ -260,13 +264,17 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
 static void goodix_process_events(struct goodix_ts_data *ts)
 {
 	u8  point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
-	int touch_num;
+	int touch_num, status;
 	int i;
 
-	touch_num = goodix_ts_read_input_report(ts, point_data);
-	if (touch_num < 0)
+	status = goodix_ts_read_input_report(ts, point_data);
+	if (status < 0)
 		return;
 
+	input_report_key(ts->input_dev, GOODIX_SOFTBUTTON1,
+			!!(status & GOODIX_SOFTBUTTON_MASK));
+
+	touch_num = status & GOODIX_TOUCH_NUM_MASK;
 	for (i = 0; i < touch_num; i++)
 		goodix_ts_report_touch(ts,
 				&point_data[1 + GOODIX_CONTACT_SIZE * i]);
@@ -612,6 +620,8 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)
 	ts->input_dev->id.product = ts->id;
 	ts->input_dev->id.version = ts->version;
 
+	input_set_capability(ts->input_dev, EV_KEY, GOODIX_SOFTBUTTON1);
+
 	error = input_register_device(ts->input_dev);
 	if (error) {
 		dev_err(&ts->client->dev,
Acked-by Tested-by on v1 1/1
#1 lore raw

Hi,

Quoted 10 lines · Sergei A. Trusov

On some x86 tablets with a goodix touchscreen the windows logo on the front is a capacitive home button. Touching this button results in a touch with bit 4 of the 0th byte set, while normally only the lower 4 bits are used to indicate the number of touches.

Detect this and report a KEY_LEFTMETA press when this happens. Note the hardware might support more than one button, the number of a button is reported by the 'id' byte of coor_data. Now we ignore button id.

The changes look good to me:

Also this makes the capacitive home button on my HP stream 7 work, so:

Regards,

Hans

Quoted 68 lines
---
  drivers/input/touchscreen/goodix.c | 20 +++++++++++++++-----
  1 file changed, 15 insertions(+), 5 deletions(-)
drivers/input/touchscreen/goodix.c +15 -5
index 240b16f3ee97..a4c17c461792 100644
@@ -76,6 +76,10 @@ struct goodix_ts_data {
  #define MAX_CONTACTS_LOC	5
  #define TRIGGER_LOC		6
 
+#define GOODIX_TOUCH_NUM_MASK		0x0f
+#define GOODIX_SOFTBUTTON_MASK		0x10
+#define GOODIX_SOFTBUTTON1		KEY_LEFTMETA
+
  static const unsigned long goodix_irq_flags[] = {
  	IRQ_TYPE_EDGE_RISING,
  	IRQ_TYPE_EDGE_FALLING,
@@ -208,7 +212,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
  	if (!(data[0] & 0x80))
  		return -EAGAIN;
 
-	touch_num = data[0] & 0x0f;
+	touch_num = data[0] & GOODIX_TOUCH_NUM_MASK;
  	if (touch_num > ts->max_touch_num)
  		return -EPROTO;
 
@@ -223,7 +227,7 @@ static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data)
  			return error;
  	}
 
-	return touch_num;
+	return data[0];
  }
 
  static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
@@ -260,13 +264,17 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
  static void goodix_process_events(struct goodix_ts_data *ts)
  {
  	u8  point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
-	int touch_num;
+	int touch_num, status;
  	int i;
 
-	touch_num = goodix_ts_read_input_report(ts, point_data);
-	if (touch_num < 0)
+	status = goodix_ts_read_input_report(ts, point_data);
+	if (status < 0)
  		return;
 
+	input_report_key(ts->input_dev, GOODIX_SOFTBUTTON1,
+			!!(status & GOODIX_SOFTBUTTON_MASK));
+
+	touch_num = status & GOODIX_TOUCH_NUM_MASK;
  	for (i = 0; i < touch_num; i++)
  		goodix_ts_report_touch(ts,
  				&point_data[1 + GOODIX_CONTACT_SIZE * i]);
@@ -612,6 +620,8 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)
  	ts->input_dev->id.product = ts->id;
  	ts->input_dev->id.version = ts->version;
 
+	input_set_capability(ts->input_dev, EV_KEY, GOODIX_SOFTBUTTON1);
+
  	error = input_register_device(ts->input_dev);
  	if (error) {
  		dev_err(&ts->client->dev,
#2 lore raw
In reply to Sergei A. Trusov
Quoted 34 lines · Sergei A. Trusov

On some x86 tablets with a goodix touchscreen the windows logo on the front is a capacitive home button. Touching this button results in a touch
with bit 4 of the 0th byte set, while normally only the lower 4 bits are used to indicate the number of touches.

Detect this and report a KEY_LEFTMETA press when this happens. Note the
hardware might support more than one button, the number of a button is
reported by the 'id' byte of coor_data. Now we ignore button id.

---
 drivers/input/touchscreen/goodix.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/input/touchscreen/goodix.c +4 -0
index 240b16f3ee97..a4c17c461792 100644
@@ -76,6 +76,10 @@ struct goodix_ts_data {
 #define MAX_CONTACTS_LOC	5
 #define TRIGGER_LOC		6
 
+#define GOODIX_TOUCH_NUM_MASK		0x0f
+#define GOODIX_SOFTBUTTON_MASK		0x10
+#define GOODIX_SOFTBUTTON1		KEY_LEFTMETA
+
 static const unsigned long goodix_irq_flags[] = {
 	IRQ_TYPE_EDGE_RISING,
 	IRQ_TYPE_EDGE_FALLING,

drivers/input/touchscreen/goodix.c static int goodix_ts_read_input_report(struct · line 216

Quoted 6 lines
drivers/input/touchscreen/goodix.c +1 -1
@@ -208,7 +212,7 @@ static int goodix_ts_read_input_report(struct
 goodix_ts_data *ts, u8 *data)
 	if (!(data[0] & 0x80))
 		return -EAGAIN;
 
-	touch_num = data[0] & 0x0f;
+	touch_num = data[0] & GOODIX_TOUCH_NUM_MASK;

This should be a separate patch.

drivers/input/touchscreen/goodix.c static int goodix_ts_read_input_report(struct · line 231

Quoted 10 lines
drivers/input/touchscreen/goodix.c +1 -1
 	if (touch_num > ts->max_touch_num)
 		return -EPROTO;
@@ -223,7 +227,7 @@ static int goodix_ts_read_input_report(struct
 goodix_ts_data *ts, u8 *data)
 			return error;
 	}
 
-	return touch_num;
+	return data[0];

I really don't like it when we change the meaning of a function's return value without changing the function's name, or explaining that we're doing that. This should be a separate patch please.

Quoted 29 lines
drivers/input/touchscreen/goodix.c +0 -0
 }
 

static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8
*coor_data)

drivers/input/touchscreen/goodix.c +7 -3
@@ -260,13 +264,17 @@ static void goodix_ts_report_touch(struct
 goodix_ts_data *ts, u8 *coor_data)
 static void goodix_process_events(struct goodix_ts_data *ts)
 {
 	u8  point_data[1 + GOODIX_CONTACT_SIZE *
 GOODIX_MAX_CONTACTS];
-	int touch_num;
+	int touch_num, status;
 	int i;
 
-	touch_num = goodix_ts_read_input_report(ts, point_data);
-	if (touch_num < 0)
+	status = goodix_ts_read_input_report(ts, point_data);
+	if (status < 0)
 		return;
 
+	input_report_key(ts->input_dev, GOODIX_SOFTBUTTON1,
+			!!(status & GOODIX_SOFTBUTTON_MASK));
+
+	touch_num = status & GOODIX_TOUCH_NUM_MASK;
 	for (i = 0; i < touch_num; i++)
drivers/input/touchscreen/goodix.c +0 -0
 		goodix_ts_report_touch(ts,
 				&point_data[1 + GOODIX_CONTACT_SIZE

* i]);

drivers/input/touchscreen/goodix.c static int goodix_request_input_dev(struct · line 625

Quoted 6 lines
drivers/input/touchscreen/goodix.c +1 -0
@@ -612,6 +620,8 @@ static int goodix_request_input_dev(struct
 goodix_ts_data *ts)
 	ts->input_dev->id.product = ts->id;
 	ts->input_dev->id.version = ts->version;
 
+	input_set_capability(ts->input_dev, EV_KEY,
 GOODIX_SOFTBUTTON1);

I don't like this define though, please use KEY_LEFTMETA directly. We can change it to a constant when we have more than one softbutton.

General question though, should we not only export and advertise the button if it exists on the device?

Quoted 5 lines
drivers/input/touchscreen/goodix.c +1 -0
+
 	error = input_register_device(ts->input_dev);
drivers/input/touchscreen/goodix.c +0 -0
 	if (error) {
 		dev_err(&ts->client->dev,
maintainer
#3 lore raw
Quoted 92 lines · Bastien Nocera
Quoted 34 lines · Sergei A. Trusov

On some x86 tablets with a goodix touchscreen the windows logo on the front is a capacitive home button. Touching this button results in a touch
with bit 4 of the 0th byte set, while normally only the lower 4 bits are used to indicate the number of touches.

Detect this and report a KEY_LEFTMETA press when this happens. Note the
hardware might support more than one button, the number of a button is
reported by the 'id' byte of coor_data. Now we ignore button id.

---
 drivers/input/touchscreen/goodix.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/input/touchscreen/goodix.c +4 -0
index 240b16f3ee97..a4c17c461792 100644
@@ -76,6 +76,10 @@ struct goodix_ts_data {
 #define MAX_CONTACTS_LOC	5
 #define TRIGGER_LOC		6
 
+#define GOODIX_TOUCH_NUM_MASK		0x0f
+#define GOODIX_SOFTBUTTON_MASK		0x10
+#define GOODIX_SOFTBUTTON1		KEY_LEFTMETA
+
 static const unsigned long goodix_irq_flags[] = {
 	IRQ_TYPE_EDGE_RISING,
 	IRQ_TYPE_EDGE_FALLING,

drivers/input/touchscreen/goodix.c static int goodix_ts_read_input_report(struct · line 216

Quoted 6 lines
drivers/input/touchscreen/goodix.c +1 -1
@@ -208,7 +212,7 @@ static int goodix_ts_read_input_report(struct
 goodix_ts_data *ts, u8 *data)
 	if (!(data[0] & 0x80))
 		return -EAGAIN;
 
-	touch_num = data[0] & 0x0f;
+	touch_num = data[0] & GOODIX_TOUCH_NUM_MASK;

This should be a separate patch.

drivers/input/touchscreen/goodix.c static int goodix_ts_read_input_report(struct · line 231

Quoted 10 lines
drivers/input/touchscreen/goodix.c +1 -1
 	if (touch_num > ts->max_touch_num)
 		return -EPROTO;
@@ -223,7 +227,7 @@ static int goodix_ts_read_input_report(struct
 goodix_ts_data *ts, u8 *data)
 			return error;
 	}
 
-	return touch_num;
+	return data[0];

I really don't like it when we change the meaning of a function's return value without changing the function's name, or explaining that we're doing that. This should be a separate patch please.

Quoted 33 lines
drivers/input/touchscreen/goodix.c +0 -0
 }
 

static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8
*coor_data)

drivers/input/touchscreen/goodix.c +7 -3
@@ -260,13 +264,17 @@ static void goodix_ts_report_touch(struct
 goodix_ts_data *ts, u8 *coor_data)
 static void goodix_process_events(struct goodix_ts_data *ts)
 {
 	u8  point_data[1 + GOODIX_CONTACT_SIZE *
 GOODIX_MAX_CONTACTS];
-	int touch_num;
+	int touch_num, status;
 	int i;
 
-	touch_num = goodix_ts_read_input_report(ts, point_data);
-	if (touch_num < 0)
+	status = goodix_ts_read_input_report(ts, point_data);
+	if (status < 0)
 		return;
 
+	input_report_key(ts->input_dev, GOODIX_SOFTBUTTON1,
+			!!(status & GOODIX_SOFTBUTTON_MASK));
+
+	touch_num = status & GOODIX_TOUCH_NUM_MASK;
 	for (i = 0; i < touch_num; i++)
drivers/input/touchscreen/goodix.c +0 -0
 		goodix_ts_report_touch(ts,
 				&point_data[1 + GOODIX_CONTACT_SIZE

* i]);

drivers/input/touchscreen/goodix.c +0 -0
@@ -612,6 +620,8 @@ static int goodix_request_input_dev(struct
 goodix_ts_data *ts)
 	ts->input_dev->id.product = ts->id;
 	ts->input_dev->id.version = ts->version;
 
Quoted 8 lines

drivers/input/touchscreen/goodix.c static int goodix_request_input_dev(struct · line 625

Quoted 2 lines
drivers/input/touchscreen/goodix.c +1 -0
+	input_set_capability(ts->input_dev, EV_KEY,
 GOODIX_SOFTBUTTON1);

I don't like this define though, please use KEY_LEFTMETA directly. We can change it to a constant when we have more than one softbutton.

General question though, should we not only export and advertise the button if it exists on the device?

Yes, this is preferred behavior.

Quoted 6 lines
Quoted 6 lines
drivers/input/touchscreen/goodix.c +1 -0
+
 	error = input_register_device(ts->input_dev);
drivers/input/touchscreen/goodix.c +0 -0
 	if (error) {
 		dev_err(&ts->client->dev,
Signature · 1 line
Dmitry
#4 lore raw
Quoted 5 lines · Dmitry Torokhov
Quoted 3 lines

General question though, should we not only export and advertise the
button if it exists on the device?

Yes, this is preferred behavior.

So we'll want a dmi match table for the devices that need this feature, and only export the button for those.

Cheers

#5 lore raw

Hi,

Quoted 9 lines · Bastien Nocera
Quoted 5 lines · Dmitry Torokhov
Quoted 3 lines

General question though, should we not only export and advertise the
button if it exists on the device?

Yes, this is preferred behavior.

So we'll want a dmi match table for the devices that need this feature, and only export the button for those.

Note Dmitry said that this is preferred behavior, not something which we MUST do. And TBH I don't think that using a DMI table is a good idea, the capacitive home-button is not only found on the HP stream 7 but also on various cheap tablets, of which there tend to be a lot, so the DMI table is going to be use. And the cheap tablets often have useful model strings such as e.g. "Default String" making DMI matching a nasty problem.

So IMHO it is better to just always report the presence of the home button, in practice I don't think userspace is going to have any problems with this.

Regards,

Hans

#7 lore raw
In reply to Sergei A. Trusov
Quoted 1 line · Sergei A. Trusov

<snip>

Quoted 4 lines

Thank you for this point. Now I see all the changes above are redundant:
we can use a value returned in the *data buffer. It is enough to add only two lines of code to achieve the behaviour of this entire patch.

A bit more with a comment explaining the reason behind those 2 lines, but shorter patches get my vote ;)

#6 lore raw
In reply to Bastien Nocera
Quoted 52 lines · On Tuesday, 20 June 2017 08:32:03 +10 Bastien Nocera wrote:
Quoted 34 lines · Sergei A. Trusov

On some x86 tablets with a goodix touchscreen the windows logo on the front is a capacitive home button. Touching this button results in a touch
with bit 4 of the 0th byte set, while normally only the lower 4 bits are used to indicate the number of touches.

Detect this and report a KEY_LEFTMETA press when this happens. Note the
hardware might support more than one button, the number of a button is
reported by the 'id' byte of coor_data. Now we ignore button id.

---
 drivers/input/touchscreen/goodix.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/input/touchscreen/goodix.c +4 -0
index 240b16f3ee97..a4c17c461792 100644
@@ -76,6 +76,10 @@ struct goodix_ts_data {
 #define MAX_CONTACTS_LOC	5
 #define TRIGGER_LOC		6
 
+#define GOODIX_TOUCH_NUM_MASK		0x0f
+#define GOODIX_SOFTBUTTON_MASK		0x10
+#define GOODIX_SOFTBUTTON1		KEY_LEFTMETA
+
 static const unsigned long goodix_irq_flags[] = {
 	IRQ_TYPE_EDGE_RISING,
 	IRQ_TYPE_EDGE_FALLING,

drivers/input/touchscreen/goodix.c static int goodix_ts_read_input_report(struct · line 216

Quoted 6 lines
drivers/input/touchscreen/goodix.c +1 -1
@@ -208,7 +212,7 @@ static int goodix_ts_read_input_report(struct
 goodix_ts_data *ts, u8 *data)
 	if (!(data[0] & 0x80))
 		return -EAGAIN;
 
-	touch_num = data[0] & 0x0f;
+	touch_num = data[0] & GOODIX_TOUCH_NUM_MASK;

This should be a separate patch.

Quoted 8 lines
drivers/input/touchscreen/goodix.c +0 -0
 	if (touch_num > ts->max_touch_num)
 		return -EPROTO;
@@ -223,7 +227,7 @@ static int goodix_ts_read_input_report(struct
 goodix_ts_data *ts, u8 *data)
 			return error;
 	}
 
Quoted 6 lines

drivers/input/touchscreen/goodix.c static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) · line 230

Quoted 2 lines
drivers/input/touchscreen/goodix.c +1 -1
-	return touch_num;
+	return data[0];

I really don't like it when we change the meaning of a function's return value without changing the function's name, or explaining that we're doing that. This should be a separate patch please.

Thank you for this point. Now I see all the changes above are redundant:
we can use a value returned in the *data buffer. It is enough to add only two lines of code to achieve the behaviour of this entire patch.

Quoted 15 lines
Quoted 15 lines
drivers/input/touchscreen/goodix.c +0 -0
 }
 

static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8
*coor_data)

drivers/input/touchscreen/goodix.c +1 -1
@@ -260,13 +264,17 @@ static void goodix_ts_report_touch(struct
 goodix_ts_data *ts, u8 *coor_data)
 static void goodix_process_events(struct goodix_ts_data *ts)
 {
 	u8  point_data[1 + GOODIX_CONTACT_SIZE *
 GOODIX_MAX_CONTACTS];
-	int touch_num;
+	int touch_num, status;
 	int i;
 
Quoted 8 lines

drivers/input/touchscreen/goodix.c static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) · line 275

Quoted 8 lines
drivers/input/touchscreen/goodix.c +4 -2
-	touch_num = goodix_ts_read_input_report(ts, point_data);
-	if (touch_num < 0)
+	status = goodix_ts_read_input_report(ts, point_data);
+	if (status < 0)
 		return;
 
+	input_report_key(ts->input_dev, GOODIX_SOFTBUTTON1,
+			!!(status & GOODIX_SOFTBUTTON_MASK));

Just this one do the job:
+ input_report_key(ts->input_dev, KEY_LEFTMETA, !!(point_data[0] & 0x10));

Quoted 11 lines
Quoted 11 lines
drivers/input/touchscreen/goodix.c +2 -0
+
+	touch_num = status & GOODIX_TOUCH_NUM_MASK;
 	for (i = 0; i < touch_num; i++)
drivers/input/touchscreen/goodix.c +0 -0
 		goodix_ts_report_touch(ts,
 				&point_data[1 + GOODIX_CONTACT_SIZE

* i]);

drivers/input/touchscreen/goodix.c +0 -0
@@ -612,6 +620,8 @@ static int goodix_request_input_dev(struct
 goodix_ts_data *ts)
 	ts->input_dev->id.product = ts->id;
 	ts->input_dev->id.version = ts->version;
 
Quoted 5 lines

drivers/input/touchscreen/goodix.c static int goodix_request_input_dev(struct · line 625

Quoted 2 lines
drivers/input/touchscreen/goodix.c +1 -0
+	input_set_capability(ts->input_dev, EV_KEY,
 GOODIX_SOFTBUTTON1);

I don't like this define though, please use KEY_LEFTMETA directly. We can change it to a constant when we have more than one softbutton.

Ok.

Quoted 13 lines

General question though, should we not only export and advertise the button if it exists on the device?

drivers/input/touchscreen/goodix.c static int goodix_request_input_dev(struct goodix_ts_data *ts) · line 627

Quoted 5 lines
drivers/input/touchscreen/goodix.c +1 -0
+
 	error = input_register_device(ts->input_dev);
drivers/input/touchscreen/goodix.c +0 -0
 	if (error) {
 		dev_err(&ts->client->dev,

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

#8 lore raw
In reply to Bastien Nocera
Quoted 10 lines · On Tuesday, 20 June 2017 19:29:01 +10 Bastien Nocera wrote:
Quoted 1 line · Sergei A. Trusov

<snip>

Quoted 4 lines

Thank you for this point. Now I see all the changes above are redundant:
we can use a value returned in the *data buffer. It is enough to add only two lines of code to achieve the behaviour of this entire patch.

A bit more with a comment explaining the reason behind those 2 lines, but shorter patches get my vote ;)

Current goodix_ts_read_input_report() function puts data from hardware into point_data buffer. Then in masks high niblle of the first byte and returns it as touch_num. We need this masked nibble to check, so I was trying to remove mask operation. After your comment I just realized that proposed patch should be much shorter. I have included more context lines to make cleaner my attempts to explain (as I am affraid my English is not so good):

---

drivers/input/touchscreen/goodix.c +4 -0
index 240b16f3ee97..0c3825c39288 100644
@@ -262,16 +262,18 @@ static void goodix_process_events(struct goodix_ts_data *ts)
 	u8  point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
 	int touch_num;
 	int i;
 
 	touch_num = goodix_ts_read_input_report(ts, point_data);
 	if (touch_num < 0)
 		return;
 
+	input_report_key(ts->input_dev, KEY_LEFTMETA, !!(point_data[0] & 0x10));
+
 	for (i = 0; i < touch_num; i++)
 		goodix_ts_report_touch(ts,
 				&point_data[1 + GOODIX_CONTACT_SIZE * i]);
 
 	input_mt_sync_frame(ts->input_dev);
 	input_sync(ts->input_dev);
 }
 
@@ -607,16 +609,18 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)
 
 	ts->input_dev->name = "Goodix Capacitive TouchScreen";
 	ts->input_dev->phys = "input/ts";
 	ts->input_dev->id.bustype = BUS_I2C;
 	ts->input_dev->id.vendor = 0x0416;
 	ts->input_dev->id.product = ts->id;
 	ts->input_dev->id.version = ts->version;
 
+	input_set_capability(ts->input_dev, EV_KEY, KEY_LEFTMETA);
+
 	error = input_register_device(ts->input_dev);
 	if (error) {
 		dev_err(&ts->client->dev,
 			"Failed to register input device: %d", error);
 		return error;
 	}
 
 	return 0;
#9 lore raw
Quoted 13 lines · Sergei A. Trusov
Quoted 11 lines · On Tuesday, 20 June 2017 19:29:01 +10 Bastien Nocera wrote:
Quoted 1 line · Sergei A. Trusov

<snip>

Quoted 4 lines

Thank you for this point. Now I see all the changes above are redundant:
we can use a value returned in the *data buffer. It is enough to add only two lines of code to achieve the behaviour of this entire patch.

A bit more with a comment explaining the reason behind those 2 lines, but shorter patches get my vote ;)

Quoted 7 lines

Current goodix_ts_read_input_report() function puts data from hardware into point_data buffer. Then in masks high niblle of the first byte and returns it as touch_num. We need this masked nibble to check, so I was trying to remove mask operation. After your comment I just realized that proposed patch should be much shorter. I have included more context lines to make cleaner my attempts to explain (as I am affraid my English is not so good):

Do you want to re-send with the comments added as below?

Quoted 6 lines

---

drivers/input/touchscreen/goodix.c +0 -0
index 240b16f3ee97..0c3825c39288 100644

drivers/input/touchscreen/goodix.c static void goodix_process_events(struct goodix_ts_data *ts) · line 270

Quoted 9 lines
drivers/input/touchscreen/goodix.c +1 -0
@@ -262,16 +262,18 @@ static void goodix_process_events(struct goodix_ts_data *ts)
 	u8  point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
 	int touch_num;
 	int i;
 
 	touch_num = goodix_ts_read_input_report(ts, point_data);
 	if (touch_num < 0)
 		return;
 
+	input_report_key(ts->input_dev, KEY_LEFTMETA, !!(point_data[0] & 0x10));

You can add a comment above:
Bit 4 of the first byte reports the status of the capacitive Windows/Home button.

Quoted 9 lines
drivers/input/touchscreen/goodix.c +0 -0
 	for (i = 0; i < touch_num; i++)
 		goodix_ts_report_touch(ts,
 				&point_data[1 + GOODIX_CONTACT_SIZE * i]);
 
 	input_mt_sync_frame(ts->input_dev);
 	input_sync(ts->input_dev);
 }
 

drivers/input/touchscreen/goodix.c static int goodix_request_input_dev(struct goodix_ts_data *ts) · line 617

Quoted 9 lines
drivers/input/touchscreen/goodix.c +1 -0
@@ -607,16 +609,18 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)
 
 	ts->input_dev->name = "Goodix Capacitive TouchScreen";
 	ts->input_dev->phys = "input/ts";
 	ts->input_dev->id.bustype = BUS_I2C;
 	ts->input_dev->id.vendor = 0x0416;
 	ts->input_dev->id.product = ts->id;
 	ts->input_dev->id.version = ts->version;
 
+	input_set_capability(ts->input_dev, EV_KEY, KEY_LEFTMETA);

Add a comment above:
Capacitive Windows/Home button on some devices

Quoted 9 lines
drivers/input/touchscreen/goodix.c +0 -0
 	error = input_register_device(ts->input_dev);
 	if (error) {
 		dev_err(&ts->client->dev,
 			"Failed to register input device: %d", error);
 		return error;
 	}
 
 	return 0;
#10 lore raw
Quoted 22 lines · On Tuesday, 20 June 2017 20:20:03 +10 Bastien Nocera wrote:
Quoted 13 lines · Sergei A. Trusov
Quoted 11 lines · On Tuesday, 20 June 2017 19:29:01 +10 Bastien Nocera wrote:
Quoted 1 line · Sergei A. Trusov

<snip>

Quoted 4 lines

Thank you for this point. Now I see all the changes above are redundant:
we can use a value returned in the *data buffer. It is enough to add only two lines of code to achieve the behaviour of this entire patch.

A bit more with a comment explaining the reason behind those 2 lines, but shorter patches get my vote ;)

Quoted 7 lines

Current goodix_ts_read_input_report() function puts data from hardware into point_data buffer. Then in masks high niblle of the first byte and returns it as touch_num. We need this masked nibble to check, so I was trying to remove mask operation. After your comment I just realized that proposed patch should be much shorter. I have included more context lines to make cleaner my attempts to explain (as I am affraid my English is not so good):

Quoted 1 line

Do you want to re-send with the comments added as below?

Yes, thank you, I'll add those and send v2.

Quoted 57 lines
Quoted 7 lines

---

drivers/input/touchscreen/goodix.c +0 -0
index 240b16f3ee97..0c3825c39288 100644

drivers/input/touchscreen/goodix.c static void goodix_process_events(struct goodix_ts_data *ts) · line 270

Quoted 9 lines
drivers/input/touchscreen/goodix.c +1 -0
@@ -262,16 +262,18 @@ static void goodix_process_events(struct goodix_ts_data *ts)
 	u8  point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS];
 	int touch_num;
 	int i;
 
 	touch_num = goodix_ts_read_input_report(ts, point_data);
 	if (touch_num < 0)
 		return;
 
+	input_report_key(ts->input_dev, KEY_LEFTMETA, !!(point_data[0] & 0x10));

You can add a comment above:
Bit 4 of the first byte reports the status of the capacitive Windows/Home button.

Quoted 9 lines
drivers/input/touchscreen/goodix.c +0 -0
 	for (i = 0; i < touch_num; i++)
 		goodix_ts_report_touch(ts,
 				&point_data[1 + GOODIX_CONTACT_SIZE * i]);
 
 	input_mt_sync_frame(ts->input_dev);
 	input_sync(ts->input_dev);
 }
 

drivers/input/touchscreen/goodix.c static int goodix_request_input_dev(struct goodix_ts_data *ts) · line 617

Quoted 9 lines
drivers/input/touchscreen/goodix.c +1 -0
@@ -607,16 +609,18 @@ static int goodix_request_input_dev(struct goodix_ts_data *ts)
 
 	ts->input_dev->name = "Goodix Capacitive TouchScreen";
 	ts->input_dev->phys = "input/ts";
 	ts->input_dev->id.bustype = BUS_I2C;
 	ts->input_dev->id.vendor = 0x0416;
 	ts->input_dev->id.product = ts->id;
 	ts->input_dev->id.version = ts->version;
 
+	input_set_capability(ts->input_dev, EV_KEY, KEY_LEFTMETA);

Add a comment above:
Capacitive Windows/Home button on some devices

drivers/input/touchscreen/goodix.c static int goodix_request_input_dev(struct goodix_ts_data *ts) · line 626

Quoted 9 lines
drivers/input/touchscreen/goodix.c +0 -0
 	error = input_register_device(ts->input_dev);
 	if (error) {
 		dev_err(&ts->client->dev,
 			"Failed to register input device: %d", error);
 		return error;
 	}
 
 	return 0;

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