blob: f780c77931fe086dcc5f21648e0aac56566dec63 [file] [log] [blame]
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -07001.. include:: <isonum.txt>
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -07002
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -07003===================
4The userio Protocol
5===================
6
7
8:Copyright: |copy| 2015 Stephen Chandler Paul <thatslyude@gmail.com>
9
10Sponsored by Red Hat
11
12
13Introduction
14=============
15
16This module is intended to try to make the lives of input driver developers
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070017easier by allowing them to test various serio devices (mainly the various
18touchpads found on laptops) without having to have the physical device in front
19of them. userio accomplishes this by allowing any privileged userspace program
20to directly interact with the kernel's serio driver and control a virtual serio
21port from there.
22
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070023Usage overview
24==============
25
26In order to interact with the userio kernel module, one simply opens the
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070027/dev/userio character device in their applications. Commands are sent to the
28kernel module by writing to the device, and any data received from the serio
29driver is read as-is from the /dev/userio device. All of the structures and
30macros you need to interact with the device are defined in <linux/userio.h> and
31<linux/serio.h>.
32
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070033Command Structure
34=================
35
36The struct used for sending commands to /dev/userio is as follows::
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070037
38 struct userio_cmd {
39 __u8 type;
40 __u8 data;
41 };
42
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070043``type`` describes the type of command that is being sent. This can be any one
44of the USERIO_CMD macros defined in <linux/userio.h>. ``data`` is the argument
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070045that goes along with the command. In the event that the command doesn't have an
46argument, this field can be left untouched and will be ignored by the kernel.
47Each command should be sent by writing the struct directly to the character
48device. In the event that the command you send is invalid, an error will be
49returned by the character device and a more descriptive error will be printed
50to the kernel log. Only one command can be sent at a time, any additional data
51written to the character device after the initial command will be ignored.
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070052
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070053To close the virtual serio port, just close /dev/userio.
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070054
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070055Commands
56========
57
58USERIO_CMD_REGISTER
59~~~~~~~~~~~~~~~~~~~
60
61Registers the port with the serio driver and begins transmitting data back and
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070062forth. Registration can only be performed once a port type is set with
63USERIO_CMD_SET_PORT_TYPE. Has no argument.
64
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070065USERIO_CMD_SET_PORT_TYPE
66~~~~~~~~~~~~~~~~~~~~~~~~
67
68Sets the type of port we're emulating, where ``data`` is the port type being
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070069set. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042
70would set the port type to be a normal PS/2 port.
71
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070072USERIO_CMD_SEND_INTERRUPT
73~~~~~~~~~~~~~~~~~~~~~~~~~
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070074
Mauro Carvalho Chehab730518f2017-04-04 17:48:53 -070075Sends an interrupt through the virtual serio port to the serio driver, where
76``data`` is the interrupt data being sent.
77
78Userspace tools
79===============
80
81The userio userspace tools are able to record PS/2 devices using some of the
Stephen Chandler Paul5523662e2015-10-24 13:10:29 -070082debugging information from i8042, and play back the devices on /dev/userio. The
83latest version of these tools can be found at:
84
85 https://github.com/Lyude/ps2emu