These changes are the raw update to qemu-2.6.
[kvmfornfv.git] / qemu / include / hw / virtio / virtio-input.h
1 #ifndef _QEMU_VIRTIO_INPUT_H
2 #define _QEMU_VIRTIO_INPUT_H
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
12 typedef struct virtio_input_absinfo virtio_input_absinfo;
13 typedef struct virtio_input_config virtio_input_config;
14 typedef struct virtio_input_event virtio_input_event;
15
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
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
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
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
45 typedef struct VirtIOInput VirtIOInput;
46 typedef struct VirtIOInputClass VirtIOInputClass;
47 typedef struct VirtIOInputConfig VirtIOInputConfig;
48 typedef struct VirtIOInputHID VirtIOInputHID;
49 typedef struct VirtIOInputHost VirtIOInputHost;
50
51 struct VirtIOInputConfig {
52     virtio_input_config               config;
53     QTAILQ_ENTRY(VirtIOInputConfig)   node;
54 };
55
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;
64
65     virtio_input_event                *queue;
66     uint32_t                          qindex, qsize;
67
68     bool                              active;
69 };
70
71 struct VirtIOInputClass {
72     /*< private >*/
73     VirtioDeviceClass parent;
74     /*< public >*/
75
76     DeviceRealize realize;
77     DeviceUnrealize unrealize;
78     void (*change_active)(VirtIOInput *vinput);
79     void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
80 };
81
82 struct VirtIOInputHID {
83     VirtIOInput                       parent_obj;
84     char                              *display;
85     uint32_t                          head;
86     QemuInputHandler                  *handler;
87     QemuInputHandlerState             *hs;
88     int                               ledstate;
89 };
90
91 struct VirtIOInputHost {
92     VirtIOInput                       parent_obj;
93     char                              *evdev;
94     int                               fd;
95 };
96
97 void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
98 void virtio_input_init_config(VirtIOInput *vinput,
99                               virtio_input_config *config);
100 virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
101                                               uint8_t select,
102                                               uint8_t subsel);
103 void virtio_input_add_config(VirtIOInput *vinput,
104                              virtio_input_config *config);
105 void virtio_input_idstr_config(VirtIOInput *vinput,
106                                uint8_t select, const char *string);
107
108 #endif /* _QEMU_VIRTIO_INPUT_H */