xref: /qemu/hw/s390x/virtio-ccw-input.c (revision 06b40d250ecfa1633209c2e431a7a38acfd03a98)
190b90a0fSThomas Huth /*
2de345260SCornelia Huck  * virtio ccw input implementation
390b90a0fSThomas Huth  *
490b90a0fSThomas Huth  * Copyright 2012, 2015 IBM Corp.
590b90a0fSThomas Huth  *
690b90a0fSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or (at
790b90a0fSThomas Huth  * your option) any later version. See the COPYING file in the top-level
890b90a0fSThomas Huth  * directory.
990b90a0fSThomas Huth  */
1090b90a0fSThomas Huth 
1190b90a0fSThomas Huth #include "qemu/osdep.h"
12a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
1390b90a0fSThomas Huth #include "hw/virtio/virtio.h"
1490b90a0fSThomas Huth #include "qapi/error.h"
150b8fa32fSMarkus Armbruster #include "qemu/module.h"
1690b90a0fSThomas Huth #include "virtio-ccw.h"
177da50d64SPaolo Bonzini #include "hw/virtio/virtio-input.h"
187da50d64SPaolo Bonzini 
197da50d64SPaolo Bonzini #define TYPE_VIRTIO_INPUT_CCW "virtio-input-ccw"
207da50d64SPaolo Bonzini OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputCcw, VIRTIO_INPUT_CCW)
217da50d64SPaolo Bonzini 
227da50d64SPaolo Bonzini struct VirtIOInputCcw {
237da50d64SPaolo Bonzini     VirtioCcwDevice parent_obj;
247da50d64SPaolo Bonzini     VirtIOInput vdev;
257da50d64SPaolo Bonzini };
267da50d64SPaolo Bonzini 
277da50d64SPaolo Bonzini #define TYPE_VIRTIO_INPUT_HID_CCW "virtio-input-hid-ccw"
287da50d64SPaolo Bonzini #define TYPE_VIRTIO_KEYBOARD_CCW "virtio-keyboard-ccw"
297da50d64SPaolo Bonzini #define TYPE_VIRTIO_MOUSE_CCW "virtio-mouse-ccw"
307da50d64SPaolo Bonzini #define TYPE_VIRTIO_TABLET_CCW "virtio-tablet-ccw"
317da50d64SPaolo Bonzini OBJECT_DECLARE_SIMPLE_TYPE(VirtIOInputHIDCcw, VIRTIO_INPUT_HID_CCW)
327da50d64SPaolo Bonzini 
337da50d64SPaolo Bonzini struct VirtIOInputHIDCcw {
347da50d64SPaolo Bonzini     VirtioCcwDevice parent_obj;
357da50d64SPaolo Bonzini     VirtIOInputHID vdev;
367da50d64SPaolo Bonzini };
3790b90a0fSThomas Huth 
virtio_ccw_input_realize(VirtioCcwDevice * ccw_dev,Error ** errp)3890b90a0fSThomas Huth static void virtio_ccw_input_realize(VirtioCcwDevice *ccw_dev, Error **errp)
3990b90a0fSThomas Huth {
4090b90a0fSThomas Huth     VirtIOInputCcw *dev = VIRTIO_INPUT_CCW(ccw_dev);
4190b90a0fSThomas Huth     DeviceState *vdev = DEVICE(&dev->vdev);
4290b90a0fSThomas Huth 
4399ba777eSMarkus Armbruster     qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
4490b90a0fSThomas Huth }
4590b90a0fSThomas Huth 
4660480812SRichard Henderson static const Property virtio_ccw_input_properties[] = {
4790b90a0fSThomas Huth     DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
4890b90a0fSThomas Huth                     VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
4990b90a0fSThomas Huth     DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
5090b90a0fSThomas Huth                        VIRTIO_CCW_MAX_REV),
5190b90a0fSThomas Huth };
5290b90a0fSThomas Huth 
virtio_ccw_input_class_init(ObjectClass * klass,const void * data)53*12d1a768SPhilippe Mathieu-Daudé static void virtio_ccw_input_class_init(ObjectClass *klass, const void *data)
5490b90a0fSThomas Huth {
5590b90a0fSThomas Huth     DeviceClass *dc = DEVICE_CLASS(klass);
5690b90a0fSThomas Huth     VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
5790b90a0fSThomas Huth 
5890b90a0fSThomas Huth     k->realize = virtio_ccw_input_realize;
594f67d30bSMarc-André Lureau     device_class_set_props(dc, virtio_ccw_input_properties);
6090b90a0fSThomas Huth     set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
6190b90a0fSThomas Huth }
6290b90a0fSThomas Huth 
virtio_ccw_keyboard_instance_init(Object * obj)6390b90a0fSThomas Huth static void virtio_ccw_keyboard_instance_init(Object *obj)
6490b90a0fSThomas Huth {
6590b90a0fSThomas Huth     VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
6690b90a0fSThomas Huth     VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
6790b90a0fSThomas Huth 
6890b90a0fSThomas Huth     ccw_dev->force_revision_1 = true;
6990b90a0fSThomas Huth     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
7090b90a0fSThomas Huth                                 TYPE_VIRTIO_KEYBOARD);
7190b90a0fSThomas Huth }
7290b90a0fSThomas Huth 
virtio_ccw_mouse_instance_init(Object * obj)7390b90a0fSThomas Huth static void virtio_ccw_mouse_instance_init(Object *obj)
7490b90a0fSThomas Huth {
7590b90a0fSThomas Huth     VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
7690b90a0fSThomas Huth     VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
7790b90a0fSThomas Huth 
7890b90a0fSThomas Huth     ccw_dev->force_revision_1 = true;
7990b90a0fSThomas Huth     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
8090b90a0fSThomas Huth                                 TYPE_VIRTIO_MOUSE);
8190b90a0fSThomas Huth }
8290b90a0fSThomas Huth 
virtio_ccw_tablet_instance_init(Object * obj)8390b90a0fSThomas Huth static void virtio_ccw_tablet_instance_init(Object *obj)
8490b90a0fSThomas Huth {
8590b90a0fSThomas Huth     VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
8690b90a0fSThomas Huth     VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
8790b90a0fSThomas Huth 
8890b90a0fSThomas Huth     ccw_dev->force_revision_1 = true;
8990b90a0fSThomas Huth     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
9090b90a0fSThomas Huth                                 TYPE_VIRTIO_TABLET);
9190b90a0fSThomas Huth }
9290b90a0fSThomas Huth 
9390b90a0fSThomas Huth static const TypeInfo virtio_ccw_input = {
9490b90a0fSThomas Huth     .name          = TYPE_VIRTIO_INPUT_CCW,
9590b90a0fSThomas Huth     .parent        = TYPE_VIRTIO_CCW_DEVICE,
9690b90a0fSThomas Huth     .instance_size = sizeof(VirtIOInputCcw),
9790b90a0fSThomas Huth     .class_init    = virtio_ccw_input_class_init,
9890b90a0fSThomas Huth     .abstract = true,
9990b90a0fSThomas Huth };
10090b90a0fSThomas Huth 
10190b90a0fSThomas Huth static const TypeInfo virtio_ccw_input_hid = {
10290b90a0fSThomas Huth     .name          = TYPE_VIRTIO_INPUT_HID_CCW,
10390b90a0fSThomas Huth     .parent        = TYPE_VIRTIO_INPUT_CCW,
10490b90a0fSThomas Huth     .instance_size = sizeof(VirtIOInputHIDCcw),
10590b90a0fSThomas Huth     .abstract = true,
10690b90a0fSThomas Huth };
10790b90a0fSThomas Huth 
10890b90a0fSThomas Huth static const TypeInfo virtio_ccw_keyboard = {
10990b90a0fSThomas Huth     .name          = TYPE_VIRTIO_KEYBOARD_CCW,
11090b90a0fSThomas Huth     .parent        = TYPE_VIRTIO_INPUT_HID_CCW,
11190b90a0fSThomas Huth     .instance_size = sizeof(VirtIOInputHIDCcw),
11290b90a0fSThomas Huth     .instance_init = virtio_ccw_keyboard_instance_init,
11390b90a0fSThomas Huth };
11490b90a0fSThomas Huth 
11590b90a0fSThomas Huth static const TypeInfo virtio_ccw_mouse = {
11690b90a0fSThomas Huth     .name          = TYPE_VIRTIO_MOUSE_CCW,
11790b90a0fSThomas Huth     .parent        = TYPE_VIRTIO_INPUT_HID_CCW,
11890b90a0fSThomas Huth     .instance_size = sizeof(VirtIOInputHIDCcw),
11990b90a0fSThomas Huth     .instance_init = virtio_ccw_mouse_instance_init,
12090b90a0fSThomas Huth };
12190b90a0fSThomas Huth 
12290b90a0fSThomas Huth static const TypeInfo virtio_ccw_tablet = {
12390b90a0fSThomas Huth     .name          = TYPE_VIRTIO_TABLET_CCW,
12490b90a0fSThomas Huth     .parent        = TYPE_VIRTIO_INPUT_HID_CCW,
12590b90a0fSThomas Huth     .instance_size = sizeof(VirtIOInputHIDCcw),
12690b90a0fSThomas Huth     .instance_init = virtio_ccw_tablet_instance_init,
12790b90a0fSThomas Huth };
12890b90a0fSThomas Huth 
virtio_ccw_input_register(void)12990b90a0fSThomas Huth static void virtio_ccw_input_register(void)
13090b90a0fSThomas Huth {
13190b90a0fSThomas Huth     type_register_static(&virtio_ccw_input);
13290b90a0fSThomas Huth     type_register_static(&virtio_ccw_input_hid);
13390b90a0fSThomas Huth     type_register_static(&virtio_ccw_keyboard);
13490b90a0fSThomas Huth     type_register_static(&virtio_ccw_mouse);
13590b90a0fSThomas Huth     type_register_static(&virtio_ccw_tablet);
13690b90a0fSThomas Huth }
13790b90a0fSThomas Huth 
13890b90a0fSThomas Huth type_init(virtio_ccw_input_register)
139