Lines Matching refs:hdsp
434 struct hdsp *hdsp; member
445 struct hdsp { struct
595 static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp);
596 static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp);
597 static int snd_hdsp_enable_io (struct hdsp *hdsp);
598 static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp);
599 static void snd_hdsp_initialize_channels (struct hdsp *hdsp);
600 static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout);
601 static int hdsp_autosync_ref(struct hdsp *hdsp);
602 static int snd_hdsp_set_defaults(struct hdsp *hdsp);
603 static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp);
605 static int hdsp_playback_to_output_key (struct hdsp *hdsp, int in, int out) in hdsp_playback_to_output_key() argument
607 switch (hdsp->io_type) { in hdsp_playback_to_output_key()
612 if (hdsp->firmware_rev == 0xa) in hdsp_playback_to_output_key()
623 static int hdsp_input_to_output_key (struct hdsp *hdsp, int in, int out) in hdsp_input_to_output_key() argument
625 switch (hdsp->io_type) { in hdsp_input_to_output_key()
630 if (hdsp->firmware_rev == 0xa) in hdsp_input_to_output_key()
641 static void hdsp_write(struct hdsp *hdsp, int reg, int val) in hdsp_write() argument
643 writel(val, hdsp->iobase + reg); in hdsp_write()
646 static unsigned int hdsp_read(struct hdsp *hdsp, int reg) in hdsp_read() argument
648 return readl (hdsp->iobase + reg); in hdsp_read()
651 static int hdsp_check_for_iobox (struct hdsp *hdsp) in hdsp_check_for_iobox() argument
655 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return 0; in hdsp_check_for_iobox()
657 if (0 == (hdsp_read(hdsp, HDSP_statusRegister) & in hdsp_check_for_iobox()
660 dev_dbg(hdsp->card->dev, in hdsp_check_for_iobox()
668 dev_err(hdsp->card->dev, "no IO box connected!\n"); in hdsp_check_for_iobox()
669 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_check_for_iobox()
673 static int hdsp_wait_for_iobox(struct hdsp *hdsp, unsigned int loops, in hdsp_wait_for_iobox() argument
678 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_wait_for_iobox()
682 if (hdsp_read(hdsp, HDSP_statusRegister) & HDSP_ConfigError) in hdsp_wait_for_iobox()
685 dev_dbg(hdsp->card->dev, "iobox found after %ums!\n", in hdsp_wait_for_iobox()
691 dev_info(hdsp->card->dev, "no IO box connected!\n"); in hdsp_wait_for_iobox()
692 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_wait_for_iobox()
696 static int snd_hdsp_load_firmware_from_cache(struct hdsp *hdsp) { in snd_hdsp_load_firmware_from_cache() argument
702 if (hdsp->fw_uploaded) in snd_hdsp_load_firmware_from_cache()
703 cache = hdsp->fw_uploaded; in snd_hdsp_load_firmware_from_cache()
705 if (!hdsp->firmware) in snd_hdsp_load_firmware_from_cache()
707 cache = (u32 *)hdsp->firmware->data; in snd_hdsp_load_firmware_from_cache()
712 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in snd_hdsp_load_firmware_from_cache()
714 dev_info(hdsp->card->dev, "loading firmware\n"); in snd_hdsp_load_firmware_from_cache()
716 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_PROGRAM); in snd_hdsp_load_firmware_from_cache()
717 hdsp_write (hdsp, HDSP_fifoData, 0); in snd_hdsp_load_firmware_from_cache()
719 if (hdsp_fifo_wait (hdsp, 0, HDSP_LONG_WAIT)) { in snd_hdsp_load_firmware_from_cache()
720 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
722 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
726 hdsp_write (hdsp, HDSP_control2Reg, HDSP_S_LOAD); in snd_hdsp_load_firmware_from_cache()
729 hdsp_write(hdsp, HDSP_fifoData, cache[i]); in snd_hdsp_load_firmware_from_cache()
730 if (hdsp_fifo_wait (hdsp, 127, HDSP_LONG_WAIT)) { in snd_hdsp_load_firmware_from_cache()
731 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
733 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
738 hdsp_fifo_wait(hdsp, 3, HDSP_LONG_WAIT); in snd_hdsp_load_firmware_from_cache()
739 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200); in snd_hdsp_load_firmware_from_cache()
743 hdsp->control2_register = HDSP_BIGENDIAN_MODE; in snd_hdsp_load_firmware_from_cache()
745 hdsp->control2_register = 0; in snd_hdsp_load_firmware_from_cache()
747 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_load_firmware_from_cache()
748 dev_info(hdsp->card->dev, "finished firmware loading\n"); in snd_hdsp_load_firmware_from_cache()
751 if (hdsp->state & HDSP_InitializationComplete) { in snd_hdsp_load_firmware_from_cache()
752 dev_info(hdsp->card->dev, in snd_hdsp_load_firmware_from_cache()
754 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_load_firmware_from_cache()
755 snd_hdsp_set_defaults(hdsp); in snd_hdsp_load_firmware_from_cache()
756 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_load_firmware_from_cache()
759 hdsp->state |= HDSP_FirmwareLoaded; in snd_hdsp_load_firmware_from_cache()
764 static int hdsp_get_iobox_version (struct hdsp *hdsp) in hdsp_get_iobox_version() argument
766 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in hdsp_get_iobox_version()
768 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
769 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
771 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) { in hdsp_get_iobox_version()
772 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
773 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
776 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S200 | HDSP_PROGRAM); in hdsp_get_iobox_version()
777 hdsp_write (hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
778 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) in hdsp_get_iobox_version()
781 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
782 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
783 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) { in hdsp_get_iobox_version()
784 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
785 dev_info(hdsp->card->dev, "Digiface found\n"); in hdsp_get_iobox_version()
789 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
790 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
791 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
792 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) == 0) in hdsp_get_iobox_version()
795 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S300); in hdsp_get_iobox_version()
796 hdsp_write(hdsp, HDSP_control2Reg, HDSP_S_LOAD); in hdsp_get_iobox_version()
797 hdsp_write(hdsp, HDSP_fifoData, 0); in hdsp_get_iobox_version()
798 if (hdsp_fifo_wait(hdsp, 0, HDSP_SHORT_WAIT) < 0) in hdsp_get_iobox_version()
801 hdsp->io_type = RPM; in hdsp_get_iobox_version()
802 dev_info(hdsp->card->dev, "RPM found\n"); in hdsp_get_iobox_version()
806 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in hdsp_get_iobox_version()
807 hdsp->io_type = RPM; in hdsp_get_iobox_version()
808 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in hdsp_get_iobox_version()
809 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
811 hdsp->io_type = Digiface; in hdsp_get_iobox_version()
816 hdsp->io_type = Multiface; in hdsp_get_iobox_version()
817 dev_info(hdsp->card->dev, "Multiface found\n"); in hdsp_get_iobox_version()
822 static int hdsp_request_fw_loader(struct hdsp *hdsp);
824 static int hdsp_check_for_firmware (struct hdsp *hdsp, int load_on_demand) in hdsp_check_for_firmware() argument
826 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_check_for_firmware()
828 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in hdsp_check_for_firmware()
829 hdsp->state &= ~HDSP_FirmwareLoaded; in hdsp_check_for_firmware()
832 dev_err(hdsp->card->dev, "firmware not present.\n"); in hdsp_check_for_firmware()
834 if (! (hdsp->state & HDSP_FirmwareCached)) { in hdsp_check_for_firmware()
835 if (! hdsp_request_fw_loader(hdsp)) in hdsp_check_for_firmware()
837 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
841 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in hdsp_check_for_firmware()
842 dev_err(hdsp->card->dev, in hdsp_check_for_firmware()
851 static int hdsp_fifo_wait(struct hdsp *hdsp, int count, int timeout) in hdsp_fifo_wait() argument
861 if ((int)(hdsp_read (hdsp, HDSP_fifoStatus) & 0xff) <= count) in hdsp_fifo_wait()
871 dev_warn(hdsp->card->dev, in hdsp_fifo_wait()
877 static int hdsp_read_gain (struct hdsp *hdsp, unsigned int addr) in hdsp_read_gain() argument
882 return hdsp->mixer_matrix[addr]; in hdsp_read_gain()
885 static int hdsp_write_gain(struct hdsp *hdsp, unsigned int addr, unsigned short data) in hdsp_write_gain() argument
892 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) { in hdsp_write_gain()
906 if (hdsp->io_type == H9632 && addr >= 512) in hdsp_write_gain()
909 if (hdsp->io_type == H9652 && addr >= 1352) in hdsp_write_gain()
912 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
924 hdsp_write (hdsp, 4096 + (ad*4), in hdsp_write_gain()
925 (hdsp->mixer_matrix[(addr&0x7fe)+1] << 16) + in hdsp_write_gain()
926 hdsp->mixer_matrix[addr&0x7fe]); in hdsp_write_gain()
934 if (hdsp_fifo_wait(hdsp, 127, HDSP_LONG_WAIT)) in hdsp_write_gain()
937 hdsp_write (hdsp, HDSP_fifoData, ad); in hdsp_write_gain()
938 hdsp->mixer_matrix[addr] = data; in hdsp_write_gain()
945 static int snd_hdsp_use_is_exclusive(struct hdsp *hdsp) in snd_hdsp_use_is_exclusive() argument
950 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
951 if ((hdsp->playback_pid != hdsp->capture_pid) && in snd_hdsp_use_is_exclusive()
952 (hdsp->playback_pid >= 0) && (hdsp->capture_pid >= 0)) in snd_hdsp_use_is_exclusive()
954 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_use_is_exclusive()
958 static int hdsp_spdif_sample_rate(struct hdsp *hdsp) in hdsp_spdif_sample_rate() argument
960 unsigned int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sample_rate()
964 if (hdsp->io_type == H9632) in hdsp_spdif_sample_rate()
978 if (hdsp->io_type == H9632) return 128000; in hdsp_spdif_sample_rate()
981 if (hdsp->io_type == H9632) return 176400; in hdsp_spdif_sample_rate()
984 if (hdsp->io_type == H9632) return 192000; in hdsp_spdif_sample_rate()
989 dev_warn(hdsp->card->dev, in hdsp_spdif_sample_rate()
995 static int hdsp_external_sample_rate(struct hdsp *hdsp) in hdsp_external_sample_rate() argument
997 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_external_sample_rate()
1004 if (hdsp->io_type == H9632 && in hdsp_external_sample_rate()
1005 hdsp_autosync_ref(hdsp) == HDSP_AUTOSYNC_FROM_SPDIF) in hdsp_external_sample_rate()
1006 return hdsp_spdif_sample_rate(hdsp); in hdsp_external_sample_rate()
1020 static void hdsp_compute_period_size(struct hdsp *hdsp) in hdsp_compute_period_size() argument
1022 hdsp->period_bytes = 1 << ((hdsp_decode_latency(hdsp->control_register) + 8)); in hdsp_compute_period_size()
1025 static snd_pcm_uframes_t hdsp_hw_pointer(struct hdsp *hdsp) in hdsp_hw_pointer() argument
1029 position = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_hw_pointer()
1031 if (!hdsp->precise_ptr) in hdsp_hw_pointer()
1032 return (position & HDSP_BufferID) ? (hdsp->period_bytes / 4) : 0; in hdsp_hw_pointer()
1036 position &= (hdsp->period_bytes/2) - 1; in hdsp_hw_pointer()
1040 static void hdsp_reset_hw_pointer(struct hdsp *hdsp) in hdsp_reset_hw_pointer() argument
1042 hdsp_write (hdsp, HDSP_resetPointer, 0); in hdsp_reset_hw_pointer()
1043 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_reset_hw_pointer()
1047 hdsp_write (hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_reset_hw_pointer()
1050 static void hdsp_start_audio(struct hdsp *s) in hdsp_start_audio()
1056 static void hdsp_stop_audio(struct hdsp *s) in hdsp_stop_audio()
1062 static void hdsp_silence_playback(struct hdsp *hdsp) in hdsp_silence_playback() argument
1064 memset(hdsp->playback_buffer, 0, HDSP_DMA_AREA_BYTES); in hdsp_silence_playback()
1067 static int hdsp_set_interrupt_interval(struct hdsp *s, unsigned int frames) in hdsp_set_interrupt_interval()
1092 static void hdsp_set_dds_value(struct hdsp *hdsp, int rate) in hdsp_set_dds_value() argument
1107 hdsp->dds_value = n; in hdsp_set_dds_value()
1108 hdsp_write(hdsp, HDSP_freqReg, hdsp->dds_value); in hdsp_set_dds_value()
1111 static int hdsp_set_rate(struct hdsp *hdsp, int rate, int called_internally) in hdsp_set_rate() argument
1122 if (!(hdsp->control_register & HDSP_ClockModeMaster)) { in hdsp_set_rate()
1125 dev_err(hdsp->card->dev, in hdsp_set_rate()
1130 int external_freq = hdsp_external_sample_rate(hdsp); in hdsp_set_rate()
1131 int spdif_freq = hdsp_spdif_sample_rate(hdsp); in hdsp_set_rate()
1133 if ((spdif_freq == external_freq*2) && (hdsp_autosync_ref(hdsp) >= HDSP_AUTOSYNC_FROM_ADAT1)) in hdsp_set_rate()
1134 dev_info(hdsp->card->dev, in hdsp_set_rate()
1136 …else if (hdsp->io_type == H9632 && (spdif_freq == external_freq*4) && (hdsp_autosync_ref(hdsp) >= … in hdsp_set_rate()
1137 dev_info(hdsp->card->dev, in hdsp_set_rate()
1140 dev_info(hdsp->card->dev, in hdsp_set_rate()
1147 current_rate = hdsp->system_sample_rate; in hdsp_set_rate()
1159 if (rate > 96000 && hdsp->io_type != H9632) in hdsp_set_rate()
1212 if (reject_if_open && (hdsp->capture_pid >= 0 || hdsp->playback_pid >= 0)) { in hdsp_set_rate()
1213 dev_warn(hdsp->card->dev, in hdsp_set_rate()
1215 hdsp->capture_pid, in hdsp_set_rate()
1216 hdsp->playback_pid); in hdsp_set_rate()
1220 hdsp->control_register &= ~HDSP_FrequencyMask; in hdsp_set_rate()
1221 hdsp->control_register |= rate_bits; in hdsp_set_rate()
1222 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rate()
1225 if (hdsp->io_type == H9632 && hdsp->firmware_rev >= 152) in hdsp_set_rate()
1226 hdsp_set_dds_value(hdsp, rate); in hdsp_set_rate()
1229 hdsp->channel_map = channel_map_H9632_qs; in hdsp_set_rate()
1231 if (hdsp->io_type == H9632) in hdsp_set_rate()
1232 hdsp->channel_map = channel_map_H9632_ds; in hdsp_set_rate()
1234 hdsp->channel_map = channel_map_ds; in hdsp_set_rate()
1236 switch (hdsp->io_type) { in hdsp_set_rate()
1239 hdsp->channel_map = channel_map_mf_ss; in hdsp_set_rate()
1243 hdsp->channel_map = channel_map_df_ss; in hdsp_set_rate()
1246 hdsp->channel_map = channel_map_H9632_ss; in hdsp_set_rate()
1254 hdsp->system_sample_rate = rate; in hdsp_set_rate()
1263 static unsigned char snd_hdsp_midi_read_byte (struct hdsp *hdsp, int id) in snd_hdsp_midi_read_byte() argument
1267 return hdsp_read(hdsp, HDSP_midiDataIn1); in snd_hdsp_midi_read_byte()
1269 return hdsp_read(hdsp, HDSP_midiDataIn0); in snd_hdsp_midi_read_byte()
1272 static void snd_hdsp_midi_write_byte (struct hdsp *hdsp, int id, int val) in snd_hdsp_midi_write_byte() argument
1276 hdsp_write(hdsp, HDSP_midiDataOut1, val); in snd_hdsp_midi_write_byte()
1278 hdsp_write(hdsp, HDSP_midiDataOut0, val); in snd_hdsp_midi_write_byte()
1281 static int snd_hdsp_midi_input_available (struct hdsp *hdsp, int id) in snd_hdsp_midi_input_available() argument
1284 return (hdsp_read(hdsp, HDSP_midiStatusIn1) & 0xff); in snd_hdsp_midi_input_available()
1286 return (hdsp_read(hdsp, HDSP_midiStatusIn0) & 0xff); in snd_hdsp_midi_input_available()
1289 static int snd_hdsp_midi_output_possible (struct hdsp *hdsp, int id) in snd_hdsp_midi_output_possible() argument
1294 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut1) & 0xff; in snd_hdsp_midi_output_possible()
1296 fifo_bytes_used = hdsp_read(hdsp, HDSP_midiStatusOut0) & 0xff; in snd_hdsp_midi_output_possible()
1304 static void snd_hdsp_flush_midi_input (struct hdsp *hdsp, int id) in snd_hdsp_flush_midi_input() argument
1306 while (snd_hdsp_midi_input_available (hdsp, id)) in snd_hdsp_flush_midi_input()
1307 snd_hdsp_midi_read_byte (hdsp, id); in snd_hdsp_flush_midi_input()
1323 if ((n_pending = snd_hdsp_midi_output_possible (hmidi->hdsp, hmidi->id)) > 0) { in snd_hdsp_midi_output_write()
1329 snd_hdsp_midi_write_byte (hmidi->hdsp, hmidi->id, buf[i]); in snd_hdsp_midi_output_write()
1346 if ((n_pending = snd_hdsp_midi_input_available (hmidi->hdsp, hmidi->id)) > 0) { in snd_hdsp_midi_input_read()
1351 buf[i] = snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1357 snd_hdsp_midi_read_byte (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_read()
1362 hmidi->hdsp->control_register |= HDSP_Midi1InterruptEnable; in snd_hdsp_midi_input_read()
1364 hmidi->hdsp->control_register |= HDSP_Midi0InterruptEnable; in snd_hdsp_midi_input_read()
1365 hdsp_write(hmidi->hdsp, HDSP_controlRegister, hmidi->hdsp->control_register); in snd_hdsp_midi_input_read()
1372 struct hdsp *hdsp; in snd_hdsp_midi_input_trigger() local
1378 hdsp = hmidi->hdsp; in snd_hdsp_midi_input_trigger()
1380 spin_lock_irqsave (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1382 if (!(hdsp->control_register & ie)) { in snd_hdsp_midi_input_trigger()
1383 snd_hdsp_flush_midi_input (hdsp, hmidi->id); in snd_hdsp_midi_input_trigger()
1384 hdsp->control_register |= ie; in snd_hdsp_midi_input_trigger()
1387 hdsp->control_register &= ~ie; in snd_hdsp_midi_input_trigger()
1390 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_midi_input_trigger()
1391 spin_unlock_irqrestore (&hdsp->lock, flags); in snd_hdsp_midi_input_trigger()
1443 snd_hdsp_flush_midi_input (hmidi->hdsp, hmidi->id); in snd_hdsp_midi_input_open()
1504 static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int id) in snd_hdsp_create_midi() argument
1508 hdsp->midi[id].id = id; in snd_hdsp_create_midi()
1509 hdsp->midi[id].rmidi = NULL; in snd_hdsp_create_midi()
1510 hdsp->midi[id].input = NULL; in snd_hdsp_create_midi()
1511 hdsp->midi[id].output = NULL; in snd_hdsp_create_midi()
1512 hdsp->midi[id].hdsp = hdsp; in snd_hdsp_create_midi()
1513 hdsp->midi[id].istimer = 0; in snd_hdsp_create_midi()
1514 hdsp->midi[id].pending = 0; in snd_hdsp_create_midi()
1515 spin_lock_init (&hdsp->midi[id].lock); in snd_hdsp_create_midi()
1518 if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) in snd_hdsp_create_midi()
1521 sprintf(hdsp->midi[id].rmidi->name, "HDSP MIDI %d", id+1); in snd_hdsp_create_midi()
1522 hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; in snd_hdsp_create_midi()
1524 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); in snd_hdsp_create_midi()
1525 snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &snd_hdsp_midi_input); in snd_hdsp_create_midi()
1527 hdsp->midi[id].rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT | in snd_hdsp_create_midi()
1569 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_get() local
1571 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif); in snd_hdsp_control_spdif_get()
1577 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_put() local
1582 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1583 change = val != hdsp->creg_spdif; in snd_hdsp_control_spdif_put()
1584 hdsp->creg_spdif = val; in snd_hdsp_control_spdif_put()
1585 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_put()
1598 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_get() local
1600 snd_hdsp_convert_to_aes(&ucontrol->value.iec958, hdsp->creg_spdif_stream); in snd_hdsp_control_spdif_stream_get()
1606 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_control_spdif_stream_put() local
1611 spin_lock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1612 change = val != hdsp->creg_spdif_stream; in snd_hdsp_control_spdif_stream_put()
1613 hdsp->creg_spdif_stream = val; in snd_hdsp_control_spdif_stream_put()
1614 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_control_spdif_stream_put()
1615 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= val); in snd_hdsp_control_spdif_stream_put()
1616 spin_unlock_irq(&hdsp->lock); in snd_hdsp_control_spdif_stream_put()
1641 static unsigned int hdsp_spdif_in(struct hdsp *hdsp) in hdsp_spdif_in() argument
1643 return hdsp_decode_spdif_in(hdsp->control_register & HDSP_SPDIFInputMask); in hdsp_spdif_in()
1646 static int hdsp_set_spdif_input(struct hdsp *hdsp, int in) in hdsp_set_spdif_input() argument
1648 hdsp->control_register &= ~HDSP_SPDIFInputMask; in hdsp_set_spdif_input()
1649 hdsp->control_register |= hdsp_encode_spdif_in(in); in hdsp_set_spdif_input()
1650 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_spdif_input()
1659 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_in() local
1661 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 4 : 3, in snd_hdsp_info_spdif_in()
1667 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_in() local
1669 ucontrol->value.enumerated.item[0] = hdsp_spdif_in(hdsp); in snd_hdsp_get_spdif_in()
1675 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_spdif_in() local
1679 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_spdif_in()
1681 val = ucontrol->value.enumerated.item[0] % ((hdsp->io_type == H9632) ? 4 : 3); in snd_hdsp_put_spdif_in()
1682 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1683 change = val != hdsp_spdif_in(hdsp); in snd_hdsp_put_spdif_in()
1685 hdsp_set_spdif_input(hdsp, val); in snd_hdsp_put_spdif_in()
1686 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_spdif_in()
1699 static int hdsp_toggle_setting(struct hdsp *hdsp, u32 regmask) in hdsp_toggle_setting() argument
1701 return (hdsp->control_register & regmask) ? 1 : 0; in hdsp_toggle_setting()
1704 static int hdsp_set_toggle_setting(struct hdsp *hdsp, u32 regmask, int out) in hdsp_set_toggle_setting() argument
1707 hdsp->control_register |= regmask; in hdsp_set_toggle_setting()
1709 hdsp->control_register &= ~regmask; in hdsp_set_toggle_setting()
1710 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_toggle_setting()
1720 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_toggle_setting() local
1723 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1724 ucontrol->value.integer.value[0] = hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_get_toggle_setting()
1725 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_toggle_setting()
1732 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_toggle_setting() local
1737 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_toggle_setting()
1740 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1741 change = (int) val != hdsp_toggle_setting(hdsp, regmask); in snd_hdsp_put_toggle_setting()
1743 hdsp_set_toggle_setting(hdsp, regmask, val); in snd_hdsp_put_toggle_setting()
1744 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_toggle_setting()
1763 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_spdif_sample_rate() local
1765 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_spdif_sample_rate()
1771 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sample_rate() local
1773 switch (hdsp_spdif_sample_rate(hdsp)) { in snd_hdsp_get_spdif_sample_rate()
1825 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_sample_rate() local
1827 ucontrol->value.enumerated.item[0] = hdsp->system_sample_rate; in snd_hdsp_get_system_sample_rate()
1842 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_autosync_sample_rate() local
1848 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_autosync_sample_rate()
1854 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_sample_rate() local
1856 switch (hdsp_external_sample_rate(hdsp)) { in snd_hdsp_get_autosync_sample_rate()
1899 static int hdsp_system_clock_mode(struct hdsp *hdsp) in hdsp_system_clock_mode() argument
1901 if (hdsp->control_register & HDSP_ClockModeMaster) in hdsp_system_clock_mode()
1903 else if (hdsp_external_sample_rate(hdsp) != hdsp->system_sample_rate) in hdsp_system_clock_mode()
1917 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_system_clock_mode() local
1919 ucontrol->value.enumerated.item[0] = hdsp_system_clock_mode(hdsp); in snd_hdsp_get_system_clock_mode()
1932 static int hdsp_clock_source(struct hdsp *hdsp) in hdsp_clock_source() argument
1934 if (hdsp->control_register & HDSP_ClockModeMaster) { in hdsp_clock_source()
1935 switch (hdsp->system_sample_rate) { in hdsp_clock_source()
1962 static int hdsp_set_clock_source(struct hdsp *hdsp, int mode) in hdsp_set_clock_source() argument
1967 if (hdsp_external_sample_rate(hdsp) != 0) { in hdsp_set_clock_source()
1968 if (!hdsp_set_rate(hdsp, hdsp_external_sample_rate(hdsp), 1)) { in hdsp_set_clock_source()
1969 hdsp->control_register &= ~HDSP_ClockModeMaster; in hdsp_set_clock_source()
1970 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2005 hdsp->control_register |= HDSP_ClockModeMaster; in hdsp_set_clock_source()
2006 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_clock_source()
2007 hdsp_set_rate(hdsp, rate, 1); in hdsp_set_clock_source()
2019 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_clock_source() local
2021 return snd_ctl_enum_info(uinfo, 1, (hdsp->io_type == H9632) ? 10 : 7, in snd_hdsp_info_clock_source()
2027 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source() local
2029 ucontrol->value.enumerated.item[0] = hdsp_clock_source(hdsp); in snd_hdsp_get_clock_source()
2035 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source() local
2039 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_clock_source()
2043 if (hdsp->io_type == H9632) { in snd_hdsp_put_clock_source()
2050 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2051 if (val != hdsp_clock_source(hdsp)) in snd_hdsp_put_clock_source()
2052 change = (hdsp_set_clock_source(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_clock_source()
2055 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_clock_source()
2063 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_clock_source_lock() local
2065 ucontrol->value.integer.value[0] = hdsp->clock_source_locked; in snd_hdsp_get_clock_source_lock()
2071 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_clock_source_lock() local
2074 change = (int)ucontrol->value.integer.value[0] != hdsp->clock_source_locked; in snd_hdsp_put_clock_source_lock()
2076 hdsp->clock_source_locked = !!ucontrol->value.integer.value[0]; in snd_hdsp_put_clock_source_lock()
2089 static int hdsp_da_gain(struct hdsp *hdsp) in hdsp_da_gain() argument
2091 switch (hdsp->control_register & HDSP_DAGainMask) { in hdsp_da_gain()
2103 static int hdsp_set_da_gain(struct hdsp *hdsp, int mode) in hdsp_set_da_gain() argument
2105 hdsp->control_register &= ~HDSP_DAGainMask; in hdsp_set_da_gain()
2108 hdsp->control_register |= HDSP_DAGainHighGain; in hdsp_set_da_gain()
2111 hdsp->control_register |= HDSP_DAGainPlus4dBu; in hdsp_set_da_gain()
2114 hdsp->control_register |= HDSP_DAGainMinus10dBV; in hdsp_set_da_gain()
2120 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_da_gain()
2133 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_da_gain() local
2135 ucontrol->value.enumerated.item[0] = hdsp_da_gain(hdsp); in snd_hdsp_get_da_gain()
2141 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_da_gain() local
2145 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_da_gain()
2150 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2151 if (val != hdsp_da_gain(hdsp)) in snd_hdsp_put_da_gain()
2152 change = (hdsp_set_da_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_da_gain()
2155 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_da_gain()
2168 static int hdsp_ad_gain(struct hdsp *hdsp) in hdsp_ad_gain() argument
2170 switch (hdsp->control_register & HDSP_ADGainMask) { in hdsp_ad_gain()
2182 static int hdsp_set_ad_gain(struct hdsp *hdsp, int mode) in hdsp_set_ad_gain() argument
2184 hdsp->control_register &= ~HDSP_ADGainMask; in hdsp_set_ad_gain()
2187 hdsp->control_register |= HDSP_ADGainMinus10dBV; in hdsp_set_ad_gain()
2190 hdsp->control_register |= HDSP_ADGainPlus4dBu; in hdsp_set_ad_gain()
2193 hdsp->control_register |= HDSP_ADGainLowGain; in hdsp_set_ad_gain()
2199 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_ad_gain()
2212 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_ad_gain() local
2214 ucontrol->value.enumerated.item[0] = hdsp_ad_gain(hdsp); in snd_hdsp_get_ad_gain()
2220 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_ad_gain() local
2224 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_ad_gain()
2229 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2230 if (val != hdsp_ad_gain(hdsp)) in snd_hdsp_put_ad_gain()
2231 change = (hdsp_set_ad_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_ad_gain()
2234 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_ad_gain()
2247 static int hdsp_phone_gain(struct hdsp *hdsp) in hdsp_phone_gain() argument
2249 switch (hdsp->control_register & HDSP_PhoneGainMask) { in hdsp_phone_gain()
2261 static int hdsp_set_phone_gain(struct hdsp *hdsp, int mode) in hdsp_set_phone_gain() argument
2263 hdsp->control_register &= ~HDSP_PhoneGainMask; in hdsp_set_phone_gain()
2266 hdsp->control_register |= HDSP_PhoneGain0dB; in hdsp_set_phone_gain()
2269 hdsp->control_register |= HDSP_PhoneGainMinus6dB; in hdsp_set_phone_gain()
2272 hdsp->control_register |= HDSP_PhoneGainMinus12dB; in hdsp_set_phone_gain()
2278 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_phone_gain()
2291 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_phone_gain() local
2293 ucontrol->value.enumerated.item[0] = hdsp_phone_gain(hdsp); in snd_hdsp_get_phone_gain()
2299 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_phone_gain() local
2303 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_phone_gain()
2308 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2309 if (val != hdsp_phone_gain(hdsp)) in snd_hdsp_put_phone_gain()
2310 change = (hdsp_set_phone_gain(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_phone_gain()
2313 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_phone_gain()
2326 static int hdsp_pref_sync_ref(struct hdsp *hdsp) in hdsp_pref_sync_ref() argument
2332 switch (hdsp->control_register & HDSP_SyncRefMask) { in hdsp_pref_sync_ref()
2351 static int hdsp_set_pref_sync_ref(struct hdsp *hdsp, int pref) in hdsp_set_pref_sync_ref() argument
2353 hdsp->control_register &= ~HDSP_SyncRefMask; in hdsp_set_pref_sync_ref()
2356 hdsp->control_register &= ~HDSP_SyncRefMask; /* clear SyncRef bits */ in hdsp_set_pref_sync_ref()
2359 hdsp->control_register |= HDSP_SyncRef_ADAT2; in hdsp_set_pref_sync_ref()
2362 hdsp->control_register |= HDSP_SyncRef_ADAT3; in hdsp_set_pref_sync_ref()
2365 hdsp->control_register |= HDSP_SyncRef_SPDIF; in hdsp_set_pref_sync_ref()
2368 hdsp->control_register |= HDSP_SyncRef_WORD; in hdsp_set_pref_sync_ref()
2371 hdsp->control_register |= HDSP_SyncRef_ADAT_SYNC; in hdsp_set_pref_sync_ref()
2376 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_pref_sync_ref()
2385 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_info_pref_sync_ref() local
2388 switch (hdsp->io_type) { in snd_hdsp_info_pref_sync_ref()
2408 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_pref_sync_ref() local
2410 ucontrol->value.enumerated.item[0] = hdsp_pref_sync_ref(hdsp); in snd_hdsp_get_pref_sync_ref()
2416 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_pref_sync_ref() local
2420 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_pref_sync_ref()
2423 switch (hdsp->io_type) { in snd_hdsp_put_pref_sync_ref()
2439 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2440 change = (int)val != hdsp_pref_sync_ref(hdsp); in snd_hdsp_put_pref_sync_ref()
2441 hdsp_set_pref_sync_ref(hdsp, val); in snd_hdsp_put_pref_sync_ref()
2442 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_pref_sync_ref()
2455 static int hdsp_autosync_ref(struct hdsp *hdsp) in hdsp_autosync_ref() argument
2458 unsigned int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_autosync_ref()
2492 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_autosync_ref() local
2494 ucontrol->value.enumerated.item[0] = hdsp_autosync_ref(hdsp); in snd_hdsp_get_autosync_ref()
2507 static int hdsp_set_precise_pointer(struct hdsp *hdsp, int precise) in hdsp_set_precise_pointer() argument
2510 hdsp->precise_ptr = 1; in hdsp_set_precise_pointer()
2512 hdsp->precise_ptr = 0; in hdsp_set_precise_pointer()
2520 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_precise_pointer() local
2522 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2523 ucontrol->value.integer.value[0] = hdsp->precise_ptr; in snd_hdsp_get_precise_pointer()
2524 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_precise_pointer()
2530 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_precise_pointer() local
2534 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_precise_pointer()
2537 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2538 change = (int)val != hdsp->precise_ptr; in snd_hdsp_put_precise_pointer()
2539 hdsp_set_precise_pointer(hdsp, val); in snd_hdsp_put_precise_pointer()
2540 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_precise_pointer()
2553 static int hdsp_set_use_midi_work(struct hdsp *hdsp, int use_work) in hdsp_set_use_midi_work() argument
2556 hdsp->use_midi_work = 1; in hdsp_set_use_midi_work()
2558 hdsp->use_midi_work = 0; in hdsp_set_use_midi_work()
2566 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_use_midi_work() local
2568 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_work()
2569 ucontrol->value.integer.value[0] = hdsp->use_midi_work; in snd_hdsp_get_use_midi_work()
2570 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_use_midi_work()
2576 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_use_midi_work() local
2580 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_use_midi_work()
2583 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_work()
2584 change = (int)val != hdsp->use_midi_work; in snd_hdsp_put_use_midi_work()
2585 hdsp_set_use_midi_work(hdsp, val); in snd_hdsp_put_use_midi_work()
2586 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_use_midi_work()
2614 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_mixer() local
2622 if (source >= hdsp->max_channels) in snd_hdsp_get_mixer()
2623 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels,destination); in snd_hdsp_get_mixer()
2625 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_get_mixer()
2627 spin_lock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2628 ucontrol->value.integer.value[2] = hdsp_read_gain (hdsp, addr); in snd_hdsp_get_mixer()
2629 spin_unlock_irq(&hdsp->lock); in snd_hdsp_get_mixer()
2635 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_mixer() local
2642 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_mixer()
2648 if (source >= hdsp->max_channels) in snd_hdsp_put_mixer()
2649 addr = hdsp_playback_to_output_key(hdsp,source-hdsp->max_channels, destination); in snd_hdsp_put_mixer()
2651 addr = hdsp_input_to_output_key(hdsp,source, destination); in snd_hdsp_put_mixer()
2655 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2656 change = gain != hdsp_read_gain(hdsp, addr); in snd_hdsp_put_mixer()
2658 hdsp_write_gain(hdsp, addr, gain); in snd_hdsp_put_mixer()
2659 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_mixer()
2679 static int hdsp_wc_sync_check(struct hdsp *hdsp) in hdsp_wc_sync_check() argument
2681 int status2 = hdsp_read(hdsp, HDSP_status2Register); in hdsp_wc_sync_check()
2694 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_wc_sync_check() local
2696 ucontrol->value.enumerated.item[0] = hdsp_wc_sync_check(hdsp); in snd_hdsp_get_wc_sync_check()
2709 static int hdsp_spdif_sync_check(struct hdsp *hdsp) in hdsp_spdif_sync_check() argument
2711 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_spdif_sync_check()
2725 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_spdif_sync_check() local
2727 ucontrol->value.enumerated.item[0] = hdsp_spdif_sync_check(hdsp); in snd_hdsp_get_spdif_sync_check()
2740 static int hdsp_adatsync_sync_check(struct hdsp *hdsp) in hdsp_adatsync_sync_check() argument
2742 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adatsync_sync_check()
2754 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adatsync_sync_check() local
2756 ucontrol->value.enumerated.item[0] = hdsp_adatsync_sync_check(hdsp); in snd_hdsp_get_adatsync_sync_check()
2767 static int hdsp_adat_sync_check(struct hdsp *hdsp, int idx) in hdsp_adat_sync_check() argument
2769 int status = hdsp_read(hdsp, HDSP_statusRegister); in hdsp_adat_sync_check()
2783 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_adat_sync_check() local
2789 switch (hdsp->io_type) { in snd_hdsp_get_adat_sync_check()
2804 ucontrol->value.enumerated.item[0] = hdsp_adat_sync_check(hdsp, offset); in snd_hdsp_get_adat_sync_check()
2817 static int hdsp_dds_offset(struct hdsp *hdsp) in hdsp_dds_offset() argument
2820 unsigned int dds_value = hdsp->dds_value; in hdsp_dds_offset()
2821 int system_sample_rate = hdsp->system_sample_rate; in hdsp_dds_offset()
2839 static int hdsp_set_dds_offset(struct hdsp *hdsp, int offset_hz) in hdsp_set_dds_offset() argument
2841 int rate = hdsp->system_sample_rate + offset_hz; in hdsp_set_dds_offset()
2842 hdsp_set_dds_value(hdsp, rate); in hdsp_set_dds_offset()
2857 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_dds_offset() local
2859 ucontrol->value.integer.value[0] = hdsp_dds_offset(hdsp); in snd_hdsp_get_dds_offset()
2865 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_dds_offset() local
2869 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_dds_offset()
2872 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2873 if (val != hdsp_dds_offset(hdsp)) in snd_hdsp_put_dds_offset()
2874 change = (hdsp_set_dds_offset(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_dds_offset()
2877 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_dds_offset()
2956 static int hdsp_rpm_input12(struct hdsp *hdsp) in hdsp_rpm_input12() argument
2958 switch (hdsp->control_register & HDSP_RPM_Inp12) { in hdsp_rpm_input12()
2974 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input12() local
2976 ucontrol->value.enumerated.item[0] = hdsp_rpm_input12(hdsp); in snd_hdsp_get_rpm_input12()
2981 static int hdsp_set_rpm_input12(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input12() argument
2983 hdsp->control_register &= ~HDSP_RPM_Inp12; in hdsp_set_rpm_input12()
2986 hdsp->control_register |= HDSP_RPM_Inp12_Phon_6dB; in hdsp_set_rpm_input12()
2991 hdsp->control_register |= HDSP_RPM_Inp12_Phon_n6dB; in hdsp_set_rpm_input12()
2994 hdsp->control_register |= HDSP_RPM_Inp12_Line_0dB; in hdsp_set_rpm_input12()
2997 hdsp->control_register |= HDSP_RPM_Inp12_Line_n6dB; in hdsp_set_rpm_input12()
3003 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input12()
3010 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input12() local
3014 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input12()
3021 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3022 if (val != hdsp_rpm_input12(hdsp)) in snd_hdsp_put_rpm_input12()
3023 change = (hdsp_set_rpm_input12(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input12()
3026 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input12()
3041 static int hdsp_rpm_input34(struct hdsp *hdsp) in hdsp_rpm_input34() argument
3043 switch (hdsp->control_register & HDSP_RPM_Inp34) { in hdsp_rpm_input34()
3059 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_input34() local
3061 ucontrol->value.enumerated.item[0] = hdsp_rpm_input34(hdsp); in snd_hdsp_get_rpm_input34()
3066 static int hdsp_set_rpm_input34(struct hdsp *hdsp, int mode) in hdsp_set_rpm_input34() argument
3068 hdsp->control_register &= ~HDSP_RPM_Inp34; in hdsp_set_rpm_input34()
3071 hdsp->control_register |= HDSP_RPM_Inp34_Phon_6dB; in hdsp_set_rpm_input34()
3076 hdsp->control_register |= HDSP_RPM_Inp34_Phon_n6dB; in hdsp_set_rpm_input34()
3079 hdsp->control_register |= HDSP_RPM_Inp34_Line_0dB; in hdsp_set_rpm_input34()
3082 hdsp->control_register |= HDSP_RPM_Inp34_Line_n6dB; in hdsp_set_rpm_input34()
3088 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_input34()
3095 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_input34() local
3099 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_input34()
3106 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3107 if (val != hdsp_rpm_input34(hdsp)) in snd_hdsp_put_rpm_input34()
3108 change = (hdsp_set_rpm_input34(hdsp, val) == 0) ? 1 : 0; in snd_hdsp_put_rpm_input34()
3111 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_input34()
3117 static int hdsp_rpm_bypass(struct hdsp *hdsp) in hdsp_rpm_bypass() argument
3119 return (hdsp->control_register & HDSP_RPM_Bypass) ? 1 : 0; in hdsp_rpm_bypass()
3125 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_bypass() local
3127 ucontrol->value.integer.value[0] = hdsp_rpm_bypass(hdsp); in snd_hdsp_get_rpm_bypass()
3132 static int hdsp_set_rpm_bypass(struct hdsp *hdsp, int on) in hdsp_set_rpm_bypass() argument
3135 hdsp->control_register |= HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3137 hdsp->control_register &= ~HDSP_RPM_Bypass; in hdsp_set_rpm_bypass()
3138 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_bypass()
3145 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_bypass() local
3149 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_bypass()
3152 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3153 change = (int)val != hdsp_rpm_bypass(hdsp); in snd_hdsp_put_rpm_bypass()
3154 hdsp_set_rpm_bypass(hdsp, val); in snd_hdsp_put_rpm_bypass()
3155 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_bypass()
3169 static int hdsp_rpm_disconnect(struct hdsp *hdsp) in hdsp_rpm_disconnect() argument
3171 return (hdsp->control_register & HDSP_RPM_Disconnect) ? 1 : 0; in hdsp_rpm_disconnect()
3177 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_get_rpm_disconnect() local
3179 ucontrol->value.integer.value[0] = hdsp_rpm_disconnect(hdsp); in snd_hdsp_get_rpm_disconnect()
3184 static int hdsp_set_rpm_disconnect(struct hdsp *hdsp, int on) in hdsp_set_rpm_disconnect() argument
3187 hdsp->control_register |= HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3189 hdsp->control_register &= ~HDSP_RPM_Disconnect; in hdsp_set_rpm_disconnect()
3190 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in hdsp_set_rpm_disconnect()
3197 struct hdsp *hdsp = snd_kcontrol_chip(kcontrol); in snd_hdsp_put_rpm_disconnect() local
3201 if (!snd_hdsp_use_is_exclusive(hdsp)) in snd_hdsp_put_rpm_disconnect()
3204 spin_lock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3205 change = (int)val != hdsp_rpm_disconnect(hdsp); in snd_hdsp_put_rpm_disconnect()
3206 hdsp_set_rpm_disconnect(hdsp, val); in snd_hdsp_put_rpm_disconnect()
3207 spin_unlock_irq(&hdsp->lock); in snd_hdsp_put_rpm_disconnect()
3256 static int snd_hdsp_create_controls(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_controls() argument
3262 if (hdsp->io_type == RPM) { in snd_hdsp_create_controls()
3265 err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_rpm_controls[idx], hdsp)); in snd_hdsp_create_controls()
3273 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_controls[idx], hdsp))) < 0) in snd_hdsp_create_controls()
3276 hdsp->spdif_ctl = kctl; in snd_hdsp_create_controls()
3282 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) in snd_hdsp_create_controls()
3284 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3287 if ((err = snd_ctl_add (card, kctl = snd_ctl_new1(&snd_hdsp_adat_sync_check, hdsp)))) in snd_hdsp_create_controls()
3293 if (hdsp->io_type == H9632) { in snd_hdsp_create_controls()
3295 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_9632_controls[idx], hdsp))) < 0) in snd_hdsp_create_controls()
3301 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) { in snd_hdsp_create_controls()
3302 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_hdsp_96xx_aeb, hdsp))) < 0) in snd_hdsp_create_controls()
3316 struct hdsp *hdsp = entry->private_data; in snd_hdsp_proc_read() local
3325 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_proc_read()
3326 status2 = hdsp_read(hdsp, HDSP_status2Register); in snd_hdsp_proc_read()
3328 snd_iprintf(buffer, "%s (Card #%d)\n", hdsp->card_name, in snd_hdsp_proc_read()
3329 hdsp->card->number + 1); in snd_hdsp_proc_read()
3331 hdsp->capture_buffer, hdsp->playback_buffer); in snd_hdsp_proc_read()
3333 hdsp->irq, hdsp->port, (unsigned long)hdsp->iobase); in snd_hdsp_proc_read()
3334 snd_iprintf(buffer, "Control register: 0x%x\n", hdsp->control_register); in snd_hdsp_proc_read()
3336 hdsp->control2_register); in snd_hdsp_proc_read()
3340 if (hdsp_check_for_iobox(hdsp)) { in snd_hdsp_proc_read()
3346 if (hdsp_check_for_firmware(hdsp, 0)) { in snd_hdsp_proc_read()
3347 if (hdsp->state & HDSP_FirmwareCached) { in snd_hdsp_proc_read()
3348 if (snd_hdsp_load_firmware_from_cache(hdsp) != 0) { in snd_hdsp_proc_read()
3357 err = hdsp_request_fw_loader(hdsp); in snd_hdsp_proc_read()
3367 snd_iprintf(buffer, "FIFO status: %d\n", hdsp_read(hdsp, HDSP_fifoStatus) & 0xff); in snd_hdsp_proc_read()
3368 snd_iprintf(buffer, "MIDI1 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut0)); in snd_hdsp_proc_read()
3369 snd_iprintf(buffer, "MIDI1 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn0)); in snd_hdsp_proc_read()
3370 snd_iprintf(buffer, "MIDI2 Output status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusOut1)); in snd_hdsp_proc_read()
3371 snd_iprintf(buffer, "MIDI2 Input status: 0x%x\n", hdsp_read(hdsp, HDSP_midiStatusIn1)); in snd_hdsp_proc_read()
3372 snd_iprintf(buffer, "Use Midi Tasklet: %s\n", hdsp->use_midi_work ? "on" : "off"); in snd_hdsp_proc_read()
3376 x = 1 << (6 + hdsp_decode_latency(hdsp->control_register & HDSP_LatencyMask)); in snd_hdsp_proc_read()
3378 …fer Size (Latency): %d samples (2 periods of %lu bytes)\n", x, (unsigned long) hdsp->period_bytes); in snd_hdsp_proc_read()
3379 snd_iprintf(buffer, "Hardware pointer (frames): %ld\n", hdsp_hw_pointer(hdsp)); in snd_hdsp_proc_read()
3380 snd_iprintf(buffer, "Precise pointer: %s\n", hdsp->precise_ptr ? "on" : "off"); in snd_hdsp_proc_read()
3381 snd_iprintf(buffer, "Line out: %s\n", (hdsp->control_register & HDSP_LineOut) ? "on" : "off"); in snd_hdsp_proc_read()
3387 switch (hdsp_clock_source(hdsp)) { in snd_hdsp_proc_read()
3423 if (hdsp_system_clock_mode(hdsp)) in snd_hdsp_proc_read()
3428 switch (hdsp_pref_sync_ref (hdsp)) { in snd_hdsp_proc_read()
3453 switch (hdsp_autosync_ref (hdsp)) { in snd_hdsp_proc_read()
3481 snd_iprintf (buffer, "AutoSync Frequency: %d\n", hdsp_external_sample_rate(hdsp)); in snd_hdsp_proc_read()
3485 snd_iprintf (buffer, "System Clock Frequency: %d\n", hdsp->system_sample_rate); in snd_hdsp_proc_read()
3486 snd_iprintf (buffer, "System Clock Locked: %s\n", hdsp->clock_source_locked ? "Yes" : "No"); in snd_hdsp_proc_read()
3490 if (hdsp->io_type != RPM) { in snd_hdsp_proc_read()
3491 switch (hdsp_spdif_in(hdsp)) { in snd_hdsp_proc_read()
3510 if (RPM == hdsp->io_type) { in snd_hdsp_proc_read()
3511 if (hdsp->control_register & HDSP_RPM_Bypass) in snd_hdsp_proc_read()
3515 if (hdsp->control_register & HDSP_RPM_Disconnect) in snd_hdsp_proc_read()
3520 switch (hdsp->control_register & HDSP_RPM_Inp12) { in snd_hdsp_proc_read()
3540 switch (hdsp->control_register & HDSP_RPM_Inp34) { in snd_hdsp_proc_read()
3561 if (hdsp->control_register & HDSP_SPDIFOpticalOut) in snd_hdsp_proc_read()
3566 if (hdsp->control_register & HDSP_SPDIFProfessional) in snd_hdsp_proc_read()
3571 if (hdsp->control_register & HDSP_SPDIFEmphasis) in snd_hdsp_proc_read()
3576 if (hdsp->control_register & HDSP_SPDIFNonAudio) in snd_hdsp_proc_read()
3580 x = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_proc_read()
3595 switch (hdsp->io_type) { in snd_hdsp_proc_read()
3635 if (hdsp->io_type == H9632) { in snd_hdsp_proc_read()
3638 switch (hdsp_ad_gain(hdsp)) { in snd_hdsp_proc_read()
3651 switch (hdsp_da_gain(hdsp)) { in snd_hdsp_proc_read()
3664 switch (hdsp_phone_gain(hdsp)) { in snd_hdsp_proc_read()
3678 hdsp_toggle_setting(hdsp, HDSP_XLRBreakoutCable) ? in snd_hdsp_proc_read()
3681 if (hdsp->control_register & HDSP_AnalogExtensionBoard) in snd_hdsp_proc_read()
3690 static void snd_hdsp_proc_init(struct hdsp *hdsp) in snd_hdsp_proc_init() argument
3692 snd_card_ro_proc_new(hdsp->card, "hdsp", hdsp, snd_hdsp_proc_read); in snd_hdsp_proc_init()
3695 static void snd_hdsp_free_buffers(struct hdsp *hdsp) in snd_hdsp_free_buffers() argument
3697 snd_hammerfall_free_buffer(&hdsp->capture_dma_buf, hdsp->pci); in snd_hdsp_free_buffers()
3698 snd_hammerfall_free_buffer(&hdsp->playback_dma_buf, hdsp->pci); in snd_hdsp_free_buffers()
3701 static int snd_hdsp_initialize_memory(struct hdsp *hdsp) in snd_hdsp_initialize_memory() argument
3705 if (snd_hammerfall_get_buffer(hdsp->pci, &hdsp->capture_dma_buf, HDSP_DMA_AREA_BYTES) < 0 || in snd_hdsp_initialize_memory()
3706 snd_hammerfall_get_buffer(hdsp->pci, &hdsp->playback_dma_buf, HDSP_DMA_AREA_BYTES) < 0) { in snd_hdsp_initialize_memory()
3707 if (hdsp->capture_dma_buf.area) in snd_hdsp_initialize_memory()
3708 snd_dma_free_pages(&hdsp->capture_dma_buf); in snd_hdsp_initialize_memory()
3709 dev_err(hdsp->card->dev, in snd_hdsp_initialize_memory()
3710 "%s: no buffers available\n", hdsp->card_name); in snd_hdsp_initialize_memory()
3716 cb_bus = ALIGN(hdsp->capture_dma_buf.addr, 0x10000ul); in snd_hdsp_initialize_memory()
3717 pb_bus = ALIGN(hdsp->playback_dma_buf.addr, 0x10000ul); in snd_hdsp_initialize_memory()
3721 hdsp_write(hdsp, HDSP_inputBufferAddress, cb_bus); in snd_hdsp_initialize_memory()
3722 hdsp_write(hdsp, HDSP_outputBufferAddress, pb_bus); in snd_hdsp_initialize_memory()
3724 hdsp->capture_buffer = hdsp->capture_dma_buf.area + (cb_bus - hdsp->capture_dma_buf.addr); in snd_hdsp_initialize_memory()
3725 hdsp->playback_buffer = hdsp->playback_dma_buf.area + (pb_bus - hdsp->playback_dma_buf.addr); in snd_hdsp_initialize_memory()
3730 static int snd_hdsp_set_defaults(struct hdsp *hdsp) in snd_hdsp_set_defaults() argument
3748 hdsp->control_register = HDSP_ClockModeMaster | in snd_hdsp_set_defaults()
3754 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3757 hdsp->control2_register = HDSP_BIGENDIAN_MODE; in snd_hdsp_set_defaults()
3759 hdsp->control2_register = 0; in snd_hdsp_set_defaults()
3761 if (hdsp->io_type == H9652) in snd_hdsp_set_defaults()
3762 snd_hdsp_9652_enable_mixer (hdsp); in snd_hdsp_set_defaults()
3764 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_set_defaults()
3766 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_set_defaults()
3767 hdsp_compute_period_size(hdsp); in snd_hdsp_set_defaults()
3772 hdsp->mixer_matrix[i] = MINUS_INFINITY_GAIN; in snd_hdsp_set_defaults()
3774 …for (i = 0; i < ((hdsp->io_type == H9652 || hdsp->io_type == H9632) ? 1352 : HDSP_MATRIX_MIXER_SIZ… in snd_hdsp_set_defaults()
3775 if (hdsp_write_gain (hdsp, i, MINUS_INFINITY_GAIN)) in snd_hdsp_set_defaults()
3780 if (hdsp->io_type == H9632) { in snd_hdsp_set_defaults()
3781 hdsp->control_register |= (HDSP_DAGainPlus4dBu | HDSP_ADGainPlus4dBu | HDSP_PhoneGain0dB); in snd_hdsp_set_defaults()
3782 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_set_defaults()
3788 hdsp_set_rate(hdsp, 48000, 1); in snd_hdsp_set_defaults()
3795 struct hdsp *hdsp = container_of(work, struct hdsp, midi_work); in hdsp_midi_work() local
3797 if (hdsp->midi[0].pending) in hdsp_midi_work()
3798 snd_hdsp_midi_input_read (&hdsp->midi[0]); in hdsp_midi_work()
3799 if (hdsp->midi[1].pending) in hdsp_midi_work()
3800 snd_hdsp_midi_input_read (&hdsp->midi[1]); in hdsp_midi_work()
3805 struct hdsp *hdsp = (struct hdsp *) dev_id; in snd_hdsp_interrupt() local
3814 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_interrupt()
3823 hdsp_write(hdsp, HDSP_interruptConfirmation, 0); in snd_hdsp_interrupt()
3825 midi0status = hdsp_read (hdsp, HDSP_midiStatusIn0) & 0xff; in snd_hdsp_interrupt()
3826 midi1status = hdsp_read (hdsp, HDSP_midiStatusIn1) & 0xff; in snd_hdsp_interrupt()
3828 if (!(hdsp->state & HDSP_InitializationComplete)) in snd_hdsp_interrupt()
3832 if (hdsp->capture_substream) in snd_hdsp_interrupt()
3833 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream); in snd_hdsp_interrupt()
3835 if (hdsp->playback_substream) in snd_hdsp_interrupt()
3836 snd_pcm_period_elapsed(hdsp->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream); in snd_hdsp_interrupt()
3840 if (hdsp->use_midi_work) { in snd_hdsp_interrupt()
3842 hdsp->control_register &= ~HDSP_Midi0InterruptEnable; in snd_hdsp_interrupt()
3843 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3844 hdsp->midi[0].pending = 1; in snd_hdsp_interrupt()
3847 snd_hdsp_midi_input_read (&hdsp->midi[0]); in snd_hdsp_interrupt()
3850 …if (hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632 && midi1 && midi1… in snd_hdsp_interrupt()
3851 if (hdsp->use_midi_work) { in snd_hdsp_interrupt()
3853 hdsp->control_register &= ~HDSP_Midi1InterruptEnable; in snd_hdsp_interrupt()
3854 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_interrupt()
3855 hdsp->midi[1].pending = 1; in snd_hdsp_interrupt()
3858 snd_hdsp_midi_input_read (&hdsp->midi[1]); in snd_hdsp_interrupt()
3861 if (hdsp->use_midi_work && schedule) in snd_hdsp_interrupt()
3862 queue_work(system_highpri_wq, &hdsp->midi_work); in snd_hdsp_interrupt()
3868 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_pointer() local
3869 return hdsp_hw_pointer(hdsp); in snd_hdsp_hw_pointer()
3872 static signed char *hdsp_channel_buffer_location(struct hdsp *hdsp, in hdsp_channel_buffer_location() argument
3879 if (snd_BUG_ON(channel < 0 || channel >= hdsp->max_channels)) in hdsp_channel_buffer_location()
3882 if ((mapped_channel = hdsp->channel_map[channel]) < 0) in hdsp_channel_buffer_location()
3886 return hdsp->capture_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3888 return hdsp->playback_buffer + (mapped_channel * HDSP_CHANNEL_BUFFER_BYTES); in hdsp_channel_buffer_location()
3895 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_copy() local
3901 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_playback_copy()
3913 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_copy_kernel() local
3916 channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel); in snd_hdsp_playback_copy_kernel()
3927 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_copy() local
3933 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_capture_copy()
3945 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_copy_kernel() local
3948 channel_buf = hdsp_channel_buffer_location(hdsp, substream->pstr->stream, channel); in snd_hdsp_capture_copy_kernel()
3959 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_silence() local
3962 channel_buf = hdsp_channel_buffer_location (hdsp, substream->pstr->stream, channel); in snd_hdsp_hw_silence()
3972 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_reset() local
3975 other = hdsp->capture_substream; in snd_hdsp_reset()
3977 other = hdsp->playback_substream; in snd_hdsp_reset()
3978 if (hdsp->running) in snd_hdsp_reset()
3979 runtime->status->hw_ptr = hdsp_hw_pointer(hdsp); in snd_hdsp_reset()
3998 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_hw_params() local
4003 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hw_params()
4006 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_hw_params()
4009 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4012 hdsp->control_register &= ~(HDSP_SPDIFProfessional | HDSP_SPDIFNonAudio | HDSP_SPDIFEmphasis); in snd_hdsp_hw_params()
4013 hdsp_write(hdsp, HDSP_controlRegister, hdsp->control_register |= hdsp->creg_spdif_stream); in snd_hdsp_hw_params()
4014 this_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4015 other_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4017 this_pid = hdsp->capture_pid; in snd_hdsp_hw_params()
4018 other_pid = hdsp->playback_pid; in snd_hdsp_hw_params()
4028 if (params_rate(params) != hdsp->system_sample_rate) { in snd_hdsp_hw_params()
4029 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4034 if (params_period_size(params) != hdsp->period_bytes / 4) { in snd_hdsp_hw_params()
4035 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4042 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4046 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4052 spin_lock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4053 if (! hdsp->clock_source_locked) { in snd_hdsp_hw_params()
4054 if ((err = hdsp_set_rate(hdsp, params_rate(params), 0)) < 0) { in snd_hdsp_hw_params()
4055 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4060 spin_unlock_irq(&hdsp->lock); in snd_hdsp_hw_params()
4062 if ((err = hdsp_set_interrupt_interval(hdsp, params_period_size(params))) < 0) { in snd_hdsp_hw_params()
4073 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_channel_info() local
4076 if (snd_BUG_ON(channel >= hdsp->max_channels)) in snd_hdsp_channel_info()
4078 channel = array_index_nospec(channel, hdsp->max_channels); in snd_hdsp_channel_info()
4080 if (hdsp->channel_map[channel] < 0) in snd_hdsp_channel_info()
4083 info->offset = hdsp->channel_map[channel] * HDSP_CHANNEL_BUFFER_BYTES; in snd_hdsp_channel_info()
4106 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_trigger() local
4110 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_trigger()
4113 if (hdsp_check_for_firmware(hdsp, 0)) /* no auto-loading in trigger */ in snd_hdsp_trigger()
4116 spin_lock(&hdsp->lock); in snd_hdsp_trigger()
4117 running = hdsp->running; in snd_hdsp_trigger()
4127 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4131 other = hdsp->capture_substream; in snd_hdsp_trigger()
4133 other = hdsp->playback_substream; in snd_hdsp_trigger()
4150 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4154 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4158 hdsp_silence_playback(hdsp); in snd_hdsp_trigger()
4162 if (!hdsp->running && running) in snd_hdsp_trigger()
4163 hdsp_start_audio(hdsp); in snd_hdsp_trigger()
4164 else if (hdsp->running && !running) in snd_hdsp_trigger()
4165 hdsp_stop_audio(hdsp); in snd_hdsp_trigger()
4166 hdsp->running = running; in snd_hdsp_trigger()
4167 spin_unlock(&hdsp->lock); in snd_hdsp_trigger()
4174 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_prepare() local
4177 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_prepare()
4180 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_prepare()
4183 spin_lock_irq(&hdsp->lock); in snd_hdsp_prepare()
4184 if (!hdsp->running) in snd_hdsp_prepare()
4185 hdsp_reset_hw_pointer(hdsp); in snd_hdsp_prepare()
4186 spin_unlock_irq(&hdsp->lock); in snd_hdsp_prepare()
4268 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels() local
4270 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels()
4272 list[0] = hdsp->qs_in_channels; in snd_hdsp_hw_rule_in_channels()
4273 list[1] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4274 list[2] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4278 list[0] = hdsp->ds_in_channels; in snd_hdsp_hw_rule_in_channels()
4279 list[1] = hdsp->ss_in_channels; in snd_hdsp_hw_rule_in_channels()
4288 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels() local
4290 if (hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels()
4291 list[0] = hdsp->qs_out_channels; in snd_hdsp_hw_rule_out_channels()
4292 list[1] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4293 list[2] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4296 list[0] = hdsp->ds_out_channels; in snd_hdsp_hw_rule_out_channels()
4297 list[1] = hdsp->ss_out_channels; in snd_hdsp_hw_rule_out_channels()
4305 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_in_channels_rate() local
4308 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_in_channels_rate()
4310 .min = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4311 .max = hdsp->qs_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4317 .min = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4318 .max = hdsp->ds_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4324 .min = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4325 .max = hdsp->ss_in_channels, in snd_hdsp_hw_rule_in_channels_rate()
4336 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_out_channels_rate() local
4339 if (r->min > 96000 && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_out_channels_rate()
4341 .min = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4342 .max = hdsp->qs_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4348 .min = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4349 .max = hdsp->ds_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4355 .min = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4356 .max = hdsp->ss_out_channels, in snd_hdsp_hw_rule_out_channels_rate()
4367 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_out_channels() local
4370 if (c->min >= hdsp->ss_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4377 } else if (c->max <= hdsp->qs_out_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_out_channels()
4384 } else if (c->max <= hdsp->ds_out_channels) { in snd_hdsp_hw_rule_rate_out_channels()
4398 struct hdsp *hdsp = rule->private; in snd_hdsp_hw_rule_rate_in_channels() local
4401 if (c->min >= hdsp->ss_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4408 } else if (c->max <= hdsp->qs_in_channels && hdsp->io_type == H9632) { in snd_hdsp_hw_rule_rate_in_channels()
4415 } else if (c->max <= hdsp->ds_in_channels) { in snd_hdsp_hw_rule_rate_in_channels()
4428 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_open() local
4431 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_playback_open()
4434 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_playback_open()
4437 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4442 runtime->dma_area = hdsp->playback_buffer; in snd_hdsp_playback_open()
4445 hdsp->playback_pid = current->pid; in snd_hdsp_playback_open()
4446 hdsp->playback_substream = substream; in snd_hdsp_playback_open()
4448 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_open()
4452 if (hdsp->clock_source_locked) { in snd_hdsp_playback_open()
4453 runtime->hw.rate_min = runtime->hw.rate_max = hdsp->system_sample_rate; in snd_hdsp_playback_open()
4454 } else if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4459 if (hdsp->io_type == H9632) { in snd_hdsp_playback_open()
4460 runtime->hw.channels_min = hdsp->qs_out_channels; in snd_hdsp_playback_open()
4461 runtime->hw.channels_max = hdsp->ss_out_channels; in snd_hdsp_playback_open()
4465 snd_hdsp_hw_rule_out_channels, hdsp, in snd_hdsp_playback_open()
4468 snd_hdsp_hw_rule_out_channels_rate, hdsp, in snd_hdsp_playback_open()
4471 snd_hdsp_hw_rule_rate_out_channels, hdsp, in snd_hdsp_playback_open()
4474 if (RPM != hdsp->io_type) { in snd_hdsp_playback_open()
4475 hdsp->creg_spdif_stream = hdsp->creg_spdif; in snd_hdsp_playback_open()
4476 hdsp->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_open()
4477 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_open()
4478 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_open()
4485 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_playback_release() local
4487 spin_lock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4489 hdsp->playback_pid = -1; in snd_hdsp_playback_release()
4490 hdsp->playback_substream = NULL; in snd_hdsp_playback_release()
4492 spin_unlock_irq(&hdsp->lock); in snd_hdsp_playback_release()
4494 if (RPM != hdsp->io_type) { in snd_hdsp_playback_release()
4495 hdsp->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_hdsp_playback_release()
4496 snd_ctl_notify(hdsp->card, SNDRV_CTL_EVENT_MASK_VALUE | in snd_hdsp_playback_release()
4497 SNDRV_CTL_EVENT_MASK_INFO, &hdsp->spdif_ctl->id); in snd_hdsp_playback_release()
4505 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_open() local
4508 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_capture_open()
4511 if (hdsp_check_for_firmware(hdsp, 1)) in snd_hdsp_capture_open()
4514 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4519 runtime->dma_area = hdsp->capture_buffer; in snd_hdsp_capture_open()
4522 hdsp->capture_pid = current->pid; in snd_hdsp_capture_open()
4523 hdsp->capture_substream = substream; in snd_hdsp_capture_open()
4525 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_open()
4529 if (hdsp->io_type == H9632) { in snd_hdsp_capture_open()
4530 runtime->hw.channels_min = hdsp->qs_in_channels; in snd_hdsp_capture_open()
4531 runtime->hw.channels_max = hdsp->ss_in_channels; in snd_hdsp_capture_open()
4537 snd_hdsp_hw_rule_in_channels, hdsp, in snd_hdsp_capture_open()
4540 snd_hdsp_hw_rule_in_channels_rate, hdsp, in snd_hdsp_capture_open()
4543 snd_hdsp_hw_rule_rate_in_channels, hdsp, in snd_hdsp_capture_open()
4550 struct hdsp *hdsp = snd_pcm_substream_chip(substream); in snd_hdsp_capture_release() local
4552 spin_lock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4554 hdsp->capture_pid = -1; in snd_hdsp_capture_release()
4555 hdsp->capture_substream = NULL; in snd_hdsp_capture_release()
4557 spin_unlock_irq(&hdsp->lock); in snd_hdsp_capture_release()
4588 static int hdsp_9652_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9652_get_peak() argument
4593 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9652_get_peak()
4600 if (copy_u32_le(&peak_rms->input_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4603 if (copy_u32_le(&peak_rms->playback_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4606 if (copy_u32_le(&peak_rms->output_peaks[i], hdsp->iobase + ofs)) in hdsp_9652_get_peak()
4609 if (copy_u48_le(&peak_rms->input_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4610 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4613 if (copy_u48_le(&peak_rms->playback_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4614 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4617 if (copy_u48_le(&peak_rms->output_rms[i], hdsp->iobase + ofs, in hdsp_9652_get_peak()
4618 hdsp->iobase + ofs + 4)) in hdsp_9652_get_peak()
4625 static int hdsp_9632_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_9632_get_peak() argument
4631 if (hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DoubleSpeedStatus) in hdsp_9632_get_peak()
4633 m = (struct hdsp_9632_meters __iomem *)(hdsp->iobase+HDSP_9632_metersBase); in hdsp_9632_get_peak()
4655 static int hdsp_get_peak(struct hdsp *hdsp, struct hdsp_peak_rms __user *peak_rms) in hdsp_get_peak() argument
4661 hdsp->iobase + HDSP_playbackPeakLevel + i * 4)) in hdsp_get_peak()
4664 hdsp->iobase + HDSP_inputPeakLevel + i * 4)) in hdsp_get_peak()
4669 hdsp->iobase + HDSP_outputPeakLevel + i * 4)) in hdsp_get_peak()
4674 hdsp->iobase + HDSP_playbackRmsLevel + i * 8 + 4, in hdsp_get_peak()
4675 hdsp->iobase + HDSP_playbackRmsLevel + i * 8)) in hdsp_get_peak()
4678 hdsp->iobase + HDSP_inputRmsLevel + i * 8 + 4, in hdsp_get_peak()
4679 hdsp->iobase + HDSP_inputRmsLevel + i * 8)) in hdsp_get_peak()
4687 struct hdsp *hdsp = hw->private_data; in snd_hdsp_hwdep_ioctl() local
4695 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4699 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4703 if (!(hdsp->state & HDSP_FirmwareLoaded)) { in snd_hdsp_hwdep_ioctl()
4704 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4709 switch (hdsp->io_type) { in snd_hdsp_hwdep_ioctl()
4711 return hdsp_9652_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4713 return hdsp_9632_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4715 return hdsp_get_peak(hdsp, peak_rms); in snd_hdsp_hwdep_ioctl()
4723 err = hdsp_check_for_iobox(hdsp); in snd_hdsp_hwdep_ioctl()
4727 err = hdsp_check_for_firmware(hdsp, 1); in snd_hdsp_hwdep_ioctl()
4732 spin_lock_irqsave(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4733 info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4734 info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4735 if (hdsp->io_type != H9632) in snd_hdsp_hwdep_ioctl()
4736 info.adatsync_sync_check = (unsigned char)hdsp_adatsync_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4737 info.spdif_sync_check = (unsigned char)hdsp_spdif_sync_check(hdsp); in snd_hdsp_hwdep_ioctl()
4738 …for (i = 0; i < ((hdsp->io_type != Multiface && hdsp->io_type != RPM && hdsp->io_type != H9632) ? … in snd_hdsp_hwdep_ioctl()
4739 info.adat_sync_check[i] = (unsigned char)hdsp_adat_sync_check(hdsp, i); in snd_hdsp_hwdep_ioctl()
4740 info.spdif_in = (unsigned char)hdsp_spdif_in(hdsp); in snd_hdsp_hwdep_ioctl()
4741 info.spdif_out = (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4744 hdsp_toggle_setting(hdsp, HDSP_SPDIFProfessional); in snd_hdsp_hwdep_ioctl()
4746 hdsp_toggle_setting(hdsp, HDSP_SPDIFEmphasis); in snd_hdsp_hwdep_ioctl()
4748 hdsp_toggle_setting(hdsp, HDSP_SPDIFNonAudio); in snd_hdsp_hwdep_ioctl()
4749 info.spdif_sample_rate = hdsp_spdif_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4750 info.system_sample_rate = hdsp->system_sample_rate; in snd_hdsp_hwdep_ioctl()
4751 info.autosync_sample_rate = hdsp_external_sample_rate(hdsp); in snd_hdsp_hwdep_ioctl()
4752 info.system_clock_mode = (unsigned char)hdsp_system_clock_mode(hdsp); in snd_hdsp_hwdep_ioctl()
4753 info.clock_source = (unsigned char)hdsp_clock_source(hdsp); in snd_hdsp_hwdep_ioctl()
4754 info.autosync_ref = (unsigned char)hdsp_autosync_ref(hdsp); in snd_hdsp_hwdep_ioctl()
4756 hdsp_toggle_setting(hdsp, HDSP_LineOut); in snd_hdsp_hwdep_ioctl()
4757 if (hdsp->io_type == H9632) { in snd_hdsp_hwdep_ioctl()
4758 info.da_gain = (unsigned char)hdsp_da_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4759 info.ad_gain = (unsigned char)hdsp_ad_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4760 info.phone_gain = (unsigned char)hdsp_phone_gain(hdsp); in snd_hdsp_hwdep_ioctl()
4762 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4765 } else if (hdsp->io_type == RPM) { in snd_hdsp_hwdep_ioctl()
4766 info.da_gain = (unsigned char) hdsp_rpm_input12(hdsp); in snd_hdsp_hwdep_ioctl()
4767 info.ad_gain = (unsigned char) hdsp_rpm_input34(hdsp); in snd_hdsp_hwdep_ioctl()
4769 if (hdsp->io_type == H9632 || hdsp->io_type == H9652) in snd_hdsp_hwdep_ioctl()
4771 (unsigned char)hdsp_toggle_setting(hdsp, in snd_hdsp_hwdep_ioctl()
4773 spin_unlock_irqrestore(&hdsp->lock, flags); in snd_hdsp_hwdep_ioctl()
4781 if (hdsp->io_type != H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4782 h9632_aeb.aebi = hdsp->ss_in_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4783 h9632_aeb.aebo = hdsp->ss_out_channels - H9632_SS_CHANNELS; in snd_hdsp_hwdep_ioctl()
4792 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4793 if (hdsp->io_type == Undefined) { in snd_hdsp_hwdep_ioctl()
4794 if ((err = hdsp_get_iobox_version(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4798 hdsp_version.io_type = hdsp->io_type; in snd_hdsp_hwdep_ioctl()
4799 hdsp_version.firmware_rev = hdsp->firmware_rev; in snd_hdsp_hwdep_ioctl()
4809 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4811 if (hdsp->io_type == Undefined) return -EINVAL; in snd_hdsp_hwdep_ioctl()
4813 if (hdsp->state & (HDSP_FirmwareCached | HDSP_FirmwareLoaded)) in snd_hdsp_hwdep_ioctl()
4816 dev_info(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4822 if (hdsp_check_for_iobox (hdsp)) in snd_hdsp_hwdep_ioctl()
4825 if (!hdsp->fw_uploaded) { in snd_hdsp_hwdep_ioctl()
4826 hdsp->fw_uploaded = vmalloc(HDSP_FIRMWARE_SIZE); in snd_hdsp_hwdep_ioctl()
4827 if (!hdsp->fw_uploaded) in snd_hdsp_hwdep_ioctl()
4831 if (copy_from_user(hdsp->fw_uploaded, firmware_data, in snd_hdsp_hwdep_ioctl()
4833 vfree(hdsp->fw_uploaded); in snd_hdsp_hwdep_ioctl()
4834 hdsp->fw_uploaded = NULL; in snd_hdsp_hwdep_ioctl()
4838 hdsp->state |= HDSP_FirmwareCached; in snd_hdsp_hwdep_ioctl()
4840 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4843 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_hwdep_ioctl()
4844 if ((err = snd_hdsp_enable_io(hdsp)) < 0) in snd_hdsp_hwdep_ioctl()
4847 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_hwdep_ioctl()
4848 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_hwdep_ioctl()
4850 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { in snd_hdsp_hwdep_ioctl()
4851 dev_err(hdsp->card->dev, in snd_hdsp_hwdep_ioctl()
4860 …if (copy_to_user(mixer->matrix, hdsp->mixer_matrix, sizeof(unsigned short)*HDSP_MATRIX_MIXER_SIZE)) in snd_hdsp_hwdep_ioctl()
4895 static int snd_hdsp_create_hwdep(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_hwdep() argument
4903 hdsp->hwdep = hw; in snd_hdsp_create_hwdep()
4904 hw->private_data = hdsp; in snd_hdsp_create_hwdep()
4913 static int snd_hdsp_create_pcm(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_pcm() argument
4918 if ((err = snd_pcm_new(card, hdsp->card_name, 0, 1, 1, &pcm)) < 0) in snd_hdsp_create_pcm()
4921 hdsp->pcm = pcm; in snd_hdsp_create_pcm()
4922 pcm->private_data = hdsp; in snd_hdsp_create_pcm()
4923 strcpy(pcm->name, hdsp->card_name); in snd_hdsp_create_pcm()
4933 static void snd_hdsp_9652_enable_mixer (struct hdsp *hdsp) in snd_hdsp_9652_enable_mixer() argument
4935 hdsp->control2_register |= HDSP_9652_ENABLE_MIXER; in snd_hdsp_9652_enable_mixer()
4936 hdsp_write (hdsp, HDSP_control2Reg, hdsp->control2_register); in snd_hdsp_9652_enable_mixer()
4939 static int snd_hdsp_enable_io (struct hdsp *hdsp) in snd_hdsp_enable_io() argument
4943 if (hdsp_fifo_wait (hdsp, 0, 100)) { in snd_hdsp_enable_io()
4944 dev_err(hdsp->card->dev, in snd_hdsp_enable_io()
4949 for (i = 0; i < hdsp->max_channels; ++i) { in snd_hdsp_enable_io()
4950 hdsp_write (hdsp, HDSP_inputEnable + (4 * i), 1); in snd_hdsp_enable_io()
4951 hdsp_write (hdsp, HDSP_outputEnable + (4 * i), 1); in snd_hdsp_enable_io()
4957 static void snd_hdsp_initialize_channels(struct hdsp *hdsp) in snd_hdsp_initialize_channels() argument
4961 switch (hdsp->io_type) { in snd_hdsp_initialize_channels()
4963 hdsp->card_name = "RME Hammerfall DSP + Digiface"; in snd_hdsp_initialize_channels()
4964 hdsp->ss_in_channels = hdsp->ss_out_channels = DIGIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
4965 hdsp->ds_in_channels = hdsp->ds_out_channels = DIGIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
4969 hdsp->card_name = "RME Hammerfall HDSP 9652"; in snd_hdsp_initialize_channels()
4970 hdsp->ss_in_channels = hdsp->ss_out_channels = H9652_SS_CHANNELS; in snd_hdsp_initialize_channels()
4971 hdsp->ds_in_channels = hdsp->ds_out_channels = H9652_DS_CHANNELS; in snd_hdsp_initialize_channels()
4975 status = hdsp_read(hdsp, HDSP_statusRegister); in snd_hdsp_initialize_channels()
4979 hdsp->card_name = "RME Hammerfall HDSP 9632"; in snd_hdsp_initialize_channels()
4980 hdsp->ss_in_channels = H9632_SS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
4981 hdsp->ds_in_channels = H9632_DS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
4982 hdsp->qs_in_channels = H9632_QS_CHANNELS+aebi_channels; in snd_hdsp_initialize_channels()
4983 hdsp->ss_out_channels = H9632_SS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
4984 hdsp->ds_out_channels = H9632_DS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
4985 hdsp->qs_out_channels = H9632_QS_CHANNELS+aebo_channels; in snd_hdsp_initialize_channels()
4989 hdsp->card_name = "RME Hammerfall DSP + Multiface"; in snd_hdsp_initialize_channels()
4990 hdsp->ss_in_channels = hdsp->ss_out_channels = MULTIFACE_SS_CHANNELS; in snd_hdsp_initialize_channels()
4991 hdsp->ds_in_channels = hdsp->ds_out_channels = MULTIFACE_DS_CHANNELS; in snd_hdsp_initialize_channels()
4995 hdsp->card_name = "RME Hammerfall DSP + RPM"; in snd_hdsp_initialize_channels()
4996 hdsp->ss_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
4997 hdsp->ss_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
4998 hdsp->ds_in_channels = RPM_CHANNELS-1; in snd_hdsp_initialize_channels()
4999 hdsp->ds_out_channels = RPM_CHANNELS; in snd_hdsp_initialize_channels()
5008 static void snd_hdsp_initialize_midi_flush (struct hdsp *hdsp) in snd_hdsp_initialize_midi_flush() argument
5010 snd_hdsp_flush_midi_input (hdsp, 0); in snd_hdsp_initialize_midi_flush()
5011 snd_hdsp_flush_midi_input (hdsp, 1); in snd_hdsp_initialize_midi_flush()
5014 static int snd_hdsp_create_alsa_devices(struct snd_card *card, struct hdsp *hdsp) in snd_hdsp_create_alsa_devices() argument
5018 if ((err = snd_hdsp_create_pcm(card, hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5025 if ((err = snd_hdsp_create_midi(card, hdsp, 0)) < 0) { in snd_hdsp_create_alsa_devices()
5031 if (hdsp->io_type == Digiface || hdsp->io_type == H9652) { in snd_hdsp_create_alsa_devices()
5032 if ((err = snd_hdsp_create_midi(card, hdsp, 1)) < 0) { in snd_hdsp_create_alsa_devices()
5039 if ((err = snd_hdsp_create_controls(card, hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5045 snd_hdsp_proc_init(hdsp); in snd_hdsp_create_alsa_devices()
5047 hdsp->system_sample_rate = -1; in snd_hdsp_create_alsa_devices()
5048 hdsp->playback_pid = -1; in snd_hdsp_create_alsa_devices()
5049 hdsp->capture_pid = -1; in snd_hdsp_create_alsa_devices()
5050 hdsp->capture_substream = NULL; in snd_hdsp_create_alsa_devices()
5051 hdsp->playback_substream = NULL; in snd_hdsp_create_alsa_devices()
5053 if ((err = snd_hdsp_set_defaults(hdsp)) < 0) { in snd_hdsp_create_alsa_devices()
5059 if (!(hdsp->state & HDSP_InitializationComplete)) { in snd_hdsp_create_alsa_devices()
5061 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_create_alsa_devices()
5062 hdsp->port, hdsp->irq); in snd_hdsp_create_alsa_devices()
5069 hdsp->state |= HDSP_InitializationComplete; in snd_hdsp_create_alsa_devices()
5076 static int hdsp_request_fw_loader(struct hdsp *hdsp) in hdsp_request_fw_loader() argument
5082 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5084 if (hdsp->io_type == Undefined) { in hdsp_request_fw_loader()
5085 if ((err = hdsp_get_iobox_version(hdsp)) < 0) in hdsp_request_fw_loader()
5087 if (hdsp->io_type == H9652 || hdsp->io_type == H9632) in hdsp_request_fw_loader()
5092 switch (hdsp->io_type) { in hdsp_request_fw_loader()
5097 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5103 if (hdsp->firmware_rev == 0xa) in hdsp_request_fw_loader()
5109 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5110 "invalid io_type %d\n", hdsp->io_type); in hdsp_request_fw_loader()
5114 if (request_firmware(&fw, fwfile, &hdsp->pci->dev)) { in hdsp_request_fw_loader()
5115 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5120 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5127 hdsp->firmware = fw; in hdsp_request_fw_loader()
5129 hdsp->state |= HDSP_FirmwareCached; in hdsp_request_fw_loader()
5131 if ((err = snd_hdsp_load_firmware_from_cache(hdsp)) < 0) in hdsp_request_fw_loader()
5134 if (!(hdsp->state & HDSP_InitializationComplete)) { in hdsp_request_fw_loader()
5135 if ((err = snd_hdsp_enable_io(hdsp)) < 0) in hdsp_request_fw_loader()
5138 if ((err = snd_hdsp_create_hwdep(hdsp->card, hdsp)) < 0) { in hdsp_request_fw_loader()
5139 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5143 snd_hdsp_initialize_channels(hdsp); in hdsp_request_fw_loader()
5144 snd_hdsp_initialize_midi_flush(hdsp); in hdsp_request_fw_loader()
5145 if ((err = snd_hdsp_create_alsa_devices(hdsp->card, hdsp)) < 0) { in hdsp_request_fw_loader()
5146 dev_err(hdsp->card->dev, in hdsp_request_fw_loader()
5155 struct hdsp *hdsp) in snd_hdsp_create() argument
5157 struct pci_dev *pci = hdsp->pci; in snd_hdsp_create()
5162 hdsp->irq = -1; in snd_hdsp_create()
5163 hdsp->state = 0; in snd_hdsp_create()
5164 hdsp->midi[0].rmidi = NULL; in snd_hdsp_create()
5165 hdsp->midi[1].rmidi = NULL; in snd_hdsp_create()
5166 hdsp->midi[0].input = NULL; in snd_hdsp_create()
5167 hdsp->midi[1].input = NULL; in snd_hdsp_create()
5168 hdsp->midi[0].output = NULL; in snd_hdsp_create()
5169 hdsp->midi[1].output = NULL; in snd_hdsp_create()
5170 hdsp->midi[0].pending = 0; in snd_hdsp_create()
5171 hdsp->midi[1].pending = 0; in snd_hdsp_create()
5172 spin_lock_init(&hdsp->midi[0].lock); in snd_hdsp_create()
5173 spin_lock_init(&hdsp->midi[1].lock); in snd_hdsp_create()
5174 hdsp->iobase = NULL; in snd_hdsp_create()
5175 hdsp->control_register = 0; in snd_hdsp_create()
5176 hdsp->control2_register = 0; in snd_hdsp_create()
5177 hdsp->io_type = Undefined; in snd_hdsp_create()
5178 hdsp->max_channels = 26; in snd_hdsp_create()
5180 hdsp->card = card; in snd_hdsp_create()
5182 spin_lock_init(&hdsp->lock); in snd_hdsp_create()
5184 INIT_WORK(&hdsp->midi_work, hdsp_midi_work); in snd_hdsp_create()
5186 pci_read_config_word(hdsp->pci, PCI_CLASS_REVISION, &hdsp->firmware_rev); in snd_hdsp_create()
5187 hdsp->firmware_rev &= 0xff; in snd_hdsp_create()
5196 pci_write_config_byte(hdsp->pci, PCI_LATENCY_TIMER, 0xFF); in snd_hdsp_create()
5201 if (hdsp->firmware_rev < 0xa) in snd_hdsp_create()
5203 else if (hdsp->firmware_rev < 0x64) in snd_hdsp_create()
5204 hdsp->card_name = "RME Hammerfall DSP"; in snd_hdsp_create()
5205 else if (hdsp->firmware_rev < 0x96) { in snd_hdsp_create()
5206 hdsp->card_name = "RME HDSP 9652"; in snd_hdsp_create()
5209 hdsp->card_name = "RME HDSP 9632"; in snd_hdsp_create()
5210 hdsp->max_channels = 16; in snd_hdsp_create()
5217 pci_set_master(hdsp->pci); in snd_hdsp_create()
5221 hdsp->port = pci_resource_start(pci, 0); in snd_hdsp_create()
5222 if ((hdsp->iobase = ioremap(hdsp->port, HDSP_IO_EXTENT)) == NULL) { in snd_hdsp_create()
5223 dev_err(hdsp->card->dev, "unable to remap region 0x%lx-0x%lx\n", in snd_hdsp_create()
5224 hdsp->port, hdsp->port + HDSP_IO_EXTENT - 1); in snd_hdsp_create()
5229 KBUILD_MODNAME, hdsp)) { in snd_hdsp_create()
5230 dev_err(hdsp->card->dev, "unable to use IRQ %d\n", pci->irq); in snd_hdsp_create()
5234 hdsp->irq = pci->irq; in snd_hdsp_create()
5235 card->sync_irq = hdsp->irq; in snd_hdsp_create()
5236 hdsp->precise_ptr = 0; in snd_hdsp_create()
5237 hdsp->use_midi_work = 1; in snd_hdsp_create()
5238 hdsp->dds_value = 0; in snd_hdsp_create()
5240 if ((err = snd_hdsp_initialize_memory(hdsp)) < 0) in snd_hdsp_create()
5246 err = hdsp_wait_for_iobox(hdsp, 1000, 10); in snd_hdsp_create()
5251 if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { in snd_hdsp_create()
5252 if ((err = hdsp_request_fw_loader(hdsp)) < 0) in snd_hdsp_create()
5257 dev_err(hdsp->card->dev, in snd_hdsp_create()
5263 dev_info(hdsp->card->dev, in snd_hdsp_create()
5265 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) in snd_hdsp_create()
5269 dev_info(hdsp->card->dev, in snd_hdsp_create()
5271 if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version2) in snd_hdsp_create()
5272 hdsp->io_type = RPM; in snd_hdsp_create()
5273 else if (hdsp_read(hdsp, HDSP_status2Register) & HDSP_version1) in snd_hdsp_create()
5274 hdsp->io_type = Multiface; in snd_hdsp_create()
5276 hdsp->io_type = Digiface; in snd_hdsp_create()
5280 if ((err = snd_hdsp_enable_io(hdsp)) != 0) in snd_hdsp_create()
5284 hdsp->io_type = H9652; in snd_hdsp_create()
5287 hdsp->io_type = H9632; in snd_hdsp_create()
5289 if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) in snd_hdsp_create()
5292 snd_hdsp_initialize_channels(hdsp); in snd_hdsp_create()
5293 snd_hdsp_initialize_midi_flush(hdsp); in snd_hdsp_create()
5295 hdsp->state |= HDSP_FirmwareLoaded; in snd_hdsp_create()
5297 if ((err = snd_hdsp_create_alsa_devices(card, hdsp)) < 0) in snd_hdsp_create()
5303 static int snd_hdsp_free(struct hdsp *hdsp) in snd_hdsp_free() argument
5305 if (hdsp->port) { in snd_hdsp_free()
5307 cancel_work_sync(&hdsp->midi_work); in snd_hdsp_free()
5308 …hdsp->control_register &= ~(HDSP_Start|HDSP_AudioInterruptEnable|HDSP_Midi0InterruptEnable|HDSP_Mi… in snd_hdsp_free()
5309 hdsp_write (hdsp, HDSP_controlRegister, hdsp->control_register); in snd_hdsp_free()
5312 if (hdsp->irq >= 0) in snd_hdsp_free()
5313 free_irq(hdsp->irq, (void *)hdsp); in snd_hdsp_free()
5315 snd_hdsp_free_buffers(hdsp); in snd_hdsp_free()
5317 release_firmware(hdsp->firmware); in snd_hdsp_free()
5318 vfree(hdsp->fw_uploaded); in snd_hdsp_free()
5319 iounmap(hdsp->iobase); in snd_hdsp_free()
5321 if (hdsp->port) in snd_hdsp_free()
5322 pci_release_regions(hdsp->pci); in snd_hdsp_free()
5324 if (pci_is_enabled(hdsp->pci)) in snd_hdsp_free()
5325 pci_disable_device(hdsp->pci); in snd_hdsp_free()
5331 struct hdsp *hdsp = card->private_data; in snd_hdsp_card_free() local
5333 if (hdsp) in snd_hdsp_card_free()
5334 snd_hdsp_free(hdsp); in snd_hdsp_card_free()
5341 struct hdsp *hdsp; in snd_hdsp_probe() local
5353 sizeof(struct hdsp), &card); in snd_hdsp_probe()
5357 hdsp = card->private_data; in snd_hdsp_probe()
5359 hdsp->dev = dev; in snd_hdsp_probe()
5360 hdsp->pci = pci; in snd_hdsp_probe()
5361 err = snd_hdsp_create(card, hdsp); in snd_hdsp_probe()
5366 sprintf(card->longname, "%s at 0x%lx, irq %d", hdsp->card_name, in snd_hdsp_probe()
5367 hdsp->port, hdsp->irq); in snd_hdsp_probe()