This source file includes following definitions.
- clear_handshake
- get_dsp_register
- set_dsp_register
- px_digital_out
- px_analog_in
- px_digital_in
- px_num
- bx_digital_out
- bx_analog_in
- bx_digital_in
- bx_num
- num_pipes_out
- num_pipes_in
- num_busses_out
- num_busses_in
- num_analog_busses_out
- num_analog_busses_in
- num_digital_busses_out
- num_digital_busses_in
- monitor_index
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 #ifndef _ECHOAUDIO_H_
153 #define _ECHOAUDIO_H_
154
155
156 #include "echoaudio_dsp.h"
157
158
159
160
161
162
163
164
165
166
167
168
169 #define VENDOR_ID 0x1057
170 #define DEVICE_ID_56301 0x1801
171 #define DEVICE_ID_56361 0x3410
172 #define SUBVENDOR_ID 0xECC0
173
174
175
176
177
178 #define DARLA20 0x0010
179 #define GINA20 0x0020
180 #define LAYLA20 0x0030
181 #define DARLA24 0x0040
182 #define GINA24 0x0050
183 #define LAYLA24 0x0060
184 #define MONA 0x0070
185 #define MIA 0x0080
186 #define INDIGO 0x0090
187 #define INDIGO_IO 0x00a0
188 #define INDIGO_DJ 0x00b0
189 #define DC8 0x00c0
190 #define INDIGO_IOX 0x00d0
191 #define INDIGO_DJX 0x00e0
192 #define ECHO3G 0x0100
193
194
195
196
197
198
199
200
201
202
203
204 #define ECHO_MAXAUDIOINPUTS 32
205 #define ECHO_MAXAUDIOOUTPUTS 32
206 #define ECHO_MAXAUDIOPIPES 32
207
208 #define E3G_MAX_OUTPUTS 16
209 #define ECHO_MAXMIDIJACKS 1
210 #define ECHO_MIDI_QUEUE_SZ 512
211 #define ECHO_MTC_QUEUE_SZ 32
212
213
214
215
216
217 #define MIDI_ACTIVITY_TIMEOUT_USEC 200000
218
219
220
221
222
223
224
225
226
227
228
229 #define ECHO_CLOCK_INTERNAL 0
230 #define ECHO_CLOCK_WORD 1
231 #define ECHO_CLOCK_SUPER 2
232 #define ECHO_CLOCK_SPDIF 3
233 #define ECHO_CLOCK_ADAT 4
234 #define ECHO_CLOCK_ESYNC 5
235 #define ECHO_CLOCK_ESYNC96 6
236 #define ECHO_CLOCK_MTC 7
237 #define ECHO_CLOCK_NUMBER 8
238 #define ECHO_CLOCKS 0xffff
239
240
241
242
243
244 #define ECHO_CLOCK_BIT_INTERNAL (1 << ECHO_CLOCK_INTERNAL)
245 #define ECHO_CLOCK_BIT_WORD (1 << ECHO_CLOCK_WORD)
246 #define ECHO_CLOCK_BIT_SUPER (1 << ECHO_CLOCK_SUPER)
247 #define ECHO_CLOCK_BIT_SPDIF (1 << ECHO_CLOCK_SPDIF)
248 #define ECHO_CLOCK_BIT_ADAT (1 << ECHO_CLOCK_ADAT)
249 #define ECHO_CLOCK_BIT_ESYNC (1 << ECHO_CLOCK_ESYNC)
250 #define ECHO_CLOCK_BIT_ESYNC96 (1 << ECHO_CLOCK_ESYNC96)
251 #define ECHO_CLOCK_BIT_MTC (1<<ECHO_CLOCK_MTC)
252
253
254
255
256
257
258
259
260
261
262
263 #define DIGITAL_MODE_NONE 0xFF
264 #define DIGITAL_MODE_SPDIF_RCA 0
265 #define DIGITAL_MODE_SPDIF_OPTICAL 1
266 #define DIGITAL_MODE_ADAT 2
267 #define DIGITAL_MODE_SPDIF_CDROM 3
268 #define DIGITAL_MODES 4
269
270
271
272
273 #define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA (1 << DIGITAL_MODE_SPDIF_RCA)
274 #define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL (1 << DIGITAL_MODE_SPDIF_OPTICAL)
275 #define ECHOCAPS_HAS_DIGITAL_MODE_ADAT (1 << DIGITAL_MODE_ADAT)
276 #define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM (1 << DIGITAL_MODE_SPDIF_CDROM)
277
278
279 #define EXT_3GBOX_NC 0x01
280 #define EXT_3GBOX_NOT_SET 0x02
281
282
283 #define ECHOGAIN_MUTED (-128)
284 #define ECHOGAIN_MINOUT (-128)
285 #define ECHOGAIN_MAXOUT (6)
286 #define ECHOGAIN_MININP (-50)
287 #define ECHOGAIN_MAXINP (50)
288
289 #define PIPE_STATE_STOPPED 0
290 #define PIPE_STATE_PAUSED 1
291 #define PIPE_STATE_STARTED 2
292 #define PIPE_STATE_PENDING 3
293
294
295
296 struct audiopipe {
297 volatile __le32 *dma_counter;
298
299
300
301 u32 last_counter;
302
303
304 u32 position;
305
306
307
308 short index;
309
310
311 short interleave;
312 struct snd_dma_buffer sgpage;
313 struct snd_pcm_hardware hw;
314 struct snd_pcm_hw_constraint_list constr;
315 short sglist_head;
316 char state;
317 };
318
319
320 struct audioformat {
321 u8 interleave;
322
323
324 u8 bits_per_sample;
325 char mono_to_stereo;
326
327
328 char data_are_bigendian;
329 };
330
331
332 struct echoaudio {
333 spinlock_t lock;
334 struct snd_pcm_substream *substream[DSP_MAXPIPES];
335 int last_period[DSP_MAXPIPES];
336 struct mutex mode_mutex;
337 u16 num_digital_modes, digital_mode_list[6];
338 u16 num_clock_sources, clock_source_list[10];
339 atomic_t opencount;
340 struct snd_kcontrol *clock_src_ctl;
341 struct snd_pcm *analog_pcm, *digital_pcm;
342 struct snd_card *card;
343 const char *card_name;
344 struct pci_dev *pci;
345 unsigned long dsp_registers_phys;
346 struct resource *iores;
347 struct snd_dma_buffer commpage_dma_buf;
348 int irq;
349 #ifdef ECHOCARD_HAS_MIDI
350 struct snd_rawmidi *rmidi;
351 struct snd_rawmidi_substream *midi_in, *midi_out;
352 #endif
353 struct timer_list timer;
354 char tinuse;
355 char midi_full;
356 char can_set_rate;
357 char rate_set;
358
359
360 struct comm_page *comm_page;
361
362
363 u32 pipe_alloc_mask;
364 u32 pipe_cyclic_mask;
365
366
367 u32 sample_rate;
368 u8 digital_mode;
369
370
371 u8 spdif_status;
372 u8 clock_state;
373 u8 input_clock;
374
375
376 u8 output_clock;
377 char meters_enabled;
378 char asic_loaded;
379 char bad_board;
380 char professional_spdif;
381 char non_audio_spdif;
382 char digital_in_automute;
383 char has_phantom_power;
384 char hasnt_input_nominal_level;
385 char phantom_power;
386 char has_midi;
387 char midi_input_enabled;
388
389 #ifdef ECHOCARD_ECHO3G
390
391 char px_digital_out, px_analog_in, px_digital_in, px_num;
392 char bx_digital_out, bx_analog_in, bx_digital_in, bx_num;
393 #endif
394
395 char nominal_level[ECHO_MAXAUDIOPIPES];
396
397 s8 input_gain[ECHO_MAXAUDIOINPUTS];
398
399 s8 output_gain[ECHO_MAXAUDIOOUTPUTS];
400
401 s8 monitor_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOINPUTS];
402
403 s8 vmixer_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOOUTPUTS];
404
405
406 u16 digital_modes;
407
408 u16 input_clock_types;
409 u16 output_clock_types;
410
411 u16 device_id, subdevice_id;
412 u16 *dsp_code;
413
414 short dsp_code_to_load;
415 short asic_code;
416 u32 comm_page_phys;
417
418 volatile u32 __iomem *dsp_registers;
419 u32 active_mask;
420
421 #ifdef CONFIG_PM_SLEEP
422 const struct firmware *fw_cache[8];
423 #endif
424
425 #ifdef ECHOCARD_HAS_MIDI
426 u16 mtc_state;
427 u8 midi_buffer[MIDI_IN_BUFFER_SIZE];
428 #endif
429 };
430
431
432 static int init_dsp_comm_page(struct echoaudio *chip);
433 static int init_line_levels(struct echoaudio *chip);
434 static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe);
435 static int load_firmware(struct echoaudio *chip);
436 static int wait_handshake(struct echoaudio *chip);
437 static int send_vector(struct echoaudio *chip, u32 command);
438 static int get_firmware(const struct firmware **fw_entry,
439 struct echoaudio *chip, const short fw_index);
440 static void free_firmware(const struct firmware *fw_entry,
441 struct echoaudio *chip);
442
443 #ifdef ECHOCARD_HAS_MIDI
444 static int enable_midi_input(struct echoaudio *chip, char enable);
445 static void snd_echo_midi_output_trigger(
446 struct snd_rawmidi_substream *substream, int up);
447 static int midi_service_irq(struct echoaudio *chip);
448 static int snd_echo_midi_create(struct snd_card *card,
449 struct echoaudio *chip);
450 #endif
451
452
453 static inline void clear_handshake(struct echoaudio *chip)
454 {
455 chip->comm_page->handshake = 0;
456 }
457
458 static inline u32 get_dsp_register(struct echoaudio *chip, u32 index)
459 {
460 return readl(&chip->dsp_registers[index]);
461 }
462
463 static inline void set_dsp_register(struct echoaudio *chip, u32 index,
464 u32 value)
465 {
466 writel(value, &chip->dsp_registers[index]);
467 }
468
469
470
471
472
473
474
475 static inline int px_digital_out(const struct echoaudio *chip)
476 {
477 return PX_DIGITAL_OUT;
478 }
479
480 static inline int px_analog_in(const struct echoaudio *chip)
481 {
482 return PX_ANALOG_IN;
483 }
484
485 static inline int px_digital_in(const struct echoaudio *chip)
486 {
487 return PX_DIGITAL_IN;
488 }
489
490 static inline int px_num(const struct echoaudio *chip)
491 {
492 return PX_NUM;
493 }
494
495 static inline int bx_digital_out(const struct echoaudio *chip)
496 {
497 return BX_DIGITAL_OUT;
498 }
499
500 static inline int bx_analog_in(const struct echoaudio *chip)
501 {
502 return BX_ANALOG_IN;
503 }
504
505 static inline int bx_digital_in(const struct echoaudio *chip)
506 {
507 return BX_DIGITAL_IN;
508 }
509
510 static inline int bx_num(const struct echoaudio *chip)
511 {
512 return BX_NUM;
513 }
514
515 static inline int num_pipes_out(const struct echoaudio *chip)
516 {
517 return px_analog_in(chip);
518 }
519
520 static inline int num_pipes_in(const struct echoaudio *chip)
521 {
522 return px_num(chip) - px_analog_in(chip);
523 }
524
525 static inline int num_busses_out(const struct echoaudio *chip)
526 {
527 return bx_analog_in(chip);
528 }
529
530 static inline int num_busses_in(const struct echoaudio *chip)
531 {
532 return bx_num(chip) - bx_analog_in(chip);
533 }
534
535 static inline int num_analog_busses_out(const struct echoaudio *chip)
536 {
537 return bx_digital_out(chip);
538 }
539
540 static inline int num_analog_busses_in(const struct echoaudio *chip)
541 {
542 return bx_digital_in(chip) - bx_analog_in(chip);
543 }
544
545 static inline int num_digital_busses_out(const struct echoaudio *chip)
546 {
547 return num_busses_out(chip) - num_analog_busses_out(chip);
548 }
549
550 static inline int num_digital_busses_in(const struct echoaudio *chip)
551 {
552 return num_busses_in(chip) - num_analog_busses_in(chip);
553 }
554
555
556
557 static inline int monitor_index(const struct echoaudio *chip, int out, int in)
558 {
559 return out * num_busses_in(chip) + in;
560 }
561
562 #endif