1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 #ifndef _LIBPS2_H 2 #ifndef _LIBPS2_H 3 #define _LIBPS2_H 3 #define _LIBPS2_H 4 4 5 /* 5 /* 6 * Copyright (C) 1999-2002 Vojtech Pavlik 6 * Copyright (C) 1999-2002 Vojtech Pavlik 7 * Copyright (C) 2004 Dmitry Torokhov 7 * Copyright (C) 2004 Dmitry Torokhov 8 */ 8 */ 9 9 10 #include <linux/bitops.h> 10 #include <linux/bitops.h> 11 #include <linux/interrupt.h> << 12 #include <linux/mutex.h> 11 #include <linux/mutex.h> 13 #include <linux/types.h> 12 #include <linux/types.h> 14 #include <linux/wait.h> 13 #include <linux/wait.h> 15 14 16 struct ps2dev; !! 15 #define PS2_CMD_SETSCALE11 0x00e6 >> 16 #define PS2_CMD_SETRES 0x10e8 >> 17 #define PS2_CMD_GETID 0x02f2 >> 18 #define PS2_CMD_RESET_BAT 0x02ff >> 19 >> 20 #define PS2_RET_BAT 0xaa >> 21 #define PS2_RET_ID 0x00 >> 22 #define PS2_RET_ACK 0xfa >> 23 #define PS2_RET_NAK 0xfe >> 24 #define PS2_RET_ERR 0xfc >> 25 >> 26 #define PS2_FLAG_ACK BIT(0) /* Waiting for ACK/NAK */ >> 27 #define PS2_FLAG_CMD BIT(1) /* Waiting for a command to finish */ >> 28 #define PS2_FLAG_CMD1 BIT(2) /* Waiting for the first byte of command response */ >> 29 #define PS2_FLAG_WAITID BIT(3) /* Command executing is GET ID */ >> 30 #define PS2_FLAG_NAK BIT(4) /* Last transmission was NAKed */ >> 31 #define PS2_FLAG_ACK_CMD BIT(5) /* Waiting to ACK the command (first) byte */ 17 32 18 /** << 19 * enum ps2_disposition - indicates how receiv << 20 * @PS2_PROCESS: pass to the main protocol han << 21 * @PS2_IGNORE: skip the byte << 22 * @PS2_ERROR: do not process the byte, abort << 23 */ << 24 enum ps2_disposition { << 25 PS2_PROCESS, << 26 PS2_IGNORE, << 27 PS2_ERROR, << 28 }; << 29 << 30 typedef enum ps2_disposition (*ps2_pre_receive << 31 << 32 typedef void (*ps2_receive_handler_t)(struct p << 33 << 34 /** << 35 * struct ps2dev - represents a device using P << 36 * @serio: a serio port used by the PS/2 devic << 37 * @cmd_mutex: a mutex ensuring that only one << 38 * @wait: a waitqueue used to signal completio << 39 * @flags: various internal flags indicating s << 40 * @cmdbuf: buffer holding command response << 41 * @cmdcnt: outstanding number of bytes of the << 42 * @nak: a byte transmitted by the device when << 43 * @pre_receive_handler: checks communication << 44 * (&enum ps2_disposition) of the received dat << 45 * @receive_handler: main handler of particula << 46 * or mouse protocol << 47 */ << 48 struct ps2dev { 33 struct ps2dev { 49 struct serio *serio; 34 struct serio *serio; >> 35 >> 36 /* Ensures that only one command is executing at a time */ 50 struct mutex cmd_mutex; 37 struct mutex cmd_mutex; >> 38 >> 39 /* Used to signal completion from interrupt handler */ 51 wait_queue_head_t wait; 40 wait_queue_head_t wait; >> 41 52 unsigned long flags; 42 unsigned long flags; 53 u8 cmdbuf[8]; 43 u8 cmdbuf[8]; 54 u8 cmdcnt; 44 u8 cmdcnt; 55 u8 nak; 45 u8 nak; 56 << 57 ps2_pre_receive_handler_t pre_receive_ << 58 ps2_receive_handler_t receive_handler; << 59 }; 46 }; 60 47 61 void ps2_init(struct ps2dev *ps2dev, struct se !! 48 void ps2_init(struct ps2dev *ps2dev, struct serio *serio); 62 ps2_pre_receive_handler_t pre_re << 63 ps2_receive_handler_t receive_ha << 64 int ps2_sendbyte(struct ps2dev *ps2dev, u8 byt 49 int ps2_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout); 65 void ps2_drain(struct ps2dev *ps2dev, size_t m 50 void ps2_drain(struct ps2dev *ps2dev, size_t maxbytes, unsigned int timeout); 66 void ps2_begin_command(struct ps2dev *ps2dev); 51 void ps2_begin_command(struct ps2dev *ps2dev); 67 void ps2_end_command(struct ps2dev *ps2dev); 52 void ps2_end_command(struct ps2dev *ps2dev); 68 int __ps2_command(struct ps2dev *ps2dev, u8 *p 53 int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command); 69 int ps2_command(struct ps2dev *ps2dev, u8 *par 54 int ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command); 70 int ps2_sliced_command(struct ps2dev *ps2dev, 55 int ps2_sliced_command(struct ps2dev *ps2dev, u8 command); >> 56 bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data); >> 57 bool ps2_handle_response(struct ps2dev *ps2dev, u8 data); >> 58 void ps2_cmd_aborted(struct ps2dev *ps2dev); 71 bool ps2_is_keyboard_id(u8 id); 59 bool ps2_is_keyboard_id(u8 id); 72 << 73 irqreturn_t ps2_interrupt(struct serio *serio, << 74 60 75 #endif /* _LIBPS2_H */ 61 #endif /* _LIBPS2_H */ 76 62
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.