26 #include <linux/pci.h>
27 #include <linux/module.h>
36 #include <asm/current.h>
51 MODULE_PARM_DESC(precise_ptr,
"Enable precise pointer (doesn't work reliably).");
56 "{RME,Hammerfall-Light}}");
67 #define RME9652_NCHANNELS 26
68 #define RME9636_NCHANNELS 18
72 #define RME9652_SYNC_FROM_SPDIF 0
73 #define RME9652_SYNC_FROM_ADAT1 1
74 #define RME9652_SYNC_FROM_ADAT2 2
75 #define RME9652_SYNC_FROM_ADAT3 3
79 #define RME9652_SPDIFIN_OPTICAL 0
80 #define RME9652_SPDIFIN_COAXIAL 1
81 #define RME9652_SPDIFIN_INTERN 2
85 #define RME9652_IRQ (1<<0)
86 #define RME9652_lock_2 (1<<1)
87 #define RME9652_lock_1 (1<<2)
88 #define RME9652_lock_0 (1<<3)
89 #define RME9652_fs48 (1<<4)
90 #define RME9652_wsel_rd (1<<5)
92 #define RME9652_sync_2 (1<<16)
93 #define RME9652_sync_1 (1<<17)
94 #define RME9652_sync_0 (1<<18)
95 #define RME9652_DS_rd (1<<19)
96 #define RME9652_tc_busy (1<<20)
97 #define RME9652_tc_out (1<<21)
98 #define RME9652_F_0 (1<<22)
99 #define RME9652_F_1 (1<<23)
100 #define RME9652_F_2 (1<<24)
101 #define RME9652_ERF (1<<25)
102 #define RME9652_buffer_id (1<<26)
103 #define RME9652_tc_valid (1<<27)
104 #define RME9652_SPDIF_READ (1<<28)
106 #define RME9652_sync (RME9652_sync_0|RME9652_sync_1|RME9652_sync_2)
107 #define RME9652_lock (RME9652_lock_0|RME9652_lock_1|RME9652_lock_2)
108 #define RME9652_F (RME9652_F_0|RME9652_F_1|RME9652_F_2)
109 #define rme9652_decode_spdif_rate(x) ((x)>>22)
113 #define RME9652_buf_pos 0x000FFC0
119 #define RME9652_REV15_buf_pos(x) ((((x)&0xE0000000)>>26)|((x)&RME9652_buf_pos))
125 #define RME9652_IO_EXTENT 1024
127 #define RME9652_init_buffer 0
128 #define RME9652_play_buffer 32
129 #define RME9652_rec_buffer 36
130 #define RME9652_control_register 64
131 #define RME9652_irq_clear 96
132 #define RME9652_time_code 100
133 #define RME9652_thru_base 128
141 #define RME9652_status_register 0
146 #define RME9652_start_bit (1<<0)
148 #define RME9652_Master (1<<4)
149 #define RME9652_IE (1<<5)
150 #define RME9652_freq (1<<6)
151 #define RME9652_freq1 (1<<7)
152 #define RME9652_DS (1<<8)
153 #define RME9652_PRO (1<<9)
154 #define RME9652_EMP (1<<10)
155 #define RME9652_Dolby (1<<11)
156 #define RME9652_opt_out (1<<12)
157 #define RME9652_wsel (1<<13)
158 #define RME9652_inp_0 (1<<14)
159 #define RME9652_inp_1 (1<<15)
160 #define RME9652_SyncPref_ADAT2 (1<<16)
161 #define RME9652_SyncPref_ADAT3 (1<<17)
162 #define RME9652_SPDIF_RESET (1<<18)
163 #define RME9652_SPDIF_SELECT (1<<19)
164 #define RME9652_SPDIF_CLOCK (1<<20)
165 #define RME9652_SPDIF_WRITE (1<<21)
166 #define RME9652_ADAT1_INTERNAL (1<<22)
170 #define RME9652_latency 0x0e
171 #define rme9652_encode_latency(x) (((x)&0x7)<<1)
172 #define rme9652_decode_latency(x) (((x)>>1)&0x7)
173 #define rme9652_running_double_speed(s) ((s)->control_register & RME9652_DS)
174 #define RME9652_inp (RME9652_inp_0|RME9652_inp_1)
175 #define rme9652_encode_spdif_in(x) (((x)&0x3)<<14)
176 #define rme9652_decode_spdif_in(x) (((x)>>14)&0x3)
178 #define RME9652_SyncPref_Mask (RME9652_SyncPref_ADAT2|RME9652_SyncPref_ADAT3)
179 #define RME9652_SyncPref_ADAT1 0
180 #define RME9652_SyncPref_SPDIF (RME9652_SyncPref_ADAT2|RME9652_SyncPref_ADAT3)
184 #define RME9652_CHANNEL_BUFFER_SAMPLES (16*1024)
185 #define RME9652_CHANNEL_BUFFER_BYTES (4*RME9652_CHANNEL_BUFFER_SAMPLES)
196 #define RME9652_DMA_AREA_BYTES ((RME9652_NCHANNELS+1) * RME9652_CHANNEL_BUFFER_BYTES)
197 #define RME9652_DMA_AREA_KILOBYTES (RME9652_DMA_AREA_BYTES/1024)
262 static char channel_map_9652_ss[26] = {
263 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
264 18, 19, 20, 21, 22, 23, 24, 25
267 static char channel_map_9636_ss[26] = {
268 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
272 -1, -1, -1, -1, -1, -1, -1, -1
275 static char channel_map_9652_ds[26] = {
277 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23,
281 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
284 static char channel_map_9636_ds[26] = {
286 1, 3, 5, 7, 9, 11, 13, 15,
290 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
298 if (dmab->
bytes >= size)
333 static inline unsigned int rme9652_read(
struct snd_rme9652 *rme9652,
int reg)
338 static inline int snd_rme9652_use_is_exclusive(
struct snd_rme9652 *rme9652)
348 spin_unlock_irqrestore(&rme9652->
lock, flags);
352 static inline int rme9652_adat_sample_rate(
struct snd_rme9652 *rme9652)
363 static inline void rme9652_compute_period_size(
struct snd_rme9652 *rme9652)
400 if (offset < period_size) {
403 printk(
KERN_ERR "Unexpected hw_pointer position (bufid == 0): status: %x offset: %d\n", status, offset);
408 offset += period_size * 2;
410 if (offset > period_size + rme9652->
max_jitter) {
412 printk(
KERN_ERR "Unexpected hw_pointer position (bufid == 1): status: %x offset: %d\n", status, offset);
421 static inline void rme9652_reset_hw_pointer(
struct snd_rme9652 *rme9652)
431 for (i = 0; i < 8; i++) {
432 rme9652_write(rme9652, i * 4, 0);
450 static int rme9652_set_interrupt_interval(
struct snd_rme9652 *
s,
456 spin_lock_irq(&s->
lock);
474 rme9652_compute_period_size(s);
479 spin_unlock_irq(&s->
lock);
487 int reject_if_open = 0;
490 if (!snd_rme9652_use_is_exclusive (rme9652)) {
505 spin_lock_irq(&rme9652->
lock);
506 xrate = rme9652_adat_sample_rate(rme9652);
534 spin_unlock_irq(&rme9652->
lock);
539 spin_unlock_irq(&rme9652->
lock);
543 if ((restart = rme9652->
running)) {
544 rme9652_stop(rme9652);
551 rme9652_start(rme9652);
568 spin_unlock_irq(&rme9652->
lock);
600 rme9652->
thru_bits |= (1 << mapped_channel);
602 rme9652->
thru_bits &= ~(1 << mapped_channel);
605 rme9652_write(rme9652,
614 rme9652_set_thru(rme9652, -1, 1);
625 rme9652_reset_hw_pointer(rme9652);
631 rme9652_set_thru(rme9652, -1, 0);
632 rme9652_stop(rme9652);
639 static void rme9652_spdif_set_bit (
struct snd_rme9652 *rme9652,
int mask,
int onoff)
649 static void rme9652_spdif_write_byte (
struct snd_rme9652 *rme9652,
const int val)
654 for (i = 0, mask = 0x80; i < 8; i++, mask >>= 1) {
665 static int rme9652_spdif_read_byte (
struct snd_rme9652 *rme9652)
673 for (i = 0, mask = 0x80; i < 8; i++, mask >>= 1) {
686 rme9652_spdif_write_byte (rme9652, 0x20);
687 rme9652_spdif_write_byte (rme9652, address);
688 rme9652_spdif_write_byte (rme9652, data);
698 rme9652_spdif_write_byte (rme9652, 0x20);
699 rme9652_spdif_write_byte (rme9652, address);
703 rme9652_spdif_write_byte (rme9652, 0x21);
704 ret = rme9652_spdif_read_byte (rme9652);
710 static void rme9652_initialize_spdif_receiver (
struct snd_rme9652 *rme9652)
716 rme9652_write_spdif_codec (rme9652, 4, 0x40);
717 rme9652_write_spdif_codec (rme9652, 17, 0x13);
718 rme9652_write_spdif_codec (rme9652, 6, 0x02);
721 static inline int rme9652_spdif_sample_rate(
struct snd_rme9652 *s)
723 unsigned int rate_bits;
733 x = rme9652_spdif_read_codec (s, 30);
740 if (y > 30400 && y < 33600) ret = 32000;
741 else if (y > 41900 && y < 46000) ret = 44100;
742 else if (y > 46000 && y < 50400) ret = 48000;
743 else if (y > 60800 && y < 67200) ret = 64000;
744 else if (y > 83700 && y < 92000) ret = 88200;
745 else if (y > 92000 && y < 100000) ret = 96000;
822 snd_rme9652_convert_to_aes(&ucontrol->
value.iec958, rme9652->
creg_spdif);
832 val = snd_rme9652_convert_from_aes(&ucontrol->
value.iec958);
833 spin_lock_irq(&rme9652->
lock);
836 spin_unlock_irq(&rme9652->
lock);
861 val = snd_rme9652_convert_from_aes(&ucontrol->
value.iec958);
862 spin_lock_irq(&rme9652->
lock);
867 spin_unlock_irq(&rme9652->
lock);
884 #define RME9652_ADAT1_IN(xname, xindex) \
885 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
886 .info = snd_rme9652_info_adat1_in, \
887 .get = snd_rme9652_get_adat1_in, \
888 .put = snd_rme9652_put_adat1_in }
890 static unsigned int rme9652_adat1_in(
struct snd_rme9652 *rme9652)
897 static int rme9652_set_adat1_input(
struct snd_rme9652 *rme9652,
int internal)
909 if ((restart = rme9652->
running)) {
910 rme9652_stop(rme9652);
916 rme9652_start(rme9652);
924 static char *texts[2] = {
"ADAT1",
"Internal"};
939 spin_lock_irq(&rme9652->
lock);
940 ucontrol->
value.enumerated.item[0] = rme9652_adat1_in(rme9652);
941 spin_unlock_irq(&rme9652->
lock);
951 if (!snd_rme9652_use_is_exclusive(rme9652))
953 val = ucontrol->
value.enumerated.item[0] % 2;
954 spin_lock_irq(&rme9652->
lock);
955 change = val != rme9652_adat1_in(rme9652);
957 rme9652_set_adat1_input(rme9652, val);
958 spin_unlock_irq(&rme9652->
lock);
962 #define RME9652_SPDIF_IN(xname, xindex) \
963 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
964 .info = snd_rme9652_info_spdif_in, \
965 .get = snd_rme9652_get_spdif_in, .put = snd_rme9652_put_spdif_in }
967 static unsigned int rme9652_spdif_in(
struct snd_rme9652 *rme9652)
973 static int rme9652_set_spdif_input(
struct snd_rme9652 *rme9652,
int in)
980 if ((restart = rme9652->
running)) {
981 rme9652_stop(rme9652);
987 rme9652_start(rme9652);
995 static char *texts[3] = {
"ADAT1",
"Coaxial",
"Internal"};
1010 spin_lock_irq(&rme9652->
lock);
1011 ucontrol->
value.enumerated.item[0] = rme9652_spdif_in(rme9652);
1012 spin_unlock_irq(&rme9652->
lock);
1022 if (!snd_rme9652_use_is_exclusive(rme9652))
1024 val = ucontrol->
value.enumerated.item[0] % 3;
1025 spin_lock_irq(&rme9652->
lock);
1026 change = val != rme9652_spdif_in(rme9652);
1028 rme9652_set_spdif_input(rme9652, val);
1029 spin_unlock_irq(&rme9652->
lock);
1033 #define RME9652_SPDIF_OUT(xname, xindex) \
1034 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1035 .info = snd_rme9652_info_spdif_out, \
1036 .get = snd_rme9652_get_spdif_out, .put = snd_rme9652_put_spdif_out }
1038 static int rme9652_spdif_out(
struct snd_rme9652 *rme9652)
1043 static int rme9652_set_spdif_output(
struct snd_rme9652 *rme9652,
int out)
1053 if ((restart = rme9652->
running)) {
1054 rme9652_stop(rme9652);
1060 rme9652_start(rme9652);
1066 #define snd_rme9652_info_spdif_out snd_ctl_boolean_mono_info
1072 spin_lock_irq(&rme9652->
lock);
1073 ucontrol->
value.integer.value[0] = rme9652_spdif_out(rme9652);
1074 spin_unlock_irq(&rme9652->
lock);
1084 if (!snd_rme9652_use_is_exclusive(rme9652))
1086 val = ucontrol->
value.integer.value[0] & 1;
1087 spin_lock_irq(&rme9652->
lock);
1088 change = (
int)val != rme9652_spdif_out(rme9652);
1089 rme9652_set_spdif_output(rme9652, val);
1090 spin_unlock_irq(&rme9652->
lock);
1094 #define RME9652_SYNC_MODE(xname, xindex) \
1095 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1096 .info = snd_rme9652_info_sync_mode, \
1097 .get = snd_rme9652_get_sync_mode, .put = snd_rme9652_put_sync_mode }
1099 static int rme9652_sync_mode(
struct snd_rme9652 *rme9652)
1110 static int rme9652_set_sync_mode(
struct snd_rme9652 *rme9652,
int mode)
1129 if ((restart = rme9652->
running)) {
1130 rme9652_stop(rme9652);
1136 rme9652_start(rme9652);
1144 static char *texts[3] = {
"AutoSync",
"Master",
"Word Clock"};
1159 spin_lock_irq(&rme9652->
lock);
1160 ucontrol->
value.enumerated.item[0] = rme9652_sync_mode(rme9652);
1161 spin_unlock_irq(&rme9652->
lock);
1171 val = ucontrol->
value.enumerated.item[0] % 3;
1172 spin_lock_irq(&rme9652->
lock);
1173 change = (
int)val != rme9652_sync_mode(rme9652);
1174 rme9652_set_sync_mode(rme9652, val);
1175 spin_unlock_irq(&rme9652->
lock);
1179 #define RME9652_SYNC_PREF(xname, xindex) \
1180 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1181 .info = snd_rme9652_info_sync_pref, \
1182 .get = snd_rme9652_get_sync_pref, .put = snd_rme9652_put_sync_pref }
1184 static int rme9652_sync_pref(
struct snd_rme9652 *rme9652)
1200 static int rme9652_set_sync_pref(
struct snd_rme9652 *rme9652,
int pref)
1220 if ((restart = rme9652->
running)) {
1221 rme9652_stop(rme9652);
1227 rme9652_start(rme9652);
1235 static char *texts[4] = {
"IEC958 In",
"ADAT1 In",
"ADAT2 In",
"ADAT3 In"};
1251 spin_lock_irq(&rme9652->
lock);
1252 ucontrol->
value.enumerated.item[0] = rme9652_sync_pref(rme9652);
1253 spin_unlock_irq(&rme9652->
lock);
1263 if (!snd_rme9652_use_is_exclusive(rme9652))
1266 val = ucontrol->
value.enumerated.item[0] %
max;
1267 spin_lock_irq(&rme9652->
lock);
1268 change = (
int)val != rme9652_sync_pref(rme9652);
1269 rme9652_set_sync_pref(rme9652, val);
1270 spin_unlock_irq(&rme9652->
lock);
1291 ucontrol->
value.integer.value[
k] = !!(thru_bits & (1 <<
k));
1303 if (!snd_rme9652_use_is_exclusive(rme9652))
1307 if (ucontrol->
value.integer.value[chn])
1308 thru_bits |= 1 <<
chn;
1311 spin_lock_irq(&rme9652->
lock);
1312 change = thru_bits ^ rme9652->
thru_bits;
1315 if (!(change & (1 << chn)))
1317 rme9652_set_thru(rme9652,chn,thru_bits&(1<<chn));
1320 spin_unlock_irq(&rme9652->
lock);
1324 #define RME9652_PASSTHRU(xname, xindex) \
1325 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1326 .info = snd_rme9652_info_passthru, \
1327 .put = snd_rme9652_put_passthru, \
1328 .get = snd_rme9652_get_passthru }
1330 #define snd_rme9652_info_passthru snd_ctl_boolean_mono_info
1336 spin_lock_irq(&rme9652->
lock);
1338 spin_unlock_irq(&rme9652->
lock);
1349 if (!snd_rme9652_use_is_exclusive(rme9652))
1352 val = ucontrol->
value.integer.value[0] & 1;
1353 spin_lock_irq(&rme9652->
lock);
1354 change = (ucontrol->
value.integer.value[0] != rme9652->
passthru);
1356 err = rme9652_set_passthru(rme9652, val);
1357 spin_unlock_irq(&rme9652->
lock);
1358 return err ? err : change;
1363 #define RME9652_SPDIF_RATE(xname, xindex) \
1364 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1365 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
1366 .info = snd_rme9652_info_spdif_rate, \
1367 .get = snd_rme9652_get_spdif_rate }
1382 spin_lock_irq(&rme9652->
lock);
1383 ucontrol->
value.integer.value[0] = rme9652_spdif_sample_rate(rme9652);
1384 spin_unlock_irq(&rme9652->
lock);
1388 #define RME9652_ADAT_SYNC(xname, xindex, xidx) \
1389 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1390 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
1391 .info = snd_rme9652_info_adat_sync, \
1392 .get = snd_rme9652_get_adat_sync, .private_value = xidx }
1396 static char *texts[4] = {
"No Lock",
"Lock",
"No Lock Sync",
"Lock Sync"};
1410 unsigned int mask1, mask2,
val;
1419 ucontrol->
value.enumerated.item[0] = (val & mask1) ? 1 : 0;
1420 ucontrol->
value.enumerated.item[0] |= (val & mask2) ? 2 : 0;
1424 #define RME9652_TC_VALID(xname, xindex) \
1425 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1426 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
1427 .info = snd_rme9652_info_tc_valid, \
1428 .get = snd_rme9652_get_tc_valid }
1430 #define snd_rme9652_info_tc_valid snd_ctl_boolean_mono_info
1436 ucontrol->
value.integer.value[0] =
1441 #ifdef ALSA_HAS_STANDARD_WAY_OF_RETURNING_TIMECODE
1445 static int snd_rme9652_get_tc_value(
void *
private_data,
1446 snd_kswitch_t *kswitch,
1447 snd_switch_t *uswitch)
1453 uswitch->type = SNDRV_SW_TYPE_DWORD;
1457 uswitch->value.data32[0] = 0;
1467 for (i = 0; i < 50; i++) {
1478 for (i = 0; i < 32; i++) {
1482 value |= 0x80000000;
1485 if (value > 2 * 60 * 48000) {
1486 value -= 2 * 60 * 48000;
1491 uswitch->value.data32[0] =
value;
1502 .info = snd_rme9652_control_spdif_info,
1503 .get = snd_rme9652_control_spdif_get,
1504 .put = snd_rme9652_control_spdif_put,
1510 .info = snd_rme9652_control_spdif_stream_info,
1511 .get = snd_rme9652_control_spdif_stream_get,
1512 .put = snd_rme9652_control_spdif_stream_put,
1518 .info = snd_rme9652_control_spdif_mask_info,
1519 .get = snd_rme9652_control_spdif_mask_get,
1520 .private_value = IEC958_AES0_NONAUDIO |
1528 .info = snd_rme9652_control_spdif_mask_info,
1529 .get = snd_rme9652_control_spdif_mask_get,
1530 .private_value = IEC958_AES0_NONAUDIO |
1540 .name =
"Channels Thru",
1542 .info = snd_rme9652_info_thru,
1543 .get = snd_rme9652_get_thru,
1544 .put = snd_rme9652_put_thru,
1565 for (idx = 0; idx <
ARRAY_SIZE(snd_rme9652_controls); idx++) {
1576 if (rme9652->
hw_rev >= 15)
1592 int show_auto_sync_source = 0;
1594 unsigned int status;
1599 snd_iprintf(buffer,
"%s (Card #%d)\n", rme9652->
card_name, rme9652->
card->number + 1);
1600 snd_iprintf(buffer,
"Buffers: capture %p playback %p\n",
1602 snd_iprintf(buffer,
"IRQ: %d Registers bus: 0x%lx VM: 0x%lx\n",
1603 rme9652->
irq, rme9652->
port, (
unsigned long)rme9652->
iobase);
1606 snd_iprintf(buffer,
"\n");
1611 snd_iprintf(buffer,
"Latency: %d samples (2 periods of %lu bytes)\n",
1613 snd_iprintf(buffer,
"Hardware pointer (frames): %ld\n",
1614 rme9652_hw_pointer(rme9652));
1615 snd_iprintf(buffer,
"Passthru: %s\n",
1619 snd_iprintf(buffer,
"Clock mode: autosync\n");
1620 show_auto_sync_source = 1;
1623 snd_iprintf(buffer,
"Clock mode: word clock\n");
1625 snd_iprintf(buffer,
"Clock mode: word clock (no signal)\n");
1628 snd_iprintf(buffer,
"Clock mode: master\n");
1631 if (show_auto_sync_source) {
1634 snd_iprintf(buffer,
"Pref. sync source: ADAT1\n");
1637 snd_iprintf(buffer,
"Pref. sync source: ADAT2\n");
1640 snd_iprintf(buffer,
"Pref. sync source: ADAT3\n");
1643 snd_iprintf(buffer,
"Pref. sync source: IEC958\n");
1646 snd_iprintf(buffer,
"Pref. sync source: ???\n");
1650 if (rme9652->
hw_rev >= 15)
1651 snd_iprintf(buffer,
"\nADAT1 Input source: %s\n",
1653 "Internal" :
"ADAT1 optical");
1655 snd_iprintf(buffer,
"\n");
1660 snd_iprintf(buffer,
"IEC958 input: ADAT1\n");
1663 snd_iprintf(buffer,
"IEC958 input: Coaxial\n");
1666 snd_iprintf(buffer,
"IEC958 input: Internal\n");
1669 snd_iprintf(buffer,
"IEC958 input: ???\n");
1674 snd_iprintf(buffer,
"IEC958 output: Coaxial & ADAT1\n");
1676 snd_iprintf(buffer,
"IEC958 output: Coaxial only\n");
1680 snd_iprintf(buffer,
"IEC958 quality: Professional\n");
1682 snd_iprintf(buffer,
"IEC958 quality: Consumer\n");
1686 snd_iprintf(buffer,
"IEC958 emphasis: on\n");
1688 snd_iprintf(buffer,
"IEC958 emphasis: off\n");
1692 snd_iprintf(buffer,
"IEC958 Dolby: on\n");
1694 snd_iprintf(buffer,
"IEC958 Dolby: off\n");
1697 i = rme9652_spdif_sample_rate(rme9652);
1701 "IEC958 sample rate: error flag set\n");
1702 }
else if (i == 0) {
1703 snd_iprintf(buffer,
"IEC958 sample rate: undetermined\n");
1705 snd_iprintf(buffer,
"IEC958 sample rate: %d\n", i);
1708 snd_iprintf(buffer,
"\n");
1710 snd_iprintf(buffer,
"ADAT Sample rate: %dHz\n",
1711 rme9652_adat_sample_rate(rme9652));
1717 snd_iprintf(buffer,
"ADAT1: %s\n", x ?
"Sync" :
"Lock");
1719 snd_iprintf(buffer,
"ADAT1: No Lock\n");
1724 snd_iprintf(buffer,
"ADAT2: %s\n", x ?
"Sync" :
"Lock");
1726 snd_iprintf(buffer,
"ADAT2: No Lock\n");
1731 snd_iprintf(buffer,
"ADAT3: %s\n", x ?
"Sync" :
"Lock");
1733 snd_iprintf(buffer,
"ADAT3: No Lock\n");
1736 snd_iprintf(buffer,
"\n");
1738 snd_iprintf(buffer,
"Timecode signal: %s\n",
1739 (status & RME9652_tc_valid) ?
"yes" :
"no");
1743 snd_iprintf(buffer,
"Punch Status:\n\n");
1746 if (thru_bits & (1 << i)) {
1747 snd_iprintf(buffer,
"%2d: on ", i + 1);
1749 snd_iprintf(buffer,
"%2d: off ", i + 1);
1752 if (((i + 1) % 8) == 0) {
1753 snd_iprintf(buffer,
"\n");
1757 snd_iprintf(buffer,
"\n");
1764 if (! snd_card_proc_new(rme9652->
card,
"rme9652", &entry))
1765 snd_info_set_text_ops(entry, rme9652, snd_rme9652_proc_read);
1768 static void snd_rme9652_free_buffers(
struct snd_rme9652 *rme9652)
1774 static int snd_rme9652_free(
struct snd_rme9652 *rme9652)
1776 if (rme9652->
irq >= 0)
1777 rme9652_stop(rme9652);
1778 snd_rme9652_free_buffers(rme9652);
1780 if (rme9652->
irq >= 0)
1793 unsigned long pb_bus, cb_bus;
1819 static void snd_rme9652_set_defaults(
struct snd_rme9652 *rme9652)
1844 rme9652_reset_hw_pointer(rme9652);
1845 rme9652_compute_period_size(rme9652);
1857 rme9652_set_rate(rme9652, 48000);
1883 return rme9652_hw_pointer(rme9652);
1886 static char *rme9652_channel_buffer_location(
struct snd_rme9652 *rme9652,
1896 if ((mapped_channel = rme9652->
channel_map[channel]) < 0) {
1909 static int snd_rme9652_playback_copy(
struct snd_pcm_substream *substream,
int channel,
1918 channel_buf = rme9652_channel_buffer_location (rme9652,
1919 substream->
pstr->stream,
1928 static int snd_rme9652_capture_copy(
struct snd_pcm_substream *substream,
int channel,
1937 channel_buf = rme9652_channel_buffer_location (rme9652,
1938 substream->
pstr->stream,
1942 if (
copy_to_user(dst, channel_buf + pos * 4, count * 4))
1947 static int snd_rme9652_hw_silence(
struct snd_pcm_substream *substream,
int channel,
1953 channel_buf = rme9652_channel_buffer_location (rme9652,
1954 substream->
pstr->stream,
1958 memset(channel_buf + pos * 4, 0, count * 4);
1972 runtime->
status->hw_ptr = rme9652_hw_pointer(rme9652);
1974 runtime->
status->hw_ptr = 0;
1996 spin_lock_irq(&rme9652->
lock);
2008 if ((other_pid > 0) && (this_pid != other_pid)) {
2016 rme9652_adat_sample_rate(rme9652)) {
2017 spin_unlock_irq(&rme9652->
lock);
2023 spin_unlock_irq(&rme9652->
lock);
2030 spin_unlock_irq(&rme9652->
lock);
2034 spin_unlock_irq(&rme9652->
lock);
2040 if ((err = rme9652_set_rate(rme9652,
params_rate(params))) < 0) {
2045 if ((err = rme9652_set_interrupt_interval(rme9652,
params_period_size(params))) < 0) {
2073 unsigned int cmd,
void *
arg)
2078 return snd_rme9652_reset(substream);
2083 return snd_rme9652_channel_info(substream, info);
2092 static void rme9652_silence_playback(
struct snd_rme9652 *rme9652)
2103 spin_lock(&rme9652->
lock);
2107 running |= 1 << substream->
stream;
2110 running &= ~(1 << substream->
stream);
2114 spin_unlock(&rme9652->
lock);
2126 snd_pcm_trigger_done(s, substream);
2128 running |= 1 << s->
stream;
2130 running &= ~(1 << s->
stream);
2137 rme9652_silence_playback(rme9652);
2141 rme9652_silence_playback(rme9652);
2145 rme9652_silence_playback(rme9652);
2148 snd_pcm_trigger_done(substream, substream);
2149 if (!rme9652->
running && running)
2150 rme9652_start(rme9652);
2151 else if (rme9652->
running && !running)
2152 rme9652_stop(rme9652);
2154 spin_unlock(&rme9652->
lock);
2162 unsigned long flags;
2167 rme9652_reset_hw_pointer(rme9652);
2168 spin_unlock_irqrestore(&rme9652->
lock, flags);
2189 .period_bytes_min = (64 * 4) * 10,
2212 .period_bytes_min = (64 * 4) * 10,
2219 static unsigned int period_sizes[] = { 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
2223 .list = period_sizes,
2242 if (r->
min > 48000) {
2249 }
else if (r->
max < 88200) {
2289 spin_lock_irq(&rme9652->
lock);
2293 runtime->
hw = snd_rme9652_playback_subinfo;
2298 rme9652_stop(rme9652);
2299 rme9652_set_thru(rme9652, -1, 0);
2305 spin_unlock_irq(&rme9652->
lock);
2310 snd_rme9652_hw_rule_channels, rme9652,
2313 snd_rme9652_hw_rule_channels_rate, rme9652,
2316 snd_rme9652_hw_rule_rate_channels, rme9652,
2330 spin_lock_irq(&rme9652->
lock);
2335 spin_unlock_irq(&rme9652->
lock);
2349 spin_lock_irq(&rme9652->
lock);
2353 runtime->
hw = snd_rme9652_capture_subinfo;
2358 rme9652_stop(rme9652);
2359 rme9652_set_thru(rme9652, -1, 0);
2365 spin_unlock_irq(&rme9652->
lock);
2370 snd_rme9652_hw_rule_channels, rme9652,
2373 snd_rme9652_hw_rule_channels_rate, rme9652,
2376 snd_rme9652_hw_rule_rate_channels, rme9652,
2385 spin_lock_irq(&rme9652->
lock);
2390 spin_unlock_irq(&rme9652->
lock);
2394 static struct snd_pcm_ops snd_rme9652_playback_ops = {
2395 .open = snd_rme9652_playback_open,
2396 .close = snd_rme9652_playback_release,
2397 .ioctl = snd_rme9652_ioctl,
2398 .hw_params = snd_rme9652_hw_params,
2399 .prepare = snd_rme9652_prepare,
2400 .trigger = snd_rme9652_trigger,
2401 .pointer = snd_rme9652_hw_pointer,
2402 .copy = snd_rme9652_playback_copy,
2403 .silence = snd_rme9652_hw_silence,
2406 static struct snd_pcm_ops snd_rme9652_capture_ops = {
2407 .open = snd_rme9652_capture_open,
2408 .close = snd_rme9652_capture_release,
2409 .ioctl = snd_rme9652_ioctl,
2410 .hw_params = snd_rme9652_hw_params,
2411 .prepare = snd_rme9652_prepare,
2412 .trigger = snd_rme9652_trigger,
2413 .pointer = snd_rme9652_hw_pointer,
2414 .copy = snd_rme9652_capture_copy,
2425 0, 1, 1, &pcm)) < 0) {
2455 switch (rev & 0xff) {
2482 KBUILD_MODNAME, rme9652)) {
2511 if (rme9652->
hw_rev == 15) {
2512 rme9652->
card_name =
"RME Digi9636 (Rev 1.5)";
2520 rme9652->
card_name =
"RME Digi9636 (Rev G)";
2525 rme9652->
card_name =
"RME Digi9652 (Rev G)";
2530 if (rme9652->
hw_rev == 15) {
2531 rme9652->
card_name =
"RME Digi9652 (Rev 1.5)";
2543 if ((err = snd_rme9652_initialize_memory(rme9652)) < 0) {
2547 if ((err = snd_rme9652_create_pcm(card, rme9652)) < 0) {
2551 if ((err = snd_rme9652_create_controls(card, rme9652)) < 0) {
2555 snd_rme9652_proc_init(rme9652);
2564 snd_rme9652_set_defaults(rme9652);
2566 if (rme9652->
hw_rev == 15) {
2567 rme9652_initialize_spdif_receiver (rme9652);
2573 static void snd_rme9652_card_free(
struct snd_card *card)
2578 snd_rme9652_free(rme9652);
2608 if ((err = snd_rme9652_create(card, rme9652, precise_ptr[dev])) < 0) {
2623 pci_set_drvdata(pci, card);
2631 pci_set_drvdata(pci,
NULL);
2635 .name = KBUILD_MODNAME,
2636 .id_table = snd_rme9652_ids,
2637 .probe = snd_rme9652_probe,