2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ALPS touchpad PS/2 mouse driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 Peter Osterlund <petero2@telia.com>
|
|
|
|
* Copyright (c) 2005 Vojtech Pavlik <vojtech@suse.cz>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ALPS_H
|
|
|
|
#define _ALPS_H
|
|
|
|
|
2014-07-26 05:43:35 +00:00
|
|
|
#include <linux/input/mt.h>
|
|
|
|
|
2013-02-14 06:19:59 +00:00
|
|
|
#define ALPS_PROTO_V1 1
|
|
|
|
#define ALPS_PROTO_V2 2
|
|
|
|
#define ALPS_PROTO_V3 3
|
|
|
|
#define ALPS_PROTO_V4 4
|
2013-02-22 06:58:28 +00:00
|
|
|
#define ALPS_PROTO_V5 5
|
2013-12-02 06:33:52 +00:00
|
|
|
#define ALPS_PROTO_V6 6
|
2014-07-26 20:51:41 +00:00
|
|
|
#define ALPS_PROTO_V7 7 /* t3btl t4s */
|
2011-11-08 03:53:24 +00:00
|
|
|
|
2014-07-26 05:43:35 +00:00
|
|
|
#define MAX_TOUCHES 2
|
|
|
|
|
2013-12-26 22:54:19 +00:00
|
|
|
#define DOLPHIN_COUNT_PER_ELECTRODE 64
|
|
|
|
#define DOLPHIN_PROFILE_XOFFSET 8 /* x-electrode offset */
|
|
|
|
#define DOLPHIN_PROFILE_YOFFSET 1 /* y-electrode offset */
|
|
|
|
|
2014-07-26 20:51:41 +00:00
|
|
|
/*
|
|
|
|
* enum V7_PACKET_ID - defines the packet type for V7
|
|
|
|
* V7_PACKET_ID_IDLE: There's no finger and no button activity.
|
|
|
|
* V7_PACKET_ID_TWO: There's one or two non-resting fingers on touchpad
|
|
|
|
* or there's button activities.
|
|
|
|
* V7_PACKET_ID_MULTI: There are at least three non-resting fingers.
|
|
|
|
* V7_PACKET_ID_NEW: The finger position in slot is not continues from
|
|
|
|
* previous packet.
|
|
|
|
*/
|
|
|
|
enum V7_PACKET_ID {
|
|
|
|
V7_PACKET_ID_IDLE,
|
|
|
|
V7_PACKET_ID_TWO,
|
|
|
|
V7_PACKET_ID_MULTI,
|
|
|
|
V7_PACKET_ID_NEW,
|
|
|
|
V7_PACKET_ID_UNKNOWN,
|
|
|
|
};
|
|
|
|
|
2013-02-14 04:55:19 +00:00
|
|
|
/**
|
|
|
|
* struct alps_model_info - touchpad ID table
|
|
|
|
* @signature: E7 response string to match.
|
|
|
|
* @command_mode_resp: For V3/V4 touchpads, the final byte of the EC response
|
|
|
|
* (aka command mode response) identifies the firmware minor version. This
|
|
|
|
* can be used to distinguish different hardware models which are not
|
|
|
|
* uniquely identifiable through their E7 responses.
|
|
|
|
* @proto_version: Indicates V1/V2/V3/...
|
|
|
|
* @byte0: Helps figure out whether a position report packet matches the
|
|
|
|
* known format for this model. The first byte of the report, ANDed with
|
|
|
|
* mask0, should match byte0.
|
|
|
|
* @mask0: The mask used to check the first byte of the report.
|
|
|
|
* @flags: Additional device capabilities (passthrough port, trackstick, etc.).
|
|
|
|
*
|
|
|
|
* Many (but not all) ALPS touchpads can be identified by looking at the
|
|
|
|
* values returned in the "E7 report" and/or the "EC report." This table
|
|
|
|
* lists a number of such touchpads.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
struct alps_model_info {
|
2013-02-14 04:55:19 +00:00
|
|
|
unsigned char signature[3];
|
|
|
|
unsigned char command_mode_resp;
|
2011-11-08 03:53:24 +00:00
|
|
|
unsigned char proto_version;
|
2013-02-14 04:55:19 +00:00
|
|
|
unsigned char byte0, mask0;
|
2014-07-26 05:37:15 +00:00
|
|
|
int flags;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2013-02-14 04:55:19 +00:00
|
|
|
/**
|
|
|
|
* struct alps_nibble_commands - encodings for register accesses
|
|
|
|
* @command: PS/2 command used for the nibble
|
|
|
|
* @data: Data supplied as an argument to the PS/2 command, if applicable
|
|
|
|
*
|
|
|
|
* The ALPS protocol uses magic sequences to transmit binary data to the
|
|
|
|
* touchpad, as it is generally not OK to send arbitrary bytes out the
|
|
|
|
* PS/2 port. Each of the sequences in this table sends one nibble of the
|
|
|
|
* register address or (write) data. Different versions of the ALPS protocol
|
|
|
|
* use slightly different encodings.
|
|
|
|
*/
|
2011-11-08 03:53:36 +00:00
|
|
|
struct alps_nibble_commands {
|
|
|
|
int command;
|
|
|
|
unsigned char data;
|
|
|
|
};
|
|
|
|
|
2014-07-26 05:38:51 +00:00
|
|
|
struct alps_bitmap_point {
|
|
|
|
int start_bit;
|
|
|
|
int num_bits;
|
|
|
|
};
|
|
|
|
|
2013-02-14 06:26:11 +00:00
|
|
|
/**
|
|
|
|
* struct alps_fields - decoded version of the report packet
|
|
|
|
* @x_map: Bitmap of active X positions for MT.
|
|
|
|
* @y_map: Bitmap of active Y positions for MT.
|
|
|
|
* @fingers: Number of fingers for MT.
|
2014-07-26 05:43:35 +00:00
|
|
|
* @pressure: Pressure.
|
|
|
|
* @st: position for ST.
|
|
|
|
* @mt: position for MT.
|
2013-02-14 06:26:11 +00:00
|
|
|
* @first_mp: Packet is the first of a multi-packet report.
|
|
|
|
* @is_mp: Packet is part of a multi-packet report.
|
|
|
|
* @left: Left touchpad button is active.
|
|
|
|
* @right: Right touchpad button is active.
|
|
|
|
* @middle: Middle touchpad button is active.
|
|
|
|
* @ts_left: Left trackstick button is active.
|
|
|
|
* @ts_right: Right trackstick button is active.
|
|
|
|
* @ts_middle: Middle trackstick button is active.
|
|
|
|
*/
|
|
|
|
struct alps_fields {
|
|
|
|
unsigned int x_map;
|
|
|
|
unsigned int y_map;
|
|
|
|
unsigned int fingers;
|
2014-07-26 05:43:35 +00:00
|
|
|
|
|
|
|
int pressure;
|
|
|
|
struct input_mt_pos st;
|
|
|
|
struct input_mt_pos mt[MAX_TOUCHES];
|
|
|
|
|
2013-02-14 06:26:11 +00:00
|
|
|
unsigned int first_mp:1;
|
|
|
|
unsigned int is_mp:1;
|
|
|
|
|
|
|
|
unsigned int left:1;
|
|
|
|
unsigned int right:1;
|
|
|
|
unsigned int middle:1;
|
|
|
|
|
|
|
|
unsigned int ts_left:1;
|
|
|
|
unsigned int ts_right:1;
|
|
|
|
unsigned int ts_middle:1;
|
|
|
|
};
|
|
|
|
|
2013-02-14 04:55:19 +00:00
|
|
|
/**
|
|
|
|
* struct alps_data - private data structure for the ALPS driver
|
|
|
|
* @dev2: "Relative" device used to report trackstick or mouse activity.
|
|
|
|
* @phys: Physical path for the relative device.
|
|
|
|
* @nibble_commands: Command mapping used for touchpad register accesses.
|
|
|
|
* @addr_command: Command used to tell the touchpad that a register address
|
|
|
|
* follows.
|
2013-02-14 04:56:33 +00:00
|
|
|
* @proto_version: Indicates V1/V2/V3/...
|
|
|
|
* @byte0: Helps figure out whether a position report packet matches the
|
|
|
|
* known format for this model. The first byte of the report, ANDed with
|
|
|
|
* mask0, should match byte0.
|
|
|
|
* @mask0: The mask used to check the first byte of the report.
|
2014-07-26 05:49:14 +00:00
|
|
|
* @fw_ver: cached copy of firmware version (EC report)
|
2013-02-14 04:56:33 +00:00
|
|
|
* @flags: Additional device capabilities (passthrough port, trackstick, etc.).
|
2013-02-14 06:24:55 +00:00
|
|
|
* @x_max: Largest possible X position value.
|
|
|
|
* @y_max: Largest possible Y position value.
|
|
|
|
* @x_bits: Number of X bits in the MT bitmap.
|
|
|
|
* @y_bits: Number of Y bits in the MT bitmap.
|
2013-02-14 06:22:08 +00:00
|
|
|
* @hw_init: Protocol-specific hardware init function.
|
|
|
|
* @process_packet: Protocol-specific function to process a report packet.
|
2013-02-14 06:26:11 +00:00
|
|
|
* @decode_fields: Protocol-specific function to read packet bitfields.
|
2013-02-14 06:22:08 +00:00
|
|
|
* @set_abs_params: Protocol-specific function to configure the input_dev.
|
2013-02-14 04:55:19 +00:00
|
|
|
* @prev_fin: Finger bit from previous packet.
|
|
|
|
* @multi_packet: Multi-packet data in progress.
|
|
|
|
* @multi_data: Saved multi-packet data.
|
2014-07-26 05:43:35 +00:00
|
|
|
* @f: Decoded packet data fields.
|
2013-02-14 04:55:19 +00:00
|
|
|
* @quirks: Bitmap of ALPS_QUIRK_*.
|
|
|
|
* @timer: Timer for flushing out the final report packet in the stream.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
struct alps_data {
|
2013-02-14 04:55:19 +00:00
|
|
|
struct input_dev *dev2;
|
|
|
|
char phys[32];
|
2013-02-14 04:56:33 +00:00
|
|
|
|
|
|
|
/* these are autodetected when the device is identified */
|
2011-11-08 03:53:36 +00:00
|
|
|
const struct alps_nibble_commands *nibble_commands;
|
2013-02-14 04:55:19 +00:00
|
|
|
int addr_command;
|
2013-02-14 04:56:33 +00:00
|
|
|
unsigned char proto_version;
|
|
|
|
unsigned char byte0, mask0;
|
2014-07-26 05:49:14 +00:00
|
|
|
unsigned char fw_ver[3];
|
2014-07-26 05:37:15 +00:00
|
|
|
int flags;
|
2013-02-14 06:24:55 +00:00
|
|
|
int x_max;
|
|
|
|
int y_max;
|
|
|
|
int x_bits;
|
|
|
|
int y_bits;
|
2014-07-29 18:22:07 +00:00
|
|
|
unsigned int x_res;
|
|
|
|
unsigned int y_res;
|
2013-02-14 04:56:33 +00:00
|
|
|
|
2013-02-14 06:22:08 +00:00
|
|
|
int (*hw_init)(struct psmouse *psmouse);
|
|
|
|
void (*process_packet)(struct psmouse *psmouse);
|
2014-07-26 05:48:44 +00:00
|
|
|
int (*decode_fields)(struct alps_fields *f, unsigned char *p,
|
2013-12-26 22:54:19 +00:00
|
|
|
struct psmouse *psmouse);
|
2013-02-14 06:22:08 +00:00
|
|
|
void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
|
|
|
|
|
2013-02-14 04:55:19 +00:00
|
|
|
int prev_fin;
|
|
|
|
int multi_packet;
|
|
|
|
unsigned char multi_data[6];
|
2014-07-26 05:43:35 +00:00
|
|
|
struct alps_fields f;
|
2011-11-08 03:53:36 +00:00
|
|
|
u8 quirks;
|
2009-12-15 16:39:50 +00:00
|
|
|
struct timer_list timer;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2011-11-08 03:53:36 +00:00
|
|
|
#define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
|
|
|
|
|
2007-03-10 06:39:54 +00:00
|
|
|
#ifdef CONFIG_MOUSE_PS2_ALPS
|
2009-09-10 02:13:20 +00:00
|
|
|
int alps_detect(struct psmouse *psmouse, bool set_properties);
|
2007-03-10 06:39:54 +00:00
|
|
|
int alps_init(struct psmouse *psmouse);
|
|
|
|
#else
|
2009-09-10 02:13:20 +00:00
|
|
|
inline int alps_detect(struct psmouse *psmouse, bool set_properties)
|
2007-03-10 06:39:54 +00:00
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
inline int alps_init(struct psmouse *psmouse)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_MOUSE_PS2_ALPS */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|