Skip to contentSkip to conversation

HID: input: Finish TransducerSerialNumber implementation

PATCH In review Jason Gerecke 5 participants 8 messages Sep 22, 2014 – Oct 29, 2014 2 messages not in the archive HID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: input: Finish TransducerSerialNumber implementation

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the code to send a MSC_SERIAL event to userspace when this usage is seen in a report is nowhere to be found. This commit addresses both issues.

---
 drivers/hid/hid-input.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/hid/hid-input.c +9 -0
index 2619f7f..abed624 100644
@@ -690,6 +690,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 
 		case 0x5b: /* TransducerSerialNumber */
 			set_bit(MSC_SERIAL, input->mscbit);
+			usage->type = EV_MSC;
+			usage->code = MSC_SERIAL;
+			bit = input->mscbit;
+			max = MSC_MAX;
 			break;
 
 		default:  goto unknown;
@@ -1041,6 +1045,11 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
 		input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3));
 	}
 
+	if (usage->hid == (HID_UP_DIGITIZER | 0x005b)) { /* TransducerSerialNumber */
+		input_event(input, EV_MSC, MSC_SERIAL, value);
+		return;
+	}
+
 	if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
 		dbg_hid("Maximum Effects - %d\n",value);
 		return;
Signature · 1 line
2.1.0
#1 lore raw

Hi Jason,

Quoted 28 lines · Jason Gerecke

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the code to send a MSC_SERIAL event to userspace when this usage is seen in a report is nowhere to be found. This commit addresses both issues.

---
 drivers/hid/hid-input.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/hid/hid-input.c +4 -0
index 2619f7f..abed624 100644
@@ -690,6 +690,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 
 		case 0x5b: /* TransducerSerialNumber */
 			set_bit(MSC_SERIAL, input->mscbit);
+			usage->type = EV_MSC;
+			usage->code = MSC_SERIAL;
+			bit = input->mscbit;
+			max = MSC_MAX;
 			break;
 
 		default:  goto unknown;

drivers/hid/hid-input.c void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct · line 1052

Quoted 8 lines
drivers/hid/hid-input.c +5 -0
@@ -1041,6 +1045,11 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
 		input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a) >> 3));
 	}
 
+	if (usage->hid == (HID_UP_DIGITIZER | 0x005b)) { /* TransducerSerialNumber */
+		input_event(input, EV_MSC, MSC_SERIAL, value);
+		return;
+	}
+

Are you sure that the generic call to
"input_event(input, usage->type, usage->code, value);" in the end of hidinput_hid_event() is not sufficient enough?

As long as the usage/code are set in the hid_usage struct, you should be fine.

Cheers,
Benjamin

Quoted 6 lines
drivers/hid/hid-input.c +0 -0
 	if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects Max */
 		dbg_hid("Maximum Effects - %d\n",value);
 		return;
Signature · 1 line
2.1.0
#2 lore raw
Quoted 58 lines

-----Original Message-----
From: Benjamin Tissoires [mailto:[email protected]]
Sent: Tuesday, September 23, 2014 8:12 AM
To: Jason Gerecke
Cc: [email protected]; [email protected]; [email protected]; Jason Gerecke
Subject: Re: [PATCH] HID: input: Finish TransducerSerialNumber implementation

Hi Jason,

Quoted 6 lines · Jason Gerecke

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the code to send a MSC_SERIAL event to userspace when this usage is seen in a report is nowhere to be found. This commit

addresses both issues.

