2 **********************************************************************
3 * recmgr.c -- Recording manager for emu10k1 driver
4 * Copyright 1999, 2000 Creative Labs, Inc.
6 **********************************************************************
8 * Date Author Summary of changes
9 * ---- ------ ------------------
10 * October 20, 1999 Bertrand Lee base code release
12 **********************************************************************
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public
25 * License along with this program; if not, write to the Free
26 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
29 **********************************************************************
32 #include <linux/delay.h>
36 void emu10k1_reset_record(struct emu10k1_card *card, struct wavein_buffer *buffer)
38 DPF(2, "emu10k1_reset_record()\n");
40 sblive_writeptr(card, buffer->sizereg, 0, ADCBS_BUFSIZE_NONE);
42 sblive_writeptr(card, buffer->sizereg, 0, buffer->sizeregval);
44 while (sblive_readptr(card, buffer->idxreg, 0))
48 void emu10k1_start_record(struct emu10k1_card *card, struct wavein_buffer *buffer)
50 DPF(2, "emu10k1_start_record()\n");
53 sblive_writeptr(card, ADCCR, 0, buffer->adcctl);
56 void emu10k1_stop_record(struct emu10k1_card *card, struct wavein_buffer *buffer)
58 DPF(2, "emu10k1_stop_record()\n");
60 /* Disable record transfer */
62 sblive_writeptr(card, ADCCR, 0, 0);
65 void emu10k1_set_record_src(struct emu10k1_card *card, struct wiinst *wiinst)
67 struct wavein_buffer *buffer = &wiinst->buffer;
69 DPF(2, "emu10k1_set_record_src()\n");
71 switch (wiinst->recsrc) {
74 DPF(2, "recording source: AC97\n");
75 buffer->sizereg = ADCBS;
76 buffer->addrreg = ADCBA;
77 buffer->idxreg = card->is_audigy ? A_ADCIDX_IDX : ADCIDX_IDX;
79 switch (wiinst->format.samplingrate) {
81 buffer->adcctl = ADCCR_SAMPLERATE_48;
84 buffer->adcctl = ADCCR_SAMPLERATE_44;
87 buffer->adcctl = ADCCR_SAMPLERATE_32;
90 buffer->adcctl = ADCCR_SAMPLERATE_24;
93 buffer->adcctl = ADCCR_SAMPLERATE_22;
96 buffer->adcctl = ADCCR_SAMPLERATE_16;
98 // FIXME: audigy supports 12kHz recording
101 buffer->adcctl = A_ADCCR_SAMPLERATE_12;
105 buffer->adcctl = card->is_audigy ? A_ADCCR_SAMPLERATE_11 : ADCCR_SAMPLERATE_11;
108 buffer->adcctl = card->is_audigy ? A_ADCCR_SAMPLERATE_8 : ADCCR_SAMPLERATE_8;
115 buffer->adcctl |= card->is_audigy ? A_ADCCR_LCHANENABLE : ADCCR_LCHANENABLE;
117 if (wiinst->format.channels == 2)
118 buffer->adcctl |= card->is_audigy ? A_ADCCR_RCHANENABLE : ADCCR_RCHANENABLE;
123 DPF(2, "recording source: MIC\n");
124 buffer->sizereg = MICBS;
125 buffer->addrreg = MICBA;
126 buffer->idxreg = MICIDX_IDX;
131 DPF(2, "recording source: FX\n");
132 buffer->sizereg = FXBS;
133 buffer->addrreg = FXBA;
134 buffer->idxreg = FXIDX_IDX;
137 sblive_writeptr(card, FXWC, 0, wiinst->fxwc);
144 DPD(2, "bus addx: %#lx\n", (unsigned long) buffer->dma_handle);
146 sblive_writeptr(card, buffer->addrreg, 0, (u32)buffer->dma_handle);