1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
4 * Xen para-virtual sound device
6 * Copyright (C) 2016-2018 EPAM Systems Inc.
8 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
11 #ifndef __XEN_SND_FRONT_EVTCHNL_H
12 #define __XEN_SND_FRONT_EVTCHNL_H
14 #include <xen/interface/io/sndif.h>
16 struct xen_snd_front_info;
18 /* Timeout in ms to wait for backend to respond. */
19 #define VSND_WAIT_BACK_MS 3000
21 enum xen_snd_front_evtchnl_state {
22 EVTCHNL_STATE_DISCONNECTED,
23 EVTCHNL_STATE_CONNECTED,
26 enum xen_snd_front_evtchnl_type {
31 struct xen_snd_front_evtchnl {
32 struct xen_snd_front_info *front_info;
37 /* State of the event channel. */
38 enum xen_snd_front_evtchnl_state state;
39 enum xen_snd_front_evtchnl_type type;
40 /* Either response id or incoming event id. */
42 /* Next request id or next expected event id. */
44 /* Shared ring access lock. */
45 struct mutex ring_io_lock;
48 struct xen_sndif_front_ring ring;
49 struct completion completion;
50 /* Serializer for backend IO: request/response. */
51 struct mutex req_io_lock;
53 /* Latest response status. */
56 struct xensnd_query_hw_param hw_param;
60 struct xensnd_event_page *page;
61 /* This is needed to handle XENSND_EVT_CUR_POS event. */
62 struct snd_pcm_substream *substream;
67 struct xen_snd_front_evtchnl_pair {
68 struct xen_snd_front_evtchnl req;
69 struct xen_snd_front_evtchnl evt;
72 int xen_snd_front_evtchnl_create_all(struct xen_snd_front_info *front_info,
75 void xen_snd_front_evtchnl_free_all(struct xen_snd_front_info *front_info);
77 int xen_snd_front_evtchnl_publish_all(struct xen_snd_front_info *front_info);
79 void xen_snd_front_evtchnl_flush(struct xen_snd_front_evtchnl *evtchnl);
81 void xen_snd_front_evtchnl_pair_set_connected(struct xen_snd_front_evtchnl_pair *evt_pair,
84 void xen_snd_front_evtchnl_pair_clear(struct xen_snd_front_evtchnl_pair *evt_pair);
86 #endif /* __XEN_SND_FRONT_EVTCHNL_H */