All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com>
To: kraxel@redhat.com, mst@redhat.com, laurent@vivier.eu
Cc: Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com>,
	qemu-devel@nongnu.org
Subject: [RFC PATCH 07/25] virtio-snd: Add properties for class init
Date: Sat, 12 Feb 2022 03:43:01 +0530	[thread overview]
Message-ID: <20220211221319.193404-8-chouhan.shreyansh2702@gmail.com> (raw)
In-Reply-To: <20210429120445.694420-1-chouhan.shreyansh2702@gmail.com>

Added properties and function stubs for virtio sound device class
init.

Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com>
---
 hw/audio/Kconfig      |   5 ++
 hw/audio/meson.build  |   1 +
 hw/audio/virtio-snd.c | 126 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 132 insertions(+)
 create mode 100644 hw/audio/virtio-snd.c

diff --git a/hw/audio/Kconfig b/hw/audio/Kconfig
index e9c6fed826..d12df06699 100644
--- a/hw/audio/Kconfig
+++ b/hw/audio/Kconfig
@@ -50,3 +50,8 @@ config CS4231
 
 config MARVELL_88W8618
     bool
+
+config VIRTIO_SND
+    bool
+    default y
+    depends on VIRTIO
diff --git a/hw/audio/meson.build b/hw/audio/meson.build
index e48a9fc73d..455e6a1501 100644
--- a/hw/audio/meson.build
+++ b/hw/audio/meson.build
@@ -12,3 +12,4 @@ softmmu_ss.add(when: 'CONFIG_PL041', if_true: files('pl041.c', 'lm4549.c'))
 softmmu_ss.add(when: 'CONFIG_SB16', if_true: files('sb16.c'))
 softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('via-ac97.c'))
 softmmu_ss.add(when: 'CONFIG_WM8750', if_true: files('wm8750.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_SND', if_true: files('virtio-snd.c'))
diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c
new file mode 100644
index 0000000000..ae438aa7ec
--- /dev/null
+++ b/hw/audio/virtio-snd.c
@@ -0,0 +1,126 @@
+/*
+ * Virtio Sound device
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/atomic.h"
+#include "qemu/iov.h"
+#include "qemu/main-loop.h"
+#include "qemu/module.h"
+#include "hw/virtio/virtio.h"
+#include "audio/audio.h"
+#include "qemu/error-report.h"
+#include "qemu/timer.h"
+#include "qemu/option.h"
+#include "qemu/option_int.h"
+#include "qemu/config-file.h"
+#include "qapi/qmp/qdict.h"
+#include "hw/virtio/virtio-snd.h"
+#include "hw/virtio/virtio-bus.h"
+#include "qapi/error.h"
+#include "qapi/qapi-events-audio.h"
+#include "hw/qdev-properties.h"
+#include "qapi/qapi-types-migration.h"
+#include "qapi/qapi-events-migration.h"
+#include "migration/misc.h"
+#include "standard-headers/linux/ethtool.h"
+#include "sysemu/sysemu.h"
+#include "trace.h"
+#include "monitor/qdev.h"
+#include "hw/pci/pci.h"
+#include "intel-hda-defs.h"
+
+#define VIRTIO_SOUND_VM_VERSION 1
+
+#define VIRTIO_SOUND_JACK_DEFAULT 0
+#define VIRTIO_SOUND_STREAM_DEFAULT 1
+#define VIRTIO_SOUND_CHMAP_DEFAULT 0
+
+#define VIRTIO_SOUND_HDA_FN_NID_OUT 0
+#define VIRTIO_SOUND_HDA_FN_NID_IN 1
+
+static void virtio_snd_get_config(VirtIODevice *vdev, uint8_t *config)
+{
+}
+
+static void virtio_snd_set_config(VirtIODevice *vdev, const uint8_t *config)
+{
+}
+
+static const VMStateDescription vmstate_virtio_snd_device = {
+    .name = "virtio-snd-device",
+    .version_id = VIRTIO_SOUND_VM_VERSION,
+    .minimum_version_id = VIRTIO_SOUND_VM_VERSION,
+};
+
+static const VMStateDescription vmstate_virtio_snd = {
+    .name = "virtio-sound",
+    .minimum_version_id = VIRTIO_SOUND_VM_VERSION,
+    .version_id = VIRTIO_SOUND_VM_VERSION,
+    .fields = (VMStateField[]) {
+        VMSTATE_VIRTIO_DEVICE,
+        VMSTATE_END_OF_LIST()
+    },
+};
+
+static Property virtio_snd_properties[] = {
+    DEFINE_AUDIO_PROPERTIES(VirtIOSound, card),
+    DEFINE_PROP_UINT32("jacks", VirtIOSound, snd_conf.jacks,
+                       VIRTIO_SOUND_JACK_DEFAULT),
+    DEFINE_PROP_UINT32("streams", VirtIOSound, snd_conf.streams,
+                       VIRTIO_SOUND_STREAM_DEFAULT),
+    DEFINE_PROP_UINT32("chmaps", VirtIOSound, snd_conf.chmaps,
+                       VIRTIO_SOUND_CHMAP_DEFAULT),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static uint64_t virtio_snd_get_features(VirtIODevice *vdev, uint64_t features,
+                                        Error **errp)
+{
+    return vdev->host_features;
+}
+
+static void virtio_snd_device_realize(DeviceState *dev, Error **errp)
+{
+}
+
+static void virtio_snd_device_unrealize(DeviceState *dev)
+{
+}
+
+static void virtio_snd_reset(VirtIODevice *vdev)
+{
+}
+
+static void virtio_snd_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+
+    device_class_set_props(dc, virtio_snd_properties);
+    dc->vmsd = &vmstate_virtio_snd;
+    set_bit(DEVICE_CATEGORY_SOUND, dc->categories);
+    vdc->realize = virtio_snd_device_realize;
+    vdc->unrealize = virtio_snd_device_unrealize;
+    vdc->get_config = virtio_snd_get_config;
+    vdc->set_config = virtio_snd_set_config;
+    vdc->get_features = virtio_snd_get_features;
+    vdc->reset = virtio_snd_reset;
+    vdc->legacy_features = 0;
+    vdc->vmsd = &vmstate_virtio_snd_device;
+}
+
+
+static const TypeInfo virtio_snd_dev_info = {
+    .name = TYPE_VIRTIO_SOUND,
+    .parent = TYPE_VIRTIO_DEVICE,
+    .instance_size = sizeof(VirtIOSound),
+    .class_init = virtio_snd_class_init,
+};
+
+static void virtio_register_types(void)
+{
+    type_register_static(&virtio_snd_dev_info);
+}
+
+type_init(virtio_register_types)
-- 
2.31.1



  parent reply	other threads:[~2022-02-11 22:18 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29 12:04 [RFC PATCH 00/27] Virtio sound card implementation Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 01/27] virtio-snd: Add virtio sound header file Shreyansh Chouhan
2021-04-30  9:34   ` Gerd Hoffmann
2021-04-29 12:04 ` [RFC PATCH 02/27] virtio-snd: Add jack control structures Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 03/27] virtio-snd: Add PCM " Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 04/27] virtio-snd: Add chmap " Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 05/27] virtio-snd: Add device implementation structures Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 06/27] virtio-snd: Add PCI wrapper code for VirtIOSound Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 07/27] virtio-snd: Add properties for class init Shreyansh Chouhan
2021-05-04 13:32   ` Laurent Vivier
2021-05-04 19:35     ` Shreyansh Chouhan
2021-05-04 20:30       ` Laurent Vivier
2021-05-04 21:24         ` Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 08/27] virtio-snd: Add code for get config function Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 09/27] virtio-snd: Add code for set " Shreyansh Chouhan
2021-04-30  9:55   ` Gerd Hoffmann
2021-04-29 12:04 ` [RFC PATCH 10/27] virtio-snd: Add code for the realize function Shreyansh Chouhan
     [not found]   ` <CANo3dkpB6Qn46mDGdGE4KTNqHpJkajNcnq_4BugNC5jd8r042Q@mail.gmail.com>
2021-07-22  4:52     ` Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 11/27] virtio-snd: Add macros for logging Shreyansh Chouhan
2021-04-30  9:59   ` Gerd Hoffmann
2021-04-29 12:04 ` [RFC PATCH 12/27] virtio-snd: Add control virtqueue handler Shreyansh Chouhan
2021-04-30 10:02   ` Gerd Hoffmann
2021-04-29 12:04 ` [RFC PATCH 13/27] virtio-snd: Add VIRTIO_SND_R_JACK_INFO handler Shreyansh Chouhan
2021-04-30 10:13   ` Gerd Hoffmann
2021-04-29 12:04 ` [RFC PATCH 14/27] virtio-snd: Add stub for VIRTIO_SND_R_JACK_REMAP handler Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 15/27] virtio-snd: Add VIRTIO_SND_R_PCM_INFO handler Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 16/27] virtio-snd: Add VIRITO_SND_R_PCM_SET_PARAMS handle Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 17/27] virtio-snd: Add VIRTIO_SND_R_PCM_PREPARE handler Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 18/27] virtio-snd: Add default configs to realize fn Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 19/27] virtio-snd: Add callback for SWVoiceOut Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 20/27] virtio-snd: Add VIRITO_SND_R_PCM_START handler Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 21/27] virtio-snd: Add VIRTIO_SND_R_PCM_STOP handler Shreyansh Chouhan
2021-04-30 10:22   ` Gerd Hoffmann
2021-04-29 12:04 ` [RFC PATCH 22/27] virtio-snd: Add VIRTIO_SND_R_PCM_RELEASE handler Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 23/27] virtio-snd: Replaced goto with if else Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 24/27] virtio-snd: Add code to device unrealize function Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 25/27] virtio-snd: Add tx vq and handler Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 26/27] virtio-snd: Add event vq and a handler stub Shreyansh Chouhan
2021-04-29 12:04 ` [RFC PATCH 27/27] virtio-snd: Add rx vq and stub handler Shreyansh Chouhan
2021-04-29 12:48 ` [RFC PATCH 00/27] Virtio sound card implementation no-reply
2021-04-30 10:56 ` Gerd Hoffmann
2022-02-11 22:12 ` [RFC PATCH v2 00/25] Virtio Sound card Implementation Shreyansh Chouhan
2022-02-12 19:08   ` Laurent Vivier
2022-02-14 10:44     ` Gerd Hoffmann
2022-02-14 11:11       ` Laurent Vivier
2023-02-22 13:11   ` Stefano Garzarella
2022-02-11 22:12 ` [RFC PATCH 01/25] virtio-snd: Add virtio sound header file Shreyansh Chouhan
2022-02-14 10:37   ` Gerd Hoffmann
2022-02-11 22:12 ` [RFC PATCH 02/25] virtio-snd: Add jack control structures Shreyansh Chouhan
2022-02-11 22:12 ` [RFC PATCH 03/25] virtio-snd: Add PCM " Shreyansh Chouhan
2022-02-11 22:12 ` [RFC PATCH 04/25] virtio-snd: Add chmap " Shreyansh Chouhan
2022-02-11 22:12 ` [RFC PATCH 05/25] virtio-snd: Add device implementation structures Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 06/25] virtio-snd: Add PCI wrapper code for VirtIOSound Shreyansh Chouhan
2022-02-11 22:13 ` Shreyansh Chouhan [this message]
2022-02-11 22:13 ` [RFC PATCH 08/25] virtio-snd: Add code for get config function Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 09/25] virtio-snd: Add code for the realize function Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 10/25] virtio-snd: Add macros for logging Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 11/25] virtio-snd: Add control virtqueue handler Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 12/25] virtio-snd: Add VIRTIO_SND_R_JACK_INFO handler Shreyansh Chouhan
2022-02-12 19:10   ` Laurent Vivier
2022-02-11 22:13 ` [RFC PATCH 13/25] virtio-snd: Add stub for VIRTIO_SND_R_JACK_REMAP handler Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 14/25] virtio-snd: Add VIRTIO_SND_R_PCM_INFO handler Shreyansh Chouhan
2022-02-12 19:20   ` Laurent Vivier
2022-02-11 22:13 ` [RFC PATCH 15/25] virtio-snd: Add VIRITO_SND_R_PCM_SET_PARAMS handle Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 16/25] virtio-snd: Add VIRTIO_SND_R_PCM_PREPARE handler Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 17/25] virtio-snd: Add default configs to realize fn Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 18/25] virtio-snd: Add callback for SWVoiceOut Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 19/25] virtio-snd: Add start/stop handler Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 20/25] virtio-snd: Add VIRTIO_SND_R_PCM_RELEASE handler Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 21/25] virtio-snd: Replaced goto with if else Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 22/25] virtio-snd: Add code to device unrealize function Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 23/25] virtio-snd: Add xfer handler Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 24/25] virtio-snd: Add event vq and a handler stub Shreyansh Chouhan
2022-02-11 22:13 ` [RFC PATCH 25/25] virtio-snd: Replaced AUD_log with tracepoints Shreyansh Chouhan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220211221319.193404-8-chouhan.shreyansh2702@gmail.com \
    --to=chouhan.shreyansh2702@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=laurent@vivier.eu \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.