Input/Touchscreen Driver: add support AD7877 touchscreen driver (resend to linux-input mailist)
Subsystems (3)
PATCH 1/1 Input/Touchscreen Driver: add support AD7877 touchscreen driver (resend to linux-input mailist)
Quoted 1 line
From
a9a37412a96d693fab23cb2ecdd5d1e86b02fad1Mon Sep 17 00:00:00 2001
From: Michael Hennerich <[email protected]>
Date: Fri, 25 Jan 2008 15:42:53 +0800
Subject: [PATCH] Input/Touchscreen Driver: add support AD7877 touchscreen driver
[try #2] Changelog:
- move locking inside ad7877_enable and ad7877_disable
- use setup_timer
- use input_dev->dev.parent
- fix unregister device
- kill EV_KEY since it's not used
- fix indention style
Apply patch from Philip Douglass:
Make ad7877 ts driver not dependent on Blackfin specific cs_change_per_word_option
--- drivers/input/touchscreen/Kconfig | 13 + drivers/input/touchscreen/Makefile | 1 + drivers/input/touchscreen/ad7877.c | 929 ++++++++++++++++++++++++++++++++++++ 3 files changed, 943 insertions(+), 0 deletions(-) create mode 100644 drivers/input/touchscreen/ad7877.c
drivers/input/touchscreen/Kconfig +13 -0
@@ -29,6 +29,19 @@ config TOUCHSCREEN_ADS7846 To compile this driver as a module, choose M here: the module will be called ads7846. +config TOUCHSCREEN_AD7877 + tristate "AD7877 based touchscreens" + depends on SPI_MASTER + help + Say Y here if you have a touchscreen interface using the + AD7877 controller, and your board-specific initialization + code includes that in its table of SPI devices. + + If unsure, say N (but it's safe to say "Y"). + + To compile this driver as a module, choose M here: the + module will be called ad7877. + config TOUCHSCREEN_BITSY tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" depends on SA1100_BITSY
drivers/input/touchscreen/Makefile +1 -0
@@ -4,6 +4,7 @@ # Each configuration option enables a list of files. +obj-$(CONFIG_TOUCHSCREEN_AD7877) += ad7877.o obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
drivers/input/touchscreen/ad7877.c new file +929 -0
929 lines not on this page · raw message
Signature · 1 line
1.5.3.4
Dmitry Torokhov
maintainerHi Bryan,
On Mon, Feb 04, 2008 at 05:52:38PM +0800, Bryan Wu wrote:
+
drivers/input/touchscreen/ad7877.c line 251
Quoted 8 lines
drivers/input/touchscreen/ad7877.c new file +8
-0+spi_message_add_tail (&req->xfer[0 ], &req->msg); +spi_message_add_tail (&req->xfer[1 ], &req->msg); + + status =spi_sync (spi, &req->msg); + +if (req->msg.status) + status = req->msg.status; +
I think the "new way" for spi is to just check return value of spi_sync and not bother with req->msg.status, but even using old style spi_sycn I'd expect something like:
status = spi_sync(spi, &req->msg); if (status == 0) status = req->msg.status;
Quoted 6 lines
drivers/input/touchscreen/ad7877.c new file +6
-0+ +static ssize_t ad7877_gpio3_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct ad7877 *ts =dev_get_drvdata (dev);
drivers/input/touchscreen/ad7877.c line 438
Quoted 10 lines
drivers/input/touchscreen/ad7877.c new file +10
-0+char *endp; +int i; + + i =simple_strtoul (buf, &endp,10 ); + +if (i) + ts->gpio3=1 ; +else + ts->gpio3=0 ; +
I am tempted to change the above to ts->gpio3 = !!i;
Quoted 13 lines
drivers/input/touchscreen/ad7877.c new file +13
-0+ +if (likely (x && z1 && !device_suspended (&ts->spi->dev))) { +/* compute touch pressure resistance using equation #2 */ + Rt = z2; + Rt -= z1; + Rt *= x; + Rt *= ts->x_plate_ohms; + Rt /= z1; + Rt = (Rt +2047 ) >>12 ; + }else + Rt =0 ; + +if (Rt) {
drivers/input/touchscreen/ad7877.c line 543
Quoted 10 lines
drivers/input/touchscreen/ad7877.c new file +10
-0+input_report_abs (input_dev,ABS_X , x); +input_report_abs (input_dev,ABS_Y , y); +input_report_abs (input_dev,ABS_PRESSURE , Rt); +input_sync (input_dev); + } + +#ifdef VERBOSE +if (Rt) +pr_debug ("%s: %d/%d/%d%s\n" , ts->spi->dev.bus_id, + x, y, Rt, Rt ?"" :" UP" );
We check the same condition 3 times in a row. The compiler might combine them but why not help it?
drivers/input/touchscreen/ad7877.c line 667
Quoted 6 lines
drivers/input/touchscreen/ad7877.c new file +6
-0+ +static int ad7877_suspend (struct spi_device *spi,pm_message_t message) +{ +struct ad7877 *ts =dev_get_drvdata (&spi->dev); + + spi->dev.power.power_state = message;
I think they are trying to get rid of power_state...
drivers/input/touchscreen/ad7877.c line 678
Quoted 11 lines
drivers/input/touchscreen/ad7877.c new file +11
-0+ad7877_disable (ts); + +return 0 ; + +} + +static int ad7877_resume (struct spi_device *spi) +{ +struct ad7877 *ts =dev_get_drvdata (&spi->dev); + + spi->dev.power.power_state =PMSG_ON ;
Same here.
drivers/input/touchscreen/ad7877.c line 855
Quoted 11 lines
drivers/input/touchscreen/ad7877.c new file +11
-0+ + err =input_register_device (input_dev); +if (err) + goto err_idev; + + ts->intr_flag =0 ; + +return 0 ; + +err_idev: + input_dev =NULL ;/* so we don't try to free it later */
But we _do_ need to free it if input_register_device() fails.
Thanks.
Signature · 1 line
Dmitry
Hennerich, Michael
maintainerRE: [PATCH] Input/Touchscreen Driver: add support AD7877touchscreen driver (resend to linux-input mailist)
Dmitry,
Thanks for you feedback.
Bryan is going to send out an updated patch.
Best regards,
Michael
Quoted 48 lines
-----Original Message-----
From: Dmitry Torokhov [mailto:[email protected]]
Sent: Montag, 4. Februar 2008 18:13
To: Bryan Wu
Cc: Michael Hennerich; [email protected]
Subject: Re: [PATCH] Input/Touchscreen Driver: add support AD7877touchscreen driver (resend to linux-input mailist)Hi Bryan,
On Mon, Feb 04, 2008 at 05:52:38PM +0800, Bryan Wu wrote:
+drivers/input/touchscreen/ad7877.c line 251
Quoted 8 lines
drivers/input/touchscreen/ad7877.c new file +8
-0+spi_message_add_tail (&req->xfer[0 ], &req->msg); +spi_message_add_tail (&req->xfer[1 ], &req->msg); + + status =spi_sync (spi, &req->msg); + +if (req->msg.status) + status = req->msg.status; +I think the "new way" for spi is to just check return value of
spi_syncand not bother withreq->msg.status, but even using old stylespi_sycnI'd expect something like:status = spi_sync(spi, &req->msg); if (status == 0) status = req->msg.status;Quoted 6 lines
drivers/input/touchscreen/ad7877.c new file +6
-0+ +static ssize_t ad7877_gpio3_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct ad7877 *ts =dev_get_drvdata (dev);drivers/input/touchscreen/ad7877.c line 438
Quoted 10 lines
drivers/input/touchscreen/ad7877.c new file +10
-0+char *endp; +int i; + + i =simple_strtoul (buf, &endp,10 ); + +if (i) + ts->gpio3=1 ; +else + ts->gpio3=0 ; +I am tempted to change the above to
ts->gpio3= !!i;
Quoted 3 lines
drivers/input/touchscreen/ad7877.c
Quoted 3 lines
drivers/input/touchscreen/ad7877.c new file +3
-0+ +if (likely (x && z1 && !device_suspended (&ts->spi->dev))) { +/* compute touch pressure resistance using equation #2
*/
Quoted 24 lines
Quoted 10 lines
drivers/input/touchscreen/ad7877.c new file +10
-0+ Rt = z2; + Rt -= z1; + Rt *= x; + Rt *= ts->x_plate_ohms; + Rt /= z1; + Rt = (Rt +2047 ) >>12 ; + }else + Rt =0 ; + +if (Rt) {drivers/input/touchscreen/ad7877.c line 543
Quoted 10 lines
drivers/input/touchscreen/ad7877.c new file +10
-0+input_report_abs (input_dev,ABS_X , x); +input_report_abs (input_dev,ABS_Y , y); +input_report_abs (input_dev,ABS_PRESSURE , Rt); +input_sync (input_dev); + } + +#ifdef VERBOSE +if (Rt) +pr_debug ("%s: %d/%d/%d%s\n" , ts->spi->dev.bus_id, + x, y, Rt, Rt ?"" :" UP" );We check the same condition 3 times in a row. The compiler might combine them but why not help it?
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +static int ad7877_suspend(struct spi_device *spi, pm_message_t
message)
Quoted 39 lines
drivers/input/touchscreen/ad7877.c line 667
Quoted 4 lines
drivers/input/touchscreen/ad7877.c new file +4
-0+{ +struct ad7877 *ts =dev_get_drvdata (&spi->dev); + + spi->dev.power.power_state = message;I think they are trying to get rid of
power_state...drivers/input/touchscreen/ad7877.c line 678
Quoted 11 lines
drivers/input/touchscreen/ad7877.c new file +11
-0+ad7877_disable (ts); + +return 0 ; + +} + +static int ad7877_resume (struct spi_device *spi) +{ +struct ad7877 *ts =dev_get_drvdata (&spi->dev); + + spi->dev.power.power_state =PMSG_ON ;Same here.
drivers/input/touchscreen/ad7877.c line 855
Quoted 11 lines
drivers/input/touchscreen/ad7877.c new file +11
-0+ + err =input_register_device (input_dev); +if (err) + goto err_idev; + + ts->intr_flag =0 ; + +return 0 ; + +err_idev: + input_dev =NULL ;/* so we don't try to free it later */ But we _do_ need to free it if
input_register_device()fails.Thanks.
--
Dmitry