2 * ALSA driver for RME Digi96, Digi96/8 and Digi96/8 PRO/PAD/PST audio
5 * Copyright (c) 2000, 2001 Anders Torger <torger@ludd.luth.se>
7 * Thanks to Henk Hesselink <henk@anda.nl> for the analog volume control
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/delay.h>
27 #include <linux/init.h>
28 #include <linux/interrupt.h>
29 #include <linux/pci.h>
30 #include <linux/module.h>
31 #include <linux/vmalloc.h>
34 #include <sound/core.h>
35 #include <sound/info.h>
36 #include <sound/control.h>
37 #include <sound/pcm.h>
38 #include <sound/pcm_params.h>
39 #include <sound/asoundef.h>
40 #include <sound/initval.h>
42 /* note, two last pcis should be equal, it is not a bug */
44 MODULE_AUTHOR("Anders Torger <torger@ludd.luth.se>");
45 MODULE_DESCRIPTION("RME Digi96, Digi96/8, Digi96/8 PRO, Digi96/8 PST, "
47 MODULE_LICENSE("GPL");
48 MODULE_SUPPORTED_DEVICE("{{RME,Digi96},"
52 "{RME,Digi96/8 PAD}}");
54 static int index
[SNDRV_CARDS
] = SNDRV_DEFAULT_IDX
; /* Index 0-MAX */
55 static char *id
[SNDRV_CARDS
] = SNDRV_DEFAULT_STR
; /* ID for this card */
56 static bool enable
[SNDRV_CARDS
] = SNDRV_DEFAULT_ENABLE_PNP
; /* Enable this card */
58 module_param_array(index
, int, NULL
, 0444);
59 MODULE_PARM_DESC(index
, "Index value for RME Digi96 soundcard.");
60 module_param_array(id
, charp
, NULL
, 0444);
61 MODULE_PARM_DESC(id
, "ID string for RME Digi96 soundcard.");
62 module_param_array(enable
, bool, NULL
, 0444);
63 MODULE_PARM_DESC(enable
, "Enable RME Digi96 soundcard.");
66 * Defines for RME Digi96 series, from internal RME reference documents
70 #define RME96_SPDIF_NCHANNELS 2
72 /* Playback and capture buffer size */
73 #define RME96_BUFFER_SIZE 0x10000
76 #define RME96_IO_SIZE 0x60000
79 #define RME96_IO_PLAY_BUFFER 0x0
80 #define RME96_IO_REC_BUFFER 0x10000
81 #define RME96_IO_CONTROL_REGISTER 0x20000
82 #define RME96_IO_ADDITIONAL_REG 0x20004
83 #define RME96_IO_CONFIRM_PLAY_IRQ 0x20008
84 #define RME96_IO_CONFIRM_REC_IRQ 0x2000C
85 #define RME96_IO_SET_PLAY_POS 0x40000
86 #define RME96_IO_RESET_PLAY_POS 0x4FFFC
87 #define RME96_IO_SET_REC_POS 0x50000
88 #define RME96_IO_RESET_REC_POS 0x5FFFC
89 #define RME96_IO_GET_PLAY_POS 0x20000
90 #define RME96_IO_GET_REC_POS 0x30000
92 /* Write control register bits */
93 #define RME96_WCR_START (1 << 0)
94 #define RME96_WCR_START_2 (1 << 1)
95 #define RME96_WCR_GAIN_0 (1 << 2)
96 #define RME96_WCR_GAIN_1 (1 << 3)
97 #define RME96_WCR_MODE24 (1 << 4)
98 #define RME96_WCR_MODE24_2 (1 << 5)
99 #define RME96_WCR_BM (1 << 6)
100 #define RME96_WCR_BM_2 (1 << 7)
101 #define RME96_WCR_ADAT (1 << 8)
102 #define RME96_WCR_FREQ_0 (1 << 9)
103 #define RME96_WCR_FREQ_1 (1 << 10)
104 #define RME96_WCR_DS (1 << 11)
105 #define RME96_WCR_PRO (1 << 12)
106 #define RME96_WCR_EMP (1 << 13)
107 #define RME96_WCR_SEL (1 << 14)
108 #define RME96_WCR_MASTER (1 << 15)
109 #define RME96_WCR_PD (1 << 16)
110 #define RME96_WCR_INP_0 (1 << 17)
111 #define RME96_WCR_INP_1 (1 << 18)
112 #define RME96_WCR_THRU_0 (1 << 19)
113 #define RME96_WCR_THRU_1 (1 << 20)
114 #define RME96_WCR_THRU_2 (1 << 21)
115 #define RME96_WCR_THRU_3 (1 << 22)
116 #define RME96_WCR_THRU_4 (1 << 23)
117 #define RME96_WCR_THRU_5 (1 << 24)
118 #define RME96_WCR_THRU_6 (1 << 25)
119 #define RME96_WCR_THRU_7 (1 << 26)
120 #define RME96_WCR_DOLBY (1 << 27)
121 #define RME96_WCR_MONITOR_0 (1 << 28)
122 #define RME96_WCR_MONITOR_1 (1 << 29)
123 #define RME96_WCR_ISEL (1 << 30)
124 #define RME96_WCR_IDIS (1 << 31)
126 #define RME96_WCR_BITPOS_GAIN_0 2
127 #define RME96_WCR_BITPOS_GAIN_1 3
128 #define RME96_WCR_BITPOS_FREQ_0 9
129 #define RME96_WCR_BITPOS_FREQ_1 10
130 #define RME96_WCR_BITPOS_INP_0 17
131 #define RME96_WCR_BITPOS_INP_1 18
132 #define RME96_WCR_BITPOS_MONITOR_0 28
133 #define RME96_WCR_BITPOS_MONITOR_1 29
135 /* Read control register bits */
136 #define RME96_RCR_AUDIO_ADDR_MASK 0xFFFF
137 #define RME96_RCR_IRQ_2 (1 << 16)
138 #define RME96_RCR_T_OUT (1 << 17)
139 #define RME96_RCR_DEV_ID_0 (1 << 21)
140 #define RME96_RCR_DEV_ID_1 (1 << 22)
141 #define RME96_RCR_LOCK (1 << 23)
142 #define RME96_RCR_VERF (1 << 26)
143 #define RME96_RCR_F0 (1 << 27)
144 #define RME96_RCR_F1 (1 << 28)
145 #define RME96_RCR_F2 (1 << 29)
146 #define RME96_RCR_AUTOSYNC (1 << 30)
147 #define RME96_RCR_IRQ (1 << 31)
149 #define RME96_RCR_BITPOS_F0 27
150 #define RME96_RCR_BITPOS_F1 28
151 #define RME96_RCR_BITPOS_F2 29
153 /* Additional register bits */
154 #define RME96_AR_WSEL (1 << 0)
155 #define RME96_AR_ANALOG (1 << 1)
156 #define RME96_AR_FREQPAD_0 (1 << 2)
157 #define RME96_AR_FREQPAD_1 (1 << 3)
158 #define RME96_AR_FREQPAD_2 (1 << 4)
159 #define RME96_AR_PD2 (1 << 5)
160 #define RME96_AR_DAC_EN (1 << 6)
161 #define RME96_AR_CLATCH (1 << 7)
162 #define RME96_AR_CCLK (1 << 8)
163 #define RME96_AR_CDATA (1 << 9)
165 #define RME96_AR_BITPOS_F0 2
166 #define RME96_AR_BITPOS_F1 3
167 #define RME96_AR_BITPOS_F2 4
170 #define RME96_MONITOR_TRACKS_1_2 0
171 #define RME96_MONITOR_TRACKS_3_4 1
172 #define RME96_MONITOR_TRACKS_5_6 2
173 #define RME96_MONITOR_TRACKS_7_8 3
176 #define RME96_ATTENUATION_0 0
177 #define RME96_ATTENUATION_6 1
178 #define RME96_ATTENUATION_12 2
179 #define RME96_ATTENUATION_18 3
182 #define RME96_INPUT_OPTICAL 0
183 #define RME96_INPUT_COAXIAL 1
184 #define RME96_INPUT_INTERNAL 2
185 #define RME96_INPUT_XLR 3
186 #define RME96_INPUT_ANALOG 4
189 #define RME96_CLOCKMODE_SLAVE 0
190 #define RME96_CLOCKMODE_MASTER 1
191 #define RME96_CLOCKMODE_WORDCLOCK 2
193 /* Block sizes in bytes */
194 #define RME96_SMALL_BLOCK_SIZE 2048
195 #define RME96_LARGE_BLOCK_SIZE 8192
198 #define RME96_AD1852_VOL_BITS 14
199 #define RME96_AD1855_VOL_BITS 10
201 /* Defines for snd_rme96_trigger */
202 #define RME96_TB_START_PLAYBACK 1
203 #define RME96_TB_START_CAPTURE 2
204 #define RME96_TB_STOP_PLAYBACK 4
205 #define RME96_TB_STOP_CAPTURE 8
206 #define RME96_TB_RESET_PLAYPOS 16
207 #define RME96_TB_RESET_CAPTUREPOS 32
208 #define RME96_TB_CLEAR_PLAYBACK_IRQ 64
209 #define RME96_TB_CLEAR_CAPTURE_IRQ 128
210 #define RME96_RESUME_PLAYBACK (RME96_TB_START_PLAYBACK)
211 #define RME96_RESUME_CAPTURE (RME96_TB_START_CAPTURE)
212 #define RME96_RESUME_BOTH (RME96_RESUME_PLAYBACK \
213 | RME96_RESUME_CAPTURE)
214 #define RME96_START_PLAYBACK (RME96_TB_START_PLAYBACK \
215 | RME96_TB_RESET_PLAYPOS)
216 #define RME96_START_CAPTURE (RME96_TB_START_CAPTURE \
217 | RME96_TB_RESET_CAPTUREPOS)
218 #define RME96_START_BOTH (RME96_START_PLAYBACK \
219 | RME96_START_CAPTURE)
220 #define RME96_STOP_PLAYBACK (RME96_TB_STOP_PLAYBACK \
221 | RME96_TB_CLEAR_PLAYBACK_IRQ)
222 #define RME96_STOP_CAPTURE (RME96_TB_STOP_CAPTURE \
223 | RME96_TB_CLEAR_CAPTURE_IRQ)
224 #define RME96_STOP_BOTH (RME96_STOP_PLAYBACK \
225 | RME96_STOP_CAPTURE)
231 void __iomem
*iobase
;
233 u32 wcreg
; /* cached write control register value */
234 u32 wcreg_spdif
; /* S/PDIF setup */
235 u32 wcreg_spdif_stream
; /* S/PDIF setup (temporary) */
236 u32 rcreg
; /* cached read control register value */
237 u32 areg
; /* cached additional register value */
238 u16 vol
[2]; /* cached volume of analog output */
240 u8 rev
; /* card revision number */
242 #ifdef CONFIG_PM_SLEEP
243 u32 playback_pointer
;
245 void *playback_suspend_buffer
;
246 void *capture_suspend_buffer
;
249 struct snd_pcm_substream
*playback_substream
;
250 struct snd_pcm_substream
*capture_substream
;
252 int playback_frlog
; /* log2 of framesize */
255 size_t playback_periodsize
; /* in bytes, zero if not used */
256 size_t capture_periodsize
; /* in bytes, zero if not used */
258 struct snd_card
*card
;
259 struct snd_pcm
*spdif_pcm
;
260 struct snd_pcm
*adat_pcm
;
262 struct snd_kcontrol
*spdif_ctl
;
265 static const struct pci_device_id snd_rme96_ids
[] = {
266 { PCI_VDEVICE(XILINX
, PCI_DEVICE_ID_RME_DIGI96
), 0, },
267 { PCI_VDEVICE(XILINX
, PCI_DEVICE_ID_RME_DIGI96_8
), 0, },
268 { PCI_VDEVICE(XILINX
, PCI_DEVICE_ID_RME_DIGI96_8_PRO
), 0, },
269 { PCI_VDEVICE(XILINX
, PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
), 0, },
273 MODULE_DEVICE_TABLE(pci
, snd_rme96_ids
);
275 #define RME96_ISPLAYING(rme96) ((rme96)->wcreg & RME96_WCR_START)
276 #define RME96_ISRECORDING(rme96) ((rme96)->wcreg & RME96_WCR_START_2)
277 #define RME96_HAS_ANALOG_IN(rme96) ((rme96)->pci->device == PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST)
278 #define RME96_HAS_ANALOG_OUT(rme96) ((rme96)->pci->device == PCI_DEVICE_ID_RME_DIGI96_8_PRO || \
279 (rme96)->pci->device == PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST)
280 #define RME96_DAC_IS_1852(rme96) (RME96_HAS_ANALOG_OUT(rme96) && (rme96)->rev >= 4)
281 #define RME96_DAC_IS_1855(rme96) (((rme96)->pci->device == PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST && (rme96)->rev < 4) || \
282 ((rme96)->pci->device == PCI_DEVICE_ID_RME_DIGI96_8_PRO && (rme96)->rev == 2))
283 #define RME96_185X_MAX_OUT(rme96) ((1 << (RME96_DAC_IS_1852(rme96) ? RME96_AD1852_VOL_BITS : RME96_AD1855_VOL_BITS)) - 1)
286 snd_rme96_playback_prepare(struct snd_pcm_substream
*substream
);
289 snd_rme96_capture_prepare(struct snd_pcm_substream
*substream
);
292 snd_rme96_playback_trigger(struct snd_pcm_substream
*substream
,
296 snd_rme96_capture_trigger(struct snd_pcm_substream
*substream
,
299 static snd_pcm_uframes_t
300 snd_rme96_playback_pointer(struct snd_pcm_substream
*substream
);
302 static snd_pcm_uframes_t
303 snd_rme96_capture_pointer(struct snd_pcm_substream
*substream
);
305 static void snd_rme96_proc_init(struct rme96
*rme96
);
308 snd_rme96_create_switches(struct snd_card
*card
,
309 struct rme96
*rme96
);
312 snd_rme96_getinputtype(struct rme96
*rme96
);
314 static inline unsigned int
315 snd_rme96_playback_ptr(struct rme96
*rme96
)
317 return (readl(rme96
->iobase
+ RME96_IO_GET_PLAY_POS
)
318 & RME96_RCR_AUDIO_ADDR_MASK
) >> rme96
->playback_frlog
;
321 static inline unsigned int
322 snd_rme96_capture_ptr(struct rme96
*rme96
)
324 return (readl(rme96
->iobase
+ RME96_IO_GET_REC_POS
)
325 & RME96_RCR_AUDIO_ADDR_MASK
) >> rme96
->capture_frlog
;
329 snd_rme96_playback_silence(struct snd_pcm_substream
*substream
,
330 int channel
, unsigned long pos
, unsigned long count
)
332 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
334 memset_io(rme96
->iobase
+ RME96_IO_PLAY_BUFFER
+ pos
,
340 snd_rme96_playback_copy(struct snd_pcm_substream
*substream
,
341 int channel
, unsigned long pos
,
342 void __user
*src
, unsigned long count
)
344 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
346 return copy_from_user_toio(rme96
->iobase
+ RME96_IO_PLAY_BUFFER
+ pos
,
351 snd_rme96_playback_copy_kernel(struct snd_pcm_substream
*substream
,
352 int channel
, unsigned long pos
,
353 void *src
, unsigned long count
)
355 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
357 memcpy_toio(rme96
->iobase
+ RME96_IO_PLAY_BUFFER
+ pos
, src
, count
);
362 snd_rme96_capture_copy(struct snd_pcm_substream
*substream
,
363 int channel
, unsigned long pos
,
364 void __user
*dst
, unsigned long count
)
366 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
368 return copy_to_user_fromio(dst
,
369 rme96
->iobase
+ RME96_IO_REC_BUFFER
+ pos
,
374 snd_rme96_capture_copy_kernel(struct snd_pcm_substream
*substream
,
375 int channel
, unsigned long pos
,
376 void *dst
, unsigned long count
)
378 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
380 memcpy_fromio(dst
, rme96
->iobase
+ RME96_IO_REC_BUFFER
+ pos
, count
);
385 * Digital output capabilities (S/PDIF)
387 static const struct snd_pcm_hardware snd_rme96_playback_spdif_info
=
389 .info
= (SNDRV_PCM_INFO_MMAP_IOMEM
|
390 SNDRV_PCM_INFO_MMAP_VALID
|
391 SNDRV_PCM_INFO_SYNC_START
|
392 SNDRV_PCM_INFO_RESUME
|
393 SNDRV_PCM_INFO_INTERLEAVED
|
394 SNDRV_PCM_INFO_PAUSE
),
395 .formats
= (SNDRV_PCM_FMTBIT_S16_LE
|
396 SNDRV_PCM_FMTBIT_S32_LE
),
397 .rates
= (SNDRV_PCM_RATE_32000
|
398 SNDRV_PCM_RATE_44100
|
399 SNDRV_PCM_RATE_48000
|
400 SNDRV_PCM_RATE_64000
|
401 SNDRV_PCM_RATE_88200
|
402 SNDRV_PCM_RATE_96000
),
407 .buffer_bytes_max
= RME96_BUFFER_SIZE
,
408 .period_bytes_min
= RME96_SMALL_BLOCK_SIZE
,
409 .period_bytes_max
= RME96_LARGE_BLOCK_SIZE
,
410 .periods_min
= RME96_BUFFER_SIZE
/ RME96_LARGE_BLOCK_SIZE
,
411 .periods_max
= RME96_BUFFER_SIZE
/ RME96_SMALL_BLOCK_SIZE
,
416 * Digital input capabilities (S/PDIF)
418 static const struct snd_pcm_hardware snd_rme96_capture_spdif_info
=
420 .info
= (SNDRV_PCM_INFO_MMAP_IOMEM
|
421 SNDRV_PCM_INFO_MMAP_VALID
|
422 SNDRV_PCM_INFO_SYNC_START
|
423 SNDRV_PCM_INFO_RESUME
|
424 SNDRV_PCM_INFO_INTERLEAVED
|
425 SNDRV_PCM_INFO_PAUSE
),
426 .formats
= (SNDRV_PCM_FMTBIT_S16_LE
|
427 SNDRV_PCM_FMTBIT_S32_LE
),
428 .rates
= (SNDRV_PCM_RATE_32000
|
429 SNDRV_PCM_RATE_44100
|
430 SNDRV_PCM_RATE_48000
|
431 SNDRV_PCM_RATE_64000
|
432 SNDRV_PCM_RATE_88200
|
433 SNDRV_PCM_RATE_96000
),
438 .buffer_bytes_max
= RME96_BUFFER_SIZE
,
439 .period_bytes_min
= RME96_SMALL_BLOCK_SIZE
,
440 .period_bytes_max
= RME96_LARGE_BLOCK_SIZE
,
441 .periods_min
= RME96_BUFFER_SIZE
/ RME96_LARGE_BLOCK_SIZE
,
442 .periods_max
= RME96_BUFFER_SIZE
/ RME96_SMALL_BLOCK_SIZE
,
447 * Digital output capabilities (ADAT)
449 static const struct snd_pcm_hardware snd_rme96_playback_adat_info
=
451 .info
= (SNDRV_PCM_INFO_MMAP_IOMEM
|
452 SNDRV_PCM_INFO_MMAP_VALID
|
453 SNDRV_PCM_INFO_SYNC_START
|
454 SNDRV_PCM_INFO_RESUME
|
455 SNDRV_PCM_INFO_INTERLEAVED
|
456 SNDRV_PCM_INFO_PAUSE
),
457 .formats
= (SNDRV_PCM_FMTBIT_S16_LE
|
458 SNDRV_PCM_FMTBIT_S32_LE
),
459 .rates
= (SNDRV_PCM_RATE_44100
|
460 SNDRV_PCM_RATE_48000
),
465 .buffer_bytes_max
= RME96_BUFFER_SIZE
,
466 .period_bytes_min
= RME96_SMALL_BLOCK_SIZE
,
467 .period_bytes_max
= RME96_LARGE_BLOCK_SIZE
,
468 .periods_min
= RME96_BUFFER_SIZE
/ RME96_LARGE_BLOCK_SIZE
,
469 .periods_max
= RME96_BUFFER_SIZE
/ RME96_SMALL_BLOCK_SIZE
,
474 * Digital input capabilities (ADAT)
476 static const struct snd_pcm_hardware snd_rme96_capture_adat_info
=
478 .info
= (SNDRV_PCM_INFO_MMAP_IOMEM
|
479 SNDRV_PCM_INFO_MMAP_VALID
|
480 SNDRV_PCM_INFO_SYNC_START
|
481 SNDRV_PCM_INFO_RESUME
|
482 SNDRV_PCM_INFO_INTERLEAVED
|
483 SNDRV_PCM_INFO_PAUSE
),
484 .formats
= (SNDRV_PCM_FMTBIT_S16_LE
|
485 SNDRV_PCM_FMTBIT_S32_LE
),
486 .rates
= (SNDRV_PCM_RATE_44100
|
487 SNDRV_PCM_RATE_48000
),
492 .buffer_bytes_max
= RME96_BUFFER_SIZE
,
493 .period_bytes_min
= RME96_SMALL_BLOCK_SIZE
,
494 .period_bytes_max
= RME96_LARGE_BLOCK_SIZE
,
495 .periods_min
= RME96_BUFFER_SIZE
/ RME96_LARGE_BLOCK_SIZE
,
496 .periods_max
= RME96_BUFFER_SIZE
/ RME96_SMALL_BLOCK_SIZE
,
501 * The CDATA, CCLK and CLATCH bits can be used to write to the SPI interface
502 * of the AD1852 or AD1852 D/A converter on the board. CDATA must be set up
503 * on the falling edge of CCLK and be stable on the rising edge. The rising
504 * edge of CLATCH after the last data bit clocks in the whole data word.
505 * A fast processor could probably drive the SPI interface faster than the
506 * DAC can handle (3MHz for the 1855, unknown for the 1852). The udelay(1)
507 * limits the data rate to 500KHz and only causes a delay of 33 microsecs.
509 * NOTE: increased delay from 1 to 10, since there where problems setting
513 snd_rme96_write_SPI(struct rme96
*rme96
, u16 val
)
517 for (i
= 0; i
< 16; i
++) {
519 rme96
->areg
|= RME96_AR_CDATA
;
521 rme96
->areg
&= ~RME96_AR_CDATA
;
523 rme96
->areg
&= ~(RME96_AR_CCLK
| RME96_AR_CLATCH
);
524 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
526 rme96
->areg
|= RME96_AR_CCLK
;
527 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
531 rme96
->areg
&= ~(RME96_AR_CCLK
| RME96_AR_CDATA
);
532 rme96
->areg
|= RME96_AR_CLATCH
;
533 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
535 rme96
->areg
&= ~RME96_AR_CLATCH
;
536 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
540 snd_rme96_apply_dac_volume(struct rme96
*rme96
)
542 if (RME96_DAC_IS_1852(rme96
)) {
543 snd_rme96_write_SPI(rme96
, (rme96
->vol
[0] << 2) | 0x0);
544 snd_rme96_write_SPI(rme96
, (rme96
->vol
[1] << 2) | 0x2);
545 } else if (RME96_DAC_IS_1855(rme96
)) {
546 snd_rme96_write_SPI(rme96
, (rme96
->vol
[0] & 0x3FF) | 0x000);
547 snd_rme96_write_SPI(rme96
, (rme96
->vol
[1] & 0x3FF) | 0x400);
552 snd_rme96_reset_dac(struct rme96
*rme96
)
554 writel(rme96
->wcreg
| RME96_WCR_PD
,
555 rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
556 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
560 snd_rme96_getmontracks(struct rme96
*rme96
)
562 return ((rme96
->wcreg
>> RME96_WCR_BITPOS_MONITOR_0
) & 1) +
563 (((rme96
->wcreg
>> RME96_WCR_BITPOS_MONITOR_1
) & 1) << 1);
567 snd_rme96_setmontracks(struct rme96
*rme96
,
571 rme96
->wcreg
|= RME96_WCR_MONITOR_0
;
573 rme96
->wcreg
&= ~RME96_WCR_MONITOR_0
;
576 rme96
->wcreg
|= RME96_WCR_MONITOR_1
;
578 rme96
->wcreg
&= ~RME96_WCR_MONITOR_1
;
580 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
585 snd_rme96_getattenuation(struct rme96
*rme96
)
587 return ((rme96
->wcreg
>> RME96_WCR_BITPOS_GAIN_0
) & 1) +
588 (((rme96
->wcreg
>> RME96_WCR_BITPOS_GAIN_1
) & 1) << 1);
592 snd_rme96_setattenuation(struct rme96
*rme96
,
595 switch (attenuation
) {
597 rme96
->wcreg
= (rme96
->wcreg
& ~RME96_WCR_GAIN_0
) &
601 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_GAIN_0
) &
605 rme96
->wcreg
= (rme96
->wcreg
& ~RME96_WCR_GAIN_0
) |
609 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_GAIN_0
) |
615 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
620 snd_rme96_capture_getrate(struct rme96
*rme96
,
626 if (rme96
->areg
& RME96_AR_ANALOG
) {
627 /* Analog input, overrides S/PDIF setting */
628 n
= ((rme96
->areg
>> RME96_AR_BITPOS_F0
) & 1) +
629 (((rme96
->areg
>> RME96_AR_BITPOS_F1
) & 1) << 1);
643 return (rme96
->areg
& RME96_AR_BITPOS_F2
) ? rate
<< 1 : rate
;
646 rme96
->rcreg
= readl(rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
647 if (rme96
->rcreg
& RME96_RCR_LOCK
) {
650 if (rme96
->rcreg
& RME96_RCR_T_OUT
) {
656 if (rme96
->rcreg
& RME96_RCR_VERF
) {
661 n
= ((rme96
->rcreg
>> RME96_RCR_BITPOS_F0
) & 1) +
662 (((rme96
->rcreg
>> RME96_RCR_BITPOS_F1
) & 1) << 1) +
663 (((rme96
->rcreg
>> RME96_RCR_BITPOS_F2
) & 1) << 2);
667 if (rme96
->rcreg
& RME96_RCR_T_OUT
) {
671 case 3: return 96000;
672 case 4: return 88200;
673 case 5: return 48000;
674 case 6: return 44100;
675 case 7: return 32000;
683 snd_rme96_playback_getrate(struct rme96
*rme96
)
687 if (!(rme96
->wcreg
& RME96_WCR_MASTER
) &&
688 snd_rme96_getinputtype(rme96
) != RME96_INPUT_ANALOG
&&
689 (rate
= snd_rme96_capture_getrate(rme96
, &dummy
)) > 0)
694 rate
= ((rme96
->wcreg
>> RME96_WCR_BITPOS_FREQ_0
) & 1) +
695 (((rme96
->wcreg
>> RME96_WCR_BITPOS_FREQ_1
) & 1) << 1);
709 return (rme96
->wcreg
& RME96_WCR_DS
) ? rate
<< 1 : rate
;
713 snd_rme96_playback_setrate(struct rme96
*rme96
,
718 ds
= rme96
->wcreg
& RME96_WCR_DS
;
721 rme96
->wcreg
&= ~RME96_WCR_DS
;
722 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_FREQ_0
) &
726 rme96
->wcreg
&= ~RME96_WCR_DS
;
727 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_FREQ_1
) &
731 rme96
->wcreg
&= ~RME96_WCR_DS
;
732 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_FREQ_0
) |
736 rme96
->wcreg
|= RME96_WCR_DS
;
737 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_FREQ_0
) &
741 rme96
->wcreg
|= RME96_WCR_DS
;
742 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_FREQ_1
) &
746 rme96
->wcreg
|= RME96_WCR_DS
;
747 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_FREQ_0
) |
753 if ((!ds
&& rme96
->wcreg
& RME96_WCR_DS
) ||
754 (ds
&& !(rme96
->wcreg
& RME96_WCR_DS
)))
756 /* change to/from double-speed: reset the DAC (if available) */
757 snd_rme96_reset_dac(rme96
);
758 return 1; /* need to restore volume */
760 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
766 snd_rme96_capture_analog_setrate(struct rme96
*rme96
,
771 rme96
->areg
= ((rme96
->areg
| RME96_AR_FREQPAD_0
) &
772 ~RME96_AR_FREQPAD_1
) & ~RME96_AR_FREQPAD_2
;
775 rme96
->areg
= ((rme96
->areg
& ~RME96_AR_FREQPAD_0
) |
776 RME96_AR_FREQPAD_1
) & ~RME96_AR_FREQPAD_2
;
779 rme96
->areg
= ((rme96
->areg
| RME96_AR_FREQPAD_0
) |
780 RME96_AR_FREQPAD_1
) & ~RME96_AR_FREQPAD_2
;
783 if (rme96
->rev
< 4) {
786 rme96
->areg
= ((rme96
->areg
| RME96_AR_FREQPAD_0
) &
787 ~RME96_AR_FREQPAD_1
) | RME96_AR_FREQPAD_2
;
790 if (rme96
->rev
< 4) {
793 rme96
->areg
= ((rme96
->areg
& ~RME96_AR_FREQPAD_0
) |
794 RME96_AR_FREQPAD_1
) | RME96_AR_FREQPAD_2
;
797 rme96
->areg
= ((rme96
->areg
| RME96_AR_FREQPAD_0
) |
798 RME96_AR_FREQPAD_1
) | RME96_AR_FREQPAD_2
;
803 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
808 snd_rme96_setclockmode(struct rme96
*rme96
,
812 case RME96_CLOCKMODE_SLAVE
:
814 rme96
->wcreg
&= ~RME96_WCR_MASTER
;
815 rme96
->areg
&= ~RME96_AR_WSEL
;
817 case RME96_CLOCKMODE_MASTER
:
819 rme96
->wcreg
|= RME96_WCR_MASTER
;
820 rme96
->areg
&= ~RME96_AR_WSEL
;
822 case RME96_CLOCKMODE_WORDCLOCK
:
823 /* Word clock is a master mode */
824 rme96
->wcreg
|= RME96_WCR_MASTER
;
825 rme96
->areg
|= RME96_AR_WSEL
;
830 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
831 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
836 snd_rme96_getclockmode(struct rme96
*rme96
)
838 if (rme96
->areg
& RME96_AR_WSEL
) {
839 return RME96_CLOCKMODE_WORDCLOCK
;
841 return (rme96
->wcreg
& RME96_WCR_MASTER
) ? RME96_CLOCKMODE_MASTER
:
842 RME96_CLOCKMODE_SLAVE
;
846 snd_rme96_setinputtype(struct rme96
*rme96
,
852 case RME96_INPUT_OPTICAL
:
853 rme96
->wcreg
= (rme96
->wcreg
& ~RME96_WCR_INP_0
) &
856 case RME96_INPUT_COAXIAL
:
857 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_INP_0
) &
860 case RME96_INPUT_INTERNAL
:
861 rme96
->wcreg
= (rme96
->wcreg
& ~RME96_WCR_INP_0
) |
864 case RME96_INPUT_XLR
:
865 if ((rme96
->pci
->device
!= PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
&&
866 rme96
->pci
->device
!= PCI_DEVICE_ID_RME_DIGI96_8_PRO
) ||
867 (rme96
->pci
->device
== PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
&&
870 /* Only Digi96/8 PRO and Digi96/8 PAD supports XLR */
873 rme96
->wcreg
= (rme96
->wcreg
| RME96_WCR_INP_0
) |
876 case RME96_INPUT_ANALOG
:
877 if (!RME96_HAS_ANALOG_IN(rme96
)) {
880 rme96
->areg
|= RME96_AR_ANALOG
;
881 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
882 if (rme96
->rev
< 4) {
884 * Revision less than 004 does not support 64 and
887 if (snd_rme96_capture_getrate(rme96
, &n
) == 88200) {
888 snd_rme96_capture_analog_setrate(rme96
, 44100);
890 if (snd_rme96_capture_getrate(rme96
, &n
) == 64000) {
891 snd_rme96_capture_analog_setrate(rme96
, 32000);
898 if (type
!= RME96_INPUT_ANALOG
&& RME96_HAS_ANALOG_IN(rme96
)) {
899 rme96
->areg
&= ~RME96_AR_ANALOG
;
900 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
902 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
907 snd_rme96_getinputtype(struct rme96
*rme96
)
909 if (rme96
->areg
& RME96_AR_ANALOG
) {
910 return RME96_INPUT_ANALOG
;
912 return ((rme96
->wcreg
>> RME96_WCR_BITPOS_INP_0
) & 1) +
913 (((rme96
->wcreg
>> RME96_WCR_BITPOS_INP_1
) & 1) << 1);
917 snd_rme96_setframelog(struct rme96
*rme96
,
923 if (n_channels
== 2) {
926 /* assume 8 channels */
930 frlog
+= (rme96
->wcreg
& RME96_WCR_MODE24
) ? 2 : 1;
931 rme96
->playback_frlog
= frlog
;
933 frlog
+= (rme96
->wcreg
& RME96_WCR_MODE24_2
) ? 2 : 1;
934 rme96
->capture_frlog
= frlog
;
939 snd_rme96_playback_setformat(struct rme96
*rme96
, snd_pcm_format_t format
)
942 case SNDRV_PCM_FORMAT_S16_LE
:
943 rme96
->wcreg
&= ~RME96_WCR_MODE24
;
945 case SNDRV_PCM_FORMAT_S32_LE
:
946 rme96
->wcreg
|= RME96_WCR_MODE24
;
951 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
956 snd_rme96_capture_setformat(struct rme96
*rme96
, snd_pcm_format_t format
)
959 case SNDRV_PCM_FORMAT_S16_LE
:
960 rme96
->wcreg
&= ~RME96_WCR_MODE24_2
;
962 case SNDRV_PCM_FORMAT_S32_LE
:
963 rme96
->wcreg
|= RME96_WCR_MODE24_2
;
968 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
973 snd_rme96_set_period_properties(struct rme96
*rme96
,
976 switch (period_bytes
) {
977 case RME96_LARGE_BLOCK_SIZE
:
978 rme96
->wcreg
&= ~RME96_WCR_ISEL
;
980 case RME96_SMALL_BLOCK_SIZE
:
981 rme96
->wcreg
|= RME96_WCR_ISEL
;
987 rme96
->wcreg
&= ~RME96_WCR_IDIS
;
988 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
992 snd_rme96_playback_hw_params(struct snd_pcm_substream
*substream
,
993 struct snd_pcm_hw_params
*params
)
995 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
996 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
997 int err
, rate
, dummy
;
998 bool apply_dac_volume
= false;
1000 runtime
->dma_area
= (void __force
*)(rme96
->iobase
+
1001 RME96_IO_PLAY_BUFFER
);
1002 runtime
->dma_addr
= rme96
->port
+ RME96_IO_PLAY_BUFFER
;
1003 runtime
->dma_bytes
= RME96_BUFFER_SIZE
;
1005 spin_lock_irq(&rme96
->lock
);
1006 if (!(rme96
->wcreg
& RME96_WCR_MASTER
) &&
1007 snd_rme96_getinputtype(rme96
) != RME96_INPUT_ANALOG
&&
1008 (rate
= snd_rme96_capture_getrate(rme96
, &dummy
)) > 0)
1011 if ((int)params_rate(params
) != rate
) {
1016 err
= snd_rme96_playback_setrate(rme96
, params_rate(params
));
1019 apply_dac_volume
= err
> 0; /* need to restore volume later? */
1022 err
= snd_rme96_playback_setformat(rme96
, params_format(params
));
1025 snd_rme96_setframelog(rme96
, params_channels(params
), 1);
1026 if (rme96
->capture_periodsize
!= 0) {
1027 if (params_period_size(params
) << rme96
->playback_frlog
!=
1028 rme96
->capture_periodsize
)
1034 rme96
->playback_periodsize
=
1035 params_period_size(params
) << rme96
->playback_frlog
;
1036 snd_rme96_set_period_properties(rme96
, rme96
->playback_periodsize
);
1038 if ((rme96
->wcreg
& RME96_WCR_ADAT
) == 0) {
1039 rme96
->wcreg
&= ~(RME96_WCR_PRO
| RME96_WCR_DOLBY
| RME96_WCR_EMP
);
1040 writel(rme96
->wcreg
|= rme96
->wcreg_spdif_stream
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1045 spin_unlock_irq(&rme96
->lock
);
1046 if (apply_dac_volume
) {
1047 usleep_range(3000, 10000);
1048 snd_rme96_apply_dac_volume(rme96
);
1055 snd_rme96_capture_hw_params(struct snd_pcm_substream
*substream
,
1056 struct snd_pcm_hw_params
*params
)
1058 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1059 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1060 int err
, isadat
, rate
;
1062 runtime
->dma_area
= (void __force
*)(rme96
->iobase
+
1063 RME96_IO_REC_BUFFER
);
1064 runtime
->dma_addr
= rme96
->port
+ RME96_IO_REC_BUFFER
;
1065 runtime
->dma_bytes
= RME96_BUFFER_SIZE
;
1067 spin_lock_irq(&rme96
->lock
);
1068 if ((err
= snd_rme96_capture_setformat(rme96
, params_format(params
))) < 0) {
1069 spin_unlock_irq(&rme96
->lock
);
1072 if (snd_rme96_getinputtype(rme96
) == RME96_INPUT_ANALOG
) {
1073 if ((err
= snd_rme96_capture_analog_setrate(rme96
,
1074 params_rate(params
))) < 0)
1076 spin_unlock_irq(&rme96
->lock
);
1079 } else if ((rate
= snd_rme96_capture_getrate(rme96
, &isadat
)) > 0) {
1080 if ((int)params_rate(params
) != rate
) {
1081 spin_unlock_irq(&rme96
->lock
);
1084 if ((isadat
&& runtime
->hw
.channels_min
== 2) ||
1085 (!isadat
&& runtime
->hw
.channels_min
== 8))
1087 spin_unlock_irq(&rme96
->lock
);
1091 snd_rme96_setframelog(rme96
, params_channels(params
), 0);
1092 if (rme96
->playback_periodsize
!= 0) {
1093 if (params_period_size(params
) << rme96
->capture_frlog
!=
1094 rme96
->playback_periodsize
)
1096 spin_unlock_irq(&rme96
->lock
);
1100 rme96
->capture_periodsize
=
1101 params_period_size(params
) << rme96
->capture_frlog
;
1102 snd_rme96_set_period_properties(rme96
, rme96
->capture_periodsize
);
1103 spin_unlock_irq(&rme96
->lock
);
1109 snd_rme96_trigger(struct rme96
*rme96
,
1112 if (op
& RME96_TB_RESET_PLAYPOS
)
1113 writel(0, rme96
->iobase
+ RME96_IO_RESET_PLAY_POS
);
1114 if (op
& RME96_TB_RESET_CAPTUREPOS
)
1115 writel(0, rme96
->iobase
+ RME96_IO_RESET_REC_POS
);
1116 if (op
& RME96_TB_CLEAR_PLAYBACK_IRQ
) {
1117 rme96
->rcreg
= readl(rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1118 if (rme96
->rcreg
& RME96_RCR_IRQ
)
1119 writel(0, rme96
->iobase
+ RME96_IO_CONFIRM_PLAY_IRQ
);
1121 if (op
& RME96_TB_CLEAR_CAPTURE_IRQ
) {
1122 rme96
->rcreg
= readl(rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1123 if (rme96
->rcreg
& RME96_RCR_IRQ_2
)
1124 writel(0, rme96
->iobase
+ RME96_IO_CONFIRM_REC_IRQ
);
1126 if (op
& RME96_TB_START_PLAYBACK
)
1127 rme96
->wcreg
|= RME96_WCR_START
;
1128 if (op
& RME96_TB_STOP_PLAYBACK
)
1129 rme96
->wcreg
&= ~RME96_WCR_START
;
1130 if (op
& RME96_TB_START_CAPTURE
)
1131 rme96
->wcreg
|= RME96_WCR_START_2
;
1132 if (op
& RME96_TB_STOP_CAPTURE
)
1133 rme96
->wcreg
&= ~RME96_WCR_START_2
;
1134 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1140 snd_rme96_interrupt(int irq
,
1143 struct rme96
*rme96
= (struct rme96
*)dev_id
;
1145 rme96
->rcreg
= readl(rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1146 /* fastpath out, to ease interrupt sharing */
1147 if (!((rme96
->rcreg
& RME96_RCR_IRQ
) ||
1148 (rme96
->rcreg
& RME96_RCR_IRQ_2
)))
1153 if (rme96
->rcreg
& RME96_RCR_IRQ
) {
1155 snd_pcm_period_elapsed(rme96
->playback_substream
);
1156 writel(0, rme96
->iobase
+ RME96_IO_CONFIRM_PLAY_IRQ
);
1158 if (rme96
->rcreg
& RME96_RCR_IRQ_2
) {
1160 snd_pcm_period_elapsed(rme96
->capture_substream
);
1161 writel(0, rme96
->iobase
+ RME96_IO_CONFIRM_REC_IRQ
);
1166 static const unsigned int period_bytes
[] = { RME96_SMALL_BLOCK_SIZE
, RME96_LARGE_BLOCK_SIZE
};
1168 static const struct snd_pcm_hw_constraint_list hw_constraints_period_bytes
= {
1169 .count
= ARRAY_SIZE(period_bytes
),
1170 .list
= period_bytes
,
1175 rme96_set_buffer_size_constraint(struct rme96
*rme96
,
1176 struct snd_pcm_runtime
*runtime
)
1180 snd_pcm_hw_constraint_single(runtime
, SNDRV_PCM_HW_PARAM_BUFFER_BYTES
,
1182 if ((size
= rme96
->playback_periodsize
) != 0 ||
1183 (size
= rme96
->capture_periodsize
) != 0)
1184 snd_pcm_hw_constraint_single(runtime
,
1185 SNDRV_PCM_HW_PARAM_PERIOD_BYTES
,
1188 snd_pcm_hw_constraint_list(runtime
, 0,
1189 SNDRV_PCM_HW_PARAM_PERIOD_BYTES
,
1190 &hw_constraints_period_bytes
);
1194 snd_rme96_playback_spdif_open(struct snd_pcm_substream
*substream
)
1197 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1198 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1200 snd_pcm_set_sync(substream
);
1201 spin_lock_irq(&rme96
->lock
);
1202 if (rme96
->playback_substream
) {
1203 spin_unlock_irq(&rme96
->lock
);
1206 rme96
->wcreg
&= ~RME96_WCR_ADAT
;
1207 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1208 rme96
->playback_substream
= substream
;
1209 spin_unlock_irq(&rme96
->lock
);
1211 runtime
->hw
= snd_rme96_playback_spdif_info
;
1212 if (!(rme96
->wcreg
& RME96_WCR_MASTER
) &&
1213 snd_rme96_getinputtype(rme96
) != RME96_INPUT_ANALOG
&&
1214 (rate
= snd_rme96_capture_getrate(rme96
, &dummy
)) > 0)
1217 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
1218 runtime
->hw
.rate_min
= rate
;
1219 runtime
->hw
.rate_max
= rate
;
1221 rme96_set_buffer_size_constraint(rme96
, runtime
);
1223 rme96
->wcreg_spdif_stream
= rme96
->wcreg_spdif
;
1224 rme96
->spdif_ctl
->vd
[0].access
&= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
1225 snd_ctl_notify(rme96
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
1226 SNDRV_CTL_EVENT_MASK_INFO
, &rme96
->spdif_ctl
->id
);
1231 snd_rme96_capture_spdif_open(struct snd_pcm_substream
*substream
)
1234 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1235 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1237 snd_pcm_set_sync(substream
);
1238 runtime
->hw
= snd_rme96_capture_spdif_info
;
1239 if (snd_rme96_getinputtype(rme96
) != RME96_INPUT_ANALOG
&&
1240 (rate
= snd_rme96_capture_getrate(rme96
, &isadat
)) > 0)
1245 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
1246 runtime
->hw
.rate_min
= rate
;
1247 runtime
->hw
.rate_max
= rate
;
1250 spin_lock_irq(&rme96
->lock
);
1251 if (rme96
->capture_substream
) {
1252 spin_unlock_irq(&rme96
->lock
);
1255 rme96
->capture_substream
= substream
;
1256 spin_unlock_irq(&rme96
->lock
);
1258 rme96_set_buffer_size_constraint(rme96
, runtime
);
1263 snd_rme96_playback_adat_open(struct snd_pcm_substream
*substream
)
1266 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1267 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1269 snd_pcm_set_sync(substream
);
1270 spin_lock_irq(&rme96
->lock
);
1271 if (rme96
->playback_substream
) {
1272 spin_unlock_irq(&rme96
->lock
);
1275 rme96
->wcreg
|= RME96_WCR_ADAT
;
1276 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1277 rme96
->playback_substream
= substream
;
1278 spin_unlock_irq(&rme96
->lock
);
1280 runtime
->hw
= snd_rme96_playback_adat_info
;
1281 if (!(rme96
->wcreg
& RME96_WCR_MASTER
) &&
1282 snd_rme96_getinputtype(rme96
) != RME96_INPUT_ANALOG
&&
1283 (rate
= snd_rme96_capture_getrate(rme96
, &dummy
)) > 0)
1286 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
1287 runtime
->hw
.rate_min
= rate
;
1288 runtime
->hw
.rate_max
= rate
;
1290 rme96_set_buffer_size_constraint(rme96
, runtime
);
1295 snd_rme96_capture_adat_open(struct snd_pcm_substream
*substream
)
1298 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1299 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1301 snd_pcm_set_sync(substream
);
1302 runtime
->hw
= snd_rme96_capture_adat_info
;
1303 if (snd_rme96_getinputtype(rme96
) == RME96_INPUT_ANALOG
) {
1304 /* makes no sense to use analog input. Note that analog
1305 expension cards AEB4/8-I are RME96_INPUT_INTERNAL */
1308 if ((rate
= snd_rme96_capture_getrate(rme96
, &isadat
)) > 0) {
1312 runtime
->hw
.rates
= snd_pcm_rate_to_rate_bit(rate
);
1313 runtime
->hw
.rate_min
= rate
;
1314 runtime
->hw
.rate_max
= rate
;
1317 spin_lock_irq(&rme96
->lock
);
1318 if (rme96
->capture_substream
) {
1319 spin_unlock_irq(&rme96
->lock
);
1322 rme96
->capture_substream
= substream
;
1323 spin_unlock_irq(&rme96
->lock
);
1325 rme96_set_buffer_size_constraint(rme96
, runtime
);
1330 snd_rme96_playback_close(struct snd_pcm_substream
*substream
)
1332 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1335 spin_lock_irq(&rme96
->lock
);
1336 if (RME96_ISPLAYING(rme96
)) {
1337 snd_rme96_trigger(rme96
, RME96_STOP_PLAYBACK
);
1339 rme96
->playback_substream
= NULL
;
1340 rme96
->playback_periodsize
= 0;
1341 spdif
= (rme96
->wcreg
& RME96_WCR_ADAT
) == 0;
1342 spin_unlock_irq(&rme96
->lock
);
1344 rme96
->spdif_ctl
->vd
[0].access
|= SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
1345 snd_ctl_notify(rme96
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
1346 SNDRV_CTL_EVENT_MASK_INFO
, &rme96
->spdif_ctl
->id
);
1352 snd_rme96_capture_close(struct snd_pcm_substream
*substream
)
1354 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1356 spin_lock_irq(&rme96
->lock
);
1357 if (RME96_ISRECORDING(rme96
)) {
1358 snd_rme96_trigger(rme96
, RME96_STOP_CAPTURE
);
1360 rme96
->capture_substream
= NULL
;
1361 rme96
->capture_periodsize
= 0;
1362 spin_unlock_irq(&rme96
->lock
);
1367 snd_rme96_playback_prepare(struct snd_pcm_substream
*substream
)
1369 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1371 spin_lock_irq(&rme96
->lock
);
1372 if (RME96_ISPLAYING(rme96
)) {
1373 snd_rme96_trigger(rme96
, RME96_STOP_PLAYBACK
);
1375 writel(0, rme96
->iobase
+ RME96_IO_RESET_PLAY_POS
);
1376 spin_unlock_irq(&rme96
->lock
);
1381 snd_rme96_capture_prepare(struct snd_pcm_substream
*substream
)
1383 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1385 spin_lock_irq(&rme96
->lock
);
1386 if (RME96_ISRECORDING(rme96
)) {
1387 snd_rme96_trigger(rme96
, RME96_STOP_CAPTURE
);
1389 writel(0, rme96
->iobase
+ RME96_IO_RESET_REC_POS
);
1390 spin_unlock_irq(&rme96
->lock
);
1395 snd_rme96_playback_trigger(struct snd_pcm_substream
*substream
,
1398 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1399 struct snd_pcm_substream
*s
;
1402 snd_pcm_group_for_each_entry(s
, substream
) {
1403 if (snd_pcm_substream_chip(s
) == rme96
)
1404 snd_pcm_trigger_done(s
, substream
);
1407 sync
= (rme96
->playback_substream
&& rme96
->capture_substream
) &&
1408 (rme96
->playback_substream
->group
==
1409 rme96
->capture_substream
->group
);
1412 case SNDRV_PCM_TRIGGER_START
:
1413 if (!RME96_ISPLAYING(rme96
)) {
1414 if (substream
!= rme96
->playback_substream
)
1416 snd_rme96_trigger(rme96
, sync
? RME96_START_BOTH
1417 : RME96_START_PLAYBACK
);
1421 case SNDRV_PCM_TRIGGER_SUSPEND
:
1422 case SNDRV_PCM_TRIGGER_STOP
:
1423 if (RME96_ISPLAYING(rme96
)) {
1424 if (substream
!= rme96
->playback_substream
)
1426 snd_rme96_trigger(rme96
, sync
? RME96_STOP_BOTH
1427 : RME96_STOP_PLAYBACK
);
1431 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
1432 if (RME96_ISPLAYING(rme96
))
1433 snd_rme96_trigger(rme96
, sync
? RME96_STOP_BOTH
1434 : RME96_STOP_PLAYBACK
);
1437 case SNDRV_PCM_TRIGGER_RESUME
:
1438 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
1439 if (!RME96_ISPLAYING(rme96
))
1440 snd_rme96_trigger(rme96
, sync
? RME96_RESUME_BOTH
1441 : RME96_RESUME_PLAYBACK
);
1452 snd_rme96_capture_trigger(struct snd_pcm_substream
*substream
,
1455 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1456 struct snd_pcm_substream
*s
;
1459 snd_pcm_group_for_each_entry(s
, substream
) {
1460 if (snd_pcm_substream_chip(s
) == rme96
)
1461 snd_pcm_trigger_done(s
, substream
);
1464 sync
= (rme96
->playback_substream
&& rme96
->capture_substream
) &&
1465 (rme96
->playback_substream
->group
==
1466 rme96
->capture_substream
->group
);
1469 case SNDRV_PCM_TRIGGER_START
:
1470 if (!RME96_ISRECORDING(rme96
)) {
1471 if (substream
!= rme96
->capture_substream
)
1473 snd_rme96_trigger(rme96
, sync
? RME96_START_BOTH
1474 : RME96_START_CAPTURE
);
1478 case SNDRV_PCM_TRIGGER_SUSPEND
:
1479 case SNDRV_PCM_TRIGGER_STOP
:
1480 if (RME96_ISRECORDING(rme96
)) {
1481 if (substream
!= rme96
->capture_substream
)
1483 snd_rme96_trigger(rme96
, sync
? RME96_STOP_BOTH
1484 : RME96_STOP_CAPTURE
);
1488 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
1489 if (RME96_ISRECORDING(rme96
))
1490 snd_rme96_trigger(rme96
, sync
? RME96_STOP_BOTH
1491 : RME96_STOP_CAPTURE
);
1494 case SNDRV_PCM_TRIGGER_RESUME
:
1495 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
1496 if (!RME96_ISRECORDING(rme96
))
1497 snd_rme96_trigger(rme96
, sync
? RME96_RESUME_BOTH
1498 : RME96_RESUME_CAPTURE
);
1508 static snd_pcm_uframes_t
1509 snd_rme96_playback_pointer(struct snd_pcm_substream
*substream
)
1511 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1512 return snd_rme96_playback_ptr(rme96
);
1515 static snd_pcm_uframes_t
1516 snd_rme96_capture_pointer(struct snd_pcm_substream
*substream
)
1518 struct rme96
*rme96
= snd_pcm_substream_chip(substream
);
1519 return snd_rme96_capture_ptr(rme96
);
1522 static const struct snd_pcm_ops snd_rme96_playback_spdif_ops
= {
1523 .open
= snd_rme96_playback_spdif_open
,
1524 .close
= snd_rme96_playback_close
,
1525 .ioctl
= snd_pcm_lib_ioctl
,
1526 .hw_params
= snd_rme96_playback_hw_params
,
1527 .prepare
= snd_rme96_playback_prepare
,
1528 .trigger
= snd_rme96_playback_trigger
,
1529 .pointer
= snd_rme96_playback_pointer
,
1530 .copy_user
= snd_rme96_playback_copy
,
1531 .copy_kernel
= snd_rme96_playback_copy_kernel
,
1532 .fill_silence
= snd_rme96_playback_silence
,
1533 .mmap
= snd_pcm_lib_mmap_iomem
,
1536 static const struct snd_pcm_ops snd_rme96_capture_spdif_ops
= {
1537 .open
= snd_rme96_capture_spdif_open
,
1538 .close
= snd_rme96_capture_close
,
1539 .ioctl
= snd_pcm_lib_ioctl
,
1540 .hw_params
= snd_rme96_capture_hw_params
,
1541 .prepare
= snd_rme96_capture_prepare
,
1542 .trigger
= snd_rme96_capture_trigger
,
1543 .pointer
= snd_rme96_capture_pointer
,
1544 .copy_user
= snd_rme96_capture_copy
,
1545 .copy_kernel
= snd_rme96_capture_copy_kernel
,
1546 .mmap
= snd_pcm_lib_mmap_iomem
,
1549 static const struct snd_pcm_ops snd_rme96_playback_adat_ops
= {
1550 .open
= snd_rme96_playback_adat_open
,
1551 .close
= snd_rme96_playback_close
,
1552 .ioctl
= snd_pcm_lib_ioctl
,
1553 .hw_params
= snd_rme96_playback_hw_params
,
1554 .prepare
= snd_rme96_playback_prepare
,
1555 .trigger
= snd_rme96_playback_trigger
,
1556 .pointer
= snd_rme96_playback_pointer
,
1557 .copy_user
= snd_rme96_playback_copy
,
1558 .copy_kernel
= snd_rme96_playback_copy_kernel
,
1559 .fill_silence
= snd_rme96_playback_silence
,
1560 .mmap
= snd_pcm_lib_mmap_iomem
,
1563 static const struct snd_pcm_ops snd_rme96_capture_adat_ops
= {
1564 .open
= snd_rme96_capture_adat_open
,
1565 .close
= snd_rme96_capture_close
,
1566 .ioctl
= snd_pcm_lib_ioctl
,
1567 .hw_params
= snd_rme96_capture_hw_params
,
1568 .prepare
= snd_rme96_capture_prepare
,
1569 .trigger
= snd_rme96_capture_trigger
,
1570 .pointer
= snd_rme96_capture_pointer
,
1571 .copy_user
= snd_rme96_capture_copy
,
1572 .copy_kernel
= snd_rme96_capture_copy_kernel
,
1573 .mmap
= snd_pcm_lib_mmap_iomem
,
1577 snd_rme96_free(void *private_data
)
1579 struct rme96
*rme96
= (struct rme96
*)private_data
;
1584 if (rme96
->irq
>= 0) {
1585 snd_rme96_trigger(rme96
, RME96_STOP_BOTH
);
1586 rme96
->areg
&= ~RME96_AR_DAC_EN
;
1587 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
1588 free_irq(rme96
->irq
, (void *)rme96
);
1591 if (rme96
->iobase
) {
1592 iounmap(rme96
->iobase
);
1593 rme96
->iobase
= NULL
;
1596 pci_release_regions(rme96
->pci
);
1599 #ifdef CONFIG_PM_SLEEP
1600 vfree(rme96
->playback_suspend_buffer
);
1601 vfree(rme96
->capture_suspend_buffer
);
1603 pci_disable_device(rme96
->pci
);
1607 snd_rme96_free_spdif_pcm(struct snd_pcm
*pcm
)
1609 struct rme96
*rme96
= pcm
->private_data
;
1610 rme96
->spdif_pcm
= NULL
;
1614 snd_rme96_free_adat_pcm(struct snd_pcm
*pcm
)
1616 struct rme96
*rme96
= pcm
->private_data
;
1617 rme96
->adat_pcm
= NULL
;
1621 snd_rme96_create(struct rme96
*rme96
)
1623 struct pci_dev
*pci
= rme96
->pci
;
1627 spin_lock_init(&rme96
->lock
);
1629 if ((err
= pci_enable_device(pci
)) < 0)
1632 if ((err
= pci_request_regions(pci
, "RME96")) < 0)
1634 rme96
->port
= pci_resource_start(rme96
->pci
, 0);
1636 rme96
->iobase
= ioremap_nocache(rme96
->port
, RME96_IO_SIZE
);
1637 if (!rme96
->iobase
) {
1638 dev_err(rme96
->card
->dev
,
1639 "unable to remap memory region 0x%lx-0x%lx\n",
1640 rme96
->port
, rme96
->port
+ RME96_IO_SIZE
- 1);
1644 if (request_irq(pci
->irq
, snd_rme96_interrupt
, IRQF_SHARED
,
1645 KBUILD_MODNAME
, rme96
)) {
1646 dev_err(rme96
->card
->dev
, "unable to grab IRQ %d\n", pci
->irq
);
1649 rme96
->irq
= pci
->irq
;
1651 /* read the card's revision number */
1652 pci_read_config_byte(pci
, 8, &rme96
->rev
);
1654 /* set up ALSA pcm device for S/PDIF */
1655 if ((err
= snd_pcm_new(rme96
->card
, "Digi96 IEC958", 0,
1656 1, 1, &rme96
->spdif_pcm
)) < 0)
1660 rme96
->spdif_pcm
->private_data
= rme96
;
1661 rme96
->spdif_pcm
->private_free
= snd_rme96_free_spdif_pcm
;
1662 strcpy(rme96
->spdif_pcm
->name
, "Digi96 IEC958");
1663 snd_pcm_set_ops(rme96
->spdif_pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_rme96_playback_spdif_ops
);
1664 snd_pcm_set_ops(rme96
->spdif_pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_rme96_capture_spdif_ops
);
1666 rme96
->spdif_pcm
->info_flags
= 0;
1668 /* set up ALSA pcm device for ADAT */
1669 if (pci
->device
== PCI_DEVICE_ID_RME_DIGI96
) {
1670 /* ADAT is not available on the base model */
1671 rme96
->adat_pcm
= NULL
;
1673 if ((err
= snd_pcm_new(rme96
->card
, "Digi96 ADAT", 1,
1674 1, 1, &rme96
->adat_pcm
)) < 0)
1678 rme96
->adat_pcm
->private_data
= rme96
;
1679 rme96
->adat_pcm
->private_free
= snd_rme96_free_adat_pcm
;
1680 strcpy(rme96
->adat_pcm
->name
, "Digi96 ADAT");
1681 snd_pcm_set_ops(rme96
->adat_pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_rme96_playback_adat_ops
);
1682 snd_pcm_set_ops(rme96
->adat_pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_rme96_capture_adat_ops
);
1684 rme96
->adat_pcm
->info_flags
= 0;
1687 rme96
->playback_periodsize
= 0;
1688 rme96
->capture_periodsize
= 0;
1690 /* make sure playback/capture is stopped, if by some reason active */
1691 snd_rme96_trigger(rme96
, RME96_STOP_BOTH
);
1693 /* set default values in registers */
1695 RME96_WCR_FREQ_1
| /* set 44.1 kHz playback */
1696 RME96_WCR_SEL
| /* normal playback */
1697 RME96_WCR_MASTER
| /* set to master clock mode */
1698 RME96_WCR_INP_0
; /* set coaxial input */
1700 rme96
->areg
= RME96_AR_FREQPAD_1
; /* set 44.1 kHz analog capture */
1702 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1703 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
1706 writel(rme96
->areg
| RME96_AR_PD2
,
1707 rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
1708 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
1710 /* reset and enable the DAC (order is important). */
1711 snd_rme96_reset_dac(rme96
);
1712 rme96
->areg
|= RME96_AR_DAC_EN
;
1713 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
1715 /* reset playback and record buffer pointers */
1716 writel(0, rme96
->iobase
+ RME96_IO_RESET_PLAY_POS
);
1717 writel(0, rme96
->iobase
+ RME96_IO_RESET_REC_POS
);
1720 rme96
->vol
[0] = rme96
->vol
[1] = 0;
1721 if (RME96_HAS_ANALOG_OUT(rme96
)) {
1722 snd_rme96_apply_dac_volume(rme96
);
1725 /* init switch interface */
1726 if ((err
= snd_rme96_create_switches(rme96
->card
, rme96
)) < 0) {
1730 /* init proc interface */
1731 snd_rme96_proc_init(rme96
);
1741 snd_rme96_proc_read(struct snd_info_entry
*entry
, struct snd_info_buffer
*buffer
)
1744 struct rme96
*rme96
= entry
->private_data
;
1746 rme96
->rcreg
= readl(rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1748 snd_iprintf(buffer
, rme96
->card
->longname
);
1749 snd_iprintf(buffer
, " (index #%d)\n", rme96
->card
->number
+ 1);
1751 snd_iprintf(buffer
, "\nGeneral settings\n");
1752 if (rme96
->wcreg
& RME96_WCR_IDIS
) {
1753 snd_iprintf(buffer
, " period size: N/A (interrupts "
1755 } else if (rme96
->wcreg
& RME96_WCR_ISEL
) {
1756 snd_iprintf(buffer
, " period size: 2048 bytes\n");
1758 snd_iprintf(buffer
, " period size: 8192 bytes\n");
1760 snd_iprintf(buffer
, "\nInput settings\n");
1761 switch (snd_rme96_getinputtype(rme96
)) {
1762 case RME96_INPUT_OPTICAL
:
1763 snd_iprintf(buffer
, " input: optical");
1765 case RME96_INPUT_COAXIAL
:
1766 snd_iprintf(buffer
, " input: coaxial");
1768 case RME96_INPUT_INTERNAL
:
1769 snd_iprintf(buffer
, " input: internal");
1771 case RME96_INPUT_XLR
:
1772 snd_iprintf(buffer
, " input: XLR");
1774 case RME96_INPUT_ANALOG
:
1775 snd_iprintf(buffer
, " input: analog");
1778 if (snd_rme96_capture_getrate(rme96
, &n
) < 0) {
1779 snd_iprintf(buffer
, "\n sample rate: no valid signal\n");
1782 snd_iprintf(buffer
, " (8 channels)\n");
1784 snd_iprintf(buffer
, " (2 channels)\n");
1786 snd_iprintf(buffer
, " sample rate: %d Hz\n",
1787 snd_rme96_capture_getrate(rme96
, &n
));
1789 if (rme96
->wcreg
& RME96_WCR_MODE24_2
) {
1790 snd_iprintf(buffer
, " sample format: 24 bit\n");
1792 snd_iprintf(buffer
, " sample format: 16 bit\n");
1795 snd_iprintf(buffer
, "\nOutput settings\n");
1796 if (rme96
->wcreg
& RME96_WCR_SEL
) {
1797 snd_iprintf(buffer
, " output signal: normal playback\n");
1799 snd_iprintf(buffer
, " output signal: same as input\n");
1801 snd_iprintf(buffer
, " sample rate: %d Hz\n",
1802 snd_rme96_playback_getrate(rme96
));
1803 if (rme96
->wcreg
& RME96_WCR_MODE24
) {
1804 snd_iprintf(buffer
, " sample format: 24 bit\n");
1806 snd_iprintf(buffer
, " sample format: 16 bit\n");
1808 if (rme96
->areg
& RME96_AR_WSEL
) {
1809 snd_iprintf(buffer
, " sample clock source: word clock\n");
1810 } else if (rme96
->wcreg
& RME96_WCR_MASTER
) {
1811 snd_iprintf(buffer
, " sample clock source: internal\n");
1812 } else if (snd_rme96_getinputtype(rme96
) == RME96_INPUT_ANALOG
) {
1813 snd_iprintf(buffer
, " sample clock source: autosync (internal anyway due to analog input setting)\n");
1814 } else if (snd_rme96_capture_getrate(rme96
, &n
) < 0) {
1815 snd_iprintf(buffer
, " sample clock source: autosync (internal anyway due to no valid signal)\n");
1817 snd_iprintf(buffer
, " sample clock source: autosync\n");
1819 if (rme96
->wcreg
& RME96_WCR_PRO
) {
1820 snd_iprintf(buffer
, " format: AES/EBU (professional)\n");
1822 snd_iprintf(buffer
, " format: IEC958 (consumer)\n");
1824 if (rme96
->wcreg
& RME96_WCR_EMP
) {
1825 snd_iprintf(buffer
, " emphasis: on\n");
1827 snd_iprintf(buffer
, " emphasis: off\n");
1829 if (rme96
->wcreg
& RME96_WCR_DOLBY
) {
1830 snd_iprintf(buffer
, " non-audio (dolby): on\n");
1832 snd_iprintf(buffer
, " non-audio (dolby): off\n");
1834 if (RME96_HAS_ANALOG_IN(rme96
)) {
1835 snd_iprintf(buffer
, "\nAnalog output settings\n");
1836 switch (snd_rme96_getmontracks(rme96
)) {
1837 case RME96_MONITOR_TRACKS_1_2
:
1838 snd_iprintf(buffer
, " monitored ADAT tracks: 1+2\n");
1840 case RME96_MONITOR_TRACKS_3_4
:
1841 snd_iprintf(buffer
, " monitored ADAT tracks: 3+4\n");
1843 case RME96_MONITOR_TRACKS_5_6
:
1844 snd_iprintf(buffer
, " monitored ADAT tracks: 5+6\n");
1846 case RME96_MONITOR_TRACKS_7_8
:
1847 snd_iprintf(buffer
, " monitored ADAT tracks: 7+8\n");
1850 switch (snd_rme96_getattenuation(rme96
)) {
1851 case RME96_ATTENUATION_0
:
1852 snd_iprintf(buffer
, " attenuation: 0 dB\n");
1854 case RME96_ATTENUATION_6
:
1855 snd_iprintf(buffer
, " attenuation: -6 dB\n");
1857 case RME96_ATTENUATION_12
:
1858 snd_iprintf(buffer
, " attenuation: -12 dB\n");
1860 case RME96_ATTENUATION_18
:
1861 snd_iprintf(buffer
, " attenuation: -18 dB\n");
1864 snd_iprintf(buffer
, " volume left: %u\n", rme96
->vol
[0]);
1865 snd_iprintf(buffer
, " volume right: %u\n", rme96
->vol
[1]);
1869 static void snd_rme96_proc_init(struct rme96
*rme96
)
1871 struct snd_info_entry
*entry
;
1873 if (! snd_card_proc_new(rme96
->card
, "rme96", &entry
))
1874 snd_info_set_text_ops(entry
, rme96
, snd_rme96_proc_read
);
1881 #define snd_rme96_info_loopback_control snd_ctl_boolean_mono_info
1884 snd_rme96_get_loopback_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1886 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
1888 spin_lock_irq(&rme96
->lock
);
1889 ucontrol
->value
.integer
.value
[0] = rme96
->wcreg
& RME96_WCR_SEL
? 0 : 1;
1890 spin_unlock_irq(&rme96
->lock
);
1894 snd_rme96_put_loopback_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1896 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
1900 val
= ucontrol
->value
.integer
.value
[0] ? 0 : RME96_WCR_SEL
;
1901 spin_lock_irq(&rme96
->lock
);
1902 val
= (rme96
->wcreg
& ~RME96_WCR_SEL
) | val
;
1903 change
= val
!= rme96
->wcreg
;
1905 writel(val
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
1906 spin_unlock_irq(&rme96
->lock
);
1911 snd_rme96_info_inputtype_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1913 static const char * const _texts
[5] = {
1914 "Optical", "Coaxial", "Internal", "XLR", "Analog"
1916 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
1917 const char *texts
[5] = {
1918 _texts
[0], _texts
[1], _texts
[2], _texts
[3], _texts
[4]
1922 switch (rme96
->pci
->device
) {
1923 case PCI_DEVICE_ID_RME_DIGI96
:
1924 case PCI_DEVICE_ID_RME_DIGI96_8
:
1927 case PCI_DEVICE_ID_RME_DIGI96_8_PRO
:
1930 case PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
:
1931 if (rme96
->rev
> 4) {
1934 texts
[3] = _texts
[4]; /* Analog instead of XLR */
1944 return snd_ctl_enum_info(uinfo
, 1, num_items
, texts
);
1947 snd_rme96_get_inputtype_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1949 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
1950 unsigned int items
= 3;
1952 spin_lock_irq(&rme96
->lock
);
1953 ucontrol
->value
.enumerated
.item
[0] = snd_rme96_getinputtype(rme96
);
1955 switch (rme96
->pci
->device
) {
1956 case PCI_DEVICE_ID_RME_DIGI96
:
1957 case PCI_DEVICE_ID_RME_DIGI96_8
:
1960 case PCI_DEVICE_ID_RME_DIGI96_8_PRO
:
1963 case PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
:
1964 if (rme96
->rev
> 4) {
1965 /* for handling PST case, (INPUT_ANALOG is moved to INPUT_XLR */
1966 if (ucontrol
->value
.enumerated
.item
[0] == RME96_INPUT_ANALOG
) {
1967 ucontrol
->value
.enumerated
.item
[0] = RME96_INPUT_XLR
;
1978 if (ucontrol
->value
.enumerated
.item
[0] >= items
) {
1979 ucontrol
->value
.enumerated
.item
[0] = items
- 1;
1982 spin_unlock_irq(&rme96
->lock
);
1986 snd_rme96_put_inputtype_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1988 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
1990 int change
, items
= 3;
1992 switch (rme96
->pci
->device
) {
1993 case PCI_DEVICE_ID_RME_DIGI96
:
1994 case PCI_DEVICE_ID_RME_DIGI96_8
:
1997 case PCI_DEVICE_ID_RME_DIGI96_8_PRO
:
2000 case PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
:
2001 if (rme96
->rev
> 4) {
2011 val
= ucontrol
->value
.enumerated
.item
[0] % items
;
2013 /* special case for PST */
2014 if (rme96
->pci
->device
== PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
&& rme96
->rev
> 4) {
2015 if (val
== RME96_INPUT_XLR
) {
2016 val
= RME96_INPUT_ANALOG
;
2020 spin_lock_irq(&rme96
->lock
);
2021 change
= (int)val
!= snd_rme96_getinputtype(rme96
);
2022 snd_rme96_setinputtype(rme96
, val
);
2023 spin_unlock_irq(&rme96
->lock
);
2028 snd_rme96_info_clockmode_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
2030 static const char * const texts
[3] = { "AutoSync", "Internal", "Word" };
2032 return snd_ctl_enum_info(uinfo
, 1, 3, texts
);
2035 snd_rme96_get_clockmode_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2037 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2039 spin_lock_irq(&rme96
->lock
);
2040 ucontrol
->value
.enumerated
.item
[0] = snd_rme96_getclockmode(rme96
);
2041 spin_unlock_irq(&rme96
->lock
);
2045 snd_rme96_put_clockmode_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2047 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2051 val
= ucontrol
->value
.enumerated
.item
[0] % 3;
2052 spin_lock_irq(&rme96
->lock
);
2053 change
= (int)val
!= snd_rme96_getclockmode(rme96
);
2054 snd_rme96_setclockmode(rme96
, val
);
2055 spin_unlock_irq(&rme96
->lock
);
2060 snd_rme96_info_attenuation_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
2062 static const char * const texts
[4] = {
2063 "0 dB", "-6 dB", "-12 dB", "-18 dB"
2066 return snd_ctl_enum_info(uinfo
, 1, 4, texts
);
2069 snd_rme96_get_attenuation_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2071 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2073 spin_lock_irq(&rme96
->lock
);
2074 ucontrol
->value
.enumerated
.item
[0] = snd_rme96_getattenuation(rme96
);
2075 spin_unlock_irq(&rme96
->lock
);
2079 snd_rme96_put_attenuation_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2081 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2085 val
= ucontrol
->value
.enumerated
.item
[0] % 4;
2086 spin_lock_irq(&rme96
->lock
);
2088 change
= (int)val
!= snd_rme96_getattenuation(rme96
);
2089 snd_rme96_setattenuation(rme96
, val
);
2090 spin_unlock_irq(&rme96
->lock
);
2095 snd_rme96_info_montracks_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
2097 static const char * const texts
[4] = { "1+2", "3+4", "5+6", "7+8" };
2099 return snd_ctl_enum_info(uinfo
, 1, 4, texts
);
2102 snd_rme96_get_montracks_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2104 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2106 spin_lock_irq(&rme96
->lock
);
2107 ucontrol
->value
.enumerated
.item
[0] = snd_rme96_getmontracks(rme96
);
2108 spin_unlock_irq(&rme96
->lock
);
2112 snd_rme96_put_montracks_control(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2114 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2118 val
= ucontrol
->value
.enumerated
.item
[0] % 4;
2119 spin_lock_irq(&rme96
->lock
);
2120 change
= (int)val
!= snd_rme96_getmontracks(rme96
);
2121 snd_rme96_setmontracks(rme96
, val
);
2122 spin_unlock_irq(&rme96
->lock
);
2126 static u32
snd_rme96_convert_from_aes(struct snd_aes_iec958
*aes
)
2129 val
|= (aes
->status
[0] & IEC958_AES0_PROFESSIONAL
) ? RME96_WCR_PRO
: 0;
2130 val
|= (aes
->status
[0] & IEC958_AES0_NONAUDIO
) ? RME96_WCR_DOLBY
: 0;
2131 if (val
& RME96_WCR_PRO
)
2132 val
|= (aes
->status
[0] & IEC958_AES0_PRO_EMPHASIS_5015
) ? RME96_WCR_EMP
: 0;
2134 val
|= (aes
->status
[0] & IEC958_AES0_CON_EMPHASIS_5015
) ? RME96_WCR_EMP
: 0;
2138 static void snd_rme96_convert_to_aes(struct snd_aes_iec958
*aes
, u32 val
)
2140 aes
->status
[0] = ((val
& RME96_WCR_PRO
) ? IEC958_AES0_PROFESSIONAL
: 0) |
2141 ((val
& RME96_WCR_DOLBY
) ? IEC958_AES0_NONAUDIO
: 0);
2142 if (val
& RME96_WCR_PRO
)
2143 aes
->status
[0] |= (val
& RME96_WCR_EMP
) ? IEC958_AES0_PRO_EMPHASIS_5015
: 0;
2145 aes
->status
[0] |= (val
& RME96_WCR_EMP
) ? IEC958_AES0_CON_EMPHASIS_5015
: 0;
2148 static int snd_rme96_control_spdif_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
2150 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
2155 static int snd_rme96_control_spdif_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2157 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2159 snd_rme96_convert_to_aes(&ucontrol
->value
.iec958
, rme96
->wcreg_spdif
);
2163 static int snd_rme96_control_spdif_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2165 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2169 val
= snd_rme96_convert_from_aes(&ucontrol
->value
.iec958
);
2170 spin_lock_irq(&rme96
->lock
);
2171 change
= val
!= rme96
->wcreg_spdif
;
2172 rme96
->wcreg_spdif
= val
;
2173 spin_unlock_irq(&rme96
->lock
);
2177 static int snd_rme96_control_spdif_stream_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
2179 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
2184 static int snd_rme96_control_spdif_stream_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2186 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2188 snd_rme96_convert_to_aes(&ucontrol
->value
.iec958
, rme96
->wcreg_spdif_stream
);
2192 static int snd_rme96_control_spdif_stream_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2194 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2198 val
= snd_rme96_convert_from_aes(&ucontrol
->value
.iec958
);
2199 spin_lock_irq(&rme96
->lock
);
2200 change
= val
!= rme96
->wcreg_spdif_stream
;
2201 rme96
->wcreg_spdif_stream
= val
;
2202 rme96
->wcreg
&= ~(RME96_WCR_PRO
| RME96_WCR_DOLBY
| RME96_WCR_EMP
);
2203 rme96
->wcreg
|= val
;
2204 writel(rme96
->wcreg
, rme96
->iobase
+ RME96_IO_CONTROL_REGISTER
);
2205 spin_unlock_irq(&rme96
->lock
);
2209 static int snd_rme96_control_spdif_mask_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
2211 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_IEC958
;
2216 static int snd_rme96_control_spdif_mask_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
2218 ucontrol
->value
.iec958
.status
[0] = kcontrol
->private_value
;
2223 snd_rme96_dac_volume_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
2225 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2227 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_INTEGER
;
2229 uinfo
->value
.integer
.min
= 0;
2230 uinfo
->value
.integer
.max
= RME96_185X_MAX_OUT(rme96
);
2235 snd_rme96_dac_volume_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*u
)
2237 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2239 spin_lock_irq(&rme96
->lock
);
2240 u
->value
.integer
.value
[0] = rme96
->vol
[0];
2241 u
->value
.integer
.value
[1] = rme96
->vol
[1];
2242 spin_unlock_irq(&rme96
->lock
);
2248 snd_rme96_dac_volume_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*u
)
2250 struct rme96
*rme96
= snd_kcontrol_chip(kcontrol
);
2252 unsigned int vol
, maxvol
;
2255 if (!RME96_HAS_ANALOG_OUT(rme96
))
2257 maxvol
= RME96_185X_MAX_OUT(rme96
);
2258 spin_lock_irq(&rme96
->lock
);
2259 vol
= u
->value
.integer
.value
[0];
2260 if (vol
!= rme96
->vol
[0] && vol
<= maxvol
) {
2261 rme96
->vol
[0] = vol
;
2264 vol
= u
->value
.integer
.value
[1];
2265 if (vol
!= rme96
->vol
[1] && vol
<= maxvol
) {
2266 rme96
->vol
[1] = vol
;
2270 snd_rme96_apply_dac_volume(rme96
);
2271 spin_unlock_irq(&rme96
->lock
);
2276 static struct snd_kcontrol_new snd_rme96_controls
[] = {
2278 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
2279 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,DEFAULT
),
2280 .info
= snd_rme96_control_spdif_info
,
2281 .get
= snd_rme96_control_spdif_get
,
2282 .put
= snd_rme96_control_spdif_put
2285 .access
= SNDRV_CTL_ELEM_ACCESS_READWRITE
| SNDRV_CTL_ELEM_ACCESS_INACTIVE
,
2286 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
2287 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,PCM_STREAM
),
2288 .info
= snd_rme96_control_spdif_stream_info
,
2289 .get
= snd_rme96_control_spdif_stream_get
,
2290 .put
= snd_rme96_control_spdif_stream_put
2293 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
2294 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
2295 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,CON_MASK
),
2296 .info
= snd_rme96_control_spdif_mask_info
,
2297 .get
= snd_rme96_control_spdif_mask_get
,
2298 .private_value
= IEC958_AES0_NONAUDIO
|
2299 IEC958_AES0_PROFESSIONAL
|
2300 IEC958_AES0_CON_EMPHASIS
2303 .access
= SNDRV_CTL_ELEM_ACCESS_READ
,
2304 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
2305 .name
= SNDRV_CTL_NAME_IEC958("",PLAYBACK
,PRO_MASK
),
2306 .info
= snd_rme96_control_spdif_mask_info
,
2307 .get
= snd_rme96_control_spdif_mask_get
,
2308 .private_value
= IEC958_AES0_NONAUDIO
|
2309 IEC958_AES0_PROFESSIONAL
|
2310 IEC958_AES0_PRO_EMPHASIS
2313 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2314 .name
= "Input Connector",
2315 .info
= snd_rme96_info_inputtype_control
,
2316 .get
= snd_rme96_get_inputtype_control
,
2317 .put
= snd_rme96_put_inputtype_control
2320 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2321 .name
= "Loopback Input",
2322 .info
= snd_rme96_info_loopback_control
,
2323 .get
= snd_rme96_get_loopback_control
,
2324 .put
= snd_rme96_put_loopback_control
2327 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2328 .name
= "Sample Clock Source",
2329 .info
= snd_rme96_info_clockmode_control
,
2330 .get
= snd_rme96_get_clockmode_control
,
2331 .put
= snd_rme96_put_clockmode_control
2334 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2335 .name
= "Monitor Tracks",
2336 .info
= snd_rme96_info_montracks_control
,
2337 .get
= snd_rme96_get_montracks_control
,
2338 .put
= snd_rme96_put_montracks_control
2341 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2342 .name
= "Attenuation",
2343 .info
= snd_rme96_info_attenuation_control
,
2344 .get
= snd_rme96_get_attenuation_control
,
2345 .put
= snd_rme96_put_attenuation_control
2348 .iface
= SNDRV_CTL_ELEM_IFACE_MIXER
,
2349 .name
= "DAC Playback Volume",
2350 .info
= snd_rme96_dac_volume_info
,
2351 .get
= snd_rme96_dac_volume_get
,
2352 .put
= snd_rme96_dac_volume_put
2357 snd_rme96_create_switches(struct snd_card
*card
,
2358 struct rme96
*rme96
)
2361 struct snd_kcontrol
*kctl
;
2363 for (idx
= 0; idx
< 7; idx
++) {
2364 if ((err
= snd_ctl_add(card
, kctl
= snd_ctl_new1(&snd_rme96_controls
[idx
], rme96
))) < 0)
2366 if (idx
== 1) /* IEC958 (S/PDIF) Stream */
2367 rme96
->spdif_ctl
= kctl
;
2370 if (RME96_HAS_ANALOG_OUT(rme96
)) {
2371 for (idx
= 7; idx
< 10; idx
++)
2372 if ((err
= snd_ctl_add(card
, snd_ctl_new1(&snd_rme96_controls
[idx
], rme96
))) < 0)
2380 * Card initialisation
2383 #ifdef CONFIG_PM_SLEEP
2385 static int rme96_suspend(struct device
*dev
)
2387 struct snd_card
*card
= dev_get_drvdata(dev
);
2388 struct rme96
*rme96
= card
->private_data
;
2390 snd_power_change_state(card
, SNDRV_CTL_POWER_D3hot
);
2391 snd_pcm_suspend(rme96
->playback_substream
);
2392 snd_pcm_suspend(rme96
->capture_substream
);
2394 /* save capture & playback pointers */
2395 rme96
->playback_pointer
= readl(rme96
->iobase
+ RME96_IO_GET_PLAY_POS
)
2396 & RME96_RCR_AUDIO_ADDR_MASK
;
2397 rme96
->capture_pointer
= readl(rme96
->iobase
+ RME96_IO_GET_REC_POS
)
2398 & RME96_RCR_AUDIO_ADDR_MASK
;
2400 /* save playback and capture buffers */
2401 memcpy_fromio(rme96
->playback_suspend_buffer
,
2402 rme96
->iobase
+ RME96_IO_PLAY_BUFFER
, RME96_BUFFER_SIZE
);
2403 memcpy_fromio(rme96
->capture_suspend_buffer
,
2404 rme96
->iobase
+ RME96_IO_REC_BUFFER
, RME96_BUFFER_SIZE
);
2406 /* disable the DAC */
2407 rme96
->areg
&= ~RME96_AR_DAC_EN
;
2408 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
2412 static int rme96_resume(struct device
*dev
)
2414 struct snd_card
*card
= dev_get_drvdata(dev
);
2415 struct rme96
*rme96
= card
->private_data
;
2417 /* reset playback and record buffer pointers */
2418 writel(0, rme96
->iobase
+ RME96_IO_SET_PLAY_POS
2419 + rme96
->playback_pointer
);
2420 writel(0, rme96
->iobase
+ RME96_IO_SET_REC_POS
2421 + rme96
->capture_pointer
);
2423 /* restore playback and capture buffers */
2424 memcpy_toio(rme96
->iobase
+ RME96_IO_PLAY_BUFFER
,
2425 rme96
->playback_suspend_buffer
, RME96_BUFFER_SIZE
);
2426 memcpy_toio(rme96
->iobase
+ RME96_IO_REC_BUFFER
,
2427 rme96
->capture_suspend_buffer
, RME96_BUFFER_SIZE
);
2430 writel(rme96
->areg
| RME96_AR_PD2
,
2431 rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
2432 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
2434 /* reset and enable DAC, restore analog volume */
2435 snd_rme96_reset_dac(rme96
);
2436 rme96
->areg
|= RME96_AR_DAC_EN
;
2437 writel(rme96
->areg
, rme96
->iobase
+ RME96_IO_ADDITIONAL_REG
);
2438 if (RME96_HAS_ANALOG_OUT(rme96
)) {
2439 usleep_range(3000, 10000);
2440 snd_rme96_apply_dac_volume(rme96
);
2443 snd_power_change_state(card
, SNDRV_CTL_POWER_D0
);
2448 static SIMPLE_DEV_PM_OPS(rme96_pm
, rme96_suspend
, rme96_resume
);
2449 #define RME96_PM_OPS &rme96_pm
2451 #define RME96_PM_OPS NULL
2452 #endif /* CONFIG_PM_SLEEP */
2454 static void snd_rme96_card_free(struct snd_card
*card
)
2456 snd_rme96_free(card
->private_data
);
2460 snd_rme96_probe(struct pci_dev
*pci
,
2461 const struct pci_device_id
*pci_id
)
2464 struct rme96
*rme96
;
2465 struct snd_card
*card
;
2469 if (dev
>= SNDRV_CARDS
) {
2476 err
= snd_card_new(&pci
->dev
, index
[dev
], id
[dev
], THIS_MODULE
,
2477 sizeof(struct rme96
), &card
);
2480 card
->private_free
= snd_rme96_card_free
;
2481 rme96
= card
->private_data
;
2484 err
= snd_rme96_create(rme96
);
2488 #ifdef CONFIG_PM_SLEEP
2489 rme96
->playback_suspend_buffer
= vmalloc(RME96_BUFFER_SIZE
);
2490 if (!rme96
->playback_suspend_buffer
) {
2494 rme96
->capture_suspend_buffer
= vmalloc(RME96_BUFFER_SIZE
);
2495 if (!rme96
->capture_suspend_buffer
) {
2501 strcpy(card
->driver
, "Digi96");
2502 switch (rme96
->pci
->device
) {
2503 case PCI_DEVICE_ID_RME_DIGI96
:
2504 strcpy(card
->shortname
, "RME Digi96");
2506 case PCI_DEVICE_ID_RME_DIGI96_8
:
2507 strcpy(card
->shortname
, "RME Digi96/8");
2509 case PCI_DEVICE_ID_RME_DIGI96_8_PRO
:
2510 strcpy(card
->shortname
, "RME Digi96/8 PRO");
2512 case PCI_DEVICE_ID_RME_DIGI96_8_PAD_OR_PST
:
2513 pci_read_config_byte(rme96
->pci
, 8, &val
);
2515 strcpy(card
->shortname
, "RME Digi96/8 PAD");
2517 strcpy(card
->shortname
, "RME Digi96/8 PST");
2521 sprintf(card
->longname
, "%s at 0x%lx, irq %d", card
->shortname
,
2522 rme96
->port
, rme96
->irq
);
2523 err
= snd_card_register(card
);
2527 pci_set_drvdata(pci
, card
);
2531 snd_card_free(card
);
2535 static void snd_rme96_remove(struct pci_dev
*pci
)
2537 snd_card_free(pci_get_drvdata(pci
));
2540 static struct pci_driver rme96_driver
= {
2541 .name
= KBUILD_MODNAME
,
2542 .id_table
= snd_rme96_ids
,
2543 .probe
= snd_rme96_probe
,
2544 .remove
= snd_rme96_remove
,
2550 module_pci_driver(rme96_driver
);