linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add support for the egalax serial touchscreen driver
@ 2015-12-15 11:24 Böszörményi Zoltán
  2015-12-15 19:06 ` Stephen Kitt
  0 siblings, 1 reply; 4+ messages in thread
From: Böszörményi Zoltán @ 2015-12-15 11:24 UTC (permalink / raw)
  To: Vojtech Pavlik
  Cc: linux-input, linuxconsole-dev,
	Böszörményi Zoltán

From: Böszörményi Zoltán <zboszor@pr.hu>

Add inputattach support for the egalax serial touchscreen driver.

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>

---
 utils/inputattach.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/utils/inputattach.c b/utils/inputattach.c
index bdaafa3..720a0b5 100644
--- a/utils/inputattach.c
+++ b/utils/inputattach.c
@@ -615,20 +615,82 @@ static int wacom_iv_init(int fd, unsigned long *id, unsigned long *extra)
 	if (write(fd, WACOM_IV_RESET, WACOM_IV_RESET_LEN) != WACOM_IV_RESET_LEN)
 		return -1;
 	usleep(75 * 1000);
 	if (write(fd, WACOM_IV_STOP, WACOM_IV_STOP_LEN) != WACOM_IV_STOP_LEN)
 		return -1;
 	usleep(30 * 1000);
 
 	return 0;
 }
 
+static int check_egalax_response(int fd, unsigned char *command, int sz, unsigned char *response) {
+	int pos = 0;
+	int error = 0;
+	int rest_length;
+
+	if (write(fd, command, sz) != sz)
+		return -1;
+
+	for (pos = 0; pos < 3; pos++) {
+		if (readchar(fd, &response[pos], 100)) {
+			error = 1;
+			break;
+		}
+	}
+
+	if (error)
+		return -1;
+
+	rest_length = response[1] - 1;
+
+	for (; rest_length; rest_length--, pos++) {
+		if (readchar(fd, &response[pos], 100)) {
+			error = 1;
+			break;
+		}
+	}
+
+	if (error)
+		return -1;
+
+	if (response[1] >= command[1] &&
+		response[0] == command[0] &&
+		response[2] == command[2])
+		return 0;
+
+	return -1;
+}
+
+static int egalax_init(int fd, unsigned long *id, unsigned long *extra) {
+	unsigned char packet_alive_query[3] = { 0x0a, 0x01, 'A' };
+	unsigned char packet_fw_ver[3] = { 0x0a, 0x01, 'D' };
+	unsigned char packet_ctrl_type[3] = { 0x0a, 0x01, 'E' };
+	unsigned char response[128];
+
+	if (check_egalax_response(fd, packet_alive_query, sizeof(packet_alive_query), response))
+		return -1;
+
+	if (check_egalax_response(fd, packet_fw_ver, sizeof(packet_fw_ver), response))
+		return -1;
+
+	response[(unsigned char)response[1] + 2] = '\0';
+	printf("EETI eGalaxTouch firmware: %s\n", &response[3]);
+
+	if (check_egalax_response(fd, packet_ctrl_type, sizeof(packet_ctrl_type), response))
+		return -1;
+
+	response[(unsigned char)response[1] + 2] = '\0';
+	printf("EETI eGalaxTouch controller type: %s\n", &response[3]);
+
+	return 0;
+}
+
 struct input_types {
 	const char *name;
 	const char *name2;
 	const char *desc;
 	int speed;
 	int flags;
 	unsigned long type;
 	unsigned long id;
 	unsigned long extra;
 	int flush;
@@ -700,32 +762,42 @@ static struct input_types input_types[] = {
 	SERIO_STOWAWAY,		0x00,	0x00,	1,	NULL },
 { "--ps2serkbd",	"-ps2ser",	"PS/2 via serial keyboard",
 	B1200, CS8,
 	SERIO_PS2SER,		0x00,	0x00,	1,	NULL },
 { "--twiddler",		"-twid",	"Handykey Twiddler chording keyboard",
 	B2400, CS8,
 	SERIO_TWIDKBD,		0x00,	0x00,	0,	twiddler_init },
 { "--twiddler-joy",	"-twidjoy",	"Handykey Twiddler used as a joystick",
 	B2400, CS8,
 	SERIO_TWIDJOY,		0x00,	0x00,	0,	twiddler_init },
+#ifdef SERIO_EGALAX
+{ "--eetiegalax",	"-eeti",	"EETI eGalaxTouch",
+	B9600, CS8,
+	SERIO_EGALAX,		0x00,	0x00,	0,	egalax_init },
+#endif
 { "--elotouch",		"-elo",		"ELO touchscreen, 10-byte mode",
 	B9600, CS8,
 	SERIO_ELO,		0x00,	0x00,	0,	NULL },
 { "--elo4002",		"-elo6b",	"ELO touchscreen, 6-byte mode",
 	B9600, CS8 | CRTSCTS,
 	SERIO_ELO,		0x01,	0x00,	0,	NULL },
 { "--elo271-140",	"-elo4b",	"ELO touchscreen, 4-byte mode",
 	B9600, CS8 | CRTSCTS,
 	SERIO_ELO,		0x02,	0x00,	0,	NULL },
 { "--elo261-280",	"-elo3b",	"ELO Touchscreen, 3-byte mode",
 	B9600, CS8 | CRTSCTS,
 	SERIO_ELO,		0x03,	0x00,	0,	NULL },
+#ifdef SERIO_HAMPSHIRE
+{ "--hampshire",   "-ham",         "Hampshire touchscreen",
+	B9600, CS8,
+	SERIO_HAMPSHIRE,	0x00,   0x00,   0,  NULL },
+#endif
 { "--mtouch",		"-mtouch",	"MicroTouch (3M) touchscreen",
 	B9600, CS8 | CRTSCTS,
 	SERIO_MICROTOUCH,	0x00,	0x00,	0,	NULL },
 #ifdef SERIO_TSC40
 { "--tsc",		"-tsc",		"TSC-10/25/40 serial touchscreen",
 	B9600, CS8,
 	SERIO_TSC40,		0x00,	0x00,	0,	tsc40_init },
 #endif
 { "--touchit213",	"-t213",	"Sahara Touch-iT213 Tablet PC",
 	B9600, CS8,
-- 
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
* [PATCH] Add support for the egalax serial touchscreen driver
@ 2015-12-15  9:40 Böszörményi Zoltán
  0 siblings, 0 replies; 4+ messages in thread
From: Böszörményi Zoltán @ 2015-12-15  9:40 UTC (permalink / raw)
  To: Vojtech Pavlik
  Cc: Böszörményi Zoltán, linuxconsole-dev,
	linux-input

From: Böszörményi Zoltán <zboszor@pr.hu>

Add inputattach support for the egalax serial touchscreen driver.

Signed-off-by: Böszörményi Zoltán <zboszor@pr.hu>

---
 utils/inputattach.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/utils/inputattach.c b/utils/inputattach.c
index bdaafa3..720a0b5 100644
--- a/utils/inputattach.c
+++ b/utils/inputattach.c
@@ -615,20 +615,82 @@ static int wacom_iv_init(int fd, unsigned long *id, unsigned long *extra)
 	if (write(fd, WACOM_IV_RESET, WACOM_IV_RESET_LEN) != WACOM_IV_RESET_LEN)
 		return -1;
 	usleep(75 * 1000);
 	if (write(fd, WACOM_IV_STOP, WACOM_IV_STOP_LEN) != WACOM_IV_STOP_LEN)
 		return -1;
 	usleep(30 * 1000);
 
 	return 0;
 }
 
+static int check_egalax_response(int fd, unsigned char *command, int sz, unsigned char *response) {
+	int pos = 0;
+	int error = 0;
+	int rest_length;
+
+	if (write(fd, command, sz) != sz)
+		return -1;
+
+	for (pos = 0; pos < 3; pos++) {
+		if (readchar(fd, &response[pos], 100)) {
+			error = 1;
+			break;
+		}
+	}
+
+	if (error)
+		return -1;
+
+	rest_length = response[1] - 1;
+
+	for (; rest_length; rest_length--, pos++) {
+		if (readchar(fd, &response[pos], 100)) {
+			error = 1;
+			break;
+		}
+	}
+
+	if (error)
+		return -1;
+
+	if (response[1] >= command[1] &&
+		response[0] == command[0] &&
+		response[2] == command[2])
+		return 0;
+
+	return -1;
+}
+
+static int egalax_init(int fd, unsigned long *id, unsigned long *extra) {
+	unsigned char packet_alive_query[3] = { 0x0a, 0x01, 'A' };
+	unsigned char packet_fw_ver[3] = { 0x0a, 0x01, 'D' };
+	unsigned char packet_ctrl_type[3] = { 0x0a, 0x01, 'E' };
+	unsigned char response[128];
+
+	if (check_egalax_response(fd, packet_alive_query, sizeof(packet_alive_query), response))
+		return -1;
+
+	if (check_egalax_response(fd, packet_fw_ver, sizeof(packet_fw_ver), response))
+		return -1;
+
+	response[(unsigned char)response[1] + 2] = '\0';
+	printf("EETI eGalaxTouch firmware: %s\n", &response[3]);
+
+	if (check_egalax_response(fd, packet_ctrl_type, sizeof(packet_ctrl_type), response))
+		return -1;
+
+	response[(unsigned char)response[1] + 2] = '\0';
+	printf("EETI eGalaxTouch controller type: %s\n", &response[3]);
+
+	return 0;
+}
+
 struct input_types {
 	const char *name;
 	const char *name2;
 	const char *desc;
 	int speed;
 	int flags;
 	unsigned long type;
 	unsigned long id;
 	unsigned long extra;
 	int flush;
@@ -700,32 +762,42 @@ static struct input_types input_types[] = {
 	SERIO_STOWAWAY,		0x00,	0x00,	1,	NULL },
 { "--ps2serkbd",	"-ps2ser",	"PS/2 via serial keyboard",
 	B1200, CS8,
 	SERIO_PS2SER,		0x00,	0x00,	1,	NULL },
 { "--twiddler",		"-twid",	"Handykey Twiddler chording keyboard",
 	B2400, CS8,
 	SERIO_TWIDKBD,		0x00,	0x00,	0,	twiddler_init },
 { "--twiddler-joy",	"-twidjoy",	"Handykey Twiddler used as a joystick",
 	B2400, CS8,
 	SERIO_TWIDJOY,		0x00,	0x00,	0,	twiddler_init },
+#ifdef SERIO_EGALAX
+{ "--eetiegalax",	"-eeti",	"EETI eGalaxTouch",
+	B9600, CS8,
+	SERIO_EGALAX,		0x00,	0x00,	0,	egalax_init },
+#endif
 { "--elotouch",		"-elo",		"ELO touchscreen, 10-byte mode",
 	B9600, CS8,
 	SERIO_ELO,		0x00,	0x00,	0,	NULL },
 { "--elo4002",		"-elo6b",	"ELO touchscreen, 6-byte mode",
 	B9600, CS8 | CRTSCTS,
 	SERIO_ELO,		0x01,	0x00,	0,	NULL },
 { "--elo271-140",	"-elo4b",	"ELO touchscreen, 4-byte mode",
 	B9600, CS8 | CRTSCTS,
 	SERIO_ELO,		0x02,	0x00,	0,	NULL },
 { "--elo261-280",	"-elo3b",	"ELO Touchscreen, 3-byte mode",
 	B9600, CS8 | CRTSCTS,
 	SERIO_ELO,		0x03,	0x00,	0,	NULL },
+#ifdef SERIO_HAMPSHIRE
+{ "--hampshire",   "-ham",         "Hampshire touchscreen",
+	B9600, CS8,
+	SERIO_HAMPSHIRE,	0x00,   0x00,   0,  NULL },
+#endif
 { "--mtouch",		"-mtouch",	"MicroTouch (3M) touchscreen",
 	B9600, CS8 | CRTSCTS,
 	SERIO_MICROTOUCH,	0x00,	0x00,	0,	NULL },
 #ifdef SERIO_TSC40
 { "--tsc",		"-tsc",		"TSC-10/25/40 serial touchscreen",
 	B9600, CS8,
 	SERIO_TSC40,		0x00,	0x00,	0,	tsc40_init },
 #endif
 { "--touchit213",	"-t213",	"Sahara Touch-iT213 Tablet PC",
 	B9600, CS8,
-- 
2.5.0


------------------------------------------------------------------------------
_______________________________________________
Linuxconsole-dev mailing list
Linuxconsole-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxconsole-dev

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-15 19:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-15 11:24 [PATCH] Add support for the egalax serial touchscreen driver Böszörményi Zoltán
2015-12-15 19:06 ` Stephen Kitt
2015-12-15 19:18   ` Boszormenyi Zoltan
  -- strict thread matches above, loose matches on Subject: below --
2015-12-15  9:40 Böszörményi Zoltán

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).