elantech.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Elantech Touchpad driver (v6)
  3. *
  4. * Copyright (C) 2007-2009 Arjan Opmeer <arjan@opmeer.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  9. *
  10. * Trademarks are the property of their respective owners.
  11. */
  12. #ifndef _ELANTECH_H
  13. #define _ELANTECH_H
  14. /*
  15. * Command values for Synaptics style queries
  16. */
  17. #define ETP_FW_ID_QUERY 0x00
  18. #define ETP_FW_VERSION_QUERY 0x01
  19. #define ETP_CAPABILITIES_QUERY 0x02
  20. #define ETP_SAMPLE_QUERY 0x03
  21. /*
  22. * Command values for register reading or writing
  23. */
  24. #define ETP_REGISTER_READ 0x10
  25. #define ETP_REGISTER_WRITE 0x11
  26. #define ETP_REGISTER_READWRITE 0x00
  27. /*
  28. * Hardware version 2 custom PS/2 command value
  29. */
  30. #define ETP_PS2_CUSTOM_COMMAND 0xf8
  31. /*
  32. * Times to retry a ps2_command and millisecond delay between tries
  33. */
  34. #define ETP_PS2_COMMAND_TRIES 3
  35. #define ETP_PS2_COMMAND_DELAY 500
  36. /*
  37. * Times to try to read back a register and millisecond delay between tries
  38. */
  39. #define ETP_READ_BACK_TRIES 5
  40. #define ETP_READ_BACK_DELAY 2000
  41. /*
  42. * Register bitmasks for hardware version 1
  43. */
  44. #define ETP_R10_ABSOLUTE_MODE 0x04
  45. #define ETP_R11_4_BYTE_MODE 0x02
  46. /*
  47. * Capability bitmasks
  48. */
  49. #define ETP_CAP_HAS_ROCKER 0x04
  50. /*
  51. * One hard to find application note states that X axis range is 0 to 576
  52. * and Y axis range is 0 to 384 for harware version 1.
  53. * Edge fuzz might be necessary because of bezel around the touchpad
  54. */
  55. #define ETP_EDGE_FUZZ_V1 32
  56. #define ETP_XMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1)
  57. #define ETP_XMAX_V1 (576 - ETP_EDGE_FUZZ_V1)
  58. #define ETP_YMIN_V1 ( 0 + ETP_EDGE_FUZZ_V1)
  59. #define ETP_YMAX_V1 (384 - ETP_EDGE_FUZZ_V1)
  60. /*
  61. * The resolution for older v2 hardware doubled.
  62. * (newer v2's firmware provides command so we can query)
  63. */
  64. #define ETP_XMIN_V2 0
  65. #define ETP_XMAX_V2 1152
  66. #define ETP_YMIN_V2 0
  67. #define ETP_YMAX_V2 768
  68. #define ETP_PMIN_V2 0
  69. #define ETP_PMAX_V2 255
  70. #define ETP_WMIN_V2 0
  71. #define ETP_WMAX_V2 15
  72. /*
  73. * v3 hardware has 2 kinds of packet types,
  74. * v4 hardware has 3.
  75. */
  76. #define PACKET_UNKNOWN 0x01
  77. #define PACKET_DEBOUNCE 0x02
  78. #define PACKET_V3_HEAD 0x03
  79. #define PACKET_V3_TAIL 0x04
  80. #define PACKET_V4_HEAD 0x05
  81. #define PACKET_V4_MOTION 0x06
  82. #define PACKET_V4_STATUS 0x07
  83. /*
  84. * track up to 5 fingers for v4 hardware
  85. */
  86. #define ETP_MAX_FINGERS 5
  87. /*
  88. * weight value for v4 hardware
  89. */
  90. #define ETP_WEIGHT_VALUE 5
  91. /*
  92. * The base position for one finger, v4 hardware
  93. */
  94. struct finger_pos {
  95. unsigned int x;
  96. unsigned int y;
  97. };
  98. struct elantech_data {
  99. unsigned char reg_07;
  100. unsigned char reg_10;
  101. unsigned char reg_11;
  102. unsigned char reg_20;
  103. unsigned char reg_21;
  104. unsigned char reg_22;
  105. unsigned char reg_23;
  106. unsigned char reg_24;
  107. unsigned char reg_25;
  108. unsigned char reg_26;
  109. unsigned char debug;
  110. unsigned char capabilities[3];
  111. bool paritycheck;
  112. bool jumpy_cursor;
  113. bool reports_pressure;
  114. unsigned char hw_version;
  115. unsigned int fw_version;
  116. unsigned int single_finger_reports;
  117. unsigned int y_max;
  118. unsigned int width;
  119. struct finger_pos mt[ETP_MAX_FINGERS];
  120. unsigned char parity[256];
  121. };
  122. #ifdef CONFIG_MOUSE_PS2_ELANTECH
  123. int elantech_detect(struct psmouse *psmouse, bool set_properties);
  124. int elantech_init(struct psmouse *psmouse);
  125. #else
  126. static inline int elantech_detect(struct psmouse *psmouse, bool set_properties)
  127. {
  128. return -ENOSYS;
  129. }
  130. static inline int elantech_init(struct psmouse *psmouse)
  131. {
  132. return -ENOSYS;
  133. }
  134. #endif /* CONFIG_MOUSE_PS2_ELANTECH */
  135. #endif