Lines Matching +full:chip +full:- +full:to +full:- +full:chip

3    Copyright Echo Digital Audio Corporation (c) 1998 - 2004
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 MA 02111-1307, USA.
26 Translation from C++ and adaptation for use in ALSA-Driver
35 static int restore_dsp_rettings(struct echoaudio *chip);
38 /* Some vector commands involve the DSP reading or writing data to and from the
39 comm page; if you send one of these commands to the DSP, it will complete the
40 command and then write a non-zero value to the Handshake field in the
41 comm page. This function waits for the handshake to show up. */
42 static int wait_handshake(struct echoaudio *chip) in wait_handshake() argument
46 /* Wait up to 20ms for the handshake from the DSP */ in wait_handshake()
50 if (chip->comm_page->handshake) { in wait_handshake()
56 dev_err(chip->card->dev, "wait_handshake(): Timeout waiting for DSP\n"); in wait_handshake()
57 return -EBUSY; in wait_handshake()
63 commands; send_vector writes a vector command to the DSP. Typically, this
64 causes the DSP to read or write fields in the comm page.
65 PCI posting is not required thanks to the handshake logic. */
66 static int send_vector(struct echoaudio *chip, u32 command) in send_vector() argument
72 /* Wait up to 100ms for the "vector busy" bit to be off */ in send_vector()
74 if (!(get_dsp_register(chip, CHI32_VECTOR_REG) & in send_vector()
76 set_dsp_register(chip, CHI32_VECTOR_REG, command); in send_vector()
83 dev_err(chip->card->dev, "timeout on send_vector\n"); in send_vector()
84 return -EBUSY; in send_vector()
89 /* write_dsp writes a 32-bit value to the DSP; this is used almost
91 static int write_dsp(struct echoaudio *chip, u32 data) in write_dsp() argument
96 status = get_dsp_register(chip, CHI32_STATUS_REG); in write_dsp()
98 set_dsp_register(chip, CHI32_DATA_REG, data); in write_dsp()
106 chip->bad_board = true; /* Set true until DSP re-loaded */ in write_dsp()
107 dev_dbg(chip->card->dev, "write_dsp: Set bad_board to true\n"); in write_dsp()
108 return -EIO; in write_dsp()
113 /* read_dsp reads a 32-bit value from the DSP; this is used almost
115 static int read_dsp(struct echoaudio *chip, u32 *data) in read_dsp() argument
120 status = get_dsp_register(chip, CHI32_STATUS_REG); in read_dsp()
122 *data = get_dsp_register(chip, CHI32_DATA_REG); in read_dsp()
129 chip->bad_board = true; /* Set true until DSP re-loaded */ in read_dsp()
130 dev_err(chip->card->dev, "read_dsp: Set bad_board to true\n"); in read_dsp()
131 return -EIO; in read_dsp()
140 /* This function is used to read back the serial number from the DSP;
143 the serial number is not used, but you still need to do this as
145 static int read_sn(struct echoaudio *chip) in read_sn() argument
151 if (read_dsp(chip, &sn[i])) { in read_sn()
152 dev_err(chip->card->dev, in read_sn()
153 "Failed to read serial number\n"); in read_sn()
154 return -EIO; in read_sn()
157 dev_dbg(chip->card->dev, in read_sn()
167 static inline int check_asic_status(struct echoaudio *chip) in check_asic_status() argument
169 chip->asic_loaded = true; in check_asic_status()
179 /* Load ASIC code - done after the DSP is loaded */
180 static int load_asic_generic(struct echoaudio *chip, u32 cmd, short asic) in load_asic_generic() argument
187 err = get_firmware(&fw, chip, asic); in load_asic_generic()
189 dev_warn(chip->card->dev, "Firmware not found !\n"); in load_asic_generic()
193 code = (u8 *)fw->data; in load_asic_generic()
194 size = fw->size; in load_asic_generic()
197 if (write_dsp(chip, cmd) < 0) in load_asic_generic()
201 if (write_dsp(chip, size) < 0) in load_asic_generic()
205 if (write_dsp(chip, code[i]) < 0) in load_asic_generic()
209 free_firmware(fw, chip); in load_asic_generic()
213 dev_err(chip->card->dev, "failed on write_dsp\n"); in load_asic_generic()
214 free_firmware(fw, chip); in load_asic_generic()
215 return -EIO; in load_asic_generic()
226 program that is used to load the real DSP code. */
227 static int install_resident_loader(struct echoaudio *chip) in install_resident_loader() argument
235 /* 56361 cards only! This check is required by the old 56301-based in install_resident_loader()
237 if (chip->device_id != DEVICE_ID_56361) in install_resident_loader()
240 /* Look to see if the resident loader is present. If the resident in install_resident_loader()
242 status = get_dsp_register(chip, CHI32_STATUS_REG); in install_resident_loader()
244 dev_dbg(chip->card->dev, in install_resident_loader()
250 i = get_firmware(&fw, chip, FW_361_LOADER); in install_resident_loader()
252 dev_warn(chip->card->dev, "Firmware not found !\n"); in install_resident_loader()
265 set_dsp_register(chip, CHI32_CONTROL_REG, in install_resident_loader()
266 get_dsp_register(chip, CHI32_CONTROL_REG) | 0x900); in install_resident_loader()
268 code = (u16 *)fw->data; in install_resident_loader()
272 to by Code[0]. */ in install_resident_loader()
278 /* Get the number of DSP words to write */ in install_resident_loader()
285 /* Write the count to the DSP */ in install_resident_loader()
286 if (write_dsp(chip, words)) { in install_resident_loader()
287 dev_err(chip->card->dev, in install_resident_loader()
288 "install_resident_loader: Failed to write word count!\n"); in install_resident_loader()
292 if (write_dsp(chip, address)) { in install_resident_loader()
293 dev_err(chip->card->dev, in install_resident_loader()
294 "install_resident_loader: Failed to write DSP address!\n"); in install_resident_loader()
297 /* Write out this block of code to the DSP */ in install_resident_loader()
302 if (write_dsp(chip, data)) { in install_resident_loader()
303 dev_err(chip->card->dev, in install_resident_loader()
304 "install_resident_loader: Failed to write DSP code\n"); in install_resident_loader()
310 /* Wait for flag 5 to come up */ in install_resident_loader()
313 status = get_dsp_register(chip, CHI32_STATUS_REG); in install_resident_loader()
319 dev_err(chip->card->dev, "Resident loader failed to set HF5\n"); in install_resident_loader()
323 dev_dbg(chip->card->dev, "Resident loader successfully installed\n"); in install_resident_loader()
324 free_firmware(fw, chip); in install_resident_loader()
328 free_firmware(fw, chip); in install_resident_loader()
329 return -EIO; in install_resident_loader()
335 static int load_dsp(struct echoaudio *chip, u16 *code) in load_dsp() argument
340 if (chip->dsp_code == code) { in load_dsp()
341 dev_warn(chip->card->dev, "DSP is already loaded!\n"); in load_dsp()
344 chip->bad_board = true; /* Set true until DSP loaded */ in load_dsp()
345 chip->dsp_code = NULL; /* Current DSP code not loaded */ in load_dsp()
346 chip->asic_loaded = false; /* Loading the DSP code will reset the ASIC */ in load_dsp()
348 dev_dbg(chip->card->dev, "load_dsp: Set bad_board to true\n"); in load_dsp()
352 i = install_resident_loader(chip); in load_dsp()
358 if (send_vector(chip, DSP_VC_RESET) < 0) { in load_dsp()
359 dev_err(chip->card->dev, in load_dsp()
361 return -EIO; in load_dsp()
366 /* Wait 10ms for HF3 to indicate that software reset is complete */ in load_dsp()
368 if (get_dsp_register(chip, CHI32_STATUS_REG) & in load_dsp()
375 dev_err(chip->card->dev, in load_dsp()
377 return -EIO; in load_dsp()
381 set_dsp_register(chip, CHI32_CONTROL_REG, in load_dsp()
382 get_dsp_register(chip, CHI32_CONTROL_REG) | 0x900); in load_dsp()
412 if (write_dsp(chip, words) < 0) { in load_dsp()
413 dev_err(chip->card->dev, in load_dsp()
414 "load_dsp: failed to write number of DSP words\n"); in load_dsp()
415 return -EIO; in load_dsp()
417 if (write_dsp(chip, address) < 0) { in load_dsp()
418 dev_err(chip->card->dev, in load_dsp()
419 "load_dsp: failed to write DSP address\n"); in load_dsp()
420 return -EIO; in load_dsp()
422 if (write_dsp(chip, mem_type) < 0) { in load_dsp()
423 dev_err(chip->card->dev, in load_dsp()
424 "load_dsp: failed to write DSP memory type\n"); in load_dsp()
425 return -EIO; in load_dsp()
430 if (write_dsp(chip, data) < 0) { in load_dsp()
431 dev_err(chip->card->dev, in load_dsp()
432 "load_dsp: failed to write DSP data\n"); in load_dsp()
433 return -EIO; in load_dsp()
438 if (write_dsp(chip, 0) < 0) { /* We're done!!! */ in load_dsp()
439 dev_err(chip->card->dev, in load_dsp()
440 "load_dsp: Failed to write final zero\n"); in load_dsp()
441 return -EIO; in load_dsp()
446 /* Wait for flag 4 - indicates that the DSP loaded OK */ in load_dsp()
447 if (get_dsp_register(chip, CHI32_STATUS_REG) & in load_dsp()
449 set_dsp_register(chip, CHI32_CONTROL_REG, in load_dsp()
450 get_dsp_register(chip, CHI32_CONTROL_REG) & ~0x1b00); in load_dsp()
452 if (write_dsp(chip, DSP_FNC_SET_COMMPAGE_ADDR) < 0) { in load_dsp()
453 dev_err(chip->card->dev, in load_dsp()
454 "load_dsp: Failed to write DSP_FNC_SET_COMMPAGE_ADDR\n"); in load_dsp()
455 return -EIO; in load_dsp()
458 if (write_dsp(chip, chip->comm_page_phys) < 0) { in load_dsp()
459 dev_err(chip->card->dev, in load_dsp()
460 "load_dsp: Failed to write comm page address\n"); in load_dsp()
461 return -EIO; in load_dsp()
466 We don't actually use the serial number but we have to in load_dsp()
468 if (read_sn(chip) < 0) { in load_dsp()
469 dev_err(chip->card->dev, in load_dsp()
470 "load_dsp: Failed to read serial number\n"); in load_dsp()
471 return -EIO; in load_dsp()
474 chip->dsp_code = code; /* Show which DSP code loaded */ in load_dsp()
475 chip->bad_board = false; /* DSP OK */ in load_dsp()
481 dev_err(chip->card->dev, in load_dsp()
483 return -EIO; in load_dsp()
489 static int load_firmware(struct echoaudio *chip) in load_firmware() argument
494 if (snd_BUG_ON(!chip->comm_page)) in load_firmware()
495 return -EPERM; in load_firmware()
497 /* See if the ASIC is present and working - only if the DSP is already loaded */ in load_firmware()
498 if (chip->dsp_code) { in load_firmware()
499 box_type = check_asic_status(chip); in load_firmware()
502 /* ASIC check failed; force the DSP to reload */ in load_firmware()
503 chip->dsp_code = NULL; in load_firmware()
506 err = get_firmware(&fw, chip, chip->dsp_code_to_load); in load_firmware()
509 err = load_dsp(chip, (u16 *)fw->data); in load_firmware()
510 free_firmware(fw, chip); in load_firmware()
514 box_type = load_asic(chip); in load_firmware()
530 /* Set the nominal level for an input or output bus (true = -10dBV, false = +4dBu) */
531 static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer) in set_nominal_level() argument
533 if (snd_BUG_ON(index >= num_busses_out(chip) + num_busses_in(chip))) in set_nominal_level()
534 return -EINVAL; in set_nominal_level()
537 if (wait_handshake(chip)) in set_nominal_level()
538 return -EIO; in set_nominal_level()
540 chip->nominal_level[index] = consumer; in set_nominal_level()
543 chip->comm_page->nominal_level_mask |= cpu_to_le32(1 << index); in set_nominal_level()
545 chip->comm_page->nominal_level_mask &= ~cpu_to_le32(1 << index); in set_nominal_level()
555 static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain) in set_output_gain() argument
557 if (snd_BUG_ON(channel >= num_busses_out(chip))) in set_output_gain()
558 return -EINVAL; in set_output_gain()
560 if (wait_handshake(chip)) in set_output_gain()
561 return -EIO; in set_output_gain()
564 chip->output_gain[channel] = gain; in set_output_gain()
565 chip->comm_page->line_out_level[channel] = gain; in set_output_gain()
572 /* Set the monitor level from an input bus to an output bus. */
573 static int set_monitor_gain(struct echoaudio *chip, u16 output, u16 input, in set_monitor_gain() argument
576 if (snd_BUG_ON(output >= num_busses_out(chip) || in set_monitor_gain()
577 input >= num_busses_in(chip))) in set_monitor_gain()
578 return -EINVAL; in set_monitor_gain()
580 if (wait_handshake(chip)) in set_monitor_gain()
581 return -EIO; in set_monitor_gain()
583 chip->monitor_gain[output][input] = gain; in set_monitor_gain()
584 chip->comm_page->monitors[monitor_index(chip, output, input)] = gain; in set_monitor_gain()
590 /* Tell the DSP to read and update output, nominal & monitor levels in comm page. */
591 static int update_output_line_level(struct echoaudio *chip) in update_output_line_level() argument
593 if (wait_handshake(chip)) in update_output_line_level()
594 return -EIO; in update_output_line_level()
595 clear_handshake(chip); in update_output_line_level()
596 return send_vector(chip, DSP_VC_UPDATE_OUTVOL); in update_output_line_level()
601 /* Tell the DSP to read and update input levels in comm page */
602 static int update_input_line_level(struct echoaudio *chip) in update_input_line_level() argument
604 if (wait_handshake(chip)) in update_input_line_level()
605 return -EIO; in update_input_line_level()
606 clear_handshake(chip); in update_input_line_level()
607 return send_vector(chip, DSP_VC_UPDATE_INGAIN); in update_input_line_level()
613 will write the meter and clock detect values to the comm page at about 30Hz */
614 static void set_meters_on(struct echoaudio *chip, char on) in set_meters_on() argument
616 if (on && !chip->meters_enabled) { in set_meters_on()
617 send_vector(chip, DSP_VC_METERS_ON); in set_meters_on()
618 chip->meters_enabled = 1; in set_meters_on()
619 } else if (!on && chip->meters_enabled) { in set_meters_on()
620 send_vector(chip, DSP_VC_METERS_OFF); in set_meters_on()
621 chip->meters_enabled = 0; in set_meters_on()
622 memset((s8 *)chip->comm_page->vu_meter, ECHOGAIN_MUTED, in set_meters_on()
624 memset((s8 *)chip->comm_page->peak_meter, ECHOGAIN_MUTED, in set_meters_on()
639 static void get_audio_meters(struct echoaudio *chip, long *meters) in get_audio_meters() argument
646 for (m = 0, n = 0, i = 0; i < num_busses_out(chip); i++, m++) { in get_audio_meters()
647 meters[n++] = chip->comm_page->vu_meter[m]; in get_audio_meters()
648 meters[n++] = chip->comm_page->peak_meter[m]; in get_audio_meters()
655 for (n = 32, i = 0; i < num_busses_in(chip); i++, m++) { in get_audio_meters()
656 meters[n++] = chip->comm_page->vu_meter[m]; in get_audio_meters()
657 meters[n++] = chip->comm_page->peak_meter[m]; in get_audio_meters()
660 for (n = 64, i = 0; i < num_pipes_out(chip); i++, m++) { in get_audio_meters()
661 meters[n++] = chip->comm_page->vu_meter[m]; in get_audio_meters()
662 meters[n++] = chip->comm_page->peak_meter[m]; in get_audio_meters()
669 static int restore_dsp_rettings(struct echoaudio *chip) in restore_dsp_rettings() argument
673 err = check_asic_status(chip); in restore_dsp_rettings()
678 chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; in restore_dsp_rettings()
679 chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; in restore_dsp_rettings()
680 chip->comm_page->handshake = cpu_to_le32(0xffffffff); in restore_dsp_rettings()
683 for (i = 0; i < num_busses_out(chip); i++) { in restore_dsp_rettings()
684 err = set_output_gain(chip, i, chip->output_gain[i]); in restore_dsp_rettings()
690 for (i = 0; i < num_pipes_out(chip); i++) in restore_dsp_rettings()
691 for (o = 0; o < num_busses_out(chip); o++) { in restore_dsp_rettings()
692 err = set_vmixer_gain(chip, o, i, in restore_dsp_rettings()
693 chip->vmixer_gain[o][i]); in restore_dsp_rettings()
697 if (update_vmixer_level(chip) < 0) in restore_dsp_rettings()
698 return -EIO; in restore_dsp_rettings()
702 for (o = 0; o < num_busses_out(chip); o++) in restore_dsp_rettings()
703 for (i = 0; i < num_busses_in(chip); i++) { in restore_dsp_rettings()
704 err = set_monitor_gain(chip, o, i, in restore_dsp_rettings()
705 chip->monitor_gain[o][i]); in restore_dsp_rettings()
712 for (i = 0; i < num_busses_in(chip); i++) { in restore_dsp_rettings()
713 err = set_input_gain(chip, i, chip->input_gain[i]); in restore_dsp_rettings()
719 err = update_output_line_level(chip); in restore_dsp_rettings()
723 err = update_input_line_level(chip); in restore_dsp_rettings()
727 err = set_sample_rate(chip, chip->sample_rate); in restore_dsp_rettings()
731 if (chip->meters_enabled) { in restore_dsp_rettings()
732 err = send_vector(chip, DSP_VC_METERS_ON); in restore_dsp_rettings()
738 if (set_digital_mode(chip, chip->digital_mode) < 0) in restore_dsp_rettings()
739 return -EIO; in restore_dsp_rettings()
743 if (set_professional_spdif(chip, chip->professional_spdif) < 0) in restore_dsp_rettings()
744 return -EIO; in restore_dsp_rettings()
748 if (set_phantom_power(chip, chip->phantom_power) < 0) in restore_dsp_rettings()
749 return -EIO; in restore_dsp_rettings()
754 if (set_input_clock(chip, chip->input_clock) < 0) in restore_dsp_rettings()
755 return -EIO; in restore_dsp_rettings()
759 if (set_output_clock(chip, chip->output_clock) < 0) in restore_dsp_rettings()
760 return -EIO; in restore_dsp_rettings()
763 if (wait_handshake(chip) < 0) in restore_dsp_rettings()
764 return -EIO; in restore_dsp_rettings()
765 clear_handshake(chip); in restore_dsp_rettings()
766 if (send_vector(chip, DSP_VC_UPDATE_FLAGS) < 0) in restore_dsp_rettings()
767 return -EIO; in restore_dsp_rettings()
779 this pipe. Note that _MS_ (mono-to-stereo) playback modes are not used by ALSA
781 static void set_audio_format(struct echoaudio *chip, u16 pipe_index, in set_audio_format() argument
788 /* Look for super-interleave (no big-endian and 8 bits) */ in set_audio_format()
789 if (format->interleave > 2) { in set_audio_format()
790 switch (format->bits_per_sample) { in set_audio_format()
801 dsp_format |= format->interleave; in set_audio_format()
802 } else if (format->data_are_bigendian) { in set_audio_format()
803 /* For big-endian data, only 32 bit samples are supported */ in set_audio_format()
804 switch (format->interleave) { in set_audio_format()
814 } else if (format->interleave == 1 && in set_audio_format()
815 format->bits_per_sample == 32 && !format->mono_to_stereo) { in set_audio_format()
816 /* 32 bit little-endian mono->mono case */ in set_audio_format()
819 /* Handle the other little-endian formats */ in set_audio_format()
820 switch (format->bits_per_sample) { in set_audio_format()
822 if (format->interleave == 2) in set_audio_format()
829 if (format->interleave == 2) in set_audio_format()
835 if (format->interleave == 2) in set_audio_format()
841 if (format->interleave == 2) in set_audio_format()
848 dev_dbg(chip->card->dev, in set_audio_format()
850 chip->comm_page->audio_format[pipe_index] = cpu_to_le16(dsp_format); in set_audio_format()
856 The bits 1 in channel_mask specify what pipes to start. Only the bit of the
858 Same thing for pause_ and stop_ -trasport below. */
859 static int start_transport(struct echoaudio *chip, u32 channel_mask, in start_transport() argument
863 if (wait_handshake(chip)) in start_transport()
864 return -EIO; in start_transport()
866 chip->comm_page->cmd_start |= cpu_to_le32(channel_mask); in start_transport()
868 if (chip->comm_page->cmd_start) { in start_transport()
869 clear_handshake(chip); in start_transport()
870 send_vector(chip, DSP_VC_START_TRANSFER); in start_transport()
871 if (wait_handshake(chip)) in start_transport()
872 return -EIO; in start_transport()
874 chip->active_mask |= channel_mask; in start_transport()
875 chip->comm_page->cmd_start = 0; in start_transport()
879 dev_err(chip->card->dev, "start_transport: No pipes to start!\n"); in start_transport()
880 return -EINVAL; in start_transport()
885 static int pause_transport(struct echoaudio *chip, u32 channel_mask) in pause_transport() argument
888 if (wait_handshake(chip)) in pause_transport()
889 return -EIO; in pause_transport()
891 chip->comm_page->cmd_stop |= cpu_to_le32(channel_mask); in pause_transport()
892 chip->comm_page->cmd_reset = 0; in pause_transport()
893 if (chip->comm_page->cmd_stop) { in pause_transport()
894 clear_handshake(chip); in pause_transport()
895 send_vector(chip, DSP_VC_STOP_TRANSFER); in pause_transport()
896 if (wait_handshake(chip)) in pause_transport()
897 return -EIO; in pause_transport()
899 chip->active_mask &= ~channel_mask; in pause_transport()
900 chip->comm_page->cmd_stop = 0; in pause_transport()
901 chip->comm_page->cmd_reset = 0; in pause_transport()
905 dev_dbg(chip->card->dev, "pause_transport: No pipes to stop!\n"); in pause_transport()
911 static int stop_transport(struct echoaudio *chip, u32 channel_mask) in stop_transport() argument
914 if (wait_handshake(chip)) in stop_transport()
915 return -EIO; in stop_transport()
917 chip->comm_page->cmd_stop |= cpu_to_le32(channel_mask); in stop_transport()
918 chip->comm_page->cmd_reset |= cpu_to_le32(channel_mask); in stop_transport()
919 if (chip->comm_page->cmd_reset) { in stop_transport()
920 clear_handshake(chip); in stop_transport()
921 send_vector(chip, DSP_VC_STOP_TRANSFER); in stop_transport()
922 if (wait_handshake(chip)) in stop_transport()
923 return -EIO; in stop_transport()
925 chip->active_mask &= ~channel_mask; in stop_transport()
926 chip->comm_page->cmd_stop = 0; in stop_transport()
927 chip->comm_page->cmd_reset = 0; in stop_transport()
931 dev_dbg(chip->card->dev, "stop_transport: No pipes to stop!\n"); in stop_transport()
937 static inline int is_pipe_allocated(struct echoaudio *chip, u16 pipe_index) in is_pipe_allocated() argument
939 return (chip->pipe_alloc_mask & (1 << pipe_index)); in is_pipe_allocated()
946 static int rest_in_peace(struct echoaudio *chip) in rest_in_peace() argument
949 /* Stops all active pipes (just to be sure) */ in rest_in_peace()
950 stop_transport(chip, chip->active_mask); in rest_in_peace()
952 set_meters_on(chip, false); in rest_in_peace()
955 enable_midi_input(chip, false); in rest_in_peace()
958 /* Go to sleep */ in rest_in_peace()
959 if (chip->dsp_code) { in rest_in_peace()
961 chip->dsp_code = NULL; in rest_in_peace()
962 /* Put the DSP to sleep */ in rest_in_peace()
963 return send_vector(chip, DSP_VC_GO_COMATOSE); in rest_in_peace()
971 static int init_dsp_comm_page(struct echoaudio *chip) in init_dsp_comm_page() argument
975 dev_err(chip->card->dev, in init_dsp_comm_page()
976 "init_dsp_comm_page() - Invalid struct comm_page structure\n"); in init_dsp_comm_page()
977 return -EPERM; in init_dsp_comm_page()
981 chip->card_name = ECHOCARD_NAME; in init_dsp_comm_page()
982 chip->bad_board = true; /* Set true until DSP loaded */ in init_dsp_comm_page()
983 chip->dsp_code = NULL; /* Current DSP code not loaded */ in init_dsp_comm_page()
984 chip->asic_loaded = false; in init_dsp_comm_page()
985 memset(chip->comm_page, 0, sizeof(struct comm_page)); in init_dsp_comm_page()
988 chip->comm_page->comm_size = in init_dsp_comm_page()
990 chip->comm_page->handshake = cpu_to_le32(0xffffffff); in init_dsp_comm_page()
991 chip->comm_page->midi_out_free_count = in init_dsp_comm_page()
993 chip->comm_page->sample_rate = cpu_to_le32(44100); in init_dsp_comm_page()
996 memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); in init_dsp_comm_page()
997 memset(chip->comm_page->vmixer, ECHOGAIN_MUTED, VMIXER_ARRAY_SIZE); in init_dsp_comm_page()
1004 /* This function initializes the chip structure with default values, ie. all
1005 * muted and internal clock source. Then it copies the settings to the DSP.
1008 static int init_line_levels(struct echoaudio *chip) in init_line_levels() argument
1010 memset(chip->output_gain, ECHOGAIN_MUTED, sizeof(chip->output_gain)); in init_line_levels()
1011 memset(chip->input_gain, ECHOGAIN_MUTED, sizeof(chip->input_gain)); in init_line_levels()
1012 memset(chip->monitor_gain, ECHOGAIN_MUTED, sizeof(chip->monitor_gain)); in init_line_levels()
1013 memset(chip->vmixer_gain, ECHOGAIN_MUTED, sizeof(chip->vmixer_gain)); in init_line_levels()
1014 chip->input_clock = ECHO_CLOCK_INTERNAL; in init_line_levels()
1015 chip->output_clock = ECHO_CLOCK_WORD; in init_line_levels()
1016 chip->sample_rate = 44100; in init_line_levels()
1017 return restore_dsp_rettings(chip); in init_line_levels()
1023 It returns -1 if the IRQ is not ours, or N>=0 if it is, where N is the number
1025 static int service_irq(struct echoaudio *chip) in service_irq() argument
1030 if (get_dsp_register(chip, CHI32_STATUS_REG) & CHI32_STATUS_IRQ) { in service_irq()
1034 if (chip->comm_page->midi_input[0]) /* The count is at index 0 */ in service_irq()
1035 st = midi_service_irq(chip); /* Returns how many midi bytes we received */ in service_irq()
1038 chip->comm_page->midi_input[0] = 0; in service_irq()
1039 send_vector(chip, DSP_VC_ACK_INT); in service_irq()
1042 return -1; in service_irq()
1052 /* allocate_pipes is used to reserve audio pipes for your exclusive use.
1054 static int allocate_pipes(struct echoaudio *chip, struct audiopipe *pipe, in allocate_pipes() argument
1060 dev_dbg(chip->card->dev, in allocate_pipes()
1063 if (chip->bad_board) in allocate_pipes()
1064 return -EIO; in allocate_pipes()
1068 if (chip->pipe_alloc_mask & channel_mask) { in allocate_pipes()
1069 dev_err(chip->card->dev, in allocate_pipes()
1071 return -EAGAIN; in allocate_pipes()
1074 chip->comm_page->position[pipe_index] = 0; in allocate_pipes()
1075 chip->pipe_alloc_mask |= channel_mask; in allocate_pipes()
1077 chip->pipe_cyclic_mask |= channel_mask; in allocate_pipes()
1078 pipe->index = pipe_index; in allocate_pipes()
1079 pipe->interleave = interleave; in allocate_pipes()
1080 pipe->state = PIPE_STATE_STOPPED; in allocate_pipes()
1085 pipe->dma_counter = (__le32 *)&chip->comm_page->position[pipe_index]; in allocate_pipes()
1086 *pipe->dma_counter = 0; in allocate_pipes()
1092 static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe) in free_pipes() argument
1097 if (snd_BUG_ON(!is_pipe_allocated(chip, pipe->index))) in free_pipes()
1098 return -EINVAL; in free_pipes()
1099 if (snd_BUG_ON(pipe->state != PIPE_STATE_STOPPED)) in free_pipes()
1100 return -EINVAL; in free_pipes()
1102 for (channel_mask = i = 0; i < pipe->interleave; i++) in free_pipes()
1103 channel_mask |= 1 << (pipe->index + i); in free_pipes()
1105 chip->pipe_alloc_mask &= ~channel_mask; in free_pipes()
1106 chip->pipe_cyclic_mask &= ~channel_mask; in free_pipes()
1113 Functions for managing the scatter-gather list
1116 static int sglist_init(struct echoaudio *chip, struct audiopipe *pipe) in sglist_init() argument
1118 pipe->sglist_head = 0; in sglist_init()
1119 memset(pipe->sgpage.area, 0, PAGE_SIZE); in sglist_init()
1120 chip->comm_page->sglist_addr[pipe->index].addr = in sglist_init()
1121 cpu_to_le32(pipe->sgpage.addr); in sglist_init()
1127 static int sglist_add_mapping(struct echoaudio *chip, struct audiopipe *pipe, in sglist_add_mapping() argument
1130 int head = pipe->sglist_head; in sglist_add_mapping()
1131 struct sg_entry *list = (struct sg_entry *)pipe->sgpage.area; in sglist_add_mapping()
1133 if (head < MAX_SGLIST_ENTRIES - 1) { in sglist_add_mapping()
1136 pipe->sglist_head++; in sglist_add_mapping()
1138 dev_err(chip->card->dev, "SGlist: too many fragments\n"); in sglist_add_mapping()
1139 return -ENOMEM; in sglist_add_mapping()
1146 static inline int sglist_add_irq(struct echoaudio *chip, struct audiopipe *pipe) in sglist_add_irq() argument
1148 return sglist_add_mapping(chip, pipe, 0, 0); in sglist_add_irq()
1153 static inline int sglist_wrap(struct echoaudio *chip, struct audiopipe *pipe) in sglist_wrap() argument
1155 return sglist_add_mapping(chip, pipe, pipe->sgpage.addr, 0); in sglist_wrap()