libps2.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef _LIBPS2_H
  2. #define _LIBPS2_H
  3. /*
  4. * Copyright (C) 1999-2002 Vojtech Pavlik
  5. * Copyright (C) 2004 Dmitry Torokhov
  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. #define PS2_CMD_GETID 0x02f2
  12. #define PS2_CMD_RESET_BAT 0x02ff
  13. #define PS2_RET_BAT 0xaa
  14. #define PS2_RET_ID 0x00
  15. #define PS2_RET_ACK 0xfa
  16. #define PS2_RET_NAK 0xfe
  17. #define PS2_RET_ERR 0xfc
  18. #define PS2_FLAG_ACK 1 /* Waiting for ACK/NAK */
  19. #define PS2_FLAG_CMD 2 /* Waiting for command to finish */
  20. #define PS2_FLAG_CMD1 4 /* Waiting for the first byte of command response */
  21. #define PS2_FLAG_WAITID 8 /* Command execiting is GET ID */
  22. #define PS2_FLAG_NAK 16 /* Last transmission was NAKed */
  23. struct ps2dev {
  24. struct serio *serio;
  25. /* Ensures that only one command is executing at a time */
  26. struct mutex cmd_mutex;
  27. /* Used to signal completion from interrupt handler */
  28. wait_queue_head_t wait;
  29. unsigned long flags;
  30. unsigned char cmdbuf[8];
  31. unsigned char cmdcnt;
  32. unsigned char nak;
  33. };
  34. void ps2_init(struct ps2dev *ps2dev, struct serio *serio);
  35. int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout);
  36. void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout);
  37. void ps2_begin_command(struct ps2dev *ps2dev);
  38. void ps2_end_command(struct ps2dev *ps2dev);
  39. int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
  40. int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
  41. int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
  42. int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data);
  43. void ps2_cmd_aborted(struct ps2dev *ps2dev);
  44. int ps2_is_keyboard_id(char id);
  45. #endif /* _LIBPS2_H */