pvrusb2-io.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * Copyright (C) 2005 Mike Isely <[email protected]>
  5. */
  6. #ifndef __PVRUSB2_IO_H
  7. #define __PVRUSB2_IO_H
  8. #include <linux/usb.h>
  9. #include <linux/list.h>
  10. typedef void (*pvr2_stream_callback)(void *);
  11. enum pvr2_buffer_state {
  12. pvr2_buffer_state_none = 0, // Not on any list
  13. pvr2_buffer_state_idle = 1, // Buffer is ready to be used again
  14. pvr2_buffer_state_queued = 2, // Buffer has been queued for filling
  15. pvr2_buffer_state_ready = 3, // Buffer has data available
  16. };
  17. struct pvr2_stream;
  18. struct pvr2_buffer;
  19. struct pvr2_stream_stats {
  20. unsigned int buffers_in_queue;
  21. unsigned int buffers_in_idle;
  22. unsigned int buffers_in_ready;
  23. unsigned int buffers_processed;
  24. unsigned int buffers_failed;
  25. unsigned int bytes_processed;
  26. };
  27. /* Initialize / tear down stream structure */
  28. struct pvr2_stream *pvr2_stream_create(void);
  29. void pvr2_stream_destroy(struct pvr2_stream *);
  30. void pvr2_stream_setup(struct pvr2_stream *,
  31. struct usb_device *dev,int endpoint,
  32. unsigned int tolerance);
  33. void pvr2_stream_set_callback(struct pvr2_stream *,
  34. pvr2_stream_callback func,
  35. void *data);
  36. void pvr2_stream_get_stats(struct pvr2_stream *,
  37. struct pvr2_stream_stats *,
  38. int zero_counts);
  39. /* Query / set the nominal buffer count */
  40. int pvr2_stream_get_buffer_count(struct pvr2_stream *);
  41. int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
  42. /* Get a pointer to a buffer that is either idle, ready, or is specified
  43. named. */
  44. struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);
  45. struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
  46. struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
  47. /* Find out how many buffers are idle or ready */
  48. int pvr2_stream_get_ready_count(struct pvr2_stream *);
  49. /* Kill all pending buffers and throw away any ready buffers as well */
  50. void pvr2_stream_kill(struct pvr2_stream *);
  51. /* Set up the actual storage for a buffer */
  52. int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);
  53. /* Find out size of data in the given ready buffer */
  54. unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
  55. /* Retrieve completion code for given ready buffer */
  56. int pvr2_buffer_get_status(struct pvr2_buffer *);
  57. /* Retrieve ID of given buffer */
  58. int pvr2_buffer_get_id(struct pvr2_buffer *);
  59. /* Start reading into given buffer (kill it if needed) */
  60. int pvr2_buffer_queue(struct pvr2_buffer *);
  61. #endif /* __PVRUSB2_IO_H */