ozeltbuf.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* -----------------------------------------------------------------------------
  2. * Copyright (c) 2011 Ozmo Inc
  3. * Released under the GNU General Public License Version 2 (GPLv2).
  4. * -----------------------------------------------------------------------------
  5. */
  6. #ifndef _OZELTBUF_H
  7. #define _OZELTBUF_H
  8. #include "ozprotocol.h"
  9. /*-----------------------------------------------------------------------------
  10. */
  11. struct oz_pd;
  12. typedef void (*oz_elt_callback_t)(struct oz_pd *pd, long context);
  13. struct oz_elt_stream {
  14. struct list_head link;
  15. struct list_head elt_list;
  16. atomic_t ref_count;
  17. unsigned buf_count;
  18. unsigned max_buf_count;
  19. u8 frame_number;
  20. u8 id;
  21. };
  22. #define OZ_MAX_ELT_PAYLOAD 255
  23. struct oz_elt_info {
  24. struct list_head link;
  25. struct list_head link_order;
  26. u8 flags;
  27. u8 app_id;
  28. oz_elt_callback_t callback;
  29. long context;
  30. struct oz_elt_stream *stream;
  31. u8 data[sizeof(struct oz_elt) + OZ_MAX_ELT_PAYLOAD];
  32. int length;
  33. };
  34. /* Flags values */
  35. #define OZ_EI_F_MARKED 0x1
  36. struct oz_elt_buf {
  37. spinlock_t lock;
  38. struct list_head stream_list;
  39. struct list_head order_list;
  40. struct list_head isoc_list;
  41. u8 tx_seq_num[OZ_NB_APPS];
  42. };
  43. void oz_elt_buf_init(struct oz_elt_buf *buf);
  44. void oz_elt_buf_term(struct oz_elt_buf *buf);
  45. struct oz_elt_info *oz_elt_info_alloc(struct oz_elt_buf *buf);
  46. void oz_elt_info_free(struct oz_elt_buf *buf, struct oz_elt_info *ei);
  47. void oz_elt_info_free_chain(struct oz_elt_buf *buf, struct list_head *list);
  48. int oz_elt_stream_create(struct oz_elt_buf *buf, u8 id, int max_buf_count);
  49. int oz_elt_stream_delete(struct oz_elt_buf *buf, u8 id);
  50. void oz_elt_stream_get(struct oz_elt_stream *st);
  51. void oz_elt_stream_put(struct oz_elt_stream *st);
  52. int oz_queue_elt_info(struct oz_elt_buf *buf, u8 isoc, u8 id,
  53. struct oz_elt_info *ei);
  54. int oz_select_elts_for_tx(struct oz_elt_buf *buf, u8 isoc, unsigned *len,
  55. unsigned max_len, struct list_head *list);
  56. int oz_are_elts_available(struct oz_elt_buf *buf);
  57. #endif /* _OZELTBUF_H */