aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ca0106/ca0106.h
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/ca0106/ca0106.h')
-rw-r--r--sound/pci/ca0106/ca0106.h549
1 files changed, 549 insertions, 0 deletions
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
new file mode 100644
index 000000000000..deb028851056
--- /dev/null
+++ b/sound/pci/ca0106/ca0106.h
@@ -0,0 +1,549 @@
1/*
2 * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk>
3 * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit
4 * Version: 0.0.20
5 *
6 * FEATURES currently supported:
7 * See ca0106_main.c for features.
8 *
9 * Changelog:
10 * Support interrupts per period.
11 * Removed noise from Center/LFE channel when in Analog mode.
12 * Rename and remove mixer controls.
13 * 0.0.6
14 * Use separate card based DMA buffer for periods table list.
15 * 0.0.7
16 * Change remove and rename ctrls into lists.
17 * 0.0.8
18 * Try to fix capture sources.
19 * 0.0.9
20 * Fix AC3 output.
21 * Enable S32_LE format support.
22 * 0.0.10
23 * Enable playback 48000 and 96000 rates. (Rates other that these do not work, even with "plug:front".)
24 * 0.0.11
25 * Add Model name recognition.
26 * 0.0.12
27 * Correct interrupt timing. interrupt at end of period, instead of in the middle of a playback period.
28 * Remove redundent "voice" handling.
29 * 0.0.13
30 * Single trigger call for multi channels.
31 * 0.0.14
32 * Set limits based on what the sound card hardware can do.
33 * playback periods_min=2, periods_max=8
34 * capture hw constraints require period_size = n * 64 bytes.
35 * playback hw constraints require period_size = n * 64 bytes.
36 * 0.0.15
37 * Separated ca0106.c into separate functional .c files.
38 * 0.0.16
39 * Implement 192000 sample rate.
40 * 0.0.17
41 * Add support for SB0410 and SB0413.
42 * 0.0.18
43 * Modified Copyright message.
44 * 0.0.19
45 * Added I2C and SPI registers. Filled in interrupt enable.
46 * 0.0.20
47 * Added GPIO info for SB Live 24bit.
48 *
49 *
50 * This code was initally based on code from ALSA's emu10k1x.c which is:
51 * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com>
52 *
53 * This program is free software; you can redistribute it and/or modify
54 * it under the terms of the GNU General Public License as published by
55 * the Free Software Foundation; either version 2 of the License, or
56 * (at your option) any later version.
57 *
58 * This program is distributed in the hope that it will be useful,
59 * but WITHOUT ANY WARRANTY; without even the implied warranty of
60 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61 * GNU General Public License for more details.
62 *
63 * You should have received a copy of the GNU General Public License
64 * along with this program; if not, write to the Free Software
65 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
66 *
67 */
68
69/************************************************************************************************/
70/* PCI function 0 registers, address = <val> + PCIBASE0 */
71/************************************************************************************************/
72
73#define PTR 0x00 /* Indexed register set pointer register */
74 /* NOTE: The CHANNELNUM and ADDRESS words can */
75 /* be modified independently of each other. */
76 /* CNL[1:0], ADDR[27:16] */
77
78#define DATA 0x04 /* Indexed register set data register */
79 /* DATA[31:0] */
80
81#define IPR 0x08 /* Global interrupt pending register */
82 /* Clear pending interrupts by writing a 1 to */
83 /* the relevant bits and zero to the other bits */
84#define IPR_MIDI_RX_B 0x00020000 /* MIDI UART-B Receive buffer non-empty */
85#define IPR_MIDI_TX_B 0x00010000 /* MIDI UART-B Transmit buffer empty */
86#define IPR_SPDIF_IN_USER 0x00004000 /* SPDIF input user data has 16 more bits */
87#define IPR_SPDIF_OUT_USER 0x00002000 /* SPDIF output user data needs 16 more bits */
88#define IPR_SPDIF_OUT_FRAME 0x00001000 /* SPDIF frame about to start */
89#define IPR_SPI 0x00000800 /* SPI transaction completed */
90#define IPR_I2C_EEPROM 0x00000400 /* I2C EEPROM transaction completed */
91#define IPR_I2C_DAC 0x00000200 /* I2C DAC transaction completed */
92#define IPR_AI 0x00000100 /* Audio pending register changed. See PTR reg 0x76 */
93#define IPR_GPI 0x00000080 /* General Purpose input changed */
94#define IPR_SRC_LOCKED 0x00000040 /* SRC lock status changed */
95#define IPR_SPDIF_STATUS 0x00000020 /* SPDIF status changed */
96#define IPR_TIMER2 0x00000010 /* 192000Hz Timer */
97#define IPR_TIMER1 0x00000008 /* 44100Hz Timer */
98#define IPR_MIDI_RX_A 0x00000004 /* MIDI UART-A Receive buffer non-empty */
99#define IPR_MIDI_TX_A 0x00000002 /* MIDI UART-A Transmit buffer empty */
100#define IPR_PCI 0x00000001 /* PCI Bus error */
101
102#define INTE 0x0c /* Interrupt enable register */
103
104#define INTE_MIDI_RX_B 0x00020000 /* MIDI UART-B Receive buffer non-empty */
105#define INTE_MIDI_TX_B 0x00010000 /* MIDI UART-B Transmit buffer empty */
106#define INTE_SPDIF_IN_USER 0x00004000 /* SPDIF input user data has 16 more bits */
107#define INTE_SPDIF_OUT_USER 0x00002000 /* SPDIF output user data needs 16 more bits */
108#define INTE_SPDIF_OUT_FRAME 0x00001000 /* SPDIF frame about to start */
109#define INTE_SPI 0x00000800 /* SPI transaction completed */
110#define INTE_I2C_EEPROM 0x00000400 /* I2C EEPROM transaction completed */
111#define INTE_I2C_DAC 0x00000200 /* I2C DAC transaction completed */
112#define INTE_AI 0x00000100 /* Audio pending register changed. See PTR reg 0x75 */
113#define INTE_GPI 0x00000080 /* General Purpose input changed */
114#define INTE_SRC_LOCKED 0x00000040 /* SRC lock status changed */
115#define INTE_SPDIF_STATUS 0x00000020 /* SPDIF status changed */
116#define INTE_TIMER2 0x00000010 /* 192000Hz Timer */
117#define INTE_TIMER1 0x00000008 /* 44100Hz Timer */
118#define INTE_MIDI_RX_A 0x00000004 /* MIDI UART-A Receive buffer non-empty */
119#define INTE_MIDI_TX_A 0x00000002 /* MIDI UART-A Transmit buffer empty */
120#define INTE_PCI 0x00000001 /* PCI Bus error */
121
122#define UNKNOWN10 0x10 /* Unknown ??. Defaults to 0 */
123#define HCFG 0x14 /* Hardware config register */
124 /* 0x1000 causes AC3 to fails. It adds a dither bit. */
125
126#define HCFG_STAC 0x10000000 /* Special mode for STAC9460 Codec. */
127#define HCFG_CAPTURE_I2S_BYPASS 0x08000000 /* 1 = bypass I2S input async SRC. */
128#define HCFG_CAPTURE_SPDIF_BYPASS 0x04000000 /* 1 = bypass SPDIF input async SRC. */
129#define HCFG_PLAYBACK_I2S_BYPASS 0x02000000 /* 0 = I2S IN mixer output, 1 = I2S IN1. */
130#define HCFG_FORCE_LOCK 0x01000000 /* For test only. Force input SRC tracker to lock. */
131#define HCFG_PLAYBACK_ATTENUATION 0x00006000 /* Playback attenuation mask. 0 = 0dB, 1 = 6dB, 2 = 12dB, 3 = Mute. */
132#define HCFG_PLAYBACK_DITHER 0x00001000 /* 1 = Add dither bit to all playback channels. */
133#define HCFG_PLAYBACK_S32_LE 0x00000800 /* 1 = S32_LE, 0 = S16_LE */
134#define HCFG_CAPTURE_S32_LE 0x00000400 /* 1 = S32_LE, 0 = S16_LE (S32_LE current not working) */
135#define HCFG_8_CHANNEL_PLAY 0x00000200 /* 1 = 8 channels, 0 = 2 channels per substream.*/
136#define HCFG_8_CHANNEL_CAPTURE 0x00000100 /* 1 = 8 channels, 0 = 2 channels per substream.*/
137#define HCFG_MONO 0x00000080 /* 1 = I2S Input mono */
138#define HCFG_I2S_OUTPUT 0x00000010 /* 1 = I2S Output disabled */
139#define HCFG_AC97 0x00000008 /* 0 = AC97 1.0, 1 = AC97 2.0 */
140#define HCFG_LOCK_PLAYBACK_CACHE 0x00000004 /* 1 = Cancel bustmaster accesses to soundcache */
141 /* NOTE: This should generally never be used. */
142#define HCFG_LOCK_CAPTURE_CACHE 0x00000002 /* 1 = Cancel bustmaster accesses to soundcache */
143 /* NOTE: This should generally never be used. */
144#define HCFG_AUDIOENABLE 0x00000001 /* 0 = CODECs transmit zero-valued samples */
145 /* Should be set to 1 when the EMU10K1 is */
146 /* completely initialized. */
147#define GPIO 0x18 /* Defaults: 005f03a3-Analog, 005f02a2-SPDIF. */
148 /* Here pins 0,1,2,3,4,,6 are output. 5,7 are input */
149 /* For the Audigy LS, pin 0 (or bit 8) controls the SPDIF/Analog jack. */
150 /* SB Live 24bit:
151 * bit 8 0 = SPDIF in and out / 1 = Analog (Mic or Line)-in.
152 * bit 9 0 = Mute / 1 = Analog out.
153 * bit 10 0 = Line-in / 1 = Mic-in.
154 * bit 11 0 = ? / 1 = ?
155 * bit 12 0 = ? / 1 = ?
156 * bit 13 0 = ? / 1 = ?
157 * bit 14 0 = Mute / 1 = Analog out
158 * bit 15 0 = ? / 1 = ?
159 * Both bit 9 and bit 14 have to be set for analog sound to work on the SB Live 24bit.
160 */
161 /* 8 general purpose programmable In/Out pins.
162 * GPI [8:0] Read only. Default 0.
163 * GPO [15:8] Default 0x9. (Default to SPDIF jack enabled for SPDIF)
164 * GPO Enable [23:16] Default 0x0f. Setting a bit to 1, causes the pin to be an output pin.
165 */
166#define AC97DATA 0x1c /* AC97 register set data register (16 bit) */
167
168#define AC97ADDRESS 0x1e /* AC97 register set address register (8 bit) */
169
170/********************************************************************************************************/
171/* CA0106 pointer-offset register set, accessed through the PTR and DATA registers */
172/********************************************************************************************************/
173
174/* Initally all registers from 0x00 to 0x3f have zero contents. */
175#define PLAYBACK_LIST_ADDR 0x00 /* Base DMA address of a list of pointers to each period/size */
176 /* One list entry: 4 bytes for DMA address,
177 * 4 bytes for period_size << 16.
178 * One list entry is 8 bytes long.
179 * One list entry for each period in the buffer.
180 */
181 /* ADDR[31:0], Default: 0x0 */
182#define PLAYBACK_LIST_SIZE 0x01 /* Size of list in bytes << 16. E.g. 8 periods -> 0x00380000 */
183 /* SIZE[21:16], Default: 0x8 */
184#define PLAYBACK_LIST_PTR 0x02 /* Pointer to the current period being played */
185 /* PTR[5:0], Default: 0x0 */
186#define PLAYBACK_UNKNOWN3 0x03 /* Not used ?? */
187#define PLAYBACK_DMA_ADDR 0x04 /* Playback DMA addresss */
188 /* DMA[31:0], Default: 0x0 */
189#define PLAYBACK_PERIOD_SIZE 0x05 /* Playback period size. win2000 uses 0x04000000 */
190 /* SIZE[31:16], Default: 0x0 */
191#define PLAYBACK_POINTER 0x06 /* Playback period pointer. Used with PLAYBACK_LIST_PTR to determine buffer position currently in DAC */
192 /* POINTER[15:0], Default: 0x0 */
193#define PLAYBACK_PERIOD_END_ADDR 0x07 /* Playback fifo end address */
194 /* END_ADDR[15:0], FLAG[16] 0 = don't stop, 1 = stop */
195#define PLAYBACK_FIFO_OFFSET_ADDRESS 0x08 /* Current fifo offset address [21:16] */
196 /* Cache size valid [5:0] */
197#define PLAYBACK_UNKNOWN9 0x09 /* 0x9 to 0xf Unused */
198#define CAPTURE_DMA_ADDR 0x10 /* Capture DMA address */
199 /* DMA[31:0], Default: 0x0 */
200#define CAPTURE_BUFFER_SIZE 0x11 /* Capture buffer size */
201 /* SIZE[31:16], Default: 0x0 */
202#define CAPTURE_POINTER 0x12 /* Capture buffer pointer. Sample currently in ADC */
203 /* POINTER[15:0], Default: 0x0 */
204#define CAPTURE_FIFO_OFFSET_ADDRESS 0x13 /* Current fifo offset address [21:16] */
205 /* Cache size valid [5:0] */
206#define PLAYBACK_LAST_SAMPLE 0x20 /* The sample currently being played */
207/* 0x21 - 0x3f unused */
208#define BASIC_INTERRUPT 0x40 /* Used by both playback and capture interrupt handler */
209 /* Playback (0x1<<channel_id) */
210 /* Capture (0x100<<channel_id) */
211 /* Playback sample rate 96000 = 0x20000 */
212 /* Start Playback [3:0] (one bit per channel)
213 * Start Capture [11:8] (one bit per channel)
214 * Playback rate [23:16] (2 bits per channel) (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
215 * Playback mixer in enable [27:24] (one bit per channel)
216 * Playback mixer out enable [31:28] (one bit per channel)
217 */
218/* The Digital out jack is shared with the Center/LFE Analogue output.
219 * The jack has 4 poles. I will call 1 - Tip, 2 - Next to 1, 3 - Next to 2, 4 - Next to 3
220 * For Analogue: 1 -> Center Speaker, 2 -> Sub Woofer, 3 -> Ground, 4 -> Ground
221 * For Digital: 1 -> Front SPDIF, 2 -> Rear SPDIF, 3 -> Center/Subwoofer SPDIF, 4 -> Ground.
222 * Standard 4 pole Video A/V cable with RCA outputs: 1 -> White, 2 -> Yellow, 3 -> Sheild on all three, 4 -> Red.
223 * So, from this you can see that you cannot use a Standard 4 pole Video A/V cable with the SB Audigy LS card.
224 */
225/* The Front SPDIF PCM gets mixed with samples from the AC97 codec, so can only work for Stereo PCM and not AC3/DTS
226 * The Rear SPDIF can be used for Stereo PCM and also AC3/DTS
227 * The Center/LFE SPDIF cannot be used for AC3/DTS, but can be used for Stereo PCM.
228 * Summary: For ALSA we use the Rear channel for SPDIF Digital AC3/DTS output
229 */
230/* A standard 2 pole mono mini-jack to RCA plug can be used for SPDIF Stereo PCM output from the Front channel.
231 * A standard 3 pole stereo mini-jack to 2 RCA plugs can be used for SPDIF AC3/DTS and Stereo PCM output utilising the Rear channel and just one of the RCA plugs.
232 */
233#define SPCS0 0x41 /* SPDIF output Channel Status 0 register. For Rear. default=0x02108004, non-audio=0x02108006 */
234#define SPCS1 0x42 /* SPDIF output Channel Status 1 register. For Front */
235#define SPCS2 0x43 /* SPDIF output Channel Status 2 register. For Center/LFE */
236#define SPCS3 0x44 /* SPDIF output Channel Status 3 register. Unknown */
237 /* When Channel set to 0: */
238#define SPCS_CLKACCYMASK 0x30000000 /* Clock accuracy */
239#define SPCS_CLKACCY_1000PPM 0x00000000 /* 1000 parts per million */
240#define SPCS_CLKACCY_50PPM 0x10000000 /* 50 parts per million */
241#define SPCS_CLKACCY_VARIABLE 0x20000000 /* Variable accuracy */
242#define SPCS_SAMPLERATEMASK 0x0f000000 /* Sample rate */
243#define SPCS_SAMPLERATE_44 0x00000000 /* 44.1kHz sample rate */
244#define SPCS_SAMPLERATE_48 0x02000000 /* 48kHz sample rate */
245#define SPCS_SAMPLERATE_32 0x03000000 /* 32kHz sample rate */
246#define SPCS_CHANNELNUMMASK 0x00f00000 /* Channel number */
247#define SPCS_CHANNELNUM_UNSPEC 0x00000000 /* Unspecified channel number */
248#define SPCS_CHANNELNUM_LEFT 0x00100000 /* Left channel */
249#define SPCS_CHANNELNUM_RIGHT 0x00200000 /* Right channel */
250#define SPCS_SOURCENUMMASK 0x000f0000 /* Source number */
251#define SPCS_SOURCENUM_UNSPEC 0x00000000 /* Unspecified source number */
252#define SPCS_GENERATIONSTATUS 0x00008000 /* Originality flag (see IEC-958 spec) */
253#define SPCS_CATEGORYCODEMASK 0x00007f00 /* Category code (see IEC-958 spec) */
254#define SPCS_MODEMASK 0x000000c0 /* Mode (see IEC-958 spec) */
255#define SPCS_EMPHASISMASK 0x00000038 /* Emphasis */
256#define SPCS_EMPHASIS_NONE 0x00000000 /* No emphasis */
257#define SPCS_EMPHASIS_50_15 0x00000008 /* 50/15 usec 2 channel */
258#define SPCS_COPYRIGHT 0x00000004 /* Copyright asserted flag -- do not modify */
259#define SPCS_NOTAUDIODATA 0x00000002 /* 0 = Digital audio, 1 = not audio */
260#define SPCS_PROFESSIONAL 0x00000001 /* 0 = Consumer (IEC-958), 1 = pro (AES3-1992) */
261
262 /* When Channel set to 1: */
263#define SPCS_WORD_LENGTH_MASK 0x0000000f /* Word Length Mask */
264#define SPCS_WORD_LENGTH_16 0x00000008 /* Word Length 16 bit */
265#define SPCS_WORD_LENGTH_17 0x00000006 /* Word Length 17 bit */
266#define SPCS_WORD_LENGTH_18 0x00000004 /* Word Length 18 bit */
267#define SPCS_WORD_LENGTH_19 0x00000002 /* Word Length 19 bit */
268#define SPCS_WORD_LENGTH_20A 0x0000000a /* Word Length 20 bit */
269#define SPCS_WORD_LENGTH_20 0x00000009 /* Word Length 20 bit (both 0xa and 0x9 are 20 bit) */
270#define SPCS_WORD_LENGTH_21 0x00000007 /* Word Length 21 bit */
271#define SPCS_WORD_LENGTH_21 0x00000007 /* Word Length 21 bit */
272#define SPCS_WORD_LENGTH_22 0x00000005 /* Word Length 22 bit */
273#define SPCS_WORD_LENGTH_23 0x00000003 /* Word Length 23 bit */
274#define SPCS_WORD_LENGTH_24 0x0000000b /* Word Length 24 bit */
275#define SPCS_ORIGINAL_SAMPLE_RATE_MASK 0x000000f0 /* Original Sample rate */
276#define SPCS_ORIGINAL_SAMPLE_RATE_NONE 0x00000000 /* Original Sample rate not indicated */
277#define SPCS_ORIGINAL_SAMPLE_RATE_16000 0x00000010 /* Original Sample rate */
278#define SPCS_ORIGINAL_SAMPLE_RATE_RES1 0x00000020 /* Original Sample rate */
279#define SPCS_ORIGINAL_SAMPLE_RATE_32000 0x00000030 /* Original Sample rate */
280#define SPCS_ORIGINAL_SAMPLE_RATE_12000 0x00000040 /* Original Sample rate */
281#define SPCS_ORIGINAL_SAMPLE_RATE_11025 0x00000050 /* Original Sample rate */
282#define SPCS_ORIGINAL_SAMPLE_RATE_8000 0x00000060 /* Original Sample rate */
283#define SPCS_ORIGINAL_SAMPLE_RATE_RES2 0x00000070 /* Original Sample rate */
284#define SPCS_ORIGINAL_SAMPLE_RATE_192000 0x00000080 /* Original Sample rate */
285#define SPCS_ORIGINAL_SAMPLE_RATE_24000 0x00000090 /* Original Sample rate */
286#define SPCS_ORIGINAL_SAMPLE_RATE_96000 0x000000a0 /* Original Sample rate */
287#define SPCS_ORIGINAL_SAMPLE_RATE_48000 0x000000b0 /* Original Sample rate */
288#define SPCS_ORIGINAL_SAMPLE_RATE_176400 0x000000c0 /* Original Sample rate */
289#define SPCS_ORIGINAL_SAMPLE_RATE_22050 0x000000d0 /* Original Sample rate */
290#define SPCS_ORIGINAL_SAMPLE_RATE_88200 0x000000e0 /* Original Sample rate */
291#define SPCS_ORIGINAL_SAMPLE_RATE_44100 0x000000f0 /* Original Sample rate */
292
293#define SPDIF_SELECT1 0x45 /* Enables SPDIF or Analogue outputs 0-SPDIF, 0xf00-Analogue */
294 /* 0x100 - Front, 0x800 - Rear, 0x200 - Center/LFE.
295 * But as the jack is shared, use 0xf00.
296 * The Windows2000 driver uses 0x0000000f for both digital and analog.
297 * 0xf00 introduces interesting noises onto the Center/LFE.
298 * If you turn the volume up, you hear computer noise,
299 * e.g. mouse moving, changing between app windows etc.
300 * So, I am going to set this to 0x0000000f all the time now,
301 * same as the windows driver does.
302 * Use register SPDIF_SELECT2(0x72) to switch between SPDIF and Analog.
303 */
304 /* When Channel = 0:
305 * Wide SPDIF format [3:0] (one bit for each channel) (0=20bit, 1=24bit)
306 * Tristate SPDIF Output [11:8] (one bit for each channel) (0=Not tristate, 1=Tristate)
307 * SPDIF Bypass enable [19:16] (one bit for each channel) (0=Not bypass, 1=Bypass)
308 */
309 /* When Channel = 1:
310 * SPDIF 0 User data [7:0]
311 * SPDIF 1 User data [15:8]
312 * SPDIF 0 User data [23:16]
313 * SPDIF 0 User data [31:24]
314 * User data can be sent by using the SPDIF output frame pending and SPDIF output user bit interrupts.
315 */
316#define WATERMARK 0x46 /* Test bit to indicate cache usage level */
317#define SPDIF_INPUT_STATUS 0x49 /* SPDIF Input status register. Bits the same as SPCS.
318 * When Channel = 0: Bits the same as SPCS channel 0.
319 * When Channel = 1: Bits the same as SPCS channel 1.
320 * When Channel = 2:
321 * SPDIF Input User data [16:0]
322 * SPDIF Input Frame count [21:16]
323 */
324#define CAPTURE_CACHE_DATA 0x50 /* 0x50-0x5f Recorded samples. */
325#define CAPTURE_SOURCE 0x60 /* Capture Source 0 = MIC */
326#define CAPTURE_SOURCE_CHANNEL0 0xf0000000 /* Mask for selecting the Capture sources */
327#define CAPTURE_SOURCE_CHANNEL1 0x0f000000 /* 0 - SPDIF mixer output. */
328#define CAPTURE_SOURCE_CHANNEL2 0x00f00000 /* 1 - What you hear or . 2 - ?? */
329#define CAPTURE_SOURCE_CHANNEL3 0x000f0000 /* 3 - Mic in, Line in, TAD in, Aux in. */
330#define CAPTURE_SOURCE_RECORD_MAP 0x0000ffff /* Default 0x00e4 */
331 /* Record Map [7:0] (2 bits per channel) 0=mapped to channel 0, 1=mapped to channel 1, 2=mapped to channel2, 3=mapped to channel3
332 * Record source select for channel 0 [18:16]
333 * Record source select for channel 1 [22:20]
334 * Record source select for channel 2 [26:24]
335 * Record source select for channel 3 [30:28]
336 * 0 - SPDIF mixer output.
337 * 1 - i2s mixer output.
338 * 2 - SPDIF input.
339 * 3 - i2s input.
340 * 4 - AC97 capture.
341 * 5 - SRC output.
342 */
343#define CAPTURE_VOLUME1 0x61 /* Capture volume per channel 0-3 */
344#define CAPTURE_VOLUME2 0x62 /* Capture volume per channel 4-7 */
345
346#define PLAYBACK_ROUTING1 0x63 /* Playback routing of channels 0-7. Effects AC3 output. Default 0x32765410 */
347#define ROUTING1_REAR 0x77000000 /* Channel_id 0 sends to 10, Channel_id 1 sends to 32 */
348#define ROUTING1_NULL 0x00770000 /* Channel_id 2 sends to 54, Channel_id 3 sends to 76 */
349#define ROUTING1_CENTER_LFE 0x00007700 /* 0x32765410 means, send Channel_id 0 to FRONT, Channel_id 1 to REAR */
350#define ROUTING1_FRONT 0x00000077 /* Channel_id 2 to CENTER_LFE, Channel_id 3 to NULL. */
351 /* Channel_id's handle stereo channels. Channel X is a single mono channel */
352 /* Host is input from the PCI bus. */
353 /* Host channel 0 [2:0] -> SPDIF Mixer/Router channel 0-7.
354 * Host channel 1 [6:4] -> SPDIF Mixer/Router channel 0-7.
355 * Host channel 2 [10:8] -> SPDIF Mixer/Router channel 0-7.
356 * Host channel 3 [14:12] -> SPDIF Mixer/Router channel 0-7.
357 * Host channel 4 [18:16] -> SPDIF Mixer/Router channel 0-7.
358 * Host channel 5 [22:20] -> SPDIF Mixer/Router channel 0-7.
359 * Host channel 6 [26:24] -> SPDIF Mixer/Router channel 0-7.
360 * Host channel 7 [30:28] -> SPDIF Mixer/Router channel 0-7.
361 */
362
363#define PLAYBACK_ROUTING2 0x64 /* Playback Routing . Feeding Capture channels back into Playback. Effects AC3 output. Default 0x76767676 */
364 /* SRC is input from the capture inputs. */
365 /* SRC channel 0 [2:0] -> SPDIF Mixer/Router channel 0-7.
366 * SRC channel 1 [6:4] -> SPDIF Mixer/Router channel 0-7.
367 * SRC channel 2 [10:8] -> SPDIF Mixer/Router channel 0-7.
368 * SRC channel 3 [14:12] -> SPDIF Mixer/Router channel 0-7.
369 * SRC channel 4 [18:16] -> SPDIF Mixer/Router channel 0-7.
370 * SRC channel 5 [22:20] -> SPDIF Mixer/Router channel 0-7.
371 * SRC channel 6 [26:24] -> SPDIF Mixer/Router channel 0-7.
372 * SRC channel 7 [30:28] -> SPDIF Mixer/Router channel 0-7.
373 */
374
375#define PLAYBACK_MUTE 0x65 /* Unknown. While playing 0x0, while silent 0x00fc0000 */
376 /* SPDIF Mixer input control:
377 * Invert SRC to SPDIF Mixer [7-0] (One bit per channel)
378 * Invert Host to SPDIF Mixer [15:8] (One bit per channel)
379 * SRC to SPDIF Mixer disable [23:16] (One bit per channel)
380 * Host to SPDIF Mixer disable [31:24] (One bit per channel)
381 */
382#define PLAYBACK_VOLUME1 0x66 /* Playback SPDIF volume per channel. Set to the same PLAYBACK_VOLUME(0x6a) */
383 /* PLAYBACK_VOLUME1 must be set to 30303030 for SPDIF AC3 Playback */
384 /* SPDIF mixer input volume. 0=12dB, 0x30=0dB, 0xFE=-51.5dB, 0xff=Mute */
385 /* One register for each of the 4 stereo streams. */
386 /* SRC Right volume [7:0]
387 * SRC Left volume [15:8]
388 * Host Right volume [23:16]
389 * Host Left volume [31:24]
390 */
391#define CAPTURE_ROUTING1 0x67 /* Capture Routing. Default 0x32765410 */
392 /* Similar to register 0x63, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
393#define CAPTURE_ROUTING2 0x68 /* Unknown Routing. Default 0x76767676 */
394 /* Similar to register 0x64, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
395#define CAPTURE_MUTE 0x69 /* Unknown. While capturing 0x0, while silent 0x00fc0000 */
396 /* Similar to register 0x65, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
397#define PLAYBACK_VOLUME2 0x6a /* Playback Analog volume per channel. Does not effect AC3 output */
398 /* Similar to register 0x66, except that the destination is the I2S mixer instead of the SPDIF mixer. I.E. Outputs to the Analog outputs instead of SPDIF. */
399#define UNKNOWN6b 0x6b /* Unknown. Readonly. Default 00400000 00400000 00400000 00400000 */
400#define UART_A_DATA 0x6c /* Uart, used in setting sample rates, bits per sample etc. */
401#define UART_A_CMD 0x6d /* Uart, used in setting sample rates, bits per sample etc. */
402#define UART_B_DATA 0x6e /* Uart, Unknown. */
403#define UART_B_CMD 0x6f /* Uart, Unknown. */
404#define SAMPLE_RATE_TRACKER_STATUS 0x70 /* Readonly. Default 00108000 00108000 00500000 00500000 */
405 /* Estimated sample rate [19:0] Relative to 48kHz. 0x8000 = 1.0
406 * Rate Locked [20]
407 * SPDIF Locked [21] For SPDIF channel only.
408 * Valid Audio [22] For SPDIF channel only.
409 */
410#define CAPTURE_CONTROL 0x71 /* Some sort of routing. default = 40c81000 30303030 30300000 00700000 */
411 /* Channel_id 0: 0x40c81000 must be changed to 0x40c80000 for SPDIF AC3 input or output. */
412 /* Channel_id 1: 0xffffffff(mute) 0x30303030(max) controls CAPTURE feedback into PLAYBACK. */
413 /* Sample rate output control register Channel=0
414 * Sample output rate [1:0] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
415 * Sample input rate [3:2] (0=48kHz, 1=Not available, 2=96kHz, 3=192Khz)
416 * SRC input source select [4] 0=Audio from digital mixer, 1=Audio from analog source.
417 * Record rate [9:8] (0=48kHz, 1=Not available, 2=96kHz, 3=192Khz)
418 * Record mixer output enable [12:10]
419 * I2S input rate master mode [15:14] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
420 * I2S output rate [17:16] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
421 * I2S output source select [18] (0=Audio from host, 1=Audio from SRC)
422 * Record mixer I2S enable [20:19] (enable/disable i2sin1 and i2sin0)
423 * I2S output master clock select [21] (0=256*I2S output rate, 1=512*I2S output rate.)
424 * I2S input master clock select [22] (0=256*I2S input rate, 1=512*I2S input rate.)
425 * I2S input mode [23] (0=Slave, 1=Master)
426 * SPDIF output rate [25:24] (0=48kHz, 1=44.1kHz, 2=96kHz, 3=192Khz)
427 * SPDIF output source select [26] (0=host, 1=SRC)
428 * Not used [27]
429 * Record Source 0 input [29:28] (0=SPDIF in, 1=I2S in, 2=AC97 Mic, 3=AC97 PCM)
430 * Record Source 1 input [31:30] (0=SPDIF in, 1=I2S in, 2=AC97 Mic, 3=AC97 PCM)
431 */
432 /* Sample rate output control register Channel=1
433 * I2S Input 0 volume Right [7:0]
434 * I2S Input 0 volume Left [15:8]
435 * I2S Input 1 volume Right [23:16]
436 * I2S Input 1 volume Left [31:24]
437 */
438 /* Sample rate output control register Channel=2
439 * SPDIF Input volume Right [23:16]
440 * SPDIF Input volume Left [31:24]
441 */
442 /* Sample rate output control register Channel=3
443 * No used
444 */
445#define SPDIF_SELECT2 0x72 /* Some sort of routing. Channel_id 0 only. default = 0x0f0f003f. Analog 0x000b0000, Digital 0x0b000000 */
446#define ROUTING2_FRONT_MASK 0x00010000 /* Enable for Front speakers. */
447#define ROUTING2_CENTER_LFE_MASK 0x00020000 /* Enable for Center/LFE speakers. */
448#define ROUTING2_REAR_MASK 0x00080000 /* Enable for Rear speakers. */
449 /* Audio output control
450 * AC97 output enable [5:0]
451 * I2S output enable [19:16]
452 * SPDIF output enable [27:24]
453 */
454#define UNKNOWN73 0x73 /* Unknown. Readonly. Default 0x0 */
455#define CHIP_VERSION 0x74 /* P17 Chip version. Channel_id 0 only. Default 00000071 */
456#define EXTENDED_INT_MASK 0x75 /* Used by both playback and capture interrupt handler */
457 /* Sets which Interrupts are enabled. */
458 /* 0x00000001 = Half period. Playback.
459 * 0x00000010 = Full period. Playback.
460 * 0x00000100 = Half buffer. Playback.
461 * 0x00001000 = Full buffer. Playback.
462 * 0x00010000 = Half buffer. Capture.
463 * 0x00100000 = Full buffer. Capture.
464 * Capture can only do 2 periods.
465 * 0x01000000 = End audio. Playback.
466 * 0x40000000 = Half buffer Playback,Caputre xrun.
467 * 0x80000000 = Full buffer Playback,Caputre xrun.
468 */
469#define EXTENDED_INT 0x76 /* Used by both playback and capture interrupt handler */
470 /* Shows which interrupts are active at the moment. */
471 /* Same bit layout as EXTENDED_INT_MASK */
472#define COUNTER77 0x77 /* Counter range 0 to 0x3fffff, 192000 counts per second. */
473#define COUNTER78 0x78 /* Counter range 0 to 0x3fffff, 44100 counts per second. */
474#define EXTENDED_INT_TIMER 0x79 /* Channel_id 0 only. Used by both playback and capture interrupt handler */
475 /* Causes interrupts based on timer intervals. */
476#define SPI 0x7a /* SPI: Serial Interface Register */
477#define I2C_A 0x7b /* I2C Address. 32 bit */
478#define I2C_0 0x7c /* I2C Data Port 0. 32 bit */
479#define I2C_1 0x7d /* I2C Data Port 1. 32 bit */
480
481
482#define SET_CHANNEL 0 /* Testing channel outputs 0=Front, 1=Center/LFE, 2=Unknown, 3=Rear */
483#define PCM_FRONT_CHANNEL 0
484#define PCM_REAR_CHANNEL 1
485#define PCM_CENTER_LFE_CHANNEL 2
486#define PCM_UNKNOWN_CHANNEL 3
487#define CONTROL_FRONT_CHANNEL 0
488#define CONTROL_REAR_CHANNEL 3
489#define CONTROL_CENTER_LFE_CHANNEL 1
490#define CONTROL_UNKNOWN_CHANNEL 2
491
492typedef struct snd_ca0106_channel ca0106_channel_t;
493typedef struct snd_ca0106 ca0106_t;
494typedef struct snd_ca0106_pcm ca0106_pcm_t;
495
496struct snd_ca0106_channel {
497 ca0106_t *emu;
498 int number;
499 int use;
500 void (*interrupt)(ca0106_t *emu, ca0106_channel_t *channel);
501 ca0106_pcm_t *epcm;
502};
503
504struct snd_ca0106_pcm {
505 ca0106_t *emu;
506 snd_pcm_substream_t *substream;
507 int channel_id;
508 unsigned short running;
509};
510
511// definition of the chip-specific record
512struct snd_ca0106 {
513 snd_card_t *card;
514 struct pci_dev *pci;
515
516 unsigned long port;
517 struct resource *res_port;
518 int irq;
519
520 unsigned int revision; /* chip revision */
521 unsigned int serial; /* serial number */
522 unsigned short model; /* subsystem id */
523
524 spinlock_t emu_lock;
525
526 ac97_t *ac97;
527 snd_pcm_t *pcm;
528
529 ca0106_channel_t playback_channels[4];
530 ca0106_channel_t capture_channels[4];
531 u32 spdif_bits[4]; /* s/pdif out setup */
532 int spdif_enable;
533 int capture_source;
534
535 struct snd_dma_buffer buffer;
536};
537
538int __devinit snd_ca0106_mixer(ca0106_t *emu);
539int __devinit snd_ca0106_proc_init(ca0106_t * emu);
540
541unsigned int snd_ca0106_ptr_read(ca0106_t * emu,
542 unsigned int reg,
543 unsigned int chn);
544
545void snd_ca0106_ptr_write(ca0106_t *emu,
546 unsigned int reg,
547 unsigned int chn,
548 unsigned int data);
549