psmouse.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef _PSMOUSE_H
  2. #define _PSMOUSE_H
  3. #define PSMOUSE_CMD_SETSCALE11 0x00e6
  4. #define PSMOUSE_CMD_SETSCALE21 0x00e7
  5. #define PSMOUSE_CMD_SETRES 0x10e8
  6. #define PSMOUSE_CMD_GETINFO 0x03e9
  7. #define PSMOUSE_CMD_SETSTREAM 0x00ea
  8. #define PSMOUSE_CMD_SETPOLL 0x00f0
  9. #define PSMOUSE_CMD_POLL 0x03eb
  10. #define PSMOUSE_CMD_GETID 0x02f2
  11. #define PSMOUSE_CMD_SETRATE 0x10f3
  12. #define PSMOUSE_CMD_ENABLE 0x00f4
  13. #define PSMOUSE_CMD_DISABLE 0x00f5
  14. #define PSMOUSE_CMD_RESET_DIS 0x00f6
  15. #define PSMOUSE_CMD_RESET_BAT 0x02ff
  16. #define PSMOUSE_RET_BAT 0xaa
  17. #define PSMOUSE_RET_ID 0x00
  18. #define PSMOUSE_RET_ACK 0xfa
  19. #define PSMOUSE_RET_NAK 0xfe
  20. enum psmouse_state {
  21. PSMOUSE_IGNORE,
  22. PSMOUSE_INITIALIZING,
  23. PSMOUSE_CMD_MODE,
  24. PSMOUSE_ACTIVATED,
  25. };
  26. /* psmouse protocol handler return codes */
  27. typedef enum {
  28. PSMOUSE_BAD_DATA,
  29. PSMOUSE_GOOD_DATA,
  30. PSMOUSE_FULL_PACKET
  31. } psmouse_ret_t;
  32. struct psmouse {
  33. void *private;
  34. struct input_dev dev;
  35. struct ps2dev ps2dev;
  36. char *vendor;
  37. char *name;
  38. unsigned char packet[8];
  39. unsigned char pktcnt;
  40. unsigned char pktsize;
  41. unsigned char type;
  42. unsigned int model;
  43. unsigned long last;
  44. unsigned long out_of_sync;
  45. enum psmouse_state state;
  46. char devname[64];
  47. char phys[32];
  48. unsigned int rate;
  49. unsigned int resolution;
  50. unsigned int resetafter;
  51. unsigned int smartscroll; /* Logitech only */
  52. psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse, struct pt_regs *regs);
  53. void (*set_rate)(struct psmouse *psmouse, unsigned int rate);
  54. void (*set_resolution)(struct psmouse *psmouse, unsigned int resolution);
  55. int (*reconnect)(struct psmouse *psmouse);
  56. void (*disconnect)(struct psmouse *psmouse);
  57. void (*pt_activate)(struct psmouse *psmouse);
  58. void (*pt_deactivate)(struct psmouse *psmouse);
  59. };
  60. enum psmouse_type {
  61. PSMOUSE_NONE,
  62. PSMOUSE_PS2,
  63. PSMOUSE_PS2PP,
  64. PSMOUSE_THINKPS,
  65. PSMOUSE_GENPS,
  66. PSMOUSE_IMPS,
  67. PSMOUSE_IMEX,
  68. PSMOUSE_SYNAPTICS,
  69. PSMOUSE_ALPS,
  70. PSMOUSE_LIFEBOOK,
  71. PSMOUSE_AUTO /* This one should always be last */
  72. };
  73. int psmouse_sliced_command(struct psmouse *psmouse, unsigned char command);
  74. int psmouse_reset(struct psmouse *psmouse);
  75. void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution);
  76. ssize_t psmouse_attr_show_helper(struct device *dev, char *buf,
  77. ssize_t (*handler)(struct psmouse *, char *));
  78. ssize_t psmouse_attr_set_helper(struct device *dev, const char *buf, size_t count,
  79. ssize_t (*handler)(struct psmouse *, const char *, size_t));
  80. #define PSMOUSE_DEFINE_ATTR(_name) \
  81. static ssize_t psmouse_attr_show_##_name(struct psmouse *, char *); \
  82. static ssize_t psmouse_attr_set_##_name(struct psmouse *, const char *, size_t);\
  83. static ssize_t psmouse_do_show_##_name(struct device *d, struct device_attribute *attr, char *b) \
  84. { \
  85. return psmouse_attr_show_helper(d, b, psmouse_attr_show_##_name); \
  86. } \
  87. static ssize_t psmouse_do_set_##_name(struct device *d, struct device_attribute *attr, const char *b, size_t s)\
  88. { \
  89. return psmouse_attr_set_helper(d, b, s, psmouse_attr_set_##_name); \
  90. } \
  91. static struct device_attribute psmouse_attr_##_name = \
  92. __ATTR(_name, S_IWUSR | S_IRUGO, \
  93. psmouse_do_show_##_name, psmouse_do_set_##_name);
  94. #endif /* _PSMOUSE_H */