Lines Matching refs:hdsp

431     struct hdsp             *hdsp;  member
442 struct hdsp { struct
590 static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp);
591 static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp);
592 static int snd_hdsp_enable_io (struct hdsp *hdsp);
593 static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp);
594 static void snd_hdsp_initialize_channels (struct hdsp *hdsp);
595 static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout);
596 static int hdsp_autosync_ref(struct hdsp *hdsp);
597 static int snd_hdsp_set_defaults(struct hdsp *hdsp);
598 static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp);
600 static int hdsp_playback_to_output_key (struct hdsp *hdsp, int in, int out) in hdsp_playback_to_output_key() argument
602 switch (hdsp->io_type) { in hdsp_playback_to_output_key()
607 if (hdsp->firmware_rev == 0xa) in hdsp_playback_to_output_key()
618 static int hdsp_input_to_output_key (struct hdsp *hdsp, int in, int out) in hdsp_input_to_output_key() argument
620 switch (hdsp->io_type) { in hdsp_input_to_output_key()
625 if (hdsp->firmware_rev == 0xa) in hdsp_input_to_output_key()
636 static void hdsp_write(struct hdsp *hdsp, int reg, int val) in hdsp_write() argument
638 writel(val, hdsp->iobase + reg); in hdsp_write()
641 static unsigned int hdsp_read(struct hdsp *hdsp, int reg) in hdsp_read() argument
643 return readl (hdsp->iobase + reg); in hdsp_read()
646 static int hdsp_check_for_iobox (struct hdsp *hdsp) in hdsp_check_for_iobox() argument
650 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0; in hdsp_check_for_iobox()
652 if (0 == (hdsp_read(hdsp, HDSP_statusRegister) & in hdsp_check_for_iobox()
655 dev_dbg(hdsp->card->dev, in hdsp_check_for_iobox()
663 dev_err(hdsp->card->dev, "no IO box connected!\n"); in hdsp_check_for_iobox()
664 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_check_for_iobox()
668 static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops, in hdsp_wait_for_iobox() argument
673 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_wait_for_iobox()
677 if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError) in hdsp_wait_for_iobox()
680 dev_dbg(hdsp->card->dev, "iobox found after %ums!\n", in hdsp_wait_for_iobox()
686 dev_info(hdsp->card->dev, "no IO box connected!\n"); in hdsp_wait_for_iobox()
687 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_wait_for_iobox()
691 static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) { in snd_hdsp_load_firmware_from_cache() argument
697 if (hdsp->fw_uploaded) in snd_hdsp_load_firmware_from_cache()
698 cache = hdsp->fw_uploaded; in snd_hdsp_load_firmware_from_cache()
700 if (!hdsp->firmware) in snd_hdsp_load_firmware_from_cache()
702 cache = (u32 *)hdsp->firmware->data; in snd_hdsp_load_firmware_from_cache()
707 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in snd_hdsp_load_firmware_from_cache()
709 dev_info(hdsp->card->dev, "loading firmware\n"); in snd_hdsp_load_firmware_from_cache()
711 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM); in snd_hdsp_load_firmware_from_cache()
712 hdsp_write (hdsp, HDSP_fifoData, 0); in snd_hdsp_load_firmware_from_cache()
714 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { in snd_hdsp_load_firmware_from_cache()
715 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
717 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
721 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD); in snd_hdsp_load_firmware_from_cache()
724 hdsp_write(hdsp, HDSP_fifoData, cache[i]); in snd_hdsp_load_firmware_from_cache()
725 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { in snd_hdsp_load_firmware_from_cache()
726 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
728 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
733 hdsp_fifo_wait(hdsp, 3, HDSP_LONG_WAIT); in snd_hdsp_load_firmware_from_cache()
734 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
738 hdsp->control2_register = HDSP_BIGENDIAN_MODE; in snd_hdsp_load_firmware_from_cache()
740 hdsp->control2_register = 0; in snd_hdsp_load_firmware_from_cache()
742 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_load_firmware_from_cache()
743 dev_info(hdsp->card->dev, "finished firmware loading\n"); in snd_hdsp_load_firmware_from_cache()
746 if (hdsp->state & HDSP_InitializationComplete) { in snd_hdsp_load_firmware_from_cache()
747 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
749 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_load_firmware_from_cache()
750 snd_hdsp_set_defaults(hdsp); in snd_hdsp_load_firmware_from_cache()
751 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_load_firmware_from_cache()
754 hdsp->state |= HDSP_FirmwareLoaded; in snd_hdsp_load_firmware_from_cache()
759 static int hdsp_get_iobox_version (struct hdsp *hdsp) in hdsp_get_iobox_version() argument
761 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in hdsp_get_iobox_version()
763 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
764 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
766 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) { in hdsp_get_iobox_version()
767 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
768 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
771 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200 | HDSP_PROGRAM); in hdsp_get_iobox_version()
772 hdsp_write (hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
773 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) in hdsp_get_iobox_version()
776 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
777 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
778 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) { in hdsp_get_iobox_version()
779 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
780 dev_info(hdsp->card->dev, "Digiface found\n"); in hdsp_get_iobox_version()
784 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
785 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
786 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
787 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) in hdsp_get_iobox_version()
790 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
791 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
792 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
793 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) in hdsp_get_iobox_version()
796 hdsp->io_type = RPM; in hdsp_get_iobox_version()
797 dev_info(hdsp->card->dev, "RPM found\n"); in hdsp_get_iobox_version()
801 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in hdsp_get_iobox_version()
802 hdsp->io_type = RPM; in hdsp_get_iobox_version()
803 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in hdsp_get_iobox_version()
804 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
806 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
811 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
812 dev_info(hdsp->card->dev, "Multiface found\n"); in hdsp_get_iobox_version()
817 static int hdsp_request_fw_loader(struct hdsp *hdsp);
819 static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand) in hdsp_check_for_firmware() argument
821 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_check_for_firmware()
823 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in hdsp_check_for_firmware()
824 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_check_for_firmware()
827 dev_err(hdsp->card->dev, "firmware not present.\n"); in hdsp_check_for_firmware()
829 if (! (hdsp->state & HDSP_FirmwareCached)) { in hdsp_check_for_firmware()
830 if (! hdsp_request_fw_loader(hdsp)) in hdsp_check_for_firmware()
832 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
836 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in hdsp_check_for_firmware()
837 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
846 static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout) in hdsp_fifo_wait() argument
856 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count) in hdsp_fifo_wait()
866 dev_warn(hdsp->card->dev, in hdsp_fifo_wait()
872 static int hdsp_read_gain (struct hdsp *hdsp, unsigned int addr) in hdsp_read_gain() argument
877 return hdsp->mixer_matrix[addr]; in hdsp_read_gain()
880 static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short data) in hdsp_write_gain() argument
887 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) { in hdsp_write_gain()
901 if (hdsp->io_type == H9632 && addr >= 512) in hdsp_write_gain()
904 if (hdsp->io_type == H9652 && addr >= 1352) in hdsp_write_gain()
907 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
919 hdsp_write (hdsp, 4096 + (ad*4), in hdsp_write_gain()
920 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + in hdsp_write_gain()
921 hdsp->mixer_matrix[addr&0x7fe]); in hdsp_write_gain()
929 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) in hdsp_write_gain()
932 hdsp_write (hdsp, HDSP_fifoData, ad); in hdsp_write_gain()
933 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
940 static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp) in snd_hdsp_use_is_exclusive() argument
945 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
946 if ((hdsp->playback_pid != hdsp->capture_pid) && in snd_hdsp_use_is_exclusive()
947 (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0)) in snd_hdsp_use_is_exclusive()
949 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
953 static int hdsp_spdif_sample_rate(struct hdsp *hdsp) in hdsp_spdif_sample_rate() argument
955 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sample_rate()
959 if (hdsp->io_type == H9632) in hdsp_spdif_sample_rate()
973 if (hdsp->io_type == H9632) return 128000; in hdsp_spdif_sample_rate()
976 if (hdsp->io_type == H9632) return 176400; in hdsp_spdif_sample_rate()
979 if (hdsp->io_type == H9632) return 192000; in hdsp_spdif_sample_rate()
984 dev_warn(hdsp->card->dev, in hdsp_spdif_sample_rate()
990 static int hdsp_external_sample_rate(struct hdsp *hdsp) in hdsp_external_sample_rate() argument
992 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_external_sample_rate()
999 if (hdsp->io_type == H9632 && in hdsp_external_sample_rate()
1000 hdsp_autosync_ref(hdsp) == HDSP_AUTOSYNC_FROM_SPDIF) in hdsp_external_sample_rate()
1001 return hdsp_spdif_sample_rate(hdsp); in hdsp_external_sample_rate()
1015 static void hdsp_compute_period_size(struct hdsp *hdsp) in hdsp_compute_period_size() argument
1017 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8)); in hdsp_compute_period_size()
1020 static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp) in hdsp_hw_pointer() argument
1024 position = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_hw_pointer()
1026 if (!hdsp->precise_ptr) in hdsp_hw_pointer()
1027 return (position & HDSP_BufferID) ? (hdsp->period_bytes / 4) : 0; in hdsp_hw_pointer()
1031 position &= (hdsp->period_bytes/2) - 1; in hdsp_hw_pointer()
1035 static void hdsp_reset_hw_pointer(struct hdsp *hdsp) in hdsp_reset_hw_pointer() argument
1037 hdsp_write (hdsp, HDSP_resetPointer, 0); in hdsp_reset_hw_pointer()
1038 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_reset_hw_pointer()
1042 hdsp_write (hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_reset_hw_pointer()
1045 static void hdsp_start_audio(struct hdsp *s) in hdsp_start_audio()
1051 static void hdsp_stop_audio(struct hdsp *s) in hdsp_stop_audio()
1057 static void hdsp_silence_playback(struct hdsp *hdsp) in hdsp_silence_playback() argument
1059 memset(hdsp->playback_buffer, 0, HDSP_DMA_AREA_BYTES); in hdsp_silence_playback()
1062 static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames) in hdsp_set_interrupt_interval()
1087 static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) in hdsp_set_dds_value() argument
1102 hdsp->dds_value = n; in hdsp_set_dds_value()
1103 hdsp_write(hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_set_dds_value()
1106 static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally) in hdsp_set_rate() argument
1117 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { in hdsp_set_rate()
1120 dev_err(hdsp->card->dev, in hdsp_set_rate()
1125 int external_freq = hdsp_external_sample_rate(hdsp); in hdsp_set_rate()
1126 int spdif_freq = hdsp_spdif_sample_rate(hdsp); in hdsp_set_rate()
1128 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) in hdsp_set_rate()
1129 dev_info(hdsp->card->dev, in hdsp_set_rate()
1131 …else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= … in hdsp_set_rate()
1132 dev_info(hdsp->card->dev, in hdsp_set_rate()
1135 dev_info(hdsp->card->dev, in hdsp_set_rate()
1142 current_rate = hdsp->system_sample_rate; in hdsp_set_rate()
1154 if (rate > 96000 && hdsp->io_type != H9632) in hdsp_set_rate()
1207 if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) { in hdsp_set_rate()
1208 dev_warn(hdsp->card->dev, in hdsp_set_rate()
1210 hdsp->capture_pid, in hdsp_set_rate()
1211 hdsp->playback_pid); in hdsp_set_rate()
1215 hdsp->control_register &= ~HDSP_FrequencyMask; in hdsp_set_rate()
1216 hdsp->control_register |= rate_bits; in hdsp_set_rate()
1217 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rate()
1220 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_set_rate()
1221 hdsp_set_dds_value(hdsp, rate); in hdsp_set_rate()
1224 hdsp->channel_map = channel_map_H9632_qs; in hdsp_set_rate()
1226 if (hdsp->io_type == H9632) in hdsp_set_rate()
1227 hdsp->channel_map = channel_map_H9632_ds; in hdsp_set_rate()
1229 hdsp->channel_map = channel_map_ds; in hdsp_set_rate()
1231 switch (hdsp->io_type) { in hdsp_set_rate()
1234 hdsp->channel_map = channel_map_mf_ss; in hdsp_set_rate()
1238 hdsp->channel_map = channel_map_df_ss; in hdsp_set_rate()
1241 hdsp->channel_map = channel_map_H9632_ss; in hdsp_set_rate()
1249 hdsp->system_sample_rate = rate; in hdsp_set_rate()
1258 static unsigned char snd_hdsp_midi_read_byte (struct hdsp *hdsp, int id) in snd_hdsp_midi_read_byte() argument
1262 return hdsp_read(hdsp, HDSP_midiDataIn1); in snd_hdsp_midi_read_byte()
1264 return hdsp_read(hdsp, HDSP_midiDataIn0); in snd_hdsp_midi_read_byte()
1267 static void snd_hdsp_midi_write_byte (struct hdsp *hdsp, int id, int val) in snd_hdsp_midi_write_byte() argument
1271 hdsp_write(hdsp, HDSP_midiDataOut1, val); in snd_hdsp_midi_write_byte()
1273 hdsp_write(hdsp, HDSP_midiDataOut0, val); in snd_hdsp_midi_write_byte()
1276 static int snd_hdsp_midi_input_available (struct hdsp *hdsp, int id) in snd_hdsp_midi_input_available() argument
1279 return (hdsp_read(hdsp, HDSP_midiStatusIn1) & 0xff); in snd_hdsp_midi_input_available()
1281 return (hdsp_read(hdsp, HDSP_midiStatusIn0) & 0xff); in snd_hdsp_midi_input_available()
1284 static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id) in snd_hdsp_midi_output_possible() argument
1289 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff; in snd_hdsp_midi_output_possible()
1291 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff; in snd_hdsp_midi_output_possible()
1299 static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id) in snd_hdsp_flush_midi_input() argument
1303 while (snd_hdsp_midi_input_available(hdsp, id) && --count) in snd_hdsp_flush_midi_input()
1304 snd_hdsp_midi_read_byte(hdsp, id); in snd_hdsp_flush_midi_input()
1320 n_pending = snd_hdsp_midi_output_possible(hmidi->hdsp, hmidi->id); in snd_hdsp_midi_output_write()
1328 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); in snd_hdsp_midi_output_write()
1345 n_pending = snd_hdsp_midi_input_available(hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1351 buf[i] = snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1357 snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1362 hmidi->hdsp->control_register |= HDSP_Midi1InterruptEnable; in snd_hdsp_midi_input_read()
1364 hmidi->hdsp->control_register |= HDSP_Midi0InterruptEnable; in snd_hdsp_midi_input_read()
1365 hdsp_write(hmidi->hdsp, HDSP_controlRegister, hmidi->hdsp->control_register); in snd_hdsp_midi_input_read()
1372 struct hdsp *hdsp; in snd_hdsp_midi_input_trigger() local
1378 hdsp = hmidi->hdsp; in snd_hdsp_midi_input_trigger()
1380 spin_lock_irqsave (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1382 if (!(hdsp->control_register & ie)) { in snd_hdsp_midi_input_trigger()
1383 snd_hdsp_flush_midi_input (hdsp, hmidi->id); in snd_hdsp_midi_input_trigger()
1384 hdsp->control_register |= ie; in snd_hdsp_midi_input_trigger()
1387 hdsp->control_register &= ~ie; in snd_hdsp_midi_input_trigger()
1390 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_midi_input_trigger()
1391 spin_unlock_irqrestore (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1443 snd_hdsp_flush_midi_input (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_open()
1504 static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id) in snd_hdsp_create_midi() argument
1508 hdsp->midi[id].id = id; in snd_hdsp_create_midi()
1509 hdsp->midi[id].rmidi = NULL; in snd_hdsp_create_midi()
1510 hdsp->midi[id].input = NULL; in snd_hdsp_create_midi()
1511 hdsp->midi[id].output = NULL; in snd_hdsp_create_midi()
1512 hdsp->midi[id].hdsp = hdsp; in snd_hdsp_create_midi()
1513 hdsp->midi[id].istimer = 0; in snd_hdsp_create_midi()
1514 hdsp->midi[id].pending = 0; in snd_hdsp_create_midi()
1515 spin_lock_init (&hdsp->midi[id].lock); in snd_hdsp_create_midi()
1518 if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) in snd_hdsp_create_midi()
1521 sprintf(hdsp->midi[id].rmidi->name, "HDSP MIDI %d", id+1); in snd_hdsp_create_midi()
1522 hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; in snd_hdsp_create_midi()
1524 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); in snd_hdsp_create_midi()
1525 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_hdsp_midi_input); in snd_hdsp_create_midi()
1527 hdsp->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | in snd_hdsp_create_midi()
1569 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_get() local
1571 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif); in snd_hdsp_control_spdif_get()
1577 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_put() local
1582 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1583 change = val != hdsp->creg_spdif; in snd_hdsp_control_spdif_put()
1584 hdsp->creg_spdif = val; in snd_hdsp_control_spdif_put()
1585 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1598 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_get() local
1600 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream); in snd_hdsp_control_spdif_stream_get()
1606 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_put() local
1611 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1612 change = val != hdsp->creg_spdif_stream; in snd_hdsp_control_spdif_stream_put()
1613 hdsp->creg_spdif_stream = val; in snd_hdsp_control_spdif_stream_put()
1614 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_control_spdif_stream_put()
1615 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= val); in snd_hdsp_control_spdif_stream_put()
1616 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1641 static unsigned int hdsp_spdif_in(struct hdsp *hdsp) in hdsp_spdif_in() argument
1643 return hdsp_decode_spdif_in(hdsp->control_register & HDSP_SPDIFInputMask); in hdsp_spdif_in()
1646 static int hdsp_set_spdif_input(struct hdsp *hdsp, int in) in hdsp_set_spdif_input() argument
1648 hdsp->control_register &= ~HDSP_SPDIFInputMask; in hdsp_set_spdif_input()
1649 hdsp->control_register |= hdsp_encode_spdif_in(in); in hdsp_set_spdif_input()
1650 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_spdif_input()
1659 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_in() local
1661 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 4 : 3, in snd_hdsp_info_spdif_in()
1667 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_in() local
1669 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); in snd_hdsp_get_spdif_in()
1675 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_spdif_in() local
1679 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_spdif_in()
1681 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3); in snd_hdsp_put_spdif_in()
1682 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1683 change = val != hdsp_spdif_in(hdsp); in snd_hdsp_put_spdif_in()
1685 hdsp_set_spdif_input(hdsp, val); in snd_hdsp_put_spdif_in()
1686 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1699 static int hdsp_toggle_setting(struct hdsp *hdsp, u32 regmask) in hdsp_toggle_setting() argument
1701 return (hdsp->control_register & regmask) ? 1 : 0; in hdsp_toggle_setting()
1704 static int hdsp_set_toggle_setting(struct hdsp *hdsp, u32 regmask, int out) in hdsp_set_toggle_setting() argument
1707 hdsp->control_register |= regmask; in hdsp_set_toggle_setting()
1709 hdsp->control_register &= ~regmask; in hdsp_set_toggle_setting()
1710 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_toggle_setting()
1720 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_toggle_setting() local
1723 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1724 ucontrol->value.integer.value[0] = hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_get_toggle_setting()
1725 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1732 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_toggle_setting() local
1737 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_toggle_setting()
1740 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1741 change = (int) val != hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_put_toggle_setting()
1743 hdsp_set_toggle_setting(hdsp, regmask, val); in snd_hdsp_put_toggle_setting()
1744 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1763 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_sample_rate() local
1765 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_spdif_sample_rate()
1771 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sample_rate() local
1773 switch (hdsp_spdif_sample_rate(hdsp)) { in snd_hdsp_get_spdif_sample_rate()
1825 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_sample_rate() local
1827 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; in snd_hdsp_get_system_sample_rate()
1842 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_autosync_sample_rate() local
1848 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_autosync_sample_rate()
1854 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_sample_rate() local
1856 switch (hdsp_external_sample_rate(hdsp)) { in snd_hdsp_get_autosync_sample_rate()
1899 static int hdsp_system_clock_mode(struct hdsp *hdsp) in hdsp_system_clock_mode() argument
1901 if (hdsp->control_register & HDSP_ClockModeMaster) in hdsp_system_clock_mode()
1903 else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) in hdsp_system_clock_mode()
1917 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_clock_mode() local
1919 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); in snd_hdsp_get_system_clock_mode()
1932 static int hdsp_clock_source(struct hdsp *hdsp) in hdsp_clock_source() argument
1934 if (hdsp->control_register & HDSP_ClockModeMaster) { in hdsp_clock_source()
1935 switch (hdsp->system_sample_rate) { in hdsp_clock_source()
1962 static int hdsp_set_clock_source(struct hdsp *hdsp, int mode) in hdsp_set_clock_source() argument
1967 if (hdsp_external_sample_rate(hdsp) != 0) { in hdsp_set_clock_source()
1968 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) { in hdsp_set_clock_source()
1969 hdsp->control_register &= ~HDSP_ClockModeMaster; in hdsp_set_clock_source()
1970 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2005 hdsp->control_register |= HDSP_ClockModeMaster; in hdsp_set_clock_source()
2006 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2007 hdsp_set_rate(hdsp, rate, 1); in hdsp_set_clock_source()
2019 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_clock_source() local
2021 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_clock_source()
2027 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source() local
2029 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); in snd_hdsp_get_clock_source()
2035 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source() local
2039 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_clock_source()
2043 if (hdsp->io_type == H9632) { in snd_hdsp_put_clock_source()
2050 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2051 if (val != hdsp_clock_source(hdsp)) in snd_hdsp_put_clock_source()
2052 change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_clock_source()
2055 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2063 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source_lock() local
2065 ucontrol->value.integer.value[0] = hdsp->clock_source_locked; in snd_hdsp_get_clock_source_lock()
2071 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source_lock() local
2074 change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked; in snd_hdsp_put_clock_source_lock()
2076 hdsp->clock_source_locked = !!ucontrol->value.integer.value[0]; in snd_hdsp_put_clock_source_lock()
2089 static int hdsp_da_gain(struct hdsp *hdsp) in hdsp_da_gain() argument
2091 switch (hdsp->control_register & HDSP_DAGainMask) { in hdsp_da_gain()
2103 static int hdsp_set_da_gain(struct hdsp *hdsp, int mode) in hdsp_set_da_gain() argument
2105 hdsp->control_register &= ~HDSP_DAGainMask; in hdsp_set_da_gain()
2108 hdsp->control_register |= HDSP_DAGainHighGain; in hdsp_set_da_gain()
2111 hdsp->control_register |= HDSP_DAGainPlus4dBu; in hdsp_set_da_gain()
2114 hdsp->control_register |= HDSP_DAGainMinus10dBV; in hdsp_set_da_gain()
2120 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_da_gain()
2133 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_da_gain() local
2135 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp); in snd_hdsp_get_da_gain()
2141 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_da_gain() local
2145 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_da_gain()
2150 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2151 if (val != hdsp_da_gain(hdsp)) in snd_hdsp_put_da_gain()
2152 change = (hdsp_set_da_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_da_gain()
2155 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2168 static int hdsp_ad_gain(struct hdsp *hdsp) in hdsp_ad_gain() argument
2170 switch (hdsp->control_register & HDSP_ADGainMask) { in hdsp_ad_gain()
2182 static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode) in hdsp_set_ad_gain() argument
2184 hdsp->control_register &= ~HDSP_ADGainMask; in hdsp_set_ad_gain()
2187 hdsp->control_register |= HDSP_ADGainMinus10dBV; in hdsp_set_ad_gain()
2190 hdsp->control_register |= HDSP_ADGainPlus4dBu; in hdsp_set_ad_gain()
2193 hdsp->control_register |= HDSP_ADGainLowGain; in hdsp_set_ad_gain()
2199 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_ad_gain()
2212 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_ad_gain() local
2214 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp); in snd_hdsp_get_ad_gain()
2220 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_ad_gain() local
2224 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_ad_gain()
2229 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2230 if (val != hdsp_ad_gain(hdsp)) in snd_hdsp_put_ad_gain()
2231 change = (hdsp_set_ad_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_ad_gain()
2234 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2247 static int hdsp_phone_gain(struct hdsp *hdsp) in hdsp_phone_gain() argument
2249 switch (hdsp->control_register & HDSP_PhoneGainMask) { in hdsp_phone_gain()
2261 static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode) in hdsp_set_phone_gain() argument
2263 hdsp->control_register &= ~HDSP_PhoneGainMask; in hdsp_set_phone_gain()
2266 hdsp->control_register |= HDSP_PhoneGain0dB; in hdsp_set_phone_gain()
2269 hdsp->control_register |= HDSP_PhoneGainMinus6dB; in hdsp_set_phone_gain()
2272 hdsp->control_register |= HDSP_PhoneGainMinus12dB; in hdsp_set_phone_gain()
2278 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_phone_gain()
2291 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_phone_gain() local
2293 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp); in snd_hdsp_get_phone_gain()
2299 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_phone_gain() local
2303 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_phone_gain()
2308 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2309 if (val != hdsp_phone_gain(hdsp)) in snd_hdsp_put_phone_gain()
2310 change = (hdsp_set_phone_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_phone_gain()
2313 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2326 static int hdsp_pref_sync_ref(struct hdsp *hdsp) in hdsp_pref_sync_ref() argument
2332 switch (hdsp->control_register & HDSP_SyncRefMask) { in hdsp_pref_sync_ref()
2351 static int hdsp_set_pref_sync_ref(struct hdsp *hdsp, int pref) in hdsp_set_pref_sync_ref() argument
2353 hdsp->control_register &= ~HDSP_SyncRefMask; in hdsp_set_pref_sync_ref()
2356 hdsp->control_register &= ~HDSP_SyncRefMask; /* clear SyncRef bits */ in hdsp_set_pref_sync_ref()
2359 hdsp->control_register |= HDSP_SyncRef_ADAT2; in hdsp_set_pref_sync_ref()
2362 hdsp->control_register |= HDSP_SyncRef_ADAT3; in hdsp_set_pref_sync_ref()
2365 hdsp->control_register |= HDSP_SyncRef_SPDIF; in hdsp_set_pref_sync_ref()
2368 hdsp->control_register |= HDSP_SyncRef_WORD; in hdsp_set_pref_sync_ref()
2371 hdsp->control_register |= HDSP_SyncRef_ADAT_SYNC; in hdsp_set_pref_sync_ref()
2376 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_pref_sync_ref()
2385 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_pref_sync_ref() local
2388 switch (hdsp->io_type) { in snd_hdsp_info_pref_sync_ref()
2408 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_pref_sync_ref() local
2410 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); in snd_hdsp_get_pref_sync_ref()
2416 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_pref_sync_ref() local
2420 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_pref_sync_ref()
2423 switch (hdsp->io_type) { in snd_hdsp_put_pref_sync_ref()
2439 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2440 change = (int)val != hdsp_pref_sync_ref(hdsp); in snd_hdsp_put_pref_sync_ref()
2441 hdsp_set_pref_sync_ref(hdsp, val); in snd_hdsp_put_pref_sync_ref()
2442 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2455 static int hdsp_autosync_ref(struct hdsp *hdsp) in hdsp_autosync_ref() argument
2458 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_autosync_ref()
2492 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_ref() local
2494 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp); in snd_hdsp_get_autosync_ref()
2507 static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise) in hdsp_set_precise_pointer() argument
2510 hdsp->precise_ptr = 1; in hdsp_set_precise_pointer()
2512 hdsp->precise_ptr = 0; in hdsp_set_precise_pointer()
2520 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_precise_pointer() local
2522 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2523 ucontrol->value.integer.value[0] = hdsp->precise_ptr; in snd_hdsp_get_precise_pointer()
2524 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2530 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_precise_pointer() local
2534 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_precise_pointer()
2537 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2538 change = (int)val != hdsp->precise_ptr; in snd_hdsp_put_precise_pointer()
2539 hdsp_set_precise_pointer(hdsp, val); in snd_hdsp_put_precise_pointer()
2540 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2553 static int hdsp_set_use_midi_work(struct hdsp *hdsp, int use_work) in hdsp_set_use_midi_work() argument
2556 hdsp->use_midi_work = 1; in hdsp_set_use_midi_work()
2558 hdsp->use_midi_work = 0; in hdsp_set_use_midi_work()
2566 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_use_midi_work() local
2568 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_work()
2569 ucontrol->value.integer.value[0] = hdsp->use_midi_work; in snd_hdsp_get_use_midi_work()
2570 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_work()
2576 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_use_midi_work() local
2580 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_use_midi_work()
2583 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_work()
2584 change = (int)val != hdsp->use_midi_work; in snd_hdsp_put_use_midi_work()
2585 hdsp_set_use_midi_work(hdsp, val); in snd_hdsp_put_use_midi_work()
2586 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_work()
2614 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_mixer() local
2622 if (source >= hdsp->max_channels) in snd_hdsp_get_mixer()
2623 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination); in snd_hdsp_get_mixer()
2625 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_get_mixer()
2627 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2628 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr); in snd_hdsp_get_mixer()
2629 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2635 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_mixer() local
2642 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_mixer()
2648 if (source >= hdsp->max_channels) in snd_hdsp_put_mixer()
2649 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels, destination); in snd_hdsp_put_mixer()
2651 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_put_mixer()
2655 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2656 change = gain != hdsp_read_gain(hdsp, addr); in snd_hdsp_put_mixer()
2658 hdsp_write_gain(hdsp, addr, gain); in snd_hdsp_put_mixer()
2659 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2679 static int hdsp_wc_sync_check(struct hdsp *hdsp) in hdsp_wc_sync_check() argument
2681 int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_wc_sync_check()
2694 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_wc_sync_check() local
2696 ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp); in snd_hdsp_get_wc_sync_check()
2709 static int hdsp_spdif_sync_check(struct hdsp *hdsp) in hdsp_spdif_sync_check() argument
2711 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sync_check()
2725 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sync_check() local
2727 ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp); in snd_hdsp_get_spdif_sync_check()
2740 static int hdsp_adatsync_sync_check(struct hdsp *hdsp) in hdsp_adatsync_sync_check() argument
2742 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adatsync_sync_check()
2754 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adatsync_sync_check() local
2756 ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp); in snd_hdsp_get_adatsync_sync_check()
2767 static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx) in hdsp_adat_sync_check() argument
2769 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adat_sync_check()
2783 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adat_sync_check() local
2789 switch (hdsp->io_type) { in snd_hdsp_get_adat_sync_check()
2804 ucontrol->value.enumerated.item[0] = hdsp_adat_sync_check(hdsp, offset); in snd_hdsp_get_adat_sync_check()
2817 static int hdsp_dds_offset(struct hdsp *hdsp) in hdsp_dds_offset() argument
2820 unsigned int dds_value = hdsp->dds_value; in hdsp_dds_offset()
2821 int system_sample_rate = hdsp->system_sample_rate; in hdsp_dds_offset()
2839 static int hdsp_set_dds_offset(struct hdsp *hdsp, int offset_hz) in hdsp_set_dds_offset() argument
2841 int rate = hdsp->system_sample_rate + offset_hz; in hdsp_set_dds_offset()
2842 hdsp_set_dds_value(hdsp, rate); in hdsp_set_dds_offset()
2857 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_dds_offset() local
2859 ucontrol->value.integer.value[0] = hdsp_dds_offset(hdsp); in snd_hdsp_get_dds_offset()
2865 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_dds_offset() local
2869 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_dds_offset()
2872 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2873 if (val != hdsp_dds_offset(hdsp)) in snd_hdsp_put_dds_offset()
2874 change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_dds_offset()
2877 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2956 static int hdsp_rpm_input12(struct hdsp *hdsp) in hdsp_rpm_input12() argument
2958 switch (hdsp->control_register & HDSP_RPM_Inp12) { in hdsp_rpm_input12()
2974 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input12() local
2976 ucontrol->value.enumerated.item[0] = hdsp_rpm_input12(hdsp); in snd_hdsp_get_rpm_input12()
2981 static int hdsp_set_rpm_input12(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input12() argument
2983 hdsp->control_register &= ~HDSP_RPM_Inp12; in hdsp_set_rpm_input12()
2986 hdsp->control_register |= HDSP_RPM_Inp12_Phon_6dB; in hdsp_set_rpm_input12()
2991 hdsp->control_register |= HDSP_RPM_Inp12_Phon_n6dB; in hdsp_set_rpm_input12()
2994 hdsp->control_register |= HDSP_RPM_Inp12_Line_0dB; in hdsp_set_rpm_input12()
2997 hdsp->control_register |= HDSP_RPM_Inp12_Line_n6dB; in hdsp_set_rpm_input12()
3003 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input12()
3010 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input12() local
3014 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input12()
3021 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3022 if (val != hdsp_rpm_input12(hdsp)) in snd_hdsp_put_rpm_input12()
3023 change = (hdsp_set_rpm_input12(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input12()
3026 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3041 static int hdsp_rpm_input34(struct hdsp *hdsp) in hdsp_rpm_input34() argument
3043 switch (hdsp->control_register & HDSP_RPM_Inp34) { in hdsp_rpm_input34()
3059 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input34() local
3061 ucontrol->value.enumerated.item[0] = hdsp_rpm_input34(hdsp); in snd_hdsp_get_rpm_input34()
3066 static int hdsp_set_rpm_input34(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input34() argument
3068 hdsp->control_register &= ~HDSP_RPM_Inp34; in hdsp_set_rpm_input34()
3071 hdsp->control_register |= HDSP_RPM_Inp34_Phon_6dB; in hdsp_set_rpm_input34()
3076 hdsp->control_register |= HDSP_RPM_Inp34_Phon_n6dB; in hdsp_set_rpm_input34()
3079 hdsp->control_register |= HDSP_RPM_Inp34_Line_0dB; in hdsp_set_rpm_input34()
3082 hdsp->control_register |= HDSP_RPM_Inp34_Line_n6dB; in hdsp_set_rpm_input34()
3088 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input34()
3095 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input34() local
3099 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input34()
3106 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3107 if (val != hdsp_rpm_input34(hdsp)) in snd_hdsp_put_rpm_input34()
3108 change = (hdsp_set_rpm_input34(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input34()
3111 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3117 static int hdsp_rpm_bypass(struct hdsp *hdsp) in hdsp_rpm_bypass() argument
3119 return (hdsp->control_register & HDSP_RPM_Bypass) ? 1 : 0; in hdsp_rpm_bypass()
3125 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_bypass() local
3127 ucontrol->value.integer.value[0] = hdsp_rpm_bypass(hdsp); in snd_hdsp_get_rpm_bypass()
3132 static int hdsp_set_rpm_bypass(struct hdsp *hdsp, int on) in hdsp_set_rpm_bypass() argument
3135 hdsp->control_register |= HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3137 hdsp->control_register &= ~HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3138 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_bypass()
3145 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_bypass() local
3149 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_bypass()
3152 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3153 change = (int)val != hdsp_rpm_bypass(hdsp); in snd_hdsp_put_rpm_bypass()
3154 hdsp_set_rpm_bypass(hdsp, val); in snd_hdsp_put_rpm_bypass()
3155 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3169 static int hdsp_rpm_disconnect(struct hdsp *hdsp) in hdsp_rpm_disconnect() argument
3171 return (hdsp->control_register & HDSP_RPM_Disconnect) ? 1 : 0; in hdsp_rpm_disconnect()
3177 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_disconnect() local
3179 ucontrol->value.integer.value[0] = hdsp_rpm_disconnect(hdsp); in snd_hdsp_get_rpm_disconnect()
3184 static int hdsp_set_rpm_disconnect(struct hdsp *hdsp, int on) in hdsp_set_rpm_disconnect() argument
3187 hdsp->control_register |= HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3189 hdsp->control_register &= ~HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3190 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_disconnect()
3197 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_disconnect() local
3201 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_disconnect()
3204 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3205 change = (int)val != hdsp_rpm_disconnect(hdsp); in snd_hdsp_put_rpm_disconnect()
3206 hdsp_set_rpm_disconnect(hdsp, val); in snd_hdsp_put_rpm_disconnect()
3207 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3257 static bool hdsp_loopback_get(struct hdsp *const hdsp, const u8 channel) in hdsp_loopback_get() argument
3259 return hdsp->io_loopback & (1 << channel); in hdsp_loopback_get()
3262 static int hdsp_loopback_set(struct hdsp *const hdsp, const u8 channel, const bool enable) in hdsp_loopback_set() argument
3264 if (hdsp_loopback_get(hdsp, channel) == enable) in hdsp_loopback_set()
3267 hdsp->io_loopback ^= (1 << channel); in hdsp_loopback_set()
3269 hdsp_write(hdsp, HDSP_inputEnable + (4 * (hdsp->max_channels + channel)), enable); in hdsp_loopback_set()
3277 struct hdsp *const hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_loopback_get() local
3280 if (channel >= hdsp->max_channels) in snd_hdsp_loopback_get()
3283 ucontrol->value.integer.value[0] = hdsp_loopback_get(hdsp, channel); in snd_hdsp_loopback_get()
3291 struct hdsp *const hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_loopback_put() local
3295 if (channel >= hdsp->max_channels) in snd_hdsp_loopback_put()
3298 return hdsp_loopback_set(hdsp, channel, enable); in snd_hdsp_loopback_put()
3310 static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_controls() argument
3316 if (hdsp->io_type == RPM) { in snd_hdsp_create_controls()
3319 err = snd_ctl_add(card, snd_ctl_new1(&snd_hdsp_rpm_controls[idx], hdsp)); in snd_hdsp_create_controls()
3327 kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp); in snd_hdsp_create_controls()
3332 hdsp->spdif_ctl = kctl; in snd_hdsp_create_controls()
3338 kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp); in snd_hdsp_create_controls()
3342 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3345 kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp); in snd_hdsp_create_controls()
3353 if (hdsp->io_type == H9632) { in snd_hdsp_create_controls()
3355 kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp); in snd_hdsp_create_controls()
3363 if (hdsp->io_type == H9632) { in snd_hdsp_create_controls()
3364 snd_hdsp_loopback_control.count = hdsp->max_channels; in snd_hdsp_create_controls()
3365 kctl = snd_ctl_new1(&snd_hdsp_loopback_control, hdsp); in snd_hdsp_create_controls()
3374 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3375 kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp); in snd_hdsp_create_controls()
3391 struct hdsp *hdsp = entry->private_data; in snd_hdsp_proc_read() local
3400 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_proc_read()
3401 status2 = hdsp_read(hdsp, HDSP_status2Register); in snd_hdsp_proc_read()
3403 snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, in snd_hdsp_proc_read()
3404 hdsp->card->number + 1); in snd_hdsp_proc_read()
3406 hdsp->capture_buffer, hdsp->playback_buffer); in snd_hdsp_proc_read()
3408 hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); in snd_hdsp_proc_read()
3409 snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); in snd_hdsp_proc_read()
3411 hdsp->control2_register); in snd_hdsp_proc_read()
3415 if (hdsp_check_for_iobox(hdsp)) { in snd_hdsp_proc_read()
3421 if (hdsp_check_for_firmware(hdsp, 0)) { in snd_hdsp_proc_read()
3422 if (hdsp->state & HDSP_FirmwareCached) { in snd_hdsp_proc_read()
3423 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in snd_hdsp_proc_read()
3432 err = hdsp_request_fw_loader(hdsp); in snd_hdsp_proc_read()
3442 snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); in snd_hdsp_proc_read()
3443 snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); in snd_hdsp_proc_read()
3444 snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); in snd_hdsp_proc_read()
3445 snd_iprintf(buffer, "MIDI2 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut1)); in snd_hdsp_proc_read()
3446 snd_iprintf(buffer, "MIDI2 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn1)); in snd_hdsp_proc_read()
3447 snd_iprintf(buffer, "Use Midi Tasklet: %s\n", hdsp->use_midi_work ? "on" : "off"); in snd_hdsp_proc_read()
3451 x = 1 << (6 + hdsp_decode_latency(hdsp->control_register & HDSP_LatencyMask)); in snd_hdsp_proc_read()
3453 …fer Size (Latency): %d samples (2 periods of %lu bytes)\n", x, (unsigned long) hdsp->period_bytes); in snd_hdsp_proc_read()
3454 snd_iprintf(buffer, "Hardware pointer (frames): %ld\n", hdsp_hw_pointer(hdsp)); in snd_hdsp_proc_read()
3455 snd_iprintf(buffer, "Precise pointer: %s\n", hdsp->precise_ptr ? "on" : "off"); in snd_hdsp_proc_read()
3456 snd_iprintf(buffer, "Line out: %s\n", (hdsp->control_register & HDSP_LineOut) ? "on" : "off"); in snd_hdsp_proc_read()
3462 switch (hdsp_clock_source(hdsp)) { in snd_hdsp_proc_read()
3498 if (hdsp_system_clock_mode(hdsp)) in snd_hdsp_proc_read()
3503 switch (hdsp_pref_sync_ref (hdsp)) { in snd_hdsp_proc_read()
3528 switch (hdsp_autosync_ref (hdsp)) { in snd_hdsp_proc_read()
3556 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp)); in snd_hdsp_proc_read()
3560 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); in snd_hdsp_proc_read()
3561 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); in snd_hdsp_proc_read()
3565 if (hdsp->io_type != RPM) { in snd_hdsp_proc_read()
3566 switch (hdsp_spdif_in(hdsp)) { in snd_hdsp_proc_read()
3585 if (RPM == hdsp->io_type) { in snd_hdsp_proc_read()
3586 if (hdsp->control_register & HDSP_RPM_Bypass) in snd_hdsp_proc_read()
3590 if (hdsp->control_register & HDSP_RPM_Disconnect) in snd_hdsp_proc_read()
3595 switch (hdsp->control_register & HDSP_RPM_Inp12) { in snd_hdsp_proc_read()
3615 switch (hdsp->control_register & HDSP_RPM_Inp34) { in snd_hdsp_proc_read()
3636 if (hdsp->control_register & HDSP_SPDIFOpticalOut) in snd_hdsp_proc_read()
3641 if (hdsp->control_register & HDSP_SPDIFProfessional) in snd_hdsp_proc_read()
3646 if (hdsp->control_register & HDSP_SPDIFEmphasis) in snd_hdsp_proc_read()
3651 if (hdsp->control_register & HDSP_SPDIFNonAudio) in snd_hdsp_proc_read()
3655 x = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_proc_read()
3670 switch (hdsp->io_type) { in snd_hdsp_proc_read()
3710 if (hdsp->io_type == H9632) { in snd_hdsp_proc_read()
3713 switch (hdsp_ad_gain(hdsp)) { in snd_hdsp_proc_read()
3726 switch (hdsp_da_gain(hdsp)) { in snd_hdsp_proc_read()
3739 switch (hdsp_phone_gain(hdsp)) { in snd_hdsp_proc_read()
3753 hdsp_toggle_setting(hdsp, HDSP_XLRBreakoutCable) ? in snd_hdsp_proc_read()
3756 if (hdsp->control_register & HDSP_AnalogExtensionBoard) in snd_hdsp_proc_read()
3765 static void snd_hdsp_proc_init(struct hdsp *hdsp) in snd_hdsp_proc_init() argument
3767 snd_card_ro_proc_new(hdsp->card, "hdsp", hdsp, snd_hdsp_proc_read); in snd_hdsp_proc_init()
3770 static int snd_hdsp_initialize_memory(struct hdsp *hdsp) in snd_hdsp_initialize_memory() argument
3774 capture_dma = snd_hammerfall_get_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES); in snd_hdsp_initialize_memory()
3775 playback_dma = snd_hammerfall_get_buffer(hdsp->pci, HDSP_DMA_AREA_BYTES); in snd_hdsp_initialize_memory()
3777 dev_err(hdsp->card->dev, in snd_hdsp_initialize_memory()
3778 "%s: no buffers available\n", hdsp->card_name); in snd_hdsp_initialize_memory()
3783 hdsp->capture_dma_buf = *capture_dma; in snd_hdsp_initialize_memory()
3784 hdsp->playback_dma_buf = *playback_dma; in snd_hdsp_initialize_memory()
3787 hdsp->capture_dma_buf.addr = ALIGN(capture_dma->addr, 0x10000ul); in snd_hdsp_initialize_memory()
3788 hdsp->playback_dma_buf.addr = ALIGN(playback_dma->addr, 0x10000ul); in snd_hdsp_initialize_memory()
3791 hdsp_write(hdsp, HDSP_inputBufferAddress, hdsp->capture_dma_buf.addr); in snd_hdsp_initialize_memory()
3792 hdsp_write(hdsp, HDSP_outputBufferAddress, hdsp->playback_dma_buf.addr); in snd_hdsp_initialize_memory()
3794 hdsp->capture_dma_buf.area += hdsp->capture_dma_buf.addr - capture_dma->addr; in snd_hdsp_initialize_memory()
3795 hdsp->playback_dma_buf.area += hdsp->playback_dma_buf.addr - playback_dma->addr; in snd_hdsp_initialize_memory()
3796 hdsp->capture_buffer = hdsp->capture_dma_buf.area; in snd_hdsp_initialize_memory()
3797 hdsp->playback_buffer = hdsp->playback_dma_buf.area; in snd_hdsp_initialize_memory()
3802 static int snd_hdsp_set_defaults(struct hdsp *hdsp) in snd_hdsp_set_defaults() argument
3820 hdsp->control_register = HDSP_ClockModeMaster | in snd_hdsp_set_defaults()
3826 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3829 hdsp->control2_register = HDSP_BIGENDIAN_MODE; in snd_hdsp_set_defaults()
3831 hdsp->control2_register = 0; in snd_hdsp_set_defaults()
3833 if (hdsp->io_type == H9652) in snd_hdsp_set_defaults()
3834 snd_hdsp_9652_enable_mixer (hdsp); in snd_hdsp_set_defaults()
3836 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_set_defaults()
3838 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_set_defaults()
3839 hdsp_compute_period_size(hdsp); in snd_hdsp_set_defaults()
3844 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN; in snd_hdsp_set_defaults()
3846 …for (i = 0; i < ((hdsp->io_type == H9652 || hdsp->io_type == H9632) ? 1352 : HDSP_MATRIX_MIXER_SIZ… in snd_hdsp_set_defaults()
3847 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) in snd_hdsp_set_defaults()
3852 if (hdsp->io_type == H9632) { in snd_hdsp_set_defaults()
3853 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB); in snd_hdsp_set_defaults()
3854 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3860 hdsp_set_rate(hdsp, 48000, 1); in snd_hdsp_set_defaults()
3867 struct hdsp *hdsp = container_of(work, struct hdsp, midi_work); in hdsp_midi_work() local
3869 if (hdsp->midi[0].pending) in hdsp_midi_work()
3870 snd_hdsp_midi_input_read (&hdsp->midi[0]); in hdsp_midi_work()
3871 if (hdsp->midi[1].pending) in hdsp_midi_work()
3872 snd_hdsp_midi_input_read (&hdsp->midi[1]); in hdsp_midi_work()
3877 struct hdsp *hdsp = (struct hdsp *) dev_id; in snd_hdsp_interrupt() local
3886 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_interrupt()
3895 hdsp_write(hdsp, HDSP_interruptConfirmation, 0); in snd_hdsp_interrupt()
3897 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff; in snd_hdsp_interrupt()
3898 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff; in snd_hdsp_interrupt()
3900 if (!(hdsp->state & HDSP_InitializationComplete)) in snd_hdsp_interrupt()
3904 if (hdsp->capture_substream) in snd_hdsp_interrupt()
3905 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); in snd_hdsp_interrupt()
3907 if (hdsp->playback_substream) in snd_hdsp_interrupt()
3908 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); in snd_hdsp_interrupt()
3912 if (hdsp->use_midi_work) { in snd_hdsp_interrupt()
3914 hdsp->control_register &= ~HDSP_Midi0InterruptEnable; in snd_hdsp_interrupt()
3915 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3916 hdsp->midi[0].pending = 1; in snd_hdsp_interrupt()
3919 snd_hdsp_midi_input_read (&hdsp->midi[0]); in snd_hdsp_interrupt()
3922 …if (hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632 && midi1 && midi1… in snd_hdsp_interrupt()
3923 if (hdsp->use_midi_work) { in snd_hdsp_interrupt()
3925 hdsp->control_register &= ~HDSP_Midi1InterruptEnable; in snd_hdsp_interrupt()
3926 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3927 hdsp->midi[1].pending = 1; in snd_hdsp_interrupt()
3930 snd_hdsp_midi_input_read (&hdsp->midi[1]); in snd_hdsp_interrupt()
3933 if (hdsp->use_midi_work && schedule) in snd_hdsp_interrupt()
3934 queue_work(system_highpri_wq, &hdsp->midi_work); in snd_hdsp_interrupt()
3940 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_pointer() local
3941 return hdsp_hw_pointer(hdsp); in snd_hdsp_hw_pointer()
3944 static signed char *hdsp_channel_buffer_location(struct hdsp *hdsp, in hdsp_channel_buffer_location() argument
3951 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels)) in hdsp_channel_buffer_location()
3954 mapped_channel = hdsp->channel_map[channel]; in hdsp_channel_buffer_location()
3959 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3961 return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3968 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_copy() local
3974 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_playback_copy()
3986 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_copy() local
3992 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_capture_copy()
4004 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_silence() local
4007 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_hw_silence()
4017 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_reset() local
4020 other = hdsp->capture_substream; in snd_hdsp_reset()
4022 other = hdsp->playback_substream; in snd_hdsp_reset()
4023 if (hdsp->running) in snd_hdsp_reset()
4024 runtime->status->hw_ptr = hdsp_hw_pointer(hdsp); in snd_hdsp_reset()
4043 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_params() local
4048 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hw_params()
4051 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_hw_params()
4054 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4057 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_hw_params()
4058 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= hdsp->creg_spdif_stream); in snd_hdsp_hw_params()
4059 this_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4060 other_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4062 this_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4063 other_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4073 if (params_rate(params) != hdsp->system_sample_rate) { in snd_hdsp_hw_params()
4074 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4079 if (params_period_size(params) != hdsp->period_bytes / 4) { in snd_hdsp_hw_params()
4080 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4087 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4091 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4097 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4098 if (! hdsp->clock_source_locked) { in snd_hdsp_hw_params()
4099 err = hdsp_set_rate(hdsp, params_rate(params), 0); in snd_hdsp_hw_params()
4101 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4106 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4108 err = hdsp_set_interrupt_interval(hdsp, params_period_size(params)); in snd_hdsp_hw_params()
4120 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_channel_info() local
4123 if (snd_BUG_ON(channel >= hdsp->max_channels)) in snd_hdsp_channel_info()
4125 channel = array_index_nospec(channel, hdsp->max_channels); in snd_hdsp_channel_info()
4127 if (hdsp->channel_map[channel] < 0) in snd_hdsp_channel_info()
4130 info->offset = hdsp->channel_map[channel] * HDSP_CHANNEL_BUFFER_BYTES; in snd_hdsp_channel_info()
4153 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_trigger() local
4157 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_trigger()
4160 if (hdsp_check_for_firmware(hdsp, 0)) /* no auto-loading in trigger */ in snd_hdsp_trigger()
4163 spin_lock(&hdsp->lock); in snd_hdsp_trigger()
4164 running = hdsp->running; in snd_hdsp_trigger()
4174 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4178 other = hdsp->capture_substream; in snd_hdsp_trigger()
4180 other = hdsp->playback_substream; in snd_hdsp_trigger()
4197 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4201 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4205 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4209 if (!hdsp->running && running) in snd_hdsp_trigger()
4210 hdsp_start_audio(hdsp); in snd_hdsp_trigger()
4211 else if (hdsp->running && !running) in snd_hdsp_trigger()
4212 hdsp_stop_audio(hdsp); in snd_hdsp_trigger()
4213 hdsp->running = running; in snd_hdsp_trigger()
4214 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4221 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_prepare() local
4224 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_prepare()
4227 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_prepare()
4230 spin_lock_irq(&hdsp->lock); in snd_hdsp_prepare()
4231 if (!hdsp->running) in snd_hdsp_prepare()
4232 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_prepare()
4233 spin_unlock_irq(&hdsp->lock); in snd_hdsp_prepare()
4307 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels() local
4309 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels()
4311 list[0] = hdsp->qs_in_channels; in snd_hdsp_hw_rule_in_channels()
4312 list[1] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4313 list[2] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4317 list[0] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4318 list[1] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4327 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels() local
4329 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels()
4330 list[0] = hdsp->qs_out_channels; in snd_hdsp_hw_rule_out_channels()
4331 list[1] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4332 list[2] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4335 list[0] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4336 list[1] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4344 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels_rate() local
4347 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels_rate()
4349 .min = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4350 .max = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4356 .min = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4357 .max = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4363 .min = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4364 .max = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4375 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels_rate() local
4378 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels_rate()
4380 .min = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4381 .max = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4387 .min = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4388 .max = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4394 .min = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4395 .max = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4406 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_out_channels() local
4409 if (c->min >= hdsp->ss_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4416 } else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_out_channels()
4423 } else if (c->max <= hdsp->ds_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4437 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_in_channels() local
4440 if (c->min >= hdsp->ss_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4447 } else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_in_channels()
4454 } else if (c->max <= hdsp->ds_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4467 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_open() local
4470 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_playback_open()
4473 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_playback_open()
4476 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4481 snd_pcm_set_runtime_buffer(substream, &hdsp->playback_dma_buf); in snd_hdsp_playback_open()
4483 hdsp->playback_pid = current->pid; in snd_hdsp_playback_open()
4484 hdsp->playback_substream = substream; in snd_hdsp_playback_open()
4486 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4490 if (hdsp->clock_source_locked) { in snd_hdsp_playback_open()
4491 runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate; in snd_hdsp_playback_open()
4492 } else if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4498 if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4499 runtime->hw.channels_min = hdsp->qs_out_channels; in snd_hdsp_playback_open()
4500 runtime->hw.channels_max = hdsp->ss_out_channels; in snd_hdsp_playback_open()
4504 snd_hdsp_hw_rule_out_channels, hdsp, in snd_hdsp_playback_open()
4507 snd_hdsp_hw_rule_out_channels_rate, hdsp, in snd_hdsp_playback_open()
4510 snd_hdsp_hw_rule_rate_out_channels, hdsp, in snd_hdsp_playback_open()
4513 if (RPM != hdsp->io_type) { in snd_hdsp_playback_open()
4514 hdsp->creg_spdif_stream = hdsp->creg_spdif; in snd_hdsp_playback_open()
4515 hdsp->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_open()
4516 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_open()
4517 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_open()
4524 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_release() local
4526 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4528 hdsp->playback_pid = -1; in snd_hdsp_playback_release()
4529 hdsp->playback_substream = NULL; in snd_hdsp_playback_release()
4531 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4533 if (RPM != hdsp->io_type) { in snd_hdsp_playback_release()
4534 hdsp->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_release()
4535 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_release()
4536 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_release()
4544 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_open() local
4547 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_capture_open()
4550 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_capture_open()
4553 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4558 snd_pcm_set_runtime_buffer(substream, &hdsp->capture_dma_buf); in snd_hdsp_capture_open()
4560 hdsp->capture_pid = current->pid; in snd_hdsp_capture_open()
4561 hdsp->capture_substream = substream; in snd_hdsp_capture_open()
4563 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4567 if (hdsp->io_type == H9632) { in snd_hdsp_capture_open()
4568 runtime->hw.channels_min = hdsp->qs_in_channels; in snd_hdsp_capture_open()
4569 runtime->hw.channels_max = hdsp->ss_in_channels; in snd_hdsp_capture_open()
4576 snd_hdsp_hw_rule_in_channels, hdsp, in snd_hdsp_capture_open()
4579 snd_hdsp_hw_rule_in_channels_rate, hdsp, in snd_hdsp_capture_open()
4582 snd_hdsp_hw_rule_rate_in_channels, hdsp, in snd_hdsp_capture_open()
4589 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_release() local
4591 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4593 hdsp->capture_pid = -1; in snd_hdsp_capture_release()
4594 hdsp->capture_substream = NULL; in snd_hdsp_capture_release()
4596 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4627 static int hdsp_9652_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9652_get_peak() argument
4632 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9652_get_peak()
4639 if (copy_u32_le(&peak_rms->input_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4642 if (copy_u32_le(&peak_rms->playback_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4645 if (copy_u32_le(&peak_rms->output_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4648 if (copy_u48_le(&peak_rms->input_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4649 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4652 if (copy_u48_le(&peak_rms->playback_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4653 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4656 if (copy_u48_le(&peak_rms->output_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4657 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4664 static int hdsp_9632_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9632_get_peak() argument
4670 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9632_get_peak()
4672 m = (struct hdsp_9632_meters __iomem *)(hdsp->iobase+HDSP_9632_metersBase); in hdsp_9632_get_peak()
4694 static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_get_peak() argument
4700 hdsp->iobase + HDSP_playbackPeakLevel + i * 4)) in hdsp_get_peak()
4703 hdsp->iobase + HDSP_inputPeakLevel + i * 4)) in hdsp_get_peak()
4708 hdsp->iobase + HDSP_outputPeakLevel + i * 4)) in hdsp_get_peak()
4713 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4, in hdsp_get_peak()
4714 hdsp->iobase + HDSP_playbackRmsLevel + i * 8)) in hdsp_get_peak()
4717 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4, in hdsp_get_peak()
4718 hdsp->iobase + HDSP_inputRmsLevel + i * 8)) in hdsp_get_peak()
4726 struct hdsp *hdsp = hw->private_data; in snd_hdsp_hwdep_ioctl() local
4734 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4738 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4742 if (!(hdsp->state & HDSP_FirmwareLoaded)) { in snd_hdsp_hwdep_ioctl()
4743 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4748 switch (hdsp->io_type) { in snd_hdsp_hwdep_ioctl()
4750 return hdsp_9652_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4752 return hdsp_9632_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4754 return hdsp_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4762 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4766 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4771 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4772 info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4773 info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4774 if (hdsp->io_type != H9632) in snd_hdsp_hwdep_ioctl()
4775 info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4776 info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4777 …for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632) ? … in snd_hdsp_hwdep_ioctl()
4778 info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i); in snd_hdsp_hwdep_ioctl()
4779 info.spdif_in = (unsigned char)hdsp_spdif_in(hdsp); in snd_hdsp_hwdep_ioctl()
4780 info.spdif_out = (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4783 hdsp_toggle_setting(hdsp, HDSP_SPDIFProfessional); in snd_hdsp_hwdep_ioctl()
4785 hdsp_toggle_setting(hdsp, HDSP_SPDIFEmphasis); in snd_hdsp_hwdep_ioctl()
4787 hdsp_toggle_setting(hdsp, HDSP_SPDIFNonAudio); in snd_hdsp_hwdep_ioctl()
4788 info.spdif_sample_rate = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4789 info.system_sample_rate = hdsp->system_sample_rate; in snd_hdsp_hwdep_ioctl()
4790 info.autosync_sample_rate = hdsp_external_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4791 info.system_clock_mode = (unsigned char)hdsp_system_clock_mode(hdsp); in snd_hdsp_hwdep_ioctl()
4792 info.clock_source = (unsigned char)hdsp_clock_source(hdsp); in snd_hdsp_hwdep_ioctl()
4793 info.autosync_ref = (unsigned char)hdsp_autosync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4795 hdsp_toggle_setting(hdsp, HDSP_LineOut); in snd_hdsp_hwdep_ioctl()
4796 if (hdsp->io_type == H9632) { in snd_hdsp_hwdep_ioctl()
4797 info.da_gain = (unsigned char)hdsp_da_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4798 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4799 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4801 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4804 } else if (hdsp->io_type == RPM) { in snd_hdsp_hwdep_ioctl()
4805 info.da_gain = (unsigned char) hdsp_rpm_input12(hdsp); in snd_hdsp_hwdep_ioctl()
4806 info.ad_gain = (unsigned char) hdsp_rpm_input34(hdsp); in snd_hdsp_hwdep_ioctl()
4808 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) in snd_hdsp_hwdep_ioctl()
4810 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4812 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4820 if (hdsp->io_type != H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4821 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4822 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4831 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4832 if (hdsp->io_type == Undefined) { in snd_hdsp_hwdep_ioctl()
4833 err = hdsp_get_iobox_version(hdsp); in snd_hdsp_hwdep_ioctl()
4838 hdsp_version.io_type = hdsp->io_type; in snd_hdsp_hwdep_ioctl()
4839 hdsp_version.firmware_rev = hdsp->firmware_rev; in snd_hdsp_hwdep_ioctl()
4849 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4851 if (hdsp->io_type == Undefined) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4853 if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded)) in snd_hdsp_hwdep_ioctl()
4856 dev_info(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4862 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hwdep_ioctl()
4865 if (!hdsp->fw_uploaded) { in snd_hdsp_hwdep_ioctl()
4866 hdsp->fw_uploaded = vmalloc(HDSP_FIRMWARE_SIZE); in snd_hdsp_hwdep_ioctl()
4867 if (!hdsp->fw_uploaded) in snd_hdsp_hwdep_ioctl()
4871 if (copy_from_user(hdsp->fw_uploaded, firmware_data, in snd_hdsp_hwdep_ioctl()
4873 vfree(hdsp->fw_uploaded); in snd_hdsp_hwdep_ioctl()
4874 hdsp->fw_uploaded = NULL; in snd_hdsp_hwdep_ioctl()
4878 hdsp->state |= HDSP_FirmwareCached; in snd_hdsp_hwdep_ioctl()
4880 err = snd_hdsp_load_firmware_from_cache(hdsp); in snd_hdsp_hwdep_ioctl()
4884 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_hwdep_ioctl()
4885 err = snd_hdsp_enable_io(hdsp); in snd_hdsp_hwdep_ioctl()
4889 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_hwdep_ioctl()
4890 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_hwdep_ioctl()
4892 err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp); in snd_hdsp_hwdep_ioctl()
4894 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4903 …if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) in snd_hdsp_hwdep_ioctl()
4936 static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_hwdep() argument
4945 hdsp->hwdep = hw; in snd_hdsp_create_hwdep()
4946 hw->private_data = hdsp; in snd_hdsp_create_hwdep()
4955 static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_pcm() argument
4960 err = snd_pcm_new(card, hdsp->card_name, 0, 1, 1, &pcm); in snd_hdsp_create_pcm()
4964 hdsp->pcm = pcm; in snd_hdsp_create_pcm()
4965 pcm->private_data = hdsp; in snd_hdsp_create_pcm()
4966 strcpy(pcm->name, hdsp->card_name); in snd_hdsp_create_pcm()
4976 static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp) in snd_hdsp_9652_enable_mixer() argument
4978 hdsp->control2_register |= HDSP_9652_ENABLE_MIXER; in snd_hdsp_9652_enable_mixer()
4979 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_9652_enable_mixer()
4982 static int snd_hdsp_enable_io (struct hdsp *hdsp) in snd_hdsp_enable_io() argument
4986 if (hdsp_fifo_wait (hdsp, 0, 100)) { in snd_hdsp_enable_io()
4987 dev_err(hdsp->card->dev, in snd_hdsp_enable_io()
4992 for (i = 0; i < hdsp->max_channels; ++i) { in snd_hdsp_enable_io()
4993 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1); in snd_hdsp_enable_io()
4994 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1); in snd_hdsp_enable_io()
5000 static void snd_hdsp_initialize_channels(struct hdsp *hdsp) in snd_hdsp_initialize_channels() argument
5004 switch (hdsp->io_type) { in snd_hdsp_initialize_channels()
5006 hdsp->card_name = "RME Hammerfall DSP + Digiface"; in snd_hdsp_initialize_channels()
5007 hdsp->ss_in_channels = hdsp->ss_out_channels = DIGIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
5008 hdsp->ds_in_channels = hdsp->ds_out_channels = DIGIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
5012 hdsp->card_name = "RME Hammerfall HDSP 9652"; in snd_hdsp_initialize_channels()
5013 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS; in snd_hdsp_initialize_channels()
5014 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS; in snd_hdsp_initialize_channels()
5018 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_initialize_channels()
5022 hdsp->card_name = "RME Hammerfall HDSP 9632"; in snd_hdsp_initialize_channels()
5023 hdsp->ss_in_channels = H9632_SS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
5024 hdsp->ds_in_channels = H9632_DS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
5025 hdsp->qs_in_channels = H9632_QS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
5026 hdsp->ss_out_channels = H9632_SS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
5027 hdsp->ds_out_channels = H9632_DS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
5028 hdsp->qs_out_channels = H9632_QS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
5032 hdsp->io_loopback = 0xffffffff; in snd_hdsp_initialize_channels()
5033 for (i = 0; i < hdsp->max_channels; ++i) in snd_hdsp_initialize_channels()
5034 hdsp_loopback_set(hdsp, i, false); in snd_hdsp_initialize_channels()
5038 hdsp->card_name = "RME Hammerfall DSP + Multiface"; in snd_hdsp_initialize_channels()
5039 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
5040 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
5044 hdsp->card_name = "RME Hammerfall DSP + RPM"; in snd_hdsp_initialize_channels()
5045 hdsp->ss_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
5046 hdsp->ss_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
5047 hdsp->ds_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
5048 hdsp->ds_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
5057 static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp) in snd_hdsp_initialize_midi_flush() argument
5059 snd_hdsp_flush_midi_input (hdsp, 0); in snd_hdsp_initialize_midi_flush()
5060 snd_hdsp_flush_midi_input (hdsp, 1); in snd_hdsp_initialize_midi_flush()
5063 static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_alsa_devices() argument
5067 err = snd_hdsp_create_pcm(card, hdsp); in snd_hdsp_create_alsa_devices()
5075 err = snd_hdsp_create_midi(card, hdsp, 0); in snd_hdsp_create_alsa_devices()
5082 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_alsa_devices()
5083 err = snd_hdsp_create_midi(card, hdsp, 1); in snd_hdsp_create_alsa_devices()
5091 err = snd_hdsp_create_controls(card, hdsp); in snd_hdsp_create_alsa_devices()
5098 snd_hdsp_proc_init(hdsp); in snd_hdsp_create_alsa_devices()
5100 hdsp->system_sample_rate = -1; in snd_hdsp_create_alsa_devices()
5101 hdsp->playback_pid = -1; in snd_hdsp_create_alsa_devices()
5102 hdsp->capture_pid = -1; in snd_hdsp_create_alsa_devices()
5103 hdsp->capture_substream = NULL; in snd_hdsp_create_alsa_devices()
5104 hdsp->playback_substream = NULL; in snd_hdsp_create_alsa_devices()
5106 err = snd_hdsp_set_defaults(hdsp); in snd_hdsp_create_alsa_devices()
5113 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_create_alsa_devices()
5115 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_create_alsa_devices()
5116 hdsp->port, hdsp->irq); in snd_hdsp_create_alsa_devices()
5124 hdsp->state |= HDSP_InitializationComplete; in snd_hdsp_create_alsa_devices()
5131 static int hdsp_request_fw_loader(struct hdsp *hdsp) in hdsp_request_fw_loader() argument
5137 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5139 if (hdsp->io_type == Undefined) { in hdsp_request_fw_loader()
5140 err = hdsp_get_iobox_version(hdsp); in hdsp_request_fw_loader()
5143 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5148 switch (hdsp->io_type) { in hdsp_request_fw_loader()
5153 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5159 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5165 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5166 "invalid io_type %d\n", hdsp->io_type); in hdsp_request_fw_loader()
5170 if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) { in hdsp_request_fw_loader()
5171 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5176 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5183 hdsp->firmware = fw; in hdsp_request_fw_loader()
5185 hdsp->state |= HDSP_FirmwareCached; in hdsp_request_fw_loader()
5187 err = snd_hdsp_load_firmware_from_cache(hdsp); in hdsp_request_fw_loader()
5191 if (!(hdsp->state & HDSP_InitializationComplete)) { in hdsp_request_fw_loader()
5192 err = snd_hdsp_enable_io(hdsp); in hdsp_request_fw_loader()
5196 err = snd_hdsp_create_hwdep(hdsp->card, hdsp); in hdsp_request_fw_loader()
5198 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5202 snd_hdsp_initialize_channels(hdsp); in hdsp_request_fw_loader()
5203 snd_hdsp_initialize_midi_flush(hdsp); in hdsp_request_fw_loader()
5204 err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp); in hdsp_request_fw_loader()
5206 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5215 struct hdsp *hdsp) in snd_hdsp_create() argument
5217 struct pci_dev *pci = hdsp->pci; in snd_hdsp_create()
5222 hdsp->irq = -1; in snd_hdsp_create()
5223 hdsp->state = 0; in snd_hdsp_create()
5224 hdsp->midi[0].rmidi = NULL; in snd_hdsp_create()
5225 hdsp->midi[1].rmidi = NULL; in snd_hdsp_create()
5226 hdsp->midi[0].input = NULL; in snd_hdsp_create()
5227 hdsp->midi[1].input = NULL; in snd_hdsp_create()
5228 hdsp->midi[0].output = NULL; in snd_hdsp_create()
5229 hdsp->midi[1].output = NULL; in snd_hdsp_create()
5230 hdsp->midi[0].pending = 0; in snd_hdsp_create()
5231 hdsp->midi[1].pending = 0; in snd_hdsp_create()
5232 spin_lock_init(&hdsp->midi[0].lock); in snd_hdsp_create()
5233 spin_lock_init(&hdsp->midi[1].lock); in snd_hdsp_create()
5234 hdsp->iobase = NULL; in snd_hdsp_create()
5235 hdsp->control_register = 0; in snd_hdsp_create()
5236 hdsp->control2_register = 0; in snd_hdsp_create()
5237 hdsp->io_type = Undefined; in snd_hdsp_create()
5238 hdsp->max_channels = 26; in snd_hdsp_create()
5240 hdsp->card = card; in snd_hdsp_create()
5242 spin_lock_init(&hdsp->lock); in snd_hdsp_create()
5244 INIT_WORK(&hdsp->midi_work, hdsp_midi_work); in snd_hdsp_create()
5246 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev); in snd_hdsp_create()
5247 hdsp->firmware_rev &= 0xff; in snd_hdsp_create()
5256 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF); in snd_hdsp_create()
5261 if (hdsp->firmware_rev < 0xa) in snd_hdsp_create()
5263 else if (hdsp->firmware_rev < 0x64) in snd_hdsp_create()
5264 hdsp->card_name = "RME Hammerfall DSP"; in snd_hdsp_create()
5265 else if (hdsp->firmware_rev < 0x96) { in snd_hdsp_create()
5266 hdsp->card_name = "RME HDSP 9652"; in snd_hdsp_create()
5269 hdsp->card_name = "RME HDSP 9632"; in snd_hdsp_create()
5270 hdsp->max_channels = 16; in snd_hdsp_create()
5278 pci_set_master(hdsp->pci); in snd_hdsp_create()
5283 hdsp->port = pci_resource_start(pci, 0); in snd_hdsp_create()
5284 hdsp->iobase = devm_ioremap(&pci->dev, hdsp->port, HDSP_IO_EXTENT); in snd_hdsp_create()
5285 if (!hdsp->iobase) { in snd_hdsp_create()
5286 dev_err(hdsp->card->dev, "unable to remap region 0x%lx-0x%lx\n", in snd_hdsp_create()
5287 hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1); in snd_hdsp_create()
5292 IRQF_SHARED, KBUILD_MODNAME, hdsp)) { in snd_hdsp_create()
5293 dev_err(hdsp->card->dev, "unable to use IRQ %d\n", pci->irq); in snd_hdsp_create()
5297 hdsp->irq = pci->irq; in snd_hdsp_create()
5298 card->sync_irq = hdsp->irq; in snd_hdsp_create()
5299 hdsp->precise_ptr = 0; in snd_hdsp_create()
5300 hdsp->use_midi_work = 1; in snd_hdsp_create()
5301 hdsp->dds_value = 0; in snd_hdsp_create()
5303 err = snd_hdsp_initialize_memory(hdsp); in snd_hdsp_create()
5310 err = hdsp_wait_for_iobox(hdsp, 1000, 10); in snd_hdsp_create()
5315 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in snd_hdsp_create()
5316 err = hdsp_request_fw_loader(hdsp); in snd_hdsp_create()
5322 dev_err(hdsp->card->dev, in snd_hdsp_create()
5328 dev_info(hdsp->card->dev, in snd_hdsp_create()
5330 err = snd_hdsp_create_hwdep(card, hdsp); in snd_hdsp_create()
5335 dev_info(hdsp->card->dev, in snd_hdsp_create()
5337 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in snd_hdsp_create()
5338 hdsp->io_type = RPM; in snd_hdsp_create()
5339 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in snd_hdsp_create()
5340 hdsp->io_type = Multiface; in snd_hdsp_create()
5342 hdsp->io_type = Digiface; in snd_hdsp_create()
5346 err = snd_hdsp_enable_io(hdsp); in snd_hdsp_create()
5351 hdsp->io_type = H9652; in snd_hdsp_create()
5354 hdsp->io_type = H9632; in snd_hdsp_create()
5356 err = snd_hdsp_create_hwdep(card, hdsp); in snd_hdsp_create()
5360 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_create()
5361 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_create()
5363 hdsp->state |= HDSP_FirmwareLoaded; in snd_hdsp_create()
5365 err = snd_hdsp_create_alsa_devices(card, hdsp); in snd_hdsp_create()
5374 struct hdsp *hdsp = card->private_data; in snd_hdsp_card_free() local
5376 if (hdsp->port) { in snd_hdsp_card_free()
5378 cancel_work_sync(&hdsp->midi_work); in snd_hdsp_card_free()
5379hdsp->control_register &= ~(HDSP_Start|HDSP_AudioInterruptEnable|HDSP_Midi0InterruptEnable|HDSP_Mi… in snd_hdsp_card_free()
5380 hdsp_write (hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_card_free()
5383 release_firmware(hdsp->firmware); in snd_hdsp_card_free()
5384 vfree(hdsp->fw_uploaded); in snd_hdsp_card_free()
5391 struct hdsp *hdsp; in snd_hdsp_probe() local
5403 sizeof(struct hdsp), &card); in snd_hdsp_probe()
5407 hdsp = card->private_data; in snd_hdsp_probe()
5409 hdsp->dev = dev; in snd_hdsp_probe()
5410 hdsp->pci = pci; in snd_hdsp_probe()
5411 err = snd_hdsp_create(card, hdsp); in snd_hdsp_probe()
5416 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_probe()
5417 hdsp->port, hdsp->irq); in snd_hdsp_probe()