pvrusb2-io.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. *
  3. *
  4. * Copyright (C) 2005 Mike Isely <isely@pobox.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef __PVRUSB2_IO_H
  17. #define __PVRUSB2_IO_H
  18. #include <linux/usb.h>
  19. #include <linux/list.h>
  20. typedef void (*pvr2_stream_callback)(void *);
  21. enum pvr2_buffer_state {
  22. pvr2_buffer_state_none = 0, // Not on any list
  23. pvr2_buffer_state_idle = 1, // Buffer is ready to be used again
  24. pvr2_buffer_state_queued = 2, // Buffer has been queued for filling
  25. pvr2_buffer_state_ready = 3, // Buffer has data available
  26. };
  27. struct pvr2_stream;
  28. struct pvr2_buffer;
  29. struct pvr2_stream_stats {
  30. unsigned int buffers_in_queue;
  31. unsigned int buffers_in_idle;
  32. unsigned int buffers_in_ready;
  33. unsigned int buffers_processed;
  34. unsigned int buffers_failed;
  35. unsigned int bytes_processed;
  36. };
  37. /* Initialize / tear down stream structure */
  38. struct pvr2_stream *pvr2_stream_create(void);
  39. void pvr2_stream_destroy(struct pvr2_stream *);
  40. void pvr2_stream_setup(struct pvr2_stream *,
  41. struct usb_device *dev,int endpoint,
  42. unsigned int tolerance);
  43. void pvr2_stream_set_callback(struct pvr2_stream *,
  44. pvr2_stream_callback func,
  45. void *data);
  46. void pvr2_stream_get_stats(struct pvr2_stream *,
  47. struct pvr2_stream_stats *,
  48. int zero_counts);
  49. /* Query / set the nominal buffer count */
  50. int pvr2_stream_get_buffer_count(struct pvr2_stream *);
  51. int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
  52. /* Get a pointer to a buffer that is either idle, ready, or is specified
  53. named. */
  54. struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);
  55. struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
  56. struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
  57. /* Find out how many buffers are idle or ready */
  58. int pvr2_stream_get_ready_count(struct pvr2_stream *);
  59. /* Kill all pending buffers and throw away any ready buffers as well */
  60. void pvr2_stream_kill(struct pvr2_stream *);
  61. /* Set up the actual storage for a buffer */
  62. int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);
  63. /* Find out size of data in the given ready buffer */
  64. unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
  65. /* Retrieve completion code for given ready buffer */
  66. int pvr2_buffer_get_status(struct pvr2_buffer *);
  67. /* Retrieve ID of given buffer */
  68. int pvr2_buffer_get_id(struct pvr2_buffer *);
  69. /* Start reading into given buffer (kill it if needed) */
  70. int pvr2_buffer_queue(struct pvr2_buffer *);
  71. #endif /* __PVRUSB2_IO_H */