0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152 #ifndef _ECHOAUDIO_H_
0153 #define _ECHOAUDIO_H_
0154
0155
0156 #include "echoaudio_dsp.h"
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 #define VENDOR_ID 0x1057
0170 #define DEVICE_ID_56301 0x1801
0171 #define DEVICE_ID_56361 0x3410
0172 #define SUBVENDOR_ID 0xECC0
0173
0174
0175
0176
0177
0178 #define DARLA20 0x0010
0179 #define GINA20 0x0020
0180 #define LAYLA20 0x0030
0181 #define DARLA24 0x0040
0182 #define GINA24 0x0050
0183 #define LAYLA24 0x0060
0184 #define MONA 0x0070
0185 #define MIA 0x0080
0186 #define INDIGO 0x0090
0187 #define INDIGO_IO 0x00a0
0188 #define INDIGO_DJ 0x00b0
0189 #define DC8 0x00c0
0190 #define INDIGO_IOX 0x00d0
0191 #define INDIGO_DJX 0x00e0
0192 #define ECHO3G 0x0100
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204 #define ECHO_MAXAUDIOINPUTS 32
0205 #define ECHO_MAXAUDIOOUTPUTS 32
0206 #define ECHO_MAXAUDIOPIPES 32
0207
0208 #define E3G_MAX_OUTPUTS 16
0209 #define ECHO_MAXMIDIJACKS 1
0210 #define ECHO_MIDI_QUEUE_SZ 512
0211 #define ECHO_MTC_QUEUE_SZ 32
0212
0213
0214
0215
0216
0217 #define MIDI_ACTIVITY_TIMEOUT_USEC 200000
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229 #define ECHO_CLOCK_INTERNAL 0
0230 #define ECHO_CLOCK_WORD 1
0231 #define ECHO_CLOCK_SUPER 2
0232 #define ECHO_CLOCK_SPDIF 3
0233 #define ECHO_CLOCK_ADAT 4
0234 #define ECHO_CLOCK_ESYNC 5
0235 #define ECHO_CLOCK_ESYNC96 6
0236 #define ECHO_CLOCK_MTC 7
0237 #define ECHO_CLOCK_NUMBER 8
0238 #define ECHO_CLOCKS 0xffff
0239
0240
0241
0242
0243
0244 #define ECHO_CLOCK_BIT_INTERNAL (1 << ECHO_CLOCK_INTERNAL)
0245 #define ECHO_CLOCK_BIT_WORD (1 << ECHO_CLOCK_WORD)
0246 #define ECHO_CLOCK_BIT_SUPER (1 << ECHO_CLOCK_SUPER)
0247 #define ECHO_CLOCK_BIT_SPDIF (1 << ECHO_CLOCK_SPDIF)
0248 #define ECHO_CLOCK_BIT_ADAT (1 << ECHO_CLOCK_ADAT)
0249 #define ECHO_CLOCK_BIT_ESYNC (1 << ECHO_CLOCK_ESYNC)
0250 #define ECHO_CLOCK_BIT_ESYNC96 (1 << ECHO_CLOCK_ESYNC96)
0251 #define ECHO_CLOCK_BIT_MTC (1<<ECHO_CLOCK_MTC)
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263 #define DIGITAL_MODE_NONE 0xFF
0264 #define DIGITAL_MODE_SPDIF_RCA 0
0265 #define DIGITAL_MODE_SPDIF_OPTICAL 1
0266 #define DIGITAL_MODE_ADAT 2
0267 #define DIGITAL_MODE_SPDIF_CDROM 3
0268 #define DIGITAL_MODES 4
0269
0270
0271
0272
0273 #define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_RCA (1 << DIGITAL_MODE_SPDIF_RCA)
0274 #define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_OPTICAL (1 << DIGITAL_MODE_SPDIF_OPTICAL)
0275 #define ECHOCAPS_HAS_DIGITAL_MODE_ADAT (1 << DIGITAL_MODE_ADAT)
0276 #define ECHOCAPS_HAS_DIGITAL_MODE_SPDIF_CDROM (1 << DIGITAL_MODE_SPDIF_CDROM)
0277
0278
0279 #define EXT_3GBOX_NC 0x01
0280 #define EXT_3GBOX_NOT_SET 0x02
0281
0282
0283 #define ECHOGAIN_MUTED (-128)
0284 #define ECHOGAIN_MINOUT (-128)
0285 #define ECHOGAIN_MAXOUT (6)
0286 #define ECHOGAIN_MININP (-50)
0287 #define ECHOGAIN_MAXINP (50)
0288
0289 #define PIPE_STATE_STOPPED 0
0290 #define PIPE_STATE_PAUSED 1
0291 #define PIPE_STATE_STARTED 2
0292 #define PIPE_STATE_PENDING 3
0293
0294
0295
0296 struct audiopipe {
0297 volatile __le32 *dma_counter;
0298
0299
0300
0301 u32 last_period;
0302
0303
0304 u32 last_counter;
0305
0306
0307
0308
0309 u32 position;
0310
0311
0312
0313 short index;
0314
0315
0316 short interleave;
0317 struct snd_dma_buffer sgpage;
0318 struct snd_pcm_hardware hw;
0319 struct snd_pcm_hw_constraint_list constr;
0320 short sglist_head;
0321 char state;
0322 };
0323
0324
0325 struct audioformat {
0326 u8 interleave;
0327
0328
0329 u8 bits_per_sample;
0330 char mono_to_stereo;
0331
0332
0333 char data_are_bigendian;
0334 };
0335
0336
0337 struct echoaudio {
0338 spinlock_t lock;
0339 struct snd_pcm_substream *substream[DSP_MAXPIPES];
0340 struct mutex mode_mutex;
0341 u16 num_digital_modes, digital_mode_list[6];
0342 u16 num_clock_sources, clock_source_list[10];
0343 unsigned int opencount;
0344 struct snd_kcontrol *clock_src_ctl;
0345 struct snd_pcm *analog_pcm, *digital_pcm;
0346 struct snd_card *card;
0347 const char *card_name;
0348 struct pci_dev *pci;
0349 unsigned long dsp_registers_phys;
0350 struct resource *iores;
0351 struct snd_dma_buffer *commpage_dma_buf;
0352 int irq;
0353 #ifdef ECHOCARD_HAS_MIDI
0354 struct snd_rawmidi *rmidi;
0355 struct snd_rawmidi_substream *midi_in, *midi_out;
0356 #endif
0357 struct timer_list timer;
0358 char tinuse;
0359 char midi_full;
0360 char can_set_rate;
0361 char rate_set;
0362
0363
0364 struct comm_page *comm_page;
0365
0366
0367 u32 pipe_alloc_mask;
0368 u32 pipe_cyclic_mask;
0369
0370
0371 u32 sample_rate;
0372 u8 digital_mode;
0373
0374
0375 u8 spdif_status;
0376 u8 clock_state;
0377 u8 input_clock;
0378
0379
0380 u8 output_clock;
0381 char meters_enabled;
0382 char asic_loaded;
0383 char bad_board;
0384 char professional_spdif;
0385 char non_audio_spdif;
0386 char digital_in_automute;
0387 char has_phantom_power;
0388 char hasnt_input_nominal_level;
0389 char phantom_power;
0390 char has_midi;
0391 char midi_input_enabled;
0392
0393 #ifdef ECHOCARD_ECHO3G
0394
0395 char px_digital_out, px_analog_in, px_digital_in, px_num;
0396 char bx_digital_out, bx_analog_in, bx_digital_in, bx_num;
0397 #endif
0398
0399 char nominal_level[ECHO_MAXAUDIOPIPES];
0400
0401 s8 input_gain[ECHO_MAXAUDIOINPUTS];
0402
0403 s8 output_gain[ECHO_MAXAUDIOOUTPUTS];
0404
0405 s8 monitor_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOINPUTS];
0406
0407 s8 vmixer_gain[ECHO_MAXAUDIOOUTPUTS][ECHO_MAXAUDIOOUTPUTS];
0408
0409
0410 u16 digital_modes;
0411
0412 u16 input_clock_types;
0413 u16 output_clock_types;
0414
0415 u16 device_id, subdevice_id;
0416 u16 *dsp_code;
0417
0418 short dsp_code_to_load;
0419 short asic_code;
0420 u32 comm_page_phys;
0421
0422 u32 __iomem *dsp_registers;
0423 u32 active_mask;
0424
0425 #ifdef CONFIG_PM_SLEEP
0426 const struct firmware *fw_cache[8];
0427 #endif
0428
0429 #ifdef ECHOCARD_HAS_MIDI
0430 u16 mtc_state;
0431 u8 midi_buffer[MIDI_IN_BUFFER_SIZE];
0432 #endif
0433 };
0434
0435
0436 static int init_dsp_comm_page(struct echoaudio *chip);
0437 static int init_line_levels(struct echoaudio *chip);
0438 static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe);
0439 static int load_firmware(struct echoaudio *chip);
0440 static int wait_handshake(struct echoaudio *chip);
0441 static int send_vector(struct echoaudio *chip, u32 command);
0442 static int get_firmware(const struct firmware **fw_entry,
0443 struct echoaudio *chip, const short fw_index);
0444 static void free_firmware(const struct firmware *fw_entry,
0445 struct echoaudio *chip);
0446
0447 #ifdef ECHOCARD_HAS_MIDI
0448 static int enable_midi_input(struct echoaudio *chip, char enable);
0449 static void snd_echo_midi_output_trigger(
0450 struct snd_rawmidi_substream *substream, int up);
0451 static int midi_service_irq(struct echoaudio *chip);
0452 static int snd_echo_midi_create(struct snd_card *card,
0453 struct echoaudio *chip);
0454 #endif
0455
0456
0457 static inline void clear_handshake(struct echoaudio *chip)
0458 {
0459 chip->comm_page->handshake = 0;
0460 }
0461
0462 static inline u32 get_dsp_register(struct echoaudio *chip, u32 index)
0463 {
0464 return readl(&chip->dsp_registers[index]);
0465 }
0466
0467 static inline void set_dsp_register(struct echoaudio *chip, u32 index,
0468 u32 value)
0469 {
0470 writel(value, &chip->dsp_registers[index]);
0471 }
0472
0473
0474
0475
0476
0477
0478
0479 static inline int px_digital_out(const struct echoaudio *chip)
0480 {
0481 return PX_DIGITAL_OUT;
0482 }
0483
0484 static inline int px_analog_in(const struct echoaudio *chip)
0485 {
0486 return PX_ANALOG_IN;
0487 }
0488
0489 static inline int px_digital_in(const struct echoaudio *chip)
0490 {
0491 return PX_DIGITAL_IN;
0492 }
0493
0494 static inline int px_num(const struct echoaudio *chip)
0495 {
0496 return PX_NUM;
0497 }
0498
0499 static inline int bx_digital_out(const struct echoaudio *chip)
0500 {
0501 return BX_DIGITAL_OUT;
0502 }
0503
0504 static inline int bx_analog_in(const struct echoaudio *chip)
0505 {
0506 return BX_ANALOG_IN;
0507 }
0508
0509 static inline int bx_digital_in(const struct echoaudio *chip)
0510 {
0511 return BX_DIGITAL_IN;
0512 }
0513
0514 static inline int bx_num(const struct echoaudio *chip)
0515 {
0516 return BX_NUM;
0517 }
0518
0519 static inline int num_pipes_out(const struct echoaudio *chip)
0520 {
0521 return px_analog_in(chip);
0522 }
0523
0524 static inline int num_pipes_in(const struct echoaudio *chip)
0525 {
0526 return px_num(chip) - px_analog_in(chip);
0527 }
0528
0529 static inline int num_busses_out(const struct echoaudio *chip)
0530 {
0531 return bx_analog_in(chip);
0532 }
0533
0534 static inline int num_busses_in(const struct echoaudio *chip)
0535 {
0536 return bx_num(chip) - bx_analog_in(chip);
0537 }
0538
0539 static inline int num_analog_busses_out(const struct echoaudio *chip)
0540 {
0541 return bx_digital_out(chip);
0542 }
0543
0544 static inline int num_analog_busses_in(const struct echoaudio *chip)
0545 {
0546 return bx_digital_in(chip) - bx_analog_in(chip);
0547 }
0548
0549 static inline int num_digital_busses_out(const struct echoaudio *chip)
0550 {
0551 return num_busses_out(chip) - num_analog_busses_out(chip);
0552 }
0553
0554 static inline int num_digital_busses_in(const struct echoaudio *chip)
0555 {
0556 return num_busses_in(chip) - num_analog_busses_in(chip);
0557 }
0558
0559
0560
0561 static inline int monitor_index(const struct echoaudio *chip, int out, int in)
0562 {
0563 return out * num_busses_in(chip) + in;
0564 }
0565
0566 #endif