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()
799 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
800 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
801 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) { in hdsp_get_iobox_version()
802 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
803 dev_info(hdsp->card->dev, "Digiface found\n"); in hdsp_get_iobox_version()
807 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
808 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
809 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
810 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) in hdsp_get_iobox_version()
813 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
814 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
815 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
816 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) in hdsp_get_iobox_version()
819 hdsp->io_type = RPM; in hdsp_get_iobox_version()
820 dev_info(hdsp->card->dev, "RPM found\n"); in hdsp_get_iobox_version()
824 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in hdsp_get_iobox_version()
825 hdsp->io_type = RPM; in hdsp_get_iobox_version()
826 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in hdsp_get_iobox_version()
827 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
829 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
834 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
835 dev_info(hdsp->card->dev, "Multiface found\n"); in hdsp_get_iobox_version()
840 static int hdsp_request_fw_loader(struct hdsp *hdsp);
842 static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand) in hdsp_check_for_firmware() argument
844 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_check_for_firmware()
846 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in hdsp_check_for_firmware()
847 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_check_for_firmware()
850 dev_err(hdsp->card->dev, "firmware not present.\n"); in hdsp_check_for_firmware()
852 if (! (hdsp->state & HDSP_FirmwareCached)) { in hdsp_check_for_firmware()
853 if (! hdsp_request_fw_loader(hdsp)) in hdsp_check_for_firmware()
855 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
859 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in hdsp_check_for_firmware()
860 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
869 static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout) in hdsp_fifo_wait() argument
879 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count) in hdsp_fifo_wait()
889 dev_warn(hdsp->card->dev, in hdsp_fifo_wait()
895 static int hdsp_read_gain (struct hdsp *hdsp, unsigned int addr) in hdsp_read_gain() argument
900 return hdsp->mixer_matrix[addr]; in hdsp_read_gain()
903 static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short data) in hdsp_write_gain() argument
910 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) { in hdsp_write_gain()
924 if (hdsp->io_type == H9632 && addr >= 512) in hdsp_write_gain()
927 if (hdsp->io_type == H9652 && addr >= 1352) in hdsp_write_gain()
930 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
942 hdsp_write (hdsp, 4096 + (ad*4), in hdsp_write_gain()
943 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + in hdsp_write_gain()
944 hdsp->mixer_matrix[addr&0x7fe]); in hdsp_write_gain()
952 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) in hdsp_write_gain()
955 hdsp_write (hdsp, HDSP_fifoData, ad); in hdsp_write_gain()
956 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
963 static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp) in snd_hdsp_use_is_exclusive() argument
968 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
969 if ((hdsp->playback_pid != hdsp->capture_pid) && in snd_hdsp_use_is_exclusive()
970 (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0)) in snd_hdsp_use_is_exclusive()
972 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
976 static int hdsp_spdif_sample_rate(struct hdsp *hdsp) in hdsp_spdif_sample_rate() argument
978 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sample_rate()
982 if (hdsp->io_type == H9632) in hdsp_spdif_sample_rate()
996 if (hdsp->io_type == H9632) return 128000; in hdsp_spdif_sample_rate()
999 if (hdsp->io_type == H9632) return 176400; in hdsp_spdif_sample_rate()
1002 if (hdsp->io_type == H9632) return 192000; in hdsp_spdif_sample_rate()
1007 dev_warn(hdsp->card->dev, in hdsp_spdif_sample_rate()
1013 static int hdsp_external_sample_rate(struct hdsp *hdsp) in hdsp_external_sample_rate() argument
1015 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_external_sample_rate()
1022 if (hdsp->io_type == H9632 && in hdsp_external_sample_rate()
1023 hdsp_autosync_ref(hdsp) == HDSP_AUTOSYNC_FROM_SPDIF) in hdsp_external_sample_rate()
1024 return hdsp_spdif_sample_rate(hdsp); in hdsp_external_sample_rate()
1038 static void hdsp_compute_period_size(struct hdsp *hdsp) in hdsp_compute_period_size() argument
1040 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8)); in hdsp_compute_period_size()
1043 static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp) in hdsp_hw_pointer() argument
1047 position = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_hw_pointer()
1049 if (!hdsp->precise_ptr) in hdsp_hw_pointer()
1050 return (position & HDSP_BufferID) ? (hdsp->period_bytes / 4) : 0; in hdsp_hw_pointer()
1054 position &= (hdsp->period_bytes/2) - 1; in hdsp_hw_pointer()
1058 static void hdsp_reset_hw_pointer(struct hdsp *hdsp) in hdsp_reset_hw_pointer() argument
1060 hdsp_write (hdsp, HDSP_resetPointer, 0); in hdsp_reset_hw_pointer()
1061 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_reset_hw_pointer()
1065 hdsp_write (hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_reset_hw_pointer()
1068 static void hdsp_start_audio(struct hdsp *s) in hdsp_start_audio()
1074 static void hdsp_stop_audio(struct hdsp *s) in hdsp_stop_audio()
1080 static void hdsp_silence_playback(struct hdsp *hdsp) in hdsp_silence_playback() argument
1082 memset(hdsp->playback_buffer, 0, HDSP_DMA_AREA_BYTES); in hdsp_silence_playback()
1085 static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames) in hdsp_set_interrupt_interval()
1110 static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) in hdsp_set_dds_value() argument
1125 hdsp->dds_value = n; in hdsp_set_dds_value()
1126 hdsp_write(hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_set_dds_value()
1129 static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally) in hdsp_set_rate() argument
1140 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { in hdsp_set_rate()
1143 dev_err(hdsp->card->dev, in hdsp_set_rate()
1148 int external_freq = hdsp_external_sample_rate(hdsp); in hdsp_set_rate()
1149 int spdif_freq = hdsp_spdif_sample_rate(hdsp); in hdsp_set_rate()
1151 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) in hdsp_set_rate()
1152 dev_info(hdsp->card->dev, in hdsp_set_rate()
1154 …else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= … in hdsp_set_rate()
1155 dev_info(hdsp->card->dev, in hdsp_set_rate()
1158 dev_info(hdsp->card->dev, in hdsp_set_rate()
1165 current_rate = hdsp->system_sample_rate; in hdsp_set_rate()
1177 if (rate > 96000 && hdsp->io_type != H9632) in hdsp_set_rate()
1230 if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) { in hdsp_set_rate()
1231 dev_warn(hdsp->card->dev, in hdsp_set_rate()
1233 hdsp->capture_pid, in hdsp_set_rate()
1234 hdsp->playback_pid); in hdsp_set_rate()
1238 hdsp->control_register &= ~HDSP_FrequencyMask; in hdsp_set_rate()
1239 hdsp->control_register |= rate_bits; in hdsp_set_rate()
1240 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rate()
1243 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_set_rate()
1244 hdsp_set_dds_value(hdsp, rate); in hdsp_set_rate()
1247 hdsp->channel_map = channel_map_H9632_qs; in hdsp_set_rate()
1249 if (hdsp->io_type == H9632) in hdsp_set_rate()
1250 hdsp->channel_map = channel_map_H9632_ds; in hdsp_set_rate()
1252 hdsp->channel_map = channel_map_ds; in hdsp_set_rate()
1254 switch (hdsp->io_type) { in hdsp_set_rate()
1257 hdsp->channel_map = channel_map_mf_ss; in hdsp_set_rate()
1261 hdsp->channel_map = channel_map_df_ss; in hdsp_set_rate()
1264 hdsp->channel_map = channel_map_H9632_ss; in hdsp_set_rate()
1272 hdsp->system_sample_rate = rate; in hdsp_set_rate()
1281 static unsigned char snd_hdsp_midi_read_byte (struct hdsp *hdsp, int id) in snd_hdsp_midi_read_byte() argument
1285 return hdsp_read(hdsp, HDSP_midiDataIn1); in snd_hdsp_midi_read_byte()
1287 return hdsp_read(hdsp, HDSP_midiDataIn0); in snd_hdsp_midi_read_byte()
1290 static void snd_hdsp_midi_write_byte (struct hdsp *hdsp, int id, int val) in snd_hdsp_midi_write_byte() argument
1294 hdsp_write(hdsp, HDSP_midiDataOut1, val); in snd_hdsp_midi_write_byte()
1296 hdsp_write(hdsp, HDSP_midiDataOut0, val); in snd_hdsp_midi_write_byte()
1299 static int snd_hdsp_midi_input_available (struct hdsp *hdsp, int id) in snd_hdsp_midi_input_available() argument
1302 return (hdsp_read(hdsp, HDSP_midiStatusIn1) & 0xff); in snd_hdsp_midi_input_available()
1304 return (hdsp_read(hdsp, HDSP_midiStatusIn0) & 0xff); in snd_hdsp_midi_input_available()
1307 static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id) in snd_hdsp_midi_output_possible() argument
1312 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff; in snd_hdsp_midi_output_possible()
1314 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff; in snd_hdsp_midi_output_possible()
1322 static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id) in snd_hdsp_flush_midi_input() argument
1324 while (snd_hdsp_midi_input_available (hdsp, id)) in snd_hdsp_flush_midi_input()
1325 snd_hdsp_midi_read_byte (hdsp, id); in snd_hdsp_flush_midi_input()
1341 if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) { in snd_hdsp_midi_output_write()
1347 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); in snd_hdsp_midi_output_write()
1364 if ((n_pending = snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) > 0) { in snd_hdsp_midi_input_read()
1369 buf[i] = snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1375 snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1380 hmidi->hdsp->control_register |= HDSP_Midi1InterruptEnable; in snd_hdsp_midi_input_read()
1382 hmidi->hdsp->control_register |= HDSP_Midi0InterruptEnable; in snd_hdsp_midi_input_read()
1383 hdsp_write(hmidi->hdsp, HDSP_controlRegister, hmidi->hdsp->control_register); in snd_hdsp_midi_input_read()
1390 struct hdsp *hdsp; in snd_hdsp_midi_input_trigger() local
1396 hdsp = hmidi->hdsp; in snd_hdsp_midi_input_trigger()
1398 spin_lock_irqsave (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1400 if (!(hdsp->control_register & ie)) { in snd_hdsp_midi_input_trigger()
1401 snd_hdsp_flush_midi_input (hdsp, hmidi->id); in snd_hdsp_midi_input_trigger()
1402 hdsp->control_register |= ie; in snd_hdsp_midi_input_trigger()
1405 hdsp->control_register &= ~ie; in snd_hdsp_midi_input_trigger()
1406 tasklet_kill(&hdsp->midi_tasklet); in snd_hdsp_midi_input_trigger()
1409 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_midi_input_trigger()
1410 spin_unlock_irqrestore (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1462 snd_hdsp_flush_midi_input (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_open()
1523 static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id) in snd_hdsp_create_midi() argument
1527 hdsp->midi[id].id = id; in snd_hdsp_create_midi()
1528 hdsp->midi[id].rmidi = NULL; in snd_hdsp_create_midi()
1529 hdsp->midi[id].input = NULL; in snd_hdsp_create_midi()
1530 hdsp->midi[id].output = NULL; in snd_hdsp_create_midi()
1531 hdsp->midi[id].hdsp = hdsp; in snd_hdsp_create_midi()
1532 hdsp->midi[id].istimer = 0; in snd_hdsp_create_midi()
1533 hdsp->midi[id].pending = 0; in snd_hdsp_create_midi()
1534 spin_lock_init (&hdsp->midi[id].lock); in snd_hdsp_create_midi()
1537 if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) in snd_hdsp_create_midi()
1540 sprintf(hdsp->midi[id].rmidi->name, "HDSP MIDI %d", id+1); in snd_hdsp_create_midi()
1541 hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; in snd_hdsp_create_midi()
1543 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); in snd_hdsp_create_midi()
1544 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_hdsp_midi_input); in snd_hdsp_create_midi()
1546 hdsp->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | in snd_hdsp_create_midi()
1588 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_get() local
1590 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif); in snd_hdsp_control_spdif_get()
1596 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_put() local
1601 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1602 change = val != hdsp->creg_spdif; in snd_hdsp_control_spdif_put()
1603 hdsp->creg_spdif = val; in snd_hdsp_control_spdif_put()
1604 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1617 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_get() local
1619 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream); in snd_hdsp_control_spdif_stream_get()
1625 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_put() local
1630 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1631 change = val != hdsp->creg_spdif_stream; in snd_hdsp_control_spdif_stream_put()
1632 hdsp->creg_spdif_stream = val; in snd_hdsp_control_spdif_stream_put()
1633 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_control_spdif_stream_put()
1634 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= val); in snd_hdsp_control_spdif_stream_put()
1635 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1660 static unsigned int hdsp_spdif_in(struct hdsp *hdsp) in hdsp_spdif_in() argument
1662 return hdsp_decode_spdif_in(hdsp->control_register & HDSP_SPDIFInputMask); in hdsp_spdif_in()
1665 static int hdsp_set_spdif_input(struct hdsp *hdsp, int in) in hdsp_set_spdif_input() argument
1667 hdsp->control_register &= ~HDSP_SPDIFInputMask; in hdsp_set_spdif_input()
1668 hdsp->control_register |= hdsp_encode_spdif_in(in); in hdsp_set_spdif_input()
1669 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_spdif_input()
1678 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_in() local
1680 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 4 : 3, in snd_hdsp_info_spdif_in()
1686 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_in() local
1688 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); in snd_hdsp_get_spdif_in()
1694 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_spdif_in() local
1698 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_spdif_in()
1700 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3); in snd_hdsp_put_spdif_in()
1701 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1702 change = val != hdsp_spdif_in(hdsp); in snd_hdsp_put_spdif_in()
1704 hdsp_set_spdif_input(hdsp, val); in snd_hdsp_put_spdif_in()
1705 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1718 static int hdsp_toggle_setting(struct hdsp *hdsp, u32 regmask) in hdsp_toggle_setting() argument
1720 return (hdsp->control_register & regmask) ? 1 : 0; in hdsp_toggle_setting()
1723 static int hdsp_set_toggle_setting(struct hdsp *hdsp, u32 regmask, int out) in hdsp_set_toggle_setting() argument
1726 hdsp->control_register |= regmask; in hdsp_set_toggle_setting()
1728 hdsp->control_register &= ~regmask; in hdsp_set_toggle_setting()
1729 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_toggle_setting()
1739 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_toggle_setting() local
1742 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1743 ucontrol->value.integer.value[0] = hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_get_toggle_setting()
1744 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1751 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_toggle_setting() local
1756 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_toggle_setting()
1759 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1760 change = (int) val != hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_put_toggle_setting()
1762 hdsp_set_toggle_setting(hdsp, regmask, val); in snd_hdsp_put_toggle_setting()
1763 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1782 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_sample_rate() local
1784 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_spdif_sample_rate()
1790 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sample_rate() local
1792 switch (hdsp_spdif_sample_rate(hdsp)) { in snd_hdsp_get_spdif_sample_rate()
1844 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_sample_rate() local
1846 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; in snd_hdsp_get_system_sample_rate()
1861 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_autosync_sample_rate() local
1867 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_autosync_sample_rate()
1873 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_sample_rate() local
1875 switch (hdsp_external_sample_rate(hdsp)) { in snd_hdsp_get_autosync_sample_rate()
1918 static int hdsp_system_clock_mode(struct hdsp *hdsp) in hdsp_system_clock_mode() argument
1920 if (hdsp->control_register & HDSP_ClockModeMaster) in hdsp_system_clock_mode()
1922 else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) in hdsp_system_clock_mode()
1936 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_clock_mode() local
1938 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); in snd_hdsp_get_system_clock_mode()
1951 static int hdsp_clock_source(struct hdsp *hdsp) in hdsp_clock_source() argument
1953 if (hdsp->control_register & HDSP_ClockModeMaster) { in hdsp_clock_source()
1954 switch (hdsp->system_sample_rate) { in hdsp_clock_source()
1981 static int hdsp_set_clock_source(struct hdsp *hdsp, int mode) in hdsp_set_clock_source() argument
1986 if (hdsp_external_sample_rate(hdsp) != 0) { in hdsp_set_clock_source()
1987 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) { in hdsp_set_clock_source()
1988 hdsp->control_register &= ~HDSP_ClockModeMaster; in hdsp_set_clock_source()
1989 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2024 hdsp->control_register |= HDSP_ClockModeMaster; in hdsp_set_clock_source()
2025 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2026 hdsp_set_rate(hdsp, rate, 1); in hdsp_set_clock_source()
2038 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_clock_source() local
2040 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_clock_source()
2046 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source() local
2048 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); in snd_hdsp_get_clock_source()
2054 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source() local
2058 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_clock_source()
2062 if (hdsp->io_type == H9632) { in snd_hdsp_put_clock_source()
2069 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2070 if (val != hdsp_clock_source(hdsp)) in snd_hdsp_put_clock_source()
2071 change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_clock_source()
2074 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2082 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source_lock() local
2084 ucontrol->value.integer.value[0] = hdsp->clock_source_locked; in snd_hdsp_get_clock_source_lock()
2090 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source_lock() local
2093 change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked; in snd_hdsp_put_clock_source_lock()
2095 hdsp->clock_source_locked = !!ucontrol->value.integer.value[0]; in snd_hdsp_put_clock_source_lock()
2108 static int hdsp_da_gain(struct hdsp *hdsp) in hdsp_da_gain() argument
2110 switch (hdsp->control_register & HDSP_DAGainMask) { in hdsp_da_gain()
2122 static int hdsp_set_da_gain(struct hdsp *hdsp, int mode) in hdsp_set_da_gain() argument
2124 hdsp->control_register &= ~HDSP_DAGainMask; in hdsp_set_da_gain()
2127 hdsp->control_register |= HDSP_DAGainHighGain; in hdsp_set_da_gain()
2130 hdsp->control_register |= HDSP_DAGainPlus4dBu; in hdsp_set_da_gain()
2133 hdsp->control_register |= HDSP_DAGainMinus10dBV; in hdsp_set_da_gain()
2139 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_da_gain()
2152 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_da_gain() local
2154 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp); in snd_hdsp_get_da_gain()
2160 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_da_gain() local
2164 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_da_gain()
2169 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2170 if (val != hdsp_da_gain(hdsp)) in snd_hdsp_put_da_gain()
2171 change = (hdsp_set_da_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_da_gain()
2174 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2187 static int hdsp_ad_gain(struct hdsp *hdsp) in hdsp_ad_gain() argument
2189 switch (hdsp->control_register & HDSP_ADGainMask) { in hdsp_ad_gain()
2201 static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode) in hdsp_set_ad_gain() argument
2203 hdsp->control_register &= ~HDSP_ADGainMask; in hdsp_set_ad_gain()
2206 hdsp->control_register |= HDSP_ADGainMinus10dBV; in hdsp_set_ad_gain()
2209 hdsp->control_register |= HDSP_ADGainPlus4dBu; in hdsp_set_ad_gain()
2212 hdsp->control_register |= HDSP_ADGainLowGain; in hdsp_set_ad_gain()
2218 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_ad_gain()
2231 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_ad_gain() local
2233 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp); in snd_hdsp_get_ad_gain()
2239 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_ad_gain() local
2243 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_ad_gain()
2248 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2249 if (val != hdsp_ad_gain(hdsp)) in snd_hdsp_put_ad_gain()
2250 change = (hdsp_set_ad_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_ad_gain()
2253 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2266 static int hdsp_phone_gain(struct hdsp *hdsp) in hdsp_phone_gain() argument
2268 switch (hdsp->control_register & HDSP_PhoneGainMask) { in hdsp_phone_gain()
2280 static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode) in hdsp_set_phone_gain() argument
2282 hdsp->control_register &= ~HDSP_PhoneGainMask; in hdsp_set_phone_gain()
2285 hdsp->control_register |= HDSP_PhoneGain0dB; in hdsp_set_phone_gain()
2288 hdsp->control_register |= HDSP_PhoneGainMinus6dB; in hdsp_set_phone_gain()
2291 hdsp->control_register |= HDSP_PhoneGainMinus12dB; in hdsp_set_phone_gain()
2297 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_phone_gain()
2310 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_phone_gain() local
2312 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp); in snd_hdsp_get_phone_gain()
2318 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_phone_gain() local
2322 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_phone_gain()
2327 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2328 if (val != hdsp_phone_gain(hdsp)) in snd_hdsp_put_phone_gain()
2329 change = (hdsp_set_phone_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_phone_gain()
2332 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2345 static int hdsp_pref_sync_ref(struct hdsp *hdsp) in hdsp_pref_sync_ref() argument
2351 switch (hdsp->control_register & HDSP_SyncRefMask) { in hdsp_pref_sync_ref()
2370 static int hdsp_set_pref_sync_ref(struct hdsp *hdsp, int pref) in hdsp_set_pref_sync_ref() argument
2372 hdsp->control_register &= ~HDSP_SyncRefMask; in hdsp_set_pref_sync_ref()
2375 hdsp->control_register &= ~HDSP_SyncRefMask; /* clear SyncRef bits */ in hdsp_set_pref_sync_ref()
2378 hdsp->control_register |= HDSP_SyncRef_ADAT2; in hdsp_set_pref_sync_ref()
2381 hdsp->control_register |= HDSP_SyncRef_ADAT3; in hdsp_set_pref_sync_ref()
2384 hdsp->control_register |= HDSP_SyncRef_SPDIF; in hdsp_set_pref_sync_ref()
2387 hdsp->control_register |= HDSP_SyncRef_WORD; in hdsp_set_pref_sync_ref()
2390 hdsp->control_register |= HDSP_SyncRef_ADAT_SYNC; in hdsp_set_pref_sync_ref()
2395 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_pref_sync_ref()
2404 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_pref_sync_ref() local
2407 switch (hdsp->io_type) { in snd_hdsp_info_pref_sync_ref()
2427 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_pref_sync_ref() local
2429 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); in snd_hdsp_get_pref_sync_ref()
2435 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_pref_sync_ref() local
2439 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_pref_sync_ref()
2442 switch (hdsp->io_type) { in snd_hdsp_put_pref_sync_ref()
2458 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2459 change = (int)val != hdsp_pref_sync_ref(hdsp); in snd_hdsp_put_pref_sync_ref()
2460 hdsp_set_pref_sync_ref(hdsp, val); in snd_hdsp_put_pref_sync_ref()
2461 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2474 static int hdsp_autosync_ref(struct hdsp *hdsp) in hdsp_autosync_ref() argument
2477 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_autosync_ref()
2511 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_ref() local
2513 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp); in snd_hdsp_get_autosync_ref()
2526 static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise) in hdsp_set_precise_pointer() argument
2529 hdsp->precise_ptr = 1; in hdsp_set_precise_pointer()
2531 hdsp->precise_ptr = 0; in hdsp_set_precise_pointer()
2539 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_precise_pointer() local
2541 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2542 ucontrol->value.integer.value[0] = hdsp->precise_ptr; in snd_hdsp_get_precise_pointer()
2543 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2549 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_precise_pointer() local
2553 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_precise_pointer()
2556 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2557 change = (int)val != hdsp->precise_ptr; in snd_hdsp_put_precise_pointer()
2558 hdsp_set_precise_pointer(hdsp, val); in snd_hdsp_put_precise_pointer()
2559 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2572 static int hdsp_set_use_midi_tasklet(struct hdsp *hdsp, int use_tasklet) in hdsp_set_use_midi_tasklet() argument
2575 hdsp->use_midi_tasklet = 1; in hdsp_set_use_midi_tasklet()
2577 hdsp->use_midi_tasklet = 0; in hdsp_set_use_midi_tasklet()
2585 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_use_midi_tasklet() local
2587 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_tasklet()
2588 ucontrol->value.integer.value[0] = hdsp->use_midi_tasklet; in snd_hdsp_get_use_midi_tasklet()
2589 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_tasklet()
2595 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_use_midi_tasklet() local
2599 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_use_midi_tasklet()
2602 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_tasklet()
2603 change = (int)val != hdsp->use_midi_tasklet; in snd_hdsp_put_use_midi_tasklet()
2604 hdsp_set_use_midi_tasklet(hdsp, val); in snd_hdsp_put_use_midi_tasklet()
2605 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_tasklet()
2633 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_mixer() local
2641 if (source >= hdsp->max_channels) in snd_hdsp_get_mixer()
2642 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination); in snd_hdsp_get_mixer()
2644 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_get_mixer()
2646 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2647 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr); in snd_hdsp_get_mixer()
2648 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2654 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_mixer() local
2661 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_mixer()
2667 if (source >= hdsp->max_channels) in snd_hdsp_put_mixer()
2668 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels, destination); in snd_hdsp_put_mixer()
2670 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_put_mixer()
2674 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2675 change = gain != hdsp_read_gain(hdsp, addr); in snd_hdsp_put_mixer()
2677 hdsp_write_gain(hdsp, addr, gain); in snd_hdsp_put_mixer()
2678 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2698 static int hdsp_wc_sync_check(struct hdsp *hdsp) in hdsp_wc_sync_check() argument
2700 int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_wc_sync_check()
2713 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_wc_sync_check() local
2715 ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp); in snd_hdsp_get_wc_sync_check()
2728 static int hdsp_spdif_sync_check(struct hdsp *hdsp) in hdsp_spdif_sync_check() argument
2730 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sync_check()
2744 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sync_check() local
2746 ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp); in snd_hdsp_get_spdif_sync_check()
2759 static int hdsp_adatsync_sync_check(struct hdsp *hdsp) in hdsp_adatsync_sync_check() argument
2761 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adatsync_sync_check()
2773 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adatsync_sync_check() local
2775 ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp); in snd_hdsp_get_adatsync_sync_check()
2786 static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx) in hdsp_adat_sync_check() argument
2788 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adat_sync_check()
2802 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adat_sync_check() local
2808 switch (hdsp->io_type) { in snd_hdsp_get_adat_sync_check()
2823 ucontrol->value.enumerated.item[0] = hdsp_adat_sync_check(hdsp, offset); in snd_hdsp_get_adat_sync_check()
2836 static int hdsp_dds_offset(struct hdsp *hdsp) in hdsp_dds_offset() argument
2839 unsigned int dds_value = hdsp->dds_value; in hdsp_dds_offset()
2840 int system_sample_rate = hdsp->system_sample_rate; in hdsp_dds_offset()
2858 static int hdsp_set_dds_offset(struct hdsp *hdsp, int offset_hz) in hdsp_set_dds_offset() argument
2860 int rate = hdsp->system_sample_rate + offset_hz; in hdsp_set_dds_offset()
2861 hdsp_set_dds_value(hdsp, rate); in hdsp_set_dds_offset()
2876 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_dds_offset() local
2878 ucontrol->value.integer.value[0] = hdsp_dds_offset(hdsp); in snd_hdsp_get_dds_offset()
2884 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_dds_offset() local
2888 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_dds_offset()
2891 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2892 if (val != hdsp_dds_offset(hdsp)) in snd_hdsp_put_dds_offset()
2893 change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_dds_offset()
2896 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2975 static int hdsp_rpm_input12(struct hdsp *hdsp) in hdsp_rpm_input12() argument
2977 switch (hdsp->control_register & HDSP_RPM_Inp12) { in hdsp_rpm_input12()
2993 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input12() local
2995 ucontrol->value.enumerated.item[0] = hdsp_rpm_input12(hdsp); in snd_hdsp_get_rpm_input12()
3000 static int hdsp_set_rpm_input12(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input12() argument
3002 hdsp->control_register &= ~HDSP_RPM_Inp12; in hdsp_set_rpm_input12()
3005 hdsp->control_register |= HDSP_RPM_Inp12_Phon_6dB; in hdsp_set_rpm_input12()
3010 hdsp->control_register |= HDSP_RPM_Inp12_Phon_n6dB; in hdsp_set_rpm_input12()
3013 hdsp->control_register |= HDSP_RPM_Inp12_Line_0dB; in hdsp_set_rpm_input12()
3016 hdsp->control_register |= HDSP_RPM_Inp12_Line_n6dB; in hdsp_set_rpm_input12()
3022 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input12()
3029 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input12() local
3033 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input12()
3040 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3041 if (val != hdsp_rpm_input12(hdsp)) in snd_hdsp_put_rpm_input12()
3042 change = (hdsp_set_rpm_input12(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input12()
3045 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3060 static int hdsp_rpm_input34(struct hdsp *hdsp) in hdsp_rpm_input34() argument
3062 switch (hdsp->control_register & HDSP_RPM_Inp34) { in hdsp_rpm_input34()
3078 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input34() local
3080 ucontrol->value.enumerated.item[0] = hdsp_rpm_input34(hdsp); in snd_hdsp_get_rpm_input34()
3085 static int hdsp_set_rpm_input34(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input34() argument
3087 hdsp->control_register &= ~HDSP_RPM_Inp34; in hdsp_set_rpm_input34()
3090 hdsp->control_register |= HDSP_RPM_Inp34_Phon_6dB; in hdsp_set_rpm_input34()
3095 hdsp->control_register |= HDSP_RPM_Inp34_Phon_n6dB; in hdsp_set_rpm_input34()
3098 hdsp->control_register |= HDSP_RPM_Inp34_Line_0dB; in hdsp_set_rpm_input34()
3101 hdsp->control_register |= HDSP_RPM_Inp34_Line_n6dB; in hdsp_set_rpm_input34()
3107 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input34()
3114 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input34() local
3118 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input34()
3125 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3126 if (val != hdsp_rpm_input34(hdsp)) in snd_hdsp_put_rpm_input34()
3127 change = (hdsp_set_rpm_input34(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input34()
3130 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3136 static int hdsp_rpm_bypass(struct hdsp *hdsp) in hdsp_rpm_bypass() argument
3138 return (hdsp->control_register & HDSP_RPM_Bypass) ? 1 : 0; in hdsp_rpm_bypass()
3144 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_bypass() local
3146 ucontrol->value.integer.value[0] = hdsp_rpm_bypass(hdsp); in snd_hdsp_get_rpm_bypass()
3151 static int hdsp_set_rpm_bypass(struct hdsp *hdsp, int on) in hdsp_set_rpm_bypass() argument
3154 hdsp->control_register |= HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3156 hdsp->control_register &= ~HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3157 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_bypass()
3164 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_bypass() local
3168 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_bypass()
3171 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3172 change = (int)val != hdsp_rpm_bypass(hdsp); in snd_hdsp_put_rpm_bypass()
3173 hdsp_set_rpm_bypass(hdsp, val); in snd_hdsp_put_rpm_bypass()
3174 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3188 static int hdsp_rpm_disconnect(struct hdsp *hdsp) in hdsp_rpm_disconnect() argument
3190 return (hdsp->control_register & HDSP_RPM_Disconnect) ? 1 : 0; in hdsp_rpm_disconnect()
3196 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_disconnect() local
3198 ucontrol->value.integer.value[0] = hdsp_rpm_disconnect(hdsp); in snd_hdsp_get_rpm_disconnect()
3203 static int hdsp_set_rpm_disconnect(struct hdsp *hdsp, int on) in hdsp_set_rpm_disconnect() argument
3206 hdsp->control_register |= HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3208 hdsp->control_register &= ~HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3209 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_disconnect()
3216 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_disconnect() local
3220 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_disconnect()
3223 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3224 change = (int)val != hdsp_rpm_disconnect(hdsp); in snd_hdsp_put_rpm_disconnect()
3225 hdsp_set_rpm_disconnect(hdsp, val); in snd_hdsp_put_rpm_disconnect()
3226 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3275 static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_controls() argument
3281 if (hdsp->io_type == RPM) { in snd_hdsp_create_controls()
3284 err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_rpm_controls[idx], hdsp)); in snd_hdsp_create_controls()
3292 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0) in snd_hdsp_create_controls()
3295 hdsp->spdif_ctl = kctl; in snd_hdsp_create_controls()
3301 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) in snd_hdsp_create_controls()
3303 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3306 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) in snd_hdsp_create_controls()
3312 if (hdsp->io_type == H9632) { in snd_hdsp_create_controls()
3314 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0) in snd_hdsp_create_controls()
3320 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3321 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0) in snd_hdsp_create_controls()
3335 struct hdsp *hdsp = entry->private_data; in snd_hdsp_proc_read() local
3344 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_proc_read()
3345 status2 = hdsp_read(hdsp, HDSP_status2Register); in snd_hdsp_proc_read()
3347 snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, in snd_hdsp_proc_read()
3348 hdsp->card->number + 1); in snd_hdsp_proc_read()
3350 hdsp->capture_buffer, hdsp->playback_buffer); in snd_hdsp_proc_read()
3352 hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); in snd_hdsp_proc_read()
3353 snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); in snd_hdsp_proc_read()
3355 hdsp->control2_register); in snd_hdsp_proc_read()
3359 if (hdsp_check_for_iobox(hdsp)) { in snd_hdsp_proc_read()
3365 if (hdsp_check_for_firmware(hdsp, 0)) { in snd_hdsp_proc_read()
3366 if (hdsp->state & HDSP_FirmwareCached) { in snd_hdsp_proc_read()
3367 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in snd_hdsp_proc_read()
3375 err = hdsp_request_fw_loader(hdsp); in snd_hdsp_proc_read()
3385 snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); in snd_hdsp_proc_read()
3386 snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); in snd_hdsp_proc_read()
3387 snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); in snd_hdsp_proc_read()
3388 snd_iprintf(buffer, "MIDI2 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut1)); in snd_hdsp_proc_read()
3389 snd_iprintf(buffer, "MIDI2 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn1)); in snd_hdsp_proc_read()
3390 snd_iprintf(buffer, "Use Midi Tasklet: %s\n", hdsp->use_midi_tasklet ? "on" : "off"); in snd_hdsp_proc_read()
3394 x = 1 << (6 + hdsp_decode_latency(hdsp->control_register & HDSP_LatencyMask)); in snd_hdsp_proc_read()
3396 …fer Size (Latency): %d samples (2 periods of %lu bytes)\n", x, (unsigned long) hdsp->period_bytes); in snd_hdsp_proc_read()
3397 snd_iprintf(buffer, "Hardware pointer (frames): %ld\n", hdsp_hw_pointer(hdsp)); in snd_hdsp_proc_read()
3398 snd_iprintf(buffer, "Precise pointer: %s\n", hdsp->precise_ptr ? "on" : "off"); in snd_hdsp_proc_read()
3399 snd_iprintf(buffer, "Line out: %s\n", (hdsp->control_register & HDSP_LineOut) ? "on" : "off"); in snd_hdsp_proc_read()
3405 switch (hdsp_clock_source(hdsp)) { in snd_hdsp_proc_read()
3441 if (hdsp_system_clock_mode(hdsp)) in snd_hdsp_proc_read()
3446 switch (hdsp_pref_sync_ref (hdsp)) { in snd_hdsp_proc_read()
3471 switch (hdsp_autosync_ref (hdsp)) { in snd_hdsp_proc_read()
3499 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp)); in snd_hdsp_proc_read()
3503 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); in snd_hdsp_proc_read()
3504 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); in snd_hdsp_proc_read()
3508 if (hdsp->io_type != RPM) { in snd_hdsp_proc_read()
3509 switch (hdsp_spdif_in(hdsp)) { in snd_hdsp_proc_read()
3528 if (RPM == hdsp->io_type) { in snd_hdsp_proc_read()
3529 if (hdsp->control_register & HDSP_RPM_Bypass) in snd_hdsp_proc_read()
3533 if (hdsp->control_register & HDSP_RPM_Disconnect) in snd_hdsp_proc_read()
3538 switch (hdsp->control_register & HDSP_RPM_Inp12) { in snd_hdsp_proc_read()
3558 switch (hdsp->control_register & HDSP_RPM_Inp34) { in snd_hdsp_proc_read()
3579 if (hdsp->control_register & HDSP_SPDIFOpticalOut) in snd_hdsp_proc_read()
3584 if (hdsp->control_register & HDSP_SPDIFProfessional) in snd_hdsp_proc_read()
3589 if (hdsp->control_register & HDSP_SPDIFEmphasis) in snd_hdsp_proc_read()
3594 if (hdsp->control_register & HDSP_SPDIFNonAudio) in snd_hdsp_proc_read()
3598 x = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_proc_read()
3613 switch (hdsp->io_type) { in snd_hdsp_proc_read()
3653 if (hdsp->io_type == H9632) { in snd_hdsp_proc_read()
3656 switch (hdsp_ad_gain(hdsp)) { in snd_hdsp_proc_read()
3669 switch (hdsp_da_gain(hdsp)) { in snd_hdsp_proc_read()
3682 switch (hdsp_phone_gain(hdsp)) { in snd_hdsp_proc_read()
3696 hdsp_toggle_setting(hdsp, HDSP_XLRBreakoutCable) ? in snd_hdsp_proc_read()
3699 if (hdsp->control_register & HDSP_AnalogExtensionBoard) in snd_hdsp_proc_read()
3708 static void snd_hdsp_proc_init(struct hdsp *hdsp) in snd_hdsp_proc_init() argument
3712 if (! snd_card_proc_new(hdsp->card, "hdsp", &entry)) in snd_hdsp_proc_init()
3713 snd_info_set_text_ops(entry, hdsp, snd_hdsp_proc_read); in snd_hdsp_proc_init()
3716 static void snd_hdsp_free_buffers(struct hdsp *hdsp) in snd_hdsp_free_buffers() argument
3718 snd_hammerfall_free_buffer(&hdsp->capture_dma_buf, hdsp->pci); in snd_hdsp_free_buffers()
3719 snd_hammerfall_free_buffer(&hdsp->playback_dma_buf, hdsp->pci); in snd_hdsp_free_buffers()
3722 static int snd_hdsp_initialize_memory(struct hdsp *hdsp) in snd_hdsp_initialize_memory() argument
3726 if (snd_hammerfall_get_buffer(hdsp->pci, &hdsp->capture_dma_buf, HDSP_DMA_AREA_BYTES) < 0 || in snd_hdsp_initialize_memory()
3727 snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) { in snd_hdsp_initialize_memory()
3728 if (hdsp->capture_dma_buf.area) in snd_hdsp_initialize_memory()
3729 snd_dma_free_pages(&hdsp->capture_dma_buf); in snd_hdsp_initialize_memory()
3730 dev_err(hdsp->card->dev, in snd_hdsp_initialize_memory()
3731 "%s: no buffers available\n", hdsp->card_name); in snd_hdsp_initialize_memory()
3737 cb_bus = ALIGN(hdsp->capture_dma_buf.addr, 0x10000ul); in snd_hdsp_initialize_memory()
3738 pb_bus = ALIGN(hdsp->playback_dma_buf.addr, 0x10000ul); in snd_hdsp_initialize_memory()
3742 hdsp_write(hdsp, HDSP_inputBufferAddress, cb_bus); in snd_hdsp_initialize_memory()
3743 hdsp_write(hdsp, HDSP_outputBufferAddress, pb_bus); in snd_hdsp_initialize_memory()
3745 hdsp->capture_buffer = hdsp->capture_dma_buf.area + (cb_bus - hdsp->capture_dma_buf.addr); in snd_hdsp_initialize_memory()
3746 hdsp->playback_buffer = hdsp->playback_dma_buf.area + (pb_bus - hdsp->playback_dma_buf.addr); in snd_hdsp_initialize_memory()
3751 static int snd_hdsp_set_defaults(struct hdsp *hdsp) in snd_hdsp_set_defaults() argument
3769 hdsp->control_register = HDSP_ClockModeMaster | in snd_hdsp_set_defaults()
3775 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3778 hdsp->control2_register = HDSP_BIGENDIAN_MODE; in snd_hdsp_set_defaults()
3780 hdsp->control2_register = 0; in snd_hdsp_set_defaults()
3782 if (hdsp->io_type == H9652) in snd_hdsp_set_defaults()
3783 snd_hdsp_9652_enable_mixer (hdsp); in snd_hdsp_set_defaults()
3785 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_set_defaults()
3787 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_set_defaults()
3788 hdsp_compute_period_size(hdsp); in snd_hdsp_set_defaults()
3793 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN; in snd_hdsp_set_defaults()
3795 …for (i = 0; i < ((hdsp->io_type == H9652 || hdsp->io_type == H9632) ? 1352 : HDSP_MATRIX_MIXER_SIZ… in snd_hdsp_set_defaults()
3796 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) in snd_hdsp_set_defaults()
3801 if (hdsp->io_type == H9632) { in snd_hdsp_set_defaults()
3802 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB); in snd_hdsp_set_defaults()
3803 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3809 hdsp_set_rate(hdsp, 48000, 1); in snd_hdsp_set_defaults()
3816 struct hdsp *hdsp = (struct hdsp *)arg; in hdsp_midi_tasklet() local
3818 if (hdsp->midi[0].pending) in hdsp_midi_tasklet()
3819 snd_hdsp_midi_input_read (&hdsp->midi[0]); in hdsp_midi_tasklet()
3820 if (hdsp->midi[1].pending) in hdsp_midi_tasklet()
3821 snd_hdsp_midi_input_read (&hdsp->midi[1]); in hdsp_midi_tasklet()
3826 struct hdsp *hdsp = (struct hdsp *) dev_id; in snd_hdsp_interrupt() local
3835 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_interrupt()
3844 hdsp_write(hdsp, HDSP_interruptConfirmation, 0); in snd_hdsp_interrupt()
3846 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff; in snd_hdsp_interrupt()
3847 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff; in snd_hdsp_interrupt()
3849 if (!(hdsp->state & HDSP_InitializationComplete)) in snd_hdsp_interrupt()
3853 if (hdsp->capture_substream) in snd_hdsp_interrupt()
3854 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); in snd_hdsp_interrupt()
3856 if (hdsp->playback_substream) in snd_hdsp_interrupt()
3857 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); in snd_hdsp_interrupt()
3861 if (hdsp->use_midi_tasklet) { in snd_hdsp_interrupt()
3863 hdsp->control_register &= ~HDSP_Midi0InterruptEnable; in snd_hdsp_interrupt()
3864 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3865 hdsp->midi[0].pending = 1; in snd_hdsp_interrupt()
3868 snd_hdsp_midi_input_read (&hdsp->midi[0]); in snd_hdsp_interrupt()
3871 …if (hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632 && midi1 && midi1… in snd_hdsp_interrupt()
3872 if (hdsp->use_midi_tasklet) { in snd_hdsp_interrupt()
3874 hdsp->control_register &= ~HDSP_Midi1InterruptEnable; in snd_hdsp_interrupt()
3875 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3876 hdsp->midi[1].pending = 1; in snd_hdsp_interrupt()
3879 snd_hdsp_midi_input_read (&hdsp->midi[1]); in snd_hdsp_interrupt()
3882 if (hdsp->use_midi_tasklet && schedule) in snd_hdsp_interrupt()
3883 tasklet_schedule(&hdsp->midi_tasklet); in snd_hdsp_interrupt()
3889 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_pointer() local
3890 return hdsp_hw_pointer(hdsp); in snd_hdsp_hw_pointer()
3893 static char *hdsp_channel_buffer_location(struct hdsp *hdsp, in hdsp_channel_buffer_location() argument
3900 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels)) in hdsp_channel_buffer_location()
3903 if ((mapped_channel = hdsp->channel_map[channel]) < 0) in hdsp_channel_buffer_location()
3907 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3909 return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3916 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_copy() local
3922 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_playback_copy()
3934 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_copy_kernel() local
3937 channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel); in snd_hdsp_playback_copy_kernel()
3948 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_copy() local
3954 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_capture_copy()
3966 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_copy_kernel() local
3969 channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel); in snd_hdsp_capture_copy_kernel()
3980 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_silence() local
3983 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_hw_silence()
3993 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_reset() local
3996 other = hdsp->capture_substream; in snd_hdsp_reset()
3998 other = hdsp->playback_substream; in snd_hdsp_reset()
3999 if (hdsp->running) in snd_hdsp_reset()
4000 runtime->status->hw_ptr = hdsp_hw_pointer(hdsp); in snd_hdsp_reset()
4019 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_params() local
4024 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hw_params()
4027 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_hw_params()
4030 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4033 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_hw_params()
4034 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= hdsp->creg_spdif_stream); in snd_hdsp_hw_params()
4035 this_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4036 other_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4038 this_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4039 other_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4049 if (params_rate(params) != hdsp->system_sample_rate) { in snd_hdsp_hw_params()
4050 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4055 if (params_period_size(params) != hdsp->period_bytes / 4) { in snd_hdsp_hw_params()
4056 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4063 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4067 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4073 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4074 if (! hdsp->clock_source_locked) { in snd_hdsp_hw_params()
4075 if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { in snd_hdsp_hw_params()
4076 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4081 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4083 if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) { in snd_hdsp_hw_params()
4094 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_channel_info() local
4097 if (snd_BUG_ON(info->channel >= hdsp->max_channels)) in snd_hdsp_channel_info()
4100 if ((mapped_channel = hdsp->channel_map[info->channel]) < 0) in snd_hdsp_channel_info()
4126 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_trigger() local
4130 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_trigger()
4133 if (hdsp_check_for_firmware(hdsp, 0)) /* no auto-loading in trigger */ in snd_hdsp_trigger()
4136 spin_lock(&hdsp->lock); in snd_hdsp_trigger()
4137 running = hdsp->running; in snd_hdsp_trigger()
4147 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4151 other = hdsp->capture_substream; in snd_hdsp_trigger()
4153 other = hdsp->playback_substream; in snd_hdsp_trigger()
4170 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4174 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4178 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4182 if (!hdsp->running && running) in snd_hdsp_trigger()
4183 hdsp_start_audio(hdsp); in snd_hdsp_trigger()
4184 else if (hdsp->running && !running) in snd_hdsp_trigger()
4185 hdsp_stop_audio(hdsp); in snd_hdsp_trigger()
4186 hdsp->running = running; in snd_hdsp_trigger()
4187 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4194 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_prepare() local
4197 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_prepare()
4200 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_prepare()
4203 spin_lock_irq(&hdsp->lock); in snd_hdsp_prepare()
4204 if (!hdsp->running) in snd_hdsp_prepare()
4205 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_prepare()
4206 spin_unlock_irq(&hdsp->lock); in snd_hdsp_prepare()
4288 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels() local
4290 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels()
4292 list[0] = hdsp->qs_in_channels; in snd_hdsp_hw_rule_in_channels()
4293 list[1] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4294 list[2] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4298 list[0] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4299 list[1] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4308 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels() local
4310 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels()
4311 list[0] = hdsp->qs_out_channels; in snd_hdsp_hw_rule_out_channels()
4312 list[1] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4313 list[2] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4316 list[0] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4317 list[1] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4325 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels_rate() local
4328 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels_rate()
4330 .min = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4331 .max = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4337 .min = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4338 .max = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4344 .min = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4345 .max = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4356 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels_rate() local
4359 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels_rate()
4361 .min = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4362 .max = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4368 .min = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4369 .max = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4375 .min = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4376 .max = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4387 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_out_channels() local
4390 if (c->min >= hdsp->ss_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4397 } else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_out_channels()
4404 } else if (c->max <= hdsp->ds_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4418 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_in_channels() local
4421 if (c->min >= hdsp->ss_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4428 } else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_in_channels()
4435 } else if (c->max <= hdsp->ds_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4448 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_open() local
4451 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_playback_open()
4454 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_playback_open()
4457 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4462 runtime->dma_area = hdsp->playback_buffer; in snd_hdsp_playback_open()
4465 hdsp->playback_pid = current->pid; in snd_hdsp_playback_open()
4466 hdsp->playback_substream = substream; in snd_hdsp_playback_open()
4468 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4472 if (hdsp->clock_source_locked) { in snd_hdsp_playback_open()
4473 runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate; in snd_hdsp_playback_open()
4474 } else if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4479 if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4480 runtime->hw.channels_min = hdsp->qs_out_channels; in snd_hdsp_playback_open()
4481 runtime->hw.channels_max = hdsp->ss_out_channels; in snd_hdsp_playback_open()
4485 snd_hdsp_hw_rule_out_channels, hdsp, in snd_hdsp_playback_open()
4488 snd_hdsp_hw_rule_out_channels_rate, hdsp, in snd_hdsp_playback_open()
4491 snd_hdsp_hw_rule_rate_out_channels, hdsp, in snd_hdsp_playback_open()
4494 if (RPM != hdsp->io_type) { in snd_hdsp_playback_open()
4495 hdsp->creg_spdif_stream = hdsp->creg_spdif; in snd_hdsp_playback_open()
4496 hdsp->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_open()
4497 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_open()
4498 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_open()
4505 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_release() local
4507 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4509 hdsp->playback_pid = -1; in snd_hdsp_playback_release()
4510 hdsp->playback_substream = NULL; in snd_hdsp_playback_release()
4512 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4514 if (RPM != hdsp->io_type) { in snd_hdsp_playback_release()
4515 hdsp->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_release()
4516 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_release()
4517 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_release()
4525 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_open() local
4528 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_capture_open()
4531 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_capture_open()
4534 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4539 runtime->dma_area = hdsp->capture_buffer; in snd_hdsp_capture_open()
4542 hdsp->capture_pid = current->pid; in snd_hdsp_capture_open()
4543 hdsp->capture_substream = substream; in snd_hdsp_capture_open()
4545 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4549 if (hdsp->io_type == H9632) { in snd_hdsp_capture_open()
4550 runtime->hw.channels_min = hdsp->qs_in_channels; in snd_hdsp_capture_open()
4551 runtime->hw.channels_max = hdsp->ss_in_channels; in snd_hdsp_capture_open()
4557 snd_hdsp_hw_rule_in_channels, hdsp, in snd_hdsp_capture_open()
4560 snd_hdsp_hw_rule_in_channels_rate, hdsp, in snd_hdsp_capture_open()
4563 snd_hdsp_hw_rule_rate_in_channels, hdsp, in snd_hdsp_capture_open()
4570 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_release() local
4572 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4574 hdsp->capture_pid = -1; in snd_hdsp_capture_release()
4575 hdsp->capture_substream = NULL; in snd_hdsp_capture_release()
4577 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4608 static int hdsp_9652_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9652_get_peak() argument
4613 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9652_get_peak()
4620 if (copy_u32_le(&peak_rms->input_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4623 if (copy_u32_le(&peak_rms->playback_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4626 if (copy_u32_le(&peak_rms->output_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4629 if (copy_u48_le(&peak_rms->input_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4630 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4633 if (copy_u48_le(&peak_rms->playback_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4634 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4637 if (copy_u48_le(&peak_rms->output_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4638 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4645 static int hdsp_9632_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9632_get_peak() argument
4651 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9632_get_peak()
4653 m = (struct hdsp_9632_meters __iomem *)(hdsp->iobase+HDSP_9632_metersBase); in hdsp_9632_get_peak()
4675 static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_get_peak() argument
4681 hdsp->iobase + HDSP_playbackPeakLevel + i * 4)) in hdsp_get_peak()
4684 hdsp->iobase + HDSP_inputPeakLevel + i * 4)) in hdsp_get_peak()
4689 hdsp->iobase + HDSP_outputPeakLevel + i * 4)) in hdsp_get_peak()
4694 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4, in hdsp_get_peak()
4695 hdsp->iobase + HDSP_playbackRmsLevel + i * 8)) in hdsp_get_peak()
4698 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4, in hdsp_get_peak()
4699 hdsp->iobase + HDSP_inputRmsLevel + i * 8)) in hdsp_get_peak()
4707 struct hdsp *hdsp = hw->private_data; in snd_hdsp_hwdep_ioctl() local
4715 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4719 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4723 if (!(hdsp->state & HDSP_FirmwareLoaded)) { in snd_hdsp_hwdep_ioctl()
4724 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4729 switch (hdsp->io_type) { in snd_hdsp_hwdep_ioctl()
4731 return hdsp_9652_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4733 return hdsp_9632_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4735 return hdsp_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4743 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4747 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4752 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4753 info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4754 info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4755 if (hdsp->io_type != H9632) in snd_hdsp_hwdep_ioctl()
4756 info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4757 info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4758 …for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632) ? … in snd_hdsp_hwdep_ioctl()
4759 info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i); in snd_hdsp_hwdep_ioctl()
4760 info.spdif_in = (unsigned char)hdsp_spdif_in(hdsp); in snd_hdsp_hwdep_ioctl()
4761 info.spdif_out = (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4764 hdsp_toggle_setting(hdsp, HDSP_SPDIFProfessional); in snd_hdsp_hwdep_ioctl()
4766 hdsp_toggle_setting(hdsp, HDSP_SPDIFEmphasis); in snd_hdsp_hwdep_ioctl()
4768 hdsp_toggle_setting(hdsp, HDSP_SPDIFNonAudio); in snd_hdsp_hwdep_ioctl()
4769 info.spdif_sample_rate = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4770 info.system_sample_rate = hdsp->system_sample_rate; in snd_hdsp_hwdep_ioctl()
4771 info.autosync_sample_rate = hdsp_external_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4772 info.system_clock_mode = (unsigned char)hdsp_system_clock_mode(hdsp); in snd_hdsp_hwdep_ioctl()
4773 info.clock_source = (unsigned char)hdsp_clock_source(hdsp); in snd_hdsp_hwdep_ioctl()
4774 info.autosync_ref = (unsigned char)hdsp_autosync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4776 hdsp_toggle_setting(hdsp, HDSP_LineOut); in snd_hdsp_hwdep_ioctl()
4777 if (hdsp->io_type == H9632) { in snd_hdsp_hwdep_ioctl()
4778 info.da_gain = (unsigned char)hdsp_da_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4779 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4780 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4782 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4785 } else if (hdsp->io_type == RPM) { in snd_hdsp_hwdep_ioctl()
4786 info.da_gain = (unsigned char) hdsp_rpm_input12(hdsp); in snd_hdsp_hwdep_ioctl()
4787 info.ad_gain = (unsigned char) hdsp_rpm_input34(hdsp); in snd_hdsp_hwdep_ioctl()
4789 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) in snd_hdsp_hwdep_ioctl()
4791 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4793 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4801 if (hdsp->io_type != H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4802 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4803 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4812 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4813 if (hdsp->io_type == Undefined) { in snd_hdsp_hwdep_ioctl()
4814 if ((err = hdsp_get_iobox_version(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4818 hdsp_version.io_type = hdsp->io_type; in snd_hdsp_hwdep_ioctl()
4819 hdsp_version.firmware_rev = hdsp->firmware_rev; in snd_hdsp_hwdep_ioctl()
4829 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4831 if (hdsp->io_type == Undefined) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4833 if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded)) in snd_hdsp_hwdep_ioctl()
4836 dev_info(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4843 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hwdep_ioctl()
4846 if (!hdsp->fw_uploaded) { in snd_hdsp_hwdep_ioctl()
4847 hdsp->fw_uploaded = vmalloc(HDSP_FIRMWARE_SIZE); in snd_hdsp_hwdep_ioctl()
4848 if (!hdsp->fw_uploaded) in snd_hdsp_hwdep_ioctl()
4852 if (copy_from_user(hdsp->fw_uploaded, firmware_data, in snd_hdsp_hwdep_ioctl()
4854 vfree(hdsp->fw_uploaded); in snd_hdsp_hwdep_ioctl()
4855 hdsp->fw_uploaded = NULL; in snd_hdsp_hwdep_ioctl()
4859 hdsp->state |= HDSP_FirmwareCached; in snd_hdsp_hwdep_ioctl()
4861 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4864 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_hwdep_ioctl()
4865 if ((err = snd_hdsp_enable_io(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4868 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_hwdep_ioctl()
4869 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_hwdep_ioctl()
4871 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { in snd_hdsp_hwdep_ioctl()
4872 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4881 …if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) in snd_hdsp_hwdep_ioctl()
4916 static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_hwdep() argument
4924 hdsp->hwdep = hw; in snd_hdsp_create_hwdep()
4925 hw->private_data = hdsp; in snd_hdsp_create_hwdep()
4934 static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_pcm() argument
4939 if ((err = snd_pcm_new(card, hdsp->card_name, 0, 1, 1, &pcm)) < 0) in snd_hdsp_create_pcm()
4942 hdsp->pcm = pcm; in snd_hdsp_create_pcm()
4943 pcm->private_data = hdsp; in snd_hdsp_create_pcm()
4944 strcpy(pcm->name, hdsp->card_name); in snd_hdsp_create_pcm()
4954 static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp) in snd_hdsp_9652_enable_mixer() argument
4956 hdsp->control2_register |= HDSP_9652_ENABLE_MIXER; in snd_hdsp_9652_enable_mixer()
4957 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_9652_enable_mixer()
4960 static int snd_hdsp_enable_io (struct hdsp *hdsp) in snd_hdsp_enable_io() argument
4964 if (hdsp_fifo_wait (hdsp, 0, 100)) { in snd_hdsp_enable_io()
4965 dev_err(hdsp->card->dev, in snd_hdsp_enable_io()
4970 for (i = 0; i < hdsp->max_channels; ++i) { in snd_hdsp_enable_io()
4971 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1); in snd_hdsp_enable_io()
4972 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1); in snd_hdsp_enable_io()
4978 static void snd_hdsp_initialize_channels(struct hdsp *hdsp) in snd_hdsp_initialize_channels() argument
4982 switch (hdsp->io_type) { in snd_hdsp_initialize_channels()
4984 hdsp->card_name = "RME Hammerfall DSP + Digiface"; in snd_hdsp_initialize_channels()
4985 hdsp->ss_in_channels = hdsp->ss_out_channels = DIGIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
4986 hdsp->ds_in_channels = hdsp->ds_out_channels = DIGIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
4990 hdsp->card_name = "RME Hammerfall HDSP 9652"; in snd_hdsp_initialize_channels()
4991 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS; in snd_hdsp_initialize_channels()
4992 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS; in snd_hdsp_initialize_channels()
4996 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_initialize_channels()
5000 hdsp->card_name = "RME Hammerfall HDSP 9632"; in snd_hdsp_initialize_channels()
5001 hdsp->ss_in_channels = H9632_SS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
5002 hdsp->ds_in_channels = H9632_DS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
5003 hdsp->qs_in_channels = H9632_QS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
5004 hdsp->ss_out_channels = H9632_SS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
5005 hdsp->ds_out_channels = H9632_DS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
5006 hdsp->qs_out_channels = H9632_QS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
5010 hdsp->card_name = "RME Hammerfall DSP + Multiface"; in snd_hdsp_initialize_channels()
5011 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
5012 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
5016 hdsp->card_name = "RME Hammerfall DSP + RPM"; in snd_hdsp_initialize_channels()
5017 hdsp->ss_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
5018 hdsp->ss_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
5019 hdsp->ds_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
5020 hdsp->ds_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
5029 static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp) in snd_hdsp_initialize_midi_flush() argument
5031 snd_hdsp_flush_midi_input (hdsp, 0); in snd_hdsp_initialize_midi_flush()
5032 snd_hdsp_flush_midi_input (hdsp, 1); in snd_hdsp_initialize_midi_flush()
5035 static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_alsa_devices() argument
5039 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5046 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { in snd_hdsp_create_alsa_devices()
5052 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_alsa_devices()
5053 if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) { in snd_hdsp_create_alsa_devices()
5060 if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5066 snd_hdsp_proc_init(hdsp); in snd_hdsp_create_alsa_devices()
5068 hdsp->system_sample_rate = -1; in snd_hdsp_create_alsa_devices()
5069 hdsp->playback_pid = -1; in snd_hdsp_create_alsa_devices()
5070 hdsp->capture_pid = -1; in snd_hdsp_create_alsa_devices()
5071 hdsp->capture_substream = NULL; in snd_hdsp_create_alsa_devices()
5072 hdsp->playback_substream = NULL; in snd_hdsp_create_alsa_devices()
5074 if ((err = snd_hdsp_set_defaults(hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5080 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_create_alsa_devices()
5082 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_create_alsa_devices()
5083 hdsp->port, hdsp->irq); in snd_hdsp_create_alsa_devices()
5090 hdsp->state |= HDSP_InitializationComplete; in snd_hdsp_create_alsa_devices()
5097 static int hdsp_request_fw_loader(struct hdsp *hdsp) in hdsp_request_fw_loader() argument
5103 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5105 if (hdsp->io_type == Undefined) { in hdsp_request_fw_loader()
5106 if ((err = hdsp_get_iobox_version(hdsp)) < 0) in hdsp_request_fw_loader()
5108 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5113 switch (hdsp->io_type) { in hdsp_request_fw_loader()
5118 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5124 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5130 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5131 "invalid io_type %d\n", hdsp->io_type); in hdsp_request_fw_loader()
5135 if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) { in hdsp_request_fw_loader()
5136 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5141 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5148 hdsp->firmware = fw; in hdsp_request_fw_loader()
5150 hdsp->state |= HDSP_FirmwareCached; in hdsp_request_fw_loader()
5152 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) in hdsp_request_fw_loader()
5155 if (!(hdsp->state & HDSP_InitializationComplete)) { in hdsp_request_fw_loader()
5156 if ((err = snd_hdsp_enable_io(hdsp)) < 0) in hdsp_request_fw_loader()
5159 if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) { in hdsp_request_fw_loader()
5160 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5164 snd_hdsp_initialize_channels(hdsp); in hdsp_request_fw_loader()
5165 snd_hdsp_initialize_midi_flush(hdsp); in hdsp_request_fw_loader()
5166 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { in hdsp_request_fw_loader()
5167 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5176 struct hdsp *hdsp) in snd_hdsp_create() argument
5178 struct pci_dev *pci = hdsp->pci; in snd_hdsp_create()
5183 hdsp->irq = -1; in snd_hdsp_create()
5184 hdsp->state = 0; in snd_hdsp_create()
5185 hdsp->midi[0].rmidi = NULL; in snd_hdsp_create()
5186 hdsp->midi[1].rmidi = NULL; in snd_hdsp_create()
5187 hdsp->midi[0].input = NULL; in snd_hdsp_create()
5188 hdsp->midi[1].input = NULL; in snd_hdsp_create()
5189 hdsp->midi[0].output = NULL; in snd_hdsp_create()
5190 hdsp->midi[1].output = NULL; in snd_hdsp_create()
5191 hdsp->midi[0].pending = 0; in snd_hdsp_create()
5192 hdsp->midi[1].pending = 0; in snd_hdsp_create()
5193 spin_lock_init(&hdsp->midi[0].lock); in snd_hdsp_create()
5194 spin_lock_init(&hdsp->midi[1].lock); in snd_hdsp_create()
5195 hdsp->iobase = NULL; in snd_hdsp_create()
5196 hdsp->control_register = 0; in snd_hdsp_create()
5197 hdsp->control2_register = 0; in snd_hdsp_create()
5198 hdsp->io_type = Undefined; in snd_hdsp_create()
5199 hdsp->max_channels = 26; in snd_hdsp_create()
5201 hdsp->card = card; in snd_hdsp_create()
5203 spin_lock_init(&hdsp->lock); in snd_hdsp_create()
5205 tasklet_init(&hdsp->midi_tasklet, hdsp_midi_tasklet, (unsigned long)hdsp); in snd_hdsp_create()
5207 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev); in snd_hdsp_create()
5208 hdsp->firmware_rev &= 0xff; in snd_hdsp_create()
5217 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF); in snd_hdsp_create()
5222 if (hdsp->firmware_rev < 0xa) in snd_hdsp_create()
5224 else if (hdsp->firmware_rev < 0x64) in snd_hdsp_create()
5225 hdsp->card_name = "RME Hammerfall DSP"; in snd_hdsp_create()
5226 else if (hdsp->firmware_rev < 0x96) { in snd_hdsp_create()
5227 hdsp->card_name = "RME HDSP 9652"; in snd_hdsp_create()
5230 hdsp->card_name = "RME HDSP 9632"; in snd_hdsp_create()
5231 hdsp->max_channels = 16; in snd_hdsp_create()
5238 pci_set_master(hdsp->pci); in snd_hdsp_create()
5242 hdsp->port = pci_resource_start(pci, 0); in snd_hdsp_create()
5243 if ((hdsp->iobase = ioremap_nocache(hdsp->port, HDSP_IO_EXTENT)) == NULL) { in snd_hdsp_create()
5244 dev_err(hdsp->card->dev, "unable to remap region 0x%lx-0x%lx\n", in snd_hdsp_create()
5245 hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1); in snd_hdsp_create()
5250 KBUILD_MODNAME, hdsp)) { in snd_hdsp_create()
5251 dev_err(hdsp->card->dev, "unable to use IRQ %d\n", pci->irq); in snd_hdsp_create()
5255 hdsp->irq = pci->irq; in snd_hdsp_create()
5256 hdsp->precise_ptr = 0; in snd_hdsp_create()
5257 hdsp->use_midi_tasklet = 1; in snd_hdsp_create()
5258 hdsp->dds_value = 0; in snd_hdsp_create()
5260 if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) in snd_hdsp_create()
5266 err = hdsp_wait_for_iobox(hdsp, 1000, 10); in snd_hdsp_create()
5271 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in snd_hdsp_create()
5272 if ((err = hdsp_request_fw_loader(hdsp)) < 0) in snd_hdsp_create()
5277 dev_err(hdsp->card->dev, in snd_hdsp_create()
5283 dev_info(hdsp->card->dev, in snd_hdsp_create()
5285 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) in snd_hdsp_create()
5289 dev_info(hdsp->card->dev, in snd_hdsp_create()
5291 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in snd_hdsp_create()
5292 hdsp->io_type = RPM; in snd_hdsp_create()
5293 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in snd_hdsp_create()
5294 hdsp->io_type = Multiface; in snd_hdsp_create()
5296 hdsp->io_type = Digiface; in snd_hdsp_create()
5300 if ((err = snd_hdsp_enable_io(hdsp)) != 0) in snd_hdsp_create()
5304 hdsp->io_type = H9652; in snd_hdsp_create()
5307 hdsp->io_type = H9632; in snd_hdsp_create()
5309 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) in snd_hdsp_create()
5312 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_create()
5313 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_create()
5315 hdsp->state |= HDSP_FirmwareLoaded; in snd_hdsp_create()
5317 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) in snd_hdsp_create()
5323 static int snd_hdsp_free(struct hdsp *hdsp) in snd_hdsp_free() argument
5325 if (hdsp->port) { in snd_hdsp_free()
5327 tasklet_kill(&hdsp->midi_tasklet); in snd_hdsp_free()
5328 …hdsp->control_register &= ~(HDSP_Start|HDSP_AudioInterruptEnable|HDSP_Midi0InterruptEnable|HDSP_Mi… in snd_hdsp_free()
5329 hdsp_write (hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_free()
5332 if (hdsp->irq >= 0) in snd_hdsp_free()
5333 free_irq(hdsp->irq, (void *)hdsp); in snd_hdsp_free()
5335 snd_hdsp_free_buffers(hdsp); in snd_hdsp_free()
5337 release_firmware(hdsp->firmware); in snd_hdsp_free()
5338 vfree(hdsp->fw_uploaded); in snd_hdsp_free()
5339 iounmap(hdsp->iobase); in snd_hdsp_free()
5341 if (hdsp->port) in snd_hdsp_free()
5342 pci_release_regions(hdsp->pci); in snd_hdsp_free()
5344 pci_disable_device(hdsp->pci); in snd_hdsp_free()
5350 struct hdsp *hdsp = card->private_data; in snd_hdsp_card_free() local
5352 if (hdsp) in snd_hdsp_card_free()
5353 snd_hdsp_free(hdsp); in snd_hdsp_card_free()
5360 struct hdsp *hdsp; in snd_hdsp_probe() local
5372 sizeof(struct hdsp), &card); in snd_hdsp_probe()
5376 hdsp = card->private_data; in snd_hdsp_probe()
5378 hdsp->dev = dev; in snd_hdsp_probe()
5379 hdsp->pci = pci; in snd_hdsp_probe()
5380 err = snd_hdsp_create(card, hdsp); in snd_hdsp_probe()
5385 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_probe()
5386 hdsp->port, hdsp->irq); in snd_hdsp_probe()