Skip to content

linux commit 0a3fe97 removes tolerance of off-by-n issue in spec-hid.h #34

@orthogonaleety

Description

@orthogonaleety

Investigating an issue linux-surface/linux-surface#2150 where applying Apiznel's 7.0 updated linux-surface patches , results in the error kernel: ipts ... Failed to process buffer: -22 on an EDS 1 device.

Investigating the matter has highlighted the following change in kernel hid-core
torvalds/linux@0a3fe97
"remove the memset() and simply return if the incoming event buffer size is not
large enough"

This causes a problem between

https://github.com/linux-surface/intel-precise-touch/blob/a9e052e/src/spec-hid.h#L57
#define IPTS_HID_REPORT_DATA_SIZE 7485

and

https://github.com/linux-surface/intel-precise-touch/blob/a9e052e/src/spec-hid.h#L108-L128

static const u8 ipts_fallback_descriptor[] = {
	0x05, 0x0D,	  /*  Usage Page (Digitizer),            */
	0x09, 0x0F,	  /*  Usage (Capacitive Hm Digitizer),   */
	0xA1, 0x01,	  /*  Collection (Application),          */
	0x85, 0x41,	  /*      Report ID (65),                */
	0x09, 0x56,	  /*      Usage (Scan Time),             */
	0x95, 0x01,	  /*      Report Count (1),              */
	0x75, 0x10,	  /*      Report Size (16),              */
	0x81, 0x02,	  /*      Input (Variable),              */
	0x09, 0x61,	  /*      Usage (Gesture Char Quality),  */
	0x75, 0x08,	  /*      Report Size (8),               */
	0x96, 0x3D, 0x1D, /*      Report Count (7485),           */
	0x81, 0x03,	  /*      Input (Constant, Variable),    */
	0x85, 0x42,	  /*      Report ID (66),                */
	0x06, 0x00, 0xFF, /*      Usage Page (FF00h),            */
	0x09, 0xC8,	  /*      Usage (C8h),                   */
	0x75, 0x08,	  /*      Report Size (8),               */
	0x95, 0x01,	  /*      Report Count (1),              */
	0xB1, 0x02,	  /*      Feature (Variable),            */
	0xC0,		  /*  End Collection                     */
};

and where they are effectively both used below, where the hid device is previously setup with the descriptor above.

https://github.com/linux-surface/intel-precise-touch/blob/a9e052e3d3664b7ec60be679471c6821040e10e3/src/hid.c#L127-L#128

	return hid_input_report(ipts->hid, HID_INPUT_REPORT, (u8 *)report,
				IPTS_HID_REPORT_DATA_SIZE, 1);

The code here where the report data is assembled is different from that of the linux-surface patches, and I haven't followed up here since irrespective, the size (4th parameter) still needs to agree with the report descriptor, but in the patches the data is written to only the 4th [3] byte of the array storing the data.

IPTS_HID_REPORT_DATA_SIZE is currently 7485,

  • when it perhaps should be 7488,

presumably having forgotten the report ID byte and the gap left for scan-time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions