mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
d6568e3de4
Implementation of support for audio controls in accordance with the extension of the virtio sound device specification [1] planned for virtio-v1.3-cs01. The device can announce the VIRTIO_SND_F_CTLS feature. If the feature is negotiated, then an additional field appears in the configuration space: struct virtio_snd_config { ... /* number of available control elements */ __le32 controls; }; The driver can send the following requests to manage audio controls: enum { ... /* control element request types */ VIRTIO_SND_R_CTL_INFO = 0x0300, VIRTIO_SND_R_CTL_ENUM_ITEMS, VIRTIO_SND_R_CTL_READ, VIRTIO_SND_R_CTL_WRITE, VIRTIO_SND_R_CTL_TLV_READ, VIRTIO_SND_R_CTL_TLV_WRITE, VIRTIO_SND_R_CTL_TLV_COMMAND, ... }; And the device can send the following audio control event notification: enum { ... /* control element event types */ VIRTIO_SND_EVT_CTL_NOTIFY = 0x1200, ... }; See additional details in [1]. [1] https://lists.oasis-open.org/archives/virtio-comment/202104/msg00013.html Signed-off-by: Anton Yakovlev <anton.yakovlev@opensynergy.com> Signed-off-by: Aiswarya Cyriac <aiswarya.cyriac@opensynergy.com> Link: https://lore.kernel.org/r/20240115133654.576068-2-aiswarya.cyriac@opensynergy.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
134 lines
3.3 KiB
C
134 lines
3.3 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_jack;
|
|
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_kctl - VirtIO control element.
|
|
* @kctl: ALSA control element.
|
|
* @items: Items for the ENUMERATED element type.
|
|
*/
|
|
struct virtio_kctl {
|
|
struct snd_kcontrol *kctl;
|
|
struct virtio_snd_ctl_enum_item *items;
|
|
};
|
|
|
|
/**
|
|
* 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.
|
|
* @jacks: VirtIO jacks.
|
|
* @njacks: Number of jacks.
|
|
* @substreams: VirtIO PCM substreams.
|
|
* @nsubstreams: Number of PCM substreams.
|
|
* @chmaps: VirtIO channel maps.
|
|
* @nchmaps: Number of channel maps.
|
|
* @kctl_infos: VirtIO control element information.
|
|
* @kctls: VirtIO control elements.
|
|
* @nkctls: Number of control elements.
|
|
*/
|
|
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_jack *jacks;
|
|
u32 njacks;
|
|
struct virtio_pcm_substream *substreams;
|
|
u32 nsubstreams;
|
|
struct virtio_snd_chmap_info *chmaps;
|
|
u32 nchmaps;
|
|
struct virtio_snd_ctl_info *kctl_infos;
|
|
struct virtio_kctl *kctls;
|
|
u32 nkctls;
|
|
};
|
|
|
|
/* 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];
|
|
}
|
|
|
|
static inline struct virtio_snd_queue *
|
|
virtsnd_pcm_queue(struct virtio_pcm_substream *vss)
|
|
{
|
|
if (vss->direction == SNDRV_PCM_STREAM_PLAYBACK)
|
|
return virtsnd_tx_queue(vss->snd);
|
|
else
|
|
return virtsnd_rx_queue(vss->snd);
|
|
}
|
|
|
|
int virtsnd_jack_parse_cfg(struct virtio_snd *snd);
|
|
|
|
int virtsnd_jack_build_devs(struct virtio_snd *snd);
|
|
|
|
void virtsnd_jack_event(struct virtio_snd *snd,
|
|
struct virtio_snd_event *event);
|
|
|
|
int virtsnd_chmap_parse_cfg(struct virtio_snd *snd);
|
|
|
|
int virtsnd_chmap_build_devs(struct virtio_snd *snd);
|
|
|
|
int virtsnd_kctl_parse_cfg(struct virtio_snd *snd);
|
|
|
|
int virtsnd_kctl_build_devs(struct virtio_snd *snd);
|
|
|
|
void virtsnd_kctl_event(struct virtio_snd *snd, struct virtio_snd_event *event);
|
|
|
|
#endif /* VIRTIO_SND_CARD_H */
|