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 15b5d6b851SKevin Cernekee #define ALPS_PROTO_V1 1 16b5d6b851SKevin Cernekee #define ALPS_PROTO_V2 2 17b5d6b851SKevin Cernekee #define ALPS_PROTO_V3 3 18b5d6b851SKevin Cernekee #define ALPS_PROTO_V4 4 19fa629ef5SSeth Forshee 2088a80348SKevin Cernekee /** 2188a80348SKevin Cernekee * struct alps_model_info - touchpad ID table 2288a80348SKevin Cernekee * @signature: E7 response string to match. 2388a80348SKevin Cernekee * @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response 2488a80348SKevin Cernekee * (aka command mode response) identifies the firmware minor version. This 2588a80348SKevin Cernekee * can be used to distinguish different hardware models which are not 2688a80348SKevin Cernekee * uniquely identifiable through their E7 responses. 2788a80348SKevin Cernekee * @proto_version: Indicates V1/V2/V3/... 2888a80348SKevin Cernekee * @byte0: Helps figure out whether a position report packet matches the 2988a80348SKevin Cernekee * known format for this model. The first byte of the report, ANDed with 3088a80348SKevin Cernekee * mask0, should match byte0. 3188a80348SKevin Cernekee * @mask0: The mask used to check the first byte of the report. 3288a80348SKevin Cernekee * @flags: Additional device capabilities (passthrough port, trackstick, etc.). 3388a80348SKevin Cernekee * 3488a80348SKevin Cernekee * Many (but not all) ALPS touchpads can be identified by looking at the 3588a80348SKevin Cernekee * values returned in the "E7 report" and/or the "EC report." This table 3688a80348SKevin Cernekee * lists a number of such touchpads. 3788a80348SKevin Cernekee */ 381da177e4SLinus Torvalds struct alps_model_info { 391da177e4SLinus Torvalds unsigned char signature[3]; 4088a80348SKevin 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 4688a80348SKevin Cernekee /** 4788a80348SKevin Cernekee * struct alps_nibble_commands - encodings for register accesses 4888a80348SKevin Cernekee * @command: PS/2 command used for the nibble 4988a80348SKevin Cernekee * @data: Data supplied as an argument to the PS/2 command, if applicable 5088a80348SKevin Cernekee * 5188a80348SKevin Cernekee * The ALPS protocol uses magic sequences to transmit binary data to the 5288a80348SKevin Cernekee * touchpad, as it is generally not OK to send arbitrary bytes out the 5388a80348SKevin Cernekee * PS/2 port. Each of the sequences in this table sends one nibble of the 5488a80348SKevin Cernekee * register address or (write) data. Different versions of the ALPS protocol 5588a80348SKevin Cernekee * use slightly different encodings. 5688a80348SKevin Cernekee */ 5725bded7cSSeth Forshee struct alps_nibble_commands { 5825bded7cSSeth Forshee int command; 5925bded7cSSeth Forshee unsigned char data; 6025bded7cSSeth Forshee }; 6125bded7cSSeth Forshee 6288a80348SKevin Cernekee /** 63*f85e5001SKevin Cernekee * struct alps_fields - decoded version of the report packet 64*f85e5001SKevin Cernekee * @x_map: Bitmap of active X positions for MT. 65*f85e5001SKevin Cernekee * @y_map: Bitmap of active Y positions for MT. 66*f85e5001SKevin Cernekee * @fingers: Number of fingers for MT. 67*f85e5001SKevin Cernekee * @x: X position for ST. 68*f85e5001SKevin Cernekee * @y: Y position for ST. 69*f85e5001SKevin Cernekee * @z: Z position for ST. 70*f85e5001SKevin Cernekee * @first_mp: Packet is the first of a multi-packet report. 71*f85e5001SKevin Cernekee * @is_mp: Packet is part of a multi-packet report. 72*f85e5001SKevin Cernekee * @left: Left touchpad button is active. 73*f85e5001SKevin Cernekee * @right: Right touchpad button is active. 74*f85e5001SKevin Cernekee * @middle: Middle touchpad button is active. 75*f85e5001SKevin Cernekee * @ts_left: Left trackstick button is active. 76*f85e5001SKevin Cernekee * @ts_right: Right trackstick button is active. 77*f85e5001SKevin Cernekee * @ts_middle: Middle trackstick button is active. 78*f85e5001SKevin Cernekee */ 79*f85e5001SKevin Cernekee struct alps_fields { 80*f85e5001SKevin Cernekee unsigned int x_map; 81*f85e5001SKevin Cernekee unsigned int y_map; 82*f85e5001SKevin Cernekee unsigned int fingers; 83*f85e5001SKevin Cernekee unsigned int x; 84*f85e5001SKevin Cernekee unsigned int y; 85*f85e5001SKevin Cernekee unsigned int z; 86*f85e5001SKevin Cernekee unsigned int first_mp:1; 87*f85e5001SKevin Cernekee unsigned int is_mp:1; 88*f85e5001SKevin Cernekee 89*f85e5001SKevin Cernekee unsigned int left:1; 90*f85e5001SKevin Cernekee unsigned int right:1; 91*f85e5001SKevin Cernekee unsigned int middle:1; 92*f85e5001SKevin Cernekee 93*f85e5001SKevin Cernekee unsigned int ts_left:1; 94*f85e5001SKevin Cernekee unsigned int ts_right:1; 95*f85e5001SKevin Cernekee unsigned int ts_middle:1; 96*f85e5001SKevin Cernekee }; 97*f85e5001SKevin Cernekee 98*f85e5001SKevin Cernekee /** 9988a80348SKevin Cernekee * struct alps_data - private data structure for the ALPS driver 10088a80348SKevin Cernekee * @dev2: "Relative" device used to report trackstick or mouse activity. 10188a80348SKevin Cernekee * @phys: Physical path for the relative device. 10288a80348SKevin Cernekee * @nibble_commands: Command mapping used for touchpad register accesses. 10388a80348SKevin Cernekee * @addr_command: Command used to tell the touchpad that a register address 10488a80348SKevin Cernekee * follows. 10599df65e7SKevin Cernekee * @proto_version: Indicates V1/V2/V3/... 10699df65e7SKevin Cernekee * @byte0: Helps figure out whether a position report packet matches the 10799df65e7SKevin Cernekee * known format for this model. The first byte of the report, ANDed with 10899df65e7SKevin Cernekee * mask0, should match byte0. 10999df65e7SKevin Cernekee * @mask0: The mask used to check the first byte of the report. 11099df65e7SKevin Cernekee * @flags: Additional device capabilities (passthrough port, trackstick, etc.). 1117a9f73e7SKevin Cernekee * @x_max: Largest possible X position value. 1127a9f73e7SKevin Cernekee * @y_max: Largest possible Y position value. 1137a9f73e7SKevin Cernekee * @x_bits: Number of X bits in the MT bitmap. 1147a9f73e7SKevin Cernekee * @y_bits: Number of Y bits in the MT bitmap. 11524af5cb9SKevin Cernekee * @hw_init: Protocol-specific hardware init function. 11624af5cb9SKevin Cernekee * @process_packet: Protocol-specific function to process a report packet. 117*f85e5001SKevin Cernekee * @decode_fields: Protocol-specific function to read packet bitfields. 11824af5cb9SKevin Cernekee * @set_abs_params: Protocol-specific function to configure the input_dev. 11988a80348SKevin Cernekee * @prev_fin: Finger bit from previous packet. 12088a80348SKevin Cernekee * @multi_packet: Multi-packet data in progress. 12188a80348SKevin Cernekee * @multi_data: Saved multi-packet data. 12288a80348SKevin Cernekee * @x1: First X coordinate from last MT report. 12388a80348SKevin Cernekee * @x2: Second X coordinate from last MT report. 12488a80348SKevin Cernekee * @y1: First Y coordinate from last MT report. 12588a80348SKevin Cernekee * @y2: Second Y coordinate from last MT report. 12688a80348SKevin Cernekee * @fingers: Number of fingers from last MT report. 12788a80348SKevin Cernekee * @quirks: Bitmap of ALPS_QUIRK_*. 12888a80348SKevin Cernekee * @timer: Timer for flushing out the final report packet in the stream. 12988a80348SKevin Cernekee */ 1301da177e4SLinus Torvalds struct alps_data { 13188a80348SKevin Cernekee struct input_dev *dev2; 13288a80348SKevin Cernekee char phys[32]; 13399df65e7SKevin Cernekee 13499df65e7SKevin Cernekee /* these are autodetected when the device is identified */ 13525bded7cSSeth Forshee const struct alps_nibble_commands *nibble_commands; 13688a80348SKevin Cernekee int addr_command; 13799df65e7SKevin Cernekee unsigned char proto_version; 13899df65e7SKevin Cernekee unsigned char byte0, mask0; 13999df65e7SKevin Cernekee unsigned char flags; 1407a9f73e7SKevin Cernekee int x_max; 1417a9f73e7SKevin Cernekee int y_max; 1427a9f73e7SKevin Cernekee int x_bits; 1437a9f73e7SKevin Cernekee int y_bits; 14499df65e7SKevin Cernekee 14524af5cb9SKevin Cernekee int (*hw_init)(struct psmouse *psmouse); 14624af5cb9SKevin Cernekee void (*process_packet)(struct psmouse *psmouse); 147*f85e5001SKevin Cernekee void (*decode_fields)(struct alps_fields *f, unsigned char *p); 14824af5cb9SKevin Cernekee void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1); 14924af5cb9SKevin Cernekee 15088a80348SKevin Cernekee int prev_fin; 15188a80348SKevin Cernekee int multi_packet; 15288a80348SKevin Cernekee unsigned char multi_data[6]; 15388a80348SKevin Cernekee int x1, x2, y1, y2; 15488a80348SKevin Cernekee int fingers; 15525bded7cSSeth Forshee u8 quirks; 1561d9f2626SSebastian Kapfer struct timer_list timer; 1571da177e4SLinus Torvalds }; 1581da177e4SLinus Torvalds 15925bded7cSSeth Forshee #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ 16025bded7cSSeth Forshee 16155e3d922SAndres Salomon #ifdef CONFIG_MOUSE_PS2_ALPS 162b7802c5cSDmitry Torokhov int alps_detect(struct psmouse *psmouse, bool set_properties); 16355e3d922SAndres Salomon int alps_init(struct psmouse *psmouse); 16455e3d922SAndres Salomon #else 165b7802c5cSDmitry Torokhov inline int alps_detect(struct psmouse *psmouse, bool set_properties) 16655e3d922SAndres Salomon { 16755e3d922SAndres Salomon return -ENOSYS; 16855e3d922SAndres Salomon } 16955e3d922SAndres Salomon inline int alps_init(struct psmouse *psmouse) 17055e3d922SAndres Salomon { 17155e3d922SAndres Salomon return -ENOSYS; 17255e3d922SAndres Salomon } 17355e3d922SAndres Salomon #endif /* CONFIG_MOUSE_PS2_ALPS */ 17455e3d922SAndres Salomon 1751da177e4SLinus Torvalds #endif 176