1 #ifndef QEMU_VIRTIO_INPUT_H
2 #define QEMU_VIRTIO_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"
12 #include "qom/object.h"
14 typedef struct virtio_input_absinfo virtio_input_absinfo
;
15 typedef struct virtio_input_config virtio_input_config
;
16 typedef struct virtio_input_event virtio_input_event
;
18 /* ----------------------------------------------------------------- */
21 #define TYPE_VIRTIO_INPUT "virtio-input-device"
22 OBJECT_DECLARE_TYPE(VirtIOInput
, VirtIOInputClass
,
24 #define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \
25 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT)
27 #define TYPE_VIRTIO_INPUT_HID "virtio-input-hid-device"
28 #define TYPE_VIRTIO_KEYBOARD "virtio-keyboard-device"
29 #define TYPE_VIRTIO_MOUSE "virtio-mouse-device"
30 #define TYPE_VIRTIO_TABLET "virtio-tablet-device"
32 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHID
, VIRTIO_INPUT_HID
)
33 #define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
34 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
36 #define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
37 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHost
, VIRTIO_INPUT_HOST
)
38 #define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
39 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
41 #define TYPE_VHOST_USER_INPUT "vhost-user-input"
42 OBJECT_DECLARE_SIMPLE_TYPE(VHostUserInput
, VHOST_USER_INPUT
)
43 #define VHOST_USER_INPUT_GET_PARENT_CLASS(obj) \
44 OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT)
46 typedef struct VirtIOInputConfig VirtIOInputConfig
;
48 struct VirtIOInputConfig
{
49 virtio_input_config config
;
50 QTAILQ_ENTRY(VirtIOInputConfig
) node
;
54 VirtIODevice parent_obj
;
58 QTAILQ_HEAD(, VirtIOInputConfig
) cfg_list
;
63 virtio_input_event event
;
64 VirtQueueElement
*elem
;
66 uint32_t qindex
, qsize
;
71 struct VirtIOInputClass
{
73 VirtioDeviceClass parent
;
76 DeviceRealize realize
;
77 DeviceUnrealize unrealize
;
78 void (*change_active
)(VirtIOInput
*vinput
);
79 void (*handle_status
)(VirtIOInput
*vinput
, virtio_input_event
*event
);
82 struct VirtIOInputHID
{
83 VirtIOInput parent_obj
;
86 QemuInputHandler
*handler
;
87 QemuInputHandlerState
*hs
;
92 struct VirtIOInputHost
{
93 VirtIOInput parent_obj
;
98 struct VHostUserInput
{
99 VirtIOInput parent_obj
;
101 VhostUserBackend
*vhost
;
104 void virtio_input_send(VirtIOInput
*vinput
, virtio_input_event
*event
);
105 void virtio_input_init_config(VirtIOInput
*vinput
,
106 virtio_input_config
*config
);
107 virtio_input_config
*virtio_input_find_config(VirtIOInput
*vinput
,
110 void virtio_input_add_config(VirtIOInput
*vinput
,
111 virtio_input_config
*config
);
112 void virtio_input_idstr_config(VirtIOInput
*vinput
,
113 uint8_t select
, const char *string
);
115 #endif /* QEMU_VIRTIO_INPUT_H */