[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 06/27] virtio-snd: Add PCI wrapper code for VirtIOSound
From: |
Shreyansh Chouhan |
Subject: |
[RFC PATCH 06/27] virtio-snd: Add PCI wrapper code for VirtIOSound |
Date: |
Thu, 29 Apr 2021 17:34:24 +0530 |
Added the virito-snd.c file which contains a wrapper
for combining the device with the VirtIOPCIProxy.
Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com>
---
hw/virtio/meson.build | 1 +
hw/virtio/virtio-snd-pci.c | 72 ++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+)
create mode 100644 hw/virtio/virtio-snd-pci.c
diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build
index fbff9bc9d4..a4593f7631 100644
--- a/hw/virtio/meson.build
+++ b/hw/virtio/meson.build
@@ -45,6 +45,7 @@ virtio_pci_ss.add(when: 'CONFIG_VIRTIO_SERIAL', if_true:
files('virtio-serial-pc
virtio_pci_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true:
files('virtio-pmem-pci.c'))
virtio_pci_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true:
files('virtio-iommu-pci.c'))
virtio_pci_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true:
files('virtio-mem-pci.c'))
+virtio_pci_ss.add(when: 'CONFIG_VIRTIO_SND', if_true:
files('virtio-snd-pci.c'))
virtio_ss.add_all(when: 'CONFIG_VIRTIO_PCI', if_true: virtio_pci_ss)
diff --git a/hw/virtio/virtio-snd-pci.c b/hw/virtio/virtio-snd-pci.c
new file mode 100644
index 0000000000..8d8e4ffa51
--- /dev/null
+++ b/hw/virtio/virtio-snd-pci.c
@@ -0,0 +1,72 @@
+/*
+ * Virtio sound PCI Bindings
+ */
+
+#include "qemu/osdep.h"
+#include "hw/virtio/virtio-snd.h"
+#include "hw/virtio/virtio-pci.h"
+#include "qapi/error.h"
+#include "qemu/module.h"
+#include "qom/object.h"
+
+typedef struct VirtIOSoundPCI VirtIOSoundPCI;
+
+/*
+ * virtio-snd-pci: This extends VirtioPCIProxy.
+ */
+#define TYPE_VIRTIO_SOUND_PCI "virtio-sound-pci-base"
+DECLARE_INSTANCE_CHECKER(VirtIOSoundPCI, VIRTIO_SOUND_PCI,
+ TYPE_VIRTIO_SOUND_PCI)
+
+struct VirtIOSoundPCI {
+ VirtIOPCIProxy parent_obj;
+ VirtIOSound vdev;
+};
+
+static Property virtio_sound_properties[] = {
+ DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
+ VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_snd_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
+{
+ VirtIOSoundPCI *dev = VIRTIO_SOUND_PCI(vpci_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
+
+ qdev_realize(vdev, BUS(&vpci_dev->bus), errp);
+}
+
+static void virtio_snd_pci_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+ VirtioPCIClass *vpciklass = VIRTIO_PCI_CLASS(klass);
+
+ k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO;
+ set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
+ device_class_set_props(dc, virtio_sound_properties);
+ vpciklass->realize = virtio_snd_pci_realize;
+}
+
+static void virtio_snd_pci_instance_init(Object *obj)
+{
+ VirtIOSoundPCI *dev = VIRTIO_SOUND_PCI(obj);
+ virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+ TYPE_VIRTIO_SOUND);
+}
+
+static const VirtioPCIDeviceTypeInfo virtio_snd_pci_info = {
+ .base_name = TYPE_VIRTIO_SOUND_PCI,
+ .generic_name = "virtio-snd-pci",
+ .instance_size = sizeof(VirtIOSoundPCI),
+ .instance_init = virtio_snd_pci_instance_init,
+ .class_init = virtio_snd_pci_class_init,
+};
+
+static void virtio_snd_pci_register(void)
+{
+ virtio_pci_types_register(&virtio_snd_pci_info);
+}
+
+type_init(virtio_snd_pci_register);
--
2.25.1
- [RFC PATCH 00/27] Virtio sound card implementation, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 01/27] virtio-snd: Add virtio sound header file, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 02/27] virtio-snd: Add jack control structures, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 04/27] virtio-snd: Add chmap control structures, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 03/27] virtio-snd: Add PCM control structures, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 05/27] virtio-snd: Add device implementation structures, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 06/27] virtio-snd: Add PCI wrapper code for VirtIOSound,
Shreyansh Chouhan <=
- [RFC PATCH 07/27] virtio-snd: Add properties for class init, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 08/27] virtio-snd: Add code for get config function, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 09/27] virtio-snd: Add code for set config function, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 10/27] virtio-snd: Add code for the realize function, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 12/27] virtio-snd: Add control virtqueue handler, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 11/27] virtio-snd: Add macros for logging, Shreyansh Chouhan, 2021/04/29
- [RFC PATCH 13/27] virtio-snd: Add VIRTIO_SND_R_JACK_INFO handler, Shreyansh Chouhan, 2021/04/29