usb: dwc3: keystone: drop dma_mask configuration
[linux/fpc-iii.git] / drivers / staging / line6 / pcm.h
blob6aa0d46a28900e3e7ea9e38fb9050153d61e0a7a
1 /*
2 * Line6 Linux USB driver - 0.9.1beta
4 * Copyright (C) 2004-2010 Markus Grabner (grabner@icg.tugraz.at)
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.
13 PCM interface to POD series devices.
16 #ifndef PCM_H
17 #define PCM_H
19 #include <sound/pcm.h>
21 #include "driver.h"
22 #include "usbdefs.h"
24 /* number of URBs */
25 #define LINE6_ISO_BUFFERS 2
28 number of USB frames per URB
29 The Line6 Windows driver always transmits two frames per packet, but
30 the Linux driver performs significantly better (i.e., lower latency)
31 with only one frame per packet.
33 #define LINE6_ISO_PACKETS 1
35 /* in a "full speed" device (such as the PODxt Pro) this means 1ms */
36 #define LINE6_ISO_INTERVAL 1
38 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
39 #define LINE6_IMPULSE_DEFAULT_PERIOD 100
40 #endif
43 Get substream from Line6 PCM data structure
45 #define get_substream(line6pcm, stream) \
46 (line6pcm->pcm->streams[stream].substream)
49 PCM mode bits.
51 There are several features of the Line6 USB driver which require PCM
52 data to be exchanged with the device:
53 *) PCM playback and capture via ALSA
54 *) software monitoring (for devices without hardware monitoring)
55 *) optional impulse response measurement
56 However, from the device's point of view, there is just a single
57 capture and playback stream, which must be shared between these
58 subsystems. It is therefore necessary to maintain the state of the
59 subsystems with respect to PCM usage. We define several constants of
60 the form LINE6_BIT_PCM_<subsystem>_<direction>_<resource> with the
61 following meanings:
62 *) <subsystem> is one of
63 -) ALSA: PCM playback and capture via ALSA
64 -) MONITOR: software monitoring
65 -) IMPULSE: optional impulse response measurement
66 *) <direction> is one of
67 -) PLAYBACK: audio output (from host to device)
68 -) CAPTURE: audio input (from device to host)
69 *) <resource> is one of
70 -) BUFFER: buffer required by PCM data stream
71 -) STREAM: actual PCM data stream
73 The subsystems call line6_pcm_acquire() to acquire the (shared)
74 resources needed for a particular operation (e.g., allocate the buffer
75 for ALSA playback or start the capture stream for software monitoring).
76 When a resource is no longer needed, it is released by calling
77 line6_pcm_release(). Buffer allocation and stream startup are handled
78 separately to allow the ALSA kernel driver to perform them at
79 appropriate places (since the callback which starts a PCM stream is not
80 allowed to sleep).
82 enum {
83 /* individual bit indices: */
84 LINE6_INDEX_PCM_ALSA_PLAYBACK_BUFFER,
85 LINE6_INDEX_PCM_ALSA_PLAYBACK_STREAM,
86 LINE6_INDEX_PCM_ALSA_CAPTURE_BUFFER,
87 LINE6_INDEX_PCM_ALSA_CAPTURE_STREAM,
88 LINE6_INDEX_PCM_MONITOR_PLAYBACK_BUFFER,
89 LINE6_INDEX_PCM_MONITOR_PLAYBACK_STREAM,
90 LINE6_INDEX_PCM_MONITOR_CAPTURE_BUFFER,
91 LINE6_INDEX_PCM_MONITOR_CAPTURE_STREAM,
92 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
93 LINE6_INDEX_PCM_IMPULSE_PLAYBACK_BUFFER,
94 LINE6_INDEX_PCM_IMPULSE_PLAYBACK_STREAM,
95 LINE6_INDEX_PCM_IMPULSE_CAPTURE_BUFFER,
96 LINE6_INDEX_PCM_IMPULSE_CAPTURE_STREAM,
97 #endif
98 LINE6_INDEX_PAUSE_PLAYBACK,
99 LINE6_INDEX_PREPARED,
101 /* individual bit masks: */
102 LINE6_BIT(PCM_ALSA_PLAYBACK_BUFFER),
103 LINE6_BIT(PCM_ALSA_PLAYBACK_STREAM),
104 LINE6_BIT(PCM_ALSA_CAPTURE_BUFFER),
105 LINE6_BIT(PCM_ALSA_CAPTURE_STREAM),
106 LINE6_BIT(PCM_MONITOR_PLAYBACK_BUFFER),
107 LINE6_BIT(PCM_MONITOR_PLAYBACK_STREAM),
108 LINE6_BIT(PCM_MONITOR_CAPTURE_BUFFER),
109 LINE6_BIT(PCM_MONITOR_CAPTURE_STREAM),
110 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
111 LINE6_BIT(PCM_IMPULSE_PLAYBACK_BUFFER),
112 LINE6_BIT(PCM_IMPULSE_PLAYBACK_STREAM),
113 LINE6_BIT(PCM_IMPULSE_CAPTURE_BUFFER),
114 LINE6_BIT(PCM_IMPULSE_CAPTURE_STREAM),
115 #endif
116 LINE6_BIT(PAUSE_PLAYBACK),
117 LINE6_BIT(PREPARED),
119 /* combined bit masks (by operation): */
120 LINE6_BITS_PCM_ALSA_BUFFER =
121 LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER |
122 LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER,
124 LINE6_BITS_PCM_ALSA_STREAM =
125 LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM |
126 LINE6_BIT_PCM_ALSA_CAPTURE_STREAM,
128 LINE6_BITS_PCM_MONITOR =
129 LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER |
130 LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM |
131 LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER |
132 LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM,
134 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
135 LINE6_BITS_PCM_IMPULSE =
136 LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER |
137 LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM |
138 LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER |
139 LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM,
140 #endif
142 /* combined bit masks (by direction): */
143 LINE6_BITS_PLAYBACK_BUFFER =
144 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
145 LINE6_BIT_PCM_IMPULSE_PLAYBACK_BUFFER |
146 #endif
147 LINE6_BIT_PCM_ALSA_PLAYBACK_BUFFER |
148 LINE6_BIT_PCM_MONITOR_PLAYBACK_BUFFER ,
150 LINE6_BITS_PLAYBACK_STREAM =
151 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
152 LINE6_BIT_PCM_IMPULSE_PLAYBACK_STREAM |
153 #endif
154 LINE6_BIT_PCM_ALSA_PLAYBACK_STREAM |
155 LINE6_BIT_PCM_MONITOR_PLAYBACK_STREAM ,
157 LINE6_BITS_CAPTURE_BUFFER =
158 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
159 LINE6_BIT_PCM_IMPULSE_CAPTURE_BUFFER |
160 #endif
161 LINE6_BIT_PCM_ALSA_CAPTURE_BUFFER |
162 LINE6_BIT_PCM_MONITOR_CAPTURE_BUFFER ,
164 LINE6_BITS_CAPTURE_STREAM =
165 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
166 LINE6_BIT_PCM_IMPULSE_CAPTURE_STREAM |
167 #endif
168 LINE6_BIT_PCM_ALSA_CAPTURE_STREAM |
169 LINE6_BIT_PCM_MONITOR_CAPTURE_STREAM,
171 LINE6_BITS_STREAM =
172 LINE6_BITS_PLAYBACK_STREAM |
173 LINE6_BITS_CAPTURE_STREAM
176 struct line6_pcm_properties {
177 struct snd_pcm_hardware snd_line6_playback_hw, snd_line6_capture_hw;
178 struct snd_pcm_hw_constraint_ratdens snd_line6_rates;
179 int bytes_per_frame;
182 struct snd_line6_pcm {
184 Pointer back to the Line6 driver data structure.
186 struct usb_line6 *line6;
189 Properties.
191 struct line6_pcm_properties *properties;
194 ALSA pcm stream
196 struct snd_pcm *pcm;
199 URBs for audio playback.
201 struct urb *urb_audio_out[LINE6_ISO_BUFFERS];
204 URBs for audio capture.
206 struct urb *urb_audio_in[LINE6_ISO_BUFFERS];
209 Temporary buffer for playback.
210 Since the packet size is not known in advance, this buffer is
211 large enough to store maximum size packets.
213 unsigned char *buffer_out;
216 Temporary buffer for capture.
217 Since the packet size is not known in advance, this buffer is
218 large enough to store maximum size packets.
220 unsigned char *buffer_in;
223 Previously captured frame (for software monitoring).
225 unsigned char *prev_fbuf;
228 Size of previously captured frame (for software monitoring).
230 int prev_fsize;
233 Free frame position in the playback buffer.
235 snd_pcm_uframes_t pos_out;
238 Count processed bytes for playback.
239 This is modulo period size (to determine when a period is
240 finished).
242 unsigned bytes_out;
245 Counter to create desired playback sample rate.
247 unsigned count_out;
250 Playback period size in bytes
252 unsigned period_out;
255 Processed frame position in the playback buffer.
256 The contents of the output ring buffer have been consumed by
257 the USB subsystem (i.e., sent to the USB device) up to this
258 position.
260 snd_pcm_uframes_t pos_out_done;
263 Count processed bytes for capture.
264 This is modulo period size (to determine when a period is
265 finished).
267 unsigned bytes_in;
270 Counter to create desired capture sample rate.
272 unsigned count_in;
275 Capture period size in bytes
277 unsigned period_in;
280 Processed frame position in the capture buffer.
281 The contents of the output ring buffer have been consumed by
282 the USB subsystem (i.e., sent to the USB device) up to this
283 position.
285 snd_pcm_uframes_t pos_in_done;
288 Bit mask of active playback URBs.
290 unsigned long active_urb_out;
293 Maximum size of USB packet.
295 int max_packet_size;
298 USB endpoint for listening to audio data.
300 int ep_audio_read;
303 USB endpoint for writing audio data.
305 int ep_audio_write;
308 Bit mask of active capture URBs.
310 unsigned long active_urb_in;
313 Bit mask of playback URBs currently being unlinked.
315 unsigned long unlink_urb_out;
318 Bit mask of capture URBs currently being unlinked.
320 unsigned long unlink_urb_in;
323 Spin lock to protect updates of the playback buffer positions (not
324 contents!)
326 spinlock_t lock_audio_out;
329 Spin lock to protect updates of the capture buffer positions (not
330 contents!)
332 spinlock_t lock_audio_in;
335 Spin lock to protect trigger.
337 spinlock_t lock_trigger;
340 PCM playback volume (left and right).
342 int volume_playback[2];
345 PCM monitor volume.
347 int volume_monitor;
349 #ifdef CONFIG_LINE6_USB_IMPULSE_RESPONSE
351 Volume of impulse response test signal (if zero, test is disabled).
353 int impulse_volume;
356 Period of impulse response test signal.
358 int impulse_period;
361 Counter for impulse response test signal.
363 int impulse_count;
364 #endif
367 Several status bits (see LINE6_BIT_*).
369 unsigned long flags;
371 int last_frame_in, last_frame_out;
374 extern int line6_init_pcm(struct usb_line6 *line6,
375 struct line6_pcm_properties *properties);
376 extern int snd_line6_trigger(struct snd_pcm_substream *substream, int cmd);
377 extern int snd_line6_prepare(struct snd_pcm_substream *substream);
378 extern void line6_pcm_disconnect(struct snd_line6_pcm *line6pcm);
379 extern int line6_pcm_acquire(struct snd_line6_pcm *line6pcm, int channels);
380 extern int line6_pcm_release(struct snd_line6_pcm *line6pcm, int channels);
382 #endif