Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
[qemu/kevin.git] / include / hw / virtio / virtio-input.h
blobe69c0aeca382013975e4a8cb15ae4e0eef9d51bc
1 #ifndef QEMU_VIRTIO_INPUT_H
2 #define QEMU_VIRTIO_INPUT_H
4 #include "hw/virtio/vhost-user.h"
5 #include "hw/virtio/vhost-user-base.h"
6 #include "ui/input.h"
7 #include "sysemu/vhost-user-backend.h"
9 /* ----------------------------------------------------------------- */
10 /* virtio input protocol */
12 #include "standard-headers/linux/virtio_ids.h"
13 #include "standard-headers/linux/virtio_input.h"
14 #include "qom/object.h"
16 typedef struct virtio_input_absinfo virtio_input_absinfo;
17 typedef struct virtio_input_config virtio_input_config;
18 typedef struct virtio_input_event virtio_input_event;
20 /* ----------------------------------------------------------------- */
21 /* qemu internals */
23 #define TYPE_VIRTIO_INPUT "virtio-input-device"
24 OBJECT_DECLARE_TYPE(VirtIOInput, VirtIOInputClass,
25 VIRTIO_INPUT)
26 #define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \
27 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT)
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"
33 #define TYPE_VIRTIO_MULTITOUCH "virtio-multitouch-device"
35 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHID, VIRTIO_INPUT_HID)
36 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
37 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
39 #define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
40 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHost, VIRTIO_INPUT_HOST)
41 #define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
42 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
44 #define TYPE_VHOST_USER_INPUT "vhost-user-input"
45 OBJECT_DECLARE_SIMPLE_TYPE(VHostUserInput, VHOST_USER_INPUT)
46 #define VHOST_USER_INPUT_GET_PARENT_CLASS(obj) \
47 OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT)
49 typedef struct VirtIOInputConfig VirtIOInputConfig;
51 struct VirtIOInputConfig {
52 virtio_input_config config;
53 QTAILQ_ENTRY(VirtIOInputConfig) node;
56 struct 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;
63 char *serial;
65 struct {
66 virtio_input_event event;
67 VirtQueueElement *elem;
68 } *queue;
69 uint32_t qindex, qsize;
71 bool active;
74 struct VirtIOInputClass {
75 /*< private >*/
76 VirtioDeviceClass parent;
77 /*< public >*/
79 DeviceRealize realize;
80 DeviceUnrealize unrealize;
81 void (*change_active)(VirtIOInput *vinput);
82 void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
85 struct VirtIOInputHID {
86 VirtIOInput parent_obj;
87 char *display;
88 uint32_t head;
89 const QemuInputHandler *handler;
90 QemuInputHandlerState *hs;
91 int ledstate;
92 bool wheel_axis;
95 struct VirtIOInputHost {
96 VirtIOInput parent_obj;
97 char *evdev;
98 int fd;
101 struct VHostUserInput {
102 VHostUserBase parent_obj;
105 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
106 void virtio_input_init_config(VirtIOInput *vinput,
107 virtio_input_config *config);
108 virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
109 uint8_t select,
110 uint8_t subsel);
111 void virtio_input_add_config(VirtIOInput *vinput,
112 virtio_input_config *config);
113 void virtio_input_idstr_config(VirtIOInput *vinput,
114 uint8_t select, const char *string);
116 #endif /* QEMU_VIRTIO_INPUT_H */