From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:22:57
Hi guys,
so, this is the v2 of the support of win7/8 devices.
changes since v1:
- removed the "optimization" patches, as the benefit was minimum
- introduce a new callback "report" in hid-core that drivers can use to treat the
report by having it entirely parsed
- rely on this new hook to support Nexio 42"
side notes:
- I've tested removing the heavy call to kzalloc in hid_input_field. The results
are disapointing -> the processing time remains the same.
- I've also tested not to rely on .event hook in hid-multitouch but only on .report.
Idem, I thought it would reduce the code of hid-multitouch and will enhance its
processing time, but the results are a roughly same number of lines for hid-multitouch
and the same processing time... :(
- these 2 tests helped in cleaning the patch set from the last time.
And again, finally, I've pass all the 40 regression tests of my db. \o/
Cheers,
Benjamin
Benjamin Tissoires (9):
HID: core: add "report" hook, called once the report has been parsed
HID: multitouch: use the callback "report" instead of sequential
events
HID: multitouch: add support for Nexio 42" panel
HID: multitouch: fix Win8 protocol for Sharp like devices
HID: multitouch: ensure that serial devices make no use of contact
count
HID: multitouch: fix protocol for Sitronix 1403:5001
HID: multitouch: fix protocol for Cando 2087:0a02
HID: multitouch: fix protocol for Elo panels
HID: multitouch: make MT_CLS_ALWAYS_TRUE the new default class
drivers/hid/hid-core.c | 4 ++
drivers/hid/hid-ids.h | 3 +
drivers/hid/hid-multitouch.c | 142 ++++++++++++++++++++++++++++++++-----------
include/linux/hid.h | 2 +
4 files changed, 115 insertions(+), 36 deletions(-)
--
1.8.1
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:23:05
Nexio 42" devices requires to rely on the HID field Contact
Count to compute the valid values. However, this field is
most of the time at the end of the report, meaning that we
need to get the all report parsed before processing it.
This patch does not introduce functional changes.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-multitouch.c | 44 ++++++++++++++++++++++++++++++++++++++------
1 file changed, 38 insertions(+), 6 deletions(-)
@@ -85,6 +85,7 @@ struct mt_device {multitouchfields*/unsignedlast_field_index;/* last field index of the report */unsignedlast_slot_field;/* the last field of a slot */+unsignedmt_report_id;/* the report ID of the multitouch device */__s8inputmode;/* InputMode HID feature, -1 if non-existent */__s8inputmode_index;/* InputMode HID feature index in the report */__s8maxcontact_report_id;/* Maximum Contact Number HID feature,
@@ -578,6 +580,16 @@ static void mt_sync_frame(struct mt_device *td, struct input_dev *input)staticintmt_event(structhid_device*hid,structhid_field*field,structhid_usage*usage,__s32value){+/* we will handle the hidinput part later, now remains hiddev */+if(hid->claimed&HID_CLAIMED_HIDDEV&&hid->hiddev_hid_event)+hid->hiddev_hid_event(hid,field,usage,value);++return1;+}++staticvoidmt_process_mt_event(structhid_device*hid,structhid_field*field,+structhid_usage*usage,__s32value)+{structmt_device*td=hid_get_drvdata(hid);__s32quirks=td->mtclass.quirks;
@@ -635,8 +647,7 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,break;default:-/* fallback to the generic hidinput handling */-return0;+return;}if(usage->usage_index+1==field->report_count){
@@ -650,12 +661,32 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,}}+}-/* we have handled the hidinput part, now remains hiddev */-if(hid->claimed&HID_CLAIMED_HIDDEV&&hid->hiddev_hid_event)-hid->hiddev_hid_event(hid,field,usage,value);+staticvoidmt_report(structhid_device*hid,structhid_report*report)+{+structmt_device*td=hid_get_drvdata(hid);+structhid_field*field;+unsignedcount;+intr,n;-return1;+if(report->id!=td->mt_report_id)+return;++if(!(hid->claimed&HID_CLAIMED_INPUT))+return;++for(r=0;r<report->maxfield;r++){+field=report->field[r];+count=field->report_count;++if(!(HID_MAIN_ITEM_VARIABLE&field->flags))+continue;++for(n=0;n<count;n++)+mt_process_mt_event(hid,field,&field->usage[n],+field->value[n]);+}}staticvoidmt_set_input_mode(structhid_device*hdev)
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:23:07
This device is the worst device I saw. It keeps TipSwitch and InRange
at 1 for fingers that are not touching the panel.
The solution is to rely on the field ContactCount, which is accurate
as the correct information are packed at the begining of the frame.
Unfortunately, CountactCount is most of the time at the end of the report.
The solution is to pick it when we have the whole report in raw_event.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-ids.h | 3 +++
drivers/hid/hid-multitouch.c | 36 ++++++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 6 deletions(-)
@@ -83,6 +84,7 @@ struct mt_device {structmt_classmtclass;/* our mt device class */structmt_fields*fields;/* temporary placeholder for storing themultitouchfields*/+__s32*contactcount;/* contact count value in the report */unsignedlast_field_index;/* last field index of the report */unsignedlast_slot_field;/* the last field of a slot */unsignedmt_report_id;/* the report ID of the multitouch device */
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:23:09
The serial protocol makes contact count a redondant information, and
sometimes it is not reliable (TRS-Star are in this case).
Disabling the use of contact count for these devices is thus safer.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-multitouch.c | 1 +
1 file changed, 1 insertion(+)
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:23:15
The previous protocol was nearly working, but when several fingers were
present on the sensor, those that were not moving were not updated
in the next report, introducing a lot of releases.
Signed-off-by: Benjamin Tissoires <redacted>
Conflicts:
drivers/hid/hid-multitouch.c
---
drivers/hid/hid-multitouch.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:23:21
Cando 2087:0a02 was broken, this fixes it.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-multitouch.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:23:50
By running a test on all the traces of the devices I have,
I noticed that the class MT_CLS_ALWAYS_TRUE could handle all
the devices I've seen so far without any other quirks.
I guess this is the behavior Win 7 requires in its driver.
We can change the default class then and keep the existing classes
for backward compatibility and performances for some of them.
Two operations have been done:
* replaced MT_CLS_DEFAULT by MT_CLS_NSMU
* then replaced MT_CLS_ALWAYS_TRUE by MT_CLS_DEFAULT
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-multitouch.c | 54 ++++++++++++++++++++++----------------------
1 file changed, 27 insertions(+), 27 deletions(-)
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:24:21
Since the inclusion of this device in hid-multitouch, the device
did not forward any events. Using the serial class makes it working
again.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-multitouch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:25:00
The Sharp LC-20FE1-W screen (04dd:9681) behaves like the Nexio 42".
It may report out of ranges values that are filtered out by relying
on the Contact Count HID field.
Adding the quirk MT_QUIRK_CONTACT_CNT_ACCURATE makes hid-multitouch
strongest against this kind of device, without breaking the current
devices.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-multitouch.c | 1 +
1 file changed, 1 insertion(+)
From: Benjamin Tissoires <hidden> Date: 2013-01-31 16:30:30
This callback is called when the parsing of the report has been done
by hid-core (so after the calls to .event). The hid drivers can now
have access to the whole report by relying on the values stored in
the different fields.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-core.c | 4 ++++
include/linux/hid.h | 2 ++
2 files changed, 6 insertions(+)
@@ -1195,6 +1195,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,{structhid_report_enum*report_enum=hid->report_enum+type;structhid_report*report;+structhid_driver*hdrv;unsignedinta;intrsize,csize=size;u8*cdata=data;
@@ -1231,6 +1232,9 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(hid->claimed!=HID_CLAIMED_HIDRAW){for(a=0;a<report->maxfield;a++)hid_input_field(hid,report->field[a],cdata,interrupt);+hdrv=hid->driver;+if(hdrv&&hdrv->report)+hdrv->report(hid,report);}if(hid->claimed&HID_CLAIMED_INPUT)
From: Henrik Rydberg <hidden> Date: 2013-02-03 12:21:55
Hi Benjamin,
quoted hunk
This callback is called when the parsing of the report has been done
by hid-core (so after the calls to .event). The hid drivers can now
have access to the whole report by relying on the values stored in
the different fields.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-core.c | 4 ++++
include/linux/hid.h | 2 ++
2 files changed, 6 insertions(+)
@@ -1195,6 +1195,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,{structhid_report_enum*report_enum=hid->report_enum+type;structhid_report*report;+structhid_driver*hdrv;unsignedinta;intrsize,csize=size;u8*cdata=data;
@@ -1231,6 +1232,9 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(hid->claimed!=HID_CLAIMED_HIDRAW){for(a=0;a<report->maxfield;a++)hid_input_field(hid,report->field[a],cdata,interrupt);+hdrv=hid->driver;+if(hdrv&&hdrv->report)+hdrv->report(hid,report);
I think this is more useful if called before the individual fields. In
fact, it seems raw_event() is already doing exactly that. No need for
a new callback, in other words.
From: Henrik Rydberg <hidden> Date: 2013-02-03 12:54:19
Hi Benjamin,
quoted hunk
This device is the worst device I saw. It keeps TipSwitch and InRange
at 1 for fingers that are not touching the panel.
The solution is to rely on the field ContactCount, which is accurate
as the correct information are packed at the begining of the frame.
Unfortunately, CountactCount is most of the time at the end of the report.
The solution is to pick it when we have the whole report in raw_event.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-ids.h | 3 +++
drivers/hid/hid-multitouch.c | 36 ++++++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 6 deletions(-)
@@ -83,6 +84,7 @@ struct mt_device {structmt_classmtclass;/* our mt device class */structmt_fields*fields;/* temporary placeholder for storing themultitouchfields*/+__s32*contactcount;/* contact count value in the report */
Why not an index here?
quoted hunk
unsigned last_field_index; /* last field index of the report */
unsigned last_slot_field; /* the last field of a slot */
unsigned mt_report_id; /* the report ID of the multitouch device */
@@ -635,12 +649,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, td->curdata.h = value; break; case HID_DG_CONTACTCOUNT:- /*- * Includes multi-packet support where subsequent- * packets are sent with zero contactcount.- */- if (value)- td->num_expected = value; break; case HID_DG_TOUCH: /* do nothing */
@@ -676,6 +684,13 @@ static void mt_report(struct hid_device *hid, struct hid_report *report) if (!(hid->claimed & HID_CLAIMED_INPUT)) return;+ /*+ * Includes multi-packet support where subsequent+ * packets are sent with zero contactcount.+ */+ if (td->contactcount && *td->contactcount)+ td->num_expected = *td->contactcount;+
Here, that is.
quoted hunk
for (r = 0; r < report->maxfield; r++) {
field = report->field[r];
count = field->report_count;
Since MT_QUIRK_CONTACT_CNT_ACCURATE is a quirk, modifiable by the
user, it should probably not validate num_expected in the code. Better
use the contact count index or something equivalent for that.
From: Henrik Rydberg <hidden> Date: 2013-02-03 13:01:51
Hi Benjamin,
so, this is the v2 of the support of win7/8 devices.
Looks like it is getting there, thanks.
changes since v1:
- removed the "optimization" patches, as the benefit was minimum
- introduce a new callback "report" in hid-core that drivers can use to treat the
report by having it entirely parsed
- rely on this new hook to support Nexio 42"
As noted in the patches comments, using raw_event() seems sufficient.
side notes:
- I've tested removing the heavy call to kzalloc in hid_input_field. The results
are disapointing -> the processing time remains the same.
- I've also tested not to rely on .event hook in hid-multitouch but only on .report.
Idem, I thought it would reduce the code of hid-multitouch and will enhance its
processing time, but the results are a roughly same number of lines for hid-multitouch
and the same processing time... :(
- these 2 tests helped in cleaning the patch set from the last time.
And again, finally, I've pass all the 40 regression tests of my db. \o/
From: Benjamin Tissoires <hidden> Date: 2013-02-04 09:24:51
Hi Henrik,
On Sun, Feb 3, 2013 at 1:27 PM, Henrik Rydberg [off-list ref] wrote:
Hi Benjamin,
quoted
This callback is called when the parsing of the report has been done
by hid-core (so after the calls to .event). The hid drivers can now
have access to the whole report by relying on the values stored in
the different fields.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-core.c | 4 ++++
include/linux/hid.h | 2 ++
2 files changed, 6 insertions(+)
@@ -1195,6 +1195,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,{structhid_report_enum*report_enum=hid->report_enum+type;structhid_report*report;+structhid_driver*hdrv;unsignedinta;intrsize,csize=size;u8*cdata=data;
@@ -1231,6 +1232,9 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(hid->claimed!=HID_CLAIMED_HIDRAW){for(a=0;a<report->maxfield;a++)hid_input_field(hid,report->field[a],cdata,interrupt);+hdrv=hid->driver;+if(hdrv&&hdrv->report)+hdrv->report(hid,report);
I think this is more useful if called before the individual fields. In
fact, it seems raw_event() is already doing exactly that. No need for
a new callback, in other words.
I'm afraid this does not work:
- calling it before the individual fields is not possible unless more
intrusive changes to hid-core:
* "hid_input_field" does the actual parsing of the input report, so
without the call the .value field is still set to the previous one
(not very useful then)
* the "hid_input_field" requires to know the previous report, due to
Array type reports which send the current keys down, and not the
release.
- the raw_event() callback contains the report _unparsed_, which means
that it's up to the hid specific driver to split the fields depending
on the report descriptor (for instance, get the right bit for
tipswitch in a byte containing tipswitch, inrange, confidence,
contactId).
- the raw_event() mechanism was the one in place in the v1 of the
patch series, in which the new callback was asked.
Cheers,
Benjamin
This callback is called when the parsing of the report has been done
by hid-core (so after the calls to .event). The hid drivers can now
have access to the whole report by relying on the values stored in
the different fields.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-core.c | 4 ++++
include/linux/hid.h | 2 ++
2 files changed, 6 insertions(+)
@@ -1195,6 +1195,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,{structhid_report_enum*report_enum=hid->report_enum+type;structhid_report*report;+structhid_driver*hdrv;unsignedinta;intrsize,csize=size;u8*cdata=data;
@@ -1231,6 +1232,9 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(hid->claimed!=HID_CLAIMED_HIDRAW){for(a=0;a<report->maxfield;a++)hid_input_field(hid,report->field[a],cdata,interrupt);+hdrv=hid->driver;+if(hdrv&&hdrv->report)+hdrv->report(hid,report);
I think this is more useful if called before the individual fields. In
fact, it seems raw_event() is already doing exactly that. No need for
a new callback, in other words.
raw_event() doesn't provide equivalent functionality though; namely, the
report is not parsed.
Or have I missed your point?
Thanks for the extensive review, Henrik, it's really helpful.
--
Jiri Kosina
SUSE Labs
From: Benjamin Tissoires <hidden> Date: 2013-02-04 09:37:04
Hi Henrik,
On Sun, Feb 3, 2013 at 2:00 PM, Henrik Rydberg [off-list ref] wrote:
Hi Benjamin,
quoted
This device is the worst device I saw. It keeps TipSwitch and InRange
at 1 for fingers that are not touching the panel.
The solution is to rely on the field ContactCount, which is accurate
as the correct information are packed at the begining of the frame.
Unfortunately, CountactCount is most of the time at the end of the report.
The solution is to pick it when we have the whole report in raw_event.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-ids.h | 3 +++
drivers/hid/hid-multitouch.c | 36 ++++++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 6 deletions(-)
@@ -83,6 +84,7 @@ struct mt_device {structmt_classmtclass;/* our mt device class */structmt_fields*fields;/* temporary placeholder for storing themultitouchfields*/+__s32*contactcount;/* contact count value in the report */
Why not an index here?
Just because an index is not sufficient. You need two things: an index
within the field, and the actual field (a pointer to a struct
hid_field). Each .value is local to a field, and even if in most of
the case, the contact count is alone in its field, it would mean to
take the risk that a new device does not follow this logic.
So the actual pointer to the contact count value seemed to be the
shortest way to do it. But it can be easily changed.
quoted
unsigned last_field_index; /* last field index of the report */
unsigned last_slot_field; /* the last field of a slot */
unsigned mt_report_id; /* the report ID of the multitouch device */
This callback is called from the user-space through the sysfs
attribute. So, it is not called in the same time that the
mt_post_parse function. This is just to avoid a user setting this
quirk once the device is up and running leading to a potential oops.
@@ -635,12 +649,6 @@ static void mt_process_mt_event(struct hid_device *hid, struct hid_field *field, td->curdata.h = value; break; case HID_DG_CONTACTCOUNT:- /*- * Includes multi-packet support where subsequent- * packets are sent with zero contactcount.- */- if (value)- td->num_expected = value; break; case HID_DG_TOUCH: /* do nothing */
@@ -676,6 +684,13 @@ static void mt_report(struct hid_device *hid, struct hid_report *report) if (!(hid->claimed & HID_CLAIMED_INPUT)) return;+ /*+ * Includes multi-packet support where subsequent+ * packets are sent with zero contactcount.+ */+ if (td->contactcount && *td->contactcount)+ td->num_expected = *td->contactcount;+
Here, that is.
quoted
for (r = 0; r < report->maxfield; r++) {
field = report->field[r];
count = field->report_count;
Since MT_QUIRK_CONTACT_CNT_ACCURATE is a quirk, modifiable by the
user, it should probably not validate num_expected in the code. Better
use the contact count index or something equivalent for that.
As when the user changes the quirk, we validate it, this is not required.
Cheers,
Benjamin
From: Benjamin Tissoires <hidden> Date: 2013-02-04 09:38:47
Hi Henrik,
On Sun, Feb 3, 2013 at 2:07 PM, Henrik Rydberg [off-list ref] wrote:
Hi Benjamin,
quoted
so, this is the v2 of the support of win7/8 devices.
Looks like it is getting there, thanks.
Thanks for the review. However, before sending a new patch series, I'd
like to have your answers to my comments as I mostly disagree on
everything :)
Thanks again,
Benjamin
quoted
changes since v1:
- removed the "optimization" patches, as the benefit was minimum
- introduce a new callback "report" in hid-core that drivers can use to treat the
report by having it entirely parsed
- rely on this new hook to support Nexio 42"
As noted in the patches comments, using raw_event() seems sufficient.
quoted
side notes:
- I've tested removing the heavy call to kzalloc in hid_input_field. The results
are disapointing -> the processing time remains the same.
- I've also tested not to rely on .event hook in hid-multitouch but only on .report.
Idem, I thought it would reduce the code of hid-multitouch and will enhance its
processing time, but the results are a roughly same number of lines for hid-multitouch
and the same processing time... :(
- these 2 tests helped in cleaning the patch set from the last time.
And again, finally, I've pass all the 40 regression tests of my db. \o/
From: Benjamin Tissoires <hidden> Date: 2013-02-04 09:41:13
On Mon, Feb 4, 2013 at 10:34 AM, Jiri Kosina [off-list ref] wrote:
On Sun, 3 Feb 2013, Henrik Rydberg wrote:
quoted
quoted
This callback is called when the parsing of the report has been done
by hid-core (so after the calls to .event). The hid drivers can now
have access to the whole report by relying on the values stored in
the different fields.
Signed-off-by: Benjamin Tissoires <redacted>
---
drivers/hid/hid-core.c | 4 ++++
include/linux/hid.h | 2 ++
2 files changed, 6 insertions(+)
@@ -1195,6 +1195,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,{structhid_report_enum*report_enum=hid->report_enum+type;structhid_report*report;+structhid_driver*hdrv;unsignedinta;intrsize,csize=size;u8*cdata=data;
@@ -1231,6 +1232,9 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(hid->claimed!=HID_CLAIMED_HIDRAW){for(a=0;a<report->maxfield;a++)hid_input_field(hid,report->field[a],cdata,interrupt);+hdrv=hid->driver;+if(hdrv&&hdrv->report)+hdrv->report(hid,report);
I think this is more useful if called before the individual fields. In
fact, it seems raw_event() is already doing exactly that. No need for
a new callback, in other words.
raw_event() doesn't provide equivalent functionality though; namely, the
report is not parsed.
Or have I missed your point?
No, you perfectly understood the purpose of the patch. raw_event() and
report() are not the same kind of callbacks at all.
Thanks for the extensive review, Henrik, it's really helpful.
Yep, thanks Henrik, and thanks Jiri for having a look at it.
Cheers,
Benjamin
From: Henrik Rydberg <hidden> Date: 2013-02-04 11:15:01
Hi Benjamin,
quoted
I think this is more useful if called before the individual fields. In
fact, it seems raw_event() is already doing exactly that. No need for
a new callback, in other words.
I'm afraid this does not work:
- calling it before the individual fields is not possible unless more
intrusive changes to hid-core:
* "hid_input_field" does the actual parsing of the input report, so
without the call the .value field is still set to the previous one
(not very useful then)
* the "hid_input_field" requires to know the previous report, due to
Array type reports which send the current keys down, and not the
release.
- the raw_event() callback contains the report _unparsed_, which means
that it's up to the hid specific driver to split the fields depending
on the report descriptor (for instance, get the right bit for
tipswitch in a byte containing tipswitch, inrange, confidence,
contactId).
- the raw_event() mechanism was the one in place in the v1 of the
patch series, in which the new callback was asked.
Thanks for the compelling argument list, v1 had obviously been thrown
out of the cache already. ;-) I agree with your approach.
Thanks,
Henrik
From: Henrik Rydberg <hidden> Date: 2013-02-04 11:36:27
Hi Benjamin,
quoted
Why not an index here?
Just because an index is not sufficient. You need two things: an index
within the field, and the actual field (a pointer to a struct
hid_field). Each .value is local to a field, and even if in most of
the case, the contact count is alone in its field, it would mean to
take the risk that a new device does not follow this logic.
The field value is passed to process_mt_event() in a fairly
straight-forward fashion, I was imagining that behavior could be
copied somehow.
So the actual pointer to the contact count value seemed to be the
shortest way to do it. But it can be easily changed.
Keeping a pointer into the core structure creates unwanted
dependencies to the scope of that value, making an eventual core
refactoring even harder, not to mention trickier to debug. So even
though it looks neat in the code, it pushes the problem forward.
This callback is called from the user-space through the sysfs
attribute. So, it is not called in the same time that the
mt_post_parse function. This is just to avoid a user setting this
quirk once the device is up and running leading to a potential oops.
Yes, but the quirk _is_ user modifiable. Hence, the problem lies in
equating the user-modifiable quirk with the branch control of the
program.
quoted
An index into the the struct actually passed in mt_report() feels safer.
again, you need to store "field" and "usage->usage_index". Agree, it
would be safer but it will take more space... :)
If you think the code change is not only correct, but also moves the
whole code base in a good direction, by all means.
Since MT_QUIRK_CONTACT_CNT_ACCURATE is a quirk, modifiable by the
user, it should probably not validate num_expected in the code. Better
use the contact count index or something equivalent for that.
As when the user changes the quirk, we validate it, this is not required.
From: Henrik Rydberg <hidden> Date: 2013-02-04 11:48:42
Hi Benjamin,
Thanks for the review. However, before sending a new patch series, I'd
like to have your answers to my comments as I mostly disagree on
everything :)
With good reason, apparently. :-) I see no major problem with your
patches, although the discussed details show that there is room for
some refactoring.
Thanks,
Henrik
From: Benjamin Tissoires <hidden> Date: 2013-02-04 13:42:28
On Mon, Feb 4, 2013 at 12:42 PM, Henrik Rydberg [off-list ref] wrote:
Hi Benjamin,
quoted
quoted
Why not an index here?
Just because an index is not sufficient. You need two things: an index
within the field, and the actual field (a pointer to a struct
hid_field). Each .value is local to a field, and even if in most of
the case, the contact count is alone in its field, it would mean to
take the risk that a new device does not follow this logic.
The field value is passed to process_mt_event() in a fairly
straight-forward fashion, I was imagining that behavior could be
copied somehow.
quoted
So the actual pointer to the contact count value seemed to be the
shortest way to do it. But it can be easily changed.
Keeping a pointer into the core structure creates unwanted
dependencies to the scope of that value, making an eventual core
refactoring even harder, not to mention trickier to debug. So even
though it looks neat in the code, it pushes the problem forward.
This callback is called from the user-space through the sysfs
attribute. So, it is not called in the same time that the
mt_post_parse function. This is just to avoid a user setting this
quirk once the device is up and running leading to a potential oops.
Yes, but the quirk _is_ user modifiable. Hence, the problem lies in
equating the user-modifiable quirk with the branch control of the
program.
I'm not sure I understood what you meant there.
The quirk is indeed user modifiable, but through the callback
mt_set_quirks() only. If the HID field Contact Count is not present,
this quirk should not be allowed to be present, thus the two removals
of the quirk in met_set_quirks() and mt_post_parse(). As there are no
other entry points, I'm quite confuse to understand where the pitfall
is.
quoted
quoted
An index into the the struct actually passed in mt_report() feels safer.
again, you need to store "field" and "usage->usage_index". Agree, it
would be safer but it will take more space... :)
If you think the code change is not only correct, but also moves the
whole code base in a good direction, by all means.
Ok, will do. After a deeper look at it, I can even have two int
indexes (and no pointers): one for the field and one other for the
value within the field.
Cheers,
Benjamin
Since MT_QUIRK_CONTACT_CNT_ACCURATE is a quirk, modifiable by the
user, it should probably not validate num_expected in the code. Better
use the contact count index or something equivalent for that.
As when the user changes the quirk, we validate it, this is not required.
Thanks for the review. However, before sending a new patch series, I'd
like to have your answers to my comments as I mostly disagree on
everything :)
With good reason, apparently. :-) I see no major problem with your
patches, although the discussed details show that there is room for
some refactoring.
Thanks to both of you. As I don't object to the HID core change, I have
now applied the patchset, so please send any further additions on top of
for-3.9/multitouch branch of my tree.
Also, Benjamin, perhaps it'd make sense to put a link somewhere into
in-tree documentation, with pointer to your testing suite?
Thanks,
--
Jiri Kosina
SUSE Labs
From: Benjamin Tissoires <hidden> Date: 2013-02-06 11:04:40
On Tue, Feb 5, 2013 at 12:13 PM, Jiri Kosina [off-list ref] wrote:
On Mon, 4 Feb 2013, Henrik Rydberg wrote:
quoted
quoted
Thanks for the review. However, before sending a new patch series, I'd
like to have your answers to my comments as I mostly disagree on
everything :)
With good reason, apparently. :-) I see no major problem with your
patches, although the discussed details show that there is room for
some refactoring.
Thanks to both of you. As I don't object to the HID core change, I have
now applied the patchset, so please send any further additions on top of
for-3.9/multitouch branch of my tree.
Ok. Thanks Jiri. I will send the patch in a minute.
Also, Benjamin, perhaps it'd make sense to put a link somewhere into
in-tree documentation, with pointer to your testing suite?
Good idea. However, I prefer removing the dependencies between hid
drivers and usbhid before including such reference to avoid testers
getting kernel oops while trying to access the usb layer from the uhid
device... So, yesterday and this morning, I rebased/updated Henrik's
patches on this topic. They should be ready soon.
Do you mind if I send the usbhid dependency and the pen+multitouch
series this week, or we are too close to the 3.9 opening window?
Cheers,
Benjamin
Also, Benjamin, perhaps it'd make sense to put a link somewhere into
in-tree documentation, with pointer to your testing suite?
Good idea. However, I prefer removing the dependencies between hid
drivers and usbhid before including such reference to avoid testers
getting kernel oops while trying to access the usb layer from the uhid
device... So, yesterday and this morning, I rebased/updated Henrik's
patches on this topic. They should be ready soon.
Makes sense, thanks.
Do you mind if I send the usbhid dependency and the pen+multitouch
series this week, or we are too close to the 3.9 opening window?
Please just send the patches, and let's see whether they will make it for
3.8 or I'll queue (some of) them for 3.9.
Thanks,
--
Jiri Kosina
SUSE Labs
From: Benjamin Tissoires <hidden> Date: 2013-02-06 13:28:37
quoted
Do you mind if I send the usbhid dependency and the pen+multitouch
series this week, or we are too close to the 3.9 opening window?
Please just send the patches, and let's see whether they will make it for
3.8 or I'll queue (some of) them for 3.9.
Well, I didn't wanted to push them into 3.8 (the rc6 is already there,
and I doubt Linus would be happy to see a lot of patches now). I was
asking if it was not too late to schedule them for 3.9, or if you'd
rather wait for 3.10 :)
Anyway, I'm doing my best to push them soon.
Cheers,
Benjamin
Do you mind if I send the usbhid dependency and the pen+multitouch
series this week, or we are too close to the 3.9 opening window?
Please just send the patches, and let's see whether they will make it for
3.8 or I'll queue (some of) them for 3.9.
Well, I didn't wanted to push them into 3.8 (the rc6 is already there,
and I doubt Linus would be happy to see a lot of patches now). I was
asking if it was not too late to schedule them for 3.9, or if you'd
rather wait for 3.10 :)
Yeah, sorry, my sentence was off-by-one, but I guess you got me :)