diff options
Diffstat (limited to 'drivers/staging/line6/pcm.h')
-rw-r--r-- | drivers/staging/line6/pcm.h | 210 |
1 files changed, 210 insertions, 0 deletions
diff --git a/drivers/staging/line6/pcm.h b/drivers/staging/line6/pcm.h new file mode 100644 index 00000000000..90f8bb9816d --- /dev/null +++ b/drivers/staging/line6/pcm.h | |||
@@ -0,0 +1,210 @@ | |||
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 | #define LINE6_ISO_BUFFERS 8 /* number of URBs */ | ||
27 | #define LINE6_ISO_PACKETS 2 /* number of USB frames per URB */ | ||
28 | #define LINE6_ISO_INTERVAL 1 /* in a "full speed" device (such as the PODxt Pro) this means 1ms */ | ||
29 | #define LINE6_ISO_PACKET_SIZE_MAX 252 /* this should be queried dynamically from the USB interface! */ | ||
30 | |||
31 | |||
32 | /* | ||
33 | Extract the messaging device from the substream instance | ||
34 | */ | ||
35 | #define s2m(s) (((struct snd_line6_pcm *)snd_pcm_substream_chip(s))->line6->ifcdev) | ||
36 | |||
37 | |||
38 | enum { | ||
39 | BIT_RUNNING_PLAYBACK, | ||
40 | BIT_RUNNING_CAPTURE, | ||
41 | BIT_PAUSE_PLAYBACK, | ||
42 | BIT_PREPARED | ||
43 | }; | ||
44 | |||
45 | struct line6_pcm_properties { | ||
46 | struct snd_pcm_hardware snd_line6_playback_hw, snd_line6_capture_hw; | ||
47 | struct snd_pcm_hw_constraint_ratdens snd_line6_rates; | ||
48 | int bytes_per_frame; | ||
49 | }; | ||
50 | |||
51 | struct snd_line6_pcm | ||
52 | { | ||
53 | /** | ||
54 | Pointer back to the Line6 driver data structure. | ||
55 | */ | ||
56 | struct usb_line6 *line6; | ||
57 | |||
58 | /** | ||
59 | Properties. | ||
60 | */ | ||
61 | struct line6_pcm_properties *properties; | ||
62 | |||
63 | /** | ||
64 | ALSA pcm stream | ||
65 | */ | ||
66 | struct snd_pcm *pcm; | ||
67 | |||
68 | /** | ||
69 | URBs for audio playback. | ||
70 | */ | ||
71 | struct urb *urb_audio_out[LINE6_ISO_BUFFERS]; | ||
72 | |||
73 | /** | ||
74 | URBs for audio capture. | ||
75 | */ | ||
76 | struct urb *urb_audio_in[LINE6_ISO_BUFFERS]; | ||
77 | |||
78 | /** | ||
79 | Temporary buffer to hold data when playback buffer wraps. | ||
80 | */ | ||
81 | unsigned char *wrap_out; | ||
82 | |||
83 | /** | ||
84 | Temporary buffer for capture. | ||
85 | Since the packet size is not known in advance, this buffer is large enough | ||
86 | to store maximum size packets. | ||
87 | */ | ||
88 | unsigned char *buffer_in; | ||
89 | |||
90 | /** | ||
91 | Free frame position in the playback buffer. | ||
92 | */ | ||
93 | snd_pcm_uframes_t pos_out; | ||
94 | |||
95 | /** | ||
96 | Count processed bytes for playback. | ||
97 | This is modulo period size (to determine when a period is finished). | ||
98 | */ | ||
99 | unsigned bytes_out; | ||
100 | |||
101 | /** | ||
102 | Counter to create desired playback sample rate. | ||
103 | */ | ||
104 | unsigned count_out; | ||
105 | |||
106 | /** | ||
107 | Playback period size in bytes | ||
108 | */ | ||
109 | unsigned period_out; | ||
110 | |||
111 | /** | ||
112 | Processed frame position in the playback buffer. | ||
113 | The contents of the output ring buffer have been consumed by the USB | ||
114 | subsystem (i.e., sent to the USB device) up to this position. | ||
115 | */ | ||
116 | snd_pcm_uframes_t pos_out_done; | ||
117 | |||
118 | /** | ||
119 | Count processed bytes for capture. | ||
120 | This is modulo period size (to determine when a period is finished). | ||
121 | */ | ||
122 | unsigned bytes_in; | ||
123 | |||
124 | /** | ||
125 | Counter to create desired capture sample rate. | ||
126 | */ | ||
127 | unsigned count_in; | ||
128 | |||
129 | /** | ||
130 | Capture period size in bytes | ||
131 | */ | ||
132 | unsigned period_in; | ||
133 | |||
134 | /** | ||
135 | Processed frame position in the capture buffer. | ||
136 | The contents of the output ring buffer have been consumed by the USB | ||
137 | subsystem (i.e., sent to the USB device) up to this position. | ||
138 | */ | ||
139 | snd_pcm_uframes_t pos_in_done; | ||
140 | |||
141 | /** | ||
142 | Bit mask of active playback URBs. | ||
143 | */ | ||
144 | unsigned long active_urb_out; | ||
145 | |||
146 | /** | ||
147 | Maximum size of USB packet. | ||
148 | */ | ||
149 | int max_packet_size; | ||
150 | |||
151 | /** | ||
152 | USB endpoint for listening to audio data. | ||
153 | */ | ||
154 | int ep_audio_read; | ||
155 | |||
156 | /** | ||
157 | USB endpoint for writing audio data. | ||
158 | */ | ||
159 | int ep_audio_write; | ||
160 | |||
161 | /** | ||
162 | Bit mask of active capture URBs. | ||
163 | */ | ||
164 | unsigned long active_urb_in; | ||
165 | |||
166 | /** | ||
167 | Bit mask of playback URBs currently being unlinked. | ||
168 | */ | ||
169 | unsigned long unlink_urb_out; | ||
170 | |||
171 | /** | ||
172 | Bit mask of capture URBs currently being unlinked. | ||
173 | */ | ||
174 | unsigned long unlink_urb_in; | ||
175 | |||
176 | /** | ||
177 | Spin lock to protect updates of the playback buffer positions (not | ||
178 | contents!) | ||
179 | */ | ||
180 | spinlock_t lock_audio_out; | ||
181 | |||
182 | /** | ||
183 | Spin lock to protect updates of the capture buffer positions (not | ||
184 | contents!) | ||
185 | */ | ||
186 | spinlock_t lock_audio_in; | ||
187 | |||
188 | /** | ||
189 | Spin lock to protect trigger. | ||
190 | */ | ||
191 | spinlock_t lock_trigger; | ||
192 | |||
193 | /** | ||
194 | PCM playback volume (left and right). | ||
195 | */ | ||
196 | int volume[2]; | ||
197 | |||
198 | /** | ||
199 | Several status bits (see BIT_*). | ||
200 | */ | ||
201 | unsigned long flags; | ||
202 | }; | ||
203 | |||
204 | |||
205 | extern int line6_init_pcm(struct usb_line6 *line6, struct line6_pcm_properties *properties); | ||
206 | extern int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd); | ||
207 | extern int snd_line6_prepare(struct snd_pcm_substream *substream); | ||
208 | |||
209 | |||
210 | #endif | ||