1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*********************************************************************
4 * 2002/06/30 Karsten Wiese:
5 * removed kernel-version dependencies.
6 * ripped from linux kernel 2.4.18 (OSS Implementation) by me.
7 * In the OSS Version, this file is compiled to a separate MODULE,
8 * that is used by the pinnacle and the classic driver.
9 * since there is no classic driver for alsa yet (i dont have a classic
10 * & writing one blindfold is difficult) this file's object is statically
11 * linked into the pinnacle-driver-module for now. look for the string
12 * "uncomment this to make this a module again"
15 * the following is a copy of the 2.4.18 OSS FREE file-heading comment:
17 * msnd.c - Driver Base
19 * Turtle Beach MultiSound Sound Card Driver for Linux
21 * Copyright (C) 1998 Andrew Veliath
23 ********************************************************************/
25 #include <linux/kernel.h>
26 #include <linux/sched/signal.h>
27 #include <linux/types.h>
28 #include <linux/interrupt.h>
31 #include <linux/delay.h>
32 #include <linux/module.h>
34 #include <sound/core.h>
35 #include <sound/initval.h>
36 #include <sound/pcm.h>
37 #include <sound/pcm_params.h>
41 #define LOGNAME "msnd"
44 void snd_msnd_init_queue(void __iomem
*base
, int start
, int size
)
46 writew(PCTODSP_BASED(start
), base
+ JQS_wStart
);
47 writew(PCTODSP_OFFSET(size
) - 1, base
+ JQS_wSize
);
48 writew(0, base
+ JQS_wHead
);
49 writew(0, base
+ JQS_wTail
);
51 EXPORT_SYMBOL(snd_msnd_init_queue
);
53 static int snd_msnd_wait_TXDE(struct snd_msnd
*dev
)
55 unsigned int io
= dev
->io
;
59 if (inb(io
+ HP_ISR
) & HPISR_TXDE
)
65 static int snd_msnd_wait_HC0(struct snd_msnd
*dev
)
67 unsigned int io
= dev
->io
;
71 if (!(inb(io
+ HP_CVR
) & HPCVR_HC
))
77 int snd_msnd_send_dsp_cmd(struct snd_msnd
*dev
, u8 cmd
)
81 spin_lock_irqsave(&dev
->lock
, flags
);
82 if (snd_msnd_wait_HC0(dev
) == 0) {
83 outb(cmd
, dev
->io
+ HP_CVR
);
84 spin_unlock_irqrestore(&dev
->lock
, flags
);
87 spin_unlock_irqrestore(&dev
->lock
, flags
);
89 snd_printd(KERN_ERR LOGNAME
": Send DSP command timeout\n");
93 EXPORT_SYMBOL(snd_msnd_send_dsp_cmd
);
95 int snd_msnd_send_word(struct snd_msnd
*dev
, unsigned char high
,
96 unsigned char mid
, unsigned char low
)
98 unsigned int io
= dev
->io
;
100 if (snd_msnd_wait_TXDE(dev
) == 0) {
101 outb(high
, io
+ HP_TXH
);
102 outb(mid
, io
+ HP_TXM
);
103 outb(low
, io
+ HP_TXL
);
107 snd_printd(KERN_ERR LOGNAME
": Send host word timeout\n");
111 EXPORT_SYMBOL(snd_msnd_send_word
);
113 int snd_msnd_upload_host(struct snd_msnd
*dev
, const u8
*bin
, int len
)
118 snd_printk(KERN_ERR LOGNAME
119 ": Upload host data not multiple of 3!\n");
123 for (i
= 0; i
< len
; i
+= 3)
124 if (snd_msnd_send_word(dev
, bin
[i
], bin
[i
+ 1], bin
[i
+ 2]))
127 inb(dev
->io
+ HP_RXL
);
128 inb(dev
->io
+ HP_CVR
);
132 EXPORT_SYMBOL(snd_msnd_upload_host
);
134 int snd_msnd_enable_irq(struct snd_msnd
*dev
)
141 snd_printdd(LOGNAME
": Enabling IRQ\n");
143 spin_lock_irqsave(&dev
->lock
, flags
);
144 if (snd_msnd_wait_TXDE(dev
) == 0) {
145 outb(inb(dev
->io
+ HP_ICR
) | HPICR_TREQ
, dev
->io
+ HP_ICR
);
146 if (dev
->type
== msndClassic
)
147 outb(dev
->irqid
, dev
->io
+ HP_IRQM
);
149 outb(inb(dev
->io
+ HP_ICR
) & ~HPICR_TREQ
, dev
->io
+ HP_ICR
);
150 outb(inb(dev
->io
+ HP_ICR
) | HPICR_RREQ
, dev
->io
+ HP_ICR
);
151 enable_irq(dev
->irq
);
152 snd_msnd_init_queue(dev
->DSPQ
, dev
->dspq_data_buff
,
153 dev
->dspq_buff_size
);
154 spin_unlock_irqrestore(&dev
->lock
, flags
);
157 spin_unlock_irqrestore(&dev
->lock
, flags
);
159 snd_printd(KERN_ERR LOGNAME
": Enable IRQ failed\n");
163 EXPORT_SYMBOL(snd_msnd_enable_irq
);
165 int snd_msnd_disable_irq(struct snd_msnd
*dev
)
169 if (--dev
->irq_ref
> 0)
172 if (dev
->irq_ref
< 0)
173 snd_printd(KERN_WARNING LOGNAME
": IRQ ref count is %d\n",
176 snd_printdd(LOGNAME
": Disabling IRQ\n");
178 spin_lock_irqsave(&dev
->lock
, flags
);
179 if (snd_msnd_wait_TXDE(dev
) == 0) {
180 outb(inb(dev
->io
+ HP_ICR
) & ~HPICR_RREQ
, dev
->io
+ HP_ICR
);
181 if (dev
->type
== msndClassic
)
182 outb(HPIRQ_NONE
, dev
->io
+ HP_IRQM
);
183 disable_irq(dev
->irq
);
184 spin_unlock_irqrestore(&dev
->lock
, flags
);
187 spin_unlock_irqrestore(&dev
->lock
, flags
);
189 snd_printd(KERN_ERR LOGNAME
": Disable IRQ failed\n");
193 EXPORT_SYMBOL(snd_msnd_disable_irq
);
195 static inline long get_play_delay_jiffies(struct snd_msnd
*chip
, long size
)
197 long tmp
= (size
* HZ
* chip
->play_sample_size
) / 8;
198 return tmp
/ (chip
->play_sample_rate
* chip
->play_channels
);
201 static void snd_msnd_dsp_write_flush(struct snd_msnd
*chip
)
203 if (!(chip
->mode
& FMODE_WRITE
) || !test_bit(F_WRITING
, &chip
->flags
))
205 set_bit(F_WRITEFLUSH
, &chip
->flags
);
206 /* interruptible_sleep_on_timeout(
208 get_play_delay_jiffies(&chip, chip->DAPF.len));*/
209 clear_bit(F_WRITEFLUSH
, &chip
->flags
);
210 if (!signal_pending(current
))
211 schedule_timeout_interruptible(
212 get_play_delay_jiffies(chip
, chip
->play_period_bytes
));
213 clear_bit(F_WRITING
, &chip
->flags
);
216 void snd_msnd_dsp_halt(struct snd_msnd
*chip
, struct file
*file
)
218 if ((file
? file
->f_mode
: chip
->mode
) & FMODE_READ
) {
219 clear_bit(F_READING
, &chip
->flags
);
220 snd_msnd_send_dsp_cmd(chip
, HDEX_RECORD_STOP
);
221 snd_msnd_disable_irq(chip
);
223 snd_printd(KERN_INFO LOGNAME
224 ": Stopping read for %p\n", file
);
225 chip
->mode
&= ~FMODE_READ
;
227 clear_bit(F_AUDIO_READ_INUSE
, &chip
->flags
);
229 if ((file
? file
->f_mode
: chip
->mode
) & FMODE_WRITE
) {
230 if (test_bit(F_WRITING
, &chip
->flags
)) {
231 snd_msnd_dsp_write_flush(chip
);
232 snd_msnd_send_dsp_cmd(chip
, HDEX_PLAY_STOP
);
234 snd_msnd_disable_irq(chip
);
237 LOGNAME
": Stopping write for %p\n", file
);
238 chip
->mode
&= ~FMODE_WRITE
;
240 clear_bit(F_AUDIO_WRITE_INUSE
, &chip
->flags
);
243 EXPORT_SYMBOL(snd_msnd_dsp_halt
);
246 int snd_msnd_DARQ(struct snd_msnd
*chip
, int bank
)
248 int /*size, n,*/ timeout
= 3;
252 /* Increment the tail and check for queue wrap */
253 wTmp
= readw(chip
->DARQ
+ JQS_wTail
) + PCTODSP_OFFSET(DAQDS__size
);
254 if (wTmp
> readw(chip
->DARQ
+ JQS_wSize
))
256 while (wTmp
== readw(chip
->DARQ
+ JQS_wHead
) && timeout
--)
259 if (chip
->capturePeriods
== 2) {
260 void __iomem
*pDAQ
= chip
->mappedbase
+ DARQ_DATA_BUFF
+
261 bank
* DAQDS__size
+ DAQDS_wStart
;
262 unsigned short offset
= 0x3000 + chip
->capturePeriodBytes
;
264 if (readw(pDAQ
) != PCTODSP_BASED(0x3000))
266 writew(PCTODSP_BASED(offset
), pDAQ
);
269 writew(wTmp
, chip
->DARQ
+ JQS_wTail
);
272 /* Get our digital audio queue struct */
273 DAQD
= bank
* DAQDS__size
+ chip
->mappedbase
+ DARQ_DATA_BUFF
;
275 /* Get length of data */
276 size
= readw(DAQD
+ DAQDS_wSize
);
278 /* Read data from the head (unprotected bank 1 access okay
279 since this is only called inside an interrupt) */
280 outb(HPBLKSEL_1
, chip
->io
+ HP_BLKS
);
281 n
= msnd_fifo_write(&chip
->DARF
,
282 (char *)(chip
->base
+ bank
* DAR_BUFF_SIZE
),
285 outb(HPBLKSEL_0
, chip
->io
+ HP_BLKS
);
288 outb(HPBLKSEL_0
, chip
->io
+ HP_BLKS
);
293 EXPORT_SYMBOL(snd_msnd_DARQ
);
295 int snd_msnd_DAPQ(struct snd_msnd
*chip
, int start
)
298 int protect
= start
, nbanks
= 0;
300 static int play_banks_submitted
;
301 /* unsigned long flags;
302 spin_lock_irqsave(&chip->lock, flags); not necessary */
304 DAPQ_tail
= readw(chip
->DAPQ
+ JQS_wTail
);
305 while (DAPQ_tail
!= readw(chip
->DAPQ
+ JQS_wHead
) || start
) {
306 int bank_num
= DAPQ_tail
/ PCTODSP_OFFSET(DAQDS__size
);
310 play_banks_submitted
= 0;
313 /* Get our digital audio queue struct */
314 DAQD
= bank_num
* DAQDS__size
+ chip
->mappedbase
+
317 /* Write size of this bank */
318 writew(chip
->play_period_bytes
, DAQD
+ DAQDS_wSize
);
319 if (play_banks_submitted
< 3)
320 ++play_banks_submitted
;
321 else if (chip
->playPeriods
== 2) {
322 unsigned short offset
= chip
->play_period_bytes
;
324 if (readw(DAQD
+ DAQDS_wStart
) != PCTODSP_BASED(0x0))
327 writew(PCTODSP_BASED(offset
), DAQD
+ DAQDS_wStart
);
331 /* Then advance the tail */
334 snd_printd(KERN_INFO "B %X %lX\n",
335 bank_num, xtime.tv_usec);
338 DAPQ_tail
= (++bank_num
% 3) * PCTODSP_OFFSET(DAQDS__size
);
339 writew(DAPQ_tail
, chip
->DAPQ
+ JQS_wTail
);
340 /* Tell the DSP to play the bank */
341 snd_msnd_send_dsp_cmd(chip
, HDEX_PLAY_START
);
348 snd_printd(KERN_INFO "%lX\n", xtime.tv_usec);
350 /* spin_unlock_irqrestore(&chip->lock, flags); not necessary */
353 EXPORT_SYMBOL(snd_msnd_DAPQ
);
355 static void snd_msnd_play_reset_queue(struct snd_msnd
*chip
,
356 unsigned int pcm_periods
,
357 unsigned int pcm_count
)
360 void __iomem
*pDAQ
= chip
->mappedbase
+ DAPQ_DATA_BUFF
;
362 chip
->last_playbank
= -1;
363 chip
->playLimit
= pcm_count
* (pcm_periods
- 1);
364 chip
->playPeriods
= pcm_periods
;
365 writew(PCTODSP_OFFSET(0 * DAQDS__size
), chip
->DAPQ
+ JQS_wHead
);
366 writew(PCTODSP_OFFSET(0 * DAQDS__size
), chip
->DAPQ
+ JQS_wTail
);
368 chip
->play_period_bytes
= pcm_count
;
370 for (n
= 0; n
< pcm_periods
; ++n
, pDAQ
+= DAQDS__size
) {
371 writew(PCTODSP_BASED((u32
)(pcm_count
* n
)),
372 pDAQ
+ DAQDS_wStart
);
373 writew(0, pDAQ
+ DAQDS_wSize
);
374 writew(1, pDAQ
+ DAQDS_wFormat
);
375 writew(chip
->play_sample_size
, pDAQ
+ DAQDS_wSampleSize
);
376 writew(chip
->play_channels
, pDAQ
+ DAQDS_wChannels
);
377 writew(chip
->play_sample_rate
, pDAQ
+ DAQDS_wSampleRate
);
378 writew(HIMT_PLAY_DONE
* 0x100 + n
, pDAQ
+ DAQDS_wIntMsg
);
379 writew(n
, pDAQ
+ DAQDS_wFlags
);
383 static void snd_msnd_capture_reset_queue(struct snd_msnd
*chip
,
384 unsigned int pcm_periods
,
385 unsigned int pcm_count
)
389 /* unsigned long flags; */
391 /* snd_msnd_init_queue(chip->DARQ, DARQ_DATA_BUFF, DARQ_BUFF_SIZE); */
393 chip
->last_recbank
= 2;
394 chip
->captureLimit
= pcm_count
* (pcm_periods
- 1);
395 chip
->capturePeriods
= pcm_periods
;
396 writew(PCTODSP_OFFSET(0 * DAQDS__size
), chip
->DARQ
+ JQS_wHead
);
397 writew(PCTODSP_OFFSET(chip
->last_recbank
* DAQDS__size
),
398 chip
->DARQ
+ JQS_wTail
);
400 #if 0 /* Critical section: bank 1 access. this is how the OSS driver does it:*/
401 spin_lock_irqsave(&chip
->lock
, flags
);
402 outb(HPBLKSEL_1
, chip
->io
+ HP_BLKS
);
403 memset_io(chip
->mappedbase
, 0, DAR_BUFF_SIZE
* 3);
404 outb(HPBLKSEL_0
, chip
->io
+ HP_BLKS
);
405 spin_unlock_irqrestore(&chip
->lock
, flags
);
408 chip
->capturePeriodBytes
= pcm_count
;
409 snd_printdd("snd_msnd_capture_reset_queue() %i\n", pcm_count
);
411 pDAQ
= chip
->mappedbase
+ DARQ_DATA_BUFF
;
413 for (n
= 0; n
< pcm_periods
; ++n
, pDAQ
+= DAQDS__size
) {
414 u32 tmp
= pcm_count
* n
;
416 writew(PCTODSP_BASED(tmp
+ 0x3000), pDAQ
+ DAQDS_wStart
);
417 writew(pcm_count
, pDAQ
+ DAQDS_wSize
);
418 writew(1, pDAQ
+ DAQDS_wFormat
);
419 writew(chip
->capture_sample_size
, pDAQ
+ DAQDS_wSampleSize
);
420 writew(chip
->capture_channels
, pDAQ
+ DAQDS_wChannels
);
421 writew(chip
->capture_sample_rate
, pDAQ
+ DAQDS_wSampleRate
);
422 writew(HIMT_RECORD_DONE
* 0x100 + n
, pDAQ
+ DAQDS_wIntMsg
);
423 writew(n
, pDAQ
+ DAQDS_wFlags
);
427 static const struct snd_pcm_hardware snd_msnd_playback
= {
428 .info
= SNDRV_PCM_INFO_MMAP
|
429 SNDRV_PCM_INFO_INTERLEAVED
|
430 SNDRV_PCM_INFO_MMAP_VALID
|
431 SNDRV_PCM_INFO_BATCH
,
432 .formats
= SNDRV_PCM_FMTBIT_U8
| SNDRV_PCM_FMTBIT_S16_LE
,
433 .rates
= SNDRV_PCM_RATE_8000_48000
,
438 .buffer_bytes_max
= 0x3000,
439 .period_bytes_min
= 0x40,
440 .period_bytes_max
= 0x1800,
446 static const struct snd_pcm_hardware snd_msnd_capture
= {
447 .info
= SNDRV_PCM_INFO_MMAP
|
448 SNDRV_PCM_INFO_INTERLEAVED
|
449 SNDRV_PCM_INFO_MMAP_VALID
|
450 SNDRV_PCM_INFO_BATCH
,
451 .formats
= SNDRV_PCM_FMTBIT_U8
| SNDRV_PCM_FMTBIT_S16_LE
,
452 .rates
= SNDRV_PCM_RATE_8000_48000
,
457 .buffer_bytes_max
= 0x3000,
458 .period_bytes_min
= 0x40,
459 .period_bytes_max
= 0x1800,
466 static int snd_msnd_playback_open(struct snd_pcm_substream
*substream
)
468 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
469 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
471 set_bit(F_AUDIO_WRITE_INUSE
, &chip
->flags
);
472 clear_bit(F_WRITING
, &chip
->flags
);
473 snd_msnd_enable_irq(chip
);
475 runtime
->dma_area
= (__force
void *)chip
->mappedbase
;
476 runtime
->dma_bytes
= 0x3000;
478 chip
->playback_substream
= substream
;
479 runtime
->hw
= snd_msnd_playback
;
483 static int snd_msnd_playback_close(struct snd_pcm_substream
*substream
)
485 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
487 snd_msnd_disable_irq(chip
);
488 clear_bit(F_AUDIO_WRITE_INUSE
, &chip
->flags
);
493 static int snd_msnd_playback_hw_params(struct snd_pcm_substream
*substream
,
494 struct snd_pcm_hw_params
*params
)
497 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
498 void __iomem
*pDAQ
= chip
->mappedbase
+ DAPQ_DATA_BUFF
;
500 chip
->play_sample_size
= snd_pcm_format_width(params_format(params
));
501 chip
->play_channels
= params_channels(params
);
502 chip
->play_sample_rate
= params_rate(params
);
504 for (i
= 0; i
< 3; ++i
, pDAQ
+= DAQDS__size
) {
505 writew(chip
->play_sample_size
, pDAQ
+ DAQDS_wSampleSize
);
506 writew(chip
->play_channels
, pDAQ
+ DAQDS_wChannels
);
507 writew(chip
->play_sample_rate
, pDAQ
+ DAQDS_wSampleRate
);
509 /* dont do this here:
510 * snd_msnd_calibrate_adc(chip->play_sample_rate);
516 static int snd_msnd_playback_prepare(struct snd_pcm_substream
*substream
)
518 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
519 unsigned int pcm_size
= snd_pcm_lib_buffer_bytes(substream
);
520 unsigned int pcm_count
= snd_pcm_lib_period_bytes(substream
);
521 unsigned int pcm_periods
= pcm_size
/ pcm_count
;
523 snd_msnd_play_reset_queue(chip
, pcm_periods
, pcm_count
);
524 chip
->playDMAPos
= 0;
528 static int snd_msnd_playback_trigger(struct snd_pcm_substream
*substream
,
531 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
534 if (cmd
== SNDRV_PCM_TRIGGER_START
) {
535 snd_printdd("snd_msnd_playback_trigger(START)\n");
536 chip
->banksPlayed
= 0;
537 set_bit(F_WRITING
, &chip
->flags
);
538 snd_msnd_DAPQ(chip
, 1);
539 } else if (cmd
== SNDRV_PCM_TRIGGER_STOP
) {
540 snd_printdd("snd_msnd_playback_trigger(STop)\n");
541 /* interrupt diagnostic, comment this out later */
542 clear_bit(F_WRITING
, &chip
->flags
);
543 snd_msnd_send_dsp_cmd(chip
, HDEX_PLAY_STOP
);
545 snd_printd(KERN_ERR
"snd_msnd_playback_trigger(?????)\n");
549 snd_printdd("snd_msnd_playback_trigger() ENDE\n");
553 static snd_pcm_uframes_t
554 snd_msnd_playback_pointer(struct snd_pcm_substream
*substream
)
556 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
558 return bytes_to_frames(substream
->runtime
, chip
->playDMAPos
);
562 static const struct snd_pcm_ops snd_msnd_playback_ops
= {
563 .open
= snd_msnd_playback_open
,
564 .close
= snd_msnd_playback_close
,
565 .hw_params
= snd_msnd_playback_hw_params
,
566 .prepare
= snd_msnd_playback_prepare
,
567 .trigger
= snd_msnd_playback_trigger
,
568 .pointer
= snd_msnd_playback_pointer
,
571 static int snd_msnd_capture_open(struct snd_pcm_substream
*substream
)
573 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
574 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
576 set_bit(F_AUDIO_READ_INUSE
, &chip
->flags
);
577 snd_msnd_enable_irq(chip
);
578 runtime
->dma_area
= (__force
void *)chip
->mappedbase
+ 0x3000;
579 runtime
->dma_bytes
= 0x3000;
580 memset(runtime
->dma_area
, 0, runtime
->dma_bytes
);
581 chip
->capture_substream
= substream
;
582 runtime
->hw
= snd_msnd_capture
;
586 static int snd_msnd_capture_close(struct snd_pcm_substream
*substream
)
588 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
590 snd_msnd_disable_irq(chip
);
591 clear_bit(F_AUDIO_READ_INUSE
, &chip
->flags
);
595 static int snd_msnd_capture_prepare(struct snd_pcm_substream
*substream
)
597 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
598 unsigned int pcm_size
= snd_pcm_lib_buffer_bytes(substream
);
599 unsigned int pcm_count
= snd_pcm_lib_period_bytes(substream
);
600 unsigned int pcm_periods
= pcm_size
/ pcm_count
;
602 snd_msnd_capture_reset_queue(chip
, pcm_periods
, pcm_count
);
603 chip
->captureDMAPos
= 0;
607 static int snd_msnd_capture_trigger(struct snd_pcm_substream
*substream
,
610 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
612 if (cmd
== SNDRV_PCM_TRIGGER_START
) {
613 chip
->last_recbank
= -1;
614 set_bit(F_READING
, &chip
->flags
);
615 if (snd_msnd_send_dsp_cmd(chip
, HDEX_RECORD_START
) == 0)
618 clear_bit(F_READING
, &chip
->flags
);
619 } else if (cmd
== SNDRV_PCM_TRIGGER_STOP
) {
620 clear_bit(F_READING
, &chip
->flags
);
621 snd_msnd_send_dsp_cmd(chip
, HDEX_RECORD_STOP
);
628 static snd_pcm_uframes_t
629 snd_msnd_capture_pointer(struct snd_pcm_substream
*substream
)
631 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
632 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
634 return bytes_to_frames(runtime
, chip
->captureDMAPos
);
638 static int snd_msnd_capture_hw_params(struct snd_pcm_substream
*substream
,
639 struct snd_pcm_hw_params
*params
)
642 struct snd_msnd
*chip
= snd_pcm_substream_chip(substream
);
643 void __iomem
*pDAQ
= chip
->mappedbase
+ DARQ_DATA_BUFF
;
645 chip
->capture_sample_size
= snd_pcm_format_width(params_format(params
));
646 chip
->capture_channels
= params_channels(params
);
647 chip
->capture_sample_rate
= params_rate(params
);
649 for (i
= 0; i
< 3; ++i
, pDAQ
+= DAQDS__size
) {
650 writew(chip
->capture_sample_size
, pDAQ
+ DAQDS_wSampleSize
);
651 writew(chip
->capture_channels
, pDAQ
+ DAQDS_wChannels
);
652 writew(chip
->capture_sample_rate
, pDAQ
+ DAQDS_wSampleRate
);
658 static const struct snd_pcm_ops snd_msnd_capture_ops
= {
659 .open
= snd_msnd_capture_open
,
660 .close
= snd_msnd_capture_close
,
661 .hw_params
= snd_msnd_capture_hw_params
,
662 .prepare
= snd_msnd_capture_prepare
,
663 .trigger
= snd_msnd_capture_trigger
,
664 .pointer
= snd_msnd_capture_pointer
,
668 int snd_msnd_pcm(struct snd_card
*card
, int device
)
670 struct snd_msnd
*chip
= card
->private_data
;
674 err
= snd_pcm_new(card
, "MSNDPINNACLE", device
, 1, 1, &pcm
);
678 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_msnd_playback_ops
);
679 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_msnd_capture_ops
);
681 pcm
->private_data
= chip
;
682 strcpy(pcm
->name
, "Hurricane");
686 EXPORT_SYMBOL(snd_msnd_pcm
);
688 MODULE_DESCRIPTION("Common routines for Turtle Beach Multisound drivers");
689 MODULE_LICENSE("GPL");