drivers/hid/hid-input.c void hidinput_hid_event(struct hid_device *hid,

Quoted 23 lines
---
 drivers/hid/hid-input.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/hid/hid-input.c index renamed from drivers/hid/hid-input.c +0 -0

2619f7f..abed624 100644

drivers/hid/hid-input.c +0 -0
@@ -690,6 +690,10 @@ static void hidinput_configure_usage(struct

hid_input *hidinput, struct hid_fiel

drivers/hid/hid-input.c +4 -0
 		case 0x5b: /* TransducerSerialNumber */
 			set_bit(MSC_SERIAL, input->mscbit);
+			usage->type = EV_MSC;
+			usage->code = MSC_SERIAL;
+			bit = input->mscbit;
+			max = MSC_MAX;
 			break;
 
 		default:  goto unknown;
@@ -1041,6 +1045,11 @@ void hidinput_hid_event(struct hid_device *hid,

struct hid_field *field, struct

drivers/hid/hid-input.c void hidinput_hid_event(struct hid_device *hid, · line 1049

Quoted 5 lines
drivers/hid/hid-input.c +1 -0
 		input_event(input, EV_KEY, BTN_TOUCH, value > a + ((b - a)
 > 3));
 	}
 
+	if (usage->hid == (HID_UP_DIGITIZER | 0x005b)) { /*

TransducerSerialNumber */

drivers/hid/hid-input.c void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct · line 1052

Quoted 4 lines
drivers/hid/hid-input.c +4 -0
+		input_event(input, EV_MSC, MSC_SERIAL, value);
+		return;
+	}
+

Are you sure that the generic call to
"input_event(input, usage->type, usage->code, value);" in the end of hidinput_hid_event() is not sufficient enough?

Quoted 5 lines

As long as the usage/code are set in the hid_usage struct, you should be fine.

Cheers,
Benjamin

Hmmm... This might be an issue with the HID descriptor, actually. It looks like my hardware doesn't set the logical minimum and maximum for the field, so the (quite out-of-range) value is ignored. I start seeing data after patching the descriptor to add these in, but the code is set to MSC_PULSELED instead of MSC_SERIAL. I suspect that the existing call to 'set_bit' in the TransducerSerialNumber case is to blame (which makes it act like 'map_foo' instead of 'map_foo_clear').

Updated patch forthcoming...

Jason

Quoted 7 lines

drivers/hid/hid-input.c void hidinput_hid_event(struct hid_device *hid, · line 1054

Quoted 1 line
drivers/hid/hid-input.c +0 -0
 	if (usage->hid == (HID_UP_PID | 0x83UL)) { /* Simultaneous Effects

Max */

Quoted 5 lines
drivers/hid/hid-input.c +0 -0
 		dbg_hid("Maximum Effects - %d\n",value);

return;
--
2.1.0

A message that is not in the archive (sent off-list or not yet received): Message-ID: <[email protected]

#4 lore raw

PATCH 1/1 HID: input: Fix TransducerSerialNumber implementation

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the call to 'set_bit' causes MSC_PULSELED to be sent instead of the expected MSC_SERIAL. This commit addreses both issues.

---
 drivers/hid/hid-input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +4 -1
index 2619f7f..cb1b3fa 100644
@@ -689,7 +689,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 			break;
 
 		case 0x5b: /* TransducerSerialNumber */
-			set_bit(MSC_SERIAL, input->mscbit);
+			usage->type = EV_MSC;
+			usage->code = MSC_SERIAL;
+			bit = input->mscbit;
+			max = MSC_MAX;
 			break;
 
 		default:  goto unknown;
Signature · 1 line
2.1.0
#5 lore raw

Re: [PATCH] HID: input: Fix TransducerSerialNumber implementation

Quoted 29 lines · Jason Gerecke

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the call to 'set_bit' causes MSC_PULSELED to be sent instead of the expected MSC_SERIAL. This commit addreses both issues.

---
 drivers/hid/hid-input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +4 -2
index 2619f7f..cb1b3fa 100644
@@ -689,7 +689,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        break;
 
                case 0x5b: /* TransducerSerialNumber */
-                       set_bit(MSC_SERIAL, input->mscbit);
+                       usage->type = EV_MSC;
+                       usage->code = MSC_SERIAL;
+                       bit = input->mscbit;
+                       max = MSC_MAX;
                        break;
 
                default:  goto unknown;
--
Quoted 2 lines

2.1.0

This patch still seems to be in limbo. Anyone (Ping? Benjamin?) care to provide an ACK or review?

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....
--
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

Reviewed-by
#6 lore raw

Re: [PATCH] HID: input: Fix TransducerSerialNumber implementation

Quoted 28 lines · Jason Gerecke
Quoted 27 lines · Jason Gerecke

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the call to 'set_bit' causes MSC_PULSELED to be sent instead of the expected MSC_SERIAL. This commit addreses both issues.

---
 drivers/hid/hid-input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +4 -1
index 2619f7f..cb1b3fa 100644
@@ -689,7 +689,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        break;
 
                case 0x5b: /* TransducerSerialNumber */
-                       set_bit(MSC_SERIAL, input->mscbit);
+                       usage->type = EV_MSC;
+                       usage->code = MSC_SERIAL;
+                       bit = input->mscbit;
+                       max = MSC_MAX;
                        break;
 
Quoted 8 lines
Quoted 4 lines
drivers/hid/hid-input.c +0 -1
                default:  goto unknown;
--

2.1.0

This patch still seems to be in limbo. Anyone (Ping? Benjamin?) care to provide an ACK or review?

Sorry for that, I was persuaded I already have answered to this one.

The patch makes sense, but I think it will be better to extend hid_map_usage() with MSC bits and define map_msc_clear(). The code will be more consistent with the rest this way.

Anyway, if Jiri does not find this to be mandatory, then this code is:

Cheers,
Benjamin

A message that is not in the archive (sent off-list or not yet received): CAF8JNhKYmBpgp4yRvQbxuaAPSk5dG3YW7qqZnrBAB22bRXPEJg@mail.gmail.com

#8 lore raw

PATCH 1/1 HID: input: Fix TransducerSerialNumber implementation

Quoted 9 lines · Jason Gerecke

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the call to 'set_bit' causes MSC_PULSELED to be sent instead of the expected MSC_SERIAL. This commit addreses both issues.

Thank you, Jason, for the fix.

Ping

Quoted 23 lines
---
 drivers/hid/hid-input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +4 -2
index 2619f7f..cb1b3fa 100644
@@ -689,7 +689,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        break;
 
                case 0x5b: /* TransducerSerialNumber */
-                       set_bit(MSC_SERIAL, input->mscbit);
+                       usage->type = EV_MSC;
+                       usage->code = MSC_SERIAL;
+                       bit = input->mscbit;
+                       max = MSC_MAX;
                        break;
 
                default:  goto unknown;
--

2.1.0

#9 lore raw

Re: [PATCH] HID: input: Fix TransducerSerialNumber implementation

In reply to Jason Gerecke
Quoted 17 lines · Jason Gerecke

The commit which introduced TransducerSerialNumber (368c966) is missing two crucial implementation details. Firstly, the commit does not set the type/code/bit/max fields as expected later down the code which can cause the driver to crash when a tablet with this usage is connected. Secondly, the call to 'set_bit' causes MSC_PULSELED to be sent instead of the expected MSC_SERIAL. This commit addreses both issues.

---
 drivers/hid/hid-input.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +0 -0
index 2619f7f..cb1b3fa 100644

drivers/hid/hid-input.c static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel · line 697

Quoted 10 lines
drivers/hid/hid-input.c +4 -1
@@ -689,7 +689,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 			break;
 
 		case 0x5b: /* TransducerSerialNumber */
-			set_bit(MSC_SERIAL, input->mscbit);
+			usage->type = EV_MSC;
+			usage->code = MSC_SERIAL;
+			bit = input->mscbit;
+			max = MSC_MAX;
 			break;
 

Apologizes for the delay. I have now queued this for 3.18 still.

Signature · 2 lines
Jiri Kosina
SUSE Labs