1e2ba5731SMauro Carvalho Chehab.. include:: <isonum.txt>
2e2ba5731SMauro Carvalho Chehab
3e2ba5731SMauro Carvalho Chehab===================
4e2ba5731SMauro Carvalho ChehabThe userio Protocol
5e2ba5731SMauro Carvalho Chehab===================
6e2ba5731SMauro Carvalho Chehab
7e2ba5731SMauro Carvalho Chehab
8e2ba5731SMauro Carvalho Chehab:Copyright: |copy| 2015 Stephen Chandler Paul <thatslyude@gmail.com>
9e2ba5731SMauro Carvalho Chehab
10e2ba5731SMauro Carvalho ChehabSponsored by Red Hat
11e2ba5731SMauro Carvalho Chehab
12e2ba5731SMauro Carvalho Chehab
13e2ba5731SMauro Carvalho ChehabIntroduction
14e2ba5731SMauro Carvalho Chehab=============
15e2ba5731SMauro Carvalho Chehab
16e2ba5731SMauro Carvalho ChehabThis module is intended to try to make the lives of input driver developers
17e2ba5731SMauro Carvalho Chehabeasier by allowing them to test various serio devices (mainly the various
18e2ba5731SMauro Carvalho Chehabtouchpads found on laptops) without having to have the physical device in front
19e2ba5731SMauro Carvalho Chehabof them. userio accomplishes this by allowing any privileged userspace program
20e2ba5731SMauro Carvalho Chehabto directly interact with the kernel's serio driver and control a virtual serio
21e2ba5731SMauro Carvalho Chehabport from there.
22e2ba5731SMauro Carvalho Chehab
23e2ba5731SMauro Carvalho ChehabUsage overview
24e2ba5731SMauro Carvalho Chehab==============
25e2ba5731SMauro Carvalho Chehab
26e2ba5731SMauro Carvalho ChehabIn order to interact with the userio kernel module, one simply opens the
27e2ba5731SMauro Carvalho Chehab/dev/userio character device in their applications. Commands are sent to the
28e2ba5731SMauro Carvalho Chehabkernel module by writing to the device, and any data received from the serio
29e2ba5731SMauro Carvalho Chehabdriver is read as-is from the /dev/userio device. All of the structures and
30e2ba5731SMauro Carvalho Chehabmacros you need to interact with the device are defined in <linux/userio.h> and
31e2ba5731SMauro Carvalho Chehab<linux/serio.h>.
32e2ba5731SMauro Carvalho Chehab
33e2ba5731SMauro Carvalho ChehabCommand Structure
34e2ba5731SMauro Carvalho Chehab=================
35e2ba5731SMauro Carvalho Chehab
36e2ba5731SMauro Carvalho ChehabThe struct used for sending commands to /dev/userio is as follows::
37e2ba5731SMauro Carvalho Chehab
38e2ba5731SMauro Carvalho Chehab	struct userio_cmd {
39e2ba5731SMauro Carvalho Chehab		__u8 type;
40e2ba5731SMauro Carvalho Chehab		__u8 data;
41e2ba5731SMauro Carvalho Chehab	};
42e2ba5731SMauro Carvalho Chehab
43e2ba5731SMauro Carvalho Chehab``type`` describes the type of command that is being sent. This can be any one
44e2ba5731SMauro Carvalho Chehabof the USERIO_CMD macros defined in <linux/userio.h>. ``data`` is the argument
45e2ba5731SMauro Carvalho Chehabthat goes along with the command. In the event that the command doesn't have an
46e2ba5731SMauro Carvalho Chehabargument, this field can be left untouched and will be ignored by the kernel.
47e2ba5731SMauro Carvalho ChehabEach command should be sent by writing the struct directly to the character
48e2ba5731SMauro Carvalho Chehabdevice. In the event that the command you send is invalid, an error will be
49e2ba5731SMauro Carvalho Chehabreturned by the character device and a more descriptive error will be printed
50e2ba5731SMauro Carvalho Chehabto the kernel log. Only one command can be sent at a time, any additional data
51e2ba5731SMauro Carvalho Chehabwritten to the character device after the initial command will be ignored.
52e2ba5731SMauro Carvalho Chehab
53e2ba5731SMauro Carvalho ChehabTo close the virtual serio port, just close /dev/userio.
54e2ba5731SMauro Carvalho Chehab
55e2ba5731SMauro Carvalho ChehabCommands
56e2ba5731SMauro Carvalho Chehab========
57e2ba5731SMauro Carvalho Chehab
58e2ba5731SMauro Carvalho ChehabUSERIO_CMD_REGISTER
59e2ba5731SMauro Carvalho Chehab~~~~~~~~~~~~~~~~~~~
60e2ba5731SMauro Carvalho Chehab
61e2ba5731SMauro Carvalho ChehabRegisters the port with the serio driver and begins transmitting data back and
62e2ba5731SMauro Carvalho Chehabforth. Registration can only be performed once a port type is set with
63e2ba5731SMauro Carvalho ChehabUSERIO_CMD_SET_PORT_TYPE. Has no argument.
64e2ba5731SMauro Carvalho Chehab
65e2ba5731SMauro Carvalho ChehabUSERIO_CMD_SET_PORT_TYPE
66e2ba5731SMauro Carvalho Chehab~~~~~~~~~~~~~~~~~~~~~~~~
67e2ba5731SMauro Carvalho Chehab
68e2ba5731SMauro Carvalho ChehabSets the type of port we're emulating, where ``data`` is the port type being
69e2ba5731SMauro Carvalho Chehabset. Can be any of the macros from <linux/serio.h>. For example: SERIO_8042
70e2ba5731SMauro Carvalho Chehabwould set the port type to be a normal PS/2 port.
71e2ba5731SMauro Carvalho Chehab
72e2ba5731SMauro Carvalho ChehabUSERIO_CMD_SEND_INTERRUPT
73e2ba5731SMauro Carvalho Chehab~~~~~~~~~~~~~~~~~~~~~~~~~
74e2ba5731SMauro Carvalho Chehab
75e2ba5731SMauro Carvalho ChehabSends an interrupt through the virtual serio port to the serio driver, where
76e2ba5731SMauro Carvalho Chehab``data`` is the interrupt data being sent.
77e2ba5731SMauro Carvalho Chehab
78e2ba5731SMauro Carvalho ChehabUserspace tools
79e2ba5731SMauro Carvalho Chehab===============
80e2ba5731SMauro Carvalho Chehab
81e2ba5731SMauro Carvalho ChehabThe userio userspace tools are able to record PS/2 devices using some of the
82e2ba5731SMauro Carvalho Chehabdebugging information from i8042, and play back the devices on /dev/userio. The
83e2ba5731SMauro Carvalho Chehablatest version of these tools can be found at:
84e2ba5731SMauro Carvalho Chehab
85e2ba5731SMauro Carvalho Chehab	https://github.com/Lyude/ps2emu
86