Re: [PATCH] Add support for the egalax serial touchscreen driver

2015-12-15 Thread Boszormenyi Zoltan
Hi,

2015-12-15 20:06 keltezéssel, Stephen Kitt írta:
> Hi,
>
> Thanks for submitting this. I have just a couple of questions...
>
> On Tue, 15 Dec 2015 12:24:32 +0100, Böszörményi Zoltán
>  wrote:
>> +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", [3]);
> inputattach is generally silent when everything goes well. I can see how this
> kind of info would be useful though; would you mind simply commenting the
> printf() lines out, and I'll add a verbose mode later on?

Sure, I'll put it under #ifdef 0.

>
>> +
>> +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", [3]);
> As above.
>
>> +#ifdef SERIO_HAMPSHIRE
>> +{ "--hampshire",   "-ham", "Hampshire touchscreen",
>> +B9600, CS8,
>> +SERIO_HAMPSHIRE,0x00,   0x00,   0,  NULL },
>> +#endif
> Is this intentional? If so, could you mention it in the commit message?

Yes, it is intentional. I noticed that the SERIO_HAMPSHIRE support
is also missing from inputattach. I don't currently know if the
Hampshire touchscreen needs an init function or not, so it is a
placeholder at the moment. Also, the SERIO_HAMPSHIRE value is
smaller than SERIO_PS2MULT which is unconditionally enabled,
so maybe it doesn't need the #ifdef SERIO_HAMPSHIRE ... #endif
cover at all. I will mention it in the commit message for the v2 patch,
which I will send tomorrow.

Best regards,
Zoltán Böszörményi

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Add support for the egalax serial touchscreen driver

2015-12-15 Thread Böszörményi Zoltán
From: Böszörményi Zoltán 

Add inputattach support for the egalax serial touchscreen driver.

Signed-off-by: Böszörményi Zoltán 

---
 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, [pos], 100)) {
+   error = 1;
+   break;
+   }
+   }
+
+   if (error)
+   return -1;
+
+   rest_length = response[1] - 1;
+
+   for (; rest_length; rest_length--, pos++) {
+   if (readchar(fd, [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", [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", [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 

Re: [PATCH] Add support for the egalax serial touchscreen driver

2015-12-15 Thread Stephen Kitt
Hi,

Thanks for submitting this. I have just a couple of questions...

On Tue, 15 Dec 2015 12:24:32 +0100, Böszörményi Zoltán
 wrote:
> +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", [3]);

inputattach is generally silent when everything goes well. I can see how this
kind of info would be useful though; would you mind simply commenting the
printf() lines out, and I'll add a verbose mode later on?

> +
> + 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", [3]);

As above.

> +#ifdef SERIO_HAMPSHIRE
> +{ "--hampshire",   "-ham", "Hampshire touchscreen",
> + B9600, CS8,
> + SERIO_HAMPSHIRE,0x00,   0x00,   0,  NULL },
> +#endif

Is this intentional? If so, could you mention it in the commit message?

Thanks,

Stephen
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html