alps.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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_data - private data structure for the ALPS driver
  59. * @dev2: "Relative" device used to report trackstick or mouse activity.
  60. * @phys: Physical path for the relative device.
  61. * @nibble_commands: Command mapping used for touchpad register accesses.
  62. * @addr_command: Command used to tell the touchpad that a register address
  63. * follows.
  64. * @proto_version: Indicates V1/V2/V3/...
  65. * @byte0: Helps figure out whether a position report packet matches the
  66. * known format for this model. The first byte of the report, ANDed with
  67. * mask0, should match byte0.
  68. * @mask0: The mask used to check the first byte of the report.
  69. * @flags: Additional device capabilities (passthrough port, trackstick, etc.).
  70. * @hw_init: Protocol-specific hardware init function.
  71. * @process_packet: Protocol-specific function to process a report packet.
  72. * @set_abs_params: Protocol-specific function to configure the input_dev.
  73. * @prev_fin: Finger bit from previous packet.
  74. * @multi_packet: Multi-packet data in progress.
  75. * @multi_data: Saved multi-packet data.
  76. * @x1: First X coordinate from last MT report.
  77. * @x2: Second X coordinate from last MT report.
  78. * @y1: First Y coordinate from last MT report.
  79. * @y2: Second Y coordinate from last MT report.
  80. * @fingers: Number of fingers from last MT report.
  81. * @quirks: Bitmap of ALPS_QUIRK_*.
  82. * @timer: Timer for flushing out the final report packet in the stream.
  83. */
  84. struct alps_data {
  85. struct input_dev *dev2;
  86. char phys[32];
  87. /* these are autodetected when the device is identified */
  88. const struct alps_nibble_commands *nibble_commands;
  89. int addr_command;
  90. unsigned char proto_version;
  91. unsigned char byte0, mask0;
  92. unsigned char flags;
  93. int (*hw_init)(struct psmouse *psmouse);
  94. void (*process_packet)(struct psmouse *psmouse);
  95. void (*set_abs_params)(struct alps_data *priv, struct input_dev *dev1);
  96. int prev_fin;
  97. int multi_packet;
  98. unsigned char multi_data[6];
  99. int x1, x2, y1, y2;
  100. int fingers;
  101. u8 quirks;
  102. struct timer_list timer;
  103. };
  104. #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */
  105. #ifdef CONFIG_MOUSE_PS2_ALPS
  106. int alps_detect(struct psmouse *psmouse, bool set_properties);
  107. int alps_init(struct psmouse *psmouse);
  108. #else
  109. inline int alps_detect(struct psmouse *psmouse, bool set_properties)
  110. {
  111. return -ENOSYS;
  112. }
  113. inline int alps_init(struct psmouse *psmouse)
  114. {
  115. return -ENOSYS;
  116. }
  117. #endif /* CONFIG_MOUSE_PS2_ALPS */
  118. #endif