]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/virtio/virtio-input.h
Merge tag 'pull-maintainer-may24-160524-2' of https://gitlab.com/stsquad/qemu into...
[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 3
bad38726
LY
4#include "hw/virtio/vhost-user.h"
5#include "hw/virtio/vhost-user-base.h"
f73ddbad 6#include "ui/input.h"
9c4d05b7 7#include "sysemu/vhost-user-backend.h"
f73ddbad
GH
8
9/* ----------------------------------------------------------------- */
10/* virtio input protocol */
11
12#include "standard-headers/linux/virtio_ids.h"
13#include "standard-headers/linux/virtio_input.h"
db1015e9 14#include "qom/object.h"
f73ddbad
GH
15
16typedef struct virtio_input_absinfo virtio_input_absinfo;
17typedef struct virtio_input_config virtio_input_config;
18typedef struct virtio_input_event virtio_input_event;
19
f73ddbad
GH
20/* ----------------------------------------------------------------- */
21/* qemu internals */
22
23#define TYPE_VIRTIO_INPUT "virtio-input-device"
c821774a 24OBJECT_DECLARE_TYPE(VirtIOInput, VirtIOInputClass,
30b5707c 25 VIRTIO_INPUT)
f73ddbad
GH
26#define VIRTIO_INPUT_GET_PARENT_CLASS(obj) \
27 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT)
f73ddbad 28
8e9ebd75
SL
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"
55a1d80a 34
8063396b 35OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHID, VIRTIO_INPUT_HID)
55a1d80a
GH
36#define VIRTIO_INPUT_HID_GET_PARENT_CLASS(obj) \
37 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HID)
38
006a5ede 39#define TYPE_VIRTIO_INPUT_HOST "virtio-input-host-device"
8063396b 40OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHost, VIRTIO_INPUT_HOST)
006a5ede
GH
41#define VIRTIO_INPUT_HOST_GET_PARENT_CLASS(obj) \
42 OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_INPUT_HOST)
43
9c4d05b7 44#define TYPE_VHOST_USER_INPUT "vhost-user-input"
8063396b 45OBJECT_DECLARE_SIMPLE_TYPE(VHostUserInput, VHOST_USER_INPUT)
9c4d05b7
MAL
46#define VHOST_USER_INPUT_GET_PARENT_CLASS(obj) \
47 OBJECT_GET_PARENT_CLASS(obj, TYPE_VHOST_USER_INPUT)
48
f73ddbad
GH
49typedef struct VirtIOInputConfig VirtIOInputConfig;
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;
b1be65f6 89 const QemuInputHandler *handler;
55a1d80a
GH
90 QemuInputHandlerState *hs;
91 int ledstate;
f4924974 92 bool wheel_axis;
55a1d80a
GH
93};
94
006a5ede
GH
95struct VirtIOInputHost {
96 VirtIOInput parent_obj;
97 char *evdev;
98 int fd;
99};
100
9c4d05b7 101struct VHostUserInput {
bad38726 102 VHostUserBase parent_obj;
9c4d05b7
MAL
103};
104
f73ddbad
GH
105void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
106void virtio_input_init_config(VirtIOInput *vinput,
107 virtio_input_config *config);
b065e275
LP
108virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
109 uint8_t select,
110 uint8_t subsel);
f73ddbad
GH
111void virtio_input_add_config(VirtIOInput *vinput,
112 virtio_input_config *config);
113void virtio_input_idstr_config(VirtIOInput *vinput,
114 uint8_t select, const char *string);
115
2a6a4076 116#endif /* QEMU_VIRTIO_INPUT_H */