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 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 46*60480812SRichard 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 DEFINE_PROP_END_OF_LIST(), 5290b90a0fSThomas Huth }; 5390b90a0fSThomas Huth 5490b90a0fSThomas Huth static void virtio_ccw_input_class_init(ObjectClass *klass, void *data) 5590b90a0fSThomas Huth { 5690b90a0fSThomas Huth DeviceClass *dc = DEVICE_CLASS(klass); 5790b90a0fSThomas Huth VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 5890b90a0fSThomas Huth 5990b90a0fSThomas Huth k->realize = virtio_ccw_input_realize; 604f67d30bSMarc-André Lureau device_class_set_props(dc, virtio_ccw_input_properties); 6190b90a0fSThomas Huth set_bit(DEVICE_CATEGORY_INPUT, dc->categories); 6290b90a0fSThomas Huth } 6390b90a0fSThomas Huth 6490b90a0fSThomas Huth static void virtio_ccw_keyboard_instance_init(Object *obj) 6590b90a0fSThomas Huth { 6690b90a0fSThomas Huth VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 6790b90a0fSThomas Huth VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 6890b90a0fSThomas Huth 6990b90a0fSThomas Huth ccw_dev->force_revision_1 = true; 7090b90a0fSThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 7190b90a0fSThomas Huth TYPE_VIRTIO_KEYBOARD); 7290b90a0fSThomas Huth } 7390b90a0fSThomas Huth 7490b90a0fSThomas Huth static void virtio_ccw_mouse_instance_init(Object *obj) 7590b90a0fSThomas Huth { 7690b90a0fSThomas Huth VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 7790b90a0fSThomas Huth VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 7890b90a0fSThomas Huth 7990b90a0fSThomas Huth ccw_dev->force_revision_1 = true; 8090b90a0fSThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 8190b90a0fSThomas Huth TYPE_VIRTIO_MOUSE); 8290b90a0fSThomas Huth } 8390b90a0fSThomas Huth 8490b90a0fSThomas Huth static void virtio_ccw_tablet_instance_init(Object *obj) 8590b90a0fSThomas Huth { 8690b90a0fSThomas Huth VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 8790b90a0fSThomas Huth VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 8890b90a0fSThomas Huth 8990b90a0fSThomas Huth ccw_dev->force_revision_1 = true; 9090b90a0fSThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 9190b90a0fSThomas Huth TYPE_VIRTIO_TABLET); 9290b90a0fSThomas Huth } 9390b90a0fSThomas Huth 9490b90a0fSThomas Huth static const TypeInfo virtio_ccw_input = { 9590b90a0fSThomas Huth .name = TYPE_VIRTIO_INPUT_CCW, 9690b90a0fSThomas Huth .parent = TYPE_VIRTIO_CCW_DEVICE, 9790b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputCcw), 9890b90a0fSThomas Huth .class_init = virtio_ccw_input_class_init, 9990b90a0fSThomas Huth .abstract = true, 10090b90a0fSThomas Huth }; 10190b90a0fSThomas Huth 10290b90a0fSThomas Huth static const TypeInfo virtio_ccw_input_hid = { 10390b90a0fSThomas Huth .name = TYPE_VIRTIO_INPUT_HID_CCW, 10490b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_CCW, 10590b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 10690b90a0fSThomas Huth .abstract = true, 10790b90a0fSThomas Huth }; 10890b90a0fSThomas Huth 10990b90a0fSThomas Huth static const TypeInfo virtio_ccw_keyboard = { 11090b90a0fSThomas Huth .name = TYPE_VIRTIO_KEYBOARD_CCW, 11190b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_HID_CCW, 11290b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 11390b90a0fSThomas Huth .instance_init = virtio_ccw_keyboard_instance_init, 11490b90a0fSThomas Huth }; 11590b90a0fSThomas Huth 11690b90a0fSThomas Huth static const TypeInfo virtio_ccw_mouse = { 11790b90a0fSThomas Huth .name = TYPE_VIRTIO_MOUSE_CCW, 11890b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_HID_CCW, 11990b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 12090b90a0fSThomas Huth .instance_init = virtio_ccw_mouse_instance_init, 12190b90a0fSThomas Huth }; 12290b90a0fSThomas Huth 12390b90a0fSThomas Huth static const TypeInfo virtio_ccw_tablet = { 12490b90a0fSThomas Huth .name = TYPE_VIRTIO_TABLET_CCW, 12590b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_HID_CCW, 12690b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 12790b90a0fSThomas Huth .instance_init = virtio_ccw_tablet_instance_init, 12890b90a0fSThomas Huth }; 12990b90a0fSThomas Huth 13090b90a0fSThomas Huth static void virtio_ccw_input_register(void) 13190b90a0fSThomas Huth { 13290b90a0fSThomas Huth type_register_static(&virtio_ccw_input); 13390b90a0fSThomas Huth type_register_static(&virtio_ccw_input_hid); 13490b90a0fSThomas Huth type_register_static(&virtio_ccw_keyboard); 13590b90a0fSThomas Huth type_register_static(&virtio_ccw_mouse); 13690b90a0fSThomas Huth type_register_static(&virtio_ccw_tablet); 13790b90a0fSThomas Huth } 13890b90a0fSThomas Huth 13990b90a0fSThomas Huth type_init(virtio_ccw_input_register) 140