]> git.proxmox.com Git - mirror_qemu.git/blame - hw/display/virtio-gpu-pci.c
ui/virtio-gpu: add and use qemu_create_displaysurface_pixman
[mirror_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 */
9b8bfe21 13#include "qemu/osdep.h"
9eafb62d
GH
14#include "hw/pci/pci.h"
15#include "hw/virtio/virtio.h"
16#include "hw/virtio/virtio-bus.h"
17#include "hw/virtio/virtio-pci.h"
18#include "hw/virtio/virtio-gpu.h"
19
20static Property virtio_gpu_pci_properties[] = {
9eafb62d
GH
21 DEFINE_VIRTIO_GPU_PCI_PROPERTIES(VirtIOPCIProxy),
22 DEFINE_PROP_END_OF_LIST(),
23};
24
25static void virtio_gpu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
26{
27 VirtIOGPUPCI *vgpu = VIRTIO_GPU_PCI(vpci_dev);
e1888295 28 VirtIOGPU *g = &vgpu->vdev;
9eafb62d 29 DeviceState *vdev = DEVICE(&vgpu->vdev);
e1888295 30 int i;
9eafb62d
GH
31
32 qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus));
33 /* force virtio-1.0 */
34 vpci_dev->flags &= ~VIRTIO_PCI_FLAG_DISABLE_MODERN;
35 vpci_dev->flags |= VIRTIO_PCI_FLAG_DISABLE_LEGACY;
36 object_property_set_bool(OBJECT(vdev), true, "realized", errp);
e1888295
GH
37
38 for (i = 0; i < g->conf.max_outputs; i++) {
39 object_property_set_link(OBJECT(g->scanout[i].con),
40 OBJECT(vpci_dev),
41 "device", errp);
42 }
9eafb62d
GH
43}
44
45static void virtio_gpu_pci_class_init(ObjectClass *klass, void *data)
46{
47 DeviceClass *dc = DEVICE_CLASS(klass);
48 VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass);
49 PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass);
50
51 set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
52 dc->props = virtio_gpu_pci_properties;
53 k->realize = virtio_gpu_pci_realize;
54 pcidev_k->class_id = PCI_CLASS_DISPLAY_OTHER;
55}
56
57static void virtio_gpu_initfn(Object *obj)
58{
59 VirtIOGPUPCI *dev = VIRTIO_GPU_PCI(obj);
b3409a31
GH
60
61 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
62 TYPE_VIRTIO_GPU);
9eafb62d
GH
63}
64
65static const TypeInfo virtio_gpu_pci_info = {
66 .name = TYPE_VIRTIO_GPU_PCI,
67 .parent = TYPE_VIRTIO_PCI,
68 .instance_size = sizeof(VirtIOGPUPCI),
69 .instance_init = virtio_gpu_initfn,
70 .class_init = virtio_gpu_pci_class_init,
71};
72
73static void virtio_gpu_pci_register_types(void)
74{
75 type_register_static(&virtio_gpu_pci_info);
76}
77type_init(virtio_gpu_pci_register_types)