Staging: line6: coding style cleanups for .h files.
[pandora-kernel.git] / drivers / staging / line6 / pcm.h
1 /*
2  * Line6 Linux USB driver - 0.8.0
3  *
4  * Copyright (C) 2004-2009 Markus Grabner (grabner@icg.tugraz.at)
5  *
6  *      This program is free software; you can redistribute it and/or
7  *      modify it under the terms of the GNU General Public License as
8  *      published by the Free Software Foundation, version 2.
9  *
10  */
11
12 /*
13         PCM interface to POD series devices.
14 */
15
16 #ifndef PCM_H
17 #define PCM_H
18
19
20 #include <sound/pcm.h>
21
22 #include "driver.h"
23 #include "usbdefs.h"
24
25
26 /* number of URBs */
27 #define LINE6_ISO_BUFFERS       8
28
29 /* number of USB frames per URB */
30 #define LINE6_ISO_PACKETS       2
31
32 /* in a "full speed" device (such as the PODxt Pro) this means 1ms */
33 #define LINE6_ISO_INTERVAL      1
34
35 /* this should be queried dynamically from the USB interface! */
36 #define LINE6_ISO_PACKET_SIZE_MAX       252
37
38
39 /*
40         Extract the messaging device from the substream instance
41 */
42 #define s2m(s)  (((struct snd_line6_pcm *) \
43                    snd_pcm_substream_chip(s))->line6->ifcdev)
44
45
46 enum {
47         BIT_RUNNING_PLAYBACK,
48         BIT_RUNNING_CAPTURE,
49         BIT_PAUSE_PLAYBACK,
50         BIT_PREPARED
51 };
52
53 struct line6_pcm_properties {
54         struct snd_pcm_hardware snd_line6_playback_hw, snd_line6_capture_hw;
55         struct snd_pcm_hw_constraint_ratdens snd_line6_rates;
56         int bytes_per_frame;
57 };
58
59 struct snd_line6_pcm {
60         /**
61                  Pointer back to the Line6 driver data structure.
62         */
63         struct usb_line6 *line6;
64
65         /**
66                  Properties.
67         */
68         struct line6_pcm_properties *properties;
69
70         /**
71                  ALSA pcm stream
72         */
73         struct snd_pcm *pcm;
74
75         /**
76                  URBs for audio playback.
77         */
78         struct urb *urb_audio_out[LINE6_ISO_BUFFERS];
79
80         /**
81                  URBs for audio capture.
82         */
83         struct urb *urb_audio_in[LINE6_ISO_BUFFERS];
84
85         /**
86                  Temporary buffer to hold data when playback buffer wraps.
87         */
88         unsigned char *wrap_out;
89
90         /**
91                  Temporary buffer for capture.
92                  Since the packet size is not known in advance, this buffer is
93                  large enough to store maximum size packets.
94         */
95         unsigned char *buffer_in;
96
97         /**
98                  Free frame position in the playback buffer.
99         */
100         snd_pcm_uframes_t pos_out;
101
102         /**
103                  Count processed bytes for playback.
104                  This is modulo period size (to determine when a period is
105                  finished).
106         */
107         unsigned bytes_out;
108
109         /**
110                  Counter to create desired playback sample rate.
111         */
112         unsigned count_out;
113
114         /**
115                  Playback period size in bytes
116         */
117         unsigned period_out;
118
119         /**
120                  Processed frame position in the playback buffer.
121                  The contents of the output ring buffer have been consumed by
122                  the USB subsystem (i.e., sent to the USB device) up to this
123                  position.
124         */
125         snd_pcm_uframes_t pos_out_done;
126
127         /**
128                  Count processed bytes for capture.
129                  This is modulo period size (to determine when a period is
130                  finished).
131         */
132         unsigned bytes_in;
133
134         /**
135                  Counter to create desired capture sample rate.
136         */
137         unsigned count_in;
138
139         /**
140                  Capture period size in bytes
141         */
142         unsigned period_in;
143
144         /**
145                  Processed frame position in the capture buffer.
146                  The contents of the output ring buffer have been consumed by
147                  the USB subsystem (i.e., sent to the USB device) up to this
148                  position.
149         */
150         snd_pcm_uframes_t pos_in_done;
151
152         /**
153                  Bit mask of active playback URBs.
154         */
155         unsigned long active_urb_out;
156
157         /**
158                  Maximum size of USB packet.
159         */
160         int max_packet_size;
161
162         /**
163                  USB endpoint for listening to audio data.
164         */
165         int ep_audio_read;
166
167         /**
168                  USB endpoint for writing audio data.
169         */
170         int ep_audio_write;
171
172         /**
173                  Bit mask of active capture URBs.
174         */
175         unsigned long active_urb_in;
176
177         /**
178                  Bit mask of playback URBs currently being unlinked.
179         */
180         unsigned long unlink_urb_out;
181
182         /**
183                  Bit mask of capture URBs currently being unlinked.
184         */
185         unsigned long unlink_urb_in;
186
187         /**
188                  Spin lock to protect updates of the playback buffer positions (not
189                  contents!)
190         */
191         spinlock_t lock_audio_out;
192
193         /**
194                  Spin lock to protect updates of the capture buffer positions (not
195                  contents!)
196         */
197         spinlock_t lock_audio_in;
198
199         /**
200                  Spin lock to protect trigger.
201         */
202         spinlock_t lock_trigger;
203
204         /**
205                  PCM playback volume (left and right).
206         */
207         int volume[2];
208
209         /**
210                  Several status bits (see BIT_*).
211         */
212         unsigned long flags;
213 };
214
215
216 extern int line6_init_pcm(struct usb_line6 *line6,
217                           struct line6_pcm_properties *properties);
218 extern int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd);
219 extern int snd_line6_prepare(struct snd_pcm_substream *substream);
220
221
222 #endif