Linux Audio

Check our new training course

Buildroot integration, development and maintenance

Need a Buildroot system for your embedded project?
Loading...
v6.2
 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_MSG_H
 7#define VIRTIO_SND_MSG_H
 8
 9#include <linux/atomic.h>
10#include <linux/virtio.h>
11
12struct virtio_snd;
13struct virtio_snd_msg;
14
15void virtsnd_ctl_msg_ref(struct virtio_snd_msg *msg);
16
17void virtsnd_ctl_msg_unref(struct virtio_snd_msg *msg);
18
19void *virtsnd_ctl_msg_request(struct virtio_snd_msg *msg);
20
21void *virtsnd_ctl_msg_response(struct virtio_snd_msg *msg);
22
23struct virtio_snd_msg *virtsnd_ctl_msg_alloc(size_t request_size,
24					     size_t response_size, gfp_t gfp);
25
26int virtsnd_ctl_msg_send(struct virtio_snd *snd, struct virtio_snd_msg *msg,
27			 struct scatterlist *out_sgs,
28			 struct scatterlist *in_sgs, bool nowait);
29
30/**
31 * virtsnd_ctl_msg_send_sync() - Simplified sending of synchronous message.
32 * @snd: VirtIO sound device.
33 * @msg: Control message.
34 *
35 * After returning from this function, the message will be deleted. If message
36 * content is still needed, the caller must additionally to
37 * virtsnd_ctl_msg_ref/unref() it.
38 *
39 * The msg_timeout_ms module parameter defines the message completion timeout.
40 * If the message is not completed within this time, the function will return an
41 * error.
42 *
43 * Context: Any context that permits to sleep.
44 * Return: 0 on success, -errno on failure.
45 *
46 * The return value is a message status code (VIRTIO_SND_S_XXX) converted to an
47 * appropriate -errno value.
48 */
49static inline int virtsnd_ctl_msg_send_sync(struct virtio_snd *snd,
50					    struct virtio_snd_msg *msg)
51{
52	return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, false);
53}
54
55/**
56 * virtsnd_ctl_msg_send_async() - Simplified sending of asynchronous message.
57 * @snd: VirtIO sound device.
58 * @msg: Control message.
59 *
60 * Context: Any context.
61 * Return: 0 on success, -errno on failure.
62 */
63static inline int virtsnd_ctl_msg_send_async(struct virtio_snd *snd,
64					     struct virtio_snd_msg *msg)
65{
66	return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, true);
67}
68
69void virtsnd_ctl_msg_cancel_all(struct virtio_snd *snd);
70
71void virtsnd_ctl_msg_complete(struct virtio_snd_msg *msg);
72
73int virtsnd_ctl_query_info(struct virtio_snd *snd, int command, int start_id,
74			   int count, size_t size, void *info);
75
76void virtsnd_ctl_notify_cb(struct virtqueue *vqueue);
77
78#endif /* VIRTIO_SND_MSG_H */
v6.13.7
 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_MSG_H
 7#define VIRTIO_SND_MSG_H
 8
 9#include <linux/atomic.h>
10#include <linux/virtio.h>
11
12struct virtio_snd;
13struct virtio_snd_msg;
14
15void virtsnd_ctl_msg_ref(struct virtio_snd_msg *msg);
16
17void virtsnd_ctl_msg_unref(struct virtio_snd_msg *msg);
18
19void *virtsnd_ctl_msg_request(struct virtio_snd_msg *msg);
20
21void *virtsnd_ctl_msg_response(struct virtio_snd_msg *msg);
22
23struct virtio_snd_msg *virtsnd_ctl_msg_alloc(size_t request_size,
24					     size_t response_size, gfp_t gfp);
25
26int virtsnd_ctl_msg_send(struct virtio_snd *snd, struct virtio_snd_msg *msg,
27			 struct scatterlist *out_sgs,
28			 struct scatterlist *in_sgs, bool nowait);
29
30/**
31 * virtsnd_ctl_msg_send_sync() - Simplified sending of synchronous message.
32 * @snd: VirtIO sound device.
33 * @msg: Control message.
34 *
35 * After returning from this function, the message will be deleted. If message
36 * content is still needed, the caller must additionally to
37 * virtsnd_ctl_msg_ref/unref() it.
38 *
39 * The msg_timeout_ms module parameter defines the message completion timeout.
40 * If the message is not completed within this time, the function will return an
41 * error.
42 *
43 * Context: Any context that permits to sleep.
44 * Return: 0 on success, -errno on failure.
45 *
46 * The return value is a message status code (VIRTIO_SND_S_XXX) converted to an
47 * appropriate -errno value.
48 */
49static inline int virtsnd_ctl_msg_send_sync(struct virtio_snd *snd,
50					    struct virtio_snd_msg *msg)
51{
52	return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, false);
53}
54
55/**
56 * virtsnd_ctl_msg_send_async() - Simplified sending of asynchronous message.
57 * @snd: VirtIO sound device.
58 * @msg: Control message.
59 *
60 * Context: Any context.
61 * Return: 0 on success, -errno on failure.
62 */
63static inline int virtsnd_ctl_msg_send_async(struct virtio_snd *snd,
64					     struct virtio_snd_msg *msg)
65{
66	return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, true);
67}
68
69void virtsnd_ctl_msg_cancel_all(struct virtio_snd *snd);
70
71void virtsnd_ctl_msg_complete(struct virtio_snd_msg *msg);
72
73int virtsnd_ctl_query_info(struct virtio_snd *snd, int command, int start_id,
74			   int count, size_t size, void *info);
75
76void virtsnd_ctl_notify_cb(struct virtqueue *vqueue);
77
78#endif /* VIRTIO_SND_MSG_H */