32 #error PAGE_SIZE is < 4k
95 for (i = 0; i < 10000000; i++) {
119 for (i = 0; i < READ_DSP_TIMEOUT; i++) {
145 static int read_sn(
struct echoaudio *chip)
150 for (i = 0; i < 5; i++) {
151 if (read_dsp(chip, &sn[i])) {
156 DE_INIT((
"Read serial number %08x %08x %08x %08x %08x\n",
157 sn[0], sn[1], sn[2], sn[3], sn[4]));
163 #ifndef ECHOCARD_HAS_ASIC
165 static inline int check_asic_status(
struct echoaudio *chip)
175 #ifdef ECHOCARD_HAS_ASIC
185 err = get_firmware(&fw, chip, asic);
195 if (write_dsp(chip, cmd) < 0)
199 if (write_dsp(chip, size) < 0)
202 for (i = 0; i <
size; i++) {
203 if (write_dsp(chip, code[i]) < 0)
212 DE_INIT((
"failed on write_dsp\n"));
226 static int install_resident_loader(
struct echoaudio *chip)
243 DE_INIT((
"Resident loader already installed; status is 0x%x\n",
277 words = code[index++];
280 address = ((
u32)code[
index] << 16) + code[index + 1];
284 if (write_dsp(chip, words)) {
285 DE_INIT((
"install_resident_loader: Failed to write word count!\n"));
289 if (write_dsp(chip, address)) {
290 DE_INIT((
"install_resident_loader: Failed to write DSP address!\n"));
294 for (i = 0; i < words; i++) {
297 data = ((
u32)code[index] << 16) + code[index + 1];
298 if (write_dsp(chip, data)) {
299 DE_INIT((
"install_resident_loader: Failed to write DSP code\n"));
306 for (i = 0; i < 200; i++) {
309 if (status & CHI32_STATUS_REG_HF5)
314 DE_INIT((
"Resident loader failed to set HF5\n"));
318 DE_INIT((
"Resident loader successfully installed\n"));
336 DE_INIT((
"DSP is already loaded!\n"));
343 DE_INIT((
"load_dsp: Set bad_board to TRUE\n"));
347 if ((i = install_resident_loader(chip)) < 0)
353 DE_INIT((
"LoadDsp: send_vector DSP_VC_RESET failed, Critical Failure\n"));
360 for (i = 0; i < 1000; i++) {
368 DE_INIT((
"load_dsp: Timeout waiting for CHI32_STATUS_REG_HF3\n"));
386 block_type = code[
index];
393 mem_type = code[index++];
396 words = code[index++];
401 address = ((
u32)code[index] << 16) + code[index + 1];
404 if (write_dsp(chip, words) < 0) {
405 DE_INIT((
"load_dsp: failed to write number of DSP words\n"));
408 if (write_dsp(chip, address) < 0) {
409 DE_INIT((
"load_dsp: failed to write DSP address\n"));
412 if (write_dsp(chip, mem_type) < 0) {
413 DE_INIT((
"load_dsp: failed to write DSP memory type\n"));
417 for (i = 0; i < words; i++, index+=2) {
418 data = ((
u32)code[index] << 16) + code[index + 1];
419 if (write_dsp(chip, data) < 0) {
420 DE_INIT((
"load_dsp: failed to write DSP data\n"));
426 if (write_dsp(chip, 0) < 0) {
427 DE_INIT((
"load_dsp: Failed to write final zero\n"));
432 for (i = 0; i < 5000; i++) {
440 DE_INIT((
"load_dsp: Failed to write DSP_FNC_SET_COMMPAGE_ADDR\n"));
445 DE_INIT((
"load_dsp: Failed to write comm page address\n"));
453 if (read_sn(chip) < 0) {
454 DE_INIT((
"load_dsp: Failed to read serial number\n"));
466 DE_INIT((
"load_dsp: DSP load timed out waiting for HF4\n"));
473 static int load_firmware(
struct echoaudio *chip)
483 if ((box_type = check_asic_status(chip)) >= 0)
492 err = load_dsp(chip, (
u16 *)fw->
data);
497 if ((box_type = load_asic(chip)) < 0)
509 #if defined(ECHOCARD_HAS_INPUT_NOMINAL_LEVEL) || \
510 defined(ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL)
513 static int set_nominal_level(
struct echoaudio *chip,
u16 index,
char consumer)
515 if (
snd_BUG_ON(index >= num_busses_out(chip) + num_busses_in(chip)))
519 if (wait_handshake(chip))
539 if (
snd_BUG_ON(channel >= num_busses_out(chip)))
542 if (wait_handshake(chip))
553 #ifdef ECHOCARD_HAS_MONITOR
558 if (
snd_BUG_ON(output >= num_busses_out(chip) ||
559 input >= num_busses_in(chip)))
562 if (wait_handshake(chip))
566 chip->
comm_page->monitors[monitor_index(chip, output, input)] =
gain;
573 static int update_output_line_level(
struct echoaudio *chip)
575 if (wait_handshake(chip))
577 clear_handshake(chip);
584 static int update_input_line_level(
struct echoaudio *chip)
586 if (wait_handshake(chip))
588 clear_handshake(chip);
596 static void set_meters_on(
struct echoaudio *chip,
char on)
621 static void get_audio_meters(
struct echoaudio *chip,
long *meters)
627 for (i = 0; i < num_busses_out(chip); i++, m++) {
634 #ifdef ECHOCARD_ECHO3G
638 for (i = 0; i < num_busses_in(chip); i++, m++) {
645 #ifdef ECHOCARD_HAS_VMIXER
646 for (i = 0; i < num_pipes_out(chip); i++, m++) {
657 static int restore_dsp_rettings(
struct echoaudio *chip)
660 DE_INIT((
"restore_dsp_settings\n"));
662 if ((err = check_asic_status(chip)) < 0)
671 for (i = 0; i < num_busses_out(chip); i++) {
672 err = set_output_gain(chip, i, chip->
output_gain[i]);
677 #ifdef ECHOCARD_HAS_VMIXER
678 for (i = 0; i < num_pipes_out(chip); i++)
679 for (o = 0; o < num_busses_out(chip); o++) {
680 err = set_vmixer_gain(chip, o, i,
685 if (update_vmixer_level(chip) < 0)
689 #ifdef ECHOCARD_HAS_MONITOR
690 for (o = 0; o < num_busses_out(chip); o++)
691 for (i = 0; i < num_busses_in(chip); i++) {
692 err = set_monitor_gain(chip, o, i,
699 #ifdef ECHOCARD_HAS_INPUT_GAIN
700 for (i = 0; i < num_busses_in(chip); i++) {
701 err = set_input_gain(chip, i, chip->
input_gain[i]);
707 err = update_output_line_level(chip);
711 err = update_input_line_level(chip);
725 #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH
730 #ifdef ECHOCARD_HAS_DIGITAL_IO
735 #ifdef ECHOCARD_HAS_PHANTOM_POWER
740 #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK
746 #ifdef ECHOCARD_HAS_OUTPUT_CLOCK_SWITCH
751 if (wait_handshake(chip) < 0)
753 clear_handshake(chip);
757 DE_INIT((
"restore_dsp_rettings done\n"));
770 static void set_audio_format(
struct echoaudio *chip,
u16 pipe_index,
797 #ifdef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
837 DE_ACT((
"set_audio_format[%d] = %x\n", pipe_index, dsp_format));
847 static int start_transport(
struct echoaudio *chip,
u32 channel_mask,
850 DE_ACT((
"start_transport %x\n", channel_mask));
852 if (wait_handshake(chip))
858 clear_handshake(chip);
860 if (wait_handshake(chip))
868 DE_ACT((
"start_transport: No pipes to start!\n"));
874 static int pause_transport(
struct echoaudio *chip,
u32 channel_mask)
876 DE_ACT((
"pause_transport %x\n", channel_mask));
878 if (wait_handshake(chip))
884 clear_handshake(chip);
886 if (wait_handshake(chip))
895 DE_ACT((
"pause_transport: No pipes to stop!\n"));
901 static int stop_transport(
struct echoaudio *chip,
u32 channel_mask)
903 DE_ACT((
"stop_transport %x\n", channel_mask));
905 if (wait_handshake(chip))
911 clear_handshake(chip);
913 if (wait_handshake(chip))
922 DE_ACT((
"stop_transport: No pipes to stop!\n"));
928 static inline int is_pipe_allocated(
struct echoaudio *chip,
u16 pipe_index)
937 static int rest_in_peace(
struct echoaudio *chip)
944 set_meters_on(chip,
FALSE);
946 #ifdef ECHOCARD_HAS_MIDI
947 enable_midi_input(chip,
FALSE);
963 static int init_dsp_comm_page(
struct echoaudio *chip)
967 DE_INIT((
"init_dsp_comm_page() - Invalid struct comm_page structure\n"));
999 static int init_line_levels(
struct echoaudio *chip)
1001 DE_INIT((
"init_line_levels\n"));
1009 return restore_dsp_rettings(chip);
1017 static int service_irq(
struct echoaudio *chip)
1024 #ifdef ECHOCARD_HAS_MIDI
1027 st = midi_service_irq(chip);
1053 DE_ACT((
"allocate_pipes: ch=%d int=%d\n", pipe_index, interleave));
1060 for (channel_mask = i = 0; i <
interleave; i++)
1061 channel_mask |= 1 << (pipe_index + i);
1063 DE_ACT((
"allocate_pipes: channel already open\n"));
1067 chip->
comm_page->position[pipe_index] = 0;
1071 pipe->
index = pipe_index;
1080 DE_ACT((
"allocate_pipes: ok\n"));
1097 for (channel_mask = i = 0; i < pipe->
interleave; i++)
1098 channel_mask |= 1 << (pipe->
index + i);
1133 DE_ACT((
"SGlist: too many fragments\n"));
1143 return sglist_add_mapping(chip, pipe, 0, 0);
1150 return sglist_add_mapping(chip, pipe, pipe->
sgpage.addr, 0);