~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/libps2.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 #ifndef _LIBPS2_H
  3 #define _LIBPS2_H
  4 
  5 /*
  6  * Copyright (C) 1999-2002 Vojtech Pavlik
  7  * Copyright (C) 2004 Dmitry Torokhov
  8  */
  9 
 10 #include <linux/bitops.h>
 11 #include <linux/interrupt.h>
 12 #include <linux/mutex.h>
 13 #include <linux/types.h>
 14 #include <linux/wait.h>
 15 
 16 struct ps2dev;
 17 
 18 /**
 19  * enum ps2_disposition - indicates how received byte should be handled
 20  * @PS2_PROCESS: pass to the main protocol handler, process normally
 21  * @PS2_IGNORE: skip the byte
 22  * @PS2_ERROR: do not process the byte, abort command in progress
 23  */
 24 enum ps2_disposition {
 25         PS2_PROCESS,
 26         PS2_IGNORE,
 27         PS2_ERROR,
 28 };
 29 
 30 typedef enum ps2_disposition (*ps2_pre_receive_handler_t)(struct ps2dev *, u8,
 31                                                           unsigned int);
 32 typedef void (*ps2_receive_handler_t)(struct ps2dev *, u8);
 33 
 34 /**
 35  * struct ps2dev - represents a device using PS/2 protocol
 36  * @serio: a serio port used by the PS/2 device
 37  * @cmd_mutex: a mutex ensuring that only one command is executing at a time
 38  * @wait: a waitqueue used to signal completion from the serio interrupt handler
 39  * @flags: various internal flags indicating stages of PS/2 command execution
 40  * @cmdbuf: buffer holding command response
 41  * @cmdcnt: outstanding number of bytes of the command response
 42  * @nak: a byte transmitted by the device when it refuses command
 43  * @pre_receive_handler: checks communication errors and returns disposition
 44  * (&enum ps2_disposition) of the received data byte
 45  * @receive_handler: main handler of particular PS/2 protocol, such as keyboard
 46  *   or mouse protocol
 47  */
 48 struct ps2dev {
 49         struct serio *serio;
 50         struct mutex cmd_mutex;
 51         wait_queue_head_t wait;
 52         unsigned long flags;
 53         u8 cmdbuf[8];
 54         u8 cmdcnt;
 55         u8 nak;
 56 
 57         ps2_pre_receive_handler_t pre_receive_handler;
 58         ps2_receive_handler_t receive_handler;
 59 };
 60 
 61 void ps2_init(struct ps2dev *ps2dev, struct serio *serio,
 62               ps2_pre_receive_handler_t pre_receive_handler,
 63               ps2_receive_handler_t receive_handler);
 64 int ps2_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout);
 65 void ps2_drain(struct ps2dev *ps2dev, size_t maxbytes, unsigned int timeout);
 66 void ps2_begin_command(struct ps2dev *ps2dev);
 67 void ps2_end_command(struct ps2dev *ps2dev);
 68 int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command);
 69 int ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command);
 70 int ps2_sliced_command(struct ps2dev *ps2dev, u8 command);
 71 bool ps2_is_keyboard_id(u8 id);
 72 
 73 irqreturn_t ps2_interrupt(struct serio *serio, u8 data, unsigned int flags);
 74 
 75 #endif /* _LIBPS2_H */
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php