* [PATCH] Add eGalaxTouch serial touchscreen driver v3
@ 2015-12-16 12:43 Zoltán Böszörményi
2015-12-16 12:54 ` Boszormenyi Zoltan
0 siblings, 1 reply; 4+ messages in thread
From: Zoltán Böszörményi @ 2015-12-16 12:43 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-input, Böszörményi Zoltán,
B�sz�rm�nyi Zolt�n
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 6072 bytes --]
From: Böszörményi Zoltán <zboszormenyi@sicom.com>
There are two EETI touchscreen drivers in the kernel (eeti_ts and egalax_ts)
but both are for I2C-connected panels. This is for a different, serial
and not multi-touch touchscreen panel. The protocol documentation is at
http://www.eeti.com.tw/pdf/Software%20Programming%20Guide_v2.0.pdf
Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/touchscreen/egalax_ts_serial.c | 194 +++++++++++++++++++++++++++
1 file changed, 194 insertions(+)
create mode 100644 drivers/input/touchscreen/egalax_ts_serial.c
diff --git a/drivers/input/touchscreen/egalax_ts_serial.c b/drivers/input/touchscreen/egalax_ts_serial.c
new file mode 100644
index 0000000..59f2bfc
--- /dev/null
+++ b/drivers/input/touchscreen/egalax_ts_serial.c
@@ -0,0 +1,194 @@
+/*
+ * EETI Egalax serial touchscreen driver
+ *
+ * Copyright (c) 2015 Zoltán Böszörményi <zboszor@pr.hu>
+ *
+ * based on the
+ *
+ * Hampshire serial touchscreen driver (Copyright (c) 2010 Adam Bennett)
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/input.h>
+#include <linux/serio.h>
+
+#define DRIVER_DESC "EETI Egalax serial touchscreen driver"
+
+/*
+ * Definitions & global arrays.
+ */
+
+#define EGALAX_FORMAT_MAX_LENGTH 6
+#define EGALAX_FORMAT_START_BIT BIT(7)
+#define EGALAX_FORMAT_PRESSURE_BIT BIT(6)
+#define EGALAX_FORMAT_TOUCH_BIT BIT(0)
+#define EGALAX_FORMAT_RESOLUTION_MASK 0x06
+
+#define EGALAX_MIN_XC 0
+#define EGALAX_MAX_XC 0x4000
+#define EGALAX_MIN_YC 0
+#define EGALAX_MAX_YC 0x4000
+
+/*
+ * Per-touchscreen data.
+ */
+struct egalax {
+ struct input_dev *input;
+ struct serio *serio;
+ int idx;
+ u8 data[EGALAX_FORMAT_MAX_LENGTH];
+ char phys[32];
+};
+
+static void egalax_process_data(struct egalax *egalax)
+{
+ struct input_dev *dev = egalax->input;
+ u8 *data = egalax->data;
+ u16 x, y;
+ u8 shift;
+ u8 mask;
+
+ shift = 3 - ((data[0] & EGALAX_FORMAT_RESOLUTION_MASK) >> 1);
+ mask = 0xff >> (shift + 1);
+
+ x = (((u16)(data[1] & mask) << 7) | (data[2] & 0x7f)) << shift;
+ y = (((u16)(data[3] & mask) << 7) | (data[4] & 0x7f)) << shift;
+
+ input_report_key(dev, BTN_TOUCH, data[0] & EGALAX_FORMAT_TOUCH_BIT);
+ input_report_abs(dev, ABS_X, x);
+ input_report_abs(dev, ABS_Y, y);
+ input_sync(dev);
+}
+
+static irqreturn_t egalax_interrupt(struct serio *serio,
+ unsigned char data, unsigned int flags)
+{
+ struct egalax *egalax = serio_get_drvdata(serio);
+ int pkt_len;
+
+ egalax->data[egalax->idx++] = data;
+
+ if (likely(egalax->data[0] & EGALAX_FORMAT_START_BIT)) {
+ pkt_len = egalax->data[0] & EGALAX_FORMAT_PRESSURE_BIT ? 6 : 5;
+ if (pkt_len == egalax->idx) {
+ egalax_process_data(egalax);
+ egalax->idx = 0;
+ }
+ } else {
+ dev_dbg(&serio->dev, "unknown/unsynchronized data: %x\n",
+ egalax->data[0]);
+ egalax->idx = 0;
+ }
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * egalax_connect() is the routine that is called when someone adds a
+ * new serio device that supports egalax protocol and registers it as
+ * an input device. This is usually accomplished using inputattach.
+ */
+static int egalax_connect(struct serio *serio, struct serio_driver *drv)
+{
+ struct egalax *egalax;
+ struct input_dev *input_dev;
+ int error;
+
+ egalax = kzalloc(sizeof(struct egalax), GFP_KERNEL);
+ input_dev = input_allocate_device();
+ if (!egalax) {
+ error = -ENOMEM;
+ goto err_free_mem;
+ }
+
+ egalax->serio = serio;
+ egalax->input = input_dev;
+ snprintf(egalax->phys, sizeof(egalax->phys),
+ "%s/input0", serio->phys);
+
+ input_dev->name = "EETI eGalaxTouch Serial TouchScreen";
+ input_dev->phys = egalax->phys;
+ input_dev->id.bustype = BUS_RS232;
+ input_dev->id.vendor = SERIO_EGALAX;
+ input_dev->id.product = 0;
+ input_dev->id.version = 0x0001;
+ input_dev->dev.parent = &serio->dev;
+
+ input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
+ input_set_abs_params(input_dev, ABS_X,
+ EGALAX_MIN_XC, EGALAX_MAX_XC, 0, 0);
+ input_set_abs_params(input_dev, ABS_Y,
+ EGALAX_MIN_YC, EGALAX_MAX_YC, 0, 0);
+
+ serio_set_drvdata(serio, egalax);
+
+ error = serio_open(serio, drv);
+ if (error)
+ goto err_reset_drvdata;
+
+ error = input_register_device(input_dev);
+ if (error)
+ goto err_close_serio;
+
+ return 0;
+
+err_close_serio:
+ serio_close(serio);
+err_reset_drvdata:
+ serio_set_drvdata(serio, NULL);
+err_free_mem:
+ input_free_device(input_dev);
+ kfree(egalax);
+ return error;
+}
+
+static void egalax_disconnect(struct serio *serio)
+{
+ struct egalax *egalax = serio_get_drvdata(serio);
+
+ serio_close(serio);
+ serio_set_drvdata(serio, NULL);
+ input_unregister_device(egalax->input);
+ kfree(egalax);
+}
+
+/*
+ * The serio driver structure.
+ */
+
+static const struct serio_device_id egalax_serio_ids[] = {
+ {
+ .type = SERIO_RS232,
+ .proto = SERIO_EGALAX,
+ .id = SERIO_ANY,
+ .extra = SERIO_ANY,
+ },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(serio, egalax_serio_ids);
+
+static struct serio_driver egalax_drv = {
+ .driver = {
+ .name = "egalax",
+ },
+ .description = DRIVER_DESC,
+ .id_table = egalax_serio_ids,
+ .interrupt = egalax_interrupt,
+ .connect = egalax_connect,
+ .disconnect = egalax_disconnect,
+};
+module_serio_driver(egalax_drv);
+
+MODULE_AUTHOR("Zoltán Böszörményi <zboszor@pr.hu>");
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_LICENSE("GPL v2");
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Add eGalaxTouch serial touchscreen driver v3
2015-12-16 12:43 [PATCH] Add eGalaxTouch serial touchscreen driver v3 Zoltán Böszörményi
@ 2015-12-16 12:54 ` Boszormenyi Zoltan
2015-12-16 19:28 ` Dmitry Torokhov
0 siblings, 1 reply; 4+ messages in thread
From: Boszormenyi Zoltan @ 2015-12-16 12:54 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Böszörményi Zoltán
2015-12-16 13:43 keltezéssel, Zoltán Böszörményi írta:
> Signed-off-by: B�sz�rm�nyi Zolt�n <zboszor@pr.hu>
this
> + * Copyright (c) 2015 Zolt�n B�sz�rm�nyi <zboszor@pr.hu>
this
> +MODULE_AUTHOR("Zolt�n B�sz�rm�nyi <zboszor@pr.hu>");
and this were in Latin-2 after you sent the patch back to me, my patch
was UTF-8 in the beginning.
Can you run the code through "recode latin2..utf-8" before committing or
should I resend to fix this?
Thanks,
Zoltán Böszörményi
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add eGalaxTouch serial touchscreen driver v3
2015-12-16 12:54 ` Boszormenyi Zoltan
@ 2015-12-16 19:28 ` Dmitry Torokhov
2015-12-16 19:31 ` Boszormenyi Zoltan
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2015-12-16 19:28 UTC (permalink / raw)
To: Boszormenyi Zoltan; +Cc: linux-input, Böszörményi Zoltán
On Wed, Dec 16, 2015 at 01:54:01PM +0100, Boszormenyi Zoltan wrote:
> 2015-12-16 13:43 keltezéssel, Zoltán Böszörményi írta:
> > Signed-off-by: B�sz�rm�nyi Zolt�n <zboszor@pr.hu>
>
> this
>
> > + * Copyright (c) 2015 Zolt�n B�sz�rm�nyi <zboszor@pr.hu>
>
> this
>
> > +MODULE_AUTHOR("Zolt�n B�sz�rm�nyi <zboszor@pr.hu>");
>
> and this were in Latin-2 after you sent the patch back to me, my patch
> was UTF-8 in the beginning.
Hmm, not sure what happened...
>
> Can you run the code through "recode latin2..utf-8" before committing or
> should I resend to fix this?
No, I recoded it and I also added back SERIO_EGALAX definition to
serio.h that you somehow dropped from the patch. The driver is queued
for 4.5 now.
Thank you.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Add eGalaxTouch serial touchscreen driver v3
2015-12-16 19:28 ` Dmitry Torokhov
@ 2015-12-16 19:31 ` Boszormenyi Zoltan
0 siblings, 0 replies; 4+ messages in thread
From: Boszormenyi Zoltan @ 2015-12-16 19:31 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Böszörményi Zoltán
2015-12-16 20:28 keltezéssel, Dmitry Torokhov írta:
> On Wed, Dec 16, 2015 at 01:54:01PM +0100, Boszormenyi Zoltan wrote:
>> 2015-12-16 13:43 keltezéssel, Zoltán Böszörményi írta:
>>> Signed-off-by: B�sz�rm�nyi Zolt�n <zboszor@pr.hu>
>> this
>>
>>> + * Copyright (c) 2015 Zolt�n B�sz�rm�nyi <zboszor@pr.hu>
>> this
>>
>>> +MODULE_AUTHOR("Zolt�n B�sz�rm�nyi <zboszor@pr.hu>");
>> and this were in Latin-2 after you sent the patch back to me, my patch
>> was UTF-8 in the beginning.
> Hmm, not sure what happened...
>
>> Can you run the code through "recode latin2..utf-8" before committing or
>> should I resend to fix this?
> No, I recoded it and I also added back SERIO_EGALAX definition to
> serio.h that you somehow dropped from the patch.
and the Makefile change I suppose. I think I was in a hurry and
only did "git add egalax_ts_serial.c" and "git commit" instead of "git commit -a".
Sorry for that.
> The driver is queued for 4.5 now.
Thank you very much,
Zoltán Böszörményi
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-16 19:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-16 12:43 [PATCH] Add eGalaxTouch serial touchscreen driver v3 Zoltán Böszörményi
2015-12-16 12:54 ` Boszormenyi Zoltan
2015-12-16 19:28 ` Dmitry Torokhov
2015-12-16 19:31 ` Boszormenyi Zoltan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.