Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Kevin Cernekee | b5d6b85 | 2013-02-13 22:19:59 -0800 | [diff] [blame^] | 15 | #define ALPS_PROTO_V1 1 |
| 16 | #define ALPS_PROTO_V2 2 |
| 17 | #define ALPS_PROTO_V3 3 |
| 18 | #define ALPS_PROTO_V4 4 |
Seth Forshee | fa629ef | 2011-11-07 19:53:24 -0800 | [diff] [blame] | 19 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 20 | /** |
| 21 | * struct alps_model_info - touchpad ID table |
| 22 | * @signature: E7 response string to match. |
| 23 | * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response |
| 24 | * (aka command mode response) identifies the firmware minor version. This |
| 25 | * can be used to distinguish different hardware models which are not |
| 26 | * uniquely identifiable through their E7 responses. |
| 27 | * @proto_version: Indicates V1/V2/V3/... |
| 28 | * @byte0: Helps figure out whether a position report packet matches the |
| 29 | * known format for this model. The first byte of the report, ANDed with |
| 30 | * mask0, should match byte0. |
| 31 | * @mask0: The mask used to check the first byte of the report. |
| 32 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). |
| 33 | * |
| 34 | * Many (but not all) ALPS touchpads can be identified by looking at the |
| 35 | * values returned in the "E7 report" and/or the "EC report." This table |
| 36 | * lists a number of such touchpads. |
| 37 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | struct alps_model_info { |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 39 | unsigned char signature[3]; |
| 40 | unsigned char command_mode_resp; |
Seth Forshee | fa629ef | 2011-11-07 19:53:24 -0800 | [diff] [blame] | 41 | unsigned char proto_version; |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 42 | unsigned char byte0, mask0; |
| 43 | unsigned char flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 46 | /** |
| 47 | * struct alps_nibble_commands - encodings for register accesses |
| 48 | * @command: PS/2 command used for the nibble |
| 49 | * @data: Data supplied as an argument to the PS/2 command, if applicable |
| 50 | * |
| 51 | * The ALPS protocol uses magic sequences to transmit binary data to the |
| 52 | * touchpad, as it is generally not OK to send arbitrary bytes out the |
| 53 | * PS/2 port. Each of the sequences in this table sends one nibble of the |
| 54 | * register address or (write) data. Different versions of the ALPS protocol |
| 55 | * use slightly different encodings. |
| 56 | */ |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 57 | struct alps_nibble_commands { |
| 58 | int command; |
| 59 | unsigned char data; |
| 60 | }; |
| 61 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 62 | /** |
| 63 | * struct alps_data - private data structure for the ALPS driver |
| 64 | * @dev2: "Relative" device used to report trackstick or mouse activity. |
| 65 | * @phys: Physical path for the relative device. |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 66 | * @nibble_commands: Command mapping used for touchpad register accesses. |
| 67 | * @addr_command: Command used to tell the touchpad that a register address |
| 68 | * follows. |
Kevin Cernekee | 99df65e | 2013-02-13 20:56:33 -0800 | [diff] [blame] | 69 | * @proto_version: Indicates V1/V2/V3/... |
| 70 | * @byte0: Helps figure out whether a position report packet matches the |
| 71 | * known format for this model. The first byte of the report, ANDed with |
| 72 | * mask0, should match byte0. |
| 73 | * @mask0: The mask used to check the first byte of the report. |
| 74 | * @flags: Additional device capabilities (passthrough port, trackstick, etc.). |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 75 | * @prev_fin: Finger bit from previous packet. |
| 76 | * @multi_packet: Multi-packet data in progress. |
| 77 | * @multi_data: Saved multi-packet data. |
| 78 | * @x1: First X coordinate from last MT report. |
| 79 | * @x2: Second X coordinate from last MT report. |
| 80 | * @y1: First Y coordinate from last MT report. |
| 81 | * @y2: Second Y coordinate from last MT report. |
| 82 | * @fingers: Number of fingers from last MT report. |
| 83 | * @quirks: Bitmap of ALPS_QUIRK_*. |
| 84 | * @timer: Timer for flushing out the final report packet in the stream. |
| 85 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | struct alps_data { |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 87 | struct input_dev *dev2; |
| 88 | char phys[32]; |
Kevin Cernekee | 99df65e | 2013-02-13 20:56:33 -0800 | [diff] [blame] | 89 | |
| 90 | /* these are autodetected when the device is identified */ |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 91 | const struct alps_nibble_commands *nibble_commands; |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 92 | int addr_command; |
Kevin Cernekee | 99df65e | 2013-02-13 20:56:33 -0800 | [diff] [blame] | 93 | unsigned char proto_version; |
| 94 | unsigned char byte0, mask0; |
| 95 | unsigned char flags; |
| 96 | |
Kevin Cernekee | 88a8034 | 2013-02-13 20:55:19 -0800 | [diff] [blame] | 97 | int prev_fin; |
| 98 | int multi_packet; |
| 99 | unsigned char multi_data[6]; |
| 100 | int x1, x2, y1, y2; |
| 101 | int fingers; |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 102 | u8 quirks; |
Sebastian Kapfer | 1d9f262 | 2009-12-15 08:39:50 -0800 | [diff] [blame] | 103 | struct timer_list timer; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | }; |
| 105 | |
Seth Forshee | 25bded7 | 2011-11-07 19:53:36 -0800 | [diff] [blame] | 106 | #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ |
| 107 | |
Andres Salomon | 55e3d92 | 2007-03-10 01:39:54 -0500 | [diff] [blame] | 108 | #ifdef CONFIG_MOUSE_PS2_ALPS |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 109 | int alps_detect(struct psmouse *psmouse, bool set_properties); |
Andres Salomon | 55e3d92 | 2007-03-10 01:39:54 -0500 | [diff] [blame] | 110 | int alps_init(struct psmouse *psmouse); |
| 111 | #else |
Dmitry Torokhov | b7802c5 | 2009-09-09 19:13:20 -0700 | [diff] [blame] | 112 | inline int alps_detect(struct psmouse *psmouse, bool set_properties) |
Andres Salomon | 55e3d92 | 2007-03-10 01:39:54 -0500 | [diff] [blame] | 113 | { |
| 114 | return -ENOSYS; |
| 115 | } |
| 116 | inline int alps_init(struct psmouse *psmouse) |
| 117 | { |
| 118 | return -ENOSYS; |
| 119 | } |
| 120 | #endif /* CONFIG_MOUSE_PS2_ALPS */ |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | #endif |