summaryrefslogtreecommitdiff
path: root/sound/virtio/virtio_pcm.h
diff options
context:
space:
mode:
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 */