1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ALSA driver for RME Digi32, Digi32/8 and Digi32 PRO audio interfaces
5 * Copyright (c) 2002-2004 Martin Langer <martin-langer@gmx.de>,
6 * Pilo Chambert <pilo.c@wanadoo.fr>
8 * Thanks to : Anders Torger <torger@ludd.luth.se>,
9 * Henk Hesselink <henk@anda.nl>
10 * for writing the digi96-driver
11 * and RME for all informations.
13 * ****************************************************************************
15 * Note #1 "Sek'd models" ................................... martin 2002-12-07
17 * Identical soundcards by Sek'd were labeled:
18 * RME Digi 32 = Sek'd Prodif 32
19 * RME Digi 32 Pro = Sek'd Prodif 96
20 * RME Digi 32/8 = Sek'd Prodif Gold
22 * ****************************************************************************
24 * Note #2 "full duplex mode" ............................... martin 2002-12-07
26 * Full duplex doesn't work. All cards (32, 32/8, 32Pro) are working identical
27 * in this mode. Rec data and play data are using the same buffer therefore. At
28 * first you have got the playing bits in the buffer and then (after playing
29 * them) they were overwitten by the captured sound of the CS8412/14. Both
30 * modes (play/record) are running harmonically hand in hand in the same buffer
31 * and you have only one start bit plus one interrupt bit to control this
33 * This is opposite to the latter rme96 where playing and capturing is totally
34 * separated and so their full duplex mode is supported by alsa (using two
35 * start bits and two interrupts for two different buffers).
36 * But due to the wrong sequence of playing and capturing ALSA shows no solved
37 * full duplex support for the rme32 at the moment. That's bad, but I'm not
38 * able to solve it. Are you motivated enough to solve this problem now? Your
39 * patch would be welcome!
41 * ****************************************************************************
43 * "The story after the long seeking" -- tiwai
45 * Ok, the situation regarding the full duplex is now improved a bit.
46 * In the fullduplex mode (given by the module parameter), the hardware buffer
47 * is split to halves for read and write directions at the DMA pointer.
48 * That is, the half above the current DMA pointer is used for write, and
49 * the half below is used for read. To mangle this strange behavior, an
50 * software intermediate buffer is introduced. This is, of course, not good
51 * from the viewpoint of the data transfer efficiency. However, this allows
52 * you to use arbitrary buffer sizes, instead of the fixed I/O buffer size.
54 * ****************************************************************************
58 #include <linux/delay.h>
59 #include <linux/gfp.h>
60 #include <linux/init.h>
61 #include <linux/interrupt.h>
62 #include <linux/pci.h>
63 #include <linux/module.h>
66 #include <sound/core.h>
67 #include <sound/info.h>
68 #include <sound/control.h>
69 #include <sound/pcm.h>
70 #include <sound/pcm_params.h>
71 #include <sound/pcm-indirect.h>
72 #include <sound/asoundef.h>
73 #include <sound/initval.h>
75 static int index
[SNDRV_CARDS
] = SNDRV_DEFAULT_IDX
; /* Index 0-MAX */
76 static char *id
[SNDRV_CARDS
] = SNDRV_DEFAULT_STR
; /* ID for this card */
77 static bool enable
[SNDRV_CARDS
] = SNDRV_DEFAULT_ENABLE_PNP
; /* Enable this card */
78 static bool fullduplex
[SNDRV_CARDS
]; // = {[0 ... (SNDRV_CARDS - 1)] = 1};
80 module_param_array(index
, int, NULL
, 0444);
81 MODULE_PARM_DESC(index
, "Index value for RME Digi32 soundcard.");
82 module_param_array(id
, charp
, NULL
, 0444);
83 MODULE_PARM_DESC(id
, "ID string for RME Digi32 soundcard.");
84 module_param_array(enable
, bool, NULL
, 0444);
85 MODULE_PARM_DESC(enable
, "Enable RME Digi32 soundcard.");
86 module_param_array(fullduplex
, bool, NULL
, 0444);
87 MODULE_PARM_DESC(fullduplex
, "Support full-duplex mode.");
88 MODULE_AUTHOR("Martin Langer <martin-langer@gmx.de>, Pilo Chambert <pilo.c@wanadoo.fr>");
89 MODULE_DESCRIPTION("RME Digi32, Digi32/8, Digi32 PRO");
90 MODULE_LICENSE("GPL");
91 MODULE_SUPPORTED_DEVICE("{{RME,Digi32}," "{RME,Digi32/8}," "{RME,Digi32 PRO}}");
93 /* Defines for RME Digi32 series */
94 #define RME32_SPDIF_NCHANNELS 2
96 /* Playback and capture buffer size */
97 #define RME32_BUFFER_SIZE 0x20000
100 #define RME32_IO_SIZE 0x30000
102 /* IO area offsets */
103 #define RME32_IO_DATA_BUFFER 0x0
104 #define RME32_IO_CONTROL_REGISTER 0x20000
105 #define RME32_IO_GET_POS 0x20000
106 #define RME32_IO_CONFIRM_ACTION_IRQ 0x20004
107 #define RME32_IO_RESET_POS 0x20100
109 /* Write control register bits */
110 #define RME32_WCR_START (1 << 0) /* startbit */
111 #define RME32_WCR_MONO (1 << 1) /* 0=stereo, 1=mono
112 Setting the whole card to mono
113 doesn't seem to be very useful.
114 A software-solution can handle
115 full-duplex with one direction in
116 stereo and the other way in mono.
117 So, the hardware should work all
118 the time in stereo! */
119 #define RME32_WCR_MODE24 (1 << 2) /* 0=16bit, 1=32bit */
120 #define RME32_WCR_SEL (1 << 3) /* 0=input on output, 1=normal playback/capture */
121 #define RME32_WCR_FREQ_0 (1 << 4) /* frequency (play) */
122 #define RME32_WCR_FREQ_1 (1 << 5)
123 #define RME32_WCR_INP_0 (1 << 6) /* input switch */
124 #define RME32_WCR_INP_1 (1 << 7)
125 #define RME32_WCR_RESET (1 << 8) /* Reset address */
126 #define RME32_WCR_MUTE (1 << 9) /* digital mute for output */
127 #define RME32_WCR_PRO (1 << 10) /* 1=professional, 0=consumer */
128 #define RME32_WCR_DS_BM (1 << 11) /* 1=DoubleSpeed (only PRO-Version); 1=BlockMode (only Adat-Version) */
129 #define RME32_WCR_ADAT (1 << 12) /* Adat Mode (only Adat-Version) */
130 #define RME32_WCR_AUTOSYNC (1 << 13) /* AutoSync */
131 #define RME32_WCR_PD (1 << 14) /* DAC Reset (only PRO-Version) */
132 #define RME32_WCR_EMP (1 << 15) /* 1=Emphasis on (only PRO-Version) */
134 #define RME32_WCR_BITPOS_FREQ_0 4
135 #define RME32_WCR_BITPOS_FREQ_1 5
136 #define RME32_WCR_BITPOS_INP_0 6
137 #define RME32_WCR_BITPOS_INP_1 7
139 /* Read control register bits */
140 #define RME32_RCR_AUDIO_ADDR_MASK 0x1ffff
141 #define RME32_RCR_LOCK (1 << 23) /* 1=locked, 0=not locked */
142 #define RME32_RCR_ERF (1 << 26) /* 1=Error, 0=no Error */
143 #define RME32_RCR_FREQ_0 (1 << 27) /* CS841x frequency (record) */
144 #define RME32_RCR_FREQ_1 (1 << 28)
145 #define RME32_RCR_FREQ_2 (1 << 29)
146 #define RME32_RCR_KMODE (1 << 30) /* card mode: 1=PLL, 0=quartz */
147 #define RME32_RCR_IRQ (1 << 31) /* interrupt */
149 #define RME32_RCR_BITPOS_F0 27
150 #define RME32_RCR_BITPOS_F1 28
151 #define RME32_RCR_BITPOS_F2 29
154 #define RME32_INPUT_OPTICAL 0
155 #define RME32_INPUT_COAXIAL 1
156 #define RME32_INPUT_INTERNAL 2
157 #define RME32_INPUT_XLR 3
160 #define RME32_CLOCKMODE_SLAVE 0
161 #define RME32_CLOCKMODE_MASTER_32 1
162 #define RME32_CLOCKMODE_MASTER_44 2
163 #define RME32_CLOCKMODE_MASTER_48 3
165 /* Block sizes in bytes */
166 #define RME32_BLOCK_SIZE 8192
168 /* Software intermediate buffer (max) size */
169 #define RME32_MID_BUFFER_SIZE (1024*1024)
171 /* Hardware revisions */
172 #define RME32_32_REVISION 192
173 #define RME32_328_REVISION_OLD 100
174 #define RME32_328_REVISION_NEW 101
175 #define RME32_PRO_REVISION_WITH_8412 192
176 #define RME32_PRO_REVISION_WITH_8414 150
183 void __iomem
*iobase
;
185 u32 wcreg
; /* cached write control register value */
186 u32 wcreg_spdif
; /* S/PDIF setup */
187 u32 wcreg_spdif_stream
; /* S/PDIF setup (temporary) */
188 u32 rcreg
; /* cached read control register value */
190 u8 rev
; /* card revision number */
192 struct snd_pcm_substream
*playback_substream
;
193 struct snd_pcm_substream
*capture_substream
;
195 int playback_frlog
; /* log2 of framesize */
198 size_t playback_periodsize
; /* in bytes, zero if not used */
199 size_t capture_periodsize
; /* in bytes, zero if not used */
201 unsigned int fullduplex_mode
;
204 struct snd_pcm_indirect playback_pcm
;
205 struct snd_pcm_indirect capture_pcm
;
207 struct snd_card
*card
;
208 struct snd_pcm
*spdif_pcm
;
209 struct snd_pcm
*adat_pcm
;
211 struct snd_kcontrol
*spdif_ctl
;
214 static const struct pci_device_id snd_rme32_ids
[] = {
215 {PCI_VDEVICE(XILINX_RME
, PCI_DEVICE_ID_RME_DIGI32
), 0,},
216 {PCI_VDEVICE(XILINX_RME
, PCI_DEVICE_ID_RME_DIGI32_8
), 0,},
217 {PCI_VDEVICE(XILINX_RME
, PCI_DEVICE_ID_RME_DIGI32_PRO
), 0,},
221 MODULE_DEVICE_TABLE(pci
, snd_rme32_ids
);
223 #define RME32_ISWORKING(rme32) ((rme32)->wcreg & RME32_WCR_START)
224 #define RME32_PRO_WITH_8414(rme32) ((rme32)->pci->device == PCI_DEVICE_ID_RME_DIGI32_PRO && (rme32)->rev == RME32_PRO_REVISION_WITH_8414)
226 static int snd_rme32_playback_prepare(struct snd_pcm_substream
*substream
);
228 static int snd_rme32_capture_prepare(struct snd_pcm_substream
*substream
);
230 static int snd_rme32_pcm_trigger(struct snd_pcm_substream
*substream
, int cmd
);
232 static void snd_rme32_proc_init(struct rme32
* rme32
);
234 static int snd_rme32_create_switches(struct snd_card
*card
, struct rme32
* rme32
);
236 static inline unsigned int snd_rme32_pcm_byteptr(struct rme32
* rme32
)
238 return (readl(rme32
->iobase
+ RME32_IO_GET_POS
)
239 & RME32_RCR_AUDIO_ADDR_MASK
);
242 /* silence callback for halfduplex mode */
243 static int snd_rme32_playback_silence(struct snd_pcm_substream
*substream
,
244 int channel
, unsigned long pos
,
247 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
249 memset_io(rme32
->iobase
+ RME32_IO_DATA_BUFFER
+ pos
, 0, count
);
253 /* copy callback for halfduplex mode */
254 static int snd_rme32_playback_copy(struct snd_pcm_substream
*substream
,
255 int channel
, unsigned long pos
,
256 void __user
*src
, unsigned long count
)
258 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
260 if (copy_from_user_toio(rme32
->iobase
+ RME32_IO_DATA_BUFFER
+ pos
,
266 static int snd_rme32_playback_copy_kernel(struct snd_pcm_substream
*substream
,
267 int channel
, unsigned long pos
,
268 void *src
, unsigned long count
)
270 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
272 memcpy_toio(rme32
->iobase
+ RME32_IO_DATA_BUFFER
+ pos
, src
, count
);
276 /* copy callback for halfduplex mode */
277 static int snd_rme32_capture_copy(struct snd_pcm_substream
*substream
,
278 int channel
, unsigned long pos
,
279 void __user
*dst
, unsigned long count
)
281 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
283 if (copy_to_user_fromio(dst
,
284 rme32
->iobase
+ RME32_IO_DATA_BUFFER
+ pos
,
290 static int snd_rme32_capture_copy_kernel(struct snd_pcm_substream
*substream
,
291 int channel
, unsigned long pos
,
292 void *dst
, unsigned long count
)
294 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
296 memcpy_fromio(dst
, rme32
->iobase
+ RME32_IO_DATA_BUFFER
+ pos
, count
);
301 * SPDIF I/O capabilities (half-duplex mode)
303 static const struct snd_pcm_hardware snd_rme32_spdif_info
= {
304 .info
= (SNDRV_PCM_INFO_MMAP_IOMEM
|
305 SNDRV_PCM_INFO_MMAP_VALID
|
306 SNDRV_PCM_INFO_INTERLEAVED
|
307 SNDRV_PCM_INFO_PAUSE
|
308 SNDRV_PCM_INFO_SYNC_START
|
309 SNDRV_PCM_INFO_SYNC_APPLPTR
),
310 .formats
= (SNDRV_PCM_FMTBIT_S16_LE
|
311 SNDRV_PCM_FMTBIT_S32_LE
),
312 .rates
= (SNDRV_PCM_RATE_32000
|
313 SNDRV_PCM_RATE_44100
|
314 SNDRV_PCM_RATE_48000
),
319 .buffer_bytes_max
= RME32_BUFFER_SIZE
,
320 .period_bytes_min
= RME32_BLOCK_SIZE
,
321 .period_bytes_max
= RME32_BLOCK_SIZE
,
322 .periods_min
= RME32_BUFFER_SIZE
/ RME32_BLOCK_SIZE
,
323 .periods_max
= RME32_BUFFER_SIZE
/ RME32_BLOCK_SIZE
,
328 * ADAT I/O capabilities (half-duplex mode)
330 static const struct snd_pcm_hardware snd_rme32_adat_info
=
332 .info
= (SNDRV_PCM_INFO_MMAP_IOMEM
|
333 SNDRV_PCM_INFO_MMAP_VALID
|
334 SNDRV_PCM_INFO_INTERLEAVED
|
335 SNDRV_PCM_INFO_PAUSE
|
336 SNDRV_PCM_INFO_SYNC_START
|
337 SNDRV_PCM_INFO_SYNC_APPLPTR
),
338 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
339 .rates
= (SNDRV_PCM_RATE_44100
|
340 SNDRV_PCM_RATE_48000
),
345 .buffer_bytes_max
= RME32_BUFFER_SIZE
,
346 .period_bytes_min
= RME32_BLOCK_SIZE
,
347 .period_bytes_max
= RME32_BLOCK_SIZE
,
348 .periods_min
= RME32_BUFFER_SIZE
/ RME32_BLOCK_SIZE
,
349 .periods_max
= RME32_BUFFER_SIZE
/ RME32_BLOCK_SIZE
,
354 * SPDIF I/O capabilities (full-duplex mode)
356 static const struct snd_pcm_hardware snd_rme32_spdif_fd_info
= {
357 .info
= (SNDRV_PCM_INFO_MMAP
|
358 SNDRV_PCM_INFO_MMAP_VALID
|
359 SNDRV_PCM_INFO_INTERLEAVED
|
360 SNDRV_PCM_INFO_PAUSE
|
361 SNDRV_PCM_INFO_SYNC_START
|
362 SNDRV_PCM_INFO_SYNC_APPLPTR
),
363 .formats
= (SNDRV_PCM_FMTBIT_S16_LE
|
364 SNDRV_PCM_FMTBIT_S32_LE
),
365 .rates
= (SNDRV_PCM_RATE_32000
|
366 SNDRV_PCM_RATE_44100
|
367 SNDRV_PCM_RATE_48000
),
372 .buffer_bytes_max
= RME32_MID_BUFFER_SIZE
,
373 .period_bytes_min
= RME32_BLOCK_SIZE
,
374 .period_bytes_max
= RME32_BLOCK_SIZE
,
376 .periods_max
= RME32_MID_BUFFER_SIZE
/ RME32_BLOCK_SIZE
,
381 * ADAT I/O capabilities (full-duplex mode)
383 static const struct snd_pcm_hardware snd_rme32_adat_fd_info
=
385 .info
= (SNDRV_PCM_INFO_MMAP
|
386 SNDRV_PCM_INFO_MMAP_VALID
|
387 SNDRV_PCM_INFO_INTERLEAVED
|
388 SNDRV_PCM_INFO_PAUSE
|
389 SNDRV_PCM_INFO_SYNC_START
|
390 SNDRV_PCM_INFO_SYNC_APPLPTR
),
391 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
392 .rates
= (SNDRV_PCM_RATE_44100
|
393 SNDRV_PCM_RATE_48000
),
398 .buffer_bytes_max
= RME32_MID_BUFFER_SIZE
,
399 .period_bytes_min
= RME32_BLOCK_SIZE
,
400 .period_bytes_max
= RME32_BLOCK_SIZE
,
402 .periods_max
= RME32_MID_BUFFER_SIZE
/ RME32_BLOCK_SIZE
,
406 static void snd_rme32_reset_dac(struct rme32
*rme32
)
408 writel(rme32
->wcreg
| RME32_WCR_PD
,
409 rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
410 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
413 static int snd_rme32_playback_getrate(struct rme32
* rme32
)
417 rate
= ((rme32
->wcreg
>> RME32_WCR_BITPOS_FREQ_0
) & 1) +
418 (((rme32
->wcreg
>> RME32_WCR_BITPOS_FREQ_1
) & 1) << 1);
432 return (rme32
->wcreg
& RME32_WCR_DS_BM
) ? rate
<< 1 : rate
;
435 static int snd_rme32_capture_getrate(struct rme32
* rme32
, int *is_adat
)
440 if (rme32
->rcreg
& RME32_RCR_LOCK
) {
444 if (rme32
->rcreg
& RME32_RCR_ERF
) {
449 n
= ((rme32
->rcreg
>> RME32_RCR_BITPOS_F0
) & 1) +
450 (((rme32
->rcreg
>> RME32_RCR_BITPOS_F1
) & 1) << 1) +
451 (((rme32
->rcreg
>> RME32_RCR_BITPOS_F2
) & 1) << 2);
453 if (RME32_PRO_WITH_8414(rme32
))
454 switch (n
) { /* supporting the CS8414 */
473 switch (n
) { /* supporting the CS8412 */
496 static int snd_rme32_playback_setrate(struct rme32
* rme32
, int rate
)
500 ds
= rme32
->wcreg
& RME32_WCR_DS_BM
;
503 rme32
->wcreg
&= ~RME32_WCR_DS_BM
;
504 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_0
) &
508 rme32
->wcreg
&= ~RME32_WCR_DS_BM
;
509 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_1
) &
513 rme32
->wcreg
&= ~RME32_WCR_DS_BM
;
514 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_0
) |
518 if (rme32
->pci
->device
!= PCI_DEVICE_ID_RME_DIGI32_PRO
)
520 rme32
->wcreg
|= RME32_WCR_DS_BM
;
521 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_0
) &
525 if (rme32
->pci
->device
!= PCI_DEVICE_ID_RME_DIGI32_PRO
)
527 rme32
->wcreg
|= RME32_WCR_DS_BM
;
528 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_1
) &
532 if (rme32
->pci
->device
!= PCI_DEVICE_ID_RME_DIGI32_PRO
)
534 rme32
->wcreg
|= RME32_WCR_DS_BM
;
535 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_0
) |
541 if ((!ds
&& rme32
->wcreg
& RME32_WCR_DS_BM
) ||
542 (ds
&& !(rme32
->wcreg
& RME32_WCR_DS_BM
)))
544 /* change to/from double-speed: reset the DAC (if available) */
545 snd_rme32_reset_dac(rme32
);
547 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
552 static int snd_rme32_setclockmode(struct rme32
* rme32
, int mode
)
555 case RME32_CLOCKMODE_SLAVE
:
557 rme32
->wcreg
= (rme32
->wcreg
& ~RME32_WCR_FREQ_0
) &
560 case RME32_CLOCKMODE_MASTER_32
:
561 /* Internal 32.0kHz */
562 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_0
) &
565 case RME32_CLOCKMODE_MASTER_44
:
566 /* Internal 44.1kHz */
567 rme32
->wcreg
= (rme32
->wcreg
& ~RME32_WCR_FREQ_0
) |
570 case RME32_CLOCKMODE_MASTER_48
:
571 /* Internal 48.0kHz */
572 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_FREQ_0
) |
578 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
582 static int snd_rme32_getclockmode(struct rme32
* rme32
)
584 return ((rme32
->wcreg
>> RME32_WCR_BITPOS_FREQ_0
) & 1) +
585 (((rme32
->wcreg
>> RME32_WCR_BITPOS_FREQ_1
) & 1) << 1);
588 static int snd_rme32_setinputtype(struct rme32
* rme32
, int type
)
591 case RME32_INPUT_OPTICAL
:
592 rme32
->wcreg
= (rme32
->wcreg
& ~RME32_WCR_INP_0
) &
595 case RME32_INPUT_COAXIAL
:
596 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_INP_0
) &
599 case RME32_INPUT_INTERNAL
:
600 rme32
->wcreg
= (rme32
->wcreg
& ~RME32_WCR_INP_0
) |
603 case RME32_INPUT_XLR
:
604 rme32
->wcreg
= (rme32
->wcreg
| RME32_WCR_INP_0
) |
610 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
614 static int snd_rme32_getinputtype(struct rme32
* rme32
)
616 return ((rme32
->wcreg
>> RME32_WCR_BITPOS_INP_0
) & 1) +
617 (((rme32
->wcreg
>> RME32_WCR_BITPOS_INP_1
) & 1) << 1);
621 snd_rme32_setframelog(struct rme32
* rme32
, int n_channels
, int is_playback
)
625 if (n_channels
== 2) {
628 /* assume 8 channels */
632 frlog
+= (rme32
->wcreg
& RME32_WCR_MODE24
) ? 2 : 1;
633 rme32
->playback_frlog
= frlog
;
635 frlog
+= (rme32
->wcreg
& RME32_WCR_MODE24
) ? 2 : 1;
636 rme32
->capture_frlog
= frlog
;
640 static int snd_rme32_setformat(struct rme32
*rme32
, snd_pcm_format_t format
)
643 case SNDRV_PCM_FORMAT_S16_LE
:
644 rme32
->wcreg
&= ~RME32_WCR_MODE24
;
646 case SNDRV_PCM_FORMAT_S32_LE
:
647 rme32
->wcreg
|= RME32_WCR_MODE24
;
652 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
657 snd_rme32_playback_hw_params(struct snd_pcm_substream
*substream
,
658 struct snd_pcm_hw_params
*params
)
660 int err
, rate
, dummy
;
661 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
662 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
664 if (!rme32
->fullduplex_mode
) {
665 runtime
->dma_area
= (void __force
*)(rme32
->iobase
+
666 RME32_IO_DATA_BUFFER
);
667 runtime
->dma_addr
= rme32
->port
+ RME32_IO_DATA_BUFFER
;
668 runtime
->dma_bytes
= RME32_BUFFER_SIZE
;
671 spin_lock_irq(&rme32
->lock
);
672 if ((rme32
->rcreg
& RME32_RCR_KMODE
) &&
673 (rate
= snd_rme32_capture_getrate(rme32
, &dummy
)) > 0) {
675 if ((int)params_rate(params
) != rate
) {
676 spin_unlock_irq(&rme32
->lock
);
679 } else if ((err
= snd_rme32_playback_setrate(rme32
, params_rate(params
))) < 0) {
680 spin_unlock_irq(&rme32
->lock
);
683 if ((err
= snd_rme32_setformat(rme32
, params_format(params
))) < 0) {
684 spin_unlock_irq(&rme32
->lock
);
688 snd_rme32_setframelog(rme32
, params_channels(params
), 1);
689 if (rme32
->capture_periodsize
!= 0) {
690 if (params_period_size(params
) << rme32
->playback_frlog
!= rme32
->capture_periodsize
) {
691 spin_unlock_irq(&rme32
->lock
);
695 rme32
->playback_periodsize
= params_period_size(params
) << rme32
->playback_frlog
;
697 if ((rme32
->wcreg
& RME32_WCR_ADAT
) == 0) {
698 rme32
->wcreg
&= ~(RME32_WCR_PRO
| RME32_WCR_EMP
);
699 rme32
->wcreg
|= rme32
->wcreg_spdif_stream
;
700 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
702 spin_unlock_irq(&rme32
->lock
);
708 snd_rme32_capture_hw_params(struct snd_pcm_substream
*substream
,
709 struct snd_pcm_hw_params
*params
)
711 int err
, isadat
, rate
;
712 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
713 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
715 if (!rme32
->fullduplex_mode
) {
716 runtime
->dma_area
= (void __force
*)rme32
->iobase
+
717 RME32_IO_DATA_BUFFER
;
718 runtime
->dma_addr
= rme32
->port
+ RME32_IO_DATA_BUFFER
;
719 runtime
->dma_bytes
= RME32_BUFFER_SIZE
;
722 spin_lock_irq(&rme32
->lock
);
723 /* enable AutoSync for record-preparing */
724 rme32
->wcreg
|= RME32_WCR_AUTOSYNC
;
725 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
727 if ((err
= snd_rme32_setformat(rme32
, params_format(params
))) < 0) {
728 spin_unlock_irq(&rme32
->lock
);
731 if ((err
= snd_rme32_playback_setrate(rme32
, params_rate(params
))) < 0) {
732 spin_unlock_irq(&rme32
->lock
);
735 if ((rate
= snd_rme32_capture_getrate(rme32
, &isadat
)) > 0) {
736 if ((int)params_rate(params
) != rate
) {
737 spin_unlock_irq(&rme32
->lock
);
740 if ((isadat
&& runtime
->hw
.channels_min
== 2) ||
741 (!isadat
&& runtime
->hw
.channels_min
== 8)) {
742 spin_unlock_irq(&rme32
->lock
);
746 /* AutoSync off for recording */
747 rme32
->wcreg
&= ~RME32_WCR_AUTOSYNC
;
748 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
750 snd_rme32_setframelog(rme32
, params_channels(params
), 0);
751 if (rme32
->playback_periodsize
!= 0) {
752 if (params_period_size(params
) << rme32
->capture_frlog
!=
753 rme32
->playback_periodsize
) {
754 spin_unlock_irq(&rme32
->lock
);
758 rme32
->capture_periodsize
=
759 params_period_size(params
) << rme32
->capture_frlog
;
760 spin_unlock_irq(&rme32
->lock
);
765 static void snd_rme32_pcm_start(struct rme32
* rme32
, int from_pause
)
768 writel(0, rme32
->iobase
+ RME32_IO_RESET_POS
);
771 rme32
->wcreg
|= RME32_WCR_START
;
772 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
775 static void snd_rme32_pcm_stop(struct rme32
* rme32
, int to_pause
)
778 * Check if there is an unconfirmed IRQ, if so confirm it, or else
779 * the hardware will not stop generating interrupts
781 rme32
->rcreg
= readl(rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
782 if (rme32
->rcreg
& RME32_RCR_IRQ
) {
783 writel(0, rme32
->iobase
+ RME32_IO_CONFIRM_ACTION_IRQ
);
785 rme32
->wcreg
&= ~RME32_WCR_START
;
786 if (rme32
->wcreg
& RME32_WCR_SEL
)
787 rme32
->wcreg
|= RME32_WCR_MUTE
;
788 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
790 writel(0, rme32
->iobase
+ RME32_IO_RESET_POS
);
793 static irqreturn_t
snd_rme32_interrupt(int irq
, void *dev_id
)
795 struct rme32
*rme32
= (struct rme32
*) dev_id
;
797 rme32
->rcreg
= readl(rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
798 if (!(rme32
->rcreg
& RME32_RCR_IRQ
)) {
801 if (rme32
->capture_substream
) {
802 snd_pcm_period_elapsed(rme32
->capture_substream
);
804 if (rme32
->playback_substream
) {
805 snd_pcm_period_elapsed(rme32
->playback_substream
);
807 writel(0, rme32
->iobase
+ RME32_IO_CONFIRM_ACTION_IRQ
);
812 static const unsigned int period_bytes
[] = { RME32_BLOCK_SIZE
};
814 static const struct snd_pcm_hw_constraint_list hw_constraints_period_bytes
= {
815 .count
= ARRAY_SIZE(period_bytes
),
816 .list
= period_bytes
,
820 static void snd_rme32_set_buffer_constraint(struct rme32
*rme32
, struct snd_pcm_runtime
*runtime
)
822 if (! rme32
->fullduplex_mode
) {
823 snd_pcm_hw_constraint_single(runtime
,
824 SNDRV_PCM_HW_PARAM_BUFFER_BYTES
,
826 snd_pcm_hw_constraint_list(runtime
, 0,
827 SNDRV_PCM_HW_PARAM_PERIOD_BYTES
,
828 &hw_constraints_period_bytes
);
832 static int snd_rme32_playback_spdif_open(struct snd_pcm_substream
*substream
)
835 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
836 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
838 snd_pcm_set_sync(substream
);
840 spin_lock_irq(&rme32
->lock
);
841 if (rme32
->playback_substream
!= NULL
) {
842 spin_unlock_irq(&rme32
->lock
);
845 rme32
->wcreg
&= ~RME32_WCR_ADAT
;
846 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
847 rme32
->playback_substream
= substream
;
848 spin_unlock_irq(&rme32
->lock
);
850 if (rme32
->fullduplex_mode
)
851 runtime
->hw
= snd_rme32_spdif_fd_info
;
853 runtime
->hw
= snd_rme32_spdif_info
;
854 if (rme32
->pci
->device
== PCI_DEVICE_ID_RME_DIGI32_PRO
) {
855 runtime
->hw
.rates
|= SNDRV_PCM_RATE_64000
| SNDRV_PCM_RATE_88200
| SNDRV_PCM_RATE_96000
;
856 runtime
->hw
.rate_max
= 96000;
858 if ((rme32
->rcreg
& RME32_RCR_KMODE
) &&
859 (rate
= snd_rme32_capture_getrate(rme32
, &dummy
)) > 0) {
861 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
862 runtime
->hw
.rate_min
= rate
;
863 runtime
->hw
.rate_max
= rate
;
866 snd_rme32_set_buffer_constraint(rme32
, runtime
);
868 rme32
->wcreg_spdif_stream
= rme32
->wcreg_spdif
;
869 rme32
->spdif_ctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
870 snd_ctl_notify(rme32
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
871 SNDRV_CTL_EVENT_MASK_INFO
, &rme32
->spdif_ctl
->id
);
875 static int snd_rme32_capture_spdif_open(struct snd_pcm_substream
*substream
)
878 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
879 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
881 snd_pcm_set_sync(substream
);
883 spin_lock_irq(&rme32
->lock
);
884 if (rme32
->capture_substream
!= NULL
) {
885 spin_unlock_irq(&rme32
->lock
);
888 rme32
->capture_substream
= substream
;
889 spin_unlock_irq(&rme32
->lock
);
891 if (rme32
->fullduplex_mode
)
892 runtime
->hw
= snd_rme32_spdif_fd_info
;
894 runtime
->hw
= snd_rme32_spdif_info
;
895 if (RME32_PRO_WITH_8414(rme32
)) {
896 runtime
->hw
.rates
|= SNDRV_PCM_RATE_88200
| SNDRV_PCM_RATE_96000
;
897 runtime
->hw
.rate_max
= 96000;
899 if ((rate
= snd_rme32_capture_getrate(rme32
, &isadat
)) > 0) {
903 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
904 runtime
->hw
.rate_min
= rate
;
905 runtime
->hw
.rate_max
= rate
;
908 snd_rme32_set_buffer_constraint(rme32
, runtime
);
914 snd_rme32_playback_adat_open(struct snd_pcm_substream
*substream
)
917 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
918 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
920 snd_pcm_set_sync(substream
);
922 spin_lock_irq(&rme32
->lock
);
923 if (rme32
->playback_substream
!= NULL
) {
924 spin_unlock_irq(&rme32
->lock
);
927 rme32
->wcreg
|= RME32_WCR_ADAT
;
928 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
929 rme32
->playback_substream
= substream
;
930 spin_unlock_irq(&rme32
->lock
);
932 if (rme32
->fullduplex_mode
)
933 runtime
->hw
= snd_rme32_adat_fd_info
;
935 runtime
->hw
= snd_rme32_adat_info
;
936 if ((rme32
->rcreg
& RME32_RCR_KMODE
) &&
937 (rate
= snd_rme32_capture_getrate(rme32
, &dummy
)) > 0) {
939 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
940 runtime
->hw
.rate_min
= rate
;
941 runtime
->hw
.rate_max
= rate
;
944 snd_rme32_set_buffer_constraint(rme32
, runtime
);
949 snd_rme32_capture_adat_open(struct snd_pcm_substream
*substream
)
952 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
953 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
955 if (rme32
->fullduplex_mode
)
956 runtime
->hw
= snd_rme32_adat_fd_info
;
958 runtime
->hw
= snd_rme32_adat_info
;
959 if ((rate
= snd_rme32_capture_getrate(rme32
, &isadat
)) > 0) {
963 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
964 runtime
->hw
.rate_min
= rate
;
965 runtime
->hw
.rate_max
= rate
;
968 snd_pcm_set_sync(substream
);
970 spin_lock_irq(&rme32
->lock
);
971 if (rme32
->capture_substream
!= NULL
) {
972 spin_unlock_irq(&rme32
->lock
);
975 rme32
->capture_substream
= substream
;
976 spin_unlock_irq(&rme32
->lock
);
978 snd_rme32_set_buffer_constraint(rme32
, runtime
);
982 static int snd_rme32_playback_close(struct snd_pcm_substream
*substream
)
984 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
987 spin_lock_irq(&rme32
->lock
);
988 rme32
->playback_substream
= NULL
;
989 rme32
->playback_periodsize
= 0;
990 spdif
= (rme32
->wcreg
& RME32_WCR_ADAT
) == 0;
991 spin_unlock_irq(&rme32
->lock
);
993 rme32
->spdif_ctl
->vd
[0].access
|= SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
994 snd_ctl_notify(rme32
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
995 SNDRV_CTL_EVENT_MASK_INFO
,
996 &rme32
->spdif_ctl
->id
);
1001 static int snd_rme32_capture_close(struct snd_pcm_substream
*substream
)
1003 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1005 spin_lock_irq(&rme32
->lock
);
1006 rme32
->capture_substream
= NULL
;
1007 rme32
->capture_periodsize
= 0;
1008 spin_unlock_irq(&rme32
->lock
);
1012 static int snd_rme32_playback_prepare(struct snd_pcm_substream
*substream
)
1014 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1016 spin_lock_irq(&rme32
->lock
);
1017 if (rme32
->fullduplex_mode
) {
1018 memset(&rme32
->playback_pcm
, 0, sizeof(rme32
->playback_pcm
));
1019 rme32
->playback_pcm
.hw_buffer_size
= RME32_BUFFER_SIZE
;
1020 rme32
->playback_pcm
.sw_buffer_size
= snd_pcm_lib_buffer_bytes(substream
);
1022 writel(0, rme32
->iobase
+ RME32_IO_RESET_POS
);
1024 if (rme32
->wcreg
& RME32_WCR_SEL
)
1025 rme32
->wcreg
&= ~RME32_WCR_MUTE
;
1026 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
1027 spin_unlock_irq(&rme32
->lock
);
1031 static int snd_rme32_capture_prepare(struct snd_pcm_substream
*substream
)
1033 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1035 spin_lock_irq(&rme32
->lock
);
1036 if (rme32
->fullduplex_mode
) {
1037 memset(&rme32
->capture_pcm
, 0, sizeof(rme32
->capture_pcm
));
1038 rme32
->capture_pcm
.hw_buffer_size
= RME32_BUFFER_SIZE
;
1039 rme32
->capture_pcm
.hw_queue_size
= RME32_BUFFER_SIZE
/ 2;
1040 rme32
->capture_pcm
.sw_buffer_size
= snd_pcm_lib_buffer_bytes(substream
);
1042 writel(0, rme32
->iobase
+ RME32_IO_RESET_POS
);
1044 spin_unlock_irq(&rme32
->lock
);
1049 snd_rme32_pcm_trigger(struct snd_pcm_substream
*substream
, int cmd
)
1051 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1052 struct snd_pcm_substream
*s
;
1054 spin_lock(&rme32
->lock
);
1055 snd_pcm_group_for_each_entry(s
, substream
) {
1056 if (s
!= rme32
->playback_substream
&&
1057 s
!= rme32
->capture_substream
)
1060 case SNDRV_PCM_TRIGGER_START
:
1061 rme32
->running
|= (1 << s
->stream
);
1062 if (rme32
->fullduplex_mode
) {
1063 /* remember the current DMA position */
1064 if (s
== rme32
->playback_substream
) {
1065 rme32
->playback_pcm
.hw_io
=
1066 rme32
->playback_pcm
.hw_data
= snd_rme32_pcm_byteptr(rme32
);
1068 rme32
->capture_pcm
.hw_io
=
1069 rme32
->capture_pcm
.hw_data
= snd_rme32_pcm_byteptr(rme32
);
1073 case SNDRV_PCM_TRIGGER_STOP
:
1074 rme32
->running
&= ~(1 << s
->stream
);
1077 snd_pcm_trigger_done(s
, substream
);
1081 case SNDRV_PCM_TRIGGER_START
:
1082 if (rme32
->running
&& ! RME32_ISWORKING(rme32
))
1083 snd_rme32_pcm_start(rme32
, 0);
1085 case SNDRV_PCM_TRIGGER_STOP
:
1086 if (! rme32
->running
&& RME32_ISWORKING(rme32
))
1087 snd_rme32_pcm_stop(rme32
, 0);
1089 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
1090 if (rme32
->running
&& RME32_ISWORKING(rme32
))
1091 snd_rme32_pcm_stop(rme32
, 1);
1093 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
1094 if (rme32
->running
&& ! RME32_ISWORKING(rme32
))
1095 snd_rme32_pcm_start(rme32
, 1);
1098 spin_unlock(&rme32
->lock
);
1102 /* pointer callback for halfduplex mode */
1103 static snd_pcm_uframes_t
1104 snd_rme32_playback_pointer(struct snd_pcm_substream
*substream
)
1106 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1107 return snd_rme32_pcm_byteptr(rme32
) >> rme32
->playback_frlog
;
1110 static snd_pcm_uframes_t
1111 snd_rme32_capture_pointer(struct snd_pcm_substream
*substream
)
1113 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1114 return snd_rme32_pcm_byteptr(rme32
) >> rme32
->capture_frlog
;
1118 /* ack and pointer callbacks for fullduplex mode */
1119 static void snd_rme32_pb_trans_copy(struct snd_pcm_substream
*substream
,
1120 struct snd_pcm_indirect
*rec
, size_t bytes
)
1122 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1123 memcpy_toio(rme32
->iobase
+ RME32_IO_DATA_BUFFER
+ rec
->hw_data
,
1124 substream
->runtime
->dma_area
+ rec
->sw_data
, bytes
);
1127 static int snd_rme32_playback_fd_ack(struct snd_pcm_substream
*substream
)
1129 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1130 struct snd_pcm_indirect
*rec
, *cprec
;
1132 rec
= &rme32
->playback_pcm
;
1133 cprec
= &rme32
->capture_pcm
;
1134 spin_lock(&rme32
->lock
);
1135 rec
->hw_queue_size
= RME32_BUFFER_SIZE
;
1136 if (rme32
->running
& (1 << SNDRV_PCM_STREAM_CAPTURE
))
1137 rec
->hw_queue_size
-= cprec
->hw_ready
;
1138 spin_unlock(&rme32
->lock
);
1139 return snd_pcm_indirect_playback_transfer(substream
, rec
,
1140 snd_rme32_pb_trans_copy
);
1143 static void snd_rme32_cp_trans_copy(struct snd_pcm_substream
*substream
,
1144 struct snd_pcm_indirect
*rec
, size_t bytes
)
1146 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1147 memcpy_fromio(substream
->runtime
->dma_area
+ rec
->sw_data
,
1148 rme32
->iobase
+ RME32_IO_DATA_BUFFER
+ rec
->hw_data
,
1152 static int snd_rme32_capture_fd_ack(struct snd_pcm_substream
*substream
)
1154 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1155 return snd_pcm_indirect_capture_transfer(substream
, &rme32
->capture_pcm
,
1156 snd_rme32_cp_trans_copy
);
1159 static snd_pcm_uframes_t
1160 snd_rme32_playback_fd_pointer(struct snd_pcm_substream
*substream
)
1162 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1163 return snd_pcm_indirect_playback_pointer(substream
, &rme32
->playback_pcm
,
1164 snd_rme32_pcm_byteptr(rme32
));
1167 static snd_pcm_uframes_t
1168 snd_rme32_capture_fd_pointer(struct snd_pcm_substream
*substream
)
1170 struct rme32
*rme32
= snd_pcm_substream_chip(substream
);
1171 return snd_pcm_indirect_capture_pointer(substream
, &rme32
->capture_pcm
,
1172 snd_rme32_pcm_byteptr(rme32
));
1175 /* for halfduplex mode */
1176 static const struct snd_pcm_ops snd_rme32_playback_spdif_ops
= {
1177 .open
= snd_rme32_playback_spdif_open
,
1178 .close
= snd_rme32_playback_close
,
1179 .hw_params
= snd_rme32_playback_hw_params
,
1180 .prepare
= snd_rme32_playback_prepare
,
1181 .trigger
= snd_rme32_pcm_trigger
,
1182 .pointer
= snd_rme32_playback_pointer
,
1183 .copy_user
= snd_rme32_playback_copy
,
1184 .copy_kernel
= snd_rme32_playback_copy_kernel
,
1185 .fill_silence
= snd_rme32_playback_silence
,
1186 .mmap
= snd_pcm_lib_mmap_iomem
,
1189 static const struct snd_pcm_ops snd_rme32_capture_spdif_ops
= {
1190 .open
= snd_rme32_capture_spdif_open
,
1191 .close
= snd_rme32_capture_close
,
1192 .hw_params
= snd_rme32_capture_hw_params
,
1193 .prepare
= snd_rme32_capture_prepare
,
1194 .trigger
= snd_rme32_pcm_trigger
,
1195 .pointer
= snd_rme32_capture_pointer
,
1196 .copy_user
= snd_rme32_capture_copy
,
1197 .copy_kernel
= snd_rme32_capture_copy_kernel
,
1198 .mmap
= snd_pcm_lib_mmap_iomem
,
1201 static const struct snd_pcm_ops snd_rme32_playback_adat_ops
= {
1202 .open
= snd_rme32_playback_adat_open
,
1203 .close
= snd_rme32_playback_close
,
1204 .hw_params
= snd_rme32_playback_hw_params
,
1205 .prepare
= snd_rme32_playback_prepare
,
1206 .trigger
= snd_rme32_pcm_trigger
,
1207 .pointer
= snd_rme32_playback_pointer
,
1208 .copy_user
= snd_rme32_playback_copy
,
1209 .copy_kernel
= snd_rme32_playback_copy_kernel
,
1210 .fill_silence
= snd_rme32_playback_silence
,
1211 .mmap
= snd_pcm_lib_mmap_iomem
,
1214 static const struct snd_pcm_ops snd_rme32_capture_adat_ops
= {
1215 .open
= snd_rme32_capture_adat_open
,
1216 .close
= snd_rme32_capture_close
,
1217 .hw_params
= snd_rme32_capture_hw_params
,
1218 .prepare
= snd_rme32_capture_prepare
,
1219 .trigger
= snd_rme32_pcm_trigger
,
1220 .pointer
= snd_rme32_capture_pointer
,
1221 .copy_user
= snd_rme32_capture_copy
,
1222 .copy_kernel
= snd_rme32_capture_copy_kernel
,
1223 .mmap
= snd_pcm_lib_mmap_iomem
,
1226 /* for fullduplex mode */
1227 static const struct snd_pcm_ops snd_rme32_playback_spdif_fd_ops
= {
1228 .open
= snd_rme32_playback_spdif_open
,
1229 .close
= snd_rme32_playback_close
,
1230 .hw_params
= snd_rme32_playback_hw_params
,
1231 .prepare
= snd_rme32_playback_prepare
,
1232 .trigger
= snd_rme32_pcm_trigger
,
1233 .pointer
= snd_rme32_playback_fd_pointer
,
1234 .ack
= snd_rme32_playback_fd_ack
,
1237 static const struct snd_pcm_ops snd_rme32_capture_spdif_fd_ops
= {
1238 .open
= snd_rme32_capture_spdif_open
,
1239 .close
= snd_rme32_capture_close
,
1240 .hw_params
= snd_rme32_capture_hw_params
,
1241 .prepare
= snd_rme32_capture_prepare
,
1242 .trigger
= snd_rme32_pcm_trigger
,
1243 .pointer
= snd_rme32_capture_fd_pointer
,
1244 .ack
= snd_rme32_capture_fd_ack
,
1247 static const struct snd_pcm_ops snd_rme32_playback_adat_fd_ops
= {
1248 .open
= snd_rme32_playback_adat_open
,
1249 .close
= snd_rme32_playback_close
,
1250 .hw_params
= snd_rme32_playback_hw_params
,
1251 .prepare
= snd_rme32_playback_prepare
,
1252 .trigger
= snd_rme32_pcm_trigger
,
1253 .pointer
= snd_rme32_playback_fd_pointer
,
1254 .ack
= snd_rme32_playback_fd_ack
,
1257 static const struct snd_pcm_ops snd_rme32_capture_adat_fd_ops
= {
1258 .open
= snd_rme32_capture_adat_open
,
1259 .close
= snd_rme32_capture_close
,
1260 .hw_params
= snd_rme32_capture_hw_params
,
1261 .prepare
= snd_rme32_capture_prepare
,
1262 .trigger
= snd_rme32_pcm_trigger
,
1263 .pointer
= snd_rme32_capture_fd_pointer
,
1264 .ack
= snd_rme32_capture_fd_ack
,
1267 static void snd_rme32_free(void *private_data
)
1269 struct rme32
*rme32
= (struct rme32
*) private_data
;
1271 if (rme32
== NULL
) {
1274 if (rme32
->irq
>= 0) {
1275 snd_rme32_pcm_stop(rme32
, 0);
1276 free_irq(rme32
->irq
, (void *) rme32
);
1279 if (rme32
->iobase
) {
1280 iounmap(rme32
->iobase
);
1281 rme32
->iobase
= NULL
;
1284 pci_release_regions(rme32
->pci
);
1287 pci_disable_device(rme32
->pci
);
1290 static void snd_rme32_free_spdif_pcm(struct snd_pcm
*pcm
)
1292 struct rme32
*rme32
= (struct rme32
*) pcm
->private_data
;
1293 rme32
->spdif_pcm
= NULL
;
1297 snd_rme32_free_adat_pcm(struct snd_pcm
*pcm
)
1299 struct rme32
*rme32
= (struct rme32
*) pcm
->private_data
;
1300 rme32
->adat_pcm
= NULL
;
1303 static int snd_rme32_create(struct rme32
*rme32
)
1305 struct pci_dev
*pci
= rme32
->pci
;
1309 spin_lock_init(&rme32
->lock
);
1311 if ((err
= pci_enable_device(pci
)) < 0)
1314 if ((err
= pci_request_regions(pci
, "RME32")) < 0)
1316 rme32
->port
= pci_resource_start(rme32
->pci
, 0);
1318 rme32
->iobase
= ioremap(rme32
->port
, RME32_IO_SIZE
);
1319 if (!rme32
->iobase
) {
1320 dev_err(rme32
->card
->dev
,
1321 "unable to remap memory region 0x%lx-0x%lx\n",
1322 rme32
->port
, rme32
->port
+ RME32_IO_SIZE
- 1);
1326 if (request_irq(pci
->irq
, snd_rme32_interrupt
, IRQF_SHARED
,
1327 KBUILD_MODNAME
, rme32
)) {
1328 dev_err(rme32
->card
->dev
, "unable to grab IRQ %d\n", pci
->irq
);
1331 rme32
->irq
= pci
->irq
;
1332 rme32
->card
->sync_irq
= rme32
->irq
;
1334 /* read the card's revision number */
1335 pci_read_config_byte(pci
, 8, &rme32
->rev
);
1337 /* set up ALSA pcm device for S/PDIF */
1338 if ((err
= snd_pcm_new(rme32
->card
, "Digi32 IEC958", 0, 1, 1, &rme32
->spdif_pcm
)) < 0) {
1341 rme32
->spdif_pcm
->private_data
= rme32
;
1342 rme32
->spdif_pcm
->private_free
= snd_rme32_free_spdif_pcm
;
1343 strcpy(rme32
->spdif_pcm
->name
, "Digi32 IEC958");
1344 if (rme32
->fullduplex_mode
) {
1345 snd_pcm_set_ops(rme32
->spdif_pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
1346 &snd_rme32_playback_spdif_fd_ops
);
1347 snd_pcm_set_ops(rme32
->spdif_pcm
, SNDRV_PCM_STREAM_CAPTURE
,
1348 &snd_rme32_capture_spdif_fd_ops
);
1349 snd_pcm_set_managed_buffer_all(rme32
->spdif_pcm
, SNDRV_DMA_TYPE_CONTINUOUS
,
1350 NULL
, 0, RME32_MID_BUFFER_SIZE
);
1351 rme32
->spdif_pcm
->info_flags
= SNDRV_PCM_INFO_JOINT_DUPLEX
;
1353 snd_pcm_set_ops(rme32
->spdif_pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
1354 &snd_rme32_playback_spdif_ops
);
1355 snd_pcm_set_ops(rme32
->spdif_pcm
, SNDRV_PCM_STREAM_CAPTURE
,
1356 &snd_rme32_capture_spdif_ops
);
1357 rme32
->spdif_pcm
->info_flags
= SNDRV_PCM_INFO_HALF_DUPLEX
;
1360 /* set up ALSA pcm device for ADAT */
1361 if ((pci
->device
== PCI_DEVICE_ID_RME_DIGI32
) ||
1362 (pci
->device
== PCI_DEVICE_ID_RME_DIGI32_PRO
)) {
1363 /* ADAT is not available on DIGI32 and DIGI32 Pro */
1364 rme32
->adat_pcm
= NULL
;
1367 if ((err
= snd_pcm_new(rme32
->card
, "Digi32 ADAT", 1,
1368 1, 1, &rme32
->adat_pcm
)) < 0)
1372 rme32
->adat_pcm
->private_data
= rme32
;
1373 rme32
->adat_pcm
->private_free
= snd_rme32_free_adat_pcm
;
1374 strcpy(rme32
->adat_pcm
->name
, "Digi32 ADAT");
1375 if (rme32
->fullduplex_mode
) {
1376 snd_pcm_set_ops(rme32
->adat_pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
1377 &snd_rme32_playback_adat_fd_ops
);
1378 snd_pcm_set_ops(rme32
->adat_pcm
, SNDRV_PCM_STREAM_CAPTURE
,
1379 &snd_rme32_capture_adat_fd_ops
);
1380 snd_pcm_set_managed_buffer_all(rme32
->adat_pcm
, SNDRV_DMA_TYPE_CONTINUOUS
,
1382 0, RME32_MID_BUFFER_SIZE
);
1383 rme32
->adat_pcm
->info_flags
= SNDRV_PCM_INFO_JOINT_DUPLEX
;
1385 snd_pcm_set_ops(rme32
->adat_pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
1386 &snd_rme32_playback_adat_ops
);
1387 snd_pcm_set_ops(rme32
->adat_pcm
, SNDRV_PCM_STREAM_CAPTURE
,
1388 &snd_rme32_capture_adat_ops
);
1389 rme32
->adat_pcm
->info_flags
= SNDRV_PCM_INFO_HALF_DUPLEX
;
1394 rme32
->playback_periodsize
= 0;
1395 rme32
->capture_periodsize
= 0;
1397 /* make sure playback/capture is stopped, if by some reason active */
1398 snd_rme32_pcm_stop(rme32
, 0);
1401 snd_rme32_reset_dac(rme32
);
1403 /* reset buffer pointer */
1404 writel(0, rme32
->iobase
+ RME32_IO_RESET_POS
);
1406 /* set default values in registers */
1407 rme32
->wcreg
= RME32_WCR_SEL
| /* normal playback */
1408 RME32_WCR_INP_0
| /* input select */
1409 RME32_WCR_MUTE
; /* muting on */
1410 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
1413 /* init switch interface */
1414 if ((err
= snd_rme32_create_switches(rme32
->card
, rme32
)) < 0) {
1418 /* init proc interface */
1419 snd_rme32_proc_init(rme32
);
1421 rme32
->capture_substream
= NULL
;
1422 rme32
->playback_substream
= NULL
;
1432 snd_rme32_proc_read(struct snd_info_entry
* entry
, struct snd_info_buffer
*buffer
)
1435 struct rme32
*rme32
= (struct rme32
*) entry
->private_data
;
1437 rme32
->rcreg
= readl(rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
1439 snd_iprintf(buffer
, rme32
->card
->longname
);
1440 snd_iprintf(buffer
, " (index #%d)\n", rme32
->card
->number
+ 1);
1442 snd_iprintf(buffer
, "\nGeneral settings\n");
1443 if (rme32
->fullduplex_mode
)
1444 snd_iprintf(buffer
, " Full-duplex mode\n");
1446 snd_iprintf(buffer
, " Half-duplex mode\n");
1447 if (RME32_PRO_WITH_8414(rme32
)) {
1448 snd_iprintf(buffer
, " receiver: CS8414\n");
1450 snd_iprintf(buffer
, " receiver: CS8412\n");
1452 if (rme32
->wcreg
& RME32_WCR_MODE24
) {
1453 snd_iprintf(buffer
, " format: 24 bit");
1455 snd_iprintf(buffer
, " format: 16 bit");
1457 if (rme32
->wcreg
& RME32_WCR_MONO
) {
1458 snd_iprintf(buffer
, ", Mono\n");
1460 snd_iprintf(buffer
, ", Stereo\n");
1463 snd_iprintf(buffer
, "\nInput settings\n");
1464 switch (snd_rme32_getinputtype(rme32
)) {
1465 case RME32_INPUT_OPTICAL
:
1466 snd_iprintf(buffer
, " input: optical");
1468 case RME32_INPUT_COAXIAL
:
1469 snd_iprintf(buffer
, " input: coaxial");
1471 case RME32_INPUT_INTERNAL
:
1472 snd_iprintf(buffer
, " input: internal");
1474 case RME32_INPUT_XLR
:
1475 snd_iprintf(buffer
, " input: XLR");
1478 if (snd_rme32_capture_getrate(rme32
, &n
) < 0) {
1479 snd_iprintf(buffer
, "\n sample rate: no valid signal\n");
1482 snd_iprintf(buffer
, " (8 channels)\n");
1484 snd_iprintf(buffer
, " (2 channels)\n");
1486 snd_iprintf(buffer
, " sample rate: %d Hz\n",
1487 snd_rme32_capture_getrate(rme32
, &n
));
1490 snd_iprintf(buffer
, "\nOutput settings\n");
1491 if (rme32
->wcreg
& RME32_WCR_SEL
) {
1492 snd_iprintf(buffer
, " output signal: normal playback");
1494 snd_iprintf(buffer
, " output signal: same as input");
1496 if (rme32
->wcreg
& RME32_WCR_MUTE
) {
1497 snd_iprintf(buffer
, " (muted)\n");
1499 snd_iprintf(buffer
, "\n");
1502 /* master output frequency */
1504 ((!(rme32
->wcreg
& RME32_WCR_FREQ_0
))
1505 && (!(rme32
->wcreg
& RME32_WCR_FREQ_1
)))) {
1506 snd_iprintf(buffer
, " sample rate: %d Hz\n",
1507 snd_rme32_playback_getrate(rme32
));
1509 if (rme32
->rcreg
& RME32_RCR_KMODE
) {
1510 snd_iprintf(buffer
, " sample clock source: AutoSync\n");
1512 snd_iprintf(buffer
, " sample clock source: Internal\n");
1514 if (rme32
->wcreg
& RME32_WCR_PRO
) {
1515 snd_iprintf(buffer
, " format: AES/EBU (professional)\n");
1517 snd_iprintf(buffer
, " format: IEC958 (consumer)\n");
1519 if (rme32
->wcreg
& RME32_WCR_EMP
) {
1520 snd_iprintf(buffer
, " emphasis: on\n");
1522 snd_iprintf(buffer
, " emphasis: off\n");
1526 static void snd_rme32_proc_init(struct rme32
*rme32
)
1528 snd_card_ro_proc_new(rme32
->card
, "rme32", rme32
, snd_rme32_proc_read
);
1535 #define snd_rme32_info_loopback_control snd_ctl_boolean_mono_info
1538 snd_rme32_get_loopback_control(struct snd_kcontrol
*kcontrol
,
1539 struct snd_ctl_elem_value
*ucontrol
)
1541 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1543 spin_lock_irq(&rme32
->lock
);
1544 ucontrol
->value
.integer
.value
[0] =
1545 rme32
->wcreg
& RME32_WCR_SEL
? 0 : 1;
1546 spin_unlock_irq(&rme32
->lock
);
1550 snd_rme32_put_loopback_control(struct snd_kcontrol
*kcontrol
,
1551 struct snd_ctl_elem_value
*ucontrol
)
1553 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1557 val
= ucontrol
->value
.integer
.value
[0] ? 0 : RME32_WCR_SEL
;
1558 spin_lock_irq(&rme32
->lock
);
1559 val
= (rme32
->wcreg
& ~RME32_WCR_SEL
) | val
;
1560 change
= val
!= rme32
->wcreg
;
1561 if (ucontrol
->value
.integer
.value
[0])
1562 val
&= ~RME32_WCR_MUTE
;
1564 val
|= RME32_WCR_MUTE
;
1566 writel(val
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
1567 spin_unlock_irq(&rme32
->lock
);
1572 snd_rme32_info_inputtype_control(struct snd_kcontrol
*kcontrol
,
1573 struct snd_ctl_elem_info
*uinfo
)
1575 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1576 static const char * const texts
[4] = {
1577 "Optical", "Coaxial", "Internal", "XLR"
1581 switch (rme32
->pci
->device
) {
1582 case PCI_DEVICE_ID_RME_DIGI32
:
1583 case PCI_DEVICE_ID_RME_DIGI32_8
:
1586 case PCI_DEVICE_ID_RME_DIGI32_PRO
:
1593 return snd_ctl_enum_info(uinfo
, 1, num_items
, texts
);
1596 snd_rme32_get_inputtype_control(struct snd_kcontrol
*kcontrol
,
1597 struct snd_ctl_elem_value
*ucontrol
)
1599 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1600 unsigned int items
= 3;
1602 spin_lock_irq(&rme32
->lock
);
1603 ucontrol
->value
.enumerated
.item
[0] = snd_rme32_getinputtype(rme32
);
1605 switch (rme32
->pci
->device
) {
1606 case PCI_DEVICE_ID_RME_DIGI32
:
1607 case PCI_DEVICE_ID_RME_DIGI32_8
:
1610 case PCI_DEVICE_ID_RME_DIGI32_PRO
:
1617 if (ucontrol
->value
.enumerated
.item
[0] >= items
) {
1618 ucontrol
->value
.enumerated
.item
[0] = items
- 1;
1621 spin_unlock_irq(&rme32
->lock
);
1625 snd_rme32_put_inputtype_control(struct snd_kcontrol
*kcontrol
,
1626 struct snd_ctl_elem_value
*ucontrol
)
1628 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1630 int change
, items
= 3;
1632 switch (rme32
->pci
->device
) {
1633 case PCI_DEVICE_ID_RME_DIGI32
:
1634 case PCI_DEVICE_ID_RME_DIGI32_8
:
1637 case PCI_DEVICE_ID_RME_DIGI32_PRO
:
1644 val
= ucontrol
->value
.enumerated
.item
[0] % items
;
1646 spin_lock_irq(&rme32
->lock
);
1647 change
= val
!= (unsigned int)snd_rme32_getinputtype(rme32
);
1648 snd_rme32_setinputtype(rme32
, val
);
1649 spin_unlock_irq(&rme32
->lock
);
1654 snd_rme32_info_clockmode_control(struct snd_kcontrol
*kcontrol
,
1655 struct snd_ctl_elem_info
*uinfo
)
1657 static const char * const texts
[4] = { "AutoSync",
1660 "Internal 48.0kHz" };
1662 return snd_ctl_enum_info(uinfo
, 1, 4, texts
);
1665 snd_rme32_get_clockmode_control(struct snd_kcontrol
*kcontrol
,
1666 struct snd_ctl_elem_value
*ucontrol
)
1668 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1670 spin_lock_irq(&rme32
->lock
);
1671 ucontrol
->value
.enumerated
.item
[0] = snd_rme32_getclockmode(rme32
);
1672 spin_unlock_irq(&rme32
->lock
);
1676 snd_rme32_put_clockmode_control(struct snd_kcontrol
*kcontrol
,
1677 struct snd_ctl_elem_value
*ucontrol
)
1679 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1683 val
= ucontrol
->value
.enumerated
.item
[0] % 3;
1684 spin_lock_irq(&rme32
->lock
);
1685 change
= val
!= (unsigned int)snd_rme32_getclockmode(rme32
);
1686 snd_rme32_setclockmode(rme32
, val
);
1687 spin_unlock_irq(&rme32
->lock
);
1691 static u32
snd_rme32_convert_from_aes(struct snd_aes_iec958
* aes
)
1694 val
|= (aes
->status
[0] & IEC958_AES0_PROFESSIONAL
) ? RME32_WCR_PRO
: 0;
1695 if (val
& RME32_WCR_PRO
)
1696 val
|= (aes
->status
[0] & IEC958_AES0_PRO_EMPHASIS_5015
) ? RME32_WCR_EMP
: 0;
1698 val
|= (aes
->status
[0] & IEC958_AES0_CON_EMPHASIS_5015
) ? RME32_WCR_EMP
: 0;
1702 static void snd_rme32_convert_to_aes(struct snd_aes_iec958
* aes
, u32 val
)
1704 aes
->status
[0] = ((val
& RME32_WCR_PRO
) ? IEC958_AES0_PROFESSIONAL
: 0);
1705 if (val
& RME32_WCR_PRO
)
1706 aes
->status
[0] |= (val
& RME32_WCR_EMP
) ? IEC958_AES0_PRO_EMPHASIS_5015
: 0;
1708 aes
->status
[0] |= (val
& RME32_WCR_EMP
) ? IEC958_AES0_CON_EMPHASIS_5015
: 0;
1711 static int snd_rme32_control_spdif_info(struct snd_kcontrol
*kcontrol
,
1712 struct snd_ctl_elem_info
*uinfo
)
1714 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
1719 static int snd_rme32_control_spdif_get(struct snd_kcontrol
*kcontrol
,
1720 struct snd_ctl_elem_value
*ucontrol
)
1722 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1724 snd_rme32_convert_to_aes(&ucontrol
->value
.iec958
,
1725 rme32
->wcreg_spdif
);
1729 static int snd_rme32_control_spdif_put(struct snd_kcontrol
*kcontrol
,
1730 struct snd_ctl_elem_value
*ucontrol
)
1732 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1736 val
= snd_rme32_convert_from_aes(&ucontrol
->value
.iec958
);
1737 spin_lock_irq(&rme32
->lock
);
1738 change
= val
!= rme32
->wcreg_spdif
;
1739 rme32
->wcreg_spdif
= val
;
1740 spin_unlock_irq(&rme32
->lock
);
1744 static int snd_rme32_control_spdif_stream_info(struct snd_kcontrol
*kcontrol
,
1745 struct snd_ctl_elem_info
*uinfo
)
1747 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
1752 static int snd_rme32_control_spdif_stream_get(struct snd_kcontrol
*kcontrol
,
1753 struct snd_ctl_elem_value
*
1756 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1758 snd_rme32_convert_to_aes(&ucontrol
->value
.iec958
,
1759 rme32
->wcreg_spdif_stream
);
1763 static int snd_rme32_control_spdif_stream_put(struct snd_kcontrol
*kcontrol
,
1764 struct snd_ctl_elem_value
*
1767 struct rme32
*rme32
= snd_kcontrol_chip(kcontrol
);
1771 val
= snd_rme32_convert_from_aes(&ucontrol
->value
.iec958
);
1772 spin_lock_irq(&rme32
->lock
);
1773 change
= val
!= rme32
->wcreg_spdif_stream
;
1774 rme32
->wcreg_spdif_stream
= val
;
1775 rme32
->wcreg
&= ~(RME32_WCR_PRO
| RME32_WCR_EMP
);
1776 rme32
->wcreg
|= val
;
1777 writel(rme32
->wcreg
, rme32
->iobase
+ RME32_IO_CONTROL_REGISTER
);
1778 spin_unlock_irq(&rme32
->lock
);
1782 static int snd_rme32_control_spdif_mask_info(struct snd_kcontrol
*kcontrol
,
1783 struct snd_ctl_elem_info
*uinfo
)
1785 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
1790 static int snd_rme32_control_spdif_mask_get(struct snd_kcontrol
*kcontrol
,
1791 struct snd_ctl_elem_value
*
1794 ucontrol
->value
.iec958
.status
[0] = kcontrol
->private_value
;
1798 static const struct snd_kcontrol_new snd_rme32_controls
[] = {
1800 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1801 .name
= SNDRV_CTL_NAME_IEC958("", PLAYBACK
, DEFAULT
),
1802 .info
= snd_rme32_control_spdif_info
,
1803 .get
= snd_rme32_control_spdif_get
,
1804 .put
= snd_rme32_control_spdif_put
1807 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
1808 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1809 .name
= SNDRV_CTL_NAME_IEC958("", PLAYBACK
, PCM_STREAM
),
1810 .info
= snd_rme32_control_spdif_stream_info
,
1811 .get
= snd_rme32_control_spdif_stream_get
,
1812 .put
= snd_rme32_control_spdif_stream_put
1815 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
1816 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1817 .name
= SNDRV_CTL_NAME_IEC958("", PLAYBACK
, CON_MASK
),
1818 .info
= snd_rme32_control_spdif_mask_info
,
1819 .get
= snd_rme32_control_spdif_mask_get
,
1820 .private_value
= IEC958_AES0_PROFESSIONAL
| IEC958_AES0_CON_EMPHASIS
1823 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
1824 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1825 .name
= SNDRV_CTL_NAME_IEC958("", PLAYBACK
, PRO_MASK
),
1826 .info
= snd_rme32_control_spdif_mask_info
,
1827 .get
= snd_rme32_control_spdif_mask_get
,
1828 .private_value
= IEC958_AES0_PROFESSIONAL
| IEC958_AES0_PRO_EMPHASIS
1831 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1832 .name
= "Input Connector",
1833 .info
= snd_rme32_info_inputtype_control
,
1834 .get
= snd_rme32_get_inputtype_control
,
1835 .put
= snd_rme32_put_inputtype_control
1838 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1839 .name
= "Loopback Input",
1840 .info
= snd_rme32_info_loopback_control
,
1841 .get
= snd_rme32_get_loopback_control
,
1842 .put
= snd_rme32_put_loopback_control
1845 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
1846 .name
= "Sample Clock Source",
1847 .info
= snd_rme32_info_clockmode_control
,
1848 .get
= snd_rme32_get_clockmode_control
,
1849 .put
= snd_rme32_put_clockmode_control
1853 static int snd_rme32_create_switches(struct snd_card
*card
, struct rme32
* rme32
)
1856 struct snd_kcontrol
*kctl
;
1858 for (idx
= 0; idx
< (int)ARRAY_SIZE(snd_rme32_controls
); idx
++) {
1859 if ((err
= snd_ctl_add(card
, kctl
= snd_ctl_new1(&snd_rme32_controls
[idx
], rme32
))) < 0)
1861 if (idx
== 1) /* IEC958 (S/PDIF) Stream */
1862 rme32
->spdif_ctl
= kctl
;
1869 * Card initialisation
1872 static void snd_rme32_card_free(struct snd_card
*card
)
1874 snd_rme32_free(card
->private_data
);
1878 snd_rme32_probe(struct pci_dev
*pci
, const struct pci_device_id
*pci_id
)
1881 struct rme32
*rme32
;
1882 struct snd_card
*card
;
1885 if (dev
>= SNDRV_CARDS
) {
1893 err
= snd_card_new(&pci
->dev
, index
[dev
], id
[dev
], THIS_MODULE
,
1894 sizeof(struct rme32
), &card
);
1897 card
->private_free
= snd_rme32_card_free
;
1898 rme32
= (struct rme32
*) card
->private_data
;
1901 if (fullduplex
[dev
])
1902 rme32
->fullduplex_mode
= 1;
1903 if ((err
= snd_rme32_create(rme32
)) < 0) {
1904 snd_card_free(card
);
1908 strcpy(card
->driver
, "Digi32");
1909 switch (rme32
->pci
->device
) {
1910 case PCI_DEVICE_ID_RME_DIGI32
:
1911 strcpy(card
->shortname
, "RME Digi32");
1913 case PCI_DEVICE_ID_RME_DIGI32_8
:
1914 strcpy(card
->shortname
, "RME Digi32/8");
1916 case PCI_DEVICE_ID_RME_DIGI32_PRO
:
1917 strcpy(card
->shortname
, "RME Digi32 PRO");
1920 sprintf(card
->longname
, "%s (Rev. %d) at 0x%lx, irq %d",
1921 card
->shortname
, rme32
->rev
, rme32
->port
, rme32
->irq
);
1923 if ((err
= snd_card_register(card
)) < 0) {
1924 snd_card_free(card
);
1927 pci_set_drvdata(pci
, card
);
1932 static void snd_rme32_remove(struct pci_dev
*pci
)
1934 snd_card_free(pci_get_drvdata(pci
));
1937 static struct pci_driver rme32_driver
= {
1938 .name
= KBUILD_MODNAME
,
1939 .id_table
= snd_rme32_ids
,
1940 .probe
= snd_rme32_probe
,
1941 .remove
= snd_rme32_remove
,
1944 module_pci_driver(rme32_driver
);