* [PATCH 2/4] TSC2102 Touchscreen
@ 2006-08-18 10:07 andrzej zaborowski
2006-08-18 13:09 ` Komal Shah
0 siblings, 1 reply; 4+ messages in thread
From: andrzej zaborowski @ 2006-08-18 10:07 UTC (permalink / raw)
To: Linux-OMAP
[-- Attachment #1: Type: text/plain, Size: 205 bytes --]
This a driver for touchscreens connected to the TSC2102 chip. It uses
the normal input events framework and can be accessed through
/dev/input/eventX.
Signed-off-by: Andrzej Zaborowski <balrog@zabor.org>
[-- Attachment #2: linux-tsc2102-touchscreen.patch --]
[-- Type: application/octet-stream, Size: 5364 bytes --]
diff -pNaur -X b/Documentation/dontdiff a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
--- a/drivers/input/touchscreen/Kconfig 2006-07-06 02:48:09.000000000 +0000
+++ b/drivers/input/touchscreen/Kconfig 2006-08-17 23:35:38.000000000 +0000
@@ -111,6 +111,20 @@ config TOUCHSCREEN_HP600
To compile this driver as a module, choose M here: the
module will be called hp680_ts_input.
+config TOUCHSCREEN_TSC2102
+ tristate "TSC 2102 based touchscreens"
+ depends on SPI_MASTER
+ select TSC2102
+ help
+ Say Y here if you have a touchscreen interface using the
+ TI TSC 2102 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 tsc2102_ts.
+
endif
config TOUCHSCREEN_OMAP
tristate "OMAP touchscreen input driver"
diff -pNaur -X b/Documentation/dontdiff a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
--- a/drivers/input/touchscreen/Makefile 2006-03-22 17:44:37.000000000 +0000
+++ b/drivers/input/touchscreen/Makefile 2006-08-17 23:35:38.000000000 +0000
@@ -12,4 +12,5 @@ obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o
obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
+obj-$(CONFIG_TOUCHSCREEN_TSC2102) += tsc2102_ts.o
obj-$(CONFIG_TOUCHSCREEN_OMAP) += omap/
diff -pNaur -X b/Documentation/dontdiff a/drivers/input/touchscreen/tsc2102_ts.c b/drivers/input/touchscreen/tsc2102_ts.c
--- a/drivers/input/touchscreen/tsc2102_ts.c 1970-01-01 00:00:00.000000000 +0000
+++ b/drivers/input/touchscreen/tsc2102_ts.c 2006-08-17 23:35:38.000000000 +0000
@@ -0,0 +1,148 @@
+/*
+ * input/touchscreen/tsc2102_ts.c
+ *
+ * Touchscreen input device driver for boards using the TSC 2102 chip.
+ *
+ * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this package; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/input.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/kbd_kern.h>
+
+#include <linux/spi/tsc2102.h>
+
+struct input_dev *dev;
+
+static void tsc2102_touch(int touching)
+{
+ if (!touching) {
+ input_report_abs(dev, ABS_X, 0);
+ input_report_abs(dev, ABS_Y, 0);
+ input_report_abs(dev, ABS_PRESSURE, 0);
+ input_sync(dev);
+ }
+
+ input_report_key(dev, BTN_TOUCH, touching);
+
+ do_poke_blanked_console = 1;
+}
+
+static void tsc2102_coords(int x, int y, int z1, int z2)
+{
+ int p;
+
+ /* Calculate the touch resistance a la equation #1 */
+ if (z1 != 0)
+ p = x * (z2 - z1) / (z1 << 4);
+ else
+ p = 1;
+
+ input_report_abs(dev, ABS_X, x);
+ input_report_abs(dev, ABS_Y, y);
+ input_report_abs(dev, ABS_PRESSURE, p);
+ input_sync(dev);
+}
+
+static int tsc2102_ts_probe(struct platform_device *pdev)
+{
+ int status;
+
+ dev = input_allocate_device();
+ if (!dev)
+ return -ENOMEM;
+
+ status = tsc2102_touch_cb(tsc2102_touch);
+ if (status) {
+ input_free_device(dev);
+ return status;
+ }
+
+ status = tsc2102_coords_cb(tsc2102_coords);
+ if (status) {
+ input_free_device(dev);
+ return status;
+ }
+
+ dev->name = "TSC2102 Touchscreen";
+ dev->dev = &pdev->dev;
+ dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ dev->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+ dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+ input_register_device(dev);
+
+ printk("TSC2102 touchscreen driver initialized\n");
+ return 0;
+}
+
+static int tsc2102_ts_remove(struct platform_device *pdev)
+{
+ tsc2102_touch_cb(0);
+ tsc2102_coords_cb(0);
+ input_unregister_device(dev);
+ return 0;
+}
+
+static int
+tsc2102_ts_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ /* Nothing yet */
+ return 0;
+}
+
+static int tsc2102_ts_resume(struct platform_device *pdev)
+{
+ /* Nothing either */
+ return 0;
+}
+
+static struct platform_driver tsc2102_ts_driver = {
+ .probe = tsc2102_ts_probe,
+ .remove = tsc2102_ts_remove,
+ .suspend = tsc2102_ts_suspend,
+ .resume = tsc2102_ts_resume,
+ .driver = {
+ .name = "tsc2102-ts",
+ },
+};
+
+static int __init tsc2102_ts_init(void)
+{
+ int ret;
+
+ ret = platform_driver_register(&tsc2102_ts_driver);
+ if (ret)
+ return -ENODEV;
+
+ return 0;
+}
+
+static void __exit tsc2102_ts_exit(void)
+{
+ platform_driver_unregister(&tsc2102_ts_driver);
+}
+
+module_init(tsc2102_ts_init);
+module_exit(tsc2102_ts_exit);
+
+MODULE_AUTHOR("Andrzej Zaborowski");
+MODULE_DESCRIPTION("Touchscreen input driver for TI TSC2102.");
+MODULE_LICENSE("GPL");
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/4] TSC2102 Touchscreen
2006-08-18 10:07 [PATCH 2/4] TSC2102 Touchscreen andrzej zaborowski
@ 2006-08-18 13:09 ` Komal Shah
2006-09-13 19:14 ` andrzej zaborowski
0 siblings, 1 reply; 4+ messages in thread
From: Komal Shah @ 2006-08-18 13:09 UTC (permalink / raw)
To: balrogg, Linux-OMAP
--- andrzej zaborowski <balrog@zabor.org> wrote:
> This a driver for touchscreens connected to the TSC2102 chip. It uses
> the normal input events framework and can be accessed through
> /dev/input/eventX.
>
Few comments here too:
+#include <linux/platform_device.h>
+#include <linux/kbd_kern.h>
Why you need kbd_kern.h ?
+ dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+ input_register_device(dev);
You should check the return value of input_register_device.
+ printk("TSC2102 touchscreen driver initialized\n");
Better if you use KERN_INFO with printk above.
+ dev->name = "TSC2102 Touchscreen";
+ dev->dev = &pdev->dev;
Also fill up remaining fields of input_dev structure. eg. phys, bustype
etc.
+static int
+tsc2102_ts_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ /* Nothing yet */
+ return 0;
+}
+
+static int tsc2102_ts_resume(struct platform_device *pdev)
+{
+ /* Nothing either */
+ return 0;
+}
How about using #ifdef CONFIG_PM around suspend and resume. ?
---Komal Shah
http://komalshah.blogspot.com/
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/4] TSC2102 Touchscreen
2006-08-18 13:09 ` Komal Shah
@ 2006-09-13 19:14 ` andrzej zaborowski
2006-10-19 13:44 ` Tony Lindgren
0 siblings, 1 reply; 4+ messages in thread
From: andrzej zaborowski @ 2006-09-13 19:14 UTC (permalink / raw)
To: Komal Shah; +Cc: Linux-OMAP
[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]
On 18/08/06, Komal Shah <komal_shah802003@yahoo.com> wrote:
> Few comments here too:
>
> +#include <linux/platform_device.h>
> +#include <linux/kbd_kern.h>
>
> Why you need kbd_kern.h ?
It was my attempt to tell the kernel to not blank the console when I'm
typing something using an on-screen keyboard in a tty, like when
typing with a keyboard. I can see that it's not the right place for
this code -- it should probably either be done in userspace, the gpm
way, or be generic for all touchscreen devices like it is for
keyboards.
Attached is a cleaner version of the patch.
>
> + dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
> + input_register_device(dev);
>
> You should check the return value of input_register_device.
>
> + printk("TSC2102 touchscreen driver initialized\n");
>
> Better if you use KERN_INFO with printk above.
>
> + dev->name = "TSC2102 Touchscreen";
> + dev->dev = &pdev->dev;
>
> Also fill up remaining fields of input_dev structure. eg. phys, bustype
> etc.
>
> +static int
> +tsc2102_ts_suspend(struct platform_device *pdev, pm_message_t state)
> +{
> + /* Nothing yet */
> + return 0;
> +}
> +
> +static int tsc2102_ts_resume(struct platform_device *pdev)
> +{
> + /* Nothing either */
> + return 0;
> +}
>
> How about using #ifdef CONFIG_PM around suspend and resume. ?
>
>
> ---Komal Shah
> http://komalshah.blogspot.com/
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
--
balrog 2oo6
[-- Attachment #2: linux-tsc2102-touchscreen.patch --]
[-- Type: application/octet-stream, Size: 5467 bytes --]
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -111,6 +111,21 @@ config TOUCHSCREEN_HP600
To compile this driver as a module, choose M here: the
module will be called hp680_ts_input.
+config TOUCHSCREEN_TSC2102
+ tristate "TSC 2102 based touchscreens"
+ depends on SPI_MASTER
+ select TSC2102
+ help
+ Say Y here if you have a touchscreen interface using the
+ TI TSC 2102 controller, and your board-specific initialization
+ code includes that in its table of SPI devices. Also make
+ sure the proper SPI controller is selected.
+
+ 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 tsc2102_ts.
+
endif
config TOUCHSCREEN_OMAP
tristate "OMAP touchscreen input driver"
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -12,4 +12,5 @@ obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o
obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
+obj-$(CONFIG_TOUCHSCREEN_TSC2102) += tsc2102_ts.o
obj-$(CONFIG_TOUCHSCREEN_OMAP) += omap/
diff --git a/drivers/input/touchscreen/tsc2102_ts.c b/drivers/input/touchscreen/tsc2102_ts.c
new file mode 100644
--- /dev/null
+++ b/drivers/input/touchscreen/tsc2102_ts.c
@@ -0,0 +1,164 @@
+/*
+ * input/touchscreen/tsc2102_ts.c
+ *
+ * Touchscreen input device driver for the TSC 2102 chip.
+ *
+ * Copyright (c) 2006 Andrzej Zaborowski <balrog@zabor.org>
+ *
+ * This package is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this package; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/input.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+
+#include <linux/spi/tsc2102.h>
+
+struct input_dev *dev;
+
+static void tsc2102_touch(int touching)
+{
+ if (!touching) {
+ input_report_abs(dev, ABS_X, 0);
+ input_report_abs(dev, ABS_Y, 0);
+ input_report_abs(dev, ABS_PRESSURE, 0);
+ input_sync(dev);
+ }
+
+ input_report_key(dev, BTN_TOUCH, touching);
+}
+
+static void tsc2102_coords(int x, int y, int z1, int z2)
+{
+ int p;
+
+ /* Calculate the touch resistance a la equation #1 */
+ if (z1 != 0)
+ p = x * (z2 - z1) / (z1 << 4);
+ else
+ p = 1;
+
+ input_report_abs(dev, ABS_X, x);
+ input_report_abs(dev, ABS_Y, y);
+ input_report_abs(dev, ABS_PRESSURE, p);
+ input_sync(dev);
+}
+
+static int tsc2102_ts_probe(struct platform_device *pdev)
+{
+ int status;
+
+ dev = input_allocate_device();
+ if (!dev)
+ return -ENOMEM;
+
+ status = tsc2102_touch_cb(tsc2102_touch);
+ if (status) {
+ input_free_device(dev);
+ return status;
+ }
+
+ status = tsc2102_coords_cb(tsc2102_coords);
+ if (status) {
+ tsc2102_touch_cb(0);
+ input_free_device(dev);
+ return status;
+ }
+
+ dev->name = "TSC2102 Touchscreen";
+ dev->dev = &pdev->dev;
+ dev->cdev.dev = &pdev->dev;
+ dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
+ dev->keybit[LONG(BTN_TOUCH)] |= BIT(BTN_TOUCH);
+ dev->absbit[0] = BIT(ABS_X) | BIT(ABS_Y) | BIT(ABS_PRESSURE);
+ dev->phys = "tsc2102/input0";
+ dev->id.bustype = BUS_HOST;
+ dev->id.vendor = 0x0001;
+ dev->id.product = 0x2102;
+ dev->id.version = 0x0001;
+
+ status = input_register_device(dev);
+ if (status) {
+ tsc2102_coords_cb(0);
+ tsc2102_touch_cb(0);
+ input_free_device(dev);
+ return status;
+ }
+
+ printk(KERN_INFO "TSC2102 touchscreen driver initialized\n");
+ return 0;
+}
+
+static int tsc2102_ts_remove(struct platform_device *pdev)
+{
+ tsc2102_touch_cb(0);
+ tsc2102_coords_cb(0);
+ input_unregister_device(dev);
+ input_free_device(dev);
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int
+tsc2102_ts_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ return 0;
+}
+
+static int tsc2102_ts_resume(struct platform_device *pdev)
+{
+ return 0;
+}
+#else
+#define tsc2102_ts_suspend NULL
+#define tsc2102_ts_resume NULL
+#endif
+
+static struct platform_driver tsc2102_ts_driver = {
+ .probe = tsc2102_ts_probe,
+ .remove = tsc2102_ts_remove,
+ .suspend = tsc2102_ts_suspend,
+ .resume = tsc2102_ts_resume,
+ .driver = {
+ .name = "tsc2102-ts",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init tsc2102_ts_init(void)
+{
+ int ret;
+
+ ret = platform_driver_register(&tsc2102_ts_driver);
+ if (ret)
+ return -ENODEV;
+
+ return 0;
+}
+
+static void __exit tsc2102_ts_exit(void)
+{
+ platform_driver_unregister(&tsc2102_ts_driver);
+}
+
+module_init(tsc2102_ts_init);
+module_exit(tsc2102_ts_exit);
+
+MODULE_AUTHOR("Andrzej Zaborowski");
+MODULE_DESCRIPTION("Touchscreen input driver for TI TSC2102.");
+MODULE_LICENSE("GPL");
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/4] TSC2102 Touchscreen
2006-09-13 19:14 ` andrzej zaborowski
@ 2006-10-19 13:44 ` Tony Lindgren
0 siblings, 0 replies; 4+ messages in thread
From: Tony Lindgren @ 2006-10-19 13:44 UTC (permalink / raw)
To: balrogg; +Cc: Linux-OMAP
* andrzej zaborowski <balrog@zabor.org> [060913 22:16]:
> On 18/08/06, Komal Shah <komal_shah802003@yahoo.com> wrote:
> >Few comments here too:
> >
> >+#include <linux/platform_device.h>
> >+#include <linux/kbd_kern.h>
> >
> >Why you need kbd_kern.h ?
>
> It was my attempt to tell the kernel to not blank the console when I'm
> typing something using an on-screen keyboard in a tty, like when
> typing with a keyboard. I can see that it's not the right place for
> this code -- it should probably either be done in userspace, the gpm
> way, or be generic for all touchscreen devices like it is for
> keyboards.
>
> Attached is a cleaner version of the patch.
Pushing today.
Tony
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-10-19 13:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-18 10:07 [PATCH 2/4] TSC2102 Touchscreen andrzej zaborowski
2006-08-18 13:09 ` Komal Shah
2006-09-13 19:14 ` andrzej zaborowski
2006-10-19 13:44 ` Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox