input/spi: add ads7843 support to ads7846 touchscreen driver
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Nicolas FERRE
Add support for the ads7843 touchscreen controller to the ads7846 driver code.
Glad to see this! Is this for AT91sam9261-EK board support, maybe?
Quoted 10 lines
The "pen down" information is managed quite differently as we do not have a touch-presure mesurement on the ads7843.
Signed-off-by Nicolas Ferre <[email protected]>---
I add a
ads7843_rxfunction to manage the end of a measurement cycle. As forads7846_rx, it does the real work and comnunicates with the input subsystem. The timer function is responsible of taking the pen up/pen down state through the board specificget_pendown_state()callback.
Hmm, unfortunately there are a lot of updates to this driver sitting in the linux-omap tree ... the N770 guys really put a lot of solid work into it (ISTR seeing a statistical plot showing how touchscreen debounce helps get stable readings!), but those patches didn't get upstream yet.
One of the more critical of those patches addressed much the same pendown state issue; it turns out that measuring pressure (after the pendown irq) isn't the best way to notice when pen status becomes "up".
Let me try to sort out the mess with those updates, and ask you to refresh this ads7843 support against that more-current ads7846 code. (Or if you want a preview, have a look at the linux-omap tree. There's a clone of that in the GIT area on kernel.org if you want.)
Quoted 3 lines
As the SPI underlying code behaves quite differently from a controller driver to another whan not having a
tx_buffilled, I have add a zerroed buffer to give to the spi layer while receiving data.
You must be working with a buggy controller driver then. That part of this patch should never be needed. It's expected that rx-only transfers will omit a tx buf; all controller drivers must handle that case.
- Dave
Quoted 3 lines
Already posted to lkml :
http://lkml.org/lkml/2006/12/15/71
Quoted 4 lines · David Brownell
Quoted 1 line · Nicolas FERRE
Add support for the ads7843 touchscreen controller to the ads7846 driver code.
Glad to see this! Is this for AT91sam9261-EK board support, maybe?
Indeed ! An also for the AT91sam9263-EK which has the same touchscreen chip.
Quoted 2 lines
Let me try to sort out the mess with those updates, and ask you to refresh this ads7843 support against that more-current ads7846 code.
Ok, let me know when you have a newer code. I will try to adapt my ads7843 support then.
Quoted 7 lines
Quoted 3 lines
As the SPI underlying code behaves quite differently from a controller driver to another whan not having a
tx_buffilled, I have add a zerroed buffer to give to the spi layer while receiving data.You must be working with a buggy controller driver then. That part of this patch should never be needed. It's expected that rx-only transfers will omit a tx buf; all controller drivers must handle that case.
I said that because it is true that most of spi controller drivers manage rx only transactions filling the tx buffer with zerros but the spi_s3c24xx.c driver seems to fill with ones (line 177 hw_txbyte())
Anyway, I will check in our controller driver to sort this out.
Regards,
Signature · 1 line
Nicolas Ferre
Quoted 11 lines · Nicolas Ferre
Quoted 7 lines
Quoted 3 lines
As the SPI underlying code behaves quite differently from a controller driver to another whan not having a
tx_buffilled, I have add a zerroed buffer to give to the spi layer while receiving data.You must be working with a buggy controller driver then. That part of this patch should never be needed. It's expected that rx-only transfers will omit a tx buf; all controller drivers must handle that case.
I said that because it is true that most of spi controller drivers manage rx only transactions filling the tx buffer with zerros but the
spi_s3c24xx.cdriver seems to fill with ones (line 177hw_txbyte())Anyway, I will check in our controller driver to sort this out.
I dug a bit into this.
Well, in the atmel_spi driver code, we use previous rx buffer if we do not provide a tx_buf (as it is said that in struct spi_transfer comments, "If the transmit buffer is null, undefined data will be shifted out while filling rx_buf"). So, the touchscreen controller sees sometimes a "start" condition (bit 7 of a control byte). It then takes the control byte and sets trash bits as a configuration. I ran into those troubles and add a zerroed buffer as tx.
Do you think that shifting zerros out when a tx_buf is not specified is the desired behavior ?
Regards,
Signature · 1 line
Nicolas Ferre
Quoted 10 lines · Nicolas Ferre
Quoted 9 lines · Nicolas Ferre
Quoted 8 lines
Quoted 4 lines
As the SPI underlying code behaves quite differently from a controller driver to another whan not having a
tx_buffilled, I have add a zerroed buffer to give to the spi layer while receiving data.You must be working with a buggy controller driver then. That part of this patch should never be needed. It's expected that rx-only transfers will omit a tx buf; all controller drivers must handle that case.
Quoted 7 lines
Quoted 5 lines
I said that because it is true that most of spi controller drivers manage rx only transactions filling the tx buffer with zerros but the
spi_s3c24xx.cdriver seems to fill with ones (line 177hw_txbyte())Anyway, I will check in our controller driver to sort this out.
I dug a bit into this.
I always like to see followup on such issues. :)
Quoted 4 lines
Well, in the
atmel_spidriver code, we use previous rx buffer if we do not provide atx_buf(as it is said that in structspi_transfercomments, "If the transmit buffer is null, undefined data will be shifted out while fillingrx_buf").
That seems like a reasonable approach. If it's undefined, the only reasons I can think of to not use the rx buffer are that:
(a) the cachelines might not be managed correctly during DMA ... i.e. to defend against a bug in the controller driver; and
(b) that writing such _defined_ data would be a "covert channel" in the security sense.
Now, (a) is just a bug to fix, and in most cases (b) won't be an issue since even if the system with that driver is being evaluated at a level where such channels matter, the hardware hooked up via SPI will probably already be trusted. (Unless the system allows thing like MMC or SD cards...) However, see below.
Quoted 3 lines
So, the touchscreen controller sees sometimes a "start" condition (bit 7 of a control byte). It then takes the control byte and sets trash bits as a configuration.
Actually, now that I look at it I see that the docs for both the ads7846 and the ads7843 show that DIN/MOSI should be zero/low after the command is given, while reading DOUT/MISO.
Which means that the real issue here is that the driver was wrong in the first place to not explicitly write zeroes while it's reading back that data.
The testing I've done with it involved two controller drivers which do happen to interpret "undefined" as "write zeros": omap_uwire, which I'm guessing does so in hardware (MicroWire is half duplex), and pxa2xx_spi, which explicitly writes zeros (null_writer).
Quoted 4 lines
I ran into those troubles and add a zerroed buffer as tx.
Do you think that shifting zerros out when a
tx_bufis not specified is the desired behavior ?
I'm leaning towards a "yes" there -- changing the spec for spi_transfer.
The alternative would seem to mean teaching the SPI interface about two different kinds of "rx only" transfers, one with "must tx zero" semantics and the other with "tx data doesn't matter" (and security audits would define it anyway, to avoid covert channels). And I can't easily justify that.
For now, I'd suggest you update the atmel_spi driver so that it shifts zeroes in that case; can't hurt (too much). And I'll forward the issue to the SPI list. If nobody there objects, I'll send patches to update the spec for spi_transfer, and the s3c driver.
- Dave
Quoted 5 lines · Nicolas Ferre
Quoted 2 lines
Let me try to sort out the mess with those updates, and ask you to refresh this ads7843 support against that more-current ads7846 code.
Ok, let me know when you have a newer code. I will try to adapt my ads7843 support then.
I just sent these updates to LKML ... though the address I had for Dmitry sees to have gone bad, I do see all six patches in the list archives.
Now it's your turn. :)
- Dave
Quoted 11 lines · David Brownell
Quoted 5 lines · Nicolas Ferre
Quoted 2 lines
Let me try to sort out the mess with those updates, and ask you to refresh this ads7843 support against that more-current ads7846 code.
Ok, let me know when you have a newer code. I will try to adapt my ads7843 support then.
I just sent these updates to LKML ... though the address I had for Dmitry sees to have gone bad, I do see all six patches in the list archives.
I changed my ISP. Please use either:
[email protected]
[email protected]
[email protected]
The last one may go bad if I ever change ISP again but I intend to keep the first 2 indefinitely.
I'll fish the patches from LKML.
Signature · 1 line
Dmitry