blob: 0c146080fd2c15ff9fd86338164e3969a3e1c355 [file] [log] [blame]
Marc-André Lureau267f6642019-05-24 15:09:46 +02001/*
2 * vhost-user VGA device
3 *
4 * Copyright Red Hat, Inc. 2018
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 *
9 */
10
11#include "qemu/osdep.h"
12#include "qapi/error.h"
13#include "virtio-vga.h"
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040014#include "qom/object.h"
Marc-André Lureau267f6642019-05-24 15:09:46 +020015
16#define TYPE_VHOST_USER_VGA "vhost-user-vga"
17
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040018typedef struct VhostUserVGA VhostUserVGA;
Eduardo Habkost8110fa12020-08-31 17:07:33 -040019DECLARE_INSTANCE_CHECKER(VhostUserVGA, VHOST_USER_VGA,
20 TYPE_VHOST_USER_VGA)
Marc-André Lureau267f6642019-05-24 15:09:46 +020021
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040022struct VhostUserVGA {
Marc-André Lureau267f6642019-05-24 15:09:46 +020023 VirtIOVGABase parent_obj;
24
25 VhostUserGPU vdev;
Eduardo Habkostdb1015e2020-09-03 16:43:22 -040026};
Marc-André Lureau267f6642019-05-24 15:09:46 +020027
28static void vhost_user_vga_inst_initfn(Object *obj)
29{
30 VhostUserVGA *dev = VHOST_USER_VGA(obj);
31
32 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
33 TYPE_VHOST_USER_GPU);
34
35 VIRTIO_VGA_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
36
37 object_property_add_alias(obj, "chardev",
Markus Armbrusterd2623122020-05-05 17:29:22 +020038 OBJECT(&dev->vdev), "chardev");
Marc-André Lureau267f6642019-05-24 15:09:46 +020039}
40
41static const VirtioPCIDeviceTypeInfo vhost_user_vga_info = {
42 .generic_name = TYPE_VHOST_USER_VGA,
43 .parent = TYPE_VIRTIO_VGA_BASE,
Eduardo Habkost2ada9012020-08-24 17:59:35 -040044 .instance_size = sizeof(VhostUserVGA),
Marc-André Lureau267f6642019-05-24 15:09:46 +020045 .instance_init = vhost_user_vga_inst_initfn,
46};
Gerd Hoffmann561d0f42021-06-24 12:38:08 +020047module_obj(TYPE_VHOST_USER_VGA);
Jose R. Ziviani24ce7aa2022-05-28 00:20:23 +020048module_kconfig(VHOST_USER_VGA);
Marc-André Lureau267f6642019-05-24 15:09:46 +020049
50static void vhost_user_vga_register_types(void)
51{
52 virtio_pci_types_register(&vhost_user_vga_info);
53}
54
55type_init(vhost_user_vga_register_types)