0001
0002
0003
0004
0005
0006 #ifndef VIRTIO_SND_CARD_H
0007 #define VIRTIO_SND_CARD_H
0008
0009 #include <linux/slab.h>
0010 #include <linux/virtio.h>
0011 #include <sound/core.h>
0012 #include <uapi/linux/virtio_snd.h>
0013
0014 #include "virtio_ctl_msg.h"
0015 #include "virtio_pcm.h"
0016
0017 #define VIRTIO_SND_CARD_DRIVER "virtio-snd"
0018 #define VIRTIO_SND_CARD_NAME "VirtIO SoundCard"
0019 #define VIRTIO_SND_PCM_NAME "VirtIO PCM"
0020
0021 struct virtio_jack;
0022 struct virtio_pcm_substream;
0023
0024
0025
0026
0027
0028
0029 struct virtio_snd_queue {
0030 spinlock_t lock;
0031 struct virtqueue *vqueue;
0032 };
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049 struct virtio_snd {
0050 struct virtio_device *vdev;
0051 struct virtio_snd_queue queues[VIRTIO_SND_VQ_MAX];
0052 struct snd_card *card;
0053 struct list_head ctl_msgs;
0054 struct virtio_snd_event *event_msgs;
0055 struct list_head pcm_list;
0056 struct virtio_jack *jacks;
0057 u32 njacks;
0058 struct virtio_pcm_substream *substreams;
0059 u32 nsubstreams;
0060 struct virtio_snd_chmap_info *chmaps;
0061 u32 nchmaps;
0062 };
0063
0064
0065 extern u32 virtsnd_msg_timeout_ms;
0066
0067 static inline struct virtio_snd_queue *
0068 virtsnd_control_queue(struct virtio_snd *snd)
0069 {
0070 return &snd->queues[VIRTIO_SND_VQ_CONTROL];
0071 }
0072
0073 static inline struct virtio_snd_queue *
0074 virtsnd_event_queue(struct virtio_snd *snd)
0075 {
0076 return &snd->queues[VIRTIO_SND_VQ_EVENT];
0077 }
0078
0079 static inline struct virtio_snd_queue *
0080 virtsnd_tx_queue(struct virtio_snd *snd)
0081 {
0082 return &snd->queues[VIRTIO_SND_VQ_TX];
0083 }
0084
0085 static inline struct virtio_snd_queue *
0086 virtsnd_rx_queue(struct virtio_snd *snd)
0087 {
0088 return &snd->queues[VIRTIO_SND_VQ_RX];
0089 }
0090
0091 static inline struct virtio_snd_queue *
0092 virtsnd_pcm_queue(struct virtio_pcm_substream *vss)
0093 {
0094 if (vss->direction == SNDRV_PCM_STREAM_PLAYBACK)
0095 return virtsnd_tx_queue(vss->snd);
0096 else
0097 return virtsnd_rx_queue(vss->snd);
0098 }
0099
0100 int virtsnd_jack_parse_cfg(struct virtio_snd *snd);
0101
0102 int virtsnd_jack_build_devs(struct virtio_snd *snd);
0103
0104 void virtsnd_jack_event(struct virtio_snd *snd,
0105 struct virtio_snd_event *event);
0106
0107 int virtsnd_chmap_parse_cfg(struct virtio_snd *snd);
0108
0109 int virtsnd_chmap_build_devs(struct virtio_snd *snd);
0110
0111 #endif