* [PATCH] inputattach: add support for tsc40
@ 2011-09-27 7:40 Christian Gmeiner
2011-09-30 4:55 ` Stephen Kitt
0 siblings, 1 reply; 2+ messages in thread
From: Christian Gmeiner @ 2011-09-27 7:40 UTC (permalink / raw)
To: linux-input, Sebastian Andrzej Siewior, Stephen Kitt
This patch adds support for TSC-40 driver to inputattach.
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
---
diff -Nur linuxconsoletools-1.4.2/docs/inputattach.1
linuxconsoletools-1.4.2_patched//docs/inputattach.1
--- linuxconsoletools-1.4.2/docs/inputattach.1 2011-08-09
07:35:02.000000000 +0200
+++ linuxconsoletools-1.4.2_patched//docs/inputattach.1 2011-09-27
11:39:28.935479294 +0200
@@ -108,6 +108,9 @@
.BR \-taos ", " \-\-taos\-evm
TAOS evaluation module.
.TP
+.BR \-tsc ", " \-\-tsc
+TSC-10/25/40 touch screen.
+.TP
.BR \-t213 ", " \-\-touchit213
Sahara Touch-iT213 Tablet PC.
.TP
diff -Nur linuxconsoletools-1.4.2/utils/inputattach.c
linuxconsoletools-1.4.2_patched//utils/inputattach.c
--- linuxconsoletools-1.4.2/utils/inputattach.c 2011-08-09
07:43:10.000000000 +0200
+++ linuxconsoletools-1.4.2_patched//utils/inputattach.c 2011-09-27
11:38:01.071479288 +0200
@@ -354,6 +354,82 @@
return 0;
}
+static int tsc40_init(int fd, unsigned long *id, unsigned long *extra)
+{
+ unsigned char cmd[2], data;
+ unsigned int eeprom;
+
+ /* Datasheet can be found here:
+ * http://www.distec.de/PDF/Drivers/DMC/TSC40_Protocol_Description.pdf
+ */
+
+#define TSC40_CMD_DATA1 0x01
+#define TSC40_CMD_RATE 0x05
+#define TSC40_CMD_ID 0x15
+#define TSC40_CMD_RESET 0x55
+
+#define TSC40_RATE_150 0x45
+#define TSC40_NACK 0x15
+
+ /* trigger a software reset to get into a well known state */
+ cmd[0] = TSC40_CMD_RESET;
+ if (write(fd, cmd, 1) != 1)
+ return -1;
+
+ /* wait to settle down */
+ usleep(15 * 1000); /* 15 ms */
+
+ /* read panel ID to check if an EEPROM is used */
+ cmd[0] = TSC40_CMD_ID;
+ if (write(fd, cmd, 1) != 1)
+ return -1;
+
+ if (readchar(fd, &data, 100))
+ return -1;
+
+ /* if bit7 is not set --> EEPROM is used */
+ eeprom = !((data & 0x80) >> 7);
+
+ /* ignore 2nd byte of ID cmd */
+ if (readchar(fd, &data, 100))
+ return -1;
+
+ /* set coordinate oupt rate setting */
+ cmd[0] = TSC40_CMD_RATE;
+ cmd[1] = TSC40_RATE_150;
+ if (write(fd, cmd, 2) != 2)
+ return -1;
+
+ /* read response */
+ if (readchar(fd, &data, 100))
+ return -1;
+
+ if ((data == TSC40_NACK) && (eeprom == 1)) {
+ /* get detailed failure information */
+ if (readchar(fd, &data, 100))
+ return -1;
+
+ switch (data) {
+ case 0x02: /* EEPROM data abnormal */
+ case 0x04: /* EEPROM write error */
+ case 0x08: /* Touch screen not connected */
+ return -1;
+ break;
+
+ default:
+ /* 0x01: EEPROM data empty */
+ break;
+ }
+ }
+
+ /* start sending coordinate informations */
+ cmd[0] = TSC40_CMD_DATA1;
+ if (write(fd, cmd, 1) != 1)
+ return -1;
+
+ return 0;
+}
+
static int t213_init(int fd, unsigned long *id, unsigned long *extra)
{
char cmd[]={0x0a,1,'A'};
@@ -556,6 +632,9 @@
{ "--mtouch", "-mtouch", "MicroTouch (3M) touchscreen",
B9600, CS8 | CRTSCTS,
SERIO_MICROTOUCH, 0x00, 0x00, 0, NULL },
+{ "--tsc", "-tsc", "TSC-10/25/40 serial touchscreen",
+ B9600, CS8,
+ SERIO_TSC40, 0x00, 0x00, 0, tsc40_init },
{ "--touchit213", "-t213", "Sahara Touch-iT213 Tablet PC",
B9600, CS8,
SERIO_TOUCHIT213, 0x00, 0x00, 0, t213_init },
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] inputattach: add support for tsc40
2011-09-27 7:40 [PATCH] inputattach: add support for tsc40 Christian Gmeiner
@ 2011-09-30 4:55 ` Stephen Kitt
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Kitt @ 2011-09-30 4:55 UTC (permalink / raw)
To: Christian Gmeiner; +Cc: linux-input, Sebastian Andrzej Siewior
Hi Christian,
I'm sorry I didn't get round to reviewing your earlier patch - the patch
below is fine by me and will be in the next release of inputattach.
Regards,
Stephen
On Tue, 27 Sep 2011 09:40:13 +0200, Christian Gmeiner
<christian.gmeiner@gmail.com> wrote:
> This patch adds support for TSC-40 driver to inputattach.
>
> Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
> ---
>
> diff -Nur linuxconsoletools-1.4.2/docs/inputattach.1
> linuxconsoletools-1.4.2_patched//docs/inputattach.1
> --- linuxconsoletools-1.4.2/docs/inputattach.1 2011-08-09
> 07:35:02.000000000 +0200
> +++ linuxconsoletools-1.4.2_patched//docs/inputattach.1 2011-09-27
> 11:39:28.935479294 +0200
> @@ -108,6 +108,9 @@
> .BR \-taos ", " \-\-taos\-evm
> TAOS evaluation module.
> .TP
> +.BR \-tsc ", " \-\-tsc
> +TSC-10/25/40 touch screen.
> +.TP
> .BR \-t213 ", " \-\-touchit213
> Sahara Touch-iT213 Tablet PC.
> .TP
> diff -Nur linuxconsoletools-1.4.2/utils/inputattach.c
> linuxconsoletools-1.4.2_patched//utils/inputattach.c
> --- linuxconsoletools-1.4.2/utils/inputattach.c 2011-08-09
> 07:43:10.000000000 +0200
> +++ linuxconsoletools-1.4.2_patched//utils/inputattach.c 2011-09-27
> 11:38:01.071479288 +0200
> @@ -354,6 +354,82 @@
> return 0;
> }
>
> +static int tsc40_init(int fd, unsigned long *id, unsigned long *extra)
> +{
> + unsigned char cmd[2], data;
> + unsigned int eeprom;
> +
> + /* Datasheet can be found here:
> + *
> http://www.distec.de/PDF/Drivers/DMC/TSC40_Protocol_Description.pdf
> + */
> +
> +#define TSC40_CMD_DATA1 0x01
> +#define TSC40_CMD_RATE 0x05
> +#define TSC40_CMD_ID 0x15
> +#define TSC40_CMD_RESET 0x55
> +
> +#define TSC40_RATE_150 0x45
> +#define TSC40_NACK 0x15
> +
> + /* trigger a software reset to get into a well known state */
> + cmd[0] = TSC40_CMD_RESET;
> + if (write(fd, cmd, 1) != 1)
> + return -1;
> +
> + /* wait to settle down */
> + usleep(15 * 1000); /* 15 ms */
> +
> + /* read panel ID to check if an EEPROM is used */
> + cmd[0] = TSC40_CMD_ID;
> + if (write(fd, cmd, 1) != 1)
> + return -1;
> +
> + if (readchar(fd, &data, 100))
> + return -1;
> +
> + /* if bit7 is not set --> EEPROM is used */
> + eeprom = !((data & 0x80) >> 7);
> +
> + /* ignore 2nd byte of ID cmd */
> + if (readchar(fd, &data, 100))
> + return -1;
> +
> + /* set coordinate oupt rate setting */
> + cmd[0] = TSC40_CMD_RATE;
> + cmd[1] = TSC40_RATE_150;
> + if (write(fd, cmd, 2) != 2)
> + return -1;
> +
> + /* read response */
> + if (readchar(fd, &data, 100))
> + return -1;
> +
> + if ((data == TSC40_NACK) && (eeprom == 1)) {
> + /* get detailed failure information */
> + if (readchar(fd, &data, 100))
> + return -1;
> +
> + switch (data) {
> + case 0x02: /* EEPROM data abnormal */
> + case 0x04: /* EEPROM write error */
> + case 0x08: /* Touch screen not connected */
> + return -1;
> + break;
> +
> + default:
> + /* 0x01: EEPROM data empty */
> + break;
> + }
> + }
> +
> + /* start sending coordinate informations */
> + cmd[0] = TSC40_CMD_DATA1;
> + if (write(fd, cmd, 1) != 1)
> + return -1;
> +
> + return 0;
> +}
> +
> static int t213_init(int fd, unsigned long *id, unsigned long *extra)
> {
> char cmd[]={0x0a,1,'A'};
> @@ -556,6 +632,9 @@
> { "--mtouch", "-mtouch", "MicroTouch (3M)
> touchscreen", B9600, CS8 | CRTSCTS,
> SERIO_MICROTOUCH, 0x00, 0x00, 0,
> NULL }, +{ "--tsc", "-tsc", "TSC-10/25/40
> serial touchscreen",
> + B9600, CS8,
> + SERIO_TSC40, 0x00, 0x00, 0,
> tsc40_init }, { "--touchit213", "-t213", "Sahara Touch-iT213
> Tablet PC", B9600, CS8,
> SERIO_TOUCHIT213, 0x00, 0x00, 0,
> t213_init },
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-30 4:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 7:40 [PATCH] inputattach: add support for tsc40 Christian Gmeiner
2011-09-30 4:55 ` Stephen Kitt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).