libps2.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_FLAG_ACK 1 /* Waiting for ACK/NAK */
  18. #define PS2_FLAG_CMD 2 /* Waiting for command to finish */
  19. #define PS2_FLAG_CMD1 4 /* Waiting for the first byte of command response */
  20. #define PS2_FLAG_WAITID 8 /* Command execiting is GET ID */
  21. struct ps2dev {
  22. struct serio *serio;
  23. /* Ensures that only one command is executing at a time */
  24. struct mutex cmd_mutex;
  25. /* Used to signal completion from interrupt handler */
  26. wait_queue_head_t wait;
  27. unsigned long flags;
  28. unsigned char cmdbuf[6];
  29. unsigned char cmdcnt;
  30. unsigned char nak;
  31. };
  32. void ps2_init(struct ps2dev *ps2dev, struct serio *serio);
  33. int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout);
  34. void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout);
  35. int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
  36. int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int command);
  37. int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
  38. int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data);
  39. void ps2_cmd_aborted(struct ps2dev *ps2dev);
  40. int ps2_is_keyboard_id(char id);
  41. #endif /* _LIBPS2_H */