0001 =================================================
0002 Brief Notes on C-Media 8338/8738/8768/8770 Driver
0003 =================================================
0004
0005 Takashi Iwai <tiwai@suse.de>
0006
0007
0008 Front/Rear Multi-channel Playback
0009 ---------------------------------
0010
0011 CM8x38 chip can use ADC as the second DAC so that two different stereo
0012 channels can be used for front/rear playbacks. Since there are two
0013 DACs, both streams are handled independently unlike the 4/6ch multi-
0014 channel playbacks in the section below.
0015
0016 As default, ALSA driver assigns the first PCM device (i.e. hw:0,0 for
0017 card#0) for front and 4/6ch playbacks, while the second PCM device
0018 (hw:0,1) is assigned to the second DAC for rear playback.
0019
0020 There are slight differences between the two DACs:
0021
0022 - The first DAC supports U8 and S16LE formats, while the second DAC
0023 supports only S16LE.
0024 - The second DAC supports only two channel stereo.
0025
0026 Please note that the CM8x38 DAC doesn't support continuous playback
0027 rate but only fixed rates: 5512, 8000, 11025, 16000, 22050, 32000,
0028 44100 and 48000 Hz.
0029
0030 The rear output can be heard only when "Four Channel Mode" switch is
0031 disabled. Otherwise no signal will be routed to the rear speakers.
0032 As default it's turned on.
0033
0034 .. WARNING::
0035 When "Four Channel Mode" switch is off, the output from rear speakers
0036 will be FULL VOLUME regardless of Master and PCM volumes [#]_.
0037 This might damage your audio equipment. Please disconnect speakers
0038 before your turn off this switch.
0039
0040
0041 .. [#]
0042 Well.. I once got the output with correct volume (i.e. same with the
0043 front one) and was so excited. It was even with "Four Channel" bit
0044 on and "double DAC" mode. Actually I could hear separate 4 channels
0045 from front and rear speakers! But.. after reboot, all was gone.
0046 It's a very pity that I didn't save the register dump at that
0047 time.. Maybe there is an unknown register to achieve this...
0048
0049 If your card has an extra output jack for the rear output, the rear
0050 playback should be routed there as default. If not, there is a
0051 control switch in the driver "Line-In As Rear", which you can change
0052 via alsamixer or somewhat else. When this switch is on, line-in jack
0053 is used as rear output.
0054
0055 There are two more controls regarding to the rear output.
0056 The "Exchange DAC" switch is used to exchange front and rear playback
0057 routes, i.e. the 2nd DAC is output from front output.
0058
0059
0060 4/6 Multi-Channel Playback
0061 --------------------------
0062
0063 The recent CM8738 chips support for the 4/6 multi-channel playback
0064 function. This is useful especially for AC3 decoding.
0065
0066 When the multi-channel is supported, the driver name has a suffix
0067 "-MC" such like "CMI8738-MC6". You can check this name from
0068 /proc/asound/cards.
0069
0070 When the 4/6-ch output is enabled, the second DAC accepts up to 6 (or
0071 4) channels. While the dual DAC supports two different rates or
0072 formats, the 4/6-ch playback supports only the same condition for all
0073 channels. Since the multi-channel playback mode uses both DACs, you
0074 cannot operate with full-duplex.
0075
0076 The 4.0 and 5.1 modes are defined as the pcm "surround40" and "surround51"
0077 in alsa-lib. For example, you can play a WAV file with 6 channels like
0078 ::
0079
0080 % aplay -Dsurround51 sixchannels.wav
0081
0082 For programming the 4/6 channel playback, you need to specify the PCM
0083 channels as you like and set the format S16LE. For example, for playback
0084 with 4 channels,
0085 ::
0086
0087 snd_pcm_hw_params_set_access(pcm, hw, SND_PCM_ACCESS_RW_INTERLEAVED);
0088 // or mmap if you like
0089 snd_pcm_hw_params_set_format(pcm, hw, SND_PCM_FORMAT_S16_LE);
0090 snd_pcm_hw_params_set_channels(pcm, hw, 4);
0091
0092 and use the interleaved 4 channel data.
0093
0094 There are some control switches affecting to the speaker connections:
0095
0096 Line-In Mode
0097 an enum control to change the behavior of line-in
0098 jack. Either "Line-In", "Rear Output" or "Bass Output" can
0099 be selected. The last item is available only with model 039
0100 or newer.
0101 When "Rear Output" is chosen, the surround channels 3 and 4
0102 are output to line-in jack.
0103 Mic-In Mode
0104 an enum control to change the behavior of mic-in
0105 jack. Either "Mic-In" or "Center/LFE Output" can be
0106 selected.
0107 When "Center/LFE Output" is chosen, the center and bass
0108 channels (channels 5 and 6) are output to mic-in jack.
0109
0110 Digital I/O
0111 -----------
0112
0113 The CM8x38 provides the excellent SPDIF capability with very cheap
0114 price (yes, that's the reason I bought the card :)
0115
0116 The SPDIF playback and capture are done via the third PCM device
0117 (hw:0,2). Usually this is assigned to the PCM device "spdif".
0118 The available rates are 44100 and 48000 Hz.
0119 For playback with aplay, you can run like below:
0120 ::
0121
0122 % aplay -Dhw:0,2 foo.wav
0123
0124 or
0125
0126 ::
0127
0128 % aplay -Dspdif foo.wav
0129
0130 24bit format is also supported experimentally.
0131
0132 The playback and capture over SPDIF use normal DAC and ADC,
0133 respectively, so you cannot playback both analog and digital streams
0134 simultaneously.
0135
0136 To enable SPDIF output, you need to turn on "IEC958 Output Switch"
0137 control via mixer or alsactl ("IEC958" is the official name of
0138 so-called S/PDIF). Then you'll see the red light on from the card so
0139 you know that's working obviously :)
0140 The SPDIF input is always enabled, so you can hear SPDIF input data
0141 from line-out with "IEC958 In Monitor" switch at any time (see
0142 below).
0143
0144 You can play via SPDIF even with the first device (hw:0,0),
0145 but SPDIF is enabled only when the proper format (S16LE), sample rate
0146 (441100 or 48000) and channels (2) are used. Otherwise it's turned
0147 off. (Also don't forget to turn on "IEC958 Output Switch", too.)
0148
0149
0150 Additionally there are relevant control switches:
0151
0152 IEC958 Mix Analog
0153 Mix analog PCM playback and FM-OPL/3 streams and
0154 output through SPDIF. This switch appears only on old chip
0155 models (CM8738 033 and 037).
0156
0157 Note: without this control you can output PCM to SPDIF.
0158 This is "mixing" of streams, so e.g. it's not for AC3 output
0159 (see the next section).
0160
0161 IEC958 In Select
0162 Select SPDIF input, the internal CD-in (false)
0163 and the external input (true).
0164
0165 IEC958 Loop
0166 SPDIF input data is loop back into SPDIF
0167 output (aka bypass)
0168
0169 IEC958 Copyright
0170 Set the copyright bit.
0171
0172 IEC958 5V
0173 Select 0.5V (coax) or 5V (optical) interface.
0174 On some cards this doesn't work and you need to change the
0175 configuration with hardware dip-switch.
0176
0177 IEC958 In Monitor
0178 SPDIF input is routed to DAC.
0179
0180 IEC958 In Phase Inverse
0181 Set SPDIF input format as inverse.
0182 [FIXME: this doesn't work on all chips..]
0183
0184 IEC958 In Valid
0185 Set input validity flag detection.
0186
0187 Note: When "PCM Playback Switch" is on, you'll hear the digital output
0188 stream through analog line-out.
0189
0190
0191 The AC3 (RAW DIGITAL) OUTPUT
0192 ----------------------------
0193
0194 The driver supports raw digital (typically AC3) i/o over SPDIF. This
0195 can be toggled via IEC958 playback control, but usually you need to
0196 access it via alsa-lib. See alsa-lib documents for more details.
0197
0198 On the raw digital mode, the "PCM Playback Switch" is automatically
0199 turned off so that non-audio data is heard from the analog line-out.
0200 Similarly the following switches are off: "IEC958 Mix Analog" and
0201 "IEC958 Loop". The switches are resumed after closing the SPDIF PCM
0202 device automatically to the previous state.
0203
0204 On the model 033, AC3 is implemented by the software conversion in
0205 the alsa-lib. If you need to bypass the software conversion of IEC958
0206 subframes, pass the "soft_ac3=0" module option. This doesn't matter
0207 on the newer models.
0208
0209
0210 ANALOG MIXER INTERFACE
0211 ----------------------
0212
0213 The mixer interface on CM8x38 is similar to SB16.
0214 There are Master, PCM, Synth, CD, Line, Mic and PC Speaker playback
0215 volumes. Synth, CD, Line and Mic have playback and capture switches,
0216 too, as well as SB16.
0217
0218 In addition to the standard SB mixer, CM8x38 provides more functions.
0219 - PCM playback switch
0220 - PCM capture switch (to capture the data sent to DAC)
0221 - Mic Boost switch
0222 - Mic capture volume
0223 - Aux playback volume/switch and capture switch
0224 - 3D control switch
0225
0226
0227 MIDI CONTROLLER
0228 ---------------
0229
0230 With CMI8338 chips, the MPU401-UART interface is disabled as default.
0231 You need to set the module option "mpu_port" to a valid I/O port address
0232 to enable MIDI support. Valid I/O ports are 0x300, 0x310, 0x320 and
0233 0x330. Choose a value that doesn't conflict with other cards.
0234
0235 With CMI8738 and newer chips, the MIDI interface is enabled by default
0236 and the driver automatically chooses a port address.
0237
0238 There is *no* hardware wavetable function on this chip (except for
0239 OPL3 synth below).
0240 What's said as MIDI synth on Windows is a software synthesizer
0241 emulation. On Linux use TiMidity or other softsynth program for
0242 playing MIDI music.
0243
0244
0245 FM OPL/3 Synth
0246 --------------
0247
0248 The FM OPL/3 is also enabled as default only for the first card.
0249 Set "fm_port" module option for more cards.
0250
0251 The output quality of FM OPL/3 is, however, very weird.
0252 I don't know why..
0253
0254 CMI8768 and newer chips do not have the FM synth.
0255
0256
0257 Joystick and Modem
0258 ------------------
0259
0260 The legacy joystick is supported. To enable the joystick support, pass
0261 joystick_port=1 module option. The value 1 means the auto-detection.
0262 If the auto-detection fails, try to pass the exact I/O address.
0263
0264 The modem is enabled dynamically via a card control switch "Modem".
0265
0266
0267 Debugging Information
0268 ---------------------
0269
0270 The registers are shown in /proc/asound/cardX/cmipci. If you have any
0271 problem (especially unexpected behavior of mixer), please attach the
0272 output of this proc file together with the bug report.