pvrusb2-io.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. *
  3. * $Id$
  4. *
  5. * Copyright (C) 2005 Mike Isely <isely@pobox.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #ifndef __PVRUSB2_IO_H
  22. #define __PVRUSB2_IO_H
  23. #include <linux/usb.h>
  24. #include <linux/list.h>
  25. typedef void (*pvr2_stream_callback)(void *);
  26. enum pvr2_buffer_state {
  27. pvr2_buffer_state_none = 0, // Not on any list
  28. pvr2_buffer_state_idle = 1, // Buffer is ready to be used again
  29. pvr2_buffer_state_queued = 2, // Buffer has been queued for filling
  30. pvr2_buffer_state_ready = 3, // Buffer has data available
  31. };
  32. struct pvr2_stream;
  33. struct pvr2_buffer;
  34. const char *pvr2_buffer_state_decode(enum pvr2_buffer_state);
  35. /* Initialize / tear down stream structure */
  36. struct pvr2_stream *pvr2_stream_create(void);
  37. void pvr2_stream_destroy(struct pvr2_stream *);
  38. void pvr2_stream_setup(struct pvr2_stream *,
  39. struct usb_device *dev,int endpoint,
  40. unsigned int tolerance);
  41. void pvr2_stream_set_callback(struct pvr2_stream *,
  42. pvr2_stream_callback func,
  43. void *data);
  44. /* Query / set the nominal buffer count */
  45. int pvr2_stream_get_buffer_count(struct pvr2_stream *);
  46. int pvr2_stream_set_buffer_count(struct pvr2_stream *,unsigned int);
  47. /* Get a pointer to a buffer that is either idle, ready, or is specified
  48. named. */
  49. struct pvr2_buffer *pvr2_stream_get_idle_buffer(struct pvr2_stream *);
  50. struct pvr2_buffer *pvr2_stream_get_ready_buffer(struct pvr2_stream *);
  51. struct pvr2_buffer *pvr2_stream_get_buffer(struct pvr2_stream *sp,int id);
  52. /* Find out how many buffers are idle or ready */
  53. int pvr2_stream_get_idle_count(struct pvr2_stream *);
  54. int pvr2_stream_get_ready_count(struct pvr2_stream *);
  55. /* Kill all pending operations */
  56. void pvr2_stream_flush(struct pvr2_stream *);
  57. /* Kill all pending buffers and throw away any ready buffers as well */
  58. void pvr2_stream_kill(struct pvr2_stream *);
  59. /* Set up the actual storage for a buffer */
  60. int pvr2_buffer_set_buffer(struct pvr2_buffer *,void *ptr,unsigned int cnt);
  61. /* Find out size of data in the given ready buffer */
  62. unsigned int pvr2_buffer_get_count(struct pvr2_buffer *);
  63. /* Retrieve completion code for given ready buffer */
  64. int pvr2_buffer_get_status(struct pvr2_buffer *);
  65. /* Retrieve state of given buffer */
  66. enum pvr2_buffer_state pvr2_buffer_get_state(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. /* Move buffer back to idle pool (kill it if needed) */
  72. int pvr2_buffer_idle(struct pvr2_buffer *);
  73. #endif /* __PVRUSB2_IO_H */
  74. /*
  75. Stuff for Emacs to see, in order to encourage consistent editing style:
  76. *** Local Variables: ***
  77. *** mode: c ***
  78. *** fill-column: 75 ***
  79. *** tab-width: 8 ***
  80. *** c-basic-offset: 8 ***
  81. *** End: ***
  82. */