alps.h 5.9 KB

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