/* SPDX-License-Identifier: GPL-2.0+ */1/*2* virtio-snd: Virtio sound device3* Copyright (C) 2021 OpenSynergy GmbH4*/5#ifndef VIRTIO_SND_MSG_H6#define VIRTIO_SND_MSG_H78#include <linux/atomic.h>9#include <linux/virtio.h>1011struct virtio_snd;12struct virtio_snd_msg;1314void virtsnd_ctl_msg_ref(struct virtio_snd_msg *msg);1516void virtsnd_ctl_msg_unref(struct virtio_snd_msg *msg);1718void *virtsnd_ctl_msg_request(struct virtio_snd_msg *msg);1920void *virtsnd_ctl_msg_response(struct virtio_snd_msg *msg);2122struct virtio_snd_msg *virtsnd_ctl_msg_alloc(size_t request_size,23size_t response_size, gfp_t gfp);2425int virtsnd_ctl_msg_send(struct virtio_snd *snd, struct virtio_snd_msg *msg,26struct scatterlist *out_sgs,27struct scatterlist *in_sgs, bool nowait);2829/**30* virtsnd_ctl_msg_send_sync() - Simplified sending of synchronous message.31* @snd: VirtIO sound device.32* @msg: Control message.33*34* After returning from this function, the message will be deleted. If message35* content is still needed, the caller must additionally to36* virtsnd_ctl_msg_ref/unref() it.37*38* The msg_timeout_ms module parameter defines the message completion timeout.39* If the message is not completed within this time, the function will return an40* error.41*42* Context: Any context that permits to sleep.43* Return: 0 on success, -errno on failure.44*45* The return value is a message status code (VIRTIO_SND_S_XXX) converted to an46* appropriate -errno value.47*/48static inline int virtsnd_ctl_msg_send_sync(struct virtio_snd *snd,49struct virtio_snd_msg *msg)50{51return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, false);52}5354/**55* virtsnd_ctl_msg_send_async() - Simplified sending of asynchronous message.56* @snd: VirtIO sound device.57* @msg: Control message.58*59* Context: Any context.60* Return: 0 on success, -errno on failure.61*/62static inline int virtsnd_ctl_msg_send_async(struct virtio_snd *snd,63struct virtio_snd_msg *msg)64{65return virtsnd_ctl_msg_send(snd, msg, NULL, NULL, true);66}6768void virtsnd_ctl_msg_cancel_all(struct virtio_snd *snd);6970void virtsnd_ctl_msg_complete(struct virtio_snd_msg *msg);7172int virtsnd_ctl_query_info(struct virtio_snd *snd, int command, int start_id,73int count, size_t size, void *info);7475void virtsnd_ctl_notify_cb(struct virtqueue *vqueue);7677#endif /* VIRTIO_SND_MSG_H */787980