Merge remote-tracking branch 'moduleh/module.h-split'
[linux-2.6/next.git] / sound / usb / usx2y / usb_stream.h
blob4dd74ab1e9cce87093631ff64a6c52d44dfed134
1 /*
2 * Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de>
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.
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.
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.
19 #define USB_STREAM_INTERFACE_VERSION 2
21 #define SNDRV_USB_STREAM_IOCTL_SET_PARAMS \
22 _IOW('H', 0x90, struct usb_stream_config)
24 struct usb_stream_packet {
25 unsigned offset;
26 unsigned length;
30 struct usb_stream_config {
31 unsigned version;
32 unsigned sample_rate;
33 unsigned period_frames;
34 unsigned frame_size;
37 struct usb_stream {
38 struct usb_stream_config cfg;
39 unsigned read_size;
40 unsigned write_size;
42 int period_size;
44 unsigned state;
46 int idle_insize;
47 int idle_outsize;
48 int sync_packet;
49 unsigned insize_done;
50 unsigned periods_done;
51 unsigned periods_polled;
53 struct usb_stream_packet outpacket[2];
54 unsigned inpackets;
55 unsigned inpacket_head;
56 unsigned inpacket_split;
57 unsigned inpacket_split_at;
58 unsigned next_inpacket_split;
59 unsigned next_inpacket_split_at;
60 struct usb_stream_packet inpacket[0];
63 enum usb_stream_state {
64 usb_stream_invalid,
65 usb_stream_stopped,
66 usb_stream_sync0,
67 usb_stream_sync1,
68 usb_stream_ready,
69 usb_stream_running,
70 usb_stream_xrun,
73 #if __KERNEL__
75 #define USB_STREAM_NURBS 4
76 #define USB_STREAM_URBDEPTH 4
78 struct usb_stream_kernel {
79 struct usb_stream *s;
81 void *write_page;
83 unsigned n_o_ps;
85 struct urb *inurb[USB_STREAM_NURBS];
86 struct urb *idle_inurb;
87 struct urb *completed_inurb;
88 struct urb *outurb[USB_STREAM_NURBS];
89 struct urb *idle_outurb;
90 struct urb *completed_outurb;
91 struct urb *i_urb;
93 int iso_frame_balance;
95 wait_queue_head_t sleep;
97 unsigned out_phase;
98 unsigned out_phase_peeked;
99 unsigned freqn;
102 struct usb_stream *usb_stream_new(struct usb_stream_kernel *sk,
103 struct usb_device *dev,
104 unsigned in_endpoint, unsigned out_endpoint,
105 unsigned sample_rate, unsigned use_packsize,
106 unsigned period_frames, unsigned frame_size);
107 void usb_stream_free(struct usb_stream_kernel *);
108 int usb_stream_start(struct usb_stream_kernel *);
109 void usb_stream_stop(struct usb_stream_kernel *);
112 #endif