• Home
  • Raw
  • Download

Lines Matching refs:chip

35 static int restore_dsp_rettings(struct echoaudio *chip);
42 static int wait_handshake(struct echoaudio *chip) in wait_handshake() argument
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()
66 static int send_vector(struct echoaudio *chip, u32 command) in send_vector() argument
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()
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()
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()
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()
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()
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()
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()
227 static int install_resident_loader(struct echoaudio *chip) in install_resident_loader() argument
237 if (chip->device_id != DEVICE_ID_56361) 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()
286 if (write_dsp(chip, words)) { in install_resident_loader()
287 dev_err(chip->card->dev, in install_resident_loader()
292 if (write_dsp(chip, address)) { in install_resident_loader()
293 dev_err(chip->card->dev, in install_resident_loader()
302 if (write_dsp(chip, data)) { in install_resident_loader()
303 dev_err(chip->card->dev, 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()
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 if ((i = install_resident_loader(chip)) < 0) in load_dsp()
357 if (send_vector(chip, DSP_VC_RESET) < 0) { in load_dsp()
358 dev_err(chip->card->dev, in load_dsp()
367 if (get_dsp_register(chip, CHI32_STATUS_REG) & in load_dsp()
374 dev_err(chip->card->dev, in load_dsp()
380 set_dsp_register(chip, CHI32_CONTROL_REG, in load_dsp()
381 get_dsp_register(chip, CHI32_CONTROL_REG) | 0x900); in load_dsp()
411 if (write_dsp(chip, words) < 0) { in load_dsp()
412 dev_err(chip->card->dev, in load_dsp()
416 if (write_dsp(chip, address) < 0) { in load_dsp()
417 dev_err(chip->card->dev, in load_dsp()
421 if (write_dsp(chip, mem_type) < 0) { in load_dsp()
422 dev_err(chip->card->dev, in load_dsp()
429 if (write_dsp(chip, data) < 0) { in load_dsp()
430 dev_err(chip->card->dev, in load_dsp()
437 if (write_dsp(chip, 0) < 0) { /* We're done!!! */ in load_dsp()
438 dev_err(chip->card->dev, in load_dsp()
446 if (get_dsp_register(chip, CHI32_STATUS_REG) & in load_dsp()
448 set_dsp_register(chip, CHI32_CONTROL_REG, in load_dsp()
449 get_dsp_register(chip, CHI32_CONTROL_REG) & ~0x1b00); in load_dsp()
451 if (write_dsp(chip, DSP_FNC_SET_COMMPAGE_ADDR) < 0) { in load_dsp()
452 dev_err(chip->card->dev, in load_dsp()
457 if (write_dsp(chip, chip->comm_page_phys) < 0) { in load_dsp()
458 dev_err(chip->card->dev, in load_dsp()
467 if (read_sn(chip) < 0) { in load_dsp()
468 dev_err(chip->card->dev, in load_dsp()
473 chip->dsp_code = code; /* Show which DSP code loaded */ in load_dsp()
474 chip->bad_board = false; /* DSP OK */ in load_dsp()
480 dev_err(chip->card->dev, in load_dsp()
488 static int load_firmware(struct echoaudio *chip) in load_firmware() argument
493 if (snd_BUG_ON(!chip->comm_page)) in load_firmware()
497 if (chip->dsp_code) { in load_firmware()
498 if ((box_type = check_asic_status(chip)) >= 0) in load_firmware()
501 chip->dsp_code = NULL; in load_firmware()
504 err = get_firmware(&fw, chip, chip->dsp_code_to_load); in load_firmware()
507 err = load_dsp(chip, (u16 *)fw->data); in load_firmware()
508 free_firmware(fw, chip); in load_firmware()
512 if ((box_type = load_asic(chip)) < 0) in load_firmware()
528 static int set_nominal_level(struct echoaudio *chip, u16 index, char consumer) in set_nominal_level() argument
530 if (snd_BUG_ON(index >= num_busses_out(chip) + num_busses_in(chip))) in set_nominal_level()
534 if (wait_handshake(chip)) in set_nominal_level()
537 chip->nominal_level[index] = consumer; in set_nominal_level()
540 chip->comm_page->nominal_level_mask |= cpu_to_le32(1 << index); in set_nominal_level()
542 chip->comm_page->nominal_level_mask &= ~cpu_to_le32(1 << index); in set_nominal_level()
552 static int set_output_gain(struct echoaudio *chip, u16 channel, s8 gain) in set_output_gain() argument
554 if (snd_BUG_ON(channel >= num_busses_out(chip))) in set_output_gain()
557 if (wait_handshake(chip)) in set_output_gain()
561 chip->output_gain[channel] = gain; in set_output_gain()
562 chip->comm_page->line_out_level[channel] = gain; in set_output_gain()
570 static int set_monitor_gain(struct echoaudio *chip, u16 output, u16 input, in set_monitor_gain() argument
573 if (snd_BUG_ON(output >= num_busses_out(chip) || in set_monitor_gain()
574 input >= num_busses_in(chip))) in set_monitor_gain()
577 if (wait_handshake(chip)) in set_monitor_gain()
580 chip->monitor_gain[output][input] = gain; in set_monitor_gain()
581 chip->comm_page->monitors[monitor_index(chip, output, input)] = gain; in set_monitor_gain()
588 static int update_output_line_level(struct echoaudio *chip) in update_output_line_level() argument
590 if (wait_handshake(chip)) in update_output_line_level()
592 clear_handshake(chip); in update_output_line_level()
593 return send_vector(chip, DSP_VC_UPDATE_OUTVOL); in update_output_line_level()
599 static int update_input_line_level(struct echoaudio *chip) in update_input_line_level() argument
601 if (wait_handshake(chip)) in update_input_line_level()
603 clear_handshake(chip); in update_input_line_level()
604 return send_vector(chip, DSP_VC_UPDATE_INGAIN); in update_input_line_level()
611 static void set_meters_on(struct echoaudio *chip, char on) in set_meters_on() argument
613 if (on && !chip->meters_enabled) { in set_meters_on()
614 send_vector(chip, DSP_VC_METERS_ON); in set_meters_on()
615 chip->meters_enabled = 1; in set_meters_on()
616 } else if (!on && chip->meters_enabled) { in set_meters_on()
617 send_vector(chip, DSP_VC_METERS_OFF); in set_meters_on()
618 chip->meters_enabled = 0; in set_meters_on()
619 memset((s8 *)chip->comm_page->vu_meter, ECHOGAIN_MUTED, in set_meters_on()
621 memset((s8 *)chip->comm_page->peak_meter, ECHOGAIN_MUTED, in set_meters_on()
636 static void get_audio_meters(struct echoaudio *chip, long *meters) in get_audio_meters() argument
642 for (i = 0; i < num_busses_out(chip); i++, m++) { in get_audio_meters()
643 meters[n++] = chip->comm_page->vu_meter[m]; in get_audio_meters()
644 meters[n++] = chip->comm_page->peak_meter[m]; in get_audio_meters()
653 for (i = 0; i < num_busses_in(chip); i++, m++) { in get_audio_meters()
654 meters[n++] = chip->comm_page->vu_meter[m]; in get_audio_meters()
655 meters[n++] = chip->comm_page->peak_meter[m]; in get_audio_meters()
661 for (i = 0; i < num_pipes_out(chip); i++, m++) { in get_audio_meters()
662 meters[n++] = chip->comm_page->vu_meter[m]; in get_audio_meters()
663 meters[n++] = chip->comm_page->peak_meter[m]; in get_audio_meters()
672 static int restore_dsp_rettings(struct echoaudio *chip) in restore_dsp_rettings() argument
676 if ((err = check_asic_status(chip)) < 0) in restore_dsp_rettings()
680 chip->comm_page->gd_clock_state = GD_CLOCK_UNDEF; in restore_dsp_rettings()
681 chip->comm_page->gd_spdif_status = GD_SPDIF_STATUS_UNDEF; in restore_dsp_rettings()
682 chip->comm_page->handshake = 0xffffffff; in restore_dsp_rettings()
685 for (i = 0; i < num_busses_out(chip); i++) { in restore_dsp_rettings()
686 err = set_output_gain(chip, i, chip->output_gain[i]); in restore_dsp_rettings()
692 for (i = 0; i < num_pipes_out(chip); i++) in restore_dsp_rettings()
693 for (o = 0; o < num_busses_out(chip); o++) { in restore_dsp_rettings()
694 err = set_vmixer_gain(chip, o, i, in restore_dsp_rettings()
695 chip->vmixer_gain[o][i]); in restore_dsp_rettings()
699 if (update_vmixer_level(chip) < 0) in restore_dsp_rettings()
704 for (o = 0; o < num_busses_out(chip); o++) in restore_dsp_rettings()
705 for (i = 0; i < num_busses_in(chip); i++) { in restore_dsp_rettings()
706 err = set_monitor_gain(chip, o, i, in restore_dsp_rettings()
707 chip->monitor_gain[o][i]); in restore_dsp_rettings()
714 for (i = 0; i < num_busses_in(chip); i++) { in restore_dsp_rettings()
715 err = set_input_gain(chip, i, chip->input_gain[i]); in restore_dsp_rettings()
721 err = update_output_line_level(chip); in restore_dsp_rettings()
725 err = update_input_line_level(chip); in restore_dsp_rettings()
729 err = set_sample_rate(chip, chip->sample_rate); in restore_dsp_rettings()
733 if (chip->meters_enabled) { in restore_dsp_rettings()
734 err = send_vector(chip, DSP_VC_METERS_ON); in restore_dsp_rettings()
740 if (set_digital_mode(chip, chip->digital_mode) < 0) in restore_dsp_rettings()
745 if (set_professional_spdif(chip, chip->professional_spdif) < 0) in restore_dsp_rettings()
750 if (set_phantom_power(chip, chip->phantom_power) < 0) in restore_dsp_rettings()
756 if (set_input_clock(chip, chip->input_clock) < 0) in restore_dsp_rettings()
761 if (set_output_clock(chip, chip->output_clock) < 0) in restore_dsp_rettings()
765 if (wait_handshake(chip) < 0) in restore_dsp_rettings()
767 clear_handshake(chip); in restore_dsp_rettings()
768 if (send_vector(chip, DSP_VC_UPDATE_FLAGS) < 0) in restore_dsp_rettings()
783 static void set_audio_format(struct echoaudio *chip, u16 pipe_index, in set_audio_format() argument
850 dev_dbg(chip->card->dev, in set_audio_format()
852 chip->comm_page->audio_format[pipe_index] = cpu_to_le16(dsp_format); in set_audio_format()
861 static int start_transport(struct echoaudio *chip, u32 channel_mask, in start_transport() argument
865 if (wait_handshake(chip)) in start_transport()
868 chip->comm_page->cmd_start |= cpu_to_le32(channel_mask); in start_transport()
870 if (chip->comm_page->cmd_start) { in start_transport()
871 clear_handshake(chip); in start_transport()
872 send_vector(chip, DSP_VC_START_TRANSFER); in start_transport()
873 if (wait_handshake(chip)) in start_transport()
876 chip->active_mask |= channel_mask; in start_transport()
877 chip->comm_page->cmd_start = 0; in start_transport()
881 dev_err(chip->card->dev, "start_transport: No pipes to start!\n"); in start_transport()
887 static int pause_transport(struct echoaudio *chip, u32 channel_mask) in pause_transport() argument
890 if (wait_handshake(chip)) in pause_transport()
893 chip->comm_page->cmd_stop |= cpu_to_le32(channel_mask); in pause_transport()
894 chip->comm_page->cmd_reset = 0; in pause_transport()
895 if (chip->comm_page->cmd_stop) { in pause_transport()
896 clear_handshake(chip); in pause_transport()
897 send_vector(chip, DSP_VC_STOP_TRANSFER); in pause_transport()
898 if (wait_handshake(chip)) in pause_transport()
901 chip->active_mask &= ~channel_mask; in pause_transport()
902 chip->comm_page->cmd_stop = 0; in pause_transport()
903 chip->comm_page->cmd_reset = 0; in pause_transport()
907 dev_warn(chip->card->dev, "pause_transport: No pipes to stop!\n"); in pause_transport()
913 static int stop_transport(struct echoaudio *chip, u32 channel_mask) in stop_transport() argument
916 if (wait_handshake(chip)) in stop_transport()
919 chip->comm_page->cmd_stop |= cpu_to_le32(channel_mask); in stop_transport()
920 chip->comm_page->cmd_reset |= cpu_to_le32(channel_mask); in stop_transport()
921 if (chip->comm_page->cmd_reset) { in stop_transport()
922 clear_handshake(chip); in stop_transport()
923 send_vector(chip, DSP_VC_STOP_TRANSFER); in stop_transport()
924 if (wait_handshake(chip)) in stop_transport()
927 chip->active_mask &= ~channel_mask; in stop_transport()
928 chip->comm_page->cmd_stop = 0; in stop_transport()
929 chip->comm_page->cmd_reset = 0; in stop_transport()
933 dev_warn(chip->card->dev, "stop_transport: No pipes to stop!\n"); in stop_transport()
939 static inline int is_pipe_allocated(struct echoaudio *chip, u16 pipe_index) in is_pipe_allocated() argument
941 return (chip->pipe_alloc_mask & (1 << pipe_index)); in is_pipe_allocated()
948 static int rest_in_peace(struct echoaudio *chip) in rest_in_peace() argument
952 stop_transport(chip, chip->active_mask); in rest_in_peace()
954 set_meters_on(chip, false); in rest_in_peace()
957 enable_midi_input(chip, false); in rest_in_peace()
961 if (chip->dsp_code) { in rest_in_peace()
963 chip->dsp_code = NULL; in rest_in_peace()
965 return send_vector(chip, DSP_VC_GO_COMATOSE); in rest_in_peace()
973 static int init_dsp_comm_page(struct echoaudio *chip) in init_dsp_comm_page() argument
977 dev_err(chip->card->dev, in init_dsp_comm_page()
983 chip->card_name = ECHOCARD_NAME; in init_dsp_comm_page()
984 chip->bad_board = true; /* Set true until DSP loaded */ in init_dsp_comm_page()
985 chip->dsp_code = NULL; /* Current DSP code not loaded */ in init_dsp_comm_page()
986 chip->asic_loaded = false; in init_dsp_comm_page()
987 memset(chip->comm_page, 0, sizeof(struct comm_page)); in init_dsp_comm_page()
990 chip->comm_page->comm_size = in init_dsp_comm_page()
992 chip->comm_page->handshake = 0xffffffff; in init_dsp_comm_page()
993 chip->comm_page->midi_out_free_count = in init_dsp_comm_page()
995 chip->comm_page->sample_rate = cpu_to_le32(44100); in init_dsp_comm_page()
998 memset(chip->comm_page->monitors, ECHOGAIN_MUTED, MONITOR_ARRAY_SIZE); in init_dsp_comm_page()
999 memset(chip->comm_page->vmixer, ECHOGAIN_MUTED, VMIXER_ARRAY_SIZE); in init_dsp_comm_page()
1010 static int init_line_levels(struct echoaudio *chip) in init_line_levels() argument
1012 memset(chip->output_gain, ECHOGAIN_MUTED, sizeof(chip->output_gain)); in init_line_levels()
1013 memset(chip->input_gain, ECHOGAIN_MUTED, sizeof(chip->input_gain)); in init_line_levels()
1014 memset(chip->monitor_gain, ECHOGAIN_MUTED, sizeof(chip->monitor_gain)); in init_line_levels()
1015 memset(chip->vmixer_gain, ECHOGAIN_MUTED, sizeof(chip->vmixer_gain)); in init_line_levels()
1016 chip->input_clock = ECHO_CLOCK_INTERNAL; in init_line_levels()
1017 chip->output_clock = ECHO_CLOCK_WORD; in init_line_levels()
1018 chip->sample_rate = 44100; in init_line_levels()
1019 return restore_dsp_rettings(chip); in init_line_levels()
1027 static int service_irq(struct echoaudio *chip) in service_irq() argument
1032 if (get_dsp_register(chip, CHI32_STATUS_REG) & CHI32_STATUS_IRQ) { in service_irq()
1036 if (chip->comm_page->midi_input[0]) /* The count is at index 0 */ in service_irq()
1037 st = midi_service_irq(chip); /* Returns how many midi bytes we received */ in service_irq()
1040 chip->comm_page->midi_input[0] = 0; in service_irq()
1041 send_vector(chip, DSP_VC_ACK_INT); in service_irq()
1056 static int allocate_pipes(struct echoaudio *chip, struct audiopipe *pipe, in allocate_pipes() argument
1063 dev_dbg(chip->card->dev, in allocate_pipes()
1066 if (chip->bad_board) in allocate_pipes()
1073 if (chip->pipe_alloc_mask & channel_mask) { in allocate_pipes()
1074 dev_err(chip->card->dev, in allocate_pipes()
1079 chip->comm_page->position[pipe_index] = 0; in allocate_pipes()
1080 chip->pipe_alloc_mask |= channel_mask; in allocate_pipes()
1082 chip->pipe_cyclic_mask |= channel_mask; in allocate_pipes()
1090 pipe->dma_counter = &chip->comm_page->position[pipe_index]; in allocate_pipes()
1097 static int free_pipes(struct echoaudio *chip, struct audiopipe *pipe) in free_pipes() argument
1102 if (snd_BUG_ON(!is_pipe_allocated(chip, pipe->index))) in free_pipes()
1110 chip->pipe_alloc_mask &= ~channel_mask; in free_pipes()
1111 chip->pipe_cyclic_mask &= ~channel_mask; in free_pipes()
1121 static int sglist_init(struct echoaudio *chip, struct audiopipe *pipe) in sglist_init() argument
1125 chip->comm_page->sglist_addr[pipe->index].addr = in sglist_init()
1132 static int sglist_add_mapping(struct echoaudio *chip, struct audiopipe *pipe, in sglist_add_mapping() argument
1143 dev_err(chip->card->dev, "SGlist: too many fragments\n"); in sglist_add_mapping()
1151 static inline int sglist_add_irq(struct echoaudio *chip, struct audiopipe *pipe) in sglist_add_irq() argument
1153 return sglist_add_mapping(chip, pipe, 0, 0); in sglist_add_irq()
1158 static inline int sglist_wrap(struct echoaudio *chip, struct audiopipe *pipe) in sglist_wrap() argument
1160 return sglist_add_mapping(chip, pipe, pipe->sgpage.addr, 0); in sglist_wrap()