]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/input/lib/include/linux/libps2.h
Inital import
[l4.git] / l4 / pkg / input / lib / include / linux / libps2.h
1 #ifndef _LIBPS2_H
2 #define _LIBPS2_H
3
4 /*
5  * Copyright (C) 1999-2002 Vojtech Pavlik
6  * Copyright (C) 2004 Dmitry Torokhov
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License version 2 as published by
10  * the Free Software Foundation.
11  */
12
13 #define PS2_CMD_GETID           0x02f2
14 #define PS2_CMD_RESET_BAT       0x02ff
15
16 #define PS2_RET_BAT             0xaa
17 #define PS2_RET_ID              0x00
18 #define PS2_RET_ACK             0xfa
19 #define PS2_RET_NAK             0xfe
20
21 #define PS2_FLAG_ACK            1       /* Waiting for ACK/NAK */
22 #define PS2_FLAG_CMD            2       /* Waiting for command to finish */
23 #define PS2_FLAG_CMD1           4       /* Waiting for the first byte of command response */
24 #define PS2_FLAG_WAITID         8       /* Command execiting is GET ID */
25
26 struct ps2dev {
27         struct serio *serio;
28
29         /* Ensures that only one command is executing at a time */
30         struct semaphore cmd_sem;
31
32         /* Used to signal completion from interrupt handler */
33         wait_queue_head_t wait;
34
35         unsigned long flags;
36         unsigned char cmdbuf[6];
37         unsigned char cmdcnt;
38         unsigned char nak;
39 };
40
41 void ps2_init(struct ps2dev *ps2dev, struct serio *serio);
42 int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout);
43 int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command);
44 int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int command);
45 int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
46 int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data);
47 void ps2_cmd_aborted(struct ps2dev *ps2dev);
48
49 #endif /* _LIBPS2_H */