Lines Matching defs:rme9652
330 static inline void rme9652_write(struct snd_rme9652 *rme9652, int reg, int val)
332 writel(val, rme9652->iobase + reg);
335 static inline unsigned int rme9652_read(struct snd_rme9652 *rme9652, int reg)
337 return readl(rme9652->iobase + reg);
340 static inline int snd_rme9652_use_is_exclusive(struct snd_rme9652 *rme9652)
345 spin_lock_irqsave(&rme9652->lock, flags);
346 if ((rme9652->playback_pid != rme9652->capture_pid) &&
347 (rme9652->playback_pid >= 0) && (rme9652->capture_pid >= 0)) {
350 spin_unlock_irqrestore(&rme9652->lock, flags);
354 static inline int rme9652_adat_sample_rate(struct snd_rme9652 *rme9652)
356 if (rme9652_running_double_speed(rme9652)) {
357 return (rme9652_read(rme9652, RME9652_status_register) &
360 return (rme9652_read(rme9652, RME9652_status_register) &
365 static inline void rme9652_compute_period_size(struct snd_rme9652 *rme9652)
369 i = rme9652->control_register & RME9652_latency;
370 rme9652->period_bytes = 1 << ((rme9652_decode_latency(i) + 8));
371 rme9652->hw_offsetmask =
372 (rme9652->period_bytes * 2 - 1) & RME9652_buf_pos;
373 rme9652->max_jitter = 80;
376 static snd_pcm_uframes_t rme9652_hw_pointer(struct snd_rme9652 *rme9652)
380 snd_pcm_uframes_t period_size = rme9652->period_bytes / 4;
383 status = rme9652_read(rme9652, RME9652_status_register);
384 if (!rme9652->precise_ptr)
392 delta = rme9652->prev_hw_offset - offset;
394 if (delta <= (snd_pcm_sframes_t)rme9652->max_jitter * 4)
395 offset = rme9652->prev_hw_offset;
397 rme9652->prev_hw_offset = offset;
398 offset &= rme9652->hw_offsetmask;
403 if (offset > rme9652->max_jitter) {
408 offset -= rme9652->max_jitter;
412 if (offset > period_size + rme9652->max_jitter) {
417 offset -= rme9652->max_jitter;
423 static inline void rme9652_reset_hw_pointer(struct snd_rme9652 *rme9652)
434 rme9652_write(rme9652, i * 4, 0);
437 rme9652->prev_hw_offset = 0;
486 static int rme9652_set_rate(struct snd_rme9652 *rme9652, int rate)
492 if (!snd_rme9652_use_is_exclusive (rme9652)) {
507 spin_lock_irq(&rme9652->lock);
508 xrate = rme9652_adat_sample_rate(rme9652);
536 spin_unlock_irq(&rme9652->lock);
540 if (reject_if_open && (rme9652->capture_pid >= 0 || rme9652->playback_pid >= 0)) {
541 spin_unlock_irq(&rme9652->lock);
545 if ((restart = rme9652->running)) {
546 rme9652_stop(rme9652);
548 rme9652->control_register &= ~(RME9652_freq | RME9652_DS);
549 rme9652->control_register |= rate;
550 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
553 rme9652_start(rme9652);
557 if (rme9652->ss_channels == RME9652_NCHANNELS) {
558 rme9652->channel_map = channel_map_9652_ds;
560 rme9652->channel_map = channel_map_9636_ds;
563 if (rme9652->ss_channels == RME9652_NCHANNELS) {
564 rme9652->channel_map = channel_map_9652_ss;
566 rme9652->channel_map = channel_map_9636_ss;
570 spin_unlock_irq(&rme9652->lock);
574 static void rme9652_set_thru(struct snd_rme9652 *rme9652, int channel, int enable)
578 rme9652->passthru = 0;
586 rme9652->thru_bits |= (1 << i);
587 rme9652_write(rme9652, RME9652_thru_base + i * 4, 1);
591 rme9652->thru_bits &= ~(1 << i);
592 rme9652_write(rme9652, RME9652_thru_base + i * 4, 0);
601 mapped_channel = rme9652->channel_map[channel];
604 rme9652->thru_bits |= (1 << mapped_channel);
606 rme9652->thru_bits &= ~(1 << mapped_channel);
609 rme9652_write(rme9652,
615 static int rme9652_set_passthru(struct snd_rme9652 *rme9652, int onoff)
618 rme9652_set_thru(rme9652, -1, 1);
624 rme9652->control_register =
629 rme9652_reset_hw_pointer(rme9652);
631 rme9652_write(rme9652, RME9652_control_register,
632 rme9652->control_register);
633 rme9652->passthru = 1;
635 rme9652_set_thru(rme9652, -1, 0);
636 rme9652_stop(rme9652);
637 rme9652->passthru = 0;
643 static void rme9652_spdif_set_bit (struct snd_rme9652 *rme9652, int mask, int onoff)
646 rme9652->control_register |= mask;
648 rme9652->control_register &= ~mask;
650 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
653 static void rme9652_spdif_write_byte (struct snd_rme9652 *rme9652, const int val)
660 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_WRITE, 1);
662 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_WRITE, 0);
664 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_CLOCK, 1);
665 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_CLOCK, 0);
669 static int rme9652_spdif_read_byte (struct snd_rme9652 *rme9652)
678 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_CLOCK, 1);
679 if (rme9652_read (rme9652, RME9652_status_register) & RME9652_SPDIF_READ)
681 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_CLOCK, 0);
687 static void rme9652_write_spdif_codec (struct snd_rme9652 *rme9652, const int address, const int data)
689 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_SELECT, 1);
690 rme9652_spdif_write_byte (rme9652, 0x20);
691 rme9652_spdif_write_byte (rme9652, address);
692 rme9652_spdif_write_byte (rme9652, data);
693 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_SELECT, 0);
697 static int rme9652_spdif_read_codec (struct snd_rme9652 *rme9652, const int address)
701 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_SELECT, 1);
702 rme9652_spdif_write_byte (rme9652, 0x20);
703 rme9652_spdif_write_byte (rme9652, address);
704 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_SELECT, 0);
705 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_SELECT, 1);
707 rme9652_spdif_write_byte (rme9652, 0x21);
708 ret = rme9652_spdif_read_byte (rme9652);
709 rme9652_spdif_set_bit (rme9652, RME9652_SPDIF_SELECT, 0);
714 static void rme9652_initialize_spdif_receiver (struct snd_rme9652 *rme9652)
717 rme9652->control_register |= RME9652_SPDIF_RESET;
719 rme9652_write_spdif_codec (rme9652, 4, 0x40);
720 rme9652_write_spdif_codec (rme9652, 17, 0x13);
721 rme9652_write_spdif_codec (rme9652, 6, 0x02);
823 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
825 snd_rme9652_convert_to_aes(&ucontrol->value.iec958, rme9652->creg_spdif);
831 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
836 spin_lock_irq(&rme9652->lock);
837 change = val != rme9652->creg_spdif;
838 rme9652->creg_spdif = val;
839 spin_unlock_irq(&rme9652->lock);
852 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
854 snd_rme9652_convert_to_aes(&ucontrol->value.iec958, rme9652->creg_spdif_stream);
860 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
865 spin_lock_irq(&rme9652->lock);
866 change = val != rme9652->creg_spdif_stream;
867 rme9652->creg_spdif_stream = val;
868 rme9652->control_register &= ~(RME9652_PRO | RME9652_Dolby | RME9652_EMP);
869 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register |= val);
870 spin_unlock_irq(&rme9652->lock);
893 static unsigned int rme9652_adat1_in(struct snd_rme9652 *rme9652)
895 if (rme9652->control_register & RME9652_ADAT1_INTERNAL)
900 static int rme9652_set_adat1_input(struct snd_rme9652 *rme9652, int internal)
905 rme9652->control_register |= RME9652_ADAT1_INTERNAL;
907 rme9652->control_register &= ~RME9652_ADAT1_INTERNAL;
911 if ((restart = rme9652->running)) {
912 rme9652_stop(rme9652);
915 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
918 rme9652_start(rme9652);
939 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
941 spin_lock_irq(&rme9652->lock);
942 ucontrol->value.enumerated.item[0] = rme9652_adat1_in(rme9652);
943 spin_unlock_irq(&rme9652->lock);
949 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
953 if (!snd_rme9652_use_is_exclusive(rme9652))
956 spin_lock_irq(&rme9652->lock);
957 change = val != rme9652_adat1_in(rme9652);
959 rme9652_set_adat1_input(rme9652, val);
960 spin_unlock_irq(&rme9652->lock);
969 static unsigned int rme9652_spdif_in(struct snd_rme9652 *rme9652)
971 return rme9652_decode_spdif_in(rme9652->control_register &
975 static int rme9652_set_spdif_input(struct snd_rme9652 *rme9652, int in)
979 rme9652->control_register &= ~RME9652_inp;
980 rme9652->control_register |= rme9652_encode_spdif_in(in);
982 if ((restart = rme9652->running)) {
983 rme9652_stop(rme9652);
986 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
989 rme9652_start(rme9652);
1010 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1012 spin_lock_irq(&rme9652->lock);
1013 ucontrol->value.enumerated.item[0] = rme9652_spdif_in(rme9652);
1014 spin_unlock_irq(&rme9652->lock);
1020 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1024 if (!snd_rme9652_use_is_exclusive(rme9652))
1027 spin_lock_irq(&rme9652->lock);
1028 change = val != rme9652_spdif_in(rme9652);
1030 rme9652_set_spdif_input(rme9652, val);
1031 spin_unlock_irq(&rme9652->lock);
1040 static int rme9652_spdif_out(struct snd_rme9652 *rme9652)
1042 return (rme9652->control_register & RME9652_opt_out) ? 1 : 0;
1045 static int rme9652_set_spdif_output(struct snd_rme9652 *rme9652, int out)
1050 rme9652->control_register |= RME9652_opt_out;
1052 rme9652->control_register &= ~RME9652_opt_out;
1055 if ((restart = rme9652->running)) {
1056 rme9652_stop(rme9652);
1059 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
1062 rme9652_start(rme9652);
1079 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1081 spin_lock_irq(&rme9652->lock);
1082 ucontrol->value.integer.value[0] = rme9652_spdif_out(rme9652);
1083 spin_unlock_irq(&rme9652->lock);
1089 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1093 if (!snd_rme9652_use_is_exclusive(rme9652))
1096 spin_lock_irq(&rme9652->lock);
1097 change = (int)val != rme9652_spdif_out(rme9652);
1098 rme9652_set_spdif_output(rme9652, val);
1099 spin_unlock_irq(&rme9652->lock);
1108 static int rme9652_sync_mode(struct snd_rme9652 *rme9652)
1110 if (rme9652->control_register & RME9652_wsel) {
1112 } else if (rme9652->control_register & RME9652_Master) {
1119 static int rme9652_set_sync_mode(struct snd_rme9652 *rme9652, int mode)
1125 rme9652->control_register &=
1129 rme9652->control_register =
1130 (rme9652->control_register & ~RME9652_wsel) | RME9652_Master;
1133 rme9652->control_register |=
1138 if ((restart = rme9652->running)) {
1139 rme9652_stop(rme9652);
1142 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
1145 rme9652_start(rme9652);
1166 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1168 spin_lock_irq(&rme9652->lock);
1169 ucontrol->value.enumerated.item[0] = rme9652_sync_mode(rme9652);
1170 spin_unlock_irq(&rme9652->lock);
1176 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1181 spin_lock_irq(&rme9652->lock);
1182 change = (int)val != rme9652_sync_mode(rme9652);
1183 rme9652_set_sync_mode(rme9652, val);
1184 spin_unlock_irq(&rme9652->lock);
1193 static int rme9652_sync_pref(struct snd_rme9652 *rme9652)
1195 switch (rme9652->control_register & RME9652_SyncPref_Mask) {
1209 static int rme9652_set_sync_pref(struct snd_rme9652 *rme9652, int pref)
1213 rme9652->control_register &= ~RME9652_SyncPref_Mask;
1216 rme9652->control_register |= RME9652_SyncPref_ADAT1;
1219 rme9652->control_register |= RME9652_SyncPref_ADAT2;
1222 rme9652->control_register |= RME9652_SyncPref_ADAT3;
1225 rme9652->control_register |= RME9652_SyncPref_SPDIF;
1229 if ((restart = rme9652->running)) {
1230 rme9652_stop(rme9652);
1233 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
1236 rme9652_start(rme9652);
1245 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1249 uinfo->value.enumerated.items = rme9652->ss_channels == RME9652_NCHANNELS ? 4 : 3;
1258 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1260 spin_lock_irq(&rme9652->lock);
1261 ucontrol->value.enumerated.item[0] = rme9652_sync_pref(rme9652);
1262 spin_unlock_irq(&rme9652->lock);
1268 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1272 if (!snd_rme9652_use_is_exclusive(rme9652))
1274 max = rme9652->ss_channels == RME9652_NCHANNELS ? 4 : 3;
1276 spin_lock_irq(&rme9652->lock);
1277 change = (int)val != rme9652_sync_pref(rme9652);
1278 rme9652_set_sync_pref(rme9652, val);
1279 spin_unlock_irq(&rme9652->lock);
1285 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1287 uinfo->count = rme9652->ss_channels;
1295 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1297 u32 thru_bits = rme9652->thru_bits;
1299 for (k = 0; k < rme9652->ss_channels; ++k) {
1307 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1312 if (!snd_rme9652_use_is_exclusive(rme9652))
1315 for (chn = 0; chn < rme9652->ss_channels; ++chn) {
1320 spin_lock_irq(&rme9652->lock);
1321 change = thru_bits ^ rme9652->thru_bits;
1323 for (chn = 0; chn < rme9652->ss_channels; ++chn) {
1326 rme9652_set_thru(rme9652,chn,thru_bits&(1<<chn));
1329 spin_unlock_irq(&rme9652->lock);
1350 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1352 spin_lock_irq(&rme9652->lock);
1353 ucontrol->value.integer.value[0] = rme9652->passthru;
1354 spin_unlock_irq(&rme9652->lock);
1360 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1365 if (!snd_rme9652_use_is_exclusive(rme9652))
1369 spin_lock_irq(&rme9652->lock);
1370 change = (ucontrol->value.integer.value[0] != rme9652->passthru);
1372 err = rme9652_set_passthru(rme9652, val);
1373 spin_unlock_irq(&rme9652->lock);
1396 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1398 spin_lock_irq(&rme9652->lock);
1399 ucontrol->value.integer.value[0] = rme9652_spdif_sample_rate(rme9652);
1400 spin_unlock_irq(&rme9652->lock);
1425 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1434 val = rme9652_read(rme9652, RME9652_status_register);
1457 struct snd_rme9652 *rme9652 = snd_kcontrol_chip(kcontrol);
1460 (rme9652_read(rme9652, RME9652_status_register) & RME9652_tc_valid) ? 1 : 0;
1580 static int snd_rme9652_create_controls(struct snd_card *card, struct snd_rme9652 *rme9652)
1587 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_rme9652_controls[idx], rme9652))) < 0)
1590 rme9652->spdif_ctl = kctl;
1593 if (rme9652->ss_channels == RME9652_NCHANNELS)
1594 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_rme9652_adat3_check, rme9652))) < 0)
1597 if (rme9652->hw_rev >= 15)
1598 if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_rme9652_adat1_input, rme9652))) < 0)
1611 struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) entry->private_data;
1612 u32 thru_bits = rme9652->thru_bits;
1618 status = rme9652_read(rme9652, RME9652_status_register);
1620 snd_iprintf(buffer, "%s (Card #%d)\n", rme9652->card_name, rme9652->card->number + 1);
1622 rme9652->capture_buffer, rme9652->playback_buffer);
1624 rme9652->irq, rme9652->port, (unsigned long)rme9652->iobase);
1625 snd_iprintf(buffer, "Control register: %x\n", rme9652->control_register);
1629 x = 1 << (6 + rme9652_decode_latency(rme9652->control_register &
1633 x, (unsigned long) rme9652->period_bytes);
1635 rme9652_hw_pointer(rme9652));
1637 rme9652->passthru ? "yes" : "no");
1639 if ((rme9652->control_register & (RME9652_Master | RME9652_wsel)) == 0) {
1642 } else if (rme9652->control_register & RME9652_wsel) {
1653 switch (rme9652->control_register & RME9652_SyncPref_Mask) {
1671 if (rme9652->hw_rev >= 15)
1673 (rme9652->control_register & RME9652_ADAT1_INTERNAL) ?
1678 switch (rme9652_decode_spdif_in(rme9652->control_register &
1694 if (rme9652->control_register & RME9652_opt_out) {
1700 if (rme9652->control_register & RME9652_PRO) {
1706 if (rme9652->control_register & RME9652_EMP) {
1712 if (rme9652->control_register & RME9652_Dolby) {
1718 i = rme9652_spdif_sample_rate(rme9652);
1732 rme9652_adat_sample_rate(rme9652));
1766 for (i = 0; i < rme9652->ss_channels; i++) {
1781 static void __devinit snd_rme9652_proc_init(struct snd_rme9652 *rme9652)
1785 if (! snd_card_proc_new(rme9652->card, "rme9652", &entry))
1786 snd_info_set_text_ops(entry, rme9652, snd_rme9652_proc_read);
1789 static void snd_rme9652_free_buffers(struct snd_rme9652 *rme9652)
1791 snd_hammerfall_free_buffer(&rme9652->capture_dma_buf, rme9652->pci);
1792 snd_hammerfall_free_buffer(&rme9652->playback_dma_buf, rme9652->pci);
1795 static int snd_rme9652_free(struct snd_rme9652 *rme9652)
1797 if (rme9652->irq >= 0)
1798 rme9652_stop(rme9652);
1799 snd_rme9652_free_buffers(rme9652);
1801 if (rme9652->irq >= 0)
1802 free_irq(rme9652->irq, (void *)rme9652);
1803 if (rme9652->iobase)
1804 iounmap(rme9652->iobase);
1805 if (rme9652->port)
1806 pci_release_regions(rme9652->pci);
1808 pci_disable_device(rme9652->pci);
1812 static int __devinit snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652)
1816 if (snd_hammerfall_get_buffer(rme9652->pci, &rme9652->capture_dma_buf, RME9652_DMA_AREA_BYTES) < 0 ||
1817 snd_hammerfall_get_buffer(rme9652->pci, &rme9652->playback_dma_buf, RME9652_DMA_AREA_BYTES) < 0) {
1818 if (rme9652->capture_dma_buf.area)
1819 snd_dma_free_pages(&rme9652->capture_dma_buf);
1820 printk(KERN_ERR "%s: no buffers available\n", rme9652->card_name);
1826 cb_bus = ALIGN(rme9652->capture_dma_buf.addr, 0x10000ul);
1827 pb_bus = ALIGN(rme9652->playback_dma_buf.addr, 0x10000ul);
1831 rme9652_write(rme9652, RME9652_rec_buffer, cb_bus);
1832 rme9652_write(rme9652, RME9652_play_buffer, pb_bus);
1834 rme9652->capture_buffer = rme9652->capture_dma_buf.area + (cb_bus - rme9652->capture_dma_buf.addr);
1835 rme9652->playback_buffer = rme9652->playback_dma_buf.area + (pb_bus - rme9652->playback_dma_buf.addr);
1840 static void snd_rme9652_set_defaults(struct snd_rme9652 *rme9652)
1844 /* ASSUMPTION: rme9652->lock is either held, or
1860 rme9652->control_register =
1863 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register);
1865 rme9652_reset_hw_pointer(rme9652);
1866 rme9652_compute_period_size(rme9652);
1871 rme9652_write(rme9652, RME9652_thru_base + k * 4, 0);
1873 rme9652->thru_bits = 0;
1874 rme9652->passthru = 0;
1878 rme9652_set_rate(rme9652, 48000);
1883 struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) dev_id;
1885 if (!(rme9652_read(rme9652, RME9652_status_register) & RME9652_IRQ)) {
1889 rme9652_write(rme9652, RME9652_irq_clear, 0);
1891 if (rme9652->capture_substream) {
1892 snd_pcm_period_elapsed(rme9652->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
1895 if (rme9652->playback_substream) {
1896 snd_pcm_period_elapsed(rme9652->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream);
1903 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
1904 return rme9652_hw_pointer(rme9652);
1907 static char *rme9652_channel_buffer_location(struct snd_rme9652 *rme9652,
1916 if ((mapped_channel = rme9652->channel_map[channel]) < 0) {
1921 return rme9652->capture_buffer +
1924 return rme9652->playback_buffer +
1932 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
1937 channel_buf = rme9652_channel_buffer_location (rme9652,
1949 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
1954 channel_buf = rme9652_channel_buffer_location (rme9652,
1966 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
1969 channel_buf = rme9652_channel_buffer_location (rme9652,
1980 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
1983 other = rme9652->capture_substream;
1985 other = rme9652->playback_substream;
1986 if (rme9652->running)
1987 runtime->status->hw_ptr = rme9652_hw_pointer(rme9652);
2006 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2011 spin_lock_irq(&rme9652->lock);
2014 rme9652->control_register &= ~(RME9652_PRO | RME9652_Dolby | RME9652_EMP);
2015 rme9652_write(rme9652, RME9652_control_register, rme9652->control_register |= rme9652->creg_spdif_stream);
2016 this_pid = rme9652->playback_pid;
2017 other_pid = rme9652->capture_pid;
2019 this_pid = rme9652->capture_pid;
2020 other_pid = rme9652->playback_pid;
2031 rme9652_adat_sample_rate(rme9652)) {
2032 spin_unlock_irq(&rme9652->lock);
2037 if (params_period_size(params) != rme9652->period_bytes / 4) {
2038 spin_unlock_irq(&rme9652->lock);
2045 spin_unlock_irq(&rme9652->lock);
2049 spin_unlock_irq(&rme9652->lock);
2055 if ((err = rme9652_set_rate(rme9652, params_rate(params))) < 0) {
2060 if ((err = rme9652_set_interrupt_interval(rme9652, params_period_size(params))) < 0) {
2071 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2076 if ((chn = rme9652->channel_map[info->channel]) < 0) {
2106 static void rme9652_silence_playback(struct snd_rme9652 *rme9652)
2108 memset(rme9652->playback_buffer, 0, RME9652_DMA_AREA_BYTES);
2114 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2117 spin_lock(&rme9652->lock);
2118 running = rme9652->running;
2128 spin_unlock(&rme9652->lock);
2132 other = rme9652->capture_substream;
2134 other = rme9652->playback_substream;
2151 rme9652_silence_playback(rme9652);
2155 rme9652_silence_playback(rme9652);
2159 rme9652_silence_playback(rme9652);
2163 if (!rme9652->running && running)
2164 rme9652_start(rme9652);
2165 else if (rme9652->running && !running)
2166 rme9652_stop(rme9652);
2167 rme9652->running = running;
2168 spin_unlock(&rme9652->lock);
2175 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2179 spin_lock_irqsave(&rme9652->lock, flags);
2180 if (!rme9652->running)
2181 rme9652_reset_hw_pointer(rme9652);
2182 spin_unlock_irqrestore(&rme9652->lock, flags);
2244 struct snd_rme9652 *rme9652 = rule->private;
2246 unsigned int list[2] = { rme9652->ds_channels, rme9652->ss_channels };
2253 struct snd_rme9652 *rme9652 = rule->private;
2258 .min = rme9652->ds_channels,
2259 .max = rme9652->ds_channels,
2265 .min = rme9652->ss_channels,
2266 .max = rme9652->ss_channels,
2277 struct snd_rme9652 *rme9652 = rule->private;
2280 if (c->min >= rme9652->ss_channels) {
2287 } else if (c->max <= rme9652->ds_channels) {
2300 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2303 spin_lock_irq(&rme9652->lock);
2308 runtime->dma_area = rme9652->playback_buffer;
2311 if (rme9652->capture_substream == NULL) {
2312 rme9652_stop(rme9652);
2313 rme9652_set_thru(rme9652, -1, 0);
2316 rme9652->playback_pid = current->pid;
2317 rme9652->playback_substream = substream;
2319 spin_unlock_irq(&rme9652->lock);
2324 snd_rme9652_hw_rule_channels, rme9652,
2327 snd_rme9652_hw_rule_channels_rate, rme9652,
2330 snd_rme9652_hw_rule_rate_channels, rme9652,
2333 rme9652->creg_spdif_stream = rme9652->creg_spdif;
2334 rme9652->spdif_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
2335 snd_ctl_notify(rme9652->card, SNDRV_CTL_EVENT_MASK_VALUE |
2336 SNDRV_CTL_EVENT_MASK_INFO, &rme9652->spdif_ctl->id);
2342 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2344 spin_lock_irq(&rme9652->lock);
2346 rme9652->playback_pid = -1;
2347 rme9652->playback_substream = NULL;
2349 spin_unlock_irq(&rme9652->lock);
2351 rme9652->spdif_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
2352 snd_ctl_notify(rme9652->card, SNDRV_CTL_EVENT_MASK_VALUE |
2353 SNDRV_CTL_EVENT_MASK_INFO, &rme9652->spdif_ctl->id);
2360 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2363 spin_lock_irq(&rme9652->lock);
2368 runtime->dma_area = rme9652->capture_buffer;
2371 if (rme9652->playback_substream == NULL) {
2372 rme9652_stop(rme9652);
2373 rme9652_set_thru(rme9652, -1, 0);
2376 rme9652->capture_pid = current->pid;
2377 rme9652->capture_substream = substream;
2379 spin_unlock_irq(&rme9652->lock);
2384 snd_rme9652_hw_rule_channels, rme9652,
2387 snd_rme9652_hw_rule_channels_rate, rme9652,
2390 snd_rme9652_hw_rule_rate_channels, rme9652,
2397 struct snd_rme9652 *rme9652 = snd_pcm_substream_chip(substream);
2399 spin_lock_irq(&rme9652->lock);
2401 rme9652->capture_pid = -1;
2402 rme9652->capture_substream = NULL;
2404 spin_unlock_irq(&rme9652->lock);
2432 struct snd_rme9652 *rme9652)
2438 rme9652->card_name,
2443 rme9652->pcm = pcm;
2444 pcm->private_data = rme9652;
2445 strcpy(pcm->name, rme9652->card_name);
2456 struct snd_rme9652 *rme9652,
2459 struct pci_dev *pci = rme9652->pci;
2464 rme9652->irq = -1;
2465 rme9652->card = card;
2467 pci_read_config_word(rme9652->pci, PCI_CLASS_REVISION, &rev);
2484 spin_lock_init(&rme9652->lock);
2486 if ((err = pci_request_regions(pci, "rme9652")) < 0)
2488 rme9652->port = pci_resource_start(pci, 0);
2489 rme9652->iobase = ioremap_nocache(rme9652->port, RME9652_IO_EXTENT);
2490 if (rme9652->iobase == NULL) {
2491 snd_printk(KERN_ERR "unable to remap region 0x%lx-0x%lx\n", rme9652->port, rme9652->port + RME9652_IO_EXTENT - 1);
2496 "rme9652", rme9652)) {
2500 rme9652->irq = pci->irq;
2501 rme9652->precise_ptr = precise_ptr;
2508 status = rme9652_read(rme9652, RME9652_status_register);
2510 rme9652->hw_rev = 15;
2512 rme9652->hw_rev = 11;
2525 if (rme9652->hw_rev == 15) {
2526 rme9652->card_name = "RME Digi9636 (Rev 1.5)";
2528 rme9652->card_name = "RME Digi9636";
2530 rme9652->ss_channels = RME9636_NCHANNELS;
2534 rme9652->card_name = "RME Digi9636 (Rev G)";
2535 rme9652->ss_channels = RME9636_NCHANNELS;
2539 rme9652->card_name = "RME Digi9652 (Rev G)";
2540 rme9652->ss_channels = RME9652_NCHANNELS;
2544 if (rme9652->hw_rev == 15) {
2545 rme9652->card_name = "RME Digi9652 (Rev 1.5)";
2547 rme9652->card_name = "RME Digi9652";
2549 rme9652->ss_channels = RME9652_NCHANNELS;
2553 rme9652->ds_channels = (rme9652->ss_channels - 2) / 2 + 2;
2555 pci_set_master(rme9652->pci);
2557 if ((err = snd_rme9652_initialize_memory(rme9652)) < 0) {
2561 if ((err = snd_rme9652_create_pcm(card, rme9652)) < 0) {
2565 if ((err = snd_rme9652_create_controls(card, rme9652)) < 0) {
2569 snd_rme9652_proc_init(rme9652);
2571 rme9652->last_spdif_sample_rate = -1;
2572 rme9652->last_adat_sample_rate = -1;
2573 rme9652->playback_pid = -1;
2574 rme9652->capture_pid = -1;
2575 rme9652->capture_substream = NULL;
2576 rme9652->playback_substream = NULL;
2578 snd_rme9652_set_defaults(rme9652);
2580 if (rme9652->hw_rev == 15) {
2581 rme9652_initialize_spdif_receiver (rme9652);
2589 struct snd_rme9652 *rme9652 = (struct snd_rme9652 *) card->private_data;
2591 if (rme9652)
2592 snd_rme9652_free(rme9652);
2599 struct snd_rme9652 *rme9652;
2616 rme9652 = (struct snd_rme9652 *) card->private_data;
2618 rme9652->dev = dev;
2619 rme9652->pci = pci;
2622 if ((err = snd_rme9652_create(card, rme9652, precise_ptr[dev])) < 0) {
2627 strcpy(card->shortname, rme9652->card_name);
2630 card->shortname, rme9652->port, rme9652->irq);