Message ID | a5c0b6b300fadf9425781285351b46c6dbb4f618.1607669375.git.mirq-linux@rere.qmqm.pl (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | input: elants: Support Asus TF300T and Nexus 7 touchscreens | expand |
Hi Michał, On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: > @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) > } > > report_len = ts->buf[FW_HDR_LENGTH] / report_count; > - if (report_len != PACKET_SIZE) { > + if (report_len != PACKET_SIZE && > + report_len != PACKET_SIZE_OLD) { > dev_err(&client->dev, > - "mismatching report length: %*ph\n", > + "unsupported report length: %*ph\n", > HEADER_SIZE, ts->buf); Do I understand this correctly that the old packets are only observed on EKTF3624? If so can we expand the check so that we only accept packets with "old" size when we know we are dealing with this device? Thanks.
On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: > Hi Michał, > On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: > > @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) > > } > > > > report_len = ts->buf[FW_HDR_LENGTH] / report_count; > > - if (report_len != PACKET_SIZE) { > > + if (report_len != PACKET_SIZE && > > + report_len != PACKET_SIZE_OLD) { > > dev_err(&client->dev, > > - "mismatching report length: %*ph\n", > > + "unsupported report length: %*ph\n", > > HEADER_SIZE, ts->buf); > Do I understand this correctly that the old packets are only observed on > EKTF3624? If so can we expand the check so that we only accept packets > with "old" size when we know we are dealing with this device? We only have EKTF3624 and can't be sure there are no other chips needing this. Best Regards Michał Mirosław
11.12.2020 19:09, Michał Mirosław пишет: > On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: >> Hi Michał, >> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: >>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) >>> } >>> >>> report_len = ts->buf[FW_HDR_LENGTH] / report_count; >>> - if (report_len != PACKET_SIZE) { >>> + if (report_len != PACKET_SIZE && >>> + report_len != PACKET_SIZE_OLD) { >>> dev_err(&client->dev, >>> - "mismatching report length: %*ph\n", >>> + "unsupported report length: %*ph\n", >>> HEADER_SIZE, ts->buf); >> Do I understand this correctly that the old packets are only observed on >> EKTF3624? If so can we expand the check so that we only accept packets >> with "old" size when we know we are dealing with this device? > > We only have EKTF3624 and can't be sure there are no other chips needing this. In practice this older packet format should be seen only on 3624, but nevertheless we could make it more explicit by adding the extra chip_id checks. It won't be difficult to change it in the future if will be needed. I think the main point that Dmitry Torokhov conveys here is that we should minimize the possible impact on the current EKT3500 code since we don't have definitive answers regarding the firmware differences among the hardware variants.
On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote: > 11.12.2020 19:09, Michał Mirosław пишет: > > On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: > >> Hi Michał, > >> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: > >>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) > >>> } > >>> > >>> report_len = ts->buf[FW_HDR_LENGTH] / report_count; > >>> - if (report_len != PACKET_SIZE) { > >>> + if (report_len != PACKET_SIZE && > >>> + report_len != PACKET_SIZE_OLD) { > >>> dev_err(&client->dev, > >>> - "mismatching report length: %*ph\n", > >>> + "unsupported report length: %*ph\n", > >>> HEADER_SIZE, ts->buf); > >> Do I understand this correctly that the old packets are only observed on > >> EKTF3624? If so can we expand the check so that we only accept packets > >> with "old" size when we know we are dealing with this device? > > > > We only have EKTF3624 and can't be sure there are no other chips needing this. > > In practice this older packet format should be seen only on 3624, but > nevertheless we could make it more explicit by adding the extra chip_id > checks. > > It won't be difficult to change it in the future if will be needed. > > I think the main point that Dmitry Torokhov conveys here is that we > should minimize the possible impact on the current EKT3500 code since we > don't have definitive answers regarding the firmware differences among > the hardware variants. The only possible impact here is that older firmware instead of breaking would suddenly work. Maybe we can accept such a risk? Best Regards Michał Mirosław
On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote: > On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote: > > 11.12.2020 19:09, Michał Mirosław пишет: > > > On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: > > >> Hi Michał, > > >> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: > > >>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) > > >>> } > > >>> > > >>> report_len = ts->buf[FW_HDR_LENGTH] / report_count; > > >>> - if (report_len != PACKET_SIZE) { > > >>> + if (report_len != PACKET_SIZE && > > >>> + report_len != PACKET_SIZE_OLD) { > > >>> dev_err(&client->dev, > > >>> - "mismatching report length: %*ph\n", > > >>> + "unsupported report length: %*ph\n", > > >>> HEADER_SIZE, ts->buf); > > >> Do I understand this correctly that the old packets are only observed on > > >> EKTF3624? If so can we expand the check so that we only accept packets > > >> with "old" size when we know we are dealing with this device? > > > > > > We only have EKTF3624 and can't be sure there are no other chips needing this. > > > > In practice this older packet format should be seen only on 3624, but > > nevertheless we could make it more explicit by adding the extra chip_id > > checks. > > > > It won't be difficult to change it in the future if will be needed. > > > > I think the main point that Dmitry Torokhov conveys here is that we > > should minimize the possible impact on the current EKT3500 code since we > > don't have definitive answers regarding the firmware differences among > > the hardware variants. > > The only possible impact here is that older firmware instead of breaking > would suddenly work. Maybe we can accept such a risk? These are not controllers we'll randomly find in devices: Windows boxes use I2C HID, Chrome devices use "new" firmware, so that leaves random ARM where someone needs to consciously add proper compatible before the driver will engage with the controller. I would prefer we were conservative and not accept potentially invalid data. Thanks.
11.12.2020 21:48, Dmitry Torokhov пишет: > On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote: >> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote: >>> 11.12.2020 19:09, Michał Mirosław пишет: >>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: >>>>> Hi Michał, >>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: >>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) >>>>>> } >>>>>> >>>>>> report_len = ts->buf[FW_HDR_LENGTH] / report_count; >>>>>> - if (report_len != PACKET_SIZE) { >>>>>> + if (report_len != PACKET_SIZE && >>>>>> + report_len != PACKET_SIZE_OLD) { >>>>>> dev_err(&client->dev, >>>>>> - "mismatching report length: %*ph\n", >>>>>> + "unsupported report length: %*ph\n", >>>>>> HEADER_SIZE, ts->buf); >>>>> Do I understand this correctly that the old packets are only observed on >>>>> EKTF3624? If so can we expand the check so that we only accept packets >>>>> with "old" size when we know we are dealing with this device? >>>> >>>> We only have EKTF3624 and can't be sure there are no other chips needing this. >>> >>> In practice this older packet format should be seen only on 3624, but >>> nevertheless we could make it more explicit by adding the extra chip_id >>> checks. >>> >>> It won't be difficult to change it in the future if will be needed. >>> >>> I think the main point that Dmitry Torokhov conveys here is that we >>> should minimize the possible impact on the current EKT3500 code since we >>> don't have definitive answers regarding the firmware differences among >>> the hardware variants. >> >> The only possible impact here is that older firmware instead of breaking >> would suddenly work. Maybe we can accept such a risk? > > These are not controllers we'll randomly find in devices: Windows boxes > use I2C HID, Chrome devices use "new" firmware, so that leaves random > ARM where someone needs to consciously add proper compatible before the > driver will engage with the controller. > > I would prefer we were conservative and not accept potentially invalid > data. > > Thanks. > Michał, will you be able to make v9 with all the review comments addressed?
08.01.2021 01:06, Dmitry Osipenko пишет: > 11.12.2020 21:48, Dmitry Torokhov пишет: >> On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote: >>> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote: >>>> 11.12.2020 19:09, Michał Mirosław пишет: >>>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: >>>>>> Hi Michał, >>>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: >>>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) >>>>>>> } >>>>>>> >>>>>>> report_len = ts->buf[FW_HDR_LENGTH] / report_count; >>>>>>> - if (report_len != PACKET_SIZE) { >>>>>>> + if (report_len != PACKET_SIZE && >>>>>>> + report_len != PACKET_SIZE_OLD) { >>>>>>> dev_err(&client->dev, >>>>>>> - "mismatching report length: %*ph\n", >>>>>>> + "unsupported report length: %*ph\n", >>>>>>> HEADER_SIZE, ts->buf); >>>>>> Do I understand this correctly that the old packets are only observed on >>>>>> EKTF3624? If so can we expand the check so that we only accept packets >>>>>> with "old" size when we know we are dealing with this device? >>>>> >>>>> We only have EKTF3624 and can't be sure there are no other chips needing this. >>>> >>>> In practice this older packet format should be seen only on 3624, but >>>> nevertheless we could make it more explicit by adding the extra chip_id >>>> checks. >>>> >>>> It won't be difficult to change it in the future if will be needed. >>>> >>>> I think the main point that Dmitry Torokhov conveys here is that we >>>> should minimize the possible impact on the current EKT3500 code since we >>>> don't have definitive answers regarding the firmware differences among >>>> the hardware variants. >>> >>> The only possible impact here is that older firmware instead of breaking >>> would suddenly work. Maybe we can accept such a risk? >> >> These are not controllers we'll randomly find in devices: Windows boxes >> use I2C HID, Chrome devices use "new" firmware, so that leaves random >> ARM where someone needs to consciously add proper compatible before the >> driver will engage with the controller. >> >> I would prefer we were conservative and not accept potentially invalid >> data. >> >> Thanks. >> > > Michał, will you be able to make v9 with all the review comments addressed? > I'll make a v9 over this weekend. Michał, please let me know if you already started to work on this or have any objections.
On Fri, Jan 22, 2021 at 11:10:52PM +0300, Dmitry Osipenko wrote: > 08.01.2021 01:06, Dmitry Osipenko пишет: > > 11.12.2020 21:48, Dmitry Torokhov пишет: > >> On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote: > >>> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote: > >>>> 11.12.2020 19:09, Michał Mirosław пишет: > >>>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: > >>>>>> Hi Michał, > >>>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: > >>>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) > >>>>>>> } > >>>>>>> > >>>>>>> report_len = ts->buf[FW_HDR_LENGTH] / report_count; > >>>>>>> - if (report_len != PACKET_SIZE) { > >>>>>>> + if (report_len != PACKET_SIZE && > >>>>>>> + report_len != PACKET_SIZE_OLD) { > >>>>>>> dev_err(&client->dev, > >>>>>>> - "mismatching report length: %*ph\n", > >>>>>>> + "unsupported report length: %*ph\n", > >>>>>>> HEADER_SIZE, ts->buf); > >>>>>> Do I understand this correctly that the old packets are only observed on > >>>>>> EKTF3624? If so can we expand the check so that we only accept packets > >>>>>> with "old" size when we know we are dealing with this device? > >>>>> > >>>>> We only have EKTF3624 and can't be sure there are no other chips needing this. > >>>> > >>>> In practice this older packet format should be seen only on 3624, but > >>>> nevertheless we could make it more explicit by adding the extra chip_id > >>>> checks. > >>>> > >>>> It won't be difficult to change it in the future if will be needed. > >>>> > >>>> I think the main point that Dmitry Torokhov conveys here is that we > >>>> should minimize the possible impact on the current EKT3500 code since we > >>>> don't have definitive answers regarding the firmware differences among > >>>> the hardware variants. > >>> > >>> The only possible impact here is that older firmware instead of breaking > >>> would suddenly work. Maybe we can accept such a risk? > >> > >> These are not controllers we'll randomly find in devices: Windows boxes > >> use I2C HID, Chrome devices use "new" firmware, so that leaves random > >> ARM where someone needs to consciously add proper compatible before the > >> driver will engage with the controller. > >> > >> I would prefer we were conservative and not accept potentially invalid > >> data. > >> > >> Thanks. > >> > > > > Michał, will you be able to make v9 with all the review comments addressed? > > > > I'll make a v9 over this weekend. > > Michał, please let me know if you already started to work on this or > have any objections. Hi, Sorry for staying quiet so long. I have to revive my Transformer before I can test anything, so please go ahead. Best Regards Michał Mirosław
23.01.2021 01:37, Michał Mirosław пишет: > On Fri, Jan 22, 2021 at 11:10:52PM +0300, Dmitry Osipenko wrote: >> 08.01.2021 01:06, Dmitry Osipenko пишет: >>> 11.12.2020 21:48, Dmitry Torokhov пишет: >>>> On Fri, Dec 11, 2020 at 06:04:01PM +0100, Michał Mirosław wrote: >>>>> On Fri, Dec 11, 2020 at 07:39:33PM +0300, Dmitry Osipenko wrote: >>>>>> 11.12.2020 19:09, Michał Mirosław пишет: >>>>>>> On Thu, Dec 10, 2020 at 11:29:40PM -0800, Dmitry Torokhov wrote: >>>>>>>> Hi Michał, >>>>>>>> On Fri, Dec 11, 2020 at 07:53:56AM +0100, Michał Mirosław wrote: >>>>>>>>> @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) >>>>>>>>> } >>>>>>>>> >>>>>>>>> report_len = ts->buf[FW_HDR_LENGTH] / report_count; >>>>>>>>> - if (report_len != PACKET_SIZE) { >>>>>>>>> + if (report_len != PACKET_SIZE && >>>>>>>>> + report_len != PACKET_SIZE_OLD) { >>>>>>>>> dev_err(&client->dev, >>>>>>>>> - "mismatching report length: %*ph\n", >>>>>>>>> + "unsupported report length: %*ph\n", >>>>>>>>> HEADER_SIZE, ts->buf); >>>>>>>> Do I understand this correctly that the old packets are only observed on >>>>>>>> EKTF3624? If so can we expand the check so that we only accept packets >>>>>>>> with "old" size when we know we are dealing with this device? >>>>>>> >>>>>>> We only have EKTF3624 and can't be sure there are no other chips needing this. >>>>>> >>>>>> In practice this older packet format should be seen only on 3624, but >>>>>> nevertheless we could make it more explicit by adding the extra chip_id >>>>>> checks. >>>>>> >>>>>> It won't be difficult to change it in the future if will be needed. >>>>>> >>>>>> I think the main point that Dmitry Torokhov conveys here is that we >>>>>> should minimize the possible impact on the current EKT3500 code since we >>>>>> don't have definitive answers regarding the firmware differences among >>>>>> the hardware variants. >>>>> >>>>> The only possible impact here is that older firmware instead of breaking >>>>> would suddenly work. Maybe we can accept such a risk? >>>> >>>> These are not controllers we'll randomly find in devices: Windows boxes >>>> use I2C HID, Chrome devices use "new" firmware, so that leaves random >>>> ARM where someone needs to consciously add proper compatible before the >>>> driver will engage with the controller. >>>> >>>> I would prefer we were conservative and not accept potentially invalid >>>> data. >>>> >>>> Thanks. >>>> >>> >>> Michał, will you be able to make v9 with all the review comments addressed? >>> >> >> I'll make a v9 over this weekend. >> >> Michał, please let me know if you already started to work on this or >> have any objections. > > Hi, > > Sorry for staying quiet so long. I have to revive my Transformer before > I can test anything, so please go ahead. No problems, hope it's nothing serious and you'll have some spare time to revive it soon!
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index d51cb910fba1..f1bf3e000e96 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -69,6 +69,7 @@ #define CMD_HEADER_REK 0x66 /* FW position data */ +#define PACKET_SIZE_OLD 40 #define PACKET_SIZE 55 #define MAX_CONTACT_NUM 10 #define FW_POS_HEADER 0 @@ -853,7 +854,8 @@ static int elants_i2c_fw_update(struct elants_data *ts) * Event reporting. */ -static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) +static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf, + size_t report_len) { struct input_dev *input = ts->input; unsigned int n_fingers; @@ -866,7 +868,8 @@ static void elants_i2c_mt_event(struct elants_data *ts, u8 *buf) buf[FW_POS_STATE]; dev_dbg(&ts->client->dev, - "n_fingers: %u, state: %04x\n", n_fingers, finger_state); + "n_fingers: %u, state: %04x, report_len: %zu\n", + n_fingers, finger_state, report_len); /* Note: all fingers have the same tool type */ tool_type = buf[FW_POS_TOOL_TYPE] & BIT(0) ? @@ -880,8 +883,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; + } else { + p = buf[FW_POS_PRESSURE + i]; + w = buf[FW_POS_WIDTH + i]; + } dev_dbg(&ts->client->dev, "i=%d x=%d y=%d p=%d w=%d\n", i, x, y, p, w); @@ -913,7 +924,8 @@ static u8 elants_i2c_calculate_checksum(u8 *buf) return checksum; } -static void elants_i2c_event(struct elants_data *ts, u8 *buf) +static void elants_i2c_event(struct elants_data *ts, u8 *buf, + size_t report_len) { u8 checksum = elants_i2c_calculate_checksum(buf); @@ -927,7 +939,7 @@ static void elants_i2c_event(struct elants_data *ts, u8 *buf) "%s: unknown packet type: %02x\n", __func__, buf[FW_POS_HEADER]); else - elants_i2c_mt_event(ts, buf); + elants_i2c_mt_event(ts, buf, report_len); } static irqreturn_t elants_i2c_irq(int irq, void *_dev) @@ -985,7 +997,8 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) break; case QUEUE_HEADER_SINGLE: - elants_i2c_event(ts, &ts->buf[HEADER_SIZE]); + elants_i2c_event(ts, &ts->buf[HEADER_SIZE], + ts->buf[FW_HDR_LENGTH]); break; case QUEUE_HEADER_NORMAL: @@ -998,17 +1011,18 @@ static irqreturn_t elants_i2c_irq(int irq, void *_dev) } report_len = ts->buf[FW_HDR_LENGTH] / report_count; - if (report_len != PACKET_SIZE) { + if (report_len != PACKET_SIZE && + report_len != PACKET_SIZE_OLD) { dev_err(&client->dev, - "mismatching report length: %*ph\n", + "unsupported report length: %*ph\n", HEADER_SIZE, ts->buf); break; } for (i = 0; i < report_count; i++) { u8 *buf = ts->buf + HEADER_SIZE + - i * PACKET_SIZE; - elants_i2c_event(ts, buf); + i * report_len; + elants_i2c_event(ts, buf, report_len); } break;