tests/boot-serial: Check the 40p machine, too
[qemu.git] / hw / display / virtio-gpu-pci.c
blobcece4aa4956aaf936a105d4d2b9bd95fddcfb1f1
1 /*
2 * Virtio video device
4 * Copyright Red Hat
6 * Authors:
7 * Dave Airlie
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
14 #include "qemu/osdep.h"
15 #include "qapi/error.h"
16 #include "hw/pci/pci.h"
17 #include "hw/virtio/virtio.h"
18 #include "hw/virtio/virtio-bus.h"
19 #include "hw/virtio/virtio-pci.h"
20 #include "hw/virtio/virtio-gpu.h"
22 static Property virtio_gpu_pci_properties[] = {
23 DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
24 DEFINE_PROP_END_OF_LIST(),
27 static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
29 VirtIOGPUPCI *vgpu = VIRTIO_GPU_PCI(vpci_dev);
30 VirtIOGPU *g = &vgpu->vdev;
31 DeviceState *vdev = DEVICE(&vgpu->vdev);
32 int i;
33 Error *local_error = NULL;
35 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
36 virtio_pci_force_virtio_1(vpci_dev);
37 object_property_set_bool(OBJECT(vdev), true, "realized", &local_error);
39 if (local_error) {
40 error_propagate(errp, local_error);
41 return;
44 for (i = 0; i < g->conf.max_outputs; i++) {
45 object_property_set_link(OBJECT(g->scanout[i].con),
46 OBJECT(vpci_dev),
47 "device", errp);
51 static void virtio_gpu_pci_class_init(ObjectClass *klass, void *data)
53 DeviceClass *dc = DEVICE_CLASS(klass);
54 VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
55 PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
57 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
58 dc->props = virtio_gpu_pci_properties;
59 dc->hotpluggable = false;
60 k->realize = virtio_gpu_pci_realize;
61 pcidev_k->class_id = PCI_CLASS_DISPLAY_OTHER;
64 static void virtio_gpu_initfn(Object *obj)
66 VirtIOGPUPCI *dev = VIRTIO_GPU_PCI(obj);
68 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
69 TYPE_VIRTIO_GPU);
72 static const TypeInfo virtio_gpu_pci_info = {
73 .name = TYPE_VIRTIO_GPU_PCI,
74 .parent = TYPE_VIRTIO_PCI,
75 .instance_size = sizeof(VirtIOGPUPCI),
76 .instance_init = virtio_gpu_initfn,
77 .class_init = virtio_gpu_pci_class_init,
80 static void virtio_gpu_pci_register_types(void)
82 type_register_static(&virtio_gpu_pci_info);
84 type_init(virtio_gpu_pci_register_types)