Lines Matching refs:hdsp
447 struct hdsp *hdsp; member
458 struct hdsp { struct
613 static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp);
614 static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp);
615 static int snd_hdsp_enable_io (struct hdsp *hdsp);
616 static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp);
617 static void snd_hdsp_initialize_channels (struct hdsp *hdsp);
618 static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout);
619 static int hdsp_autosync_ref(struct hdsp *hdsp);
620 static int snd_hdsp_set_defaults(struct hdsp *hdsp);
621 static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp);
623 static int hdsp_playback_to_output_key (struct hdsp *hdsp, int in, int out) in hdsp_playback_to_output_key() argument
625 switch (hdsp->io_type) { in hdsp_playback_to_output_key()
630 if (hdsp->firmware_rev == 0xa) in hdsp_playback_to_output_key()
641 static int hdsp_input_to_output_key (struct hdsp *hdsp, int in, int out) in hdsp_input_to_output_key() argument
643 switch (hdsp->io_type) { in hdsp_input_to_output_key()
648 if (hdsp->firmware_rev == 0xa) in hdsp_input_to_output_key()
659 static void hdsp_write(struct hdsp *hdsp, int reg, int val) in hdsp_write() argument
661 writel(val, hdsp->iobase + reg); in hdsp_write()
664 static unsigned int hdsp_read(struct hdsp *hdsp, int reg) in hdsp_read() argument
666 return readl (hdsp->iobase + reg); in hdsp_read()
669 static int hdsp_check_for_iobox (struct hdsp *hdsp) in hdsp_check_for_iobox() argument
673 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0; in hdsp_check_for_iobox()
675 if (0 == (hdsp_read(hdsp, HDSP_statusRegister) & in hdsp_check_for_iobox()
678 dev_dbg(hdsp->card->dev, in hdsp_check_for_iobox()
686 dev_err(hdsp->card->dev, "no IO box connected!\n"); in hdsp_check_for_iobox()
687 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_check_for_iobox()
691 static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops, in hdsp_wait_for_iobox() argument
696 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_wait_for_iobox()
700 if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError) in hdsp_wait_for_iobox()
703 dev_dbg(hdsp->card->dev, "iobox found after %ums!\n", in hdsp_wait_for_iobox()
709 dev_info(hdsp->card->dev, "no IO box connected!\n"); in hdsp_wait_for_iobox()
710 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_wait_for_iobox()
714 static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) { in snd_hdsp_load_firmware_from_cache() argument
720 if (hdsp->fw_uploaded) in snd_hdsp_load_firmware_from_cache()
721 cache = hdsp->fw_uploaded; in snd_hdsp_load_firmware_from_cache()
723 if (!hdsp->firmware) in snd_hdsp_load_firmware_from_cache()
725 cache = (u32 *)hdsp->firmware->data; in snd_hdsp_load_firmware_from_cache()
730 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in snd_hdsp_load_firmware_from_cache()
732 dev_info(hdsp->card->dev, "loading firmware\n"); in snd_hdsp_load_firmware_from_cache()
734 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM); in snd_hdsp_load_firmware_from_cache()
735 hdsp_write (hdsp, HDSP_fifoData, 0); in snd_hdsp_load_firmware_from_cache()
737 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { in snd_hdsp_load_firmware_from_cache()
738 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
740 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
744 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD); in snd_hdsp_load_firmware_from_cache()
747 hdsp_write(hdsp, HDSP_fifoData, cache[i]); in snd_hdsp_load_firmware_from_cache()
748 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { in snd_hdsp_load_firmware_from_cache()
749 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
751 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
756 hdsp_fifo_wait(hdsp, 3, HDSP_LONG_WAIT); in snd_hdsp_load_firmware_from_cache()
757 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
761 hdsp->control2_register = HDSP_BIGENDIAN_MODE; in snd_hdsp_load_firmware_from_cache()
763 hdsp->control2_register = 0; in snd_hdsp_load_firmware_from_cache()
765 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_load_firmware_from_cache()
766 dev_info(hdsp->card->dev, "finished firmware loading\n"); in snd_hdsp_load_firmware_from_cache()
769 if (hdsp->state & HDSP_InitializationComplete) { in snd_hdsp_load_firmware_from_cache()
770 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
772 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_load_firmware_from_cache()
773 snd_hdsp_set_defaults(hdsp); in snd_hdsp_load_firmware_from_cache()
774 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_load_firmware_from_cache()
777 hdsp->state |= HDSP_FirmwareLoaded; in snd_hdsp_load_firmware_from_cache()
782 static int hdsp_get_iobox_version (struct hdsp *hdsp) in hdsp_get_iobox_version() argument
784 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in hdsp_get_iobox_version()
786 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
787 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
789 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()
794 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200 | HDSP_PROGRAM); in hdsp_get_iobox_version()
795 hdsp_write (hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
796 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) { in hdsp_get_iobox_version()
797 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
798 dev_info(hdsp->card->dev, "Multiface found\n"); in hdsp_get_iobox_version()
802 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
803 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
804 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) { in hdsp_get_iobox_version()
805 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
806 dev_info(hdsp->card->dev, "Digiface found\n"); in hdsp_get_iobox_version()
810 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
811 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
812 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
813 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) { in hdsp_get_iobox_version()
814 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
815 dev_info(hdsp->card->dev, "Multiface found\n"); in hdsp_get_iobox_version()
819 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
820 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
821 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
822 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) { in hdsp_get_iobox_version()
823 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
824 dev_info(hdsp->card->dev, "Multiface found\n"); in hdsp_get_iobox_version()
828 hdsp->io_type = RPM; in hdsp_get_iobox_version()
829 dev_info(hdsp->card->dev, "RPM found\n"); in hdsp_get_iobox_version()
833 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in hdsp_get_iobox_version()
834 hdsp->io_type = RPM; in hdsp_get_iobox_version()
835 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in hdsp_get_iobox_version()
836 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
838 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
844 static int hdsp_request_fw_loader(struct hdsp *hdsp);
846 static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand) in hdsp_check_for_firmware() argument
848 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_check_for_firmware()
850 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in hdsp_check_for_firmware()
851 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_check_for_firmware()
854 dev_err(hdsp->card->dev, "firmware not present.\n"); in hdsp_check_for_firmware()
856 if (! (hdsp->state & HDSP_FirmwareCached)) { in hdsp_check_for_firmware()
857 if (! hdsp_request_fw_loader(hdsp)) in hdsp_check_for_firmware()
859 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
863 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in hdsp_check_for_firmware()
864 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
873 static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout) in hdsp_fifo_wait() argument
883 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count) in hdsp_fifo_wait()
893 dev_warn(hdsp->card->dev, in hdsp_fifo_wait()
899 static int hdsp_read_gain (struct hdsp *hdsp, unsigned int addr) in hdsp_read_gain() argument
904 return hdsp->mixer_matrix[addr]; in hdsp_read_gain()
907 static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short data) in hdsp_write_gain() argument
914 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) { in hdsp_write_gain()
928 if (hdsp->io_type == H9632 && addr >= 512) in hdsp_write_gain()
931 if (hdsp->io_type == H9652 && addr >= 1352) in hdsp_write_gain()
934 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
946 hdsp_write (hdsp, 4096 + (ad*4), in hdsp_write_gain()
947 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + in hdsp_write_gain()
948 hdsp->mixer_matrix[addr&0x7fe]); in hdsp_write_gain()
956 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) in hdsp_write_gain()
959 hdsp_write (hdsp, HDSP_fifoData, ad); in hdsp_write_gain()
960 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
967 static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp) in snd_hdsp_use_is_exclusive() argument
972 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
973 if ((hdsp->playback_pid != hdsp->capture_pid) && in snd_hdsp_use_is_exclusive()
974 (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0)) in snd_hdsp_use_is_exclusive()
976 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
980 static int hdsp_spdif_sample_rate(struct hdsp *hdsp) in hdsp_spdif_sample_rate() argument
982 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sample_rate()
986 if (hdsp->io_type == H9632) in hdsp_spdif_sample_rate()
1000 if (hdsp->io_type == H9632) return 128000; in hdsp_spdif_sample_rate()
1003 if (hdsp->io_type == H9632) return 176400; in hdsp_spdif_sample_rate()
1006 if (hdsp->io_type == H9632) return 192000; in hdsp_spdif_sample_rate()
1011 dev_warn(hdsp->card->dev, in hdsp_spdif_sample_rate()
1017 static int hdsp_external_sample_rate(struct hdsp *hdsp) in hdsp_external_sample_rate() argument
1019 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_external_sample_rate()
1026 if (hdsp->io_type == H9632 && in hdsp_external_sample_rate()
1027 hdsp_autosync_ref(hdsp) == HDSP_AUTOSYNC_FROM_SPDIF) in hdsp_external_sample_rate()
1028 return hdsp_spdif_sample_rate(hdsp); in hdsp_external_sample_rate()
1042 static void hdsp_compute_period_size(struct hdsp *hdsp) in hdsp_compute_period_size() argument
1044 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8)); in hdsp_compute_period_size()
1047 static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp) in hdsp_hw_pointer() argument
1051 position = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_hw_pointer()
1053 if (!hdsp->precise_ptr) in hdsp_hw_pointer()
1054 return (position & HDSP_BufferID) ? (hdsp->period_bytes / 4) : 0; in hdsp_hw_pointer()
1058 position &= (hdsp->period_bytes/2) - 1; in hdsp_hw_pointer()
1062 static void hdsp_reset_hw_pointer(struct hdsp *hdsp) in hdsp_reset_hw_pointer() argument
1064 hdsp_write (hdsp, HDSP_resetPointer, 0); in hdsp_reset_hw_pointer()
1065 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_reset_hw_pointer()
1069 hdsp_write (hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_reset_hw_pointer()
1072 static void hdsp_start_audio(struct hdsp *s) in hdsp_start_audio()
1078 static void hdsp_stop_audio(struct hdsp *s) in hdsp_stop_audio()
1084 static void hdsp_silence_playback(struct hdsp *hdsp) in hdsp_silence_playback() argument
1086 memset(hdsp->playback_buffer, 0, HDSP_DMA_AREA_BYTES); in hdsp_silence_playback()
1089 static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames) in hdsp_set_interrupt_interval()
1114 static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) in hdsp_set_dds_value() argument
1129 hdsp->dds_value = n; in hdsp_set_dds_value()
1130 hdsp_write(hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_set_dds_value()
1133 static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally) in hdsp_set_rate() argument
1144 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { in hdsp_set_rate()
1147 dev_err(hdsp->card->dev, in hdsp_set_rate()
1152 int external_freq = hdsp_external_sample_rate(hdsp); in hdsp_set_rate()
1153 int spdif_freq = hdsp_spdif_sample_rate(hdsp); in hdsp_set_rate()
1155 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) in hdsp_set_rate()
1156 dev_info(hdsp->card->dev, in hdsp_set_rate()
1158 …else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= … in hdsp_set_rate()
1159 dev_info(hdsp->card->dev, in hdsp_set_rate()
1162 dev_info(hdsp->card->dev, in hdsp_set_rate()
1169 current_rate = hdsp->system_sample_rate; in hdsp_set_rate()
1181 if (rate > 96000 && hdsp->io_type != H9632) in hdsp_set_rate()
1234 if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) { in hdsp_set_rate()
1235 dev_warn(hdsp->card->dev, in hdsp_set_rate()
1237 hdsp->capture_pid, in hdsp_set_rate()
1238 hdsp->playback_pid); in hdsp_set_rate()
1242 hdsp->control_register &= ~HDSP_FrequencyMask; in hdsp_set_rate()
1243 hdsp->control_register |= rate_bits; in hdsp_set_rate()
1244 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rate()
1247 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_set_rate()
1248 hdsp_set_dds_value(hdsp, rate); in hdsp_set_rate()
1251 hdsp->channel_map = channel_map_H9632_qs; in hdsp_set_rate()
1253 if (hdsp->io_type == H9632) in hdsp_set_rate()
1254 hdsp->channel_map = channel_map_H9632_ds; in hdsp_set_rate()
1256 hdsp->channel_map = channel_map_ds; in hdsp_set_rate()
1258 switch (hdsp->io_type) { in hdsp_set_rate()
1261 hdsp->channel_map = channel_map_mf_ss; in hdsp_set_rate()
1265 hdsp->channel_map = channel_map_df_ss; in hdsp_set_rate()
1268 hdsp->channel_map = channel_map_H9632_ss; in hdsp_set_rate()
1276 hdsp->system_sample_rate = rate; in hdsp_set_rate()
1285 static unsigned char snd_hdsp_midi_read_byte (struct hdsp *hdsp, int id) in snd_hdsp_midi_read_byte() argument
1289 return hdsp_read(hdsp, HDSP_midiDataIn1); in snd_hdsp_midi_read_byte()
1291 return hdsp_read(hdsp, HDSP_midiDataIn0); in snd_hdsp_midi_read_byte()
1294 static void snd_hdsp_midi_write_byte (struct hdsp *hdsp, int id, int val) in snd_hdsp_midi_write_byte() argument
1298 hdsp_write(hdsp, HDSP_midiDataOut1, val); in snd_hdsp_midi_write_byte()
1300 hdsp_write(hdsp, HDSP_midiDataOut0, val); in snd_hdsp_midi_write_byte()
1303 static int snd_hdsp_midi_input_available (struct hdsp *hdsp, int id) in snd_hdsp_midi_input_available() argument
1306 return (hdsp_read(hdsp, HDSP_midiStatusIn1) & 0xff); in snd_hdsp_midi_input_available()
1308 return (hdsp_read(hdsp, HDSP_midiStatusIn0) & 0xff); in snd_hdsp_midi_input_available()
1311 static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id) in snd_hdsp_midi_output_possible() argument
1316 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff; in snd_hdsp_midi_output_possible()
1318 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff; in snd_hdsp_midi_output_possible()
1326 static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id) in snd_hdsp_flush_midi_input() argument
1328 while (snd_hdsp_midi_input_available (hdsp, id)) in snd_hdsp_flush_midi_input()
1329 snd_hdsp_midi_read_byte (hdsp, id); in snd_hdsp_flush_midi_input()
1345 if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) { in snd_hdsp_midi_output_write()
1351 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); in snd_hdsp_midi_output_write()
1368 if ((n_pending = snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) > 0) { in snd_hdsp_midi_input_read()
1373 buf[i] = snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1379 snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1384 hmidi->hdsp->control_register |= HDSP_Midi1InterruptEnable; in snd_hdsp_midi_input_read()
1386 hmidi->hdsp->control_register |= HDSP_Midi0InterruptEnable; in snd_hdsp_midi_input_read()
1387 hdsp_write(hmidi->hdsp, HDSP_controlRegister, hmidi->hdsp->control_register); in snd_hdsp_midi_input_read()
1394 struct hdsp *hdsp; in snd_hdsp_midi_input_trigger() local
1400 hdsp = hmidi->hdsp; in snd_hdsp_midi_input_trigger()
1402 spin_lock_irqsave (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1404 if (!(hdsp->control_register & ie)) { in snd_hdsp_midi_input_trigger()
1405 snd_hdsp_flush_midi_input (hdsp, hmidi->id); in snd_hdsp_midi_input_trigger()
1406 hdsp->control_register |= ie; in snd_hdsp_midi_input_trigger()
1409 hdsp->control_register &= ~ie; in snd_hdsp_midi_input_trigger()
1410 tasklet_kill(&hdsp->midi_tasklet); in snd_hdsp_midi_input_trigger()
1413 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_midi_input_trigger()
1414 spin_unlock_irqrestore (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1466 snd_hdsp_flush_midi_input (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_open()
1527 static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id) in snd_hdsp_create_midi() argument
1531 hdsp->midi[id].id = id; in snd_hdsp_create_midi()
1532 hdsp->midi[id].rmidi = NULL; in snd_hdsp_create_midi()
1533 hdsp->midi[id].input = NULL; in snd_hdsp_create_midi()
1534 hdsp->midi[id].output = NULL; in snd_hdsp_create_midi()
1535 hdsp->midi[id].hdsp = hdsp; in snd_hdsp_create_midi()
1536 hdsp->midi[id].istimer = 0; in snd_hdsp_create_midi()
1537 hdsp->midi[id].pending = 0; in snd_hdsp_create_midi()
1538 spin_lock_init (&hdsp->midi[id].lock); in snd_hdsp_create_midi()
1541 if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) in snd_hdsp_create_midi()
1544 sprintf(hdsp->midi[id].rmidi->name, "HDSP MIDI %d", id+1); in snd_hdsp_create_midi()
1545 hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; in snd_hdsp_create_midi()
1547 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); in snd_hdsp_create_midi()
1548 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_hdsp_midi_input); in snd_hdsp_create_midi()
1550 hdsp->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | in snd_hdsp_create_midi()
1592 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_get() local
1594 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif); in snd_hdsp_control_spdif_get()
1600 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_put() local
1605 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1606 change = val != hdsp->creg_spdif; in snd_hdsp_control_spdif_put()
1607 hdsp->creg_spdif = val; in snd_hdsp_control_spdif_put()
1608 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1621 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_get() local
1623 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream); in snd_hdsp_control_spdif_stream_get()
1629 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_put() local
1634 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1635 change = val != hdsp->creg_spdif_stream; in snd_hdsp_control_spdif_stream_put()
1636 hdsp->creg_spdif_stream = val; in snd_hdsp_control_spdif_stream_put()
1637 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_control_spdif_stream_put()
1638 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= val); in snd_hdsp_control_spdif_stream_put()
1639 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1664 static unsigned int hdsp_spdif_in(struct hdsp *hdsp) in hdsp_spdif_in() argument
1666 return hdsp_decode_spdif_in(hdsp->control_register & HDSP_SPDIFInputMask); in hdsp_spdif_in()
1669 static int hdsp_set_spdif_input(struct hdsp *hdsp, int in) in hdsp_set_spdif_input() argument
1671 hdsp->control_register &= ~HDSP_SPDIFInputMask; in hdsp_set_spdif_input()
1672 hdsp->control_register |= hdsp_encode_spdif_in(in); in hdsp_set_spdif_input()
1673 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_spdif_input()
1682 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_in() local
1684 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 4 : 3, in snd_hdsp_info_spdif_in()
1690 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_in() local
1692 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); in snd_hdsp_get_spdif_in()
1698 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_spdif_in() local
1702 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_spdif_in()
1704 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3); in snd_hdsp_put_spdif_in()
1705 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1706 change = val != hdsp_spdif_in(hdsp); in snd_hdsp_put_spdif_in()
1708 hdsp_set_spdif_input(hdsp, val); in snd_hdsp_put_spdif_in()
1709 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1722 static int hdsp_toggle_setting(struct hdsp *hdsp, u32 regmask) in hdsp_toggle_setting() argument
1724 return (hdsp->control_register & regmask) ? 1 : 0; in hdsp_toggle_setting()
1727 static int hdsp_set_toggle_setting(struct hdsp *hdsp, u32 regmask, int out) in hdsp_set_toggle_setting() argument
1730 hdsp->control_register |= regmask; in hdsp_set_toggle_setting()
1732 hdsp->control_register &= ~regmask; in hdsp_set_toggle_setting()
1733 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_toggle_setting()
1743 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_toggle_setting() local
1746 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1747 ucontrol->value.integer.value[0] = hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_get_toggle_setting()
1748 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1755 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_toggle_setting() local
1760 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_toggle_setting()
1763 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1764 change = (int) val != hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_put_toggle_setting()
1766 hdsp_set_toggle_setting(hdsp, regmask, val); in snd_hdsp_put_toggle_setting()
1767 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1786 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_sample_rate() local
1788 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_spdif_sample_rate()
1794 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sample_rate() local
1796 switch (hdsp_spdif_sample_rate(hdsp)) { in snd_hdsp_get_spdif_sample_rate()
1848 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_sample_rate() local
1850 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; in snd_hdsp_get_system_sample_rate()
1865 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_autosync_sample_rate() local
1871 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_autosync_sample_rate()
1877 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_sample_rate() local
1879 switch (hdsp_external_sample_rate(hdsp)) { in snd_hdsp_get_autosync_sample_rate()
1922 static int hdsp_system_clock_mode(struct hdsp *hdsp) in hdsp_system_clock_mode() argument
1924 if (hdsp->control_register & HDSP_ClockModeMaster) in hdsp_system_clock_mode()
1926 else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) in hdsp_system_clock_mode()
1940 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_clock_mode() local
1942 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); in snd_hdsp_get_system_clock_mode()
1955 static int hdsp_clock_source(struct hdsp *hdsp) in hdsp_clock_source() argument
1957 if (hdsp->control_register & HDSP_ClockModeMaster) { in hdsp_clock_source()
1958 switch (hdsp->system_sample_rate) { in hdsp_clock_source()
1985 static int hdsp_set_clock_source(struct hdsp *hdsp, int mode) in hdsp_set_clock_source() argument
1990 if (hdsp_external_sample_rate(hdsp) != 0) { in hdsp_set_clock_source()
1991 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) { in hdsp_set_clock_source()
1992 hdsp->control_register &= ~HDSP_ClockModeMaster; in hdsp_set_clock_source()
1993 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2028 hdsp->control_register |= HDSP_ClockModeMaster; in hdsp_set_clock_source()
2029 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2030 hdsp_set_rate(hdsp, rate, 1); in hdsp_set_clock_source()
2042 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_clock_source() local
2044 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_clock_source()
2050 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source() local
2052 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); in snd_hdsp_get_clock_source()
2058 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source() local
2062 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_clock_source()
2066 if (hdsp->io_type == H9632) { in snd_hdsp_put_clock_source()
2073 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2074 if (val != hdsp_clock_source(hdsp)) in snd_hdsp_put_clock_source()
2075 change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_clock_source()
2078 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2086 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source_lock() local
2088 ucontrol->value.integer.value[0] = hdsp->clock_source_locked; in snd_hdsp_get_clock_source_lock()
2094 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source_lock() local
2097 change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked; in snd_hdsp_put_clock_source_lock()
2099 hdsp->clock_source_locked = !!ucontrol->value.integer.value[0]; in snd_hdsp_put_clock_source_lock()
2112 static int hdsp_da_gain(struct hdsp *hdsp) in hdsp_da_gain() argument
2114 switch (hdsp->control_register & HDSP_DAGainMask) { in hdsp_da_gain()
2126 static int hdsp_set_da_gain(struct hdsp *hdsp, int mode) in hdsp_set_da_gain() argument
2128 hdsp->control_register &= ~HDSP_DAGainMask; in hdsp_set_da_gain()
2131 hdsp->control_register |= HDSP_DAGainHighGain; in hdsp_set_da_gain()
2134 hdsp->control_register |= HDSP_DAGainPlus4dBu; in hdsp_set_da_gain()
2137 hdsp->control_register |= HDSP_DAGainMinus10dBV; in hdsp_set_da_gain()
2143 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_da_gain()
2156 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_da_gain() local
2158 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp); in snd_hdsp_get_da_gain()
2164 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_da_gain() local
2168 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_da_gain()
2173 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2174 if (val != hdsp_da_gain(hdsp)) in snd_hdsp_put_da_gain()
2175 change = (hdsp_set_da_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_da_gain()
2178 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2191 static int hdsp_ad_gain(struct hdsp *hdsp) in hdsp_ad_gain() argument
2193 switch (hdsp->control_register & HDSP_ADGainMask) { in hdsp_ad_gain()
2205 static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode) in hdsp_set_ad_gain() argument
2207 hdsp->control_register &= ~HDSP_ADGainMask; in hdsp_set_ad_gain()
2210 hdsp->control_register |= HDSP_ADGainMinus10dBV; in hdsp_set_ad_gain()
2213 hdsp->control_register |= HDSP_ADGainPlus4dBu; in hdsp_set_ad_gain()
2216 hdsp->control_register |= HDSP_ADGainLowGain; in hdsp_set_ad_gain()
2222 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_ad_gain()
2235 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_ad_gain() local
2237 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp); in snd_hdsp_get_ad_gain()
2243 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_ad_gain() local
2247 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_ad_gain()
2252 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2253 if (val != hdsp_ad_gain(hdsp)) in snd_hdsp_put_ad_gain()
2254 change = (hdsp_set_ad_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_ad_gain()
2257 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2270 static int hdsp_phone_gain(struct hdsp *hdsp) in hdsp_phone_gain() argument
2272 switch (hdsp->control_register & HDSP_PhoneGainMask) { in hdsp_phone_gain()
2284 static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode) in hdsp_set_phone_gain() argument
2286 hdsp->control_register &= ~HDSP_PhoneGainMask; in hdsp_set_phone_gain()
2289 hdsp->control_register |= HDSP_PhoneGain0dB; in hdsp_set_phone_gain()
2292 hdsp->control_register |= HDSP_PhoneGainMinus6dB; in hdsp_set_phone_gain()
2295 hdsp->control_register |= HDSP_PhoneGainMinus12dB; in hdsp_set_phone_gain()
2301 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_phone_gain()
2314 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_phone_gain() local
2316 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp); in snd_hdsp_get_phone_gain()
2322 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_phone_gain() local
2326 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_phone_gain()
2331 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2332 if (val != hdsp_phone_gain(hdsp)) in snd_hdsp_put_phone_gain()
2333 change = (hdsp_set_phone_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_phone_gain()
2336 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2349 static int hdsp_pref_sync_ref(struct hdsp *hdsp) in hdsp_pref_sync_ref() argument
2355 switch (hdsp->control_register & HDSP_SyncRefMask) { in hdsp_pref_sync_ref()
2374 static int hdsp_set_pref_sync_ref(struct hdsp *hdsp, int pref) in hdsp_set_pref_sync_ref() argument
2376 hdsp->control_register &= ~HDSP_SyncRefMask; in hdsp_set_pref_sync_ref()
2379 hdsp->control_register &= ~HDSP_SyncRefMask; /* clear SyncRef bits */ in hdsp_set_pref_sync_ref()
2382 hdsp->control_register |= HDSP_SyncRef_ADAT2; in hdsp_set_pref_sync_ref()
2385 hdsp->control_register |= HDSP_SyncRef_ADAT3; in hdsp_set_pref_sync_ref()
2388 hdsp->control_register |= HDSP_SyncRef_SPDIF; in hdsp_set_pref_sync_ref()
2391 hdsp->control_register |= HDSP_SyncRef_WORD; in hdsp_set_pref_sync_ref()
2394 hdsp->control_register |= HDSP_SyncRef_ADAT_SYNC; in hdsp_set_pref_sync_ref()
2399 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_pref_sync_ref()
2408 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_pref_sync_ref() local
2411 switch (hdsp->io_type) { in snd_hdsp_info_pref_sync_ref()
2431 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_pref_sync_ref() local
2433 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); in snd_hdsp_get_pref_sync_ref()
2439 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_pref_sync_ref() local
2443 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_pref_sync_ref()
2446 switch (hdsp->io_type) { in snd_hdsp_put_pref_sync_ref()
2462 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2463 change = (int)val != hdsp_pref_sync_ref(hdsp); in snd_hdsp_put_pref_sync_ref()
2464 hdsp_set_pref_sync_ref(hdsp, val); in snd_hdsp_put_pref_sync_ref()
2465 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2478 static int hdsp_autosync_ref(struct hdsp *hdsp) in hdsp_autosync_ref() argument
2481 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_autosync_ref()
2515 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_ref() local
2517 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp); in snd_hdsp_get_autosync_ref()
2530 static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise) in hdsp_set_precise_pointer() argument
2533 hdsp->precise_ptr = 1; in hdsp_set_precise_pointer()
2535 hdsp->precise_ptr = 0; in hdsp_set_precise_pointer()
2543 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_precise_pointer() local
2545 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2546 ucontrol->value.integer.value[0] = hdsp->precise_ptr; in snd_hdsp_get_precise_pointer()
2547 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2553 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_precise_pointer() local
2557 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_precise_pointer()
2560 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2561 change = (int)val != hdsp->precise_ptr; in snd_hdsp_put_precise_pointer()
2562 hdsp_set_precise_pointer(hdsp, val); in snd_hdsp_put_precise_pointer()
2563 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2576 static int hdsp_set_use_midi_tasklet(struct hdsp *hdsp, int use_tasklet) in hdsp_set_use_midi_tasklet() argument
2579 hdsp->use_midi_tasklet = 1; in hdsp_set_use_midi_tasklet()
2581 hdsp->use_midi_tasklet = 0; in hdsp_set_use_midi_tasklet()
2589 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_use_midi_tasklet() local
2591 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_tasklet()
2592 ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet; in snd_hdsp_get_use_midi_tasklet()
2593 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_tasklet()
2599 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_use_midi_tasklet() local
2603 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_use_midi_tasklet()
2606 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_tasklet()
2607 change = (int)val != hdsp->use_midi_tasklet; in snd_hdsp_put_use_midi_tasklet()
2608 hdsp_set_use_midi_tasklet(hdsp, val); in snd_hdsp_put_use_midi_tasklet()
2609 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_tasklet()
2637 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_mixer() local
2645 if (source >= hdsp->max_channels) in snd_hdsp_get_mixer()
2646 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination); in snd_hdsp_get_mixer()
2648 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_get_mixer()
2650 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2651 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr); in snd_hdsp_get_mixer()
2652 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2658 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_mixer() local
2665 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_mixer()
2671 if (source >= hdsp->max_channels) in snd_hdsp_put_mixer()
2672 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels, destination); in snd_hdsp_put_mixer()
2674 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_put_mixer()
2678 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2679 change = gain != hdsp_read_gain(hdsp, addr); in snd_hdsp_put_mixer()
2681 hdsp_write_gain(hdsp, addr, gain); in snd_hdsp_put_mixer()
2682 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2702 static int hdsp_wc_sync_check(struct hdsp *hdsp) in hdsp_wc_sync_check() argument
2704 int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_wc_sync_check()
2717 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_wc_sync_check() local
2719 ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp); in snd_hdsp_get_wc_sync_check()
2732 static int hdsp_spdif_sync_check(struct hdsp *hdsp) in hdsp_spdif_sync_check() argument
2734 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sync_check()
2748 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sync_check() local
2750 ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp); in snd_hdsp_get_spdif_sync_check()
2763 static int hdsp_adatsync_sync_check(struct hdsp *hdsp) in hdsp_adatsync_sync_check() argument
2765 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adatsync_sync_check()
2777 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adatsync_sync_check() local
2779 ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp); in snd_hdsp_get_adatsync_sync_check()
2790 static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx) in hdsp_adat_sync_check() argument
2792 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adat_sync_check()
2806 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adat_sync_check() local
2812 switch (hdsp->io_type) { in snd_hdsp_get_adat_sync_check()
2827 ucontrol->value.enumerated.item[0] = hdsp_adat_sync_check(hdsp, offset); in snd_hdsp_get_adat_sync_check()
2840 static int hdsp_dds_offset(struct hdsp *hdsp) in hdsp_dds_offset() argument
2843 unsigned int dds_value = hdsp->dds_value; in hdsp_dds_offset()
2844 int system_sample_rate = hdsp->system_sample_rate; in hdsp_dds_offset()
2862 static int hdsp_set_dds_offset(struct hdsp *hdsp, int offset_hz) in hdsp_set_dds_offset() argument
2864 int rate = hdsp->system_sample_rate + offset_hz; in hdsp_set_dds_offset()
2865 hdsp_set_dds_value(hdsp, rate); in hdsp_set_dds_offset()
2880 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_dds_offset() local
2882 ucontrol->value.integer.value[0] = hdsp_dds_offset(hdsp); in snd_hdsp_get_dds_offset()
2888 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_dds_offset() local
2892 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_dds_offset()
2895 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2896 if (val != hdsp_dds_offset(hdsp)) in snd_hdsp_put_dds_offset()
2897 change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_dds_offset()
2900 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2979 static int hdsp_rpm_input12(struct hdsp *hdsp) in hdsp_rpm_input12() argument
2981 switch (hdsp->control_register & HDSP_RPM_Inp12) { in hdsp_rpm_input12()
2997 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input12() local
2999 ucontrol->value.enumerated.item[0] = hdsp_rpm_input12(hdsp); in snd_hdsp_get_rpm_input12()
3004 static int hdsp_set_rpm_input12(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input12() argument
3006 hdsp->control_register &= ~HDSP_RPM_Inp12; in hdsp_set_rpm_input12()
3009 hdsp->control_register |= HDSP_RPM_Inp12_Phon_6dB; in hdsp_set_rpm_input12()
3014 hdsp->control_register |= HDSP_RPM_Inp12_Phon_n6dB; in hdsp_set_rpm_input12()
3017 hdsp->control_register |= HDSP_RPM_Inp12_Line_0dB; in hdsp_set_rpm_input12()
3020 hdsp->control_register |= HDSP_RPM_Inp12_Line_n6dB; in hdsp_set_rpm_input12()
3026 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input12()
3033 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input12() local
3037 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input12()
3044 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3045 if (val != hdsp_rpm_input12(hdsp)) in snd_hdsp_put_rpm_input12()
3046 change = (hdsp_set_rpm_input12(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input12()
3049 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3064 static int hdsp_rpm_input34(struct hdsp *hdsp) in hdsp_rpm_input34() argument
3066 switch (hdsp->control_register & HDSP_RPM_Inp34) { in hdsp_rpm_input34()
3082 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input34() local
3084 ucontrol->value.enumerated.item[0] = hdsp_rpm_input34(hdsp); in snd_hdsp_get_rpm_input34()
3089 static int hdsp_set_rpm_input34(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input34() argument
3091 hdsp->control_register &= ~HDSP_RPM_Inp34; in hdsp_set_rpm_input34()
3094 hdsp->control_register |= HDSP_RPM_Inp34_Phon_6dB; in hdsp_set_rpm_input34()
3099 hdsp->control_register |= HDSP_RPM_Inp34_Phon_n6dB; in hdsp_set_rpm_input34()
3102 hdsp->control_register |= HDSP_RPM_Inp34_Line_0dB; in hdsp_set_rpm_input34()
3105 hdsp->control_register |= HDSP_RPM_Inp34_Line_n6dB; in hdsp_set_rpm_input34()
3111 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input34()
3118 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input34() local
3122 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input34()
3129 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3130 if (val != hdsp_rpm_input34(hdsp)) in snd_hdsp_put_rpm_input34()
3131 change = (hdsp_set_rpm_input34(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input34()
3134 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3140 static int hdsp_rpm_bypass(struct hdsp *hdsp) in hdsp_rpm_bypass() argument
3142 return (hdsp->control_register & HDSP_RPM_Bypass) ? 1 : 0; in hdsp_rpm_bypass()
3148 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_bypass() local
3150 ucontrol->value.integer.value[0] = hdsp_rpm_bypass(hdsp); in snd_hdsp_get_rpm_bypass()
3155 static int hdsp_set_rpm_bypass(struct hdsp *hdsp, int on) in hdsp_set_rpm_bypass() argument
3158 hdsp->control_register |= HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3160 hdsp->control_register &= ~HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3161 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_bypass()
3168 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_bypass() local
3172 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_bypass()
3175 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3176 change = (int)val != hdsp_rpm_bypass(hdsp); in snd_hdsp_put_rpm_bypass()
3177 hdsp_set_rpm_bypass(hdsp, val); in snd_hdsp_put_rpm_bypass()
3178 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3192 static int hdsp_rpm_disconnect(struct hdsp *hdsp) in hdsp_rpm_disconnect() argument
3194 return (hdsp->control_register & HDSP_RPM_Disconnect) ? 1 : 0; in hdsp_rpm_disconnect()
3200 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_disconnect() local
3202 ucontrol->value.integer.value[0] = hdsp_rpm_disconnect(hdsp); in snd_hdsp_get_rpm_disconnect()
3207 static int hdsp_set_rpm_disconnect(struct hdsp *hdsp, int on) in hdsp_set_rpm_disconnect() argument
3210 hdsp->control_register |= HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3212 hdsp->control_register &= ~HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3213 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_disconnect()
3220 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_disconnect() local
3224 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_disconnect()
3227 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3228 change = (int)val != hdsp_rpm_disconnect(hdsp); in snd_hdsp_put_rpm_disconnect()
3229 hdsp_set_rpm_disconnect(hdsp, val); in snd_hdsp_put_rpm_disconnect()
3230 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3279 static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_controls() argument
3285 if (hdsp->io_type == RPM) { in snd_hdsp_create_controls()
3288 err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_rpm_controls[idx], hdsp)); in snd_hdsp_create_controls()
3296 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0) in snd_hdsp_create_controls()
3299 hdsp->spdif_ctl = kctl; in snd_hdsp_create_controls()
3305 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) in snd_hdsp_create_controls()
3307 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3310 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) in snd_hdsp_create_controls()
3316 if (hdsp->io_type == H9632) { in snd_hdsp_create_controls()
3318 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0) in snd_hdsp_create_controls()
3324 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3325 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0) in snd_hdsp_create_controls()
3339 struct hdsp *hdsp = entry->private_data; in snd_hdsp_proc_read() local
3348 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_proc_read()
3349 status2 = hdsp_read(hdsp, HDSP_status2Register); in snd_hdsp_proc_read()
3351 snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, in snd_hdsp_proc_read()
3352 hdsp->card->number + 1); in snd_hdsp_proc_read()
3354 hdsp->capture_buffer, hdsp->playback_buffer); in snd_hdsp_proc_read()
3356 hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); in snd_hdsp_proc_read()
3357 snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); in snd_hdsp_proc_read()
3359 hdsp->control2_register); in snd_hdsp_proc_read()
3363 if (hdsp_check_for_iobox(hdsp)) { in snd_hdsp_proc_read()
3369 if (hdsp_check_for_firmware(hdsp, 0)) { in snd_hdsp_proc_read()
3370 if (hdsp->state & HDSP_FirmwareCached) { in snd_hdsp_proc_read()
3371 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in snd_hdsp_proc_read()
3379 err = hdsp_request_fw_loader(hdsp); in snd_hdsp_proc_read()
3389 snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); in snd_hdsp_proc_read()
3390 snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); in snd_hdsp_proc_read()
3391 snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); in snd_hdsp_proc_read()
3392 snd_iprintf(buffer, "MIDI2 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut1)); in snd_hdsp_proc_read()
3393 snd_iprintf(buffer, "MIDI2 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn1)); in snd_hdsp_proc_read()
3394 snd_iprintf(buffer, "Use Midi Tasklet: %s\n", hdsp->use_midi_tasklet ? "on" : "off"); in snd_hdsp_proc_read()
3398 x = 1 << (6 + hdsp_decode_latency(hdsp->control_register & HDSP_LatencyMask)); in snd_hdsp_proc_read()
3400 …fer Size (Latency): %d samples (2 periods of %lu bytes)\n", x, (unsigned long) hdsp->period_bytes); in snd_hdsp_proc_read()
3401 snd_iprintf(buffer, "Hardware pointer (frames): %ld\n", hdsp_hw_pointer(hdsp)); in snd_hdsp_proc_read()
3402 snd_iprintf(buffer, "Precise pointer: %s\n", hdsp->precise_ptr ? "on" : "off"); in snd_hdsp_proc_read()
3403 snd_iprintf(buffer, "Line out: %s\n", (hdsp->control_register & HDSP_LineOut) ? "on" : "off"); in snd_hdsp_proc_read()
3409 switch (hdsp_clock_source(hdsp)) { in snd_hdsp_proc_read()
3445 if (hdsp_system_clock_mode(hdsp)) in snd_hdsp_proc_read()
3450 switch (hdsp_pref_sync_ref (hdsp)) { in snd_hdsp_proc_read()
3475 switch (hdsp_autosync_ref (hdsp)) { in snd_hdsp_proc_read()
3503 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp)); in snd_hdsp_proc_read()
3507 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); in snd_hdsp_proc_read()
3508 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); in snd_hdsp_proc_read()
3512 if (hdsp->io_type != RPM) { in snd_hdsp_proc_read()
3513 switch (hdsp_spdif_in(hdsp)) { in snd_hdsp_proc_read()
3532 if (RPM == hdsp->io_type) { in snd_hdsp_proc_read()
3533 if (hdsp->control_register & HDSP_RPM_Bypass) in snd_hdsp_proc_read()
3537 if (hdsp->control_register & HDSP_RPM_Disconnect) in snd_hdsp_proc_read()
3542 switch (hdsp->control_register & HDSP_RPM_Inp12) { in snd_hdsp_proc_read()
3562 switch (hdsp->control_register & HDSP_RPM_Inp34) { in snd_hdsp_proc_read()
3583 if (hdsp->control_register & HDSP_SPDIFOpticalOut) in snd_hdsp_proc_read()
3588 if (hdsp->control_register & HDSP_SPDIFProfessional) in snd_hdsp_proc_read()
3593 if (hdsp->control_register & HDSP_SPDIFEmphasis) in snd_hdsp_proc_read()
3598 if (hdsp->control_register & HDSP_SPDIFNonAudio) in snd_hdsp_proc_read()
3602 x = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_proc_read()
3617 switch (hdsp->io_type) { in snd_hdsp_proc_read()
3657 if (hdsp->io_type == H9632) { in snd_hdsp_proc_read()
3660 switch (hdsp_ad_gain(hdsp)) { in snd_hdsp_proc_read()
3673 switch (hdsp_da_gain(hdsp)) { in snd_hdsp_proc_read()
3686 switch (hdsp_phone_gain(hdsp)) { in snd_hdsp_proc_read()
3700 hdsp_toggle_setting(hdsp, HDSP_XLRBreakoutCable) ? in snd_hdsp_proc_read()
3703 if (hdsp->control_register & HDSP_AnalogExtensionBoard) in snd_hdsp_proc_read()
3712 static void snd_hdsp_proc_init(struct hdsp *hdsp) in snd_hdsp_proc_init() argument
3716 if (! snd_card_proc_new(hdsp->card, "hdsp", &entry)) in snd_hdsp_proc_init()
3717 snd_info_set_text_ops(entry, hdsp, snd_hdsp_proc_read); in snd_hdsp_proc_init()
3720 static void snd_hdsp_free_buffers(struct hdsp *hdsp) in snd_hdsp_free_buffers() argument
3722 snd_hammerfall_free_buffer(&hdsp->capture_dma_buf, hdsp->pci); in snd_hdsp_free_buffers()
3723 snd_hammerfall_free_buffer(&hdsp->playback_dma_buf, hdsp->pci); in snd_hdsp_free_buffers()
3726 static int snd_hdsp_initialize_memory(struct hdsp *hdsp) in snd_hdsp_initialize_memory() argument
3730 if (snd_hammerfall_get_buffer(hdsp->pci, &hdsp->capture_dma_buf, HDSP_DMA_AREA_BYTES) < 0 || in snd_hdsp_initialize_memory()
3731 snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) { in snd_hdsp_initialize_memory()
3732 if (hdsp->capture_dma_buf.area) in snd_hdsp_initialize_memory()
3733 snd_dma_free_pages(&hdsp->capture_dma_buf); in snd_hdsp_initialize_memory()
3734 dev_err(hdsp->card->dev, in snd_hdsp_initialize_memory()
3735 "%s: no buffers available\n", hdsp->card_name); in snd_hdsp_initialize_memory()
3741 cb_bus = ALIGN(hdsp->capture_dma_buf.addr, 0x10000ul); in snd_hdsp_initialize_memory()
3742 pb_bus = ALIGN(hdsp->playback_dma_buf.addr, 0x10000ul); in snd_hdsp_initialize_memory()
3746 hdsp_write(hdsp, HDSP_inputBufferAddress, cb_bus); in snd_hdsp_initialize_memory()
3747 hdsp_write(hdsp, HDSP_outputBufferAddress, pb_bus); in snd_hdsp_initialize_memory()
3749 hdsp->capture_buffer = hdsp->capture_dma_buf.area + (cb_bus - hdsp->capture_dma_buf.addr); in snd_hdsp_initialize_memory()
3750 hdsp->playback_buffer = hdsp->playback_dma_buf.area + (pb_bus - hdsp->playback_dma_buf.addr); in snd_hdsp_initialize_memory()
3755 static int snd_hdsp_set_defaults(struct hdsp *hdsp) in snd_hdsp_set_defaults() argument
3773 hdsp->control_register = HDSP_ClockModeMaster | in snd_hdsp_set_defaults()
3779 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3782 hdsp->control2_register = HDSP_BIGENDIAN_MODE; in snd_hdsp_set_defaults()
3784 hdsp->control2_register = 0; in snd_hdsp_set_defaults()
3786 if (hdsp->io_type == H9652) in snd_hdsp_set_defaults()
3787 snd_hdsp_9652_enable_mixer (hdsp); in snd_hdsp_set_defaults()
3789 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_set_defaults()
3791 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_set_defaults()
3792 hdsp_compute_period_size(hdsp); in snd_hdsp_set_defaults()
3797 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN; in snd_hdsp_set_defaults()
3799 …for (i = 0; i < ((hdsp->io_type == H9652 || hdsp->io_type == H9632) ? 1352 : HDSP_MATRIX_MIXER_SIZ… in snd_hdsp_set_defaults()
3800 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) in snd_hdsp_set_defaults()
3805 if (hdsp->io_type == H9632) { in snd_hdsp_set_defaults()
3806 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB); in snd_hdsp_set_defaults()
3807 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3813 hdsp_set_rate(hdsp, 48000, 1); in snd_hdsp_set_defaults()
3820 struct hdsp *hdsp = (struct hdsp *)arg; in hdsp_midi_tasklet() local
3822 if (hdsp->midi[0].pending) in hdsp_midi_tasklet()
3823 snd_hdsp_midi_input_read (&hdsp->midi[0]); in hdsp_midi_tasklet()
3824 if (hdsp->midi[1].pending) in hdsp_midi_tasklet()
3825 snd_hdsp_midi_input_read (&hdsp->midi[1]); in hdsp_midi_tasklet()
3830 struct hdsp *hdsp = (struct hdsp *) dev_id; in snd_hdsp_interrupt() local
3839 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_interrupt()
3848 hdsp_write(hdsp, HDSP_interruptConfirmation, 0); in snd_hdsp_interrupt()
3850 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff; in snd_hdsp_interrupt()
3851 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff; in snd_hdsp_interrupt()
3853 if (!(hdsp->state & HDSP_InitializationComplete)) in snd_hdsp_interrupt()
3857 if (hdsp->capture_substream) in snd_hdsp_interrupt()
3858 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); in snd_hdsp_interrupt()
3860 if (hdsp->playback_substream) in snd_hdsp_interrupt()
3861 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); in snd_hdsp_interrupt()
3865 if (hdsp->use_midi_tasklet) { in snd_hdsp_interrupt()
3867 hdsp->control_register &= ~HDSP_Midi0InterruptEnable; in snd_hdsp_interrupt()
3868 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3869 hdsp->midi[0].pending = 1; in snd_hdsp_interrupt()
3872 snd_hdsp_midi_input_read (&hdsp->midi[0]); in snd_hdsp_interrupt()
3875 …if (hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632 && midi1 && midi1… in snd_hdsp_interrupt()
3876 if (hdsp->use_midi_tasklet) { in snd_hdsp_interrupt()
3878 hdsp->control_register &= ~HDSP_Midi1InterruptEnable; in snd_hdsp_interrupt()
3879 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3880 hdsp->midi[1].pending = 1; in snd_hdsp_interrupt()
3883 snd_hdsp_midi_input_read (&hdsp->midi[1]); in snd_hdsp_interrupt()
3886 if (hdsp->use_midi_tasklet && schedule) in snd_hdsp_interrupt()
3887 tasklet_schedule(&hdsp->midi_tasklet); in snd_hdsp_interrupt()
3893 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_pointer() local
3894 return hdsp_hw_pointer(hdsp); in snd_hdsp_hw_pointer()
3897 static char *hdsp_channel_buffer_location(struct hdsp *hdsp, in hdsp_channel_buffer_location() argument
3904 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels)) in hdsp_channel_buffer_location()
3907 if ((mapped_channel = hdsp->channel_map[channel]) < 0) in hdsp_channel_buffer_location()
3911 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3913 return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3919 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_copy() local
3925 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_playback_copy()
3936 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_copy() local
3942 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_capture_copy()
3953 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_silence() local
3956 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_hw_silence()
3966 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_reset() local
3969 other = hdsp->capture_substream; in snd_hdsp_reset()
3971 other = hdsp->playback_substream; in snd_hdsp_reset()
3972 if (hdsp->running) in snd_hdsp_reset()
3973 runtime->status->hw_ptr = hdsp_hw_pointer(hdsp); in snd_hdsp_reset()
3992 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_params() local
3997 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hw_params()
4000 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_hw_params()
4003 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4006 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_hw_params()
4007 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= hdsp->creg_spdif_stream); in snd_hdsp_hw_params()
4008 this_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4009 other_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4011 this_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4012 other_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4022 if (params_rate(params) != hdsp->system_sample_rate) { in snd_hdsp_hw_params()
4023 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4028 if (params_period_size(params) != hdsp->period_bytes / 4) { in snd_hdsp_hw_params()
4029 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4036 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4040 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4046 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4047 if (! hdsp->clock_source_locked) { in snd_hdsp_hw_params()
4048 if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { in snd_hdsp_hw_params()
4049 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4054 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4056 if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) { in snd_hdsp_hw_params()
4067 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_channel_info() local
4070 if (snd_BUG_ON(info->channel >= hdsp->max_channels)) in snd_hdsp_channel_info()
4073 if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) in snd_hdsp_channel_info()
4099 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_trigger() local
4103 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_trigger()
4106 if (hdsp_check_for_firmware(hdsp, 0)) /* no auto-loading in trigger */ in snd_hdsp_trigger()
4109 spin_lock(&hdsp->lock); in snd_hdsp_trigger()
4110 running = hdsp->running; in snd_hdsp_trigger()
4120 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4124 other = hdsp->capture_substream; in snd_hdsp_trigger()
4126 other = hdsp->playback_substream; in snd_hdsp_trigger()
4143 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4147 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4151 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4155 if (!hdsp->running && running) in snd_hdsp_trigger()
4156 hdsp_start_audio(hdsp); in snd_hdsp_trigger()
4157 else if (hdsp->running && !running) in snd_hdsp_trigger()
4158 hdsp_stop_audio(hdsp); in snd_hdsp_trigger()
4159 hdsp->running = running; in snd_hdsp_trigger()
4160 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4167 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_prepare() local
4170 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_prepare()
4173 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_prepare()
4176 spin_lock_irq(&hdsp->lock); in snd_hdsp_prepare()
4177 if (!hdsp->running) in snd_hdsp_prepare()
4178 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_prepare()
4179 spin_unlock_irq(&hdsp->lock); in snd_hdsp_prepare()
4261 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels() local
4263 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels()
4265 list[0] = hdsp->qs_in_channels; in snd_hdsp_hw_rule_in_channels()
4266 list[1] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4267 list[2] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4271 list[0] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4272 list[1] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4281 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels() local
4283 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels()
4284 list[0] = hdsp->qs_out_channels; in snd_hdsp_hw_rule_out_channels()
4285 list[1] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4286 list[2] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4289 list[0] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4290 list[1] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4298 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels_rate() local
4301 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels_rate()
4303 .min = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4304 .max = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4310 .min = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4311 .max = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4317 .min = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4318 .max = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4329 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels_rate() local
4332 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels_rate()
4334 .min = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4335 .max = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4341 .min = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4342 .max = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4348 .min = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4349 .max = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4360 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_out_channels() local
4363 if (c->min >= hdsp->ss_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4370 } else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_out_channels()
4377 } else if (c->max <= hdsp->ds_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4391 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_in_channels() local
4394 if (c->min >= hdsp->ss_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4401 } else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_in_channels()
4408 } else if (c->max <= hdsp->ds_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4421 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_open() local
4424 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_playback_open()
4427 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_playback_open()
4430 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4435 runtime->dma_area = hdsp->playback_buffer; in snd_hdsp_playback_open()
4438 hdsp->playback_pid = current->pid; in snd_hdsp_playback_open()
4439 hdsp->playback_substream = substream; in snd_hdsp_playback_open()
4441 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4445 if (hdsp->clock_source_locked) { in snd_hdsp_playback_open()
4446 runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate; in snd_hdsp_playback_open()
4447 } else if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4452 if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4453 runtime->hw.channels_min = hdsp->qs_out_channels; in snd_hdsp_playback_open()
4454 runtime->hw.channels_max = hdsp->ss_out_channels; in snd_hdsp_playback_open()
4458 snd_hdsp_hw_rule_out_channels, hdsp, in snd_hdsp_playback_open()
4461 snd_hdsp_hw_rule_out_channels_rate, hdsp, in snd_hdsp_playback_open()
4464 snd_hdsp_hw_rule_rate_out_channels, hdsp, in snd_hdsp_playback_open()
4467 if (RPM != hdsp->io_type) { in snd_hdsp_playback_open()
4468 hdsp->creg_spdif_stream = hdsp->creg_spdif; in snd_hdsp_playback_open()
4469 hdsp->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_open()
4470 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_open()
4471 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_open()
4478 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_release() local
4480 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4482 hdsp->playback_pid = -1; in snd_hdsp_playback_release()
4483 hdsp->playback_substream = NULL; in snd_hdsp_playback_release()
4485 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4487 if (RPM != hdsp->io_type) { in snd_hdsp_playback_release()
4488 hdsp->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_release()
4489 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_release()
4490 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_release()
4498 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_open() local
4501 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_capture_open()
4504 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_capture_open()
4507 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4512 runtime->dma_area = hdsp->capture_buffer; in snd_hdsp_capture_open()
4515 hdsp->capture_pid = current->pid; in snd_hdsp_capture_open()
4516 hdsp->capture_substream = substream; in snd_hdsp_capture_open()
4518 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4522 if (hdsp->io_type == H9632) { in snd_hdsp_capture_open()
4523 runtime->hw.channels_min = hdsp->qs_in_channels; in snd_hdsp_capture_open()
4524 runtime->hw.channels_max = hdsp->ss_in_channels; in snd_hdsp_capture_open()
4530 snd_hdsp_hw_rule_in_channels, hdsp, in snd_hdsp_capture_open()
4533 snd_hdsp_hw_rule_in_channels_rate, hdsp, in snd_hdsp_capture_open()
4536 snd_hdsp_hw_rule_rate_in_channels, hdsp, in snd_hdsp_capture_open()
4543 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_release() local
4545 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4547 hdsp->capture_pid = -1; in snd_hdsp_capture_release()
4548 hdsp->capture_substream = NULL; in snd_hdsp_capture_release()
4550 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4581 static int hdsp_9652_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9652_get_peak() argument
4586 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9652_get_peak()
4593 if (copy_u32_le(&peak_rms->input_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4596 if (copy_u32_le(&peak_rms->playback_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4599 if (copy_u32_le(&peak_rms->output_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4602 if (copy_u48_le(&peak_rms->input_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4603 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4606 if (copy_u48_le(&peak_rms->playback_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4607 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4610 if (copy_u48_le(&peak_rms->output_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4611 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4618 static int hdsp_9632_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9632_get_peak() argument
4624 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9632_get_peak()
4626 m = (struct hdsp_9632_meters __iomem *)(hdsp->iobase+HDSP_9632_metersBase); in hdsp_9632_get_peak()
4648 static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_get_peak() argument
4654 hdsp->iobase + HDSP_playbackPeakLevel + i * 4)) in hdsp_get_peak()
4657 hdsp->iobase + HDSP_inputPeakLevel + i * 4)) in hdsp_get_peak()
4662 hdsp->iobase + HDSP_outputPeakLevel + i * 4)) in hdsp_get_peak()
4667 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4, in hdsp_get_peak()
4668 hdsp->iobase + HDSP_playbackRmsLevel + i * 8)) in hdsp_get_peak()
4671 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4, in hdsp_get_peak()
4672 hdsp->iobase + HDSP_inputRmsLevel + i * 8)) in hdsp_get_peak()
4680 struct hdsp *hdsp = hw->private_data; in snd_hdsp_hwdep_ioctl() local
4688 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4692 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4696 if (!(hdsp->state & HDSP_FirmwareLoaded)) { in snd_hdsp_hwdep_ioctl()
4697 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4702 switch (hdsp->io_type) { in snd_hdsp_hwdep_ioctl()
4704 return hdsp_9652_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4706 return hdsp_9632_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4708 return hdsp_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4716 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4720 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4725 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4726 info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4727 info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4728 if (hdsp->io_type != H9632) in snd_hdsp_hwdep_ioctl()
4729 info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4730 info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4731 …for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632) ? … in snd_hdsp_hwdep_ioctl()
4732 info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i); in snd_hdsp_hwdep_ioctl()
4733 info.spdif_in = (unsigned char)hdsp_spdif_in(hdsp); in snd_hdsp_hwdep_ioctl()
4734 info.spdif_out = (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4737 hdsp_toggle_setting(hdsp, HDSP_SPDIFProfessional); in snd_hdsp_hwdep_ioctl()
4739 hdsp_toggle_setting(hdsp, HDSP_SPDIFEmphasis); in snd_hdsp_hwdep_ioctl()
4741 hdsp_toggle_setting(hdsp, HDSP_SPDIFNonAudio); in snd_hdsp_hwdep_ioctl()
4742 info.spdif_sample_rate = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4743 info.system_sample_rate = hdsp->system_sample_rate; in snd_hdsp_hwdep_ioctl()
4744 info.autosync_sample_rate = hdsp_external_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4745 info.system_clock_mode = (unsigned char)hdsp_system_clock_mode(hdsp); in snd_hdsp_hwdep_ioctl()
4746 info.clock_source = (unsigned char)hdsp_clock_source(hdsp); in snd_hdsp_hwdep_ioctl()
4747 info.autosync_ref = (unsigned char)hdsp_autosync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4749 hdsp_toggle_setting(hdsp, HDSP_LineOut); in snd_hdsp_hwdep_ioctl()
4750 if (hdsp->io_type == H9632) { in snd_hdsp_hwdep_ioctl()
4751 info.da_gain = (unsigned char)hdsp_da_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4752 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4753 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4755 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4758 } else if (hdsp->io_type == RPM) { in snd_hdsp_hwdep_ioctl()
4759 info.da_gain = (unsigned char) hdsp_rpm_input12(hdsp); in snd_hdsp_hwdep_ioctl()
4760 info.ad_gain = (unsigned char) hdsp_rpm_input34(hdsp); in snd_hdsp_hwdep_ioctl()
4762 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) in snd_hdsp_hwdep_ioctl()
4764 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4766 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4774 if (hdsp->io_type != H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4775 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4776 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4785 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4786 if (hdsp->io_type == Undefined) { in snd_hdsp_hwdep_ioctl()
4787 if ((err = hdsp_get_iobox_version(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4791 hdsp_version.io_type = hdsp->io_type; in snd_hdsp_hwdep_ioctl()
4792 hdsp_version.firmware_rev = hdsp->firmware_rev; in snd_hdsp_hwdep_ioctl()
4802 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4804 if (hdsp->io_type == Undefined) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4806 if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded)) in snd_hdsp_hwdep_ioctl()
4809 dev_info(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4816 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hwdep_ioctl()
4819 if (!hdsp->fw_uploaded) { in snd_hdsp_hwdep_ioctl()
4820 hdsp->fw_uploaded = vmalloc(HDSP_FIRMWARE_SIZE); in snd_hdsp_hwdep_ioctl()
4821 if (!hdsp->fw_uploaded) in snd_hdsp_hwdep_ioctl()
4825 if (copy_from_user(hdsp->fw_uploaded, firmware_data, in snd_hdsp_hwdep_ioctl()
4827 vfree(hdsp->fw_uploaded); in snd_hdsp_hwdep_ioctl()
4828 hdsp->fw_uploaded = NULL; in snd_hdsp_hwdep_ioctl()
4832 hdsp->state |= HDSP_FirmwareCached; in snd_hdsp_hwdep_ioctl()
4834 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4837 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_hwdep_ioctl()
4838 if ((err = snd_hdsp_enable_io(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4841 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_hwdep_ioctl()
4842 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_hwdep_ioctl()
4844 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { in snd_hdsp_hwdep_ioctl()
4845 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4854 …if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) in snd_hdsp_hwdep_ioctl()
4887 static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_hwdep() argument
4895 hdsp->hwdep = hw; in snd_hdsp_create_hwdep()
4896 hw->private_data = hdsp; in snd_hdsp_create_hwdep()
4905 static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_pcm() argument
4910 if ((err = snd_pcm_new(card, hdsp->card_name, 0, 1, 1, &pcm)) < 0) in snd_hdsp_create_pcm()
4913 hdsp->pcm = pcm; in snd_hdsp_create_pcm()
4914 pcm->private_data = hdsp; in snd_hdsp_create_pcm()
4915 strcpy(pcm->name, hdsp->card_name); in snd_hdsp_create_pcm()
4925 static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp) in snd_hdsp_9652_enable_mixer() argument
4927 hdsp->control2_register |= HDSP_9652_ENABLE_MIXER; in snd_hdsp_9652_enable_mixer()
4928 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_9652_enable_mixer()
4931 static int snd_hdsp_enable_io (struct hdsp *hdsp) in snd_hdsp_enable_io() argument
4935 if (hdsp_fifo_wait (hdsp, 0, 100)) { in snd_hdsp_enable_io()
4936 dev_err(hdsp->card->dev, in snd_hdsp_enable_io()
4941 for (i = 0; i < hdsp->max_channels; ++i) { in snd_hdsp_enable_io()
4942 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1); in snd_hdsp_enable_io()
4943 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1); in snd_hdsp_enable_io()
4949 static void snd_hdsp_initialize_channels(struct hdsp *hdsp) in snd_hdsp_initialize_channels() argument
4953 switch (hdsp->io_type) { in snd_hdsp_initialize_channels()
4955 hdsp->card_name = "RME Hammerfall DSP + Digiface"; in snd_hdsp_initialize_channels()
4956 hdsp->ss_in_channels = hdsp->ss_out_channels = DIGIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
4957 hdsp->ds_in_channels = hdsp->ds_out_channels = DIGIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
4961 hdsp->card_name = "RME Hammerfall HDSP 9652"; in snd_hdsp_initialize_channels()
4962 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS; in snd_hdsp_initialize_channels()
4963 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS; in snd_hdsp_initialize_channels()
4967 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_initialize_channels()
4971 hdsp->card_name = "RME Hammerfall HDSP 9632"; in snd_hdsp_initialize_channels()
4972 hdsp->ss_in_channels = H9632_SS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
4973 hdsp->ds_in_channels = H9632_DS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
4974 hdsp->qs_in_channels = H9632_QS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
4975 hdsp->ss_out_channels = H9632_SS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
4976 hdsp->ds_out_channels = H9632_DS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
4977 hdsp->qs_out_channels = H9632_QS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
4981 hdsp->card_name = "RME Hammerfall DSP + Multiface"; in snd_hdsp_initialize_channels()
4982 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
4983 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
4987 hdsp->card_name = "RME Hammerfall DSP + RPM"; in snd_hdsp_initialize_channels()
4988 hdsp->ss_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
4989 hdsp->ss_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
4990 hdsp->ds_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
4991 hdsp->ds_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
5000 static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp) in snd_hdsp_initialize_midi_flush() argument
5002 snd_hdsp_flush_midi_input (hdsp, 0); in snd_hdsp_initialize_midi_flush()
5003 snd_hdsp_flush_midi_input (hdsp, 1); in snd_hdsp_initialize_midi_flush()
5006 static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_alsa_devices() argument
5010 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5017 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { in snd_hdsp_create_alsa_devices()
5023 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_alsa_devices()
5024 if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) { in snd_hdsp_create_alsa_devices()
5031 if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5037 snd_hdsp_proc_init(hdsp); in snd_hdsp_create_alsa_devices()
5039 hdsp->system_sample_rate = -1; in snd_hdsp_create_alsa_devices()
5040 hdsp->playback_pid = -1; in snd_hdsp_create_alsa_devices()
5041 hdsp->capture_pid = -1; in snd_hdsp_create_alsa_devices()
5042 hdsp->capture_substream = NULL; in snd_hdsp_create_alsa_devices()
5043 hdsp->playback_substream = NULL; in snd_hdsp_create_alsa_devices()
5045 if ((err = snd_hdsp_set_defaults(hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5051 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_create_alsa_devices()
5053 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_create_alsa_devices()
5054 hdsp->port, hdsp->irq); in snd_hdsp_create_alsa_devices()
5061 hdsp->state |= HDSP_InitializationComplete; in snd_hdsp_create_alsa_devices()
5068 static int hdsp_request_fw_loader(struct hdsp *hdsp) in hdsp_request_fw_loader() argument
5074 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5076 if (hdsp->io_type == Undefined) { in hdsp_request_fw_loader()
5077 if ((err = hdsp_get_iobox_version(hdsp)) < 0) in hdsp_request_fw_loader()
5079 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5084 switch (hdsp->io_type) { in hdsp_request_fw_loader()
5089 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5095 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5101 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5102 "invalid io_type %d\n", hdsp->io_type); in hdsp_request_fw_loader()
5106 if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) { in hdsp_request_fw_loader()
5107 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5112 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5119 hdsp->firmware = fw; in hdsp_request_fw_loader()
5121 hdsp->state |= HDSP_FirmwareCached; in hdsp_request_fw_loader()
5123 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) in hdsp_request_fw_loader()
5126 if (!(hdsp->state & HDSP_InitializationComplete)) { in hdsp_request_fw_loader()
5127 if ((err = snd_hdsp_enable_io(hdsp)) < 0) in hdsp_request_fw_loader()
5130 if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) { in hdsp_request_fw_loader()
5131 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5135 snd_hdsp_initialize_channels(hdsp); in hdsp_request_fw_loader()
5136 snd_hdsp_initialize_midi_flush(hdsp); in hdsp_request_fw_loader()
5137 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { in hdsp_request_fw_loader()
5138 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5147 struct hdsp *hdsp) in snd_hdsp_create() argument
5149 struct pci_dev *pci = hdsp->pci; in snd_hdsp_create()
5154 hdsp->irq = -1; in snd_hdsp_create()
5155 hdsp->state = 0; in snd_hdsp_create()
5156 hdsp->midi[0].rmidi = NULL; in snd_hdsp_create()
5157 hdsp->midi[1].rmidi = NULL; in snd_hdsp_create()
5158 hdsp->midi[0].input = NULL; in snd_hdsp_create()
5159 hdsp->midi[1].input = NULL; in snd_hdsp_create()
5160 hdsp->midi[0].output = NULL; in snd_hdsp_create()
5161 hdsp->midi[1].output = NULL; in snd_hdsp_create()
5162 hdsp->midi[0].pending = 0; in snd_hdsp_create()
5163 hdsp->midi[1].pending = 0; in snd_hdsp_create()
5164 spin_lock_init(&hdsp->midi[0].lock); in snd_hdsp_create()
5165 spin_lock_init(&hdsp->midi[1].lock); in snd_hdsp_create()
5166 hdsp->iobase = NULL; in snd_hdsp_create()
5167 hdsp->control_register = 0; in snd_hdsp_create()
5168 hdsp->control2_register = 0; in snd_hdsp_create()
5169 hdsp->io_type = Undefined; in snd_hdsp_create()
5170 hdsp->max_channels = 26; in snd_hdsp_create()
5172 hdsp->card = card; in snd_hdsp_create()
5174 spin_lock_init(&hdsp->lock); in snd_hdsp_create()
5176 tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp); in snd_hdsp_create()
5178 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev); in snd_hdsp_create()
5179 hdsp->firmware_rev &= 0xff; in snd_hdsp_create()
5188 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF); in snd_hdsp_create()
5193 if (hdsp->firmware_rev < 0xa) in snd_hdsp_create()
5195 else if (hdsp->firmware_rev < 0x64) in snd_hdsp_create()
5196 hdsp->card_name = "RME Hammerfall DSP"; in snd_hdsp_create()
5197 else if (hdsp->firmware_rev < 0x96) { in snd_hdsp_create()
5198 hdsp->card_name = "RME HDSP 9652"; in snd_hdsp_create()
5201 hdsp->card_name = "RME HDSP 9632"; in snd_hdsp_create()
5202 hdsp->max_channels = 16; in snd_hdsp_create()
5209 pci_set_master(hdsp->pci); in snd_hdsp_create()
5213 hdsp->port = pci_resource_start(pci, 0); in snd_hdsp_create()
5214 if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) { in snd_hdsp_create()
5215 dev_err(hdsp->card->dev, "unable to remap region 0x%lx-0x%lx\n", in snd_hdsp_create()
5216 hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1); in snd_hdsp_create()
5221 KBUILD_MODNAME, hdsp)) { in snd_hdsp_create()
5222 dev_err(hdsp->card->dev, "unable to use IRQ %d\n", pci->irq); in snd_hdsp_create()
5226 hdsp->irq = pci->irq; in snd_hdsp_create()
5227 hdsp->precise_ptr = 0; in snd_hdsp_create()
5228 hdsp->use_midi_tasklet = 1; in snd_hdsp_create()
5229 hdsp->dds_value = 0; in snd_hdsp_create()
5231 if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) in snd_hdsp_create()
5237 err = hdsp_wait_for_iobox(hdsp, 1000, 10); in snd_hdsp_create()
5242 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in snd_hdsp_create()
5243 if ((err = hdsp_request_fw_loader(hdsp)) < 0) in snd_hdsp_create()
5248 dev_err(hdsp->card->dev, in snd_hdsp_create()
5254 dev_info(hdsp->card->dev, in snd_hdsp_create()
5256 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) in snd_hdsp_create()
5260 dev_info(hdsp->card->dev, in snd_hdsp_create()
5262 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in snd_hdsp_create()
5263 hdsp->io_type = RPM; in snd_hdsp_create()
5264 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in snd_hdsp_create()
5265 hdsp->io_type = Multiface; in snd_hdsp_create()
5267 hdsp->io_type = Digiface; in snd_hdsp_create()
5271 if ((err = snd_hdsp_enable_io(hdsp)) != 0) in snd_hdsp_create()
5275 hdsp->io_type = H9652; in snd_hdsp_create()
5278 hdsp->io_type = H9632; in snd_hdsp_create()
5280 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) in snd_hdsp_create()
5283 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_create()
5284 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_create()
5286 hdsp->state |= HDSP_FirmwareLoaded; in snd_hdsp_create()
5288 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) in snd_hdsp_create()
5294 static int snd_hdsp_free(struct hdsp *hdsp) in snd_hdsp_free() argument
5296 if (hdsp->port) { in snd_hdsp_free()
5298 tasklet_kill(&hdsp->midi_tasklet); in snd_hdsp_free()
5299 …hdsp->control_register &= ~(HDSP_Start|HDSP_AudioInterruptEnable|HDSP_Midi0InterruptEnable|HDSP_Mi… in snd_hdsp_free()
5300 hdsp_write (hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_free()
5303 if (hdsp->irq >= 0) in snd_hdsp_free()
5304 free_irq(hdsp->irq, (void *)hdsp); in snd_hdsp_free()
5306 snd_hdsp_free_buffers(hdsp); in snd_hdsp_free()
5308 release_firmware(hdsp->firmware); in snd_hdsp_free()
5309 vfree(hdsp->fw_uploaded); in snd_hdsp_free()
5310 iounmap(hdsp->iobase); in snd_hdsp_free()
5312 if (hdsp->port) in snd_hdsp_free()
5313 pci_release_regions(hdsp->pci); in snd_hdsp_free()
5315 pci_disable_device(hdsp->pci); in snd_hdsp_free()
5321 struct hdsp *hdsp = card->private_data; in snd_hdsp_card_free() local
5323 if (hdsp) in snd_hdsp_card_free()
5324 snd_hdsp_free(hdsp); in snd_hdsp_card_free()
5331 struct hdsp *hdsp; in snd_hdsp_probe() local
5343 sizeof(struct hdsp), &card); in snd_hdsp_probe()
5347 hdsp = card->private_data; in snd_hdsp_probe()
5349 hdsp->dev = dev; in snd_hdsp_probe()
5350 hdsp->pci = pci; in snd_hdsp_probe()
5352 if ((err = snd_hdsp_create(card, hdsp)) < 0) { in snd_hdsp_probe()
5358 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_probe()
5359 hdsp->port, hdsp->irq); in snd_hdsp_probe()