Linux Audio

Check our new training course

Loading...
v3.1
  1/*
  2 * Elantech Touchpad driver (v6)
  3 *
  4 * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net>
  5 *
  6 * This program is free software; you can redistribute it and/or modify it
  7 * under the terms of the GNU General Public License version 2 as published
  8 * by the Free Software Foundation.
  9 *
 10 * Trademarks are the property of their respective owners.
 11 */
 12
 13#ifndef _ELANTECH_H
 14#define _ELANTECH_H
 15
 16/*
 17 * Command values for Synaptics style queries
 18 */
 
 19#define ETP_FW_VERSION_QUERY		0x01
 20#define ETP_CAPABILITIES_QUERY		0x02
 
 
 21
 22/*
 23 * Command values for register reading or writing
 24 */
 25#define ETP_REGISTER_READ		0x10
 26#define ETP_REGISTER_WRITE		0x11
 
 27
 28/*
 29 * Hardware version 2 custom PS/2 command value
 30 */
 31#define ETP_PS2_CUSTOM_COMMAND		0xf8
 32
 33/*
 34 * Times to retry a ps2_command and millisecond delay between tries
 35 */
 36#define ETP_PS2_COMMAND_TRIES		3
 37#define ETP_PS2_COMMAND_DELAY		500
 38
 39/*
 40 * Times to try to read back a register and millisecond delay between tries
 41 */
 42#define ETP_READ_BACK_TRIES		5
 43#define ETP_READ_BACK_DELAY		2000
 44
 45/*
 46 * Register bitmasks for hardware version 1
 47 */
 48#define ETP_R10_ABSOLUTE_MODE		0x04
 49#define ETP_R11_4_BYTE_MODE		0x02
 50
 51/*
 52 * Capability bitmasks
 53 */
 54#define ETP_CAP_HAS_ROCKER		0x04
 55
 56/*
 57 * One hard to find application note states that X axis range is 0 to 576
 58 * and Y axis range is 0 to 384 for harware version 1.
 59 * Edge fuzz might be necessary because of bezel around the touchpad
 60 */
 61#define ETP_EDGE_FUZZ_V1		32
 62
 63#define ETP_XMIN_V1			(  0 + ETP_EDGE_FUZZ_V1)
 64#define ETP_XMAX_V1			(576 - ETP_EDGE_FUZZ_V1)
 65#define ETP_YMIN_V1			(  0 + ETP_EDGE_FUZZ_V1)
 66#define ETP_YMAX_V1			(384 - ETP_EDGE_FUZZ_V1)
 67
 68/*
 69 * It seems the resolution for hardware version 2 doubled.
 70 * Hence the X and Y ranges are doubled too.
 71 * The bezel around the pad also appears to be smaller
 72 */
 73#define ETP_EDGE_FUZZ_V2		8
 74
 75#define ETP_XMIN_V2			(   0 + ETP_EDGE_FUZZ_V2)
 76#define ETP_XMAX_V2			(1152 - ETP_EDGE_FUZZ_V2)
 77#define ETP_YMIN_V2			(   0 + ETP_EDGE_FUZZ_V2)
 78#define ETP_YMAX_V2			( 768 - ETP_EDGE_FUZZ_V2)
 79
 80#define ETP_PMIN_V2			0
 81#define ETP_PMAX_V2			255
 82#define ETP_WMIN_V2			0
 83#define ETP_WMAX_V2			15
 84
 85/*
 86 * For two finger touches the coordinate of each finger gets reported
 87 * separately but with reduced resolution.
 88 */
 89#define ETP_2FT_FUZZ			4
 
 
 
 
 
 
 
 90
 91#define ETP_2FT_XMIN			(  0 + ETP_2FT_FUZZ)
 92#define ETP_2FT_XMAX			(288 - ETP_2FT_FUZZ)
 93#define ETP_2FT_YMIN			(  0 + ETP_2FT_FUZZ)
 94#define ETP_2FT_YMAX			(192 - ETP_2FT_FUZZ)
 
 
 
 
 
 
 
 
 
 
 
 
 
 95
 96struct elantech_data {
 
 
 
 97	unsigned char reg_10;
 98	unsigned char reg_11;
 99	unsigned char reg_20;
100	unsigned char reg_21;
101	unsigned char reg_22;
102	unsigned char reg_23;
103	unsigned char reg_24;
104	unsigned char reg_25;
105	unsigned char reg_26;
106	unsigned char debug;
107	unsigned char capabilities;
 
108	bool paritycheck;
109	bool jumpy_cursor;
110	bool reports_pressure;
 
 
111	unsigned char hw_version;
112	unsigned int fw_version;
113	unsigned int single_finger_reports;
 
 
 
114	unsigned char parity[256];
 
 
115};
116
117#ifdef CONFIG_MOUSE_PS2_ELANTECH
118int elantech_detect(struct psmouse *psmouse, bool set_properties);
119int elantech_init(struct psmouse *psmouse);
120#else
121static inline int elantech_detect(struct psmouse *psmouse, bool set_properties)
122{
123	return -ENOSYS;
124}
125static inline int elantech_init(struct psmouse *psmouse)
126{
127	return -ENOSYS;
128}
129#endif /* CONFIG_MOUSE_PS2_ELANTECH */
130
131#endif
v4.6
  1/*
  2 * Elantech Touchpad driver (v6)
  3 *
  4 * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net>
  5 *
  6 * This program is free software; you can redistribute it and/or modify it
  7 * under the terms of the GNU General Public License version 2 as published
  8 * by the Free Software Foundation.
  9 *
 10 * Trademarks are the property of their respective owners.
 11 */
 12
 13#ifndef _ELANTECH_H
 14#define _ELANTECH_H
 15
 16/*
 17 * Command values for Synaptics style queries
 18 */
 19#define ETP_FW_ID_QUERY			0x00
 20#define ETP_FW_VERSION_QUERY		0x01
 21#define ETP_CAPABILITIES_QUERY		0x02
 22#define ETP_SAMPLE_QUERY		0x03
 23#define ETP_RESOLUTION_QUERY		0x04
 24
 25/*
 26 * Command values for register reading or writing
 27 */
 28#define ETP_REGISTER_READ		0x10
 29#define ETP_REGISTER_WRITE		0x11
 30#define ETP_REGISTER_READWRITE		0x00
 31
 32/*
 33 * Hardware version 2 custom PS/2 command value
 34 */
 35#define ETP_PS2_CUSTOM_COMMAND		0xf8
 36
 37/*
 38 * Times to retry a ps2_command and millisecond delay between tries
 39 */
 40#define ETP_PS2_COMMAND_TRIES		3
 41#define ETP_PS2_COMMAND_DELAY		500
 42
 43/*
 44 * Times to try to read back a register and millisecond delay between tries
 45 */
 46#define ETP_READ_BACK_TRIES		5
 47#define ETP_READ_BACK_DELAY		2000
 48
 49/*
 50 * Register bitmasks for hardware version 1
 51 */
 52#define ETP_R10_ABSOLUTE_MODE		0x04
 53#define ETP_R11_4_BYTE_MODE		0x02
 54
 55/*
 56 * Capability bitmasks
 57 */
 58#define ETP_CAP_HAS_ROCKER		0x04
 59
 60/*
 61 * One hard to find application note states that X axis range is 0 to 576
 62 * and Y axis range is 0 to 384 for harware version 1.
 63 * Edge fuzz might be necessary because of bezel around the touchpad
 64 */
 65#define ETP_EDGE_FUZZ_V1		32
 66
 67#define ETP_XMIN_V1			(  0 + ETP_EDGE_FUZZ_V1)
 68#define ETP_XMAX_V1			(576 - ETP_EDGE_FUZZ_V1)
 69#define ETP_YMIN_V1			(  0 + ETP_EDGE_FUZZ_V1)
 70#define ETP_YMAX_V1			(384 - ETP_EDGE_FUZZ_V1)
 71
 72/*
 73 * The resolution for older v2 hardware doubled.
 74 * (newer v2's firmware provides command so we can query)
 75 */
 76#define ETP_XMIN_V2			0
 77#define ETP_XMAX_V2			1152
 78#define ETP_YMIN_V2			0
 79#define ETP_YMAX_V2			768
 
 
 
 80
 81#define ETP_PMIN_V2			0
 82#define ETP_PMAX_V2			255
 83#define ETP_WMIN_V2			0
 84#define ETP_WMAX_V2			15
 85
 86/*
 87 * v3 hardware has 2 kinds of packet types,
 88 * v4 hardware has 3.
 89 */
 90#define PACKET_UNKNOWN			0x01
 91#define PACKET_DEBOUNCE			0x02
 92#define PACKET_V3_HEAD			0x03
 93#define PACKET_V3_TAIL			0x04
 94#define PACKET_V4_HEAD			0x05
 95#define PACKET_V4_MOTION		0x06
 96#define PACKET_V4_STATUS		0x07
 97#define PACKET_TRACKPOINT		0x08
 98
 99/*
100 * track up to 5 fingers for v4 hardware
101 */
102#define ETP_MAX_FINGERS			5
103
104/*
105 * weight value for v4 hardware
106 */
107#define ETP_WEIGHT_VALUE		5
108
109/*
110 * The base position for one finger, v4 hardware
111 */
112struct finger_pos {
113	unsigned int x;
114	unsigned int y;
115};
116
117struct elantech_data {
118	struct input_dev *tp_dev;	/* Relative device for trackpoint */
119	char tp_phys[32];
120	unsigned char reg_07;
121	unsigned char reg_10;
122	unsigned char reg_11;
123	unsigned char reg_20;
124	unsigned char reg_21;
125	unsigned char reg_22;
126	unsigned char reg_23;
127	unsigned char reg_24;
128	unsigned char reg_25;
129	unsigned char reg_26;
130	unsigned char debug;
131	unsigned char capabilities[3];
132	unsigned char samples[3];
133	bool paritycheck;
134	bool jumpy_cursor;
135	bool reports_pressure;
136	bool crc_enabled;
137	bool set_hw_resolution;
138	unsigned char hw_version;
139	unsigned int fw_version;
140	unsigned int single_finger_reports;
141	unsigned int y_max;
142	unsigned int width;
143	struct finger_pos mt[ETP_MAX_FINGERS];
144	unsigned char parity[256];
145	int (*send_cmd)(struct psmouse *psmouse, unsigned char c, unsigned char *param);
146	void (*original_set_rate)(struct psmouse *psmouse, unsigned int rate);
147};
148
149#ifdef CONFIG_MOUSE_PS2_ELANTECH
150int elantech_detect(struct psmouse *psmouse, bool set_properties);
151int elantech_init(struct psmouse *psmouse);
152#else
153static inline int elantech_detect(struct psmouse *psmouse, bool set_properties)
154{
155	return -ENOSYS;
156}
157static inline int elantech_init(struct psmouse *psmouse)
158{
159	return -ENOSYS;
160}
161#endif /* CONFIG_MOUSE_PS2_ELANTECH */
162
163#endif