summaryrefslogtreecommitdiff
path: root/sound/virtio/virtio_pcm.h
diff options
context:
space:
mode:
authorAnton Yakovlev <anton.yakovlev@opensynergy.com>2021-03-02 17:47:05 +0100
committerTakashi Iwai <tiwai@suse.de>2021-03-07 09:07:44 +0100
commitf40a28679e0b7cb3a9cc6627a8dbb40961990f0a (patch)
treef3666982bba98fc53612b03b559b80206d6bd7c9 /sound/virtio/virtio_pcm.h
parent29b96bf50ba958eb5f097cdc3fbd4c1acf9547a2 (diff)
ALSA: virtio: handling control and I/O messages for the PCM device
The driver implements a message-based transport for I/O substream operations. Before the start of the substream, the hardware buffer is sliced into I/O messages, the number of which is equal to the current number of periods. The size of each message is equal to the current size of one period. I/O messages are organized in an ordered queue. The completion of the I/O message indicates an elapsed period (the only exception is the end of the stream for the capture substream). Upon completion, the message is automatically re-added to the end of the queue. Signed-off-by: Anton Yakovlev <anton.yakovlev@opensynergy.com> Link: https://lore.kernel.org/r/20210302164709.3142702-6-anton.yakovlev@opensynergy.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/virtio/virtio_pcm.h')
-rw-r--r--sound/virtio/virtio_pcm.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/sound/virtio/virtio_pcm.h b/sound/virtio/virtio_pcm.h
index 84f2f3f14f48..6722f1139666 100644
--- a/sound/virtio/virtio_pcm.h
+++ b/sound/virtio/virtio_pcm.h
@@ -23,6 +23,17 @@ struct virtio_pcm_msg;
* @substream: Kernel ALSA substream.
* @hw: Kernel ALSA substream hardware descriptor.
* @elapsed_period: Kernel work to handle the elapsed period state.
+ * @lock: Spinlock that protects fields shared by interrupt handlers and
+ * substream operators.
+ * @buffer_bytes: Current buffer size in bytes.
+ * @hw_ptr: Substream hardware pointer value in bytes [0 ... buffer_bytes).
+ * @xfer_enabled: Data transfer state (0 - off, 1 - on).
+ * @xfer_xrun: Data underflow/overflow state (0 - no xrun, 1 - xrun).
+ * @msgs: Allocated I/O messages.
+ * @nmsgs: Number of allocated I/O messages.
+ * @msg_last_enqueued: Index of the last I/O message added to the virtqueue.
+ * @msg_count: Number of pending I/O messages in the virtqueue.
+ * @msg_empty: Notify when msg_count is zero.
*/
struct virtio_pcm_substream {
struct virtio_snd *snd;
@@ -33,6 +44,16 @@ struct virtio_pcm_substream {
struct snd_pcm_substream *substream;
struct snd_pcm_hardware hw;
struct work_struct elapsed_period;
+ spinlock_t lock;
+ size_t buffer_bytes;
+ size_t hw_ptr;
+ bool xfer_enabled;
+ bool xfer_xrun;
+ struct virtio_pcm_msg **msgs;
+ unsigned int nmsgs;
+ int msg_last_enqueued;
+ unsigned int msg_count;
+ wait_queue_head_t msg_empty;
};
/**
@@ -65,8 +86,27 @@ int virtsnd_pcm_parse_cfg(struct virtio_snd *snd);
int virtsnd_pcm_build_devs(struct virtio_snd *snd);
+void virtsnd_pcm_event(struct virtio_snd *snd, struct virtio_snd_event *event);
+
+void virtsnd_pcm_tx_notify_cb(struct virtqueue *vqueue);
+
+void virtsnd_pcm_rx_notify_cb(struct virtqueue *vqueue);
+
struct virtio_pcm *virtsnd_pcm_find(struct virtio_snd *snd, u32 nid);
struct virtio_pcm *virtsnd_pcm_find_or_create(struct virtio_snd *snd, u32 nid);
+struct virtio_snd_msg *
+virtsnd_pcm_ctl_msg_alloc(struct virtio_pcm_substream *vss,
+ unsigned int command, gfp_t gfp);
+
+int virtsnd_pcm_msg_alloc(struct virtio_pcm_substream *vss,
+ unsigned int periods, unsigned int period_bytes);
+
+void virtsnd_pcm_msg_free(struct virtio_pcm_substream *vss);
+
+int virtsnd_pcm_msg_send(struct virtio_pcm_substream *vss);
+
+unsigned int virtsnd_pcm_msg_pending_num(struct virtio_pcm_substream *vss);
+
#endif /* VIRTIO_SND_PCM_H */