]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/virtio/virtio-input.h
virtio-input: fix eventq batching
[mirror_qemu.git] / include / hw / virtio / virtio-input.h
CommitLineData
2a6a4076
MA
1#ifndef QEMU_VIRTIO_INPUT_H
2#define QEMU_VIRTIO_INPUT_H
f73ddbad
GH
3
4#include "ui/input.h"
5
6/* ----------------------------------------------------------------- */
7/* virtio input protocol */
8
9#include "standard-headers/linux/virtio_ids.h"
10#include "standard-headers/linux/virtio_input.h"
11
12typedef struct virtio_input_absinfo virtio_input_absinfo;
13typedef struct virtio_input_config virtio_input_config;
14typedef struct virtio_input_event virtio_input_event;
15
f73ddbad
GH
16/* ----------------------------------------------------------------- */
17/* qemu internals */
18
19#define TYPE_VIRTIO_INPUT "virtio-input-device"
20#define VIRTIO_INPUT(obj) \
21 OBJECT_CHECK(VirtIOInput, (obj), TYPE_VIRTIO_INPUT)
22#define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \
23 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT)
24#define VIRTIO_INPUT_GET_CLASS(obj) \
25 OBJECT_GET_CLASS(VirtIOInputClass, obj, TYPE_VIRTIO_INPUT)
26#define VIRTIO_INPUT_CLASS(klass) \
27 OBJECT_CLASS_CHECK(VirtIOInputClass, klass, TYPE_VIRTIO_INPUT)
28
e63d114b
GH
29#define TYPE_VIRTIO_INPUT_HID "virtio-input-hid-device"
30#define TYPE_VIRTIO_KEYBOARD "virtio-keyboard-device"
31#define TYPE_VIRTIO_MOUSE "virtio-mouse-device"
32#define TYPE_VIRTIO_TABLET "virtio-tablet-device"
55a1d80a
GH
33
34#define VIRTIO_INPUT_HID(obj) \
35 OBJECT_CHECK(VirtIOInputHID, (obj), TYPE_VIRTIO_INPUT_HID)
36#define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
37 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
38
006a5ede
GH
39#define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
40#define VIRTIO_INPUT_HOST(obj) \
41 OBJECT_CHECK(VirtIOInputHost, (obj), TYPE_VIRTIO_INPUT_HOST)
42#define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
43 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
44
f73ddbad
GH
45typedef struct VirtIOInput VirtIOInput;
46typedef struct VirtIOInputClass VirtIOInputClass;
47typedef struct VirtIOInputConfig VirtIOInputConfig;
55a1d80a 48typedef struct VirtIOInputHID VirtIOInputHID;
006a5ede 49typedef struct VirtIOInputHost VirtIOInputHost;
f73ddbad 50
f73ddbad
GH
51struct VirtIOInputConfig {
52 virtio_input_config config;
53 QTAILQ_ENTRY(VirtIOInputConfig) node;
54};
55
56struct VirtIOInput {
57 VirtIODevice parent_obj;
58 uint8_t cfg_select;
59 uint8_t cfg_subsel;
60 uint32_t cfg_size;
61 QTAILQ_HEAD(, VirtIOInputConfig) cfg_list;
62 VirtQueue *evt, *sts;
6f2b9a5b 63 char *serial;
f73ddbad 64
57094547
LP
65 struct {
66 virtio_input_event event;
67 VirtQueueElement *elem;
68 } *queue;
f73ddbad
GH
69 uint32_t qindex, qsize;
70
71 bool active;
72};
73
74struct VirtIOInputClass {
75 /*< private >*/
76 VirtioDeviceClass parent;
77 /*< public >*/
78
79 DeviceRealize realize;
80 DeviceUnrealize unrealize;
81 void (*change_active)(VirtIOInput *vinput);
82 void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
83};
84
55a1d80a
GH
85struct VirtIOInputHID {
86 VirtIOInput parent_obj;
5cce1733
GH
87 char *display;
88 uint32_t head;
55a1d80a
GH
89 QemuInputHandler *handler;
90 QemuInputHandlerState *hs;
91 int ledstate;
92};
93
006a5ede
GH
94struct VirtIOInputHost {
95 VirtIOInput parent_obj;
96 char *evdev;
97 int fd;
98};
99
f73ddbad
GH
100void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
101void virtio_input_init_config(VirtIOInput *vinput,
102 virtio_input_config *config);
b065e275
LP
103virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
104 uint8_t select,
105 uint8_t subsel);
f73ddbad
GH
106void virtio_input_add_config(VirtIOInput *vinput,
107 virtio_input_config *config);
108void virtio_input_idstr_config(VirtIOInput *vinput,
109 uint8_t select, const char *string);
110
2a6a4076 111#endif /* QEMU_VIRTIO_INPUT_H */