summaryrefslogtreecommitdiff
path: root/sound/virtio/virtio_card.c
diff options
context:
space:
mode:
authorAnton Yakovlev <anton.yakovlev@opensynergy.com>2024-01-15 14:36:54 +0100
committerTakashi Iwai <tiwai@suse.de>2024-02-09 14:01:15 +0100
commitd6568e3de42dd971a1356f7ba581e6600d53f0a0 (patch)
treeff2ff816b0c3c7e88d11f96c76c9fdc743cd4e85 /sound/virtio/virtio_card.c
parenta097812310b5748358e32d87c6c1c18d249a397b (diff)
ALSA: virtio: add support for audio controls
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>
Diffstat (limited to 'sound/virtio/virtio_card.c')
-rw-r--r--sound/virtio/virtio_card.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sound/virtio/virtio_card.c b/sound/virtio/virtio_card.c
index b158c3cb8e5f..2da20c625247 100644
--- a/sound/virtio/virtio_card.c
+++ b/sound/virtio/virtio_card.c
@@ -64,6 +64,9 @@ static void virtsnd_event_dispatch(struct virtio_snd *snd,
case VIRTIO_SND_EVT_PCM_XRUN:
virtsnd_pcm_event(snd, event);
break;
+ case VIRTIO_SND_EVT_CTL_NOTIFY:
+ virtsnd_kctl_event(snd, event);
+ break;
}
}
@@ -233,6 +236,12 @@ static int virtsnd_build_devs(struct virtio_snd *snd)
if (rc)
return rc;
+ if (virtio_has_feature(vdev, VIRTIO_SND_F_CTLS)) {
+ rc = virtsnd_kctl_parse_cfg(snd);
+ if (rc)
+ return rc;
+ }
+
if (snd->njacks) {
rc = virtsnd_jack_build_devs(snd);
if (rc)
@@ -251,6 +260,12 @@ static int virtsnd_build_devs(struct virtio_snd *snd)
return rc;
}
+ if (snd->nkctls) {
+ rc = virtsnd_kctl_build_devs(snd);
+ if (rc)
+ return rc;
+ }
+
return snd_card_register(snd->card);
}
@@ -417,10 +432,16 @@ static const struct virtio_device_id id_table[] = {
{ 0 },
};
+static unsigned int features[] = {
+ VIRTIO_SND_F_CTLS
+};
+
static struct virtio_driver virtsnd_driver = {
.driver.name = KBUILD_MODNAME,
.driver.owner = THIS_MODULE,
.id_table = id_table,
+ .feature_table = features,
+ .feature_table_size = ARRAY_SIZE(features),
.validate = virtsnd_validate,
.probe = virtsnd_probe,
.remove = virtsnd_remove,