// SPDX-License-Identifier: GPL-2.0+ /* * virtio-snd: Virtio sound device * Copyright (C) 2021 OpenSynergy GmbH */ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/virtio_config.h> #include <sound/initval.h> #include <uapi/linux/virtio_ids.h> #include "virtio_card.h" u32 virtsnd_msg_timeout_ms = …; module_param_named(msg_timeout_ms, virtsnd_msg_timeout_ms, uint, 0644); MODULE_PARM_DESC(…) …; static void virtsnd_remove(struct virtio_device *vdev); /** * virtsnd_event_send() - Add an event to the event queue. * @vqueue: Underlying event virtqueue. * @event: Event. * @notify: Indicates whether or not to send a notification to the device. * @gfp: Kernel flags for memory allocation. * * Context: Any context. */ static void virtsnd_event_send(struct virtqueue *vqueue, struct virtio_snd_event *event, bool notify, gfp_t gfp) { … } /** * virtsnd_event_dispatch() - Dispatch an event from the device side. * @snd: VirtIO sound device. * @event: VirtIO sound event. * * Context: Any context. */ static void virtsnd_event_dispatch(struct virtio_snd *snd, struct virtio_snd_event *event) { … } /** * virtsnd_event_notify_cb() - Dispatch all reported events from the event queue. * @vqueue: Underlying event virtqueue. * * This callback function is called upon a vring interrupt request from the * device. * * Context: Interrupt context. */ static void virtsnd_event_notify_cb(struct virtqueue *vqueue) { … } /** * virtsnd_find_vqs() - Enumerate and initialize all virtqueues. * @snd: VirtIO sound device. * * After calling this function, the event queue is disabled. * * Context: Any context. * Return: 0 on success, -errno on failure. */ static int virtsnd_find_vqs(struct virtio_snd *snd) { … } /** * virtsnd_enable_event_vq() - Enable the event virtqueue. * @snd: VirtIO sound device. * * Context: Any context. */ static void virtsnd_enable_event_vq(struct virtio_snd *snd) { … } /** * virtsnd_disable_event_vq() - Disable the event virtqueue. * @snd: VirtIO sound device. * * Context: Any context. */ static void virtsnd_disable_event_vq(struct virtio_snd *snd) { … } /** * virtsnd_build_devs() - Read configuration and build ALSA devices. * @snd: VirtIO sound device. * * Context: Any context that permits to sleep. * Return: 0 on success, -errno on failure. */ static int virtsnd_build_devs(struct virtio_snd *snd) { … } /** * virtsnd_validate() - Validate if the device can be started. * @vdev: VirtIO parent device. * * Context: Any context. * Return: 0 on success, -EINVAL on failure. */ static int virtsnd_validate(struct virtio_device *vdev) { … } /** * virtsnd_probe() - Create and initialize the device. * @vdev: VirtIO parent device. * * Context: Any context that permits to sleep. * Return: 0 on success, -errno on failure. */ static int virtsnd_probe(struct virtio_device *vdev) { … } /** * virtsnd_remove() - Remove VirtIO and ALSA devices. * @vdev: VirtIO parent device. * * Context: Any context that permits to sleep. */ static void virtsnd_remove(struct virtio_device *vdev) { … } #ifdef CONFIG_PM_SLEEP /** * virtsnd_freeze() - Suspend device. * @vdev: VirtIO parent device. * * Context: Any context. * Return: 0 on success, -errno on failure. */ static int virtsnd_freeze(struct virtio_device *vdev) { … } /** * virtsnd_restore() - Resume device. * @vdev: VirtIO parent device. * * Context: Any context. * Return: 0 on success, -errno on failure. */ static int virtsnd_restore(struct virtio_device *vdev) { … } #endif /* CONFIG_PM_SLEEP */ static const struct virtio_device_id id_table[] = …; static unsigned int features[] = …; static struct virtio_driver virtsnd_driver = …; module_virtio_driver(…) …; MODULE_DEVICE_TABLE(virtio, id_table); MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;