2 * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
4 * Routines for control of EMU10K1 chips / PCM routines
5 * Multichannel PCM support Copyright (c) Lee Revell <rlrevell@joe-job.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <sound/driver.h>
30 #include <linux/pci.h>
31 #include <linux/delay.h>
32 #include <linux/slab.h>
33 #include <linux/time.h>
34 #include <linux/init.h>
35 #include <sound/core.h>
36 #include <sound/emu10k1.h>
38 static void snd_emu10k1_pcm_interrupt(struct snd_emu10k1
*emu
,
39 struct snd_emu10k1_voice
*voice
)
41 struct snd_emu10k1_pcm
*epcm
;
43 if ((epcm
= voice
->epcm
) == NULL
)
45 if (epcm
->substream
== NULL
)
48 printk("IRQ: position = 0x%x, period = 0x%x, size = 0x%x\n",
49 epcm
->substream
->runtime
->hw
->pointer(emu
, epcm
->substream
),
50 snd_pcm_lib_period_bytes(epcm
->substream
),
51 snd_pcm_lib_buffer_bytes(epcm
->substream
));
53 snd_pcm_period_elapsed(epcm
->substream
);
56 static void snd_emu10k1_pcm_ac97adc_interrupt(struct snd_emu10k1
*emu
,
60 if (status
& IPR_ADCBUFHALFFULL
) {
61 if (emu
->pcm_capture_substream
->runtime
->mode
== SNDRV_PCM_MODE_FRAME
)
65 snd_pcm_period_elapsed(emu
->pcm_capture_substream
);
68 static void snd_emu10k1_pcm_ac97mic_interrupt(struct snd_emu10k1
*emu
,
72 if (status
& IPR_MICBUFHALFFULL
) {
73 if (emu
->pcm_capture_mic_substream
->runtime
->mode
== SNDRV_PCM_MODE_FRAME
)
77 snd_pcm_period_elapsed(emu
->pcm_capture_mic_substream
);
80 static void snd_emu10k1_pcm_efx_interrupt(struct snd_emu10k1
*emu
,
84 if (status
& IPR_EFXBUFHALFFULL
) {
85 if (emu
->pcm_capture_efx_substream
->runtime
->mode
== SNDRV_PCM_MODE_FRAME
)
89 snd_pcm_period_elapsed(emu
->pcm_capture_efx_substream
);
92 static snd_pcm_uframes_t
snd_emu10k1_efx_playback_pointer(struct snd_pcm_substream
*substream
)
94 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
95 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
96 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
101 ptr
= snd_emu10k1_ptr_read(emu
, CCCA
, epcm
->voices
[0]->number
) & 0x00ffffff;
102 ptr
+= runtime
->buffer_size
;
103 ptr
-= epcm
->ccca_start_addr
;
104 ptr
%= runtime
->buffer_size
;
109 static int snd_emu10k1_pcm_channel_alloc(struct snd_emu10k1_pcm
* epcm
, int voices
)
113 if (epcm
->voices
[1] != NULL
&& voices
< 2) {
114 snd_emu10k1_voice_free(epcm
->emu
, epcm
->voices
[1]);
115 epcm
->voices
[1] = NULL
;
117 for (i
= 0; i
< voices
; i
++) {
118 if (epcm
->voices
[i
] == NULL
)
122 return 0; /* already allocated */
124 for (i
= 0; i
< ARRAY_SIZE(epcm
->voices
); i
++) {
125 if (epcm
->voices
[i
]) {
126 snd_emu10k1_voice_free(epcm
->emu
, epcm
->voices
[i
]);
127 epcm
->voices
[i
] = NULL
;
130 err
= snd_emu10k1_voice_alloc(epcm
->emu
,
131 epcm
->type
== PLAYBACK_EMUVOICE
? EMU10K1_PCM
: EMU10K1_EFX
,
137 epcm
->voices
[0]->epcm
= epcm
;
139 for (i
= 1; i
< voices
; i
++) {
140 epcm
->voices
[i
] = &epcm
->emu
->voices
[epcm
->voices
[0]->number
+ i
];
141 epcm
->voices
[i
]->epcm
= epcm
;
144 if (epcm
->extra
== NULL
) {
145 err
= snd_emu10k1_voice_alloc(epcm
->emu
,
146 epcm
->type
== PLAYBACK_EMUVOICE
? EMU10K1_PCM
: EMU10K1_EFX
,
150 // printk("pcm_channel_alloc: failed extra: voices=%d, frame=%d\n", voices, frame);
151 for (i
= 0; i
< voices
; i
++) {
152 snd_emu10k1_voice_free(epcm
->emu
, epcm
->voices
[i
]);
153 epcm
->voices
[i
] = NULL
;
157 epcm
->extra
->epcm
= epcm
;
158 epcm
->extra
->interrupt
= snd_emu10k1_pcm_interrupt
;
163 static unsigned int capture_period_sizes
[31] = {
165 384*2, 448*2, 512*2, 640*2,
166 384*4, 448*4, 512*4, 640*4,
167 384*8, 448*8, 512*8, 640*8,
168 384*16, 448*16, 512*16, 640*16,
169 384*32, 448*32, 512*32, 640*32,
170 384*64, 448*64, 512*64, 640*64,
171 384*128,448*128,512*128
174 static struct snd_pcm_hw_constraint_list hw_constraints_capture_period_sizes
= {
176 .list
= capture_period_sizes
,
180 static unsigned int capture_rates
[8] = {
181 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000
184 static struct snd_pcm_hw_constraint_list hw_constraints_capture_rates
= {
186 .list
= capture_rates
,
190 static unsigned int snd_emu10k1_capture_rate_reg(unsigned int rate
)
193 case 8000: return ADCCR_SAMPLERATE_8
;
194 case 11025: return ADCCR_SAMPLERATE_11
;
195 case 16000: return ADCCR_SAMPLERATE_16
;
196 case 22050: return ADCCR_SAMPLERATE_22
;
197 case 24000: return ADCCR_SAMPLERATE_24
;
198 case 32000: return ADCCR_SAMPLERATE_32
;
199 case 44100: return ADCCR_SAMPLERATE_44
;
200 case 48000: return ADCCR_SAMPLERATE_48
;
203 return ADCCR_SAMPLERATE_8
;
207 static unsigned int snd_emu10k1_audigy_capture_rate_reg(unsigned int rate
)
210 case 8000: return A_ADCCR_SAMPLERATE_8
;
211 case 11025: return A_ADCCR_SAMPLERATE_11
;
212 case 12000: return A_ADCCR_SAMPLERATE_12
; /* really supported? */
213 case 16000: return ADCCR_SAMPLERATE_16
;
214 case 22050: return ADCCR_SAMPLERATE_22
;
215 case 24000: return ADCCR_SAMPLERATE_24
;
216 case 32000: return ADCCR_SAMPLERATE_32
;
217 case 44100: return ADCCR_SAMPLERATE_44
;
218 case 48000: return ADCCR_SAMPLERATE_48
;
221 return A_ADCCR_SAMPLERATE_8
;
225 static unsigned int emu10k1_calc_pitch_target(unsigned int rate
)
227 unsigned int pitch_target
;
229 pitch_target
= (rate
<< 8) / 375;
230 pitch_target
= (pitch_target
>> 1) + (pitch_target
& 1);
234 #define PITCH_48000 0x00004000
235 #define PITCH_96000 0x00008000
236 #define PITCH_85000 0x00007155
237 #define PITCH_80726 0x00006ba2
238 #define PITCH_67882 0x00005a82
239 #define PITCH_57081 0x00004c1c
241 static unsigned int emu10k1_select_interprom(unsigned int pitch_target
)
243 if (pitch_target
== PITCH_48000
)
244 return CCCA_INTERPROM_0
;
245 else if (pitch_target
< PITCH_48000
)
246 return CCCA_INTERPROM_1
;
247 else if (pitch_target
>= PITCH_96000
)
248 return CCCA_INTERPROM_0
;
249 else if (pitch_target
>= PITCH_85000
)
250 return CCCA_INTERPROM_6
;
251 else if (pitch_target
>= PITCH_80726
)
252 return CCCA_INTERPROM_5
;
253 else if (pitch_target
>= PITCH_67882
)
254 return CCCA_INTERPROM_4
;
255 else if (pitch_target
>= PITCH_57081
)
256 return CCCA_INTERPROM_3
;
258 return CCCA_INTERPROM_2
;
262 * calculate cache invalidate size
264 * stereo: channel is stereo
265 * w_16: using 16bit samples
267 * returns: cache invalidate size in samples
269 static inline int emu10k1_ccis(int stereo
, int w_16
)
272 return stereo
? 24 : 26;
274 return stereo
? 24*2 : 26*2;
278 static void snd_emu10k1_pcm_init_voice(struct snd_emu10k1
*emu
,
279 int master
, int extra
,
280 struct snd_emu10k1_voice
*evoice
,
281 unsigned int start_addr
,
282 unsigned int end_addr
,
283 struct snd_emu10k1_pcm_mixer
*mix
)
285 struct snd_pcm_substream
*substream
= evoice
->epcm
->substream
;
286 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
287 unsigned int silent_page
, tmp
;
288 int voice
, stereo
, w_16
;
289 unsigned char attn
, send_amount
[8];
290 unsigned char send_routing
[8];
292 unsigned int pitch_target
;
295 voice
= evoice
->number
;
296 stereo
= runtime
->channels
== 2;
297 w_16
= snd_pcm_format_width(runtime
->format
) == 16;
299 if (!extra
&& stereo
) {
308 spin_lock_irqsave(&emu
->reg_lock
, flags
);
310 /* volume parameters */
313 memset(send_routing
, 0, sizeof(send_routing
));
318 memset(send_amount
, 0, sizeof(send_amount
));
320 /* mono, left, right (master voice = left) */
321 tmp
= stereo
? (master
? 1 : 2) : 0;
322 memcpy(send_routing
, &mix
->send_routing
[tmp
][0], 8);
323 memcpy(send_amount
, &mix
->send_volume
[tmp
][0], 8);
326 ccis
= emu10k1_ccis(stereo
, w_16
);
329 evoice
->epcm
->ccca_start_addr
= start_addr
+ ccis
;
334 if (stereo
&& !extra
) {
335 snd_emu10k1_ptr_write(emu
, CPF
, voice
, CPF_STEREO_MASK
);
336 snd_emu10k1_ptr_write(emu
, CPF
, (voice
+ 1), CPF_STEREO_MASK
);
338 snd_emu10k1_ptr_write(emu
, CPF
, voice
, 0);
344 snd_emu10k1_ptr_write(emu
, A_FXRT1
, voice
,
345 snd_emu10k1_compose_audigy_fxrt1(send_routing
));
346 snd_emu10k1_ptr_write(emu
, A_FXRT2
, voice
,
347 snd_emu10k1_compose_audigy_fxrt2(send_routing
));
348 snd_emu10k1_ptr_write(emu
, A_SENDAMOUNTS
, voice
,
349 ((unsigned int)send_amount
[4] << 24) |
350 ((unsigned int)send_amount
[5] << 16) |
351 ((unsigned int)send_amount
[6] << 8) |
352 (unsigned int)send_amount
[7]);
354 snd_emu10k1_ptr_write(emu
, FXRT
, voice
,
355 snd_emu10k1_compose_send_routing(send_routing
));
357 // Assumption that PT is already 0 so no harm overwriting
358 snd_emu10k1_ptr_write(emu
, PTRX
, voice
, (send_amount
[0] << 8) | send_amount
[1]);
359 snd_emu10k1_ptr_write(emu
, DSL
, voice
, end_addr
| (send_amount
[3] << 24));
360 snd_emu10k1_ptr_write(emu
, PSST
, voice
, start_addr
| (send_amount
[2] << 24));
361 pitch_target
= emu10k1_calc_pitch_target(runtime
->rate
);
363 snd_emu10k1_ptr_write(emu
, CCCA
, voice
, start_addr
|
364 emu10k1_select_interprom(pitch_target
) |
365 (w_16
? 0 : CCCA_8BITSELECT
));
367 snd_emu10k1_ptr_write(emu
, CCCA
, voice
, (start_addr
+ ccis
) |
368 emu10k1_select_interprom(pitch_target
) |
369 (w_16
? 0 : CCCA_8BITSELECT
));
370 // Clear filter delay memory
371 snd_emu10k1_ptr_write(emu
, Z1
, voice
, 0);
372 snd_emu10k1_ptr_write(emu
, Z2
, voice
, 0);
374 silent_page
= ((unsigned int)emu
->silent_page
.addr
<< 1) | MAP_PTI_MASK
;
375 snd_emu10k1_ptr_write(emu
, MAPA
, voice
, silent_page
);
376 snd_emu10k1_ptr_write(emu
, MAPB
, voice
, silent_page
);
377 // modulation envelope
378 snd_emu10k1_ptr_write(emu
, CVCF
, voice
, 0xffff);
379 snd_emu10k1_ptr_write(emu
, VTFT
, voice
, 0xffff);
380 snd_emu10k1_ptr_write(emu
, ATKHLDM
, voice
, 0);
381 snd_emu10k1_ptr_write(emu
, DCYSUSM
, voice
, 0x007f);
382 snd_emu10k1_ptr_write(emu
, LFOVAL1
, voice
, 0x8000);
383 snd_emu10k1_ptr_write(emu
, LFOVAL2
, voice
, 0x8000);
384 snd_emu10k1_ptr_write(emu
, FMMOD
, voice
, 0);
385 snd_emu10k1_ptr_write(emu
, TREMFRQ
, voice
, 0);
386 snd_emu10k1_ptr_write(emu
, FM2FRQ2
, voice
, 0);
387 snd_emu10k1_ptr_write(emu
, ENVVAL
, voice
, 0x8000);
389 snd_emu10k1_ptr_write(emu
, ATKHLDV
, voice
, 0x7f7f);
390 snd_emu10k1_ptr_write(emu
, ENVVOL
, voice
, 0x0000);
392 snd_emu10k1_ptr_write(emu
, PEFE_FILTERAMOUNT
, voice
, 0x7f);
394 snd_emu10k1_ptr_write(emu
, PEFE_PITCHAMOUNT
, voice
, 0);
396 spin_unlock_irqrestore(&emu
->reg_lock
, flags
);
399 static int snd_emu10k1_playback_hw_params(struct snd_pcm_substream
*substream
,
400 struct snd_pcm_hw_params
*hw_params
)
402 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
403 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
404 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
407 if ((err
= snd_emu10k1_pcm_channel_alloc(epcm
, params_channels(hw_params
))) < 0)
409 if ((err
= snd_pcm_lib_malloc_pages(substream
, params_buffer_bytes(hw_params
))) < 0)
411 if (err
> 0) { /* change */
413 if (epcm
->memblk
!= NULL
)
414 snd_emu10k1_free_pages(emu
, epcm
->memblk
);
415 epcm
->memblk
= snd_emu10k1_alloc_pages(emu
, substream
);
416 epcm
->start_addr
= 0;
419 mapped
= ((struct snd_emu10k1_memblk
*)epcm
->memblk
)->mapped_page
;
422 epcm
->start_addr
= mapped
<< PAGE_SHIFT
;
427 static int snd_emu10k1_playback_hw_free(struct snd_pcm_substream
*substream
)
429 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
430 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
431 struct snd_emu10k1_pcm
*epcm
;
433 if (runtime
->private_data
== NULL
)
435 epcm
= runtime
->private_data
;
437 snd_emu10k1_voice_free(epcm
->emu
, epcm
->extra
);
440 if (epcm
->voices
[1]) {
441 snd_emu10k1_voice_free(epcm
->emu
, epcm
->voices
[1]);
442 epcm
->voices
[1] = NULL
;
444 if (epcm
->voices
[0]) {
445 snd_emu10k1_voice_free(epcm
->emu
, epcm
->voices
[0]);
446 epcm
->voices
[0] = NULL
;
449 snd_emu10k1_free_pages(emu
, epcm
->memblk
);
451 epcm
->start_addr
= 0;
453 snd_pcm_lib_free_pages(substream
);
457 static int snd_emu10k1_efx_playback_hw_free(struct snd_pcm_substream
*substream
)
459 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
460 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
461 struct snd_emu10k1_pcm
*epcm
;
464 if (runtime
->private_data
== NULL
)
466 epcm
= runtime
->private_data
;
468 snd_emu10k1_voice_free(epcm
->emu
, epcm
->extra
);
471 for (i
=0; i
< NUM_EFX_PLAYBACK
; i
++) {
472 if (epcm
->voices
[i
]) {
473 snd_emu10k1_voice_free(epcm
->emu
, epcm
->voices
[i
]);
474 epcm
->voices
[i
] = NULL
;
478 snd_emu10k1_free_pages(emu
, epcm
->memblk
);
480 epcm
->start_addr
= 0;
482 snd_pcm_lib_free_pages(substream
);
486 static int snd_emu10k1_playback_prepare(struct snd_pcm_substream
*substream
)
488 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
489 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
490 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
491 unsigned int start_addr
, end_addr
;
493 start_addr
= epcm
->start_addr
;
494 end_addr
= snd_pcm_lib_period_bytes(substream
);
495 if (runtime
->channels
== 2) {
499 end_addr
+= start_addr
;
500 snd_emu10k1_pcm_init_voice(emu
, 1, 1, epcm
->extra
,
501 start_addr
, end_addr
, NULL
);
502 start_addr
= epcm
->start_addr
;
503 end_addr
= epcm
->start_addr
+ snd_pcm_lib_buffer_bytes(substream
);
504 snd_emu10k1_pcm_init_voice(emu
, 1, 0, epcm
->voices
[0],
505 start_addr
, end_addr
,
506 &emu
->pcm_mixer
[substream
->number
]);
508 snd_emu10k1_pcm_init_voice(emu
, 0, 0, epcm
->voices
[1],
509 start_addr
, end_addr
,
510 &emu
->pcm_mixer
[substream
->number
]);
514 static int snd_emu10k1_efx_playback_prepare(struct snd_pcm_substream
*substream
)
516 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
517 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
518 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
519 unsigned int start_addr
, end_addr
;
520 unsigned int channel_size
;
523 start_addr
= epcm
->start_addr
;
524 end_addr
= epcm
->start_addr
+ snd_pcm_lib_buffer_bytes(substream
);
527 * the kX driver leaves some space between voices
529 channel_size
= ( end_addr
- start_addr
) / NUM_EFX_PLAYBACK
;
531 snd_emu10k1_pcm_init_voice(emu
, 1, 1, epcm
->extra
,
532 start_addr
, start_addr
+ (channel_size
/ 2), NULL
);
534 /* only difference with the master voice is we use it for the pointer */
535 snd_emu10k1_pcm_init_voice(emu
, 1, 0, epcm
->voices
[0],
536 start_addr
, start_addr
+ channel_size
,
537 &emu
->efx_pcm_mixer
[0]);
539 start_addr
+= channel_size
;
540 for (i
= 1; i
< NUM_EFX_PLAYBACK
; i
++) {
541 snd_emu10k1_pcm_init_voice(emu
, 0, 0, epcm
->voices
[i
],
542 start_addr
, start_addr
+ channel_size
,
543 &emu
->efx_pcm_mixer
[i
]);
544 start_addr
+= channel_size
;
550 static struct snd_pcm_hardware snd_emu10k1_efx_playback
=
552 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_NONINTERLEAVED
|
553 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
554 SNDRV_PCM_INFO_RESUME
|
555 SNDRV_PCM_INFO_MMAP_VALID
| SNDRV_PCM_INFO_PAUSE
),
556 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
557 .rates
= SNDRV_PCM_RATE_48000
,
560 .channels_min
= NUM_EFX_PLAYBACK
,
561 .channels_max
= NUM_EFX_PLAYBACK
,
562 .buffer_bytes_max
= (64*1024),
563 .period_bytes_min
= 64,
564 .period_bytes_max
= (64*1024),
570 static int snd_emu10k1_capture_hw_params(struct snd_pcm_substream
*substream
,
571 struct snd_pcm_hw_params
*hw_params
)
573 return snd_pcm_lib_malloc_pages(substream
, params_buffer_bytes(hw_params
));
576 static int snd_emu10k1_capture_hw_free(struct snd_pcm_substream
*substream
)
578 return snd_pcm_lib_free_pages(substream
);
581 static int snd_emu10k1_capture_prepare(struct snd_pcm_substream
*substream
)
583 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
584 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
585 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
588 /* zeroing the buffer size will stop capture */
589 snd_emu10k1_ptr_write(emu
, epcm
->capture_bs_reg
, 0, 0);
590 switch (epcm
->type
) {
591 case CAPTURE_AC97ADC
:
592 snd_emu10k1_ptr_write(emu
, ADCCR
, 0, 0);
596 snd_emu10k1_ptr_write(emu
, A_FXWC1
, 0, 0);
597 snd_emu10k1_ptr_write(emu
, A_FXWC2
, 0, 0);
599 snd_emu10k1_ptr_write(emu
, FXWC
, 0, 0);
604 snd_emu10k1_ptr_write(emu
, epcm
->capture_ba_reg
, 0, runtime
->dma_addr
);
605 epcm
->capture_bufsize
= snd_pcm_lib_buffer_bytes(substream
);
606 epcm
->capture_bs_val
= 0;
607 for (idx
= 0; idx
< 31; idx
++) {
608 if (capture_period_sizes
[idx
] == epcm
->capture_bufsize
) {
609 epcm
->capture_bs_val
= idx
+ 1;
613 if (epcm
->capture_bs_val
== 0) {
615 epcm
->capture_bs_val
++;
617 if (epcm
->type
== CAPTURE_AC97ADC
) {
618 epcm
->capture_cr_val
= emu
->audigy
? A_ADCCR_LCHANENABLE
: ADCCR_LCHANENABLE
;
619 if (runtime
->channels
> 1)
620 epcm
->capture_cr_val
|= emu
->audigy
? A_ADCCR_RCHANENABLE
: ADCCR_RCHANENABLE
;
621 epcm
->capture_cr_val
|= emu
->audigy
?
622 snd_emu10k1_audigy_capture_rate_reg(runtime
->rate
) :
623 snd_emu10k1_capture_rate_reg(runtime
->rate
);
628 static void snd_emu10k1_playback_invalidate_cache(struct snd_emu10k1
*emu
, int extra
, struct snd_emu10k1_voice
*evoice
)
630 struct snd_pcm_runtime
*runtime
;
631 unsigned int voice
, stereo
, i
, ccis
, cra
= 64, cs
, sample
;
635 runtime
= evoice
->epcm
->substream
->runtime
;
636 voice
= evoice
->number
;
637 stereo
= (!extra
&& runtime
->channels
== 2);
638 sample
= snd_pcm_format_width(runtime
->format
) == 16 ? 0 : 0x80808080;
639 ccis
= emu10k1_ccis(stereo
, sample
== 0);
640 // set cs to 2 * number of cache registers beside the invalidated
641 cs
= (sample
== 0) ? (32-ccis
) : (64-ccis
+1) >> 1;
642 if (cs
> 16) cs
= 16;
643 for (i
= 0; i
< cs
; i
++) {
644 snd_emu10k1_ptr_write(emu
, CD0
+ i
, voice
, sample
);
646 snd_emu10k1_ptr_write(emu
, CD0
+ i
, voice
+ 1, sample
);
650 snd_emu10k1_ptr_write(emu
, CCR_CACHEINVALIDSIZE
, voice
, 0);
651 snd_emu10k1_ptr_write(emu
, CCR_READADDRESS
, voice
, cra
);
653 snd_emu10k1_ptr_write(emu
, CCR_CACHEINVALIDSIZE
, voice
+ 1, 0);
654 snd_emu10k1_ptr_write(emu
, CCR_READADDRESS
, voice
+ 1, cra
);
657 snd_emu10k1_ptr_write(emu
, CCR_CACHEINVALIDSIZE
, voice
, ccis
);
659 snd_emu10k1_ptr_write(emu
, CCR_CACHEINVALIDSIZE
, voice
+1, ccis
);
663 static void snd_emu10k1_playback_prepare_voice(struct snd_emu10k1
*emu
, struct snd_emu10k1_voice
*evoice
,
664 int master
, int extra
,
665 struct snd_emu10k1_pcm_mixer
*mix
)
667 struct snd_pcm_substream
*substream
;
668 struct snd_pcm_runtime
*runtime
;
669 unsigned int attn
, vattn
;
670 unsigned int voice
, tmp
;
672 if (evoice
== NULL
) /* skip second voice for mono */
674 substream
= evoice
->epcm
->substream
;
675 runtime
= substream
->runtime
;
676 voice
= evoice
->number
;
678 attn
= extra
? 0 : 0x00ff;
679 tmp
= runtime
->channels
== 2 ? (master
? 1 : 2) : 0;
680 vattn
= mix
!= NULL
? (mix
->attn
[tmp
] << 16) : 0;
681 snd_emu10k1_ptr_write(emu
, IFATN
, voice
, attn
);
682 snd_emu10k1_ptr_write(emu
, VTFT
, voice
, vattn
| 0xffff);
683 snd_emu10k1_ptr_write(emu
, CVCF
, voice
, vattn
| 0xffff);
684 snd_emu10k1_ptr_write(emu
, DCYSUSV
, voice
, 0x7f7f);
685 snd_emu10k1_voice_clear_loop_stop(emu
, voice
);
688 static void snd_emu10k1_playback_trigger_voice(struct snd_emu10k1
*emu
, struct snd_emu10k1_voice
*evoice
, int master
, int extra
)
690 struct snd_pcm_substream
*substream
;
691 struct snd_pcm_runtime
*runtime
;
692 unsigned int voice
, pitch
, pitch_target
;
694 if (evoice
== NULL
) /* skip second voice for mono */
696 substream
= evoice
->epcm
->substream
;
697 runtime
= substream
->runtime
;
698 voice
= evoice
->number
;
700 pitch
= snd_emu10k1_rate_to_pitch(runtime
->rate
) >> 8;
701 pitch_target
= emu10k1_calc_pitch_target(runtime
->rate
);
702 snd_emu10k1_ptr_write(emu
, PTRX_PITCHTARGET
, voice
, pitch_target
);
703 if (master
|| evoice
->epcm
->type
== PLAYBACK_EFX
)
704 snd_emu10k1_ptr_write(emu
, CPF_CURRENTPITCH
, voice
, pitch_target
);
705 snd_emu10k1_ptr_write(emu
, IP
, voice
, pitch
);
707 snd_emu10k1_voice_intr_enable(emu
, voice
);
710 static void snd_emu10k1_playback_stop_voice(struct snd_emu10k1
*emu
, struct snd_emu10k1_voice
*evoice
)
716 voice
= evoice
->number
;
717 snd_emu10k1_voice_intr_disable(emu
, voice
);
718 snd_emu10k1_ptr_write(emu
, PTRX_PITCHTARGET
, voice
, 0);
719 snd_emu10k1_ptr_write(emu
, CPF_CURRENTPITCH
, voice
, 0);
720 snd_emu10k1_ptr_write(emu
, IFATN
, voice
, 0xffff);
721 snd_emu10k1_ptr_write(emu
, VTFT
, voice
, 0xffff);
722 snd_emu10k1_ptr_write(emu
, CVCF
, voice
, 0xffff);
723 snd_emu10k1_ptr_write(emu
, IP
, voice
, 0);
726 static int snd_emu10k1_playback_trigger(struct snd_pcm_substream
*substream
,
729 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
730 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
731 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
732 struct snd_emu10k1_pcm_mixer
*mix
;
735 // printk("trigger - emu10k1 = 0x%x, cmd = %i, pointer = %i\n", (int)emu, cmd, substream->ops->pointer(substream));
736 spin_lock(&emu
->reg_lock
);
738 case SNDRV_PCM_TRIGGER_START
:
739 snd_emu10k1_playback_invalidate_cache(emu
, 1, epcm
->extra
); /* do we need this? */
740 snd_emu10k1_playback_invalidate_cache(emu
, 0, epcm
->voices
[0]);
742 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
743 case SNDRV_PCM_TRIGGER_RESUME
:
744 mix
= &emu
->pcm_mixer
[substream
->number
];
745 snd_emu10k1_playback_prepare_voice(emu
, epcm
->voices
[0], 1, 0, mix
);
746 snd_emu10k1_playback_prepare_voice(emu
, epcm
->voices
[1], 0, 0, mix
);
747 snd_emu10k1_playback_prepare_voice(emu
, epcm
->extra
, 1, 1, NULL
);
748 snd_emu10k1_playback_trigger_voice(emu
, epcm
->voices
[0], 1, 0);
749 snd_emu10k1_playback_trigger_voice(emu
, epcm
->voices
[1], 0, 0);
750 snd_emu10k1_playback_trigger_voice(emu
, epcm
->extra
, 1, 1);
753 case SNDRV_PCM_TRIGGER_STOP
:
754 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
755 case SNDRV_PCM_TRIGGER_SUSPEND
:
757 snd_emu10k1_playback_stop_voice(emu
, epcm
->voices
[0]);
758 snd_emu10k1_playback_stop_voice(emu
, epcm
->voices
[1]);
759 snd_emu10k1_playback_stop_voice(emu
, epcm
->extra
);
765 spin_unlock(&emu
->reg_lock
);
769 static int snd_emu10k1_capture_trigger(struct snd_pcm_substream
*substream
,
772 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
773 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
774 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
777 spin_lock(&emu
->reg_lock
);
779 case SNDRV_PCM_TRIGGER_START
:
780 case SNDRV_PCM_TRIGGER_RESUME
:
781 // hmm this should cause full and half full interrupt to be raised?
782 outl(epcm
->capture_ipr
, emu
->port
+ IPR
);
783 snd_emu10k1_intr_enable(emu
, epcm
->capture_inte
);
784 // printk("adccr = 0x%x, adcbs = 0x%x\n", epcm->adccr, epcm->adcbs);
785 switch (epcm
->type
) {
786 case CAPTURE_AC97ADC
:
787 snd_emu10k1_ptr_write(emu
, ADCCR
, 0, epcm
->capture_cr_val
);
791 snd_emu10k1_ptr_write(emu
, A_FXWC1
, 0, epcm
->capture_cr_val
);
792 snd_emu10k1_ptr_write(emu
, A_FXWC2
, 0, epcm
->capture_cr_val2
);
794 snd_emu10k1_ptr_write(emu
, FXWC
, 0, epcm
->capture_cr_val
);
799 snd_emu10k1_ptr_write(emu
, epcm
->capture_bs_reg
, 0, epcm
->capture_bs_val
);
803 case SNDRV_PCM_TRIGGER_STOP
:
804 case SNDRV_PCM_TRIGGER_SUSPEND
:
806 snd_emu10k1_intr_disable(emu
, epcm
->capture_inte
);
807 outl(epcm
->capture_ipr
, emu
->port
+ IPR
);
808 snd_emu10k1_ptr_write(emu
, epcm
->capture_bs_reg
, 0, 0);
809 switch (epcm
->type
) {
810 case CAPTURE_AC97ADC
:
811 snd_emu10k1_ptr_write(emu
, ADCCR
, 0, 0);
815 snd_emu10k1_ptr_write(emu
, A_FXWC1
, 0, 0);
816 snd_emu10k1_ptr_write(emu
, A_FXWC2
, 0, 0);
818 snd_emu10k1_ptr_write(emu
, FXWC
, 0, 0);
827 spin_unlock(&emu
->reg_lock
);
831 static snd_pcm_uframes_t
snd_emu10k1_playback_pointer(struct snd_pcm_substream
*substream
)
833 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
834 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
835 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
840 ptr
= snd_emu10k1_ptr_read(emu
, CCCA
, epcm
->voices
[0]->number
) & 0x00ffffff;
841 #if 0 /* Perex's code */
842 ptr
+= runtime
->buffer_size
;
843 ptr
-= epcm
->ccca_start_addr
;
844 ptr
%= runtime
->buffer_size
;
845 #else /* EMU10K1 Open Source code from Creative */
846 if (ptr
< epcm
->ccca_start_addr
)
847 ptr
+= runtime
->buffer_size
- epcm
->ccca_start_addr
;
849 ptr
-= epcm
->ccca_start_addr
;
850 if (ptr
>= runtime
->buffer_size
)
851 ptr
-= runtime
->buffer_size
;
854 // printk("ptr = 0x%x, buffer_size = 0x%x, period_size = 0x%x\n", ptr, runtime->buffer_size, runtime->period_size);
859 static int snd_emu10k1_efx_playback_trigger(struct snd_pcm_substream
*substream
,
862 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
863 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
864 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
868 spin_lock(&emu
->reg_lock
);
870 case SNDRV_PCM_TRIGGER_START
:
872 for (i
= 0; i
< NUM_EFX_PLAYBACK
; i
++) {
873 snd_emu10k1_playback_invalidate_cache(emu
, 0, epcm
->voices
[i
]);
875 snd_emu10k1_playback_invalidate_cache(emu
, 1, epcm
->extra
);
878 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
879 case SNDRV_PCM_TRIGGER_RESUME
:
880 snd_emu10k1_playback_prepare_voice(emu
, epcm
->extra
, 1, 1, NULL
);
881 snd_emu10k1_playback_prepare_voice(emu
, epcm
->voices
[0], 0, 0,
882 &emu
->efx_pcm_mixer
[0]);
883 for (i
= 1; i
< NUM_EFX_PLAYBACK
; i
++)
884 snd_emu10k1_playback_prepare_voice(emu
, epcm
->voices
[i
], 0, 0,
885 &emu
->efx_pcm_mixer
[i
]);
886 snd_emu10k1_playback_trigger_voice(emu
, epcm
->voices
[0], 0, 0);
887 snd_emu10k1_playback_trigger_voice(emu
, epcm
->extra
, 1, 1);
888 for (i
= 1; i
< NUM_EFX_PLAYBACK
; i
++)
889 snd_emu10k1_playback_trigger_voice(emu
, epcm
->voices
[i
], 0, 0);
892 case SNDRV_PCM_TRIGGER_SUSPEND
:
893 case SNDRV_PCM_TRIGGER_STOP
:
894 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
896 for (i
= 0; i
< NUM_EFX_PLAYBACK
; i
++) {
897 snd_emu10k1_playback_stop_voice(emu
, epcm
->voices
[i
]);
899 snd_emu10k1_playback_stop_voice(emu
, epcm
->extra
);
905 spin_unlock(&emu
->reg_lock
);
910 static snd_pcm_uframes_t
snd_emu10k1_capture_pointer(struct snd_pcm_substream
*substream
)
912 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
913 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
914 struct snd_emu10k1_pcm
*epcm
= runtime
->private_data
;
919 if (epcm
->first_ptr
) {
920 udelay(50); // hack, it takes awhile until capture is started
923 ptr
= snd_emu10k1_ptr_read(emu
, epcm
->capture_idx_reg
, 0) & 0x0000ffff;
924 return bytes_to_frames(runtime
, ptr
);
928 * Playback support device description
931 static struct snd_pcm_hardware snd_emu10k1_playback
=
933 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
934 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
935 SNDRV_PCM_INFO_RESUME
|
936 SNDRV_PCM_INFO_MMAP_VALID
| SNDRV_PCM_INFO_PAUSE
),
937 .formats
= SNDRV_PCM_FMTBIT_U8
| SNDRV_PCM_FMTBIT_S16_LE
,
938 .rates
= SNDRV_PCM_RATE_CONTINUOUS
| SNDRV_PCM_RATE_8000_96000
,
943 .buffer_bytes_max
= (128*1024),
944 .period_bytes_min
= 64,
945 .period_bytes_max
= (128*1024),
952 * Capture support device description
955 static struct snd_pcm_hardware snd_emu10k1_capture
=
957 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
958 SNDRV_PCM_INFO_BLOCK_TRANSFER
|
959 SNDRV_PCM_INFO_RESUME
|
960 SNDRV_PCM_INFO_MMAP_VALID
),
961 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
962 .rates
= SNDRV_PCM_RATE_8000_48000
,
967 .buffer_bytes_max
= (64*1024),
968 .period_bytes_min
= 384,
969 .period_bytes_max
= (64*1024),
979 static void snd_emu10k1_pcm_mixer_notify1(struct snd_emu10k1
*emu
, struct snd_kcontrol
*kctl
, int idx
, int activate
)
981 struct snd_ctl_elem_id id
;
986 kctl
->vd
[idx
].access
&= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
988 kctl
->vd
[idx
].access
|= SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
989 snd_ctl_notify(emu
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
990 SNDRV_CTL_EVENT_MASK_INFO
,
991 snd_ctl_build_ioff(&id
, kctl
, idx
));
994 static void snd_emu10k1_pcm_mixer_notify(struct snd_emu10k1
*emu
, int idx
, int activate
)
996 snd_emu10k1_pcm_mixer_notify1(emu
, emu
->ctl_send_routing
, idx
, activate
);
997 snd_emu10k1_pcm_mixer_notify1(emu
, emu
->ctl_send_volume
, idx
, activate
);
998 snd_emu10k1_pcm_mixer_notify1(emu
, emu
->ctl_attn
, idx
, activate
);
1001 static void snd_emu10k1_pcm_efx_mixer_notify(struct snd_emu10k1
*emu
, int idx
, int activate
)
1003 snd_emu10k1_pcm_mixer_notify1(emu
, emu
->ctl_efx_send_routing
, idx
, activate
);
1004 snd_emu10k1_pcm_mixer_notify1(emu
, emu
->ctl_efx_send_volume
, idx
, activate
);
1005 snd_emu10k1_pcm_mixer_notify1(emu
, emu
->ctl_efx_attn
, idx
, activate
);
1008 static void snd_emu10k1_pcm_free_substream(struct snd_pcm_runtime
*runtime
)
1010 kfree(runtime
->private_data
);
1013 static int snd_emu10k1_efx_playback_close(struct snd_pcm_substream
*substream
)
1015 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1016 struct snd_emu10k1_pcm_mixer
*mix
;
1019 for (i
=0; i
< NUM_EFX_PLAYBACK
; i
++) {
1020 mix
= &emu
->efx_pcm_mixer
[i
];
1022 snd_emu10k1_pcm_efx_mixer_notify(emu
, i
, 0);
1027 static int snd_emu10k1_efx_playback_open(struct snd_pcm_substream
*substream
)
1029 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1030 struct snd_emu10k1_pcm
*epcm
;
1031 struct snd_emu10k1_pcm_mixer
*mix
;
1032 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1035 epcm
= kzalloc(sizeof(*epcm
), GFP_KERNEL
);
1039 epcm
->type
= PLAYBACK_EFX
;
1040 epcm
->substream
= substream
;
1042 emu
->pcm_playback_efx_substream
= substream
;
1044 runtime
->private_data
= epcm
;
1045 runtime
->private_free
= snd_emu10k1_pcm_free_substream
;
1046 runtime
->hw
= snd_emu10k1_efx_playback
;
1048 for (i
=0; i
< NUM_EFX_PLAYBACK
; i
++) {
1049 mix
= &emu
->efx_pcm_mixer
[i
];
1050 mix
->send_routing
[0][0] = i
;
1051 memset(&mix
->send_volume
, 0, sizeof(mix
->send_volume
));
1052 mix
->send_volume
[0][0] = 255;
1053 mix
->attn
[0] = 0xffff;
1055 snd_emu10k1_pcm_efx_mixer_notify(emu
, i
, 1);
1060 static int snd_emu10k1_playback_open(struct snd_pcm_substream
*substream
)
1062 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1063 struct snd_emu10k1_pcm
*epcm
;
1064 struct snd_emu10k1_pcm_mixer
*mix
;
1065 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1068 epcm
= kzalloc(sizeof(*epcm
), GFP_KERNEL
);
1072 epcm
->type
= PLAYBACK_EMUVOICE
;
1073 epcm
->substream
= substream
;
1074 runtime
->private_data
= epcm
;
1075 runtime
->private_free
= snd_emu10k1_pcm_free_substream
;
1076 runtime
->hw
= snd_emu10k1_playback
;
1077 if ((err
= snd_pcm_hw_constraint_integer(runtime
, SNDRV_PCM_HW_PARAM_PERIODS
)) < 0) {
1081 if ((err
= snd_pcm_hw_constraint_minmax(runtime
, SNDRV_PCM_HW_PARAM_BUFFER_BYTES
, 256, UINT_MAX
)) < 0) {
1085 mix
= &emu
->pcm_mixer
[substream
->number
];
1086 for (i
= 0; i
< 4; i
++)
1087 mix
->send_routing
[0][i
] = mix
->send_routing
[1][i
] = mix
->send_routing
[2][i
] = i
;
1088 memset(&mix
->send_volume
, 0, sizeof(mix
->send_volume
));
1089 mix
->send_volume
[0][0] = mix
->send_volume
[0][1] =
1090 mix
->send_volume
[1][0] = mix
->send_volume
[2][1] = 255;
1091 mix
->attn
[0] = mix
->attn
[1] = mix
->attn
[2] = 0xffff;
1093 snd_emu10k1_pcm_mixer_notify(emu
, substream
->number
, 1);
1097 static int snd_emu10k1_playback_close(struct snd_pcm_substream
*substream
)
1099 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1100 struct snd_emu10k1_pcm_mixer
*mix
= &emu
->pcm_mixer
[substream
->number
];
1103 snd_emu10k1_pcm_mixer_notify(emu
, substream
->number
, 0);
1107 static int snd_emu10k1_capture_open(struct snd_pcm_substream
*substream
)
1109 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1110 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1111 struct snd_emu10k1_pcm
*epcm
;
1113 epcm
= kzalloc(sizeof(*epcm
), GFP_KERNEL
);
1117 epcm
->type
= CAPTURE_AC97ADC
;
1118 epcm
->substream
= substream
;
1119 epcm
->capture_ipr
= IPR_ADCBUFFULL
|IPR_ADCBUFHALFFULL
;
1120 epcm
->capture_inte
= INTE_ADCBUFENABLE
;
1121 epcm
->capture_ba_reg
= ADCBA
;
1122 epcm
->capture_bs_reg
= ADCBS
;
1123 epcm
->capture_idx_reg
= emu
->audigy
? A_ADCIDX
: ADCIDX
;
1124 runtime
->private_data
= epcm
;
1125 runtime
->private_free
= snd_emu10k1_pcm_free_substream
;
1126 runtime
->hw
= snd_emu10k1_capture
;
1127 emu
->capture_interrupt
= snd_emu10k1_pcm_ac97adc_interrupt
;
1128 emu
->pcm_capture_substream
= substream
;
1129 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES
, &hw_constraints_capture_period_sizes
);
1130 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_RATE
, &hw_constraints_capture_rates
);
1134 static int snd_emu10k1_capture_close(struct snd_pcm_substream
*substream
)
1136 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1138 emu
->capture_interrupt
= NULL
;
1139 emu
->pcm_capture_substream
= NULL
;
1143 static int snd_emu10k1_capture_mic_open(struct snd_pcm_substream
*substream
)
1145 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1146 struct snd_emu10k1_pcm
*epcm
;
1147 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1149 epcm
= kzalloc(sizeof(*epcm
), GFP_KERNEL
);
1153 epcm
->type
= CAPTURE_AC97MIC
;
1154 epcm
->substream
= substream
;
1155 epcm
->capture_ipr
= IPR_MICBUFFULL
|IPR_MICBUFHALFFULL
;
1156 epcm
->capture_inte
= INTE_MICBUFENABLE
;
1157 epcm
->capture_ba_reg
= MICBA
;
1158 epcm
->capture_bs_reg
= MICBS
;
1159 epcm
->capture_idx_reg
= emu
->audigy
? A_MICIDX
: MICIDX
;
1160 substream
->runtime
->private_data
= epcm
;
1161 substream
->runtime
->private_free
= snd_emu10k1_pcm_free_substream
;
1162 runtime
->hw
= snd_emu10k1_capture
;
1163 runtime
->hw
.rates
= SNDRV_PCM_RATE_8000
;
1164 runtime
->hw
.rate_min
= runtime
->hw
.rate_max
= 8000;
1165 runtime
->hw
.channels_min
= 1;
1166 emu
->capture_mic_interrupt
= snd_emu10k1_pcm_ac97mic_interrupt
;
1167 emu
->pcm_capture_mic_substream
= substream
;
1168 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES
, &hw_constraints_capture_period_sizes
);
1172 static int snd_emu10k1_capture_mic_close(struct snd_pcm_substream
*substream
)
1174 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1176 emu
->capture_interrupt
= NULL
;
1177 emu
->pcm_capture_mic_substream
= NULL
;
1181 static int snd_emu10k1_capture_efx_open(struct snd_pcm_substream
*substream
)
1183 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1184 struct snd_emu10k1_pcm
*epcm
;
1185 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1186 int nefx
= emu
->audigy
? 64 : 32;
1189 epcm
= kzalloc(sizeof(*epcm
), GFP_KERNEL
);
1193 epcm
->type
= CAPTURE_EFX
;
1194 epcm
->substream
= substream
;
1195 epcm
->capture_ipr
= IPR_EFXBUFFULL
|IPR_EFXBUFHALFFULL
;
1196 epcm
->capture_inte
= INTE_EFXBUFENABLE
;
1197 epcm
->capture_ba_reg
= FXBA
;
1198 epcm
->capture_bs_reg
= FXBS
;
1199 epcm
->capture_idx_reg
= FXIDX
;
1200 substream
->runtime
->private_data
= epcm
;
1201 substream
->runtime
->private_free
= snd_emu10k1_pcm_free_substream
;
1202 runtime
->hw
= snd_emu10k1_capture
;
1203 runtime
->hw
.rates
= SNDRV_PCM_RATE_48000
;
1204 runtime
->hw
.rate_min
= runtime
->hw
.rate_max
= 48000;
1205 spin_lock_irq(&emu
->reg_lock
);
1206 runtime
->hw
.channels_min
= runtime
->hw
.channels_max
= 0;
1207 for (idx
= 0; idx
< nefx
; idx
++) {
1208 if (emu
->efx_voices_mask
[idx
/32] & (1 << (idx
%32))) {
1209 runtime
->hw
.channels_min
++;
1210 runtime
->hw
.channels_max
++;
1213 epcm
->capture_cr_val
= emu
->efx_voices_mask
[0];
1214 epcm
->capture_cr_val2
= emu
->efx_voices_mask
[1];
1215 spin_unlock_irq(&emu
->reg_lock
);
1216 emu
->capture_efx_interrupt
= snd_emu10k1_pcm_efx_interrupt
;
1217 emu
->pcm_capture_efx_substream
= substream
;
1218 snd_pcm_hw_constraint_list(runtime
, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES
, &hw_constraints_capture_period_sizes
);
1222 static int snd_emu10k1_capture_efx_close(struct snd_pcm_substream
*substream
)
1224 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1226 emu
->capture_interrupt
= NULL
;
1227 emu
->pcm_capture_efx_substream
= NULL
;
1231 static struct snd_pcm_ops snd_emu10k1_playback_ops
= {
1232 .open
= snd_emu10k1_playback_open
,
1233 .close
= snd_emu10k1_playback_close
,
1234 .ioctl
= snd_pcm_lib_ioctl
,
1235 .hw_params
= snd_emu10k1_playback_hw_params
,
1236 .hw_free
= snd_emu10k1_playback_hw_free
,
1237 .prepare
= snd_emu10k1_playback_prepare
,
1238 .trigger
= snd_emu10k1_playback_trigger
,
1239 .pointer
= snd_emu10k1_playback_pointer
,
1240 .page
= snd_pcm_sgbuf_ops_page
,
1243 static struct snd_pcm_ops snd_emu10k1_capture_ops
= {
1244 .open
= snd_emu10k1_capture_open
,
1245 .close
= snd_emu10k1_capture_close
,
1246 .ioctl
= snd_pcm_lib_ioctl
,
1247 .hw_params
= snd_emu10k1_capture_hw_params
,
1248 .hw_free
= snd_emu10k1_capture_hw_free
,
1249 .prepare
= snd_emu10k1_capture_prepare
,
1250 .trigger
= snd_emu10k1_capture_trigger
,
1251 .pointer
= snd_emu10k1_capture_pointer
,
1255 static struct snd_pcm_ops snd_emu10k1_efx_playback_ops
= {
1256 .open
= snd_emu10k1_efx_playback_open
,
1257 .close
= snd_emu10k1_efx_playback_close
,
1258 .ioctl
= snd_pcm_lib_ioctl
,
1259 .hw_params
= snd_emu10k1_playback_hw_params
,
1260 .hw_free
= snd_emu10k1_efx_playback_hw_free
,
1261 .prepare
= snd_emu10k1_efx_playback_prepare
,
1262 .trigger
= snd_emu10k1_efx_playback_trigger
,
1263 .pointer
= snd_emu10k1_efx_playback_pointer
,
1264 .page
= snd_pcm_sgbuf_ops_page
,
1267 int __devinit
snd_emu10k1_pcm(struct snd_emu10k1
* emu
, int device
, struct snd_pcm
** rpcm
)
1269 struct snd_pcm
*pcm
;
1270 struct snd_pcm_substream
*substream
;
1276 if ((err
= snd_pcm_new(emu
->card
, "emu10k1", device
, 32, 1, &pcm
)) < 0)
1279 pcm
->private_data
= emu
;
1281 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_emu10k1_playback_ops
);
1282 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_emu10k1_capture_ops
);
1284 pcm
->info_flags
= 0;
1285 pcm
->dev_subclass
= SNDRV_PCM_SUBCLASS_GENERIC_MIX
;
1286 strcpy(pcm
->name
, "ADC Capture/Standard PCM Playback");
1289 for (substream
= pcm
->streams
[SNDRV_PCM_STREAM_PLAYBACK
].substream
; substream
; substream
= substream
->next
)
1290 if ((err
= snd_pcm_lib_preallocate_pages(substream
, SNDRV_DMA_TYPE_DEV_SG
, snd_dma_pci_data(emu
->pci
), 64*1024, 64*1024)) < 0)
1293 for (substream
= pcm
->streams
[SNDRV_PCM_STREAM_CAPTURE
].substream
; substream
; substream
= substream
->next
)
1294 snd_pcm_lib_preallocate_pages(substream
, SNDRV_DMA_TYPE_DEV
, snd_dma_pci_data(emu
->pci
), 64*1024, 64*1024);
1302 int __devinit
snd_emu10k1_pcm_multi(struct snd_emu10k1
* emu
, int device
, struct snd_pcm
** rpcm
)
1304 struct snd_pcm
*pcm
;
1305 struct snd_pcm_substream
*substream
;
1311 if ((err
= snd_pcm_new(emu
->card
, "emu10k1", device
, 1, 0, &pcm
)) < 0)
1314 pcm
->private_data
= emu
;
1316 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_emu10k1_efx_playback_ops
);
1318 pcm
->info_flags
= 0;
1319 pcm
->dev_subclass
= SNDRV_PCM_SUBCLASS_GENERIC_MIX
;
1320 strcpy(pcm
->name
, "Multichannel Playback");
1321 emu
->pcm_multi
= pcm
;
1323 for (substream
= pcm
->streams
[SNDRV_PCM_STREAM_PLAYBACK
].substream
; substream
; substream
= substream
->next
)
1324 if ((err
= snd_pcm_lib_preallocate_pages(substream
, SNDRV_DMA_TYPE_DEV_SG
, snd_dma_pci_data(emu
->pci
), 64*1024, 64*1024)) < 0)
1334 static struct snd_pcm_ops snd_emu10k1_capture_mic_ops
= {
1335 .open
= snd_emu10k1_capture_mic_open
,
1336 .close
= snd_emu10k1_capture_mic_close
,
1337 .ioctl
= snd_pcm_lib_ioctl
,
1338 .hw_params
= snd_emu10k1_capture_hw_params
,
1339 .hw_free
= snd_emu10k1_capture_hw_free
,
1340 .prepare
= snd_emu10k1_capture_prepare
,
1341 .trigger
= snd_emu10k1_capture_trigger
,
1342 .pointer
= snd_emu10k1_capture_pointer
,
1345 int __devinit
snd_emu10k1_pcm_mic(struct snd_emu10k1
* emu
, int device
, struct snd_pcm
** rpcm
)
1347 struct snd_pcm
*pcm
;
1353 if ((err
= snd_pcm_new(emu
->card
, "emu10k1 mic", device
, 0, 1, &pcm
)) < 0)
1356 pcm
->private_data
= emu
;
1358 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_emu10k1_capture_mic_ops
);
1360 pcm
->info_flags
= 0;
1361 strcpy(pcm
->name
, "Mic Capture");
1364 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV
, snd_dma_pci_data(emu
->pci
), 64*1024, 64*1024);
1371 static int snd_emu10k1_pcm_efx_voices_mask_info(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_info
*uinfo
)
1373 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1374 int nefx
= emu
->audigy
? 64 : 32;
1375 uinfo
->type
= SNDRV_CTL_ELEM_TYPE_BOOLEAN
;
1376 uinfo
->count
= nefx
;
1377 uinfo
->value
.integer
.min
= 0;
1378 uinfo
->value
.integer
.max
= 1;
1382 static int snd_emu10k1_pcm_efx_voices_mask_get(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1384 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1385 int nefx
= emu
->audigy
? 64 : 32;
1388 spin_lock_irq(&emu
->reg_lock
);
1389 for (idx
= 0; idx
< nefx
; idx
++)
1390 ucontrol
->value
.integer
.value
[idx
] = (emu
->efx_voices_mask
[idx
/ 32] & (1 << (idx
% 32))) ? 1 : 0;
1391 spin_unlock_irq(&emu
->reg_lock
);
1395 static int snd_emu10k1_pcm_efx_voices_mask_put(struct snd_kcontrol
*kcontrol
, struct snd_ctl_elem_value
*ucontrol
)
1397 struct snd_emu10k1
*emu
= snd_kcontrol_chip(kcontrol
);
1398 unsigned int nval
[2], bits
;
1399 int nefx
= emu
->audigy
? 64 : 32;
1400 int nefxb
= emu
->audigy
? 7 : 6;
1403 nval
[0] = nval
[1] = 0;
1404 for (idx
= 0, bits
= 0; idx
< nefx
; idx
++)
1405 if (ucontrol
->value
.integer
.value
[idx
]) {
1406 nval
[idx
/ 32] |= 1 << (idx
% 32);
1410 for (idx
= 0; idx
< nefxb
; idx
++)
1411 if (1 << idx
== bits
)
1417 spin_lock_irq(&emu
->reg_lock
);
1418 change
= (nval
[0] != emu
->efx_voices_mask
[0]) ||
1419 (nval
[1] != emu
->efx_voices_mask
[1]);
1420 emu
->efx_voices_mask
[0] = nval
[0];
1421 emu
->efx_voices_mask
[1] = nval
[1];
1422 spin_unlock_irq(&emu
->reg_lock
);
1426 static struct snd_kcontrol_new snd_emu10k1_pcm_efx_voices_mask
= {
1427 .iface
= SNDRV_CTL_ELEM_IFACE_PCM
,
1428 .name
= "Captured FX8010 Outputs",
1429 .info
= snd_emu10k1_pcm_efx_voices_mask_info
,
1430 .get
= snd_emu10k1_pcm_efx_voices_mask_get
,
1431 .put
= snd_emu10k1_pcm_efx_voices_mask_put
1434 static struct snd_pcm_ops snd_emu10k1_capture_efx_ops
= {
1435 .open
= snd_emu10k1_capture_efx_open
,
1436 .close
= snd_emu10k1_capture_efx_close
,
1437 .ioctl
= snd_pcm_lib_ioctl
,
1438 .hw_params
= snd_emu10k1_capture_hw_params
,
1439 .hw_free
= snd_emu10k1_capture_hw_free
,
1440 .prepare
= snd_emu10k1_capture_prepare
,
1441 .trigger
= snd_emu10k1_capture_trigger
,
1442 .pointer
= snd_emu10k1_capture_pointer
,
1448 #define INITIAL_TRAM_SHIFT 14
1449 #define INITIAL_TRAM_POS(size) ((((size) / 2) - INITIAL_TRAM_SHIFT) - 1)
1451 static void snd_emu10k1_fx8010_playback_irq(struct snd_emu10k1
*emu
, void *private_data
)
1453 struct snd_pcm_substream
*substream
= private_data
;
1454 snd_pcm_period_elapsed(substream
);
1457 static void snd_emu10k1_fx8010_playback_tram_poke1(unsigned short *dst_left
,
1458 unsigned short *dst_right
,
1459 unsigned short *src
,
1461 unsigned int tram_shift
)
1463 // printk("tram_poke1: dst_left = 0x%p, dst_right = 0x%p, src = 0x%p, count = 0x%x\n", dst_left, dst_right, src, count);
1464 if ((tram_shift
& 1) == 0) {
1466 *dst_left
-- = *src
++;
1467 *dst_right
-- = *src
++;
1471 *dst_right
-- = *src
++;
1472 *dst_left
-- = *src
++;
1477 static void fx8010_pb_trans_copy(struct snd_pcm_substream
*substream
,
1478 struct snd_pcm_indirect
*rec
, size_t bytes
)
1480 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1481 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1482 unsigned int tram_size
= pcm
->buffer_size
;
1483 unsigned short *src
= (unsigned short *)(substream
->runtime
->dma_area
+ rec
->sw_data
);
1484 unsigned int frames
= bytes
>> 2, count
;
1485 unsigned int tram_pos
= pcm
->tram_pos
;
1486 unsigned int tram_shift
= pcm
->tram_shift
;
1488 while (frames
> tram_pos
) {
1489 count
= tram_pos
+ 1;
1490 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu
->fx8010
.etram_pages
.area
+ tram_pos
,
1491 (unsigned short *)emu
->fx8010
.etram_pages
.area
+ tram_pos
+ tram_size
/ 2,
1492 src
, count
, tram_shift
);
1495 tram_pos
= (tram_size
/ 2) - 1;
1498 snd_emu10k1_fx8010_playback_tram_poke1((unsigned short *)emu
->fx8010
.etram_pages
.area
+ tram_pos
,
1499 (unsigned short *)emu
->fx8010
.etram_pages
.area
+ tram_pos
+ tram_size
/ 2,
1500 src
, frames
, tram_shift
);
1502 pcm
->tram_pos
= tram_pos
;
1503 pcm
->tram_shift
= tram_shift
;
1506 static int snd_emu10k1_fx8010_playback_transfer(struct snd_pcm_substream
*substream
)
1508 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1509 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1511 snd_pcm_indirect_playback_transfer(substream
, &pcm
->pcm_rec
, fx8010_pb_trans_copy
);
1515 static int snd_emu10k1_fx8010_playback_hw_params(struct snd_pcm_substream
*substream
,
1516 struct snd_pcm_hw_params
*hw_params
)
1518 return snd_pcm_lib_malloc_pages(substream
, params_buffer_bytes(hw_params
));
1521 static int snd_emu10k1_fx8010_playback_hw_free(struct snd_pcm_substream
*substream
)
1523 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1524 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1527 for (i
= 0; i
< pcm
->channels
; i
++)
1528 snd_emu10k1_ptr_write(emu
, TANKMEMADDRREGBASE
+ 0x80 + pcm
->etram
[i
], 0, 0);
1529 snd_pcm_lib_free_pages(substream
);
1533 static int snd_emu10k1_fx8010_playback_prepare(struct snd_pcm_substream
*substream
)
1535 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1536 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1537 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1540 // printk("prepare: etram_pages = 0x%p, dma_area = 0x%x, buffer_size = 0x%x (0x%x)\n", emu->fx8010.etram_pages, runtime->dma_area, runtime->buffer_size, runtime->buffer_size << 2);
1541 memset(&pcm
->pcm_rec
, 0, sizeof(pcm
->pcm_rec
));
1542 pcm
->pcm_rec
.hw_buffer_size
= pcm
->buffer_size
* 2; /* byte size */
1543 pcm
->pcm_rec
.sw_buffer_size
= snd_pcm_lib_buffer_bytes(substream
);
1544 pcm
->tram_pos
= INITIAL_TRAM_POS(pcm
->buffer_size
);
1545 pcm
->tram_shift
= 0;
1546 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_running
, 0, 0); /* reset */
1547 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_trigger
, 0, 0); /* reset */
1548 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_size
, 0, runtime
->buffer_size
);
1549 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_ptr
, 0, 0); /* reset ptr number */
1550 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_count
, 0, runtime
->period_size
);
1551 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_tmpcount
, 0, runtime
->period_size
);
1552 for (i
= 0; i
< pcm
->channels
; i
++)
1553 snd_emu10k1_ptr_write(emu
, TANKMEMADDRREGBASE
+ 0x80 + pcm
->etram
[i
], 0, (TANKMEMADDRREG_READ
|TANKMEMADDRREG_ALIGN
) + i
* (runtime
->buffer_size
/ pcm
->channels
));
1557 static int snd_emu10k1_fx8010_playback_trigger(struct snd_pcm_substream
*substream
, int cmd
)
1559 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1560 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1563 spin_lock(&emu
->reg_lock
);
1565 case SNDRV_PCM_TRIGGER_START
:
1567 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
1568 case SNDRV_PCM_TRIGGER_RESUME
:
1569 #ifdef EMU10K1_SET_AC3_IEC958
1572 for (i
= 0; i
< 3; i
++) {
1574 bits
= SPCS_CLKACCY_1000PPM
| SPCS_SAMPLERATE_48
|
1575 SPCS_CHANNELNUM_LEFT
| SPCS_SOURCENUM_UNSPEC
| SPCS_GENERATIONSTATUS
|
1576 0x00001200 | SPCS_EMPHASIS_NONE
| SPCS_COPYRIGHT
| SPCS_NOTAUDIODATA
;
1577 snd_emu10k1_ptr_write(emu
, SPCS0
+ i
, 0, bits
);
1581 result
= snd_emu10k1_fx8010_register_irq_handler(emu
, snd_emu10k1_fx8010_playback_irq
, pcm
->gpr_running
, substream
, &pcm
->irq
);
1584 snd_emu10k1_fx8010_playback_transfer(substream
); /* roll the ball */
1585 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_trigger
, 0, 1);
1587 case SNDRV_PCM_TRIGGER_STOP
:
1588 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
1589 case SNDRV_PCM_TRIGGER_SUSPEND
:
1590 snd_emu10k1_fx8010_unregister_irq_handler(emu
, pcm
->irq
); pcm
->irq
= NULL
;
1591 snd_emu10k1_ptr_write(emu
, emu
->gpr_base
+ pcm
->gpr_trigger
, 0, 0);
1592 pcm
->tram_pos
= INITIAL_TRAM_POS(pcm
->buffer_size
);
1593 pcm
->tram_shift
= 0;
1600 spin_unlock(&emu
->reg_lock
);
1604 static snd_pcm_uframes_t
snd_emu10k1_fx8010_playback_pointer(struct snd_pcm_substream
*substream
)
1606 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1607 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1608 size_t ptr
; /* byte pointer */
1610 if (!snd_emu10k1_ptr_read(emu
, emu
->gpr_base
+ pcm
->gpr_trigger
, 0))
1612 ptr
= snd_emu10k1_ptr_read(emu
, emu
->gpr_base
+ pcm
->gpr_ptr
, 0) << 2;
1613 return snd_pcm_indirect_playback_pointer(substream
, &pcm
->pcm_rec
, ptr
);
1616 static struct snd_pcm_hardware snd_emu10k1_fx8010_playback
=
1618 .info
= (SNDRV_PCM_INFO_MMAP
| SNDRV_PCM_INFO_INTERLEAVED
|
1619 SNDRV_PCM_INFO_RESUME
|
1620 /* SNDRV_PCM_INFO_MMAP_VALID | */ SNDRV_PCM_INFO_PAUSE
),
1621 .formats
= SNDRV_PCM_FMTBIT_U8
| SNDRV_PCM_FMTBIT_S16_LE
,
1622 .rates
= SNDRV_PCM_RATE_48000
,
1627 .buffer_bytes_max
= (128*1024),
1628 .period_bytes_min
= 1024,
1629 .period_bytes_max
= (128*1024),
1631 .periods_max
= 1024,
1635 static int snd_emu10k1_fx8010_playback_open(struct snd_pcm_substream
*substream
)
1637 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1638 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
1639 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1641 runtime
->hw
= snd_emu10k1_fx8010_playback
;
1642 runtime
->hw
.channels_min
= runtime
->hw
.channels_max
= pcm
->channels
;
1643 runtime
->hw
.period_bytes_max
= (pcm
->buffer_size
* 2) / 2;
1644 spin_lock_irq(&emu
->reg_lock
);
1645 if (pcm
->valid
== 0) {
1646 spin_unlock_irq(&emu
->reg_lock
);
1650 spin_unlock_irq(&emu
->reg_lock
);
1654 static int snd_emu10k1_fx8010_playback_close(struct snd_pcm_substream
*substream
)
1656 struct snd_emu10k1
*emu
= snd_pcm_substream_chip(substream
);
1657 struct snd_emu10k1_fx8010_pcm
*pcm
= &emu
->fx8010
.pcm
[substream
->number
];
1659 spin_lock_irq(&emu
->reg_lock
);
1661 spin_unlock_irq(&emu
->reg_lock
);
1665 static struct snd_pcm_ops snd_emu10k1_fx8010_playback_ops
= {
1666 .open
= snd_emu10k1_fx8010_playback_open
,
1667 .close
= snd_emu10k1_fx8010_playback_close
,
1668 .ioctl
= snd_pcm_lib_ioctl
,
1669 .hw_params
= snd_emu10k1_fx8010_playback_hw_params
,
1670 .hw_free
= snd_emu10k1_fx8010_playback_hw_free
,
1671 .prepare
= snd_emu10k1_fx8010_playback_prepare
,
1672 .trigger
= snd_emu10k1_fx8010_playback_trigger
,
1673 .pointer
= snd_emu10k1_fx8010_playback_pointer
,
1674 .ack
= snd_emu10k1_fx8010_playback_transfer
,
1677 int __devinit
snd_emu10k1_pcm_efx(struct snd_emu10k1
* emu
, int device
, struct snd_pcm
** rpcm
)
1679 struct snd_pcm
*pcm
;
1680 struct snd_kcontrol
*kctl
;
1686 if ((err
= snd_pcm_new(emu
->card
, "emu10k1 efx", device
, 8, 1, &pcm
)) < 0)
1689 pcm
->private_data
= emu
;
1691 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &snd_emu10k1_fx8010_playback_ops
);
1692 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
, &snd_emu10k1_capture_efx_ops
);
1694 pcm
->info_flags
= 0;
1695 strcpy(pcm
->name
, "Multichannel Capture/PT Playback");
1700 /* EFX capture - record the "FXBUS2" channels, by default we connect the EXTINs
1704 /* emu->efx_voices_mask[0] = FXWC_DEFAULTROUTE_C | FXWC_DEFAULTROUTE_A; */
1706 emu
->efx_voices_mask
[0] = 0;
1707 emu
->efx_voices_mask
[1] = 0xffff;
1709 emu
->efx_voices_mask
[0] = 0xffff0000;
1710 emu
->efx_voices_mask
[1] = 0;
1712 kctl
= snd_ctl_new1(&snd_emu10k1_pcm_efx_voices_mask
, emu
);
1715 kctl
->id
.device
= device
;
1716 snd_ctl_add(emu
->card
, kctl
);
1718 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV
, snd_dma_pci_data(emu
->pci
), 64*1024, 64*1024);