aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse
diff options
context:
space:
mode:
authorStefan Lucke <stefan@lucke.in-berlin.de>2007-02-18 01:49:10 -0500
committerDmitry Torokhov <dtor@insightbb.com>2007-02-18 01:49:10 -0500
commit24bf10ab2d72863a14187905fd992ca8119c809e (patch)
tree2726d9dfe11618a4a77eacae945e6b92c1a5f405 /drivers/input/mouse
parent62b529a7b9c11880a8820494a25db0e2ecdf3bed (diff)
Input: psmouse - add support for eGalax PS/2 touchscreen controller
Based on the touchkit USB and lifebook PS/2 touchscreen driver. The egalax touchsreen controller (PS/2 or USB version) is used in this 7" device: http://www.cartft.com/catalog/il/449 Signed-off-by: Michal Piotrowski <michal.k.k.piotrowski@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r--drivers/input/mouse/Makefile3
-rw-r--r--drivers/input/mouse/psmouse-base.c25
-rw-r--r--drivers/input/mouse/psmouse.h1
-rw-r--r--drivers/input/mouse/touchkit_ps2.c100
-rw-r--r--drivers/input/mouse/touchkit_ps2.h17
5 files changed, 139 insertions, 7 deletions
diff --git a/drivers/input/mouse/Makefile b/drivers/input/mouse/Makefile
index 21a1de61a79b..6751179baeb8 100644
--- a/drivers/input/mouse/Makefile
+++ b/drivers/input/mouse/Makefile
@@ -14,4 +14,5 @@ obj-$(CONFIG_MOUSE_SERIAL) += sermouse.o
14obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o 14obj-$(CONFIG_MOUSE_HIL) += hil_ptr.o
15obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o 15obj-$(CONFIG_MOUSE_VSXXXAA) += vsxxxaa.o
16 16
17psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o trackpoint.o 17psmouse-objs := psmouse-base.o alps.o logips2pp.o synaptics.o lifebook.o \
18 trackpoint.o touchkit_ps2.o
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 0fe5869d7d4c..eb63855f7cc1 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -28,6 +28,7 @@
28#include "alps.h" 28#include "alps.h"
29#include "lifebook.h" 29#include "lifebook.h"
30#include "trackpoint.h" 30#include "trackpoint.h"
31#include "touchkit_ps2.h"
31 32
32#define DRIVER_DESC "PS/2 mouse driver" 33#define DRIVER_DESC "PS/2 mouse driver"
33 34
@@ -605,14 +606,20 @@ static int psmouse_extensions(struct psmouse *psmouse,
605 } 606 }
606 } 607 }
607 608
608 if (max_proto > PSMOUSE_IMEX && genius_detect(psmouse, set_properties) == 0) 609 if (max_proto > PSMOUSE_IMEX) {
609 return PSMOUSE_GENPS; 610
611 if (genius_detect(psmouse, set_properties) == 0)
612 return PSMOUSE_GENPS;
613
614 if (ps2pp_init(psmouse, set_properties) == 0)
615 return PSMOUSE_PS2PP;
610 616
611 if (max_proto > PSMOUSE_IMEX && ps2pp_init(psmouse, set_properties) == 0) 617 if (trackpoint_detect(psmouse, set_properties) == 0)
612 return PSMOUSE_PS2PP; 618 return PSMOUSE_TRACKPOINT;
613 619
614 if (max_proto > PSMOUSE_IMEX && trackpoint_detect(psmouse, set_properties) == 0) 620 if (touchkit_ps2_detect(psmouse, set_properties) == 0)
615 return PSMOUSE_TRACKPOINT; 621 return PSMOUSE_TOUCHKIT_PS2;
622 }
616 623
617/* 624/*
618 * Reset to defaults in case the device got confused by extended 625 * Reset to defaults in case the device got confused by extended
@@ -713,6 +720,12 @@ static const struct psmouse_protocol psmouse_protocols[] = {
713 .detect = trackpoint_detect, 720 .detect = trackpoint_detect,
714 }, 721 },
715 { 722 {
723 .type = PSMOUSE_TOUCHKIT_PS2,
724 .name = "touchkitPS/2",
725 .alias = "touchkit",
726 .detect = touchkit_ps2_detect,
727 },
728 {
716 .type = PSMOUSE_AUTO, 729 .type = PSMOUSE_AUTO,
717 .name = "auto", 730 .name = "auto",
718 .alias = "any", 731 .alias = "any",
diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
index cf1de95b6f27..3964e8acbc54 100644
--- a/drivers/input/mouse/psmouse.h
+++ b/drivers/input/mouse/psmouse.h
@@ -87,6 +87,7 @@ enum psmouse_type {
87 PSMOUSE_ALPS, 87 PSMOUSE_ALPS,
88 PSMOUSE_LIFEBOOK, 88 PSMOUSE_LIFEBOOK,
89 PSMOUSE_TRACKPOINT, 89 PSMOUSE_TRACKPOINT,
90 PSMOUSE_TOUCHKIT_PS2,
90 PSMOUSE_AUTO /* This one should always be last */ 91 PSMOUSE_AUTO /* This one should always be last */
91}; 92};
92 93
diff --git a/drivers/input/mouse/touchkit_ps2.c b/drivers/input/mouse/touchkit_ps2.c
new file mode 100644
index 000000000000..7b977fd23571
--- /dev/null
+++ b/drivers/input/mouse/touchkit_ps2.c
@@ -0,0 +1,100 @@
1/* ----------------------------------------------------------------------------
2 * touchkit_ps2.c -- Driver for eGalax TouchKit PS/2 Touchscreens
3 *
4 * Copyright (C) 2005 by Stefan Lucke
5 * Copyright (C) 2004 by Daniel Ritz
6 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 * Based upon touchkitusb.c
23 *
24 * Vendor documentation is available in support section of:
25 * http://www.egalax.com.tw/
26 */
27
28#include <linux/kernel.h>
29#include <linux/slab.h>
30
31#include <linux/input.h>
32#include <linux/serio.h>
33#include <linux/libps2.h>
34
35#include "psmouse.h"
36#include "touchkit_ps2.h"
37
38#define TOUCHKIT_MAX_XC 0x07ff
39#define TOUCHKIT_MAX_YC 0x07ff
40
41#define TOUCHKIT_CMD 0x0a
42#define TOUCHKIT_CMD_LENGTH 1
43
44#define TOUCHKIT_CMD_ACTIVE 'A'
45#define TOUCHKIT_CMD_FIRMWARE_VERSION 'D'
46#define TOUCHKIT_CMD_CONTROLLER_TYPE 'E'
47
48#define TOUCHKIT_SEND_PARMS(s, r, c) ((s) << 12 | (r) << 8 | (c))
49
50#define TOUCHKIT_GET_TOUCHED(packet) (((packet)[0]) & 0x01)
51#define TOUCHKIT_GET_X(packet) (((packet)[1] << 7) | (packet)[2])
52#define TOUCHKIT_GET_Y(packet) (((packet)[3] << 7) | (packet)[4])
53
54static psmouse_ret_t touchkit_ps2_process_byte(struct psmouse *psmouse)
55{
56 unsigned char *packet = psmouse->packet;
57 struct input_dev *dev = psmouse->dev;
58
59 if (psmouse->pktcnt != 5)
60 return PSMOUSE_GOOD_DATA;
61
62 input_report_abs(dev, ABS_X, TOUCHKIT_GET_X(packet));
63 input_report_abs(dev, ABS_Y, TOUCHKIT_GET_Y(packet));
64 input_report_key(dev, BTN_TOUCH, TOUCHKIT_GET_TOUCHED(packet));
65 input_sync(dev);
66
67 return PSMOUSE_FULL_PACKET;
68}
69
70int touchkit_ps2_detect(struct psmouse *psmouse, int set_properties)
71{
72 struct input_dev *dev = psmouse->dev;
73 unsigned char param[3];
74 int command;
75
76 param[0] = TOUCHKIT_CMD_LENGTH;
77 param[1] = TOUCHKIT_CMD_ACTIVE;
78 command = TOUCHKIT_SEND_PARMS(2, 3, TOUCHKIT_CMD);
79
80 if (ps2_command(&psmouse->ps2dev, param, command))
81 return -ENODEV;
82
83 if (param[0] != TOUCHKIT_CMD || param[1] != 0x01 ||
84 param[2] != TOUCHKIT_CMD_ACTIVE)
85 return -ENODEV;
86
87 if (set_properties) {
88 dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
89 set_bit(BTN_TOUCH, dev->keybit);
90 input_set_abs_params(dev, ABS_X, 0, TOUCHKIT_MAX_XC, 0, 0);
91 input_set_abs_params(dev, ABS_Y, 0, TOUCHKIT_MAX_YC, 0, 0);
92
93 psmouse->vendor = "eGalax";
94 psmouse->name = "Touchscreen";
95 psmouse->protocol_handler = touchkit_ps2_process_byte;
96 psmouse->pktsize = 5;
97 }
98
99 return 0;
100}
diff --git a/drivers/input/mouse/touchkit_ps2.h b/drivers/input/mouse/touchkit_ps2.h
new file mode 100644
index 000000000000..3f03fbcaf8f0
--- /dev/null
+++ b/drivers/input/mouse/touchkit_ps2.h
@@ -0,0 +1,17 @@
1/* ----------------------------------------------------------------------------
2 * touchkit_ps2.h -- Driver for eGalax TouchKit PS/2 Touchscreens
3 *
4 * Copyright (C) 2005 by Stefan Lucke
5 * Copyright (c) 2005 Vojtech Pavlik
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 */
11
12#ifndef _TOUCHKIT_PS2_H
13#define _TOUCHKIT_PS2_H
14
15int touchkit_ps2_detect(struct psmouse *psmouse, int set_properties);
16
17#endif