On Thu, Dec 12, 2019 at 03:54:13AM +0300, Dmitry Osipenko wrote: > 11.12.2019 19:03, Michał Mirosław пишет: > > Support ELAN touchpad sensor with older firmware as found on eg. Asus > > Transformer Pads. [...] > > @@ -814,8 +817,16 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) > > pos = &buf[FW_POS_XY + i * 3]; > > x = (((u16)pos[0] & 0xf0) << 4) | pos[1]; > > y = (((u16)pos[0] & 0x0f) << 8) | pos[2]; > > - p = buf[FW_POS_PRESSURE + i]; > > - w = buf[FW_POS_WIDTH + i]; > > + if (report_len == PACKET_SIZE_OLD) { > > + w = buf[FW_POS_WIDTH + i / 2]; > > + w >>= 4 * (~i & 1); // little-endian-nibbles > > + w |= w << 4; > > + w |= !w; > > + p = w; > > Did you copy this from the downstream driver as-is? I'm looking at the > Nexus 7 driver and it does the following for older format: > > u8 size_idx[] = { 35, 35, 36, 36, 37, 37, 38, 38, 39, 39 }; > unsigned int s; > > if (i & 1) > s = buf[size_idx[i]]; > else > s = buf[size_idx[i]] / 16; > > w = s & 0xf; > p = s * 16; This is the same thing modulo (w), which is scaled here to declared axis range (1-255 from 0-15, assuming 0 means "no touch" so it should not occur). OTOH, I admit, that I don't have any software that can verify those settings. It might be that eg. one of MT_PRESSURE or MT_TOUCH_MAJOR axes should be dropped in this case, but with no docs I can't be sure what the reported values really are. This is from the original (GPL) code dump labeled 'Asus 10_6_1_27_5': | touch_size = ((i & 0x01) ? buf[size_index[i]] : (buf[size_index[i]] >> 4)) & 0x0F; | if(touch_size == 0) touch_size = 1; | if (touch_size <= 7) | touch_size = touch_size << 5; | else | touch_size = 255; | | input_report_abs(idev, ABS_MT_TOUCH_MAJOR, touch_size); | input_report_abs(idev, ABS_MT_PRESSURE, touch_size); Best Regards, Michał Mirosław