Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20200717' into staging
[qemu.git] / hw / s390x / virtio-ccw-input.c
blob5601e25deed8ce18a56c45fa1d498bcb79333029
1 /*
2 * virtio ccw scsi implementation
4 * Copyright 2012, 2015 IBM Corp.
6 * This work is licensed under the terms of the GNU GPL, version 2 or (at
7 * your option) any later version. See the COPYING file in the top-level
8 * directory.
9 */
11 #include "qemu/osdep.h"
12 #include "hw/qdev-properties.h"
13 #include "hw/virtio/virtio.h"
14 #include "qapi/error.h"
15 #include "qemu/module.h"
16 #include "virtio-ccw.h"
18 static void virtio_ccw_input_realize(VirtioCcwDevice *ccw_dev, Error **errp)
20 VirtIOInputCcw *dev = VIRTIO_INPUT_CCW(ccw_dev);
21 DeviceState *vdev = DEVICE(&dev->vdev);
23 qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
26 static Property virtio_ccw_input_properties[] = {
27 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
28 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
29 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
30 VIRTIO_CCW_MAX_REV),
31 DEFINE_PROP_END_OF_LIST(),
34 static void virtio_ccw_input_class_init(ObjectClass *klass, void *data)
36 DeviceClass *dc = DEVICE_CLASS(klass);
37 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
39 k->realize = virtio_ccw_input_realize;
40 device_class_set_props(dc, virtio_ccw_input_properties);
41 set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
44 static void virtio_ccw_keyboard_instance_init(Object *obj)
46 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
47 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
49 ccw_dev->force_revision_1 = true;
50 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
51 TYPE_VIRTIO_KEYBOARD);
54 static void virtio_ccw_mouse_instance_init(Object *obj)
56 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
57 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
59 ccw_dev->force_revision_1 = true;
60 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
61 TYPE_VIRTIO_MOUSE);
64 static void virtio_ccw_tablet_instance_init(Object *obj)
66 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
67 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
69 ccw_dev->force_revision_1 = true;
70 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
71 TYPE_VIRTIO_TABLET);
74 static const TypeInfo virtio_ccw_input = {
75 .name = TYPE_VIRTIO_INPUT_CCW,
76 .parent = TYPE_VIRTIO_CCW_DEVICE,
77 .instance_size = sizeof(VirtIOInputCcw),
78 .class_init = virtio_ccw_input_class_init,
79 .abstract = true,
82 static const TypeInfo virtio_ccw_input_hid = {
83 .name = TYPE_VIRTIO_INPUT_HID_CCW,
84 .parent = TYPE_VIRTIO_INPUT_CCW,
85 .instance_size = sizeof(VirtIOInputHIDCcw),
86 .abstract = true,
89 static const TypeInfo virtio_ccw_keyboard = {
90 .name = TYPE_VIRTIO_KEYBOARD_CCW,
91 .parent = TYPE_VIRTIO_INPUT_HID_CCW,
92 .instance_size = sizeof(VirtIOInputHIDCcw),
93 .instance_init = virtio_ccw_keyboard_instance_init,
96 static const TypeInfo virtio_ccw_mouse = {
97 .name = TYPE_VIRTIO_MOUSE_CCW,
98 .parent = TYPE_VIRTIO_INPUT_HID_CCW,
99 .instance_size = sizeof(VirtIOInputHIDCcw),
100 .instance_init = virtio_ccw_mouse_instance_init,
103 static const TypeInfo virtio_ccw_tablet = {
104 .name = TYPE_VIRTIO_TABLET_CCW,
105 .parent = TYPE_VIRTIO_INPUT_HID_CCW,
106 .instance_size = sizeof(VirtIOInputHIDCcw),
107 .instance_init = virtio_ccw_tablet_instance_init,
110 static void virtio_ccw_input_register(void)
112 type_register_static(&virtio_ccw_input);
113 type_register_static(&virtio_ccw_input_hid);
114 type_register_static(&virtio_ccw_keyboard);
115 type_register_static(&virtio_ccw_mouse);
116 type_register_static(&virtio_ccw_tablet);
119 type_init(virtio_ccw_input_register)