linux/sound/virtio/virtio_card.h
Anton Yakovlev 29b96bf50b ALSA: virtio: build PCM devices and substream hardware descriptors
Like the HDA specification, the virtio sound device specification links
PCM substreams, jacks and PCM channel maps into functional groups. For
each discovered group, a PCM device is created, the number of which
coincides with the group number.

Introduce the module parameters for setting the hardware buffer
parameters:
  pcm_buffer_ms [=160]
  pcm_periods_min [=2]
  pcm_periods_max [=16]
  pcm_period_ms_min [=10]
  pcm_period_ms_max [=80]

Signed-off-by: Anton Yakovlev <anton.yakovlev@opensynergy.com>
Link: https://lore.kernel.org/r/20210302164709.3142702-5-anton.yakovlev@opensynergy.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-03-07 09:07:35 +01:00

83 lines
2.0 KiB
C

/* SPDX-License-Identifier: GPL-2.0+ */
/*
* virtio-snd: Virtio sound device
* Copyright (C) 2021 OpenSynergy GmbH
*/
#ifndef VIRTIO_SND_CARD_H
#define VIRTIO_SND_CARD_H
#include <linux/slab.h>
#include <linux/virtio.h>
#include <sound/core.h>
#include <uapi/linux/virtio_snd.h>
#include "virtio_ctl_msg.h"
#include "virtio_pcm.h"
#define VIRTIO_SND_CARD_DRIVER "virtio-snd"
#define VIRTIO_SND_CARD_NAME "VirtIO SoundCard"
#define VIRTIO_SND_PCM_NAME "VirtIO PCM"
struct virtio_pcm_substream;
/**
* struct virtio_snd_queue - Virtqueue wrapper structure.
* @lock: Used to synchronize access to a virtqueue.
* @vqueue: Underlying virtqueue.
*/
struct virtio_snd_queue {
spinlock_t lock;
struct virtqueue *vqueue;
};
/**
* struct virtio_snd - VirtIO sound card device.
* @vdev: Underlying virtio device.
* @queues: Virtqueue wrappers.
* @card: ALSA sound card.
* @ctl_msgs: Pending control request list.
* @event_msgs: Device events.
* @pcm_list: VirtIO PCM device list.
* @substreams: VirtIO PCM substreams.
* @nsubstreams: Number of PCM substreams.
*/
struct virtio_snd {
struct virtio_device *vdev;
struct virtio_snd_queue queues[VIRTIO_SND_VQ_MAX];
struct snd_card *card;
struct list_head ctl_msgs;
struct virtio_snd_event *event_msgs;
struct list_head pcm_list;
struct virtio_pcm_substream *substreams;
u32 nsubstreams;
};
/* Message completion timeout in milliseconds (module parameter). */
extern u32 virtsnd_msg_timeout_ms;
static inline struct virtio_snd_queue *
virtsnd_control_queue(struct virtio_snd *snd)
{
return &snd->queues[VIRTIO_SND_VQ_CONTROL];
}
static inline struct virtio_snd_queue *
virtsnd_event_queue(struct virtio_snd *snd)
{
return &snd->queues[VIRTIO_SND_VQ_EVENT];
}
static inline struct virtio_snd_queue *
virtsnd_tx_queue(struct virtio_snd *snd)
{
return &snd->queues[VIRTIO_SND_VQ_TX];
}
static inline struct virtio_snd_queue *
virtsnd_rx_queue(struct virtio_snd *snd)
{
return &snd->queues[VIRTIO_SND_VQ_RX];
}
#endif /* VIRTIO_SND_CARD_H */