Repository navigation
input: touchscreen: edt-ft5x06: Suppress bogus data on startup - #5645
Conversation
|
Not pretty, but it seems to do the trick. (We could avoid special handling for "transient zeroes" either by slowing down the reset by another 400ms or delaying the initial polling timer by 400ms.) What I'm not doing right now is checking for duplicated IDs, because the bad state is not "guaranteed" to have any. But duplicated IDs are bad news generally as they can lead to input event spamming. |
6by9
left a comment
There was a problem hiding this comment.
Other than the one comment, that looks reasonable.
|
Now I think I still need to do some more testing for the "transient zeros" effect, to see whether or not we need to delay the first polling interval by 400ms or whatever (it's a bit shocking that reset seems to take so long). If we do that, the code change could be a little simpler. |
c923b4d to
3aedcd7
Compare
| /* When polling FT5x06 without IRQ: initial register | ||
| * contents could be stale or undefined; ignore them | ||
| * until something changes or num_points becomes 0. | ||
| */ |
There was a problem hiding this comment.
As per the comment, now that you're delaying and don't see the awkward drop to 0 points, can't we now just filter until num_points to hits 0?
There was a problem hiding this comment.
EDITED. I previously had a largely bogus objection about pre-existing touches.
However there is worse case, which is that it could change from the undefined data to the first real touch (which could occur after an arbitrarily long delay) without num_points ever dropping to zero.
So I think the workaround really does need to do a memcmp to detect the first change.
There was a problem hiding this comment.
Can probably simplify by detecting change to num_points only. The risk is that if the bogus data had exactly one point, we would miss the first touch.
3aedcd7 to
7c9b0a6
Compare
pelwell
left a comment
There was a problem hiding this comment.
I don't love the fact that this relies on both 0 and UINT_MAX being illegal TD_STATUS values, especially when there are no comments or named constants to make that clear, but if that is indeed the case then I can live with this.
| timer_setup(&tsdata->timer, edt_ft5x06_ts_irq_poll_timer, 0); | ||
| tsdata->timer.expires = jiffies + | ||
| msecs_to_jiffies(POLL_INTERVAL_MS); | ||
| msecs_to_jiffies(FIRST_POLL_DELAY_MS); |
There was a problem hiding this comment.
The previous indentation looks better.
There was a problem hiding this comment.
That was emacs' default for linux style - but I've just noticed that checkpatch allows both (surprisingly). I can increase it again.
There was a problem hiding this comment.
Either that or push jiffies onto the next line
There was a problem hiding this comment.
Would a signed integer and -1 be a nicer way to represent "uninitialized"? Actual values are u8, and u8->int casting is presumably uncontroversial.
To anticipate another potential question: we deliberately do include the "reserved" upper nybble in the test, because it does help to discriminate between bogus and real touch data.
There was a problem hiding this comment.
Since init_td_status is a signed int, and the rdbuf values are u8s, making the magic values negative is clearer and guaranteed to work.
7c9b0a6 to
e9a4bb1
Compare
When polled without the use of IRQ, FT5x06 registers may return undefined initial data, causing unwanted touches or event spamming. A simple way to filter this out is to suppress touches until the TD_STATUS register changes for the first time. Increase the delay before first polling to 300ms, to avoid transient I2C read flakiness that seems to occur after reset. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
e9a4bb1 to
8a1eb25
Compare
|
With the latest change you are still relying on the first TD_STATUS value not being 0 - is that guaranteed to be the case? |
Functionally, we don't rely on this: even if we chose some other bit pattern to represent the no-filtering state, a first value of 0 is a benign value that we don't need to filter, and indeed is what we'd like the first TD_STATUS to have been, so it felt natural to use it for that. It's also the simplest value to test for (silly micro-optimization!) |
Is a reviewer supposed to know that? Anyway, I don't object. |
|
Sorry... I am having second thoughts about the fix above It's possible to get into a state where the first touch is ignored. This can happen either if the initial data happened to have TD_STATUS == 0x01, which I have never observed; or quite reproducibly by the following steps:
To fix it I may need to revert the simplification which looked at TD_STATUS only, and go back to comparing the entire buffer. The safer-but-more-complicated version is sitting on branch ft5x06-filter2. I won't PR it for now. |
This is a refinement which replaces or should be squashed with commit dd802fc from PR #5645 and the new commit message should be the following: When polled without the use of IRQ, FT5x06 registers may return undefined initial data, causing unwanted touches or event spamming. To avoid this, whenever the initial number of touches is non-zero, discard all touches until something changes. Increase the delay before first polling to 300ms, to avoid transient I2C read flakiness that seems to occur after reset. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>
kernel: drivers: media: rp1_cfe: Fix link validate test for pixel format See: raspberrypi/linux#5657 kernel: drm/vc4: Correct address offset for planes with src_[xy] offsets See: raspberrypi/linux#5654 kernel: input: touchscreen: edt-ft5x06: Suppress bogus data on startup See: raspberrypi/linux#5645 kernel: vc_mem: Add the DMA memcpy support from bcm2708_fb See: raspberrypi/linux#5651 kernel: dts: bcm2712: Set default I2C baudrates to 100kHz See: raspberrypi/linux#5653 kernel: MCP23017: allow specification of the i2c bus See: raspberrypi/linux#5650 kernel: Revert: bcm2708_fb: Hack out dma support See: raspberrypi/linux#5648 firmware: config: Add [pi5] to config.txt on 2711 and earlier platforms userland: bcm_host: Update kms/fkms check for pi5
kernel: drivers: media: rp1_cfe: Fix link validate test for pixel format See: raspberrypi/linux#5657 kernel: drm/vc4: Correct address offset for planes with src_[xy] offsets See: raspberrypi/linux#5654 kernel: input: touchscreen: edt-ft5x06: Suppress bogus data on startup See: raspberrypi/linux#5645 kernel: vc_mem: Add the DMA memcpy support from bcm2708_fb See: raspberrypi/linux#5651 kernel: dts: bcm2712: Set default I2C baudrates to 100kHz See: raspberrypi/linux#5653 kernel: MCP23017: allow specification of the i2c bus See: raspberrypi/linux#5650 kernel: Revert: bcm2708_fb: Hack out dma support See: raspberrypi/linux#5648 firmware: config: Add [pi5] to config.txt on 2711 and earlier platforms userland: bcm_host: Update kms/fkms check for pi5
When polled without the use of IRQ, FT5x06 registers may hold undefined data. Filter out the initial static state (allowing a few transient zeroes which may occur around 700ms after reset).