2019-06-04 10:11:33 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
2008-10-16 22:10:19 -04:00
/*
2009-04-18 19:05:40 -07:00
* Elantech Touchpad driver ( v6 )
2008-10-16 22:10:19 -04:00
*
2009-04-18 19:05:40 -07:00
* Copyright ( C ) 2007 - 2009 Arjan Opmeer < arjan @ opmeer . net >
2008-10-16 22:10:19 -04:00
*
* Trademarks are the property of their respective owners .
*/
# ifndef _ELANTECH_H
# define _ELANTECH_H
/*
* Command values for Synaptics style queries
*/
2011-09-09 10:30:31 -07:00
# define ETP_FW_ID_QUERY 0x00
2008-10-16 22:10:19 -04:00
# define ETP_FW_VERSION_QUERY 0x01
# define ETP_CAPABILITIES_QUERY 0x02
2011-09-20 22:42:51 -07:00
# define ETP_SAMPLE_QUERY 0x03
2011-11-20 22:26:56 -08:00
# define ETP_RESOLUTION_QUERY 0x04
2020-12-10 23:49:16 -08:00
# define ETP_ICBODY_QUERY 0x05
2008-10-16 22:10:19 -04:00
/*
* Command values for register reading or writing
*/
# define ETP_REGISTER_READ 0x10
# define ETP_REGISTER_WRITE 0x11
2011-09-09 10:30:31 -07:00
# define ETP_REGISTER_READWRITE 0x00
2008-10-16 22:10:19 -04:00
/*
* Hardware version 2 custom PS / 2 command value
*/
# define ETP_PS2_CUSTOM_COMMAND 0xf8
/*
* Times to retry a ps2_command and millisecond delay between tries
*/
# define ETP_PS2_COMMAND_TRIES 3
# define ETP_PS2_COMMAND_DELAY 500
/*
* Times to try to read back a register and millisecond delay between tries
*/
# define ETP_READ_BACK_TRIES 5
# define ETP_READ_BACK_DELAY 2000
/*
* Register bitmasks for hardware version 1
*/
# define ETP_R10_ABSOLUTE_MODE 0x04
# define ETP_R11_4_BYTE_MODE 0x02
/*
* Capability bitmasks
*/
# define ETP_CAP_HAS_ROCKER 0x04
/*
* One hard to find application note states that X axis range is 0 to 576
* and Y axis range is 0 to 384 for harware version 1.
* Edge fuzz might be necessary because of bezel around the touchpad
*/
# define ETP_EDGE_FUZZ_V1 32
# define ETP_XMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1)
# define ETP_XMAX_V1 (576 - ETP_EDGE_FUZZ_V1)
# define ETP_YMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1)
# define ETP_YMAX_V1 (384 - ETP_EDGE_FUZZ_V1)
/*
2011-09-09 10:27:42 -07:00
* The resolution for older v2 hardware doubled .
* ( newer v2 ' s firmware provides command so we can query )
2008-10-16 22:10:19 -04:00
*/
2011-09-09 10:27:42 -07:00
# define ETP_XMIN_V2 0
# define ETP_XMAX_V2 1152
# define ETP_YMIN_V2 0
# define ETP_YMAX_V2 768
2008-10-16 22:10:19 -04:00
2011-05-16 22:45:54 -07:00
# define ETP_PMIN_V2 0
# define ETP_PMAX_V2 255
# define ETP_WMIN_V2 0
# define ETP_WMAX_V2 15
2011-09-09 10:30:31 -07:00
/*
2011-09-09 10:31:58 -07:00
* v3 hardware has 2 kinds of packet types ,
* v4 hardware has 3.
2011-09-09 10:30:31 -07:00
*/
# define PACKET_UNKNOWN 0x01
# define PACKET_DEBOUNCE 0x02
# define PACKET_V3_HEAD 0x03
# define PACKET_V3_TAIL 0x04
2011-09-09 10:31:58 -07:00
# define PACKET_V4_HEAD 0x05
# define PACKET_V4_MOTION 0x06
# define PACKET_V4_STATUS 0x07
Input: elantech - add support for trackpoint found on some v3 models
Some elantech v3 touchpad equipped laptops also have a trackpoint, before
this commit, these give sync errors. With this patch, the trackpoint is
provided as another input device: 'Elantech PS/2 TrackPoint'
The patch will also output messages that do not follow the expected pattern.
In the mean time I've seen 2 unknown packets occasionally:
0x04 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00
I don't know what those are for, but they can be safely ignored.
Currently all packets that are not known to v3 touchpad and where
packet[3] (the fourth byte) lowest nibble is 6 are now recognized as
PACKET_TRACKPOINT and processed by the new elantech_report_trackpoint.
This has been verified to work on a laptop Lenovo L530 where the
touchpad/trackpoint combined identify themselves as:
psmouse serio1: elantech: assuming hardware version 3 (with firmware version 0x350f02)
psmouse serio1: elantech: Synaptics capabilities query result 0xb9, 0x15, 0x0c.
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ulrik De Bie <ulrik.debie-os@e2big.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-08-22 17:06:00 -07:00
# define PACKET_TRACKPOINT 0x08
2011-09-09 10:31:58 -07:00
/*
* track up to 5 fingers for v4 hardware
*/
# define ETP_MAX_FINGERS 5
/*
* weight value for v4 hardware
*/
# define ETP_WEIGHT_VALUE 5
2018-05-22 17:28:23 -07:00
/*
* Bus information on 3 rd byte of query ETP_RESOLUTION_QUERY ( 0x04 )
*/
# define ETP_BUS_PS2_ONLY 0
# define ETP_BUS_SMB_ALERT_ONLY 1
# define ETP_BUS_SMB_HST_NTFY_ONLY 2
# define ETP_BUS_PS2_SMB_ALERT 3
# define ETP_BUS_PS2_SMB_HST_NTFY 4
2018-05-22 17:30:07 -07:00
/*
* New ICs are either using SMBus Host Notify or just plain PS2 .
*
* ETP_FW_VERSION_QUERY is :
* Byte 1 :
* - bit 0. .3 : IC BODY
* Byte 2 :
* - bit 4 : HiddenButton
* - bit 5 : PS2_SMBUS_NOTIFY
* - bit 6 : PS2CRCCheck
*/
# define ETP_NEW_IC_SMBUS_HOST_NOTIFY(fw_version) \
( ( ( ( fw_version ) & 0x0f2000 ) = = 0x0f2000 ) & & \
( ( fw_version ) & 0x0000ff ) > 0 )
2011-09-09 10:31:58 -07:00
/*
* The base position for one finger , v4 hardware
*/
struct finger_pos {
unsigned int x ;
unsigned int y ;
} ;
2011-09-09 10:30:31 -07:00
2018-05-22 17:26:24 -07:00
struct elantech_device_info {
unsigned char capabilities [ 3 ] ;
unsigned char samples [ 3 ] ;
unsigned char debug ;
unsigned char hw_version ;
2020-12-10 23:49:16 -08:00
unsigned char pattern ;
2018-05-22 17:26:24 -07:00
unsigned int fw_version ;
2020-12-10 23:49:16 -08:00
unsigned int ic_version ;
unsigned int product_id ;
2019-05-27 18:24:28 -07:00
unsigned int x_min ;
unsigned int y_min ;
unsigned int x_max ;
unsigned int y_max ;
2018-05-22 17:27:43 -07:00
unsigned int x_res ;
unsigned int y_res ;
2019-05-27 18:43:49 -07:00
unsigned int x_traces ;
unsigned int y_traces ;
2019-05-27 18:24:28 -07:00
unsigned int width ;
2018-05-22 17:28:23 -07:00
unsigned int bus ;
2018-05-22 17:26:24 -07:00
bool paritycheck ;
bool jumpy_cursor ;
bool reports_pressure ;
bool crc_enabled ;
bool set_hw_resolution ;
bool has_trackpoint ;
2019-05-27 18:33:33 -07:00
bool has_middle_button ;
2018-05-22 17:26:24 -07:00
int ( * send_cmd ) ( struct psmouse * psmouse , unsigned char c ,
unsigned char * param ) ;
} ;
2008-10-16 22:10:19 -04:00
struct elantech_data {
Input: elantech - add support for trackpoint found on some v3 models
Some elantech v3 touchpad equipped laptops also have a trackpoint, before
this commit, these give sync errors. With this patch, the trackpoint is
provided as another input device: 'Elantech PS/2 TrackPoint'
The patch will also output messages that do not follow the expected pattern.
In the mean time I've seen 2 unknown packets occasionally:
0x04 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
0x00 , 0x00 , 0x00 , 0x02 , 0x00 , 0x00
I don't know what those are for, but they can be safely ignored.
Currently all packets that are not known to v3 touchpad and where
packet[3] (the fourth byte) lowest nibble is 6 are now recognized as
PACKET_TRACKPOINT and processed by the new elantech_report_trackpoint.
This has been verified to work on a laptop Lenovo L530 where the
touchpad/trackpoint combined identify themselves as:
psmouse serio1: elantech: assuming hardware version 3 (with firmware version 0x350f02)
psmouse serio1: elantech: Synaptics capabilities query result 0xb9, 0x15, 0x0c.
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Ulrik De Bie <ulrik.debie-os@e2big.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2014-08-22 17:06:00 -07:00
struct input_dev * tp_dev ; /* Relative device for trackpoint */
char tp_phys [ 32 ] ;
2011-09-09 10:31:58 -07:00
unsigned char reg_07 ;
2008-10-16 22:10:19 -04:00
unsigned char reg_10 ;
unsigned char reg_11 ;
unsigned char reg_20 ;
unsigned char reg_21 ;
unsigned char reg_22 ;
unsigned char reg_23 ;
unsigned char reg_24 ;
unsigned char reg_25 ;
unsigned char reg_26 ;
2010-08-05 23:51:49 -07:00
unsigned int single_finger_reports ;
2011-09-09 10:26:16 -07:00
unsigned int y_max ;
2011-09-09 10:31:58 -07:00
unsigned int width ;
struct finger_pos mt [ ETP_MAX_FINGERS ] ;
2008-10-16 22:10:19 -04:00
unsigned char parity [ 256 ] ;
2018-05-22 17:26:24 -07:00
struct elantech_device_info info ;
2015-04-06 15:35:38 -07:00
void ( * original_set_rate ) ( struct psmouse * psmouse , unsigned int rate ) ;
2008-10-16 22:10:19 -04:00
} ;
2009-09-09 19:13:20 -07:00
int elantech_detect ( struct psmouse * psmouse , bool set_properties ) ;
2018-05-22 17:28:23 -07:00
int elantech_init_ps2 ( struct psmouse * psmouse ) ;
2019-08-20 12:07:01 -07:00
# ifdef CONFIG_MOUSE_PS2_ELANTECH
2008-10-16 22:10:19 -04:00
int elantech_init ( struct psmouse * psmouse ) ;
# else
static inline int elantech_init ( struct psmouse * psmouse )
{
return - ENOSYS ;
}
# endif /* CONFIG_MOUSE_PS2_ELANTECH */
2018-05-22 17:28:23 -07:00
int elantech_init_smbus ( struct psmouse * psmouse ) ;
2008-10-16 22:10:19 -04:00
# endif