Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 
0003 /*
0004  * Xen para-virtual sound device
0005  *
0006  * Copyright (C) 2016-2018 EPAM Systems Inc.
0007  *
0008  * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
0009  */
0010 
0011 #ifndef __XEN_SND_FRONT_EVTCHNL_H
0012 #define __XEN_SND_FRONT_EVTCHNL_H
0013 
0014 #include <xen/interface/io/sndif.h>
0015 
0016 struct xen_snd_front_info;
0017 
0018 /* Timeout in ms to wait for backend to respond. */
0019 #define VSND_WAIT_BACK_MS   3000
0020 
0021 enum xen_snd_front_evtchnl_state {
0022     EVTCHNL_STATE_DISCONNECTED,
0023     EVTCHNL_STATE_CONNECTED,
0024 };
0025 
0026 enum xen_snd_front_evtchnl_type {
0027     EVTCHNL_TYPE_REQ,
0028     EVTCHNL_TYPE_EVT,
0029 };
0030 
0031 struct xen_snd_front_evtchnl {
0032     struct xen_snd_front_info *front_info;
0033     int gref;
0034     int port;
0035     int irq;
0036     int index;
0037     /* State of the event channel. */
0038     enum xen_snd_front_evtchnl_state state;
0039     enum xen_snd_front_evtchnl_type type;
0040     /* Either response id or incoming event id. */
0041     u16 evt_id;
0042     /* Next request id or next expected event id. */
0043     u16 evt_next_id;
0044     /* Shared ring access lock. */
0045     struct mutex ring_io_lock;
0046     union {
0047         struct {
0048             struct xen_sndif_front_ring ring;
0049             struct completion completion;
0050             /* Serializer for backend IO: request/response. */
0051             struct mutex req_io_lock;
0052 
0053             /* Latest response status. */
0054             int resp_status;
0055             union {
0056                 struct xensnd_query_hw_param hw_param;
0057             } resp;
0058         } req;
0059         struct {
0060             struct xensnd_event_page *page;
0061             /* This is needed to handle XENSND_EVT_CUR_POS event. */
0062             struct snd_pcm_substream *substream;
0063         } evt;
0064     } u;
0065 };
0066 
0067 struct xen_snd_front_evtchnl_pair {
0068     struct xen_snd_front_evtchnl req;
0069     struct xen_snd_front_evtchnl evt;
0070 };
0071 
0072 int xen_snd_front_evtchnl_create_all(struct xen_snd_front_info *front_info,
0073                      int num_streams);
0074 
0075 void xen_snd_front_evtchnl_free_all(struct xen_snd_front_info *front_info);
0076 
0077 int xen_snd_front_evtchnl_publish_all(struct xen_snd_front_info *front_info);
0078 
0079 void xen_snd_front_evtchnl_flush(struct xen_snd_front_evtchnl *evtchnl);
0080 
0081 void xen_snd_front_evtchnl_pair_set_connected(struct xen_snd_front_evtchnl_pair *evt_pair,
0082                           bool is_connected);
0083 
0084 void xen_snd_front_evtchnl_pair_clear(struct xen_snd_front_evtchnl_pair *evt_pair);
0085 
0086 #endif /* __XEN_SND_FRONT_EVTCHNL_H */