usb_stream.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #define USB_STREAM_INTERFACE_VERSION 2
  19. #define SNDRV_USB_STREAM_IOCTL_SET_PARAMS \
  20. _IOW('H', 0x90, struct usb_stream_config)
  21. struct usb_stream_packet {
  22. unsigned offset;
  23. unsigned length;
  24. };
  25. struct usb_stream_config {
  26. unsigned version;
  27. unsigned sample_rate;
  28. unsigned period_frames;
  29. unsigned frame_size;
  30. };
  31. struct usb_stream {
  32. struct usb_stream_config cfg;
  33. unsigned read_size;
  34. unsigned write_size;
  35. int period_size;
  36. unsigned state;
  37. int idle_insize;
  38. int idle_outsize;
  39. int sync_packet;
  40. unsigned insize_done;
  41. unsigned periods_done;
  42. unsigned periods_polled;
  43. struct usb_stream_packet outpacket[2];
  44. unsigned inpackets;
  45. unsigned inpacket_head;
  46. unsigned inpacket_split;
  47. unsigned inpacket_split_at;
  48. unsigned next_inpacket_split;
  49. unsigned next_inpacket_split_at;
  50. struct usb_stream_packet inpacket[0];
  51. };
  52. enum usb_stream_state {
  53. usb_stream_invalid,
  54. usb_stream_stopped,
  55. usb_stream_sync0,
  56. usb_stream_sync1,
  57. usb_stream_ready,
  58. usb_stream_running,
  59. usb_stream_xrun,
  60. };
  61. #if __KERNEL__
  62. #define USB_STREAM_NURBS 4
  63. #define USB_STREAM_URBDEPTH 4
  64. struct usb_stream_kernel {
  65. struct usb_stream *s;
  66. void *write_page;
  67. unsigned n_o_ps;
  68. struct urb *inurb[USB_STREAM_NURBS];
  69. struct urb *idle_inurb;
  70. struct urb *completed_inurb;
  71. struct urb *outurb[USB_STREAM_NURBS];
  72. struct urb *idle_outurb;
  73. struct urb *completed_outurb;
  74. struct urb *i_urb;
  75. int iso_frame_balance;
  76. wait_queue_head_t sleep;
  77. unsigned out_phase;
  78. unsigned out_phase_peeked;
  79. unsigned freqn;
  80. };
  81. struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
  82. struct usb_device *dev,
  83. unsigned in_endpoint, unsigned out_endpoint,
  84. unsigned sample_rate, unsigned use_packsize,
  85. unsigned period_frames, unsigned frame_size);
  86. void usb_stream_free(struct usb_stream_kernel *);
  87. int usb_stream_start(struct usb_stream_kernel *);
  88. void usb_stream_stop(struct usb_stream_kernel *);
  89. #endif