MAINTAINERS: Make section QOM cover hw/core/*bus.c as well
[qemu/armbru.git] / include / hw / virtio / virtio-input.h
blob4fca03e7969ee1e78588a8c53605cc80f9f0ba13
1 #ifndef QEMU_VIRTIO_INPUT_H
2 #define QEMU_VIRTIO_INPUT_H
4 #include "ui/input.h"
5 #include "sysemu/vhost-user-backend.h"
7 /* ----------------------------------------------------------------- */
8 /* virtio input protocol */
10 #include "standard-headers/linux/virtio_ids.h"
11 #include "standard-headers/linux/virtio_input.h"
13 typedef struct virtio_input_absinfo virtio_input_absinfo;
14 typedef struct virtio_input_config virtio_input_config;
15 typedef struct virtio_input_event virtio_input_event;
17 /* ----------------------------------------------------------------- */
18 /* qemu internals */
20 #define TYPE_VIRTIO_INPUT "virtio-input-device"
21 #define VIRTIO_INPUT(obj) \
22 OBJECT_CHECK(VirtIOInput, (obj), TYPE_VIRTIO_INPUT)
23 #define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \
24 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT)
25 #define VIRTIO_INPUT_GET_CLASS(obj) \
26 OBJECT_GET_CLASS(VirtIOInputClass, obj, TYPE_VIRTIO_INPUT)
27 #define VIRTIO_INPUT_CLASS(klass) \
28 OBJECT_CLASS_CHECK(VirtIOInputClass, klass, TYPE_VIRTIO_INPUT)
30 #define TYPE_VIRTIO_INPUT_HID "virtio-input-hid-device"
31 #define TYPE_VIRTIO_KEYBOARD "virtio-keyboard-device"
32 #define TYPE_VIRTIO_MOUSE "virtio-mouse-device"
33 #define TYPE_VIRTIO_TABLET "virtio-tablet-device"
35 #define VIRTIO_INPUT_HID(obj) \
36 OBJECT_CHECK(VirtIOInputHID, (obj), TYPE_VIRTIO_INPUT_HID)
37 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
38 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
40 #define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
41 #define VIRTIO_INPUT_HOST(obj) \
42 OBJECT_CHECK(VirtIOInputHost, (obj), TYPE_VIRTIO_INPUT_HOST)
43 #define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
44 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
46 #define TYPE_VHOST_USER_INPUT "vhost-user-input"
47 #define VHOST_USER_INPUT(obj) \
48 OBJECT_CHECK(VHostUserInput, (obj), TYPE_VHOST_USER_INPUT)
49 #define VHOST_USER_INPUT_GET_PARENT_CLASS(obj) \
50 OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT)
52 typedef struct VirtIOInput VirtIOInput;
53 typedef struct VirtIOInputClass VirtIOInputClass;
54 typedef struct VirtIOInputConfig VirtIOInputConfig;
55 typedef struct VirtIOInputHID VirtIOInputHID;
56 typedef struct VirtIOInputHost VirtIOInputHost;
57 typedef struct VHostUserInput VHostUserInput;
59 struct VirtIOInputConfig {
60 virtio_input_config config;
61 QTAILQ_ENTRY(VirtIOInputConfig) node;
64 struct VirtIOInput {
65 VirtIODevice parent_obj;
66 uint8_t cfg_select;
67 uint8_t cfg_subsel;
68 uint32_t cfg_size;
69 QTAILQ_HEAD(, VirtIOInputConfig) cfg_list;
70 VirtQueue *evt, *sts;
71 char *serial;
73 struct {
74 virtio_input_event event;
75 VirtQueueElement *elem;
76 } *queue;
77 uint32_t qindex, qsize;
79 bool active;
82 struct VirtIOInputClass {
83 /*< private >*/
84 VirtioDeviceClass parent;
85 /*< public >*/
87 DeviceRealize realize;
88 DeviceUnrealize unrealize;
89 void (*change_active)(VirtIOInput *vinput);
90 void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
93 struct VirtIOInputHID {
94 VirtIOInput parent_obj;
95 char *display;
96 uint32_t head;
97 QemuInputHandler *handler;
98 QemuInputHandlerState *hs;
99 int ledstate;
100 bool wheel_axis;
103 struct VirtIOInputHost {
104 VirtIOInput parent_obj;
105 char *evdev;
106 int fd;
109 struct VHostUserInput {
110 VirtIOInput parent_obj;
112 VhostUserBackend *vhost;
115 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
116 void virtio_input_init_config(VirtIOInput *vinput,
117 virtio_input_config *config);
118 virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
119 uint8_t select,
120 uint8_t subsel);
121 void virtio_input_add_config(VirtIOInput *vinput,
122 virtio_input_config *config);
123 void virtio_input_idstr_config(VirtIOInput *vinput,
124 uint8_t select, const char *string);
126 #endif /* QEMU_VIRTIO_INPUT_H */