[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 05/27] virtio-snd: Add device implementation structures
From: |
Shreyansh Chouhan |
Subject: |
[RFC PATCH 05/27] virtio-snd: Add device implementation structures |
Date: |
Thu, 29 Apr 2021 17:34:23 +0530 |
Added jacks, pcm streams and the VirtIOSound structure for actual
device implementation.
Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh2702@gmail.com>
---
include/hw/virtio/virtio-snd.h | 64 ++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/include/hw/virtio/virtio-snd.h b/include/hw/virtio/virtio-snd.h
index ad068e5893..6ab131db50 100644
--- a/include/hw/virtio/virtio-snd.h
+++ b/include/hw/virtio/virtio-snd.h
@@ -13,6 +13,9 @@
#define VIRTIO_ID_SOUND 25
+#define TYPE_VIRTIO_SOUND "virtio-sound-device"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOSound, VIRTIO_SOUND)
+
/* CONFIGURATION SPACE */
typedef struct virtio_snd_config {
@@ -326,4 +329,65 @@ typedef struct virtio_snd_chmap_info {
uint8_t positions[VIRTIO_SND_CHMAP_MAX_SIZE];
} virtio_snd_chmap_info;
+/* VIRTIO SOUND DEVICE */
+
+/* Jacks */
+typedef struct virtio_snd_jack {
+ uint32_t features; /* 1 << VIRTIO_SND_JACK_F_XXX */
+ uint32_t hda_fn_nid;
+ uint32_t hda_reg_defconf;
+ uint32_t hda_reg_caps;
+ uint8_t connected;
+} virtio_snd_jack;
+
+/* Streams */
+typedef struct virtio_snd_pcm_stream {
+ uint32_t hda_fn_nid;
+ uint32_t buffer_bytes;
+ uint32_t period_bytes;
+ uint32_t features; /* 1 << VIRTIO_SND_PCM_F_XXX */
+ uint32_t flags; /* 1 << VIRTIO_SND_PCM_FL_XXX */
+ uint32_t direction;
+ uint8_t channels_min;
+ uint8_t channels_max;
+ uint64_t formats; /* 1 << VIRTIO_SND_PCM_FMT_XXX */
+ uint64_t rates; /* 1 << VIRTIO_SND_PCM_RATE_XXX */
+ int tail, r_pos, w_pos;
+ VirtQueueElement **elems;
+ VirtIOSound *s;
+ union {
+ SWVoiceIn *in;
+ SWVoiceOut *out;
+ } voice;
+} virtio_snd_pcm_stream;
+
+/* Stream params */
+typedef struct virtio_snd_pcm_params {
+ uint32_t features;
+ uint32_t buffer_bytes; /* size of hardware buffer in bytes */
+ uint32_t period_bytes; /* size of hardware period in bytes */
+ uint8_t channel;
+ uint8_t format;
+ uint8_t rate;
+} virtio_snd_pcm_params;
+
+/* Sound device */
+struct VirtIOSound {
+ /* Parent VirtIODevice object */
+ VirtIODevice parent_obj;
+ virtio_snd_config snd_conf;
+
+ VirtQueue *ctrl_vq;
+ VirtQueue *event_vq;
+ VirtQueue *tx_vq;
+ VirtQueue *rx_vq;
+
+ QEMUSoundCard card;
+ size_t config_size;
+
+ virtio_snd_pcm_params **pcm_params;
+ virtio_snd_pcm_stream **streams;
+ virtio_snd_jack **jacks;
+};
+
#endif
--
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 <=
- [RFC PATCH 06/27] virtio-snd: Add PCI wrapper code for VirtIOSound, Shreyansh Chouhan, 2021/04/29
- [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