1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * virtio-snd: Virtio sound device 4 * Copyright (C) 2021 OpenSynergy GmbH 5 */ 6 #ifndef VIRTIO_SND_CARD_H 7 #define VIRTIO_SND_CARD_H 8 9 #include <linux/slab.h> 10 #include <linux/virtio.h> 11 #include <sound/core.h> 12 #include <uapi/linux/virtio_snd.h> 13 14 #define VIRTIO_SND_CARD_DRIVER "virtio-snd" 15 #define VIRTIO_SND_CARD_NAME "VirtIO SoundCard" 16 17 /** 18 * struct virtio_snd_queue - Virtqueue wrapper structure. 19 * @lock: Used to synchronize access to a virtqueue. 20 * @vqueue: Underlying virtqueue. 21 */ 22 struct virtio_snd_queue { 23 spinlock_t lock; 24 struct virtqueue *vqueue; 25 }; 26 27 /** 28 * struct virtio_snd - VirtIO sound card device. 29 * @vdev: Underlying virtio device. 30 * @queues: Virtqueue wrappers. 31 * @card: ALSA sound card. 32 * @event_msgs: Device events. 33 */ 34 struct virtio_snd { 35 struct virtio_device *vdev; 36 struct virtio_snd_queue queues[VIRTIO_SND_VQ_MAX]; 37 struct snd_card *card; 38 struct virtio_snd_event *event_msgs; 39 }; 40 41 static inline struct virtio_snd_queue * 42 virtsnd_control_queue(struct virtio_snd *snd) 43 { 44 return &snd->queues[VIRTIO_SND_VQ_CONTROL]; 45 } 46 47 static inline struct virtio_snd_queue * 48 virtsnd_event_queue(struct virtio_snd *snd) 49 { 50 return &snd->queues[VIRTIO_SND_VQ_EVENT]; 51 } 52 53 static inline struct virtio_snd_queue * 54 virtsnd_tx_queue(struct virtio_snd *snd) 55 { 56 return &snd->queues[VIRTIO_SND_VQ_TX]; 57 } 58 59 static inline struct virtio_snd_queue * 60 virtsnd_rx_queue(struct virtio_snd *snd) 61 { 62 return &snd->queues[VIRTIO_SND_VQ_RX]; 63 } 64 65 #endif /* VIRTIO_SND_CARD_H */ 66