xen_snd_front_evtchnl.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /*
  3. * Xen para-virtual sound device
  4. *
  5. * Copyright (C) 2016-2018 EPAM Systems Inc.
  6. *
  7. * Author: Oleksandr Andrushchenko <[email protected]>
  8. */
  9. #ifndef __XEN_SND_FRONT_EVTCHNL_H
  10. #define __XEN_SND_FRONT_EVTCHNL_H
  11. #include <xen/interface/io/sndif.h>
  12. struct xen_snd_front_info;
  13. /* Timeout in ms to wait for backend to respond. */
  14. #define VSND_WAIT_BACK_MS 3000
  15. enum xen_snd_front_evtchnl_state {
  16. EVTCHNL_STATE_DISCONNECTED,
  17. EVTCHNL_STATE_CONNECTED,
  18. };
  19. enum xen_snd_front_evtchnl_type {
  20. EVTCHNL_TYPE_REQ,
  21. EVTCHNL_TYPE_EVT,
  22. };
  23. struct xen_snd_front_evtchnl {
  24. struct xen_snd_front_info *front_info;
  25. int gref;
  26. int port;
  27. int irq;
  28. int index;
  29. /* State of the event channel. */
  30. enum xen_snd_front_evtchnl_state state;
  31. enum xen_snd_front_evtchnl_type type;
  32. /* Either response id or incoming event id. */
  33. u16 evt_id;
  34. /* Next request id or next expected event id. */
  35. u16 evt_next_id;
  36. /* Shared ring access lock. */
  37. struct mutex ring_io_lock;
  38. union {
  39. struct {
  40. struct xen_sndif_front_ring ring;
  41. struct completion completion;
  42. /* Serializer for backend IO: request/response. */
  43. struct mutex req_io_lock;
  44. /* Latest response status. */
  45. int resp_status;
  46. union {
  47. struct xensnd_query_hw_param hw_param;
  48. } resp;
  49. } req;
  50. struct {
  51. struct xensnd_event_page *page;
  52. /* This is needed to handle XENSND_EVT_CUR_POS event. */
  53. struct snd_pcm_substream *substream;
  54. } evt;
  55. } u;
  56. };
  57. struct xen_snd_front_evtchnl_pair {
  58. struct xen_snd_front_evtchnl req;
  59. struct xen_snd_front_evtchnl evt;
  60. };
  61. int xen_snd_front_evtchnl_create_all(struct xen_snd_front_info *front_info,
  62. int num_streams);
  63. void xen_snd_front_evtchnl_free_all(struct xen_snd_front_info *front_info);
  64. int xen_snd_front_evtchnl_publish_all(struct xen_snd_front_info *front_info);
  65. void xen_snd_front_evtchnl_flush(struct xen_snd_front_evtchnl *evtchnl);
  66. void xen_snd_front_evtchnl_pair_set_connected(struct xen_snd_front_evtchnl_pair *evt_pair,
  67. bool is_connected);
  68. void xen_snd_front_evtchnl_pair_clear(struct xen_snd_front_evtchnl_pair *evt_pair);
  69. #endif /* __XEN_SND_FRONT_EVTCHNL_H */