Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * virtio-snd: Virtio sound device
0004  * Copyright (C) 2021 OpenSynergy GmbH
0005  */
0006 #ifndef VIRTIO_SND_MSG_H
0007 #define VIRTIO_SND_MSG_H
0008 
0009 #include <linux/atomic.h>
0010 #include <linux/virtio.h>
0011 
0012 struct virtio_snd;
0013 struct virtio_snd_msg;
0014 
0015 void virtsnd_ctl_msg_ref(struct virtio_snd_msg *msg);
0016 
0017 void virtsnd_ctl_msg_unref(struct virtio_snd_msg *msg);
0018 
0019 void *virtsnd_ctl_msg_request(struct virtio_snd_msg *msg);
0020 
0021 void *virtsnd_ctl_msg_response(struct virtio_snd_msg *msg);
0022 
0023 struct virtio_snd_msg *virtsnd_ctl_msg_alloc(size_t request_size,
0024                          size_t response_size, gfp_t gfp);
0025 
0026 int virtsnd_ctl_msg_send(struct virtio_snd *snd, struct virtio_snd_msg *msg,
0027              struct scatterlist *out_sgs,
0028              struct scatterlist *in_sgs, bool nowait);
0029 
0030 /**
0031  * virtsnd_ctl_msg_send_sync() - Simplified sending of synchronous message.
0032  * @snd: VirtIO sound device.
0033  * @msg: Control message.
0034  *
0035  * After returning from this function, the message will be deleted. If message
0036  * content is still needed, the caller must additionally to
0037  * virtsnd_ctl_msg_ref/unref() it.
0038  *
0039  * The msg_timeout_ms module parameter defines the message completion timeout.
0040  * If the message is not completed within this time, the function will return an
0041  * error.
0042  *
0043  * Context: Any context that permits to sleep.
0044  * Return: 0 on success, -errno on failure.
0045  *
0046  * The return value is a message status code (VIRTIO_SND_S_XXX) converted to an
0047  * appropriate -errno value.
0048  */
0049 static inline int virtsnd_ctl_msg_send_sync(struct virtio_snd *snd,
0050                         struct virtio_snd_msg *msg)
0051 {
0052     return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, false);
0053 }
0054 
0055 /**
0056  * virtsnd_ctl_msg_send_async() - Simplified sending of asynchronous message.
0057  * @snd: VirtIO sound device.
0058  * @msg: Control message.
0059  *
0060  * Context: Any context.
0061  * Return: 0 on success, -errno on failure.
0062  */
0063 static inline int virtsnd_ctl_msg_send_async(struct virtio_snd *snd,
0064                          struct virtio_snd_msg *msg)
0065 {
0066     return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, true);
0067 }
0068 
0069 void virtsnd_ctl_msg_cancel_all(struct virtio_snd *snd);
0070 
0071 void virtsnd_ctl_msg_complete(struct virtio_snd_msg *msg);
0072 
0073 int virtsnd_ctl_query_info(struct virtio_snd *snd, int command, int start_id,
0074                int count, size_t size, void *info);
0075 
0076 void virtsnd_ctl_notify_cb(struct virtqueue *vqueue);
0077 
0078 #endif /* VIRTIO_SND_MSG_H */