alps.h 5.9 KB

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