6b13f685e
김민수
BSP 최초 추가
|
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
|
#ifndef _ECHOAUDIO_H_
#define _ECHOAUDIO_H_
#define TRUE 1
#define FALSE 0
#include "echoaudio_dsp.h"
#define VENDOR_ID 0x1057
#define DEVICE_ID_56301 0x1801
#define DEVICE_ID_56361 0x3410
#define SUBVENDOR_ID 0xECC0
#define DARLA20 0x0010
#define GINA20 0x0020
#define LAYLA20 0x0030
#define DARLA24 0x0040
#define GINA24 0x0050
#define LAYLA24 0x0060
#define MONA 0x0070
#define MIA 0x0080
#define INDIGO 0x0090
#define INDIGO_IO 0x00a0
#define INDIGO_DJ 0x00b0
#define DC8 0x00c0
#define INDIGO_IOX 0x00d0
#define INDIGO_DJX 0x00e0
#define ECHO3G 0x0100
#define ECHO_MAXAUDIOINPUTS 32 /* Max audio input channels */
#define ECHO_MAXAUDIOOUTPUTS 32 /* Max audio output channels */
#define ECHO_MAXAUDIOPIPES 32 /* Max number of input and output
* pipes */
#define E3G_MAX_OUTPUTS 16
#define ECHO_MAXMIDIJACKS 1 /* Max MIDI ports */
#define ECHO_MIDI_QUEUE_SZ 512 /* Max MIDI input queue entries */
#define ECHO_MTC_QUEUE_SZ 32 /* Max MIDI time code input queue
* entries */
#define MIDI_ACTIVITY_TIMEOUT_USEC 200000
#define ECHO_CLOCK_INTERNAL 0
#define ECHO_CLOCK_WORD 1
#define ECHO_CLOCK_SUPER 2
#define ECHO_CLOCK_SPDIF 3
#define ECHO_CLOCK_ADAT 4
#define ECHO_CLOCK_ESYNC 5
#define ECHO_CLOCK_ESYNC96 6
#define ECHO_CLOCK_MTC 7
#define ECHO_CLOCK_NUMBER 8
#define ECHO_CLOCKS 0xffff
#define ECHO_CLOCK_BIT_INTERNAL (1 << ECHO_CLOCK_INTERNAL)
#define ECHO_CLOCK_BIT_WORD (1 << ECHO_CLOCK_WORD)
#define ECHO_CLOCK_BIT_SUPER (1 << ECHO_CLOCK_SUPER)
#define ECHO_CLOCK_BIT_SPDIF (1 << ECHO_CLOCK_SPDIF)
#define ECHO_CLOCK_BIT_ADAT (1 << ECHO_CLOCK_ADAT)
#define ECHO_CLOCK_BIT_ESYNC (1 << ECHO_CLOCK_ESYNC)
#define ECHO_CLOCK_BIT_ESYNC96 (1 << ECHO_CLOCK_ESYNC96)
#define ECHO_CLOCK_BIT_MTC (1<<ECHO_CLOCK_MTC)
#define DIGITAL_MODE_NONE 0xFF
#define DIGITAL_MODE_SPDIF_RCA 0
#define DIGITAL_MODE_SPDIF_OPTICAL 1
#define DIGITAL_MODE_ADAT 2
#define DIGITAL_MODE_SPDIF_CDROM 3
#define DIGITAL_MODES 4
#define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA (1 << DIGITAL_MODE_SPDIF_RCA)
#define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL (1 << DIGITAL_MODE_SPDIF_OPTICAL)
#define ECHOCAPS_HAS_DIGITAL_MODE_ADAT (1 << DIGITAL_MODE_ADAT)
#define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM (1 << DIGITAL_MODE_SPDIF_CDROM)
#define EXT_3GBOX_NC 0x01 /* 3G box not connected */
#define EXT_3GBOX_NOT_SET 0x02 /* 3G box not detected yet */
#define ECHOGAIN_MUTED (-128) /* Minimum possible gain */
#define ECHOGAIN_MINOUT (-128) /* Min output gain (dB) */
#define ECHOGAIN_MAXOUT (6) /* Max output gain (dB) */
#define ECHOGAIN_MININP (-50) /* Min input gain (0.5 dB) */
#define ECHOGAIN_MAXINP (50) /* Max input gain (0.5 dB) */
#define PIPE_STATE_STOPPED 0 /* Pipe has been reset */
#define PIPE_STATE_PAUSED 1 /* Pipe has been stopped */
#define PIPE_STATE_STARTED 2 /* Pipe has been started */
#define PIPE_STATE_PENDING 3 /* Pipe has pending start */
#ifdef CONFIG_SND_DEBUG
#define DE_INIT(x) snd_printk x
#else
#define DE_INIT(x)
#endif
#ifdef CONFIG_SND_DEBUG
#define DE_HWP(x) snd_printk x
#else
#define DE_HWP(x)
#endif
#ifdef CONFIG_SND_DEBUG
#define DE_ACT(x) snd_printk x
#else
#define DE_ACT(x)
#endif
#ifdef CONFIG_SND_DEBUG
#define DE_MID(x) snd_printk x
#else
#define DE_MID(x)
#endif
struct audiopipe {
volatile u32 *dma_counter;
u32 last_counter;
u32 position;
short index;
short interleave;
struct snd_dma_buffer sgpage;
struct snd_pcm_hardware hw;
struct snd_pcm_hw_constraint_list constr;
short sglist_head;
char state;
};
struct audioformat {
u8 interleave;
u8 bits_per_sample;
char mono_to_stereo;
char data_are_bigendian;
};
struct echoaudio {
spinlock_t lock;
struct snd_pcm_substream *substream[DSP_MAXPIPES];
int last_period[DSP_MAXPIPES];
struct mutex mode_mutex;
u16 num_digital_modes, digital_mode_list[6];
u16 num_clock_sources, clock_source_list[10];
atomic_t opencount;
struct snd_kcontrol *clock_src_ctl;
struct snd_pcm *analog_pcm, *digital_pcm;
struct snd_card *card;
const char *card_name;
struct pci_dev *pci;
unsigned long dsp_registers_phys;
struct resource *iores;
struct snd_dma_buffer commpage_dma_buf;
int irq;
#ifdef ECHOCARD_HAS_MIDI
struct snd_rawmidi *rmidi;
struct snd_rawmidi_substream *midi_in, *midi_out;
#endif
struct timer_list timer;
char tinuse;
char midi_full;
char can_set_rate;
char rate_set;
struct comm_page *comm_page;
u32 pipe_alloc_mask;
u32 pipe_cyclic_mask;
u32 sample_rate;
u8 digital_mode;
u8 spdif_status;
u8 clock_state;
u8 input_clock;
u8 output_clock;
char meters_enabled;
char asic_loaded;
char bad_board;
char professional_spdif;
char non_audio_spdif;
char digital_in_automute;
char has_phantom_power;
char hasnt_input_nominal_level;
char phantom_power;
char has_midi;
char midi_input_enabled;
#ifdef ECHOCARD_ECHO3G
char px_digital_out, px_analog_in, px_digital_in, px_num;
char bx_digital_out, bx_analog_in, bx_digital_in, bx_num;
#endif
char nominal_level[ECHO_MAXAUDIOPIPES];
s8 input_gain[ECHO_MAXAUDIOINPUTS];
s8 output_gain[ECHO_MAXAUDIOOUTPUTS];
s8 monitor_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOINPUTS];
s8 vmixer_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOOUTPUTS];
u16 digital_modes;
u16 input_clock_types;
u16 output_clock_types;
u16 device_id, subdevice_id;
u16 *dsp_code;
short dsp_code_to_load;
short asic_code;
u32 comm_page_phys;
volatile u32 __iomem *dsp_registers;
u32 active_mask;
#ifdef CONFIG_PM_SLEEP
const struct firmware *fw_cache[8];
#endif
#ifdef ECHOCARD_HAS_MIDI
u16 mtc_state;
u8 midi_buffer[MIDI_IN_BUFFER_SIZE];
#endif
};
static int init_dsp_comm_page(struct echoaudio *chip);
static int init_line_levels(struct echoaudio *chip);
static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe);
static int load_firmware(struct echoaudio *chip);
static int wait_handshake(struct echoaudio *chip);
static int send_vector(struct echoaudio *chip, u32 command);
static int get_firmware(const struct firmware **fw_entry,
struct echoaudio *chip, const short fw_index);
static void free_firmware(const struct firmware *fw_entry);
#ifdef ECHOCARD_HAS_MIDI
static int enable_midi_input(struct echoaudio *chip, char enable);
static void snd_echo_midi_output_trigger(
struct snd_rawmidi_substream *substream, int up);
static int midi_service_irq(struct echoaudio *chip);
static int snd_echo_midi_create(struct snd_card *card,
struct echoaudio *chip);
#endif
static inline void clear_handshake(struct echoaudio *chip)
{
chip->comm_page->handshake = 0;
}
static inline u32 get_dsp_register(struct echoaudio *chip, u32 index)
{
return readl(&chip->dsp_registers[index]);
}
static inline void set_dsp_register(struct echoaudio *chip, u32 index,
u32 value)
{
writel(value, &chip->dsp_registers[index]);
}
static inline int px_digital_out(const struct echoaudio *chip)
{
return PX_DIGITAL_OUT;
}
static inline int px_analog_in(const struct echoaudio *chip)
{
return PX_ANALOG_IN;
}
static inline int px_digital_in(const struct echoaudio *chip)
{
return PX_DIGITAL_IN;
}
static inline int px_num(const struct echoaudio *chip)
{
return PX_NUM;
}
static inline int bx_digital_out(const struct echoaudio *chip)
{
return BX_DIGITAL_OUT;
}
static inline int bx_analog_in(const struct echoaudio *chip)
{
return BX_ANALOG_IN;
}
static inline int bx_digital_in(const struct echoaudio *chip)
{
return BX_DIGITAL_IN;
}
static inline int bx_num(const struct echoaudio *chip)
{
return BX_NUM;
}
static inline int num_pipes_out(const struct echoaudio *chip)
{
return px_analog_in(chip);
}
static inline int num_pipes_in(const struct echoaudio *chip)
{
return px_num(chip) - px_analog_in(chip);
}
static inline int num_busses_out(const struct echoaudio *chip)
{
return bx_analog_in(chip);
}
static inline int num_busses_in(const struct echoaudio *chip)
{
return bx_num(chip) - bx_analog_in(chip);
}
static inline int num_analog_busses_out(const struct echoaudio *chip)
{
return bx_digital_out(chip);
}
static inline int num_analog_busses_in(const struct echoaudio *chip)
{
return bx_digital_in(chip) - bx_analog_in(chip);
}
static inline int num_digital_busses_out(const struct echoaudio *chip)
{
return num_busses_out(chip) - num_analog_busses_out(chip);
}
static inline int num_digital_busses_in(const struct echoaudio *chip)
{
return num_busses_in(chip) - num_analog_busses_in(chip);
}
static inline int monitor_index(const struct echoaudio *chip, int out, int in)
{
return out * num_busses_in(chip) + in;
}
#ifndef pci_device
#define pci_device(chip) (&chip->pci->dev)
#endif
#endif /* _ECHOAUDIO_H_ */
|