]> git.proxmox.com Git - mirror_qemu.git/blob - hw/display/virtio-gpu-pci.c
minikconf: do not include variables from MINIKCONF_ARGS in config-all-devices.mak
[mirror_qemu.git] / hw / display / virtio-gpu-pci.c
1 /*
2 * Virtio video device
3 *
4 * Copyright Red Hat
5 *
6 * Authors:
7 * Dave Airlie
8 *
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.
11 *
12 */
13
14 #include "qemu/osdep.h"
15 #include "qapi/error.h"
16 #include "qemu/module.h"
17 #include "hw/pci/pci.h"
18 #include "hw/virtio/virtio.h"
19 #include "hw/virtio/virtio-bus.h"
20 #include "hw/virtio/virtio-gpu-pci.h"
21
22 static Property virtio_gpu_pci_base_properties[] = {
23 DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
24 DEFINE_PROP_END_OF_LIST(),
25 };
26
27 static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
28 {
29 VirtIOGPUPCIBase *vgpu = VIRTIO_GPU_PCI_BASE(vpci_dev);
30 VirtIOGPUBase *g = vgpu->vgpu;
31 DeviceState *vdev = DEVICE(g);
32 int i;
33 Error *local_error = NULL;
34
35 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
36 if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
37 return;
38 }
39 object_property_set_bool(OBJECT(vdev), true, "realized", &local_error);
40
41 if (local_error) {
42 error_propagate(errp, local_error);
43 return;
44 }
45
46 for (i = 0; i < g->conf.max_outputs; i++) {
47 object_property_set_link(OBJECT(g->scanout[i].con),
48 OBJECT(vpci_dev),
49 "device", errp);
50 }
51 }
52
53 static void virtio_gpu_pci_base_class_init(ObjectClass *klass, void *data)
54 {
55 DeviceClass *dc = DEVICE_CLASS(klass);
56 VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
57 PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
58
59 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
60 dc->props = virtio_gpu_pci_base_properties;
61 dc->hotpluggable = false;
62 k->realize = virtio_gpu_pci_base_realize;
63 pcidev_k->class_id = PCI_CLASS_DISPLAY_OTHER;
64 }
65
66 static const TypeInfo virtio_gpu_pci_base_info = {
67 .name = TYPE_VIRTIO_GPU_PCI_BASE,
68 .parent = TYPE_VIRTIO_PCI,
69 .instance_size = sizeof(VirtIOGPUPCIBase),
70 .class_init = virtio_gpu_pci_base_class_init,
71 .abstract = true
72 };
73
74 #define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci"
75 #define VIRTIO_GPU_PCI(obj) \
76 OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI)
77
78 typedef struct VirtIOGPUPCI {
79 VirtIOGPUPCIBase parent_obj;
80 VirtIOGPU vdev;
81 } VirtIOGPUPCI;
82
83 static void virtio_gpu_initfn(Object *obj)
84 {
85 VirtIOGPUPCI *dev = VIRTIO_GPU_PCI(obj);
86
87 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
88 TYPE_VIRTIO_GPU);
89 VIRTIO_GPU_PCI_BASE(obj)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
90 }
91
92 static const VirtioPCIDeviceTypeInfo virtio_gpu_pci_info = {
93 .generic_name = TYPE_VIRTIO_GPU_PCI,
94 .parent = TYPE_VIRTIO_GPU_PCI_BASE,
95 .instance_size = sizeof(VirtIOGPUPCI),
96 .instance_init = virtio_gpu_initfn,
97 };
98
99 static void virtio_gpu_pci_register_types(void)
100 {
101 type_register_static(&virtio_gpu_pci_base_info);
102 virtio_pci_types_register(&virtio_gpu_pci_info);
103 }
104
105 type_init(virtio_gpu_pci_register_types)