11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * ALPS touchpad PS/2 mouse driver 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (c) 2003 Peter Osterlund <petero2@telia.com> 51da177e4SLinus Torvalds * Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz> 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify it 81da177e4SLinus Torvalds * under the terms of the GNU General Public License version 2 as published by 91da177e4SLinus Torvalds * the Free Software Foundation. 101da177e4SLinus Torvalds */ 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds #ifndef _ALPS_H 131da177e4SLinus Torvalds #define _ALPS_H 141da177e4SLinus Torvalds 15fa629ef5SSeth Forshee #define ALPS_PROTO_V1 0 16fa629ef5SSeth Forshee #define ALPS_PROTO_V2 1 1725bded7cSSeth Forshee #define ALPS_PROTO_V3 2 1825bded7cSSeth Forshee #define ALPS_PROTO_V4 3 19fa629ef5SSeth Forshee 20*88a80348SKevin Cernekee /** 21*88a80348SKevin Cernekee * struct alps_model_info - touchpad ID table 22*88a80348SKevin Cernekee * @signature: E7 response string to match. 23*88a80348SKevin Cernekee * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response 24*88a80348SKevin Cernekee * (aka command mode response) identifies the firmware minor version. This 25*88a80348SKevin Cernekee * can be used to distinguish different hardware models which are not 26*88a80348SKevin Cernekee * uniquely identifiable through their E7 responses. 27*88a80348SKevin Cernekee * @proto_version: Indicates V1/V2/V3/... 28*88a80348SKevin Cernekee * @byte0: Helps figure out whether a position report packet matches the 29*88a80348SKevin Cernekee * known format for this model. The first byte of the report, ANDed with 30*88a80348SKevin Cernekee * mask0, should match byte0. 31*88a80348SKevin Cernekee * @mask0: The mask used to check the first byte of the report. 32*88a80348SKevin Cernekee * @flags: Additional device capabilities (passthrough port, trackstick, etc.). 33*88a80348SKevin Cernekee * 34*88a80348SKevin Cernekee * Many (but not all) ALPS touchpads can be identified by looking at the 35*88a80348SKevin Cernekee * values returned in the "E7 report" and/or the "EC report." This table 36*88a80348SKevin Cernekee * lists a number of such touchpads. 37*88a80348SKevin Cernekee */ 381da177e4SLinus Torvalds struct alps_model_info { 391da177e4SLinus Torvalds unsigned char signature[3]; 40*88a80348SKevin Cernekee unsigned char command_mode_resp; 41fa629ef5SSeth Forshee unsigned char proto_version; 421da177e4SLinus Torvalds unsigned char byte0, mask0; 431da177e4SLinus Torvalds unsigned char flags; 441da177e4SLinus Torvalds }; 451da177e4SLinus Torvalds 46*88a80348SKevin Cernekee /** 47*88a80348SKevin Cernekee * struct alps_nibble_commands - encodings for register accesses 48*88a80348SKevin Cernekee * @command: PS/2 command used for the nibble 49*88a80348SKevin Cernekee * @data: Data supplied as an argument to the PS/2 command, if applicable 50*88a80348SKevin Cernekee * 51*88a80348SKevin Cernekee * The ALPS protocol uses magic sequences to transmit binary data to the 52*88a80348SKevin Cernekee * touchpad, as it is generally not OK to send arbitrary bytes out the 53*88a80348SKevin Cernekee * PS/2 port. Each of the sequences in this table sends one nibble of the 54*88a80348SKevin Cernekee * register address or (write) data. Different versions of the ALPS protocol 55*88a80348SKevin Cernekee * use slightly different encodings. 56*88a80348SKevin Cernekee */ 5725bded7cSSeth Forshee struct alps_nibble_commands { 5825bded7cSSeth Forshee int command; 5925bded7cSSeth Forshee unsigned char data; 6025bded7cSSeth Forshee }; 6125bded7cSSeth Forshee 62*88a80348SKevin Cernekee /** 63*88a80348SKevin Cernekee * struct alps_data - private data structure for the ALPS driver 64*88a80348SKevin Cernekee * @dev2: "Relative" device used to report trackstick or mouse activity. 65*88a80348SKevin Cernekee * @phys: Physical path for the relative device. 66*88a80348SKevin Cernekee * @i: Information on the detected touchpad model. 67*88a80348SKevin Cernekee * @nibble_commands: Command mapping used for touchpad register accesses. 68*88a80348SKevin Cernekee * @addr_command: Command used to tell the touchpad that a register address 69*88a80348SKevin Cernekee * follows. 70*88a80348SKevin Cernekee * @prev_fin: Finger bit from previous packet. 71*88a80348SKevin Cernekee * @multi_packet: Multi-packet data in progress. 72*88a80348SKevin Cernekee * @multi_data: Saved multi-packet data. 73*88a80348SKevin Cernekee * @x1: First X coordinate from last MT report. 74*88a80348SKevin Cernekee * @x2: Second X coordinate from last MT report. 75*88a80348SKevin Cernekee * @y1: First Y coordinate from last MT report. 76*88a80348SKevin Cernekee * @y2: Second Y coordinate from last MT report. 77*88a80348SKevin Cernekee * @fingers: Number of fingers from last MT report. 78*88a80348SKevin Cernekee * @quirks: Bitmap of ALPS_QUIRK_*. 79*88a80348SKevin Cernekee * @timer: Timer for flushing out the final report packet in the stream. 80*88a80348SKevin Cernekee */ 811da177e4SLinus Torvalds struct alps_data { 82*88a80348SKevin Cernekee struct input_dev *dev2; 83*88a80348SKevin Cernekee char phys[32]; 84*88a80348SKevin Cernekee const struct alps_model_info *i; 8525bded7cSSeth Forshee const struct alps_nibble_commands *nibble_commands; 86*88a80348SKevin Cernekee int addr_command; 87*88a80348SKevin Cernekee int prev_fin; 88*88a80348SKevin Cernekee int multi_packet; 89*88a80348SKevin Cernekee unsigned char multi_data[6]; 90*88a80348SKevin Cernekee int x1, x2, y1, y2; 91*88a80348SKevin Cernekee int fingers; 9225bded7cSSeth Forshee u8 quirks; 931d9f2626SSebastian Kapfer struct timer_list timer; 941da177e4SLinus Torvalds }; 951da177e4SLinus Torvalds 9625bded7cSSeth Forshee #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ 9725bded7cSSeth Forshee 9855e3d922SAndres Salomon #ifdef CONFIG_MOUSE_PS2_ALPS 99b7802c5cSDmitry Torokhov int alps_detect(struct psmouse *psmouse, bool set_properties); 10055e3d922SAndres Salomon int alps_init(struct psmouse *psmouse); 10155e3d922SAndres Salomon #else 102b7802c5cSDmitry Torokhov inline int alps_detect(struct psmouse *psmouse, bool set_properties) 10355e3d922SAndres Salomon { 10455e3d922SAndres Salomon return -ENOSYS; 10555e3d922SAndres Salomon } 10655e3d922SAndres Salomon inline int alps_init(struct psmouse *psmouse) 10755e3d922SAndres Salomon { 10855e3d922SAndres Salomon return -ENOSYS; 10955e3d922SAndres Salomon } 11055e3d922SAndres Salomon #endif /* CONFIG_MOUSE_PS2_ALPS */ 11155e3d922SAndres Salomon 1121da177e4SLinus Torvalds #endif 113