Pull cpuidle into release branch
[pandora-kernel.git] / Documentation / sound / alsa / CMIPCI.txt
1          Brief Notes on C-Media 8338/8738/8768/8770 Driver
2          =================================================
3
4                    Takashi Iwai <tiwai@suse.de>
5
6
7 Front/Rear Multi-channel Playback
8 ---------------------------------
9
10 CM8x38 chip can use ADC as the second DAC so that two different stereo
11 channels can be used for front/rear playbacks.  Since there are two
12 DACs, both streams are handled independently unlike the 4/6ch multi-
13 channel playbacks in the section below.
14
15 As default, ALSA driver assigns the first PCM device (i.e. hw:0,0 for
16 card#0) for front and 4/6ch playbacks, while the second PCM device
17 (hw:0,1) is assigned to the second DAC for rear playback.
18
19 There are slight differences between the two DACs:
20
21 - The first DAC supports U8 and S16LE formats, while the second DAC
22   supports only S16LE.
23 - The second DAC supports only two channel stereo.
24
25 Please note that the CM8x38 DAC doesn't support continuous playback
26 rate but only fixed rates: 5512, 8000, 11025, 16000, 22050, 32000,
27 44100 and 48000 Hz.
28
29 The rear output can be heard only when "Four Channel Mode" switch is
30 disabled.  Otherwise no signal will be routed to the rear speakers.
31 As default it's turned on.
32
33 *** WARNING ***
34 When "Four Channel Mode" switch is off, the output from rear speakers
35 will be FULL VOLUME regardless of Master and PCM volumes.
36 This might damage your audio equipment.  Please disconnect speakers
37 before your turn off this switch.
38 *** WARNING ***
39
40 [ Well.. I once got the output with correct volume (i.e. same with the
41   front one) and was so excited.  It was even with "Four Channel" bit
42   on and "double DAC" mode.  Actually I could hear separate 4 channels
43   from front and rear speakers!  But.. after reboot, all was gone.
44   It's a very pity that I didn't save the register dump at that
45   time..  Maybe there is an unknown register to achieve this... ]
46
47 If your card has an extra output jack for the rear output, the rear
48 playback should be routed there as default.  If not, there is a
49 control switch in the driver "Line-In As Rear", which you can change
50 via alsamixer or somewhat else.  When this switch is on, line-in jack
51 is used as rear output.
52
53 There are two more controls regarding to the rear output.
54 The "Exchange DAC" switch is used to exchange front and rear playback
55 routes, i.e. the 2nd DAC is output from front output.
56
57
58 4/6 Multi-Channel Playback
59 --------------------------
60
61 The recent CM8738 chips support for the 4/6 multi-channel playback
62 function.  This is useful especially for AC3 decoding.
63
64 When the multi-channel is supported, the driver name has a suffix
65 "-MC" such like "CMI8738-MC6".  You can check this name from
66 /proc/asound/cards.
67
68 When the 4/6-ch output is enabled, the second DAC accepts up to 6 (or
69 4) channels.  While the dual DAC supports two different rates or
70 formats, the 4/6-ch playback supports only the same condition for all
71 channels.  Since the multi-channel playback mode uses both DACs, you
72 cannot operate with full-duplex.
73
74 The 4.0 and 5.1 modes are defined as the pcm "surround40" and "surround51"
75 in alsa-lib.  For example, you can play a WAV file with 6 channels like
76
77         % aplay -Dsurround51 sixchannels.wav
78
79 For programming the 4/6 channel playback, you need to specify the PCM
80 channels as you like and set the format S16LE.  For example, for playback
81 with 4 channels,
82
83         snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED);
84             // or mmap if you like
85         snd_pcm_hw_params_set_format(pcm, hw, SND_PCM_FORMAT_S16_LE);
86         snd_pcm_hw_params_set_channels(pcm, hw, 4);
87
88 and use the interleaved 4 channel data.
89
90 There are some control switchs affecting to the speaker connections:
91
92 "Line-In Mode"  - an enum control to change the behavior of line-in
93         jack.  Either "Line-In", "Rear Output" or "Bass Output" can
94         be selected.  The last item is available only with model 039
95         or newer. 
96         When "Rear Output" is chosen, the surround channels 3 and 4
97         are output to line-in jack.
98 "Mic-In Mode"   - an enum control to change the behavior of mic-in
99         jack.  Either "Mic-In" or "Center/LFE Output" can be
100         selected. 
101         When "Center/LFE Output" is chosen, the center and bass
102         channels (channels 5 and 6) are output to mic-in jack. 
103
104 Digital I/O
105 -----------
106
107 The CM8x38 provides the excellent SPDIF capability with very cheap
108 price (yes, that's the reason I bought the card :)
109
110 The SPDIF playback and capture are done via the third PCM device
111 (hw:0,2).  Usually this is assigned to the PCM device "spdif".
112 The available rates are 44100 and 48000 Hz.
113 For playback with aplay, you can run like below:
114
115         % aplay -Dhw:0,2 foo.wav
116
117 or
118
119         % aplay -Dspdif foo.wav
120
121 24bit format is also supported experimentally.
122
123 The playback and capture over SPDIF use normal DAC and ADC,
124 respectively, so you cannot playback both analog and digital streams
125 simultaneously.
126
127 To enable SPDIF output, you need to turn on "IEC958 Output Switch"
128 control via mixer or alsactl ("IEC958" is the official name of
129 so-called S/PDIF).  Then you'll see the red light on from the card so
130 you know that's working obviously :)
131 The SPDIF input is always enabled, so you can hear SPDIF input data
132 from line-out with "IEC958 In Monitor" switch at any time (see
133 below).
134
135 You can play via SPDIF even with the first device (hw:0,0),
136 but SPDIF is enabled only when the proper format (S16LE), sample rate
137 (441100 or 48000) and channels (2) are used.  Otherwise it's turned
138 off.  (Also don't forget to turn on "IEC958 Output Switch", too.)
139
140
141 Additionally there are relevant control switches:
142
143 "IEC958 Mix Analog" - Mix analog PCM playback and FM-OPL/3 streams and
144         output through SPDIF.  This switch appears only on old chip
145         models (CM8738 033 and 037).
146         Note: without this control you can output PCM to SPDIF.
147         This is "mixing" of streams, so e.g. it's not for AC3 output
148         (see the next section).
149
150 "IEC958 In Select"  - Select SPDIF input, the internal CD-in (false)
151         and the external input (true).
152
153 "IEC958 Loop"       - SPDIF input data is loop back into SPDIF
154         output (aka bypass)
155
156 "IEC958 Copyright"  - Set the copyright bit.
157
158 "IEC958 5V"         - Select 0.5V (coax) or 5V (optical) interface.
159         On some cards this doesn't work and you need to change the
160         configuration with hardware dip-switch.
161
162 "IEC958 In Monitor" - SPDIF input is routed to DAC.
163
164 "IEC958 In Phase Inverse" - Set SPDIF input format as inverse.
165         [FIXME: this doesn't work on all chips..]
166
167 "IEC958 In Valid"   - Set input validity flag detection.
168
169 Note: When "PCM Playback Switch" is on, you'll hear the digital output
170 stream through analog line-out.
171
172
173 The AC3 (RAW DIGITAL) OUTPUT
174 ----------------------------
175
176 The driver supports raw digital (typically AC3) i/o over SPDIF.  This
177 can be toggled via IEC958 playback control, but usually you need to
178 access it via alsa-lib.  See alsa-lib documents for more details.
179
180 On the raw digital mode, the "PCM Playback Switch" is automatically
181 turned off so that non-audio data is heard from the analog line-out.
182 Similarly the following switches are off: "IEC958 Mix Analog" and
183 "IEC958 Loop".  The switches are resumed after closing the SPDIF PCM
184 device automatically to the previous state.
185
186 On the model 033, AC3 is implemented by the software conversion in
187 the alsa-lib.  If you need to bypass the software conversion of IEC958
188 subframes, pass the "soft_ac3=0" module option.  This doesn't matter
189 on the newer models.
190
191
192 ANALOG MIXER INTERFACE
193 ----------------------
194
195 The mixer interface on CM8x38 is similar to SB16.
196 There are Master, PCM, Synth, CD, Line, Mic and PC Speaker playback
197 volumes.  Synth, CD, Line and Mic have playback and capture switches,
198 too, as well as SB16.
199
200 In addition to the standard SB mixer, CM8x38 provides more functions.
201 - PCM playback switch
202 - PCM capture switch (to capture the data sent to DAC)
203 - Mic Boost switch
204 - Mic capture volume
205 - Aux playback volume/switch and capture switch
206 - 3D control switch
207
208
209 MIDI CONTROLLER
210 ---------------
211
212 With CMI8338 chips, the MPU401-UART interface is disabled as default.
213 You need to set the module option "mpu_port" to a valid I/O port address
214 to enable MIDI support.  Valid I/O ports are 0x300, 0x310, 0x320 and
215 0x330.  Choose a value that doesn't conflict with other cards.
216
217 With CMI8738 and newer chips, the MIDI interface is enabled by default
218 and the driver automatically chooses a port address.
219
220 There is _no_ hardware wavetable function on this chip (except for
221 OPL3 synth below).
222 What's said as MIDI synth on Windows is a software synthesizer
223 emulation.  On Linux use TiMidity or other softsynth program for
224 playing MIDI music.
225
226
227 FM OPL/3 Synth
228 --------------
229
230 The FM OPL/3 is also enabled as default only for the first card.
231 Set "fm_port" module option for more cards.
232
233 The output quality of FM OPL/3 is, however, very weird.
234 I don't know why..
235
236 CMI8768 and newer chips do not have the FM synth.
237
238
239 Joystick and Modem
240 ------------------
241
242 The legacy joystick is supported.  To enable the joystick support, pass
243 joystick_port=1 module option.  The value 1 means the auto-detection.
244 If the auto-detection fails, try to pass the exact I/O address.
245
246 The modem is enabled dynamically via a card control switch "Modem".
247
248
249 Debugging Information
250 ---------------------
251
252 The registers are shown in /proc/asound/cardX/cmipci.  If you have any
253 problem (especially unexpected behavior of mixer), please attach the
254 output of this proc file together with the bug report.