1#ifndef _LIBPS2_H
2#define _LIBPS2_H
3
4
5
6
7
8
9
10
11
12
13
14#define PS2_CMD_GETID 0x02f2
15#define PS2_CMD_RESET_BAT 0x02ff
16
17#define PS2_RET_BAT 0xaa
18#define PS2_RET_ID 0x00
19#define PS2_RET_ACK 0xfa
20#define PS2_RET_NAK 0xfe
21#define PS2_RET_ERR 0xfc
22
23#define PS2_FLAG_ACK 1
24#define PS2_FLAG_CMD 2
25#define PS2_FLAG_CMD1 4
26#define PS2_FLAG_WAITID 8
27#define PS2_FLAG_NAK 16
28
29struct ps2dev {
30 struct serio *serio;
31
32
33 struct mutex cmd_mutex;
34
35
36 wait_queue_head_t wait;
37
38 unsigned long flags;
39 unsigned char cmdbuf[8];
40 unsigned char cmdcnt;
41 unsigned char nak;
42};
43
44void ps2_init(struct ps2dev *ps2dev, struct serio *serio);
45int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout);
46void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout);
47void ps2_begin_command(struct ps2dev *ps2dev);
48void ps2_end_command(struct ps2dev *ps2dev);
49int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
50int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
51int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
52int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data);
53void ps2_cmd_aborted(struct ps2dev *ps2dev);
54int ps2_is_keyboard_id(char id);
55
56#endif
57