]> Git Repo - qemu.git/blame - hw/display/virtio-gpu-pci.c
virtio-gpu: add bswap helpers header
[qemu.git] / hw / display / virtio-gpu-pci.c
CommitLineData
9eafb62d
GH
1/*
2 * Virtio video device
3 *
4 * Copyright Red Hat
5 *
6 * Authors:
7 * Dave Airlie
8 *
2e252145
GH
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.
9eafb62d
GH
11 *
12 */
e688df6b 13
9b8bfe21 14#include "qemu/osdep.h"
e688df6b 15#include "qapi/error.h"
9eafb62d
GH
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"
21
7ecb381f
JQ
22typedef struct VirtIOGPUPCI VirtIOGPUPCI;
23
24/*
25 * virtio-gpu-pci: This extends VirtioPCIProxy.
26 */
27#define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci"
28#define VIRTIO_GPU_PCI(obj) \
29 OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI)
30
31struct VirtIOGPUPCI {
32 VirtIOPCIProxy parent_obj;
33 VirtIOGPU vdev;
34};
35
9eafb62d 36static Property virtio_gpu_pci_properties[] = {
9eafb62d
GH
37 DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
38 DEFINE_PROP_END_OF_LIST(),
39};
40
41static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
42{
43 VirtIOGPUPCI *vgpu = VIRTIO_GPU_PCI(vpci_dev);
e1888295 44 VirtIOGPU *g = &vgpu->vdev;
9eafb62d 45 DeviceState *vdev = DEVICE(&vgpu->vdev);
e1888295 46 int i;
34e304e9 47 Error *local_error = NULL;
9eafb62d
GH
48
49 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
f2784eed
DB
50 if (!virtio_pci_force_virtio_1(vpci_dev, errp)) {
51 return;
52 }
34e304e9
PX
53 object_property_set_bool(OBJECT(vdev), true, "realized", &local_error);
54
55 if (local_error) {
56 error_propagate(errp, local_error);
57 return;
58 }
e1888295
GH
59
60 for (i = 0; i < g->conf.max_outputs; i++) {
61 object_property_set_link(OBJECT(g->scanout[i].con),
62 OBJECT(vpci_dev),
63 "device", errp);
64 }
9eafb62d
GH
65}
66
67static void virtio_gpu_pci_class_init(ObjectClass *klass, void *data)
68{
69 DeviceClass *dc = DEVICE_CLASS(klass);
70 VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
71 PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
72
73 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
74 dc->props = virtio_gpu_pci_properties;
597966d1 75 dc->hotpluggable = false;
9eafb62d
GH
76 k->realize = virtio_gpu_pci_realize;
77 pcidev_k->class_id = PCI_CLASS_DISPLAY_OTHER;
78}
79
80static void virtio_gpu_initfn(Object *obj)
81{
82 VirtIOGPUPCI *dev = VIRTIO_GPU_PCI(obj);
b3409a31
GH
83
84 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
85 TYPE_VIRTIO_GPU);
9eafb62d
GH
86}
87
a4ee4c8b
EH
88static const VirtioPCIDeviceTypeInfo virtio_gpu_pci_info = {
89 .generic_name = TYPE_VIRTIO_GPU_PCI,
9eafb62d
GH
90 .instance_size = sizeof(VirtIOGPUPCI),
91 .instance_init = virtio_gpu_initfn,
92 .class_init = virtio_gpu_pci_class_init,
93};
94
95static void virtio_gpu_pci_register_types(void)
96{
a4ee4c8b 97 virtio_pci_types_register(&virtio_gpu_pci_info);
9eafb62d
GH
98}
99type_init(virtio_gpu_pci_register_types)
This page took 0.206605 seconds and 4 git commands to generate.