xen_snd_front_evtchnl.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <oleksandr_andrushchenko@epam.com>
  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. #ifndef GRANT_INVALID_REF
  14. /*
  15. * FIXME: usage of grant reference 0 as invalid grant reference:
  16. * grant reference 0 is valid, but never exposed to a PV driver,
  17. * because of the fact it is already in use/reserved by the PV console.
  18. */
  19. #define GRANT_INVALID_REF 0
  20. #endif
  21. /* Timeout in ms to wait for backend to respond. */
  22. #define VSND_WAIT_BACK_MS 3000
  23. enum xen_snd_front_evtchnl_state {
  24. EVTCHNL_STATE_DISCONNECTED,
  25. EVTCHNL_STATE_CONNECTED,
  26. };
  27. enum xen_snd_front_evtchnl_type {
  28. EVTCHNL_TYPE_REQ,
  29. EVTCHNL_TYPE_EVT,
  30. };
  31. struct xen_snd_front_evtchnl {
  32. struct xen_snd_front_info *front_info;
  33. int gref;
  34. int port;
  35. int irq;
  36. int index;
  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. */
  41. u16 evt_id;
  42. /* Next request id or next expected event id. */
  43. u16 evt_next_id;
  44. /* Shared ring access lock. */
  45. struct mutex ring_io_lock;
  46. union {
  47. struct {
  48. struct xen_sndif_front_ring ring;
  49. struct completion completion;
  50. /* Serializer for backend IO: request/response. */
  51. struct mutex req_io_lock;
  52. /* Latest response status. */
  53. int resp_status;
  54. union {
  55. struct xensnd_query_hw_param hw_param;
  56. } resp;
  57. } req;
  58. struct {
  59. struct xensnd_event_page *page;
  60. /* This is needed to handle XENSND_EVT_CUR_POS event. */
  61. struct snd_pcm_substream *substream;
  62. } evt;
  63. } u;
  64. };
  65. struct xen_snd_front_evtchnl_pair {
  66. struct xen_snd_front_evtchnl req;
  67. struct xen_snd_front_evtchnl evt;
  68. };
  69. int xen_snd_front_evtchnl_create_all(struct xen_snd_front_info *front_info,
  70. int num_streams);
  71. void xen_snd_front_evtchnl_free_all(struct xen_snd_front_info *front_info);
  72. int xen_snd_front_evtchnl_publish_all(struct xen_snd_front_info *front_info);
  73. void xen_snd_front_evtchnl_flush(struct xen_snd_front_evtchnl *evtchnl);
  74. void xen_snd_front_evtchnl_pair_set_connected(struct xen_snd_front_evtchnl_pair *evt_pair,
  75. bool is_connected);
  76. void xen_snd_front_evtchnl_pair_clear(struct xen_snd_front_evtchnl_pair *evt_pair);
  77. #endif /* __XEN_SND_FRONT_EVTCHNL_H */