qal_streamfs.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2018 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: qal_streamfs
  20. * Qualcomm abstraction layer (QAL) stream file system APIs
  21. */
  22. #if !defined(__QAL_STREAMFS_H)
  23. #define _QAL_STREAMFS_H
  24. /* Include Files */
  25. #include <qdf_types.h>
  26. struct qal_streamfs_chan;
  27. struct qal_dentry_t;
  28. struct qal_streamfs_chan_callbacks;
  29. struct qal_streamfs_chan_buf;
  30. /**
  31. * qal_streamfs_open() - Create streamfs channel for data trasfer
  32. * @base_filename: base name of files to create, %NULL for buffering only
  33. * @parent: dentry of parent directory, %NULL for root directory
  34. * @subbuf_size: size of sub-buffers
  35. * @n_subbufs: number of sub-buffers
  36. * @cb: streamfs channel callback functions
  37. * @private_data: user-defined data
  38. *
  39. * Returns channel pointer if successful, %NULL otherwise.
  40. */
  41. struct qal_streamfs_chan *
  42. qal_streamfs_open(const char *base_filename,
  43. struct qal_dentry_t *parent,
  44. size_t subbuf_size, size_t n_subbufs,
  45. struct qal_streamfs_chan_callbacks *cb,
  46. void *private_data);
  47. /**
  48. * qal_streamfs_close() - Closes all channel buffers and frees the channel.
  49. * @chan: pointer to qal_streamfs_chan.
  50. *
  51. * Returns NONE
  52. */
  53. void qal_streamfs_close(struct qal_streamfs_chan *chan);
  54. /**
  55. * qal_streamfs_flush() - Flushes all channel buffers.
  56. * @chan: pointer to qal_streamfs_chan.
  57. *
  58. * Returns NONE
  59. */
  60. void qal_streamfs_flush(struct qal_streamfs_chan *chan);
  61. /**
  62. * qal_streamfs_reset - reset streamfs channel
  63. * This erases data from all channel buffers and restarting the channel
  64. * in its initial state.
  65. * The buffers are not freed, so any mappings are still in effect.
  66. * @chan: pointer to qal_streamfs_chan.
  67. *
  68. * Returns NONE
  69. */
  70. void qal_streamfs_reset(struct qal_streamfs_chan *chan);
  71. /**
  72. * qal_streamfs_subbufs_consumed - update the buffer's sub-buffers-consumed
  73. * count
  74. * @chan: pointer to qal_streamfs_chan.
  75. * @cpu: the cpu associated with the channel buffer to update
  76. * @subbufs_consumed: number of sub-buffers to add to current buf's count
  77. *
  78. * Returns NONE
  79. */
  80. void qal_streamfs_subbufs_consumed(struct qal_streamfs_chan *chan,
  81. unsigned int cpu,
  82. size_t consumed);
  83. /**
  84. * qal_streamfs_write - write data into the channel
  85. * @chan: relay channel
  86. * @data: data to be written
  87. * @length: number of bytes to write
  88. *
  89. * Writes data into the current cpu's channel buffer.
  90. */
  91. inline void qal_streamfs_write(struct qal_streamfs_chan *chan,
  92. const void *data,
  93. size_t length);
  94. /**
  95. * qal_streamfs_buf_full - boolean, is the channel buffer full?
  96. * @buf: channel buffer
  97. *
  98. * Returns 1 if the buffer is full, 0 otherwise.
  99. */
  100. int qal_streamfs_buf_full(struct qal_streamfs_chan_buf *buf);
  101. #endif