1 /* 2 * ALPS touchpad PS/2 mouse driver 3 * 4 * Copyright (c) 2003 Peter Osterlund <petero2@telia.com> 5 * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> 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 _ALPS_H 13 #define _ALPS_H 14 15 #define ALPS_PROTO_V1 1 16 #define ALPS_PROTO_V2 2 17 #define ALPS_PROTO_V3 3 18 #define ALPS_PROTO_V4 4 19 #define ALPS_PROTO_V5 5 20 #define ALPS_PROTO_V6 6 21 22 /** 23 * struct alps_model_info - touchpad ID table 24 * @signature: E7 response string to match. 25 * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response 26 * (aka command mode response) identifies the firmware minor version. This 27 * can be used to distinguish different hardware models which are not 28 * uniquely identifiable through their E7 responses. 29 * @proto_version: Indicates V1/V2/V3/... 30 * @byte0: Helps figure out whether a position report packet matches the 31 * known format for this model. The first byte of the report, ANDed with 32 * mask0, should match byte0. 33 * @mask0: The mask used to check the first byte of the report. 34 * @flags: Additional device capabilities (passthrough port, trackstick, etc.). 35 * 36 * Many (but not all) ALPS touchpads can be identified by looking at the 37 * values returned in the "E7 report" and/or the "EC report." This table 38 * lists a number of such touchpads. 39 */ 40 struct alps_model_info { 41 unsigned char signature[3]; 42 unsigned char command_mode_resp; 43 unsigned char proto_version; 44 unsigned char byte0, mask0; 45 unsigned char flags; 46 }; 47 48 /** 49 * struct alps_nibble_commands - encodings for register accesses 50 * @command: PS/2 command used for the nibble 51 * @data: Data supplied as an argument to the PS/2 command, if applicable 52 * 53 * The ALPS protocol uses magic sequences to transmit binary data to the 54 * touchpad, as it is generally not OK to send arbitrary bytes out the 55 * PS/2 port. Each of the sequences in this table sends one nibble of the 56 * register address or (write) data. Different versions of the ALPS protocol 57 * use slightly different encodings. 58 */ 59 struct alps_nibble_commands { 60 int command; 61 unsigned char data; 62 }; 63 64 /** 65 * struct alps_fields - decoded version of the report packet 66 * @x_map: Bitmap of active X positions for MT. 67 * @y_map: Bitmap of active Y positions for MT. 68 * @fingers: Number of fingers for MT. 69 * @x: X position for ST. 70 * @y: Y position for ST. 71 * @z: Z position for ST. 72 * @first_mp: Packet is the first of a multi-packet report. 73 * @is_mp: Packet is part of a multi-packet report. 74 * @left: Left touchpad button is active. 75 * @right: Right touchpad button is active. 76 * @middle: Middle touchpad button is active. 77 * @ts_left: Left trackstick button is active. 78 * @ts_right: Right trackstick button is active. 79 * @ts_middle: Middle trackstick button is active. 80 */ 81 struct alps_fields { 82 unsigned int x_map; 83 unsigned int y_map; 84 unsigned int fingers; 85 unsigned int x; 86 unsigned int y; 87 unsigned int z; 88 unsigned int first_mp:1; 89 unsigned int is_mp:1; 90 91 unsigned int left:1; 92 unsigned int right:1; 93 unsigned int middle:1; 94 95 unsigned int ts_left:1; 96 unsigned int ts_right:1; 97 unsigned int ts_middle:1; 98 }; 99 100 /** 101 * struct alps_data - private data structure for the ALPS driver 102 * @dev2: "Relative" device used to report trackstick or mouse activity. 103 * @phys: Physical path for the relative device. 104 * @nibble_commands: Command mapping used for touchpad register accesses. 105 * @addr_command: Command used to tell the touchpad that a register address 106 * follows. 107 * @proto_version: Indicates V1/V2/V3/... 108 * @byte0: Helps figure out whether a position report packet matches the 109 * known format for this model. The first byte of the report, ANDed with 110 * mask0, should match byte0. 111 * @mask0: The mask used to check the first byte of the report. 112 * @flags: Additional device capabilities (passthrough port, trackstick, etc.). 113 * @x_max: Largest possible X position value. 114 * @y_max: Largest possible Y position value. 115 * @x_bits: Number of X bits in the MT bitmap. 116 * @y_bits: Number of Y bits in the MT bitmap. 117 * @hw_init: Protocol-specific hardware init function. 118 * @process_packet: Protocol-specific function to process a report packet. 119 * @decode_fields: Protocol-specific function to read packet bitfields. 120 * @set_abs_params: Protocol-specific function to configure the input_dev. 121 * @prev_fin: Finger bit from previous packet. 122 * @multi_packet: Multi-packet data in progress. 123 * @multi_data: Saved multi-packet data. 124 * @x1: First X coordinate from last MT report. 125 * @x2: Second X coordinate from last MT report. 126 * @y1: First Y coordinate from last MT report. 127 * @y2: Second Y coordinate from last MT report. 128 * @fingers: Number of fingers from last MT report. 129 * @quirks: Bitmap of ALPS_QUIRK_*. 130 * @timer: Timer for flushing out the final report packet in the stream. 131 */ 132 struct alps_data { 133 struct input_dev *dev2; 134 char phys[32]; 135 136 /* these are autodetected when the device is identified */ 137 const struct alps_nibble_commands *nibble_commands; 138 int addr_command; 139 unsigned char proto_version; 140 unsigned char byte0, mask0; 141 unsigned char flags; 142 int x_max; 143 int y_max; 144 int x_bits; 145 int y_bits; 146 147 int (*hw_init)(struct psmouse *psmouse); 148 void (*process_packet)(struct psmouse *psmouse); 149 void (*decode_fields)(struct alps_fields *f, unsigned char *p); 150 void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1); 151 152 int prev_fin; 153 int multi_packet; 154 unsigned char multi_data[6]; 155 int x1, x2, y1, y2; 156 int fingers; 157 u8 quirks; 158 struct timer_list timer; 159 }; 160 161 #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ 162 163 #ifdef CONFIG_MOUSE_PS2_ALPS 164 int alps_detect(struct psmouse *psmouse, bool set_properties); 165 int alps_init(struct psmouse *psmouse); 166 #else 167 inline int alps_detect(struct psmouse *psmouse, bool set_properties) 168 { 169 return -ENOSYS; 170 } 171 inline int alps_init(struct psmouse *psmouse) 172 { 173 return -ENOSYS; 174 } 175 #endif /* CONFIG_MOUSE_PS2_ALPS */ 176 177 #endif 178