qemu/include/hw/virtio/virtio-input.h
<<
>>
Prefs
   1#ifndef QEMU_VIRTIO_INPUT_H
   2#define QEMU_VIRTIO_INPUT_H
   3
   4#include "ui/input.h"
   5#include "sysemu/vhost-user-backend.h"
   6
   7/* ----------------------------------------------------------------- */
   8/* virtio input protocol                                             */
   9
  10#include "standard-headers/linux/virtio_ids.h"
  11#include "standard-headers/linux/virtio_input.h"
  12
  13typedef struct virtio_input_absinfo virtio_input_absinfo;
  14typedef struct virtio_input_config virtio_input_config;
  15typedef struct virtio_input_event virtio_input_event;
  16
  17/* ----------------------------------------------------------------- */
  18/* qemu internals                                                    */
  19
  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)
  29
  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"
  34
  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)
  39
  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)
  45
  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)
  51
  52typedef struct VirtIOInput VirtIOInput;
  53typedef struct VirtIOInputClass VirtIOInputClass;
  54typedef struct VirtIOInputConfig VirtIOInputConfig;
  55typedef struct VirtIOInputHID VirtIOInputHID;
  56typedef struct VirtIOInputHost VirtIOInputHost;
  57typedef struct VHostUserInput VHostUserInput;
  58
  59struct VirtIOInputConfig {
  60    virtio_input_config               config;
  61    QTAILQ_ENTRY(VirtIOInputConfig)   node;
  62};
  63
  64struct 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;
  72
  73    struct {
  74        virtio_input_event event;
  75        VirtQueueElement *elem;
  76    }                                 *queue;
  77    uint32_t                          qindex, qsize;
  78
  79    bool                              active;
  80};
  81
  82struct VirtIOInputClass {
  83    /*< private >*/
  84    VirtioDeviceClass parent;
  85    /*< public >*/
  86
  87    DeviceRealize realize;
  88    DeviceUnrealize unrealize;
  89    void (*change_active)(VirtIOInput *vinput);
  90    void (*handle_status)(VirtIOInput *vinput, virtio_input_event *event);
  91};
  92
  93struct 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;
 101};
 102
 103struct VirtIOInputHost {
 104    VirtIOInput                       parent_obj;
 105    char                              *evdev;
 106    int                               fd;
 107};
 108
 109struct VHostUserInput {
 110    VirtIOInput                       parent_obj;
 111
 112    VhostUserBackend                  *vhost;
 113};
 114
 115void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event);
 116void virtio_input_init_config(VirtIOInput *vinput,
 117                              virtio_input_config *config);
 118virtio_input_config *virtio_input_find_config(VirtIOInput *vinput,
 119                                              uint8_t select,
 120                                              uint8_t subsel);
 121void virtio_input_add_config(VirtIOInput *vinput,
 122                             virtio_input_config *config);
 123void virtio_input_idstr_config(VirtIOInput *vinput,
 124                               uint8_t select, const char *string);
 125
 126#endif /* QEMU_VIRTIO_INPUT_H */
 127