Lines Matching +full:non +full:- +full:interleave
3 Copyright Echo Digital Audio Corporation (c) 1998 - 2004
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
40 command and then write a non-zero value to the Handshake field in the
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()
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
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
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()
152 dev_err(chip->card->dev, in read_sn()
154 return -EIO; in read_sn()
157 dev_dbg(chip->card->dev, in read_sn()
169 chip->asic_loaded = true; in check_asic_status()
179 /* Load ASIC code - done after the DSP is loaded */
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()
213 dev_err(chip->card->dev, "failed on write_dsp\n"); in load_asic_generic()
215 return -EIO; in load_asic_generic()
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()
244 dev_dbg(chip->card->dev, in install_resident_loader()
252 dev_warn(chip->card->dev, "Firmware not found !\n"); in install_resident_loader()
268 code = (u16 *)fw->data; in install_resident_loader()
287 dev_err(chip->card->dev, in install_resident_loader()
293 dev_err(chip->card->dev, in install_resident_loader()
303 dev_err(chip->card->dev, 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()
329 return -EIO; in install_resident_loader()
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()
359 dev_err(chip->card->dev, in load_dsp()
361 return -EIO; in load_dsp()
375 dev_err(chip->card->dev, in load_dsp()
377 return -EIO; in load_dsp()
413 dev_err(chip->card->dev, in load_dsp()
415 return -EIO; in load_dsp()
418 dev_err(chip->card->dev, in load_dsp()
420 return -EIO; in load_dsp()
423 dev_err(chip->card->dev, in load_dsp()
425 return -EIO; in load_dsp()
431 dev_err(chip->card->dev, in load_dsp()
433 return -EIO; in load_dsp()
439 dev_err(chip->card->dev, in load_dsp()
441 return -EIO; in load_dsp()
446 /* Wait for flag 4 - indicates that the DSP loaded OK */ in load_dsp()
453 dev_err(chip->card->dev, 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()
461 return -EIO; in load_dsp()
469 dev_err(chip->card->dev, 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()
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()
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()
530 /* Set the nominal level for an input or output bus (true = -10dBV, false = +4dBu) */
534 return -EINVAL; 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()
558 return -EINVAL; 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()
578 return -EINVAL; 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()
594 return -EIO; in update_output_line_level()
605 return -EIO; in update_input_line_level()
616 if (on && !chip->meters_enabled) { in set_meters_on()
618 chip->meters_enabled = 1; in set_meters_on()
619 } else if (!on && chip->meters_enabled) { 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()
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()
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()
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()
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()
684 err = set_output_gain(chip, i, chip->output_gain[i]); in restore_dsp_rettings()
693 chip->vmixer_gain[o][i]); in restore_dsp_rettings()
698 return -EIO; in restore_dsp_rettings()
705 chip->monitor_gain[o][i]); in restore_dsp_rettings()
713 err = set_input_gain(chip, i, chip->input_gain[i]); 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()
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()
764 return -EIO; 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
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()
857 first channel must be set, regardless its interleave.
858 Same thing for pause_ and stop_ -trasport below. */
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()
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()
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()
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()
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()
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()
939 return (chip->pipe_alloc_mask & (1 << pipe_index)); in is_pipe_allocated()
950 stop_transport(chip, chip->active_mask); in rest_in_peace()
959 if (chip->dsp_code) { in rest_in_peace()
961 chip->dsp_code = NULL; in rest_in_peace()
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()
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()
1023 It returns -1 if the IRQ is not ours, or N>=0 if it is, where N is the number
1034 if (chip->comm_page->midi_input[0]) /* The count is at index 0 */ in service_irq()
1038 chip->comm_page->midi_input[0] = 0; in service_irq()
1042 return -1; in service_irq()
1055 int pipe_index, int interleave) in allocate_pipes() argument
1060 dev_dbg(chip->card->dev, in allocate_pipes()
1061 "allocate_pipes: ch=%d int=%d\n", pipe_index, interleave); in allocate_pipes()
1063 if (chip->bad_board) in allocate_pipes()
1064 return -EIO; in allocate_pipes()
1066 for (channel_mask = i = 0; i < interleave; i++) 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()
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
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()
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()
1155 return sglist_add_mapping(chip, pipe, pipe->sgpage.addr, 0); in sglist_wrap()