• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/input/serio/

Lines Matching defs:ps2dev

38 int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout)
40 serio_pause_rx(ps2dev->serio);
41 ps2dev->nak = 1;
42 ps2dev->flags |= PS2_FLAG_ACK;
43 serio_continue_rx(ps2dev->serio);
45 if (serio_write(ps2dev->serio, byte) == 0)
46 wait_event_timeout(ps2dev->wait,
47 !(ps2dev->flags & PS2_FLAG_ACK),
50 serio_pause_rx(ps2dev->serio);
51 ps2dev->flags &= ~PS2_FLAG_ACK;
52 serio_continue_rx(ps2dev->serio);
54 return -ps2dev->nak;
58 void ps2_begin_command(struct ps2dev *ps2dev)
60 mutex_lock(&ps2dev->cmd_mutex);
62 if (i8042_check_port_owner(ps2dev->serio))
67 void ps2_end_command(struct ps2dev *ps2dev)
69 if (i8042_check_port_owner(ps2dev->serio))
72 mutex_unlock(&ps2dev->cmd_mutex);
81 void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout)
83 if (maxbytes > sizeof(ps2dev->cmdbuf)) {
85 maxbytes = sizeof(ps2dev->cmdbuf);
88 ps2_begin_command(ps2dev);
90 serio_pause_rx(ps2dev->serio);
91 ps2dev->flags = PS2_FLAG_CMD;
92 ps2dev->cmdcnt = maxbytes;
93 serio_continue_rx(ps2dev->serio);
95 wait_event_timeout(ps2dev->wait,
96 !(ps2dev->flags & PS2_FLAG_CMD),
99 ps2_end_command(ps2dev);
129 static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout)
151 if (ps2dev->cmdbuf[1] == 0xaa) {
152 serio_pause_rx(ps2dev->serio);
153 ps2dev->flags = 0;
154 serio_continue_rx(ps2dev->serio);
162 if (!ps2_is_keyboard_id(ps2dev->cmdbuf[1])) {
163 serio_pause_rx(ps2dev->serio);
164 ps2dev->flags = ps2dev->cmdcnt = 0;
165 serio_continue_rx(ps2dev->serio);
184 int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
192 if (receive > sizeof(ps2dev->cmdbuf)) {
202 serio_pause_rx(ps2dev->serio);
203 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;
204 ps2dev->cmdcnt = receive;
207 ps2dev->cmdbuf[(receive - 1) - i] = param[i];
208 serio_continue_rx(ps2dev->serio);
215 if (ps2_sendbyte(ps2dev, command & 0xff,
220 if (ps2_sendbyte(ps2dev, param[i], 200))
228 timeout = wait_event_timeout(ps2dev->wait,
229 !(ps2dev->flags & PS2_FLAG_CMD1), timeout);
231 if (ps2dev->cmdcnt && !(ps2dev->flags & PS2_FLAG_CMD1)) {
233 timeout = ps2_adjust_timeout(ps2dev, command, timeout);
234 wait_event_timeout(ps2dev->wait,
235 !(ps2dev->flags & PS2_FLAG_CMD), timeout);
240 param[i] = ps2dev->cmdbuf[(receive - 1) - i];
242 if (ps2dev->cmdcnt && (command != PS2_CMD_RESET_BAT || ps2dev->cmdcnt != 1))
248 serio_pause_rx(ps2dev->serio);
249 ps2dev->flags = 0;
250 serio_continue_rx(ps2dev->serio);
256 int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
260 ps2_begin_command(ps2dev);
261 rc = __ps2_command(ps2dev, param, command);
262 ps2_end_command(ps2dev);
269 * ps2_init() initializes ps2dev structure
272 void ps2_init(struct ps2dev *ps2dev, struct serio *serio)
274 mutex_init(&ps2dev->cmd_mutex);
275 lockdep_set_subclass(&ps2dev->cmd_mutex, serio->depth);
276 init_waitqueue_head(&ps2dev->wait);
277 ps2dev->serio = serio;
286 int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data)
290 ps2dev->nak = 0;
294 ps2dev->flags |= PS2_FLAG_NAK;
295 ps2dev->nak = PS2_RET_NAK;
299 if (ps2dev->flags & PS2_FLAG_NAK) {
300 ps2dev->flags &= ~PS2_FLAG_NAK;
301 ps2dev->nak = PS2_RET_ERR;
308 if (ps2dev->flags & PS2_FLAG_WAITID) {
309 ps2dev->nak = 0;
318 if (!ps2dev->nak) {
319 ps2dev->flags &= ~PS2_FLAG_NAK;
320 if (ps2dev->cmdcnt)
321 ps2dev->flags |= PS2_FLAG_CMD | PS2_FLAG_CMD1;
324 ps2dev->flags &= ~PS2_FLAG_ACK;
325 wake_up(&ps2dev->wait);
328 ps2_handle_response(ps2dev, data);
340 int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data)
342 if (ps2dev->cmdcnt)
343 ps2dev->cmdbuf[--ps2dev->cmdcnt] = data;
345 if (ps2dev->flags & PS2_FLAG_CMD1) {
346 ps2dev->flags &= ~PS2_FLAG_CMD1;
347 if (ps2dev->cmdcnt)
348 wake_up(&ps2dev->wait);
351 if (!ps2dev->cmdcnt) {
352 ps2dev->flags &= ~PS2_FLAG_CMD;
353 wake_up(&ps2dev->wait);
360 void ps2_cmd_aborted(struct ps2dev *ps2dev)
362 if (ps2dev->flags & PS2_FLAG_ACK)
363 ps2dev->nak = 1;
365 if (ps2dev->flags & (PS2_FLAG_ACK | PS2_FLAG_CMD))
366 wake_up(&ps2dev->wait);
369 ps2dev->flags &= PS2_FLAG_NAK;