xref: /OK3568_Linux_fs/kernel/Documentation/sound/hd-audio/notes.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun=============================
2*4882a593SmuzhiyunMore Notes on HD-Audio Driver
3*4882a593Smuzhiyun=============================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunTakashi Iwai <tiwai@suse.de>
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunGeneral
9*4882a593Smuzhiyun=======
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunHD-audio is the new standard on-board audio component on modern PCs
12*4882a593Smuzhiyunafter AC97.  Although Linux has been supporting HD-audio since long
13*4882a593Smuzhiyuntime ago, there are often problems with new machines.  A part of the
14*4882a593Smuzhiyunproblem is broken BIOS, and the rest is the driver implementation.
15*4882a593SmuzhiyunThis document explains the brief trouble-shooting and debugging
16*4882a593Smuzhiyunmethods for the	HD-audio hardware.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunThe HD-audio component consists of two parts: the controller chip and
19*4882a593Smuzhiyunthe codec chips on the HD-audio bus.  Linux provides a single driver
20*4882a593Smuzhiyunfor all controllers, snd-hda-intel.  Although the driver name contains
21*4882a593Smuzhiyuna word of a well-known hardware vendor, it's not specific to it but for
22*4882a593Smuzhiyunall controller chips by other companies.  Since the HD-audio
23*4882a593Smuzhiyuncontrollers are supposed to be compatible, the single snd-hda-driver
24*4882a593Smuzhiyunshould work in most cases.  But, not surprisingly, there are known
25*4882a593Smuzhiyunbugs and issues specific to each controller type.  The snd-hda-intel
26*4882a593Smuzhiyundriver has a bunch of workarounds for these as described below.
27*4882a593Smuzhiyun
28*4882a593SmuzhiyunA controller may have multiple codecs.  Usually you have one audio
29*4882a593Smuzhiyuncodec and optionally one modem codec.  In theory, there might be
30*4882a593Smuzhiyunmultiple audio codecs, e.g. for analog and digital outputs, and the
31*4882a593Smuzhiyundriver might not work properly because of conflict of mixer elements.
32*4882a593SmuzhiyunThis should be fixed in future if such hardware really exists.
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunThe snd-hda-intel driver has several different codec parsers depending
35*4882a593Smuzhiyunon the codec.  It has a generic parser as a fallback, but this
36*4882a593Smuzhiyunfunctionality is fairly limited until now.  Instead of the generic
37*4882a593Smuzhiyunparser, usually the codec-specific parser (coded in patch_*.c) is used
38*4882a593Smuzhiyunfor the codec-specific implementations.  The details about the
39*4882a593Smuzhiyuncodec-specific problems are explained in the later sections.
40*4882a593Smuzhiyun
41*4882a593SmuzhiyunIf you are interested in the deep debugging of HD-audio, read the
42*4882a593SmuzhiyunHD-audio specification at first.  The specification is found on
43*4882a593SmuzhiyunIntel's web page, for example:
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun* https://www.intel.com/standards/hdaudio/
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunHD-Audio Controller
49*4882a593Smuzhiyun===================
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunDMA-Position Problem
52*4882a593Smuzhiyun--------------------
53*4882a593SmuzhiyunThe most common problem of the controller is the inaccurate DMA
54*4882a593Smuzhiyunpointer reporting.  The DMA pointer for playback and capture can be
55*4882a593Smuzhiyunread in two ways, either via a LPIB register or via a position-buffer
56*4882a593Smuzhiyunmap.  As default the driver tries to read from the io-mapped
57*4882a593Smuzhiyunposition-buffer, and falls back to LPIB if the position-buffer appears
58*4882a593Smuzhiyundead.  However, this detection isn't perfect on some devices.  In such
59*4882a593Smuzhiyuna case, you can change the default method via ``position_fix`` option.
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun``position_fix=1`` means to use LPIB method explicitly.
62*4882a593Smuzhiyun``position_fix=2`` means to use the position-buffer.
63*4882a593Smuzhiyun``position_fix=3`` means to use a combination of both methods, needed
64*4882a593Smuzhiyunfor some VIA controllers.  The capture stream position is corrected
65*4882a593Smuzhiyunby comparing both LPIB and position-buffer values.
66*4882a593Smuzhiyun``position_fix=4`` is another combination available for all controllers,
67*4882a593Smuzhiyunand uses LPIB for the playback and the position-buffer for the capture
68*4882a593Smuzhiyunstreams.
69*4882a593Smuzhiyun``position_fix=5`` is specific to Intel platforms, so far, for Skylake
70*4882a593Smuzhiyunand onward.  It applies the delay calculation for the precise position
71*4882a593Smuzhiyunreporting.
72*4882a593Smuzhiyun``position_fix=6`` is to correct the position with the fixed FIFO
73*4882a593Smuzhiyunsize, mainly targeted for the recent AMD controllers.
74*4882a593Smuzhiyun0 is the default value for all other
75*4882a593Smuzhiyuncontrollers, the automatic check and fallback to LPIB as described in
76*4882a593Smuzhiyunthe above.  If you get a problem of repeated sounds, this option might
77*4882a593Smuzhiyunhelp.
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunIn addition to that, every controller is known to be broken regarding
80*4882a593Smuzhiyunthe wake-up timing.  It wakes up a few samples before actually
81*4882a593Smuzhiyunprocessing the data on the buffer.  This caused a lot of problems, for
82*4882a593Smuzhiyunexample, with ALSA dmix or JACK.  Since 2.6.27 kernel, the driver puts
83*4882a593Smuzhiyunan artificial delay to the wake up timing.  This delay is controlled
84*4882a593Smuzhiyunvia ``bdl_pos_adj`` option.
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunWhen ``bdl_pos_adj`` is a negative value (as default), it's assigned to
87*4882a593Smuzhiyunan appropriate value depending on the controller chip.  For Intel
88*4882a593Smuzhiyunchips, it'd be 1 while it'd be 32 for others.  Usually this works.
89*4882a593SmuzhiyunOnly in case it doesn't work and you get warning messages, you should
90*4882a593Smuzhiyunchange this parameter to other values.
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun
93*4882a593SmuzhiyunCodec-Probing Problem
94*4882a593Smuzhiyun---------------------
95*4882a593SmuzhiyunA less often but a more severe problem is the codec probing.  When
96*4882a593SmuzhiyunBIOS reports the available codec slots wrongly, the driver gets
97*4882a593Smuzhiyunconfused and tries to access the non-existing codec slot.  This often
98*4882a593Smuzhiyunresults in the total screw-up, and destructs the further communication
99*4882a593Smuzhiyunwith the codec chips.  The symptom appears usually as error messages
100*4882a593Smuzhiyunlike:
101*4882a593Smuzhiyun::
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun    hda_intel: azx_get_response timeout, switching to polling mode:
104*4882a593Smuzhiyun          last cmd=0x12345678
105*4882a593Smuzhiyun    hda_intel: azx_get_response timeout, switching to single_cmd mode:
106*4882a593Smuzhiyun          last cmd=0x12345678
107*4882a593Smuzhiyun
108*4882a593SmuzhiyunThe first line is a warning, and this is usually relatively harmless.
109*4882a593SmuzhiyunIt means that the codec response isn't notified via an IRQ.  The
110*4882a593Smuzhiyundriver uses explicit polling method to read the response.  It gives
111*4882a593Smuzhiyunvery slight CPU overhead, but you'd unlikely notice it.
112*4882a593Smuzhiyun
113*4882a593SmuzhiyunThe second line is, however, a fatal error.  If this happens, usually
114*4882a593Smuzhiyunit means that something is really wrong.  Most likely you are
115*4882a593Smuzhiyunaccessing a non-existing codec slot.
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunThus, if the second error message appears, try to narrow the probed
118*4882a593Smuzhiyuncodec slots via ``probe_mask`` option.  It's a bitmask, and each bit
119*4882a593Smuzhiyuncorresponds to the codec slot.  For example, to probe only the first
120*4882a593Smuzhiyunslot, pass ``probe_mask=1``.  For the first and the third slots, pass
121*4882a593Smuzhiyun``probe_mask=5`` (where 5 = 1 | 4), and so on.
122*4882a593Smuzhiyun
123*4882a593SmuzhiyunSince 2.6.29 kernel, the driver has a more robust probing method, so
124*4882a593Smuzhiyunthis error might happen rarely, though.
125*4882a593Smuzhiyun
126*4882a593SmuzhiyunOn a machine with a broken BIOS, sometimes you need to force the
127*4882a593Smuzhiyundriver to probe the codec slots the hardware doesn't report for use.
128*4882a593SmuzhiyunIn such a case, turn the bit 8 (0x100) of ``probe_mask`` option on.
129*4882a593SmuzhiyunThen the rest 8 bits are passed as the codec slots to probe
130*4882a593Smuzhiyununconditionally.  For example, ``probe_mask=0x103`` will force to probe
131*4882a593Smuzhiyunthe codec slots 0 and 1 no matter what the hardware reports.
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun
134*4882a593SmuzhiyunInterrupt Handling
135*4882a593Smuzhiyun------------------
136*4882a593SmuzhiyunHD-audio driver uses MSI as default (if available) since 2.6.33
137*4882a593Smuzhiyunkernel as MSI works better on some machines, and in general, it's
138*4882a593Smuzhiyunbetter for performance.  However, Nvidia controllers showed bad
139*4882a593Smuzhiyunregressions with MSI (especially in a combination with AMD chipset),
140*4882a593Smuzhiyunthus we disabled MSI for them.
141*4882a593Smuzhiyun
142*4882a593SmuzhiyunThere seem also still other devices that don't work with MSI.  If you
143*4882a593Smuzhiyunsee a regression wrt the sound quality (stuttering, etc) or a lock-up
144*4882a593Smuzhiyunin the recent kernel, try to pass ``enable_msi=0`` option to disable
145*4882a593SmuzhiyunMSI.  If it works, you can add the known bad device to the blacklist
146*4882a593Smuzhiyundefined in hda_intel.c.  In such a case, please report and give the
147*4882a593Smuzhiyunpatch back to the upstream developer.
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun
150*4882a593SmuzhiyunHD-Audio Codec
151*4882a593Smuzhiyun==============
152*4882a593Smuzhiyun
153*4882a593SmuzhiyunModel Option
154*4882a593Smuzhiyun------------
155*4882a593SmuzhiyunThe most common problem regarding the HD-audio driver is the
156*4882a593Smuzhiyununsupported codec features or the mismatched device configuration.
157*4882a593SmuzhiyunMost of codec-specific code has several preset models, either to
158*4882a593Smuzhiyunoverride the BIOS setup or to provide more comprehensive features.
159*4882a593Smuzhiyun
160*4882a593SmuzhiyunThe driver checks PCI SSID and looks through the static configuration
161*4882a593Smuzhiyuntable until any matching entry is found.  If you have a new machine,
162*4882a593Smuzhiyunyou may see a message like below:
163*4882a593Smuzhiyun::
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun    hda_codec: ALC880: BIOS auto-probing.
166*4882a593Smuzhiyun
167*4882a593SmuzhiyunMeanwhile, in the earlier versions, you would see a message like:
168*4882a593Smuzhiyun::
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun    hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...
171*4882a593Smuzhiyun
172*4882a593SmuzhiyunEven if you see such a message, DON'T PANIC.  Take a deep breath and
173*4882a593Smuzhiyunkeep your towel.  First of all, it's an informational message, no
174*4882a593Smuzhiyunwarning, no error.  This means that the PCI SSID of your device isn't
175*4882a593Smuzhiyunlisted in the known preset model (white-)list.  But, this doesn't mean
176*4882a593Smuzhiyunthat the driver is broken.  Many codec-drivers provide the automatic
177*4882a593Smuzhiyunconfiguration mechanism based on the BIOS setup.
178*4882a593Smuzhiyun
179*4882a593SmuzhiyunThe HD-audio codec has usually "pin" widgets, and BIOS sets the default
180*4882a593Smuzhiyunconfiguration of each pin, which indicates the location, the
181*4882a593Smuzhiyunconnection type, the jack color, etc.  The HD-audio driver can guess
182*4882a593Smuzhiyunthe right connection judging from these default configuration values.
183*4882a593SmuzhiyunHowever -- some codec-support codes, such as patch_analog.c, don't
184*4882a593Smuzhiyunsupport the automatic probing (yet as of 2.6.28).  And, BIOS is often,
185*4882a593Smuzhiyunyes, pretty often broken.  It sets up wrong values and screws up the
186*4882a593Smuzhiyundriver.
187*4882a593Smuzhiyun
188*4882a593SmuzhiyunThe preset model (or recently called as "fix-up") is provided
189*4882a593Smuzhiyunbasically to overcome such a situation.  When the matching preset
190*4882a593Smuzhiyunmodel is found in the white-list, the driver assumes the static
191*4882a593Smuzhiyunconfiguration of that preset with the correct pin setup, etc.
192*4882a593SmuzhiyunThus, if you have a newer machine with a slightly different PCI SSID
193*4882a593Smuzhiyun(or codec SSID) from the existing one, you may have a good chance to
194*4882a593Smuzhiyunre-use the same model.  You can pass the ``model`` option to specify the
195*4882a593Smuzhiyunpreset model instead of PCI (and codec-) SSID look-up.
196*4882a593Smuzhiyun
197*4882a593SmuzhiyunWhat ``model`` option values are available depends on the codec chip.
198*4882a593SmuzhiyunCheck your codec chip from the codec proc file (see "Codec Proc-File"
199*4882a593Smuzhiyunsection below).  It will show the vendor/product name of your codec
200*4882a593Smuzhiyunchip.  Then, see Documentation/sound/hd-audio/models.rst file,
201*4882a593Smuzhiyunthe section of HD-audio driver.  You can find a list of codecs
202*4882a593Smuzhiyunand ``model`` options belonging to each codec.  For example, for Realtek
203*4882a593SmuzhiyunALC262 codec chip, pass ``model=ultra`` for devices that are compatible
204*4882a593Smuzhiyunwith Samsung Q1 Ultra.
205*4882a593Smuzhiyun
206*4882a593SmuzhiyunThus, the first thing you can do for any brand-new, unsupported and
207*4882a593Smuzhiyunnon-working HD-audio hardware is to check HD-audio codec and several
208*4882a593Smuzhiyundifferent ``model`` option values.  If you have any luck, some of them
209*4882a593Smuzhiyunmight suit with your device well.
210*4882a593Smuzhiyun
211*4882a593SmuzhiyunThere are a few special model option values:
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun* when 'nofixup' is passed, the device-specific fixups in the codec
214*4882a593Smuzhiyun  parser are skipped.
215*4882a593Smuzhiyun* when ``generic`` is passed, the codec-specific parser is skipped and
216*4882a593Smuzhiyun  only the generic parser is used.
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun
219*4882a593SmuzhiyunSpeaker and Headphone Output
220*4882a593Smuzhiyun----------------------------
221*4882a593SmuzhiyunOne of the most frequent (and obvious) bugs with HD-audio is the
222*4882a593Smuzhiyunsilent output from either or both of a built-in speaker and a
223*4882a593Smuzhiyunheadphone jack.  In general, you should try a headphone output at
224*4882a593Smuzhiyunfirst.  A speaker output often requires more additional controls like
225*4882a593Smuzhiyunthe external amplifier bits.  Thus a headphone output has a slightly
226*4882a593Smuzhiyunbetter chance.
227*4882a593Smuzhiyun
228*4882a593SmuzhiyunBefore making a bug report, double-check whether the mixer is set up
229*4882a593Smuzhiyuncorrectly.  The recent version of snd-hda-intel driver provides mostly
230*4882a593Smuzhiyun"Master" volume control as well as "Front" volume (where Front
231*4882a593Smuzhiyunindicates the front-channels).  In addition, there can be individual
232*4882a593Smuzhiyun"Headphone" and "Speaker" controls.
233*4882a593Smuzhiyun
234*4882a593SmuzhiyunDitto for the speaker output.  There can be "External Amplifier"
235*4882a593Smuzhiyunswitch on some codecs.  Turn on this if present.
236*4882a593Smuzhiyun
237*4882a593SmuzhiyunAnother related problem is the automatic mute of speaker output by
238*4882a593Smuzhiyunheadphone plugging.  This feature is implemented in most cases, but
239*4882a593Smuzhiyunnot on every preset model or codec-support code.
240*4882a593Smuzhiyun
241*4882a593SmuzhiyunIn anyway, try a different model option if you have such a problem.
242*4882a593SmuzhiyunSome other models may match better and give you more matching
243*4882a593Smuzhiyunfunctionality.  If none of the available models works, send a bug
244*4882a593Smuzhiyunreport.  See the bug report section for details.
245*4882a593Smuzhiyun
246*4882a593SmuzhiyunIf you are masochistic enough to debug the driver problem, note the
247*4882a593Smuzhiyunfollowing:
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun* The speaker (and the headphone, too) output often requires the
250*4882a593Smuzhiyun  external amplifier.  This can be set usually via EAPD verb or a
251*4882a593Smuzhiyun  certain GPIO.  If the codec pin supports EAPD, you have a better
252*4882a593Smuzhiyun  chance via SET_EAPD_BTL verb (0x70c).  On others, GPIO pin (mostly
253*4882a593Smuzhiyun  it's either GPIO0 or GPIO1) may turn on/off EAPD.
254*4882a593Smuzhiyun* Some Realtek codecs require special vendor-specific coefficients to
255*4882a593Smuzhiyun  turn on the amplifier.  See patch_realtek.c.
256*4882a593Smuzhiyun* IDT codecs may have extra power-enable/disable controls on each
257*4882a593Smuzhiyun  analog pin.  See patch_sigmatel.c.
258*4882a593Smuzhiyun* Very rare but some devices don't accept the pin-detection verb until
259*4882a593Smuzhiyun  triggered.  Issuing GET_PIN_SENSE verb (0xf09) may result in the
260*4882a593Smuzhiyun  codec-communication stall.  Some examples are found in
261*4882a593Smuzhiyun  patch_realtek.c.
262*4882a593Smuzhiyun
263*4882a593Smuzhiyun
264*4882a593SmuzhiyunCapture Problems
265*4882a593Smuzhiyun----------------
266*4882a593SmuzhiyunThe capture problems are often because of missing setups of mixers.
267*4882a593SmuzhiyunThus, before submitting a bug report, make sure that you set up the
268*4882a593Smuzhiyunmixer correctly.  For example, both "Capture Volume" and "Capture
269*4882a593SmuzhiyunSwitch" have to be set properly in addition to the right "Capture
270*4882a593SmuzhiyunSource" or "Input Source" selection.  Some devices have "Mic Boost"
271*4882a593Smuzhiyunvolume or switch.
272*4882a593Smuzhiyun
273*4882a593SmuzhiyunWhen the PCM device is opened via "default" PCM (without pulse-audio
274*4882a593Smuzhiyunplugin), you'll likely have "Digital Capture Volume" control as well.
275*4882a593SmuzhiyunThis is provided for the extra gain/attenuation of the signal in
276*4882a593Smuzhiyunsoftware, especially for the inputs without the hardware volume
277*4882a593Smuzhiyuncontrol such as digital microphones.  Unless really needed, this
278*4882a593Smuzhiyunshould be set to exactly 50%, corresponding to 0dB -- neither extra
279*4882a593Smuzhiyungain nor attenuation.  When you use "hw" PCM, i.e., a raw access PCM,
280*4882a593Smuzhiyunthis control will have no influence, though.
281*4882a593Smuzhiyun
282*4882a593SmuzhiyunIt's known that some codecs / devices have fairly bad analog circuits,
283*4882a593Smuzhiyunand the recorded sound contains a certain DC-offset.  This is no bug
284*4882a593Smuzhiyunof the driver.
285*4882a593Smuzhiyun
286*4882a593SmuzhiyunMost of modern laptops have no analog CD-input connection.  Thus, the
287*4882a593Smuzhiyunrecording from CD input won't work in many cases although the driver
288*4882a593Smuzhiyunprovides it as the capture source.  Use CDDA instead.
289*4882a593Smuzhiyun
290*4882a593SmuzhiyunThe automatic switching of the built-in and external mic per plugging
291*4882a593Smuzhiyunis implemented on some codec models but not on every model.  Partly
292*4882a593Smuzhiyunbecause of my laziness but mostly lack of testers.  Feel free to
293*4882a593Smuzhiyunsubmit the improvement patch to the author.
294*4882a593Smuzhiyun
295*4882a593Smuzhiyun
296*4882a593SmuzhiyunDirect Debugging
297*4882a593Smuzhiyun----------------
298*4882a593SmuzhiyunIf no model option gives you a better result, and you are a tough guy
299*4882a593Smuzhiyunto fight against evil, try debugging via hitting the raw HD-audio
300*4882a593Smuzhiyuncodec verbs to the device.  Some tools are available: hda-emu and
301*4882a593Smuzhiyunhda-analyzer.  The detailed description is found in the sections
302*4882a593Smuzhiyunbelow.  You'd need to enable hwdep for using these tools.  See "Kernel
303*4882a593SmuzhiyunConfiguration" section.
304*4882a593Smuzhiyun
305*4882a593Smuzhiyun
306*4882a593SmuzhiyunOther Issues
307*4882a593Smuzhiyun============
308*4882a593Smuzhiyun
309*4882a593SmuzhiyunKernel Configuration
310*4882a593Smuzhiyun--------------------
311*4882a593SmuzhiyunIn general, I recommend you to enable the sound debug option,
312*4882a593Smuzhiyun``CONFIG_SND_DEBUG=y``, no matter whether you are debugging or not.
313*4882a593SmuzhiyunThis enables snd_printd() macro and others, and you'll get additional
314*4882a593Smuzhiyunkernel messages at probing.
315*4882a593Smuzhiyun
316*4882a593SmuzhiyunIn addition, you can enable ``CONFIG_SND_DEBUG_VERBOSE=y``.  But this
317*4882a593Smuzhiyunwill give you far more messages.  Thus turn this on only when you are
318*4882a593Smuzhiyunsure to want it.
319*4882a593Smuzhiyun
320*4882a593SmuzhiyunDon't forget to turn on the appropriate ``CONFIG_SND_HDA_CODEC_*``
321*4882a593Smuzhiyunoptions.  Note that each of them corresponds to the codec chip, not
322*4882a593Smuzhiyunthe controller chip.  Thus, even if lspci shows the Nvidia controller,
323*4882a593Smuzhiyunyou may need to choose the option for other vendors.  If you are
324*4882a593Smuzhiyununsure, just select all yes.
325*4882a593Smuzhiyun
326*4882a593Smuzhiyun``CONFIG_SND_HDA_HWDEP`` is a useful option for debugging the driver.
327*4882a593SmuzhiyunWhen this is enabled, the driver creates hardware-dependent devices
328*4882a593Smuzhiyun(one per each codec), and you have a raw access to the device via
329*4882a593Smuzhiyunthese device files.  For example, ``hwC0D2`` will be created for the
330*4882a593Smuzhiyuncodec slot #2 of the first card (#0).  For debug-tools such as
331*4882a593Smuzhiyunhda-verb and hda-analyzer, the hwdep device has to be enabled.
332*4882a593SmuzhiyunThus, it'd be better to turn this on always.
333*4882a593Smuzhiyun
334*4882a593Smuzhiyun``CONFIG_SND_HDA_RECONFIG`` is a new option, and this depends on the
335*4882a593Smuzhiyunhwdep option above.  When enabled, you'll have some sysfs files under
336*4882a593Smuzhiyunthe corresponding hwdep directory.  See "HD-audio reconfiguration"
337*4882a593Smuzhiyunsection below.
338*4882a593Smuzhiyun
339*4882a593Smuzhiyun``CONFIG_SND_HDA_POWER_SAVE`` option enables the power-saving feature.
340*4882a593SmuzhiyunSee "Power-saving" section below.
341*4882a593Smuzhiyun
342*4882a593Smuzhiyun
343*4882a593SmuzhiyunCodec Proc-File
344*4882a593Smuzhiyun---------------
345*4882a593SmuzhiyunThe codec proc-file is a treasure-chest for debugging HD-audio.
346*4882a593SmuzhiyunIt shows most of useful information of each codec widget.
347*4882a593Smuzhiyun
348*4882a593SmuzhiyunThe proc file is located in /proc/asound/card*/codec#*, one file per
349*4882a593Smuzhiyuneach codec slot.  You can know the codec vendor, product id and
350*4882a593Smuzhiyunnames, the type of each widget, capabilities and so on.
351*4882a593SmuzhiyunThis file, however, doesn't show the jack sensing state, so far.  This
352*4882a593Smuzhiyunis because the jack-sensing might be depending on the trigger state.
353*4882a593Smuzhiyun
354*4882a593SmuzhiyunThis file will be picked up by the debug tools, and also it can be fed
355*4882a593Smuzhiyunto the emulator as the primary codec information.  See the debug tools
356*4882a593Smuzhiyunsection below.
357*4882a593Smuzhiyun
358*4882a593SmuzhiyunThis proc file can be also used to check whether the generic parser is
359*4882a593Smuzhiyunused.  When the generic parser is used, the vendor/product ID name
360*4882a593Smuzhiyunwill appear as "Realtek ID 0262", instead of "Realtek ALC262".
361*4882a593Smuzhiyun
362*4882a593Smuzhiyun
363*4882a593SmuzhiyunHD-Audio Reconfiguration
364*4882a593Smuzhiyun------------------------
365*4882a593SmuzhiyunThis is an experimental feature to allow you re-configure the HD-audio
366*4882a593Smuzhiyuncodec dynamically without reloading the driver.  The following sysfs
367*4882a593Smuzhiyunfiles are available under each codec-hwdep device directory (e.g.
368*4882a593Smuzhiyun/sys/class/sound/hwC0D0):
369*4882a593Smuzhiyun
370*4882a593Smuzhiyunvendor_id
371*4882a593Smuzhiyun    Shows the 32bit codec vendor-id hex number.  You can change the
372*4882a593Smuzhiyun    vendor-id value by writing to this file.
373*4882a593Smuzhiyunsubsystem_id
374*4882a593Smuzhiyun    Shows the 32bit codec subsystem-id hex number.  You can change the
375*4882a593Smuzhiyun    subsystem-id value by writing to this file.
376*4882a593Smuzhiyunrevision_id
377*4882a593Smuzhiyun    Shows the 32bit codec revision-id hex number.  You can change the
378*4882a593Smuzhiyun    revision-id value by writing to this file.
379*4882a593Smuzhiyunafg
380*4882a593Smuzhiyun    Shows the AFG ID.  This is read-only.
381*4882a593Smuzhiyunmfg
382*4882a593Smuzhiyun    Shows the MFG ID.  This is read-only.
383*4882a593Smuzhiyunname
384*4882a593Smuzhiyun    Shows the codec name string.  Can be changed by writing to this
385*4882a593Smuzhiyun    file.
386*4882a593Smuzhiyunmodelname
387*4882a593Smuzhiyun    Shows the currently set ``model`` option.  Can be changed by writing
388*4882a593Smuzhiyun    to this file.
389*4882a593Smuzhiyuninit_verbs
390*4882a593Smuzhiyun    The extra verbs to execute at initialization.  You can add a verb by
391*4882a593Smuzhiyun    writing to this file.  Pass three numbers: nid, verb and parameter
392*4882a593Smuzhiyun    (separated with a space).
393*4882a593Smuzhiyunhints
394*4882a593Smuzhiyun    Shows / stores hint strings for codec parsers for any use.
395*4882a593Smuzhiyun    Its format is ``key = value``.  For example, passing ``jack_detect = no``
396*4882a593Smuzhiyun    will disable the jack detection of the machine completely.
397*4882a593Smuzhiyuninit_pin_configs
398*4882a593Smuzhiyun    Shows the initial pin default config values set by BIOS.
399*4882a593Smuzhiyundriver_pin_configs
400*4882a593Smuzhiyun    Shows the pin default values set by the codec parser explicitly.
401*4882a593Smuzhiyun    This doesn't show all pin values but only the changed values by
402*4882a593Smuzhiyun    the parser.  That is, if the parser doesn't change the pin default
403*4882a593Smuzhiyun    config values by itself, this will contain nothing.
404*4882a593Smuzhiyunuser_pin_configs
405*4882a593Smuzhiyun    Shows the pin default config values to override the BIOS setup.
406*4882a593Smuzhiyun    Writing this (with two numbers, NID and value) appends the new
407*4882a593Smuzhiyun    value.  The given will be used instead of the initial BIOS value at
408*4882a593Smuzhiyun    the next reconfiguration time.  Note that this config will override
409*4882a593Smuzhiyun    even the driver pin configs, too.
410*4882a593Smuzhiyunreconfig
411*4882a593Smuzhiyun    Triggers the codec re-configuration.  When any value is written to
412*4882a593Smuzhiyun    this file, the driver re-initialize and parses the codec tree
413*4882a593Smuzhiyun    again.  All the changes done by the sysfs entries above are taken
414*4882a593Smuzhiyun    into account.
415*4882a593Smuzhiyunclear
416*4882a593Smuzhiyun    Resets the codec, removes the mixer elements and PCM stuff of the
417*4882a593Smuzhiyun    specified codec, and clear all init verbs and hints.
418*4882a593Smuzhiyun
419*4882a593SmuzhiyunFor example, when you want to change the pin default configuration
420*4882a593Smuzhiyunvalue of the pin widget 0x14 to 0x9993013f, and let the driver
421*4882a593Smuzhiyunre-configure based on that state, run like below:
422*4882a593Smuzhiyun::
423*4882a593Smuzhiyun
424*4882a593Smuzhiyun    # echo 0x14 0x9993013f > /sys/class/sound/hwC0D0/user_pin_configs
425*4882a593Smuzhiyun    # echo 1 > /sys/class/sound/hwC0D0/reconfig
426*4882a593Smuzhiyun
427*4882a593Smuzhiyun
428*4882a593SmuzhiyunHint Strings
429*4882a593Smuzhiyun------------
430*4882a593SmuzhiyunThe codec parser have several switches and adjustment knobs for
431*4882a593Smuzhiyunmatching better with the actual codec or device behavior.  Many of
432*4882a593Smuzhiyunthem can be adjusted dynamically via "hints" strings as mentioned in
433*4882a593Smuzhiyunthe section above.  For example, by passing ``jack_detect = no`` string
434*4882a593Smuzhiyunvia sysfs or a patch file, you can disable the jack detection, thus
435*4882a593Smuzhiyunthe codec parser will skip the features like auto-mute or mic
436*4882a593Smuzhiyunauto-switch.  As a boolean value, either ``yes``, ``no``, ``true``, ``false``,
437*4882a593Smuzhiyun``1`` or ``0`` can be passed.
438*4882a593Smuzhiyun
439*4882a593SmuzhiyunThe generic parser supports the following hints:
440*4882a593Smuzhiyun
441*4882a593Smuzhiyunjack_detect (bool)
442*4882a593Smuzhiyun    specify whether the jack detection is available at all on this
443*4882a593Smuzhiyun    machine; default true
444*4882a593Smuzhiyuninv_jack_detect (bool)
445*4882a593Smuzhiyun    indicates that the jack detection logic is inverted
446*4882a593Smuzhiyuntrigger_sense (bool)
447*4882a593Smuzhiyun    indicates that the jack detection needs the explicit call of
448*4882a593Smuzhiyun    AC_VERB_SET_PIN_SENSE verb
449*4882a593Smuzhiyuninv_eapd (bool)
450*4882a593Smuzhiyun    indicates that the EAPD is implemented in the inverted logic
451*4882a593Smuzhiyunpcm_format_first (bool)
452*4882a593Smuzhiyun    sets the PCM format before the stream tag and channel ID
453*4882a593Smuzhiyunsticky_stream (bool)
454*4882a593Smuzhiyun    keep the PCM format, stream tag and ID as long as possible;
455*4882a593Smuzhiyun    default true
456*4882a593Smuzhiyunspdif_status_reset (bool)
457*4882a593Smuzhiyun    reset the SPDIF status bits at each time the SPDIF stream is set
458*4882a593Smuzhiyun    up
459*4882a593Smuzhiyunpin_amp_workaround (bool)
460*4882a593Smuzhiyun    the output pin may have multiple amp values
461*4882a593Smuzhiyunsingle_adc_amp (bool)
462*4882a593Smuzhiyun    ADCs can have only single input amps
463*4882a593Smuzhiyunauto_mute (bool)
464*4882a593Smuzhiyun    enable/disable the headphone auto-mute feature; default true
465*4882a593Smuzhiyunauto_mic (bool)
466*4882a593Smuzhiyun    enable/disable the mic auto-switch feature; default true
467*4882a593Smuzhiyunline_in_auto_switch (bool)
468*4882a593Smuzhiyun    enable/disable the line-in auto-switch feature; default false
469*4882a593Smuzhiyunneed_dac_fix (bool)
470*4882a593Smuzhiyun    limits the DACs depending on the channel count
471*4882a593Smuzhiyunprimary_hp (bool)
472*4882a593Smuzhiyun    probe headphone jacks as the primary outputs; default true
473*4882a593Smuzhiyunmulti_io (bool)
474*4882a593Smuzhiyun    try probing multi-I/O config (e.g. shared line-in/surround,
475*4882a593Smuzhiyun    mic/clfe jacks)
476*4882a593Smuzhiyunmulti_cap_vol (bool)
477*4882a593Smuzhiyun    provide multiple capture volumes
478*4882a593Smuzhiyuninv_dmic_split (bool)
479*4882a593Smuzhiyun    provide split internal mic volume/switch for phase-inverted
480*4882a593Smuzhiyun    digital mics
481*4882a593Smuzhiyunindep_hp (bool)
482*4882a593Smuzhiyun    provide the independent headphone PCM stream and the corresponding
483*4882a593Smuzhiyun    mixer control, if available
484*4882a593Smuzhiyunadd_stereo_mix_input (bool)
485*4882a593Smuzhiyun    add the stereo mix (analog-loopback mix) to the input mux if
486*4882a593Smuzhiyun    available
487*4882a593Smuzhiyunadd_jack_modes (bool)
488*4882a593Smuzhiyun    add "xxx Jack Mode" enum controls to each I/O jack for allowing to
489*4882a593Smuzhiyun    change the headphone amp and mic bias VREF capabilities
490*4882a593Smuzhiyunpower_save_node (bool)
491*4882a593Smuzhiyun    advanced power management for each widget, controlling the power
492*4882a593Smuzhiyun    sate (D0/D3) of each widget node depending on the actual pin and
493*4882a593Smuzhiyun    stream states
494*4882a593Smuzhiyunpower_down_unused (bool)
495*4882a593Smuzhiyun    power down the unused widgets, a subset of power_save_node, and
496*4882a593Smuzhiyun    will be dropped in future
497*4882a593Smuzhiyunadd_hp_mic (bool)
498*4882a593Smuzhiyun    add the headphone to capture source if possible
499*4882a593Smuzhiyunhp_mic_detect (bool)
500*4882a593Smuzhiyun    enable/disable the hp/mic shared input for a single built-in mic
501*4882a593Smuzhiyun    case; default true
502*4882a593Smuzhiyunvmaster (bool)
503*4882a593Smuzhiyun    enable/disable the virtual Master control; default true
504*4882a593Smuzhiyunmixer_nid (int)
505*4882a593Smuzhiyun    specifies the widget NID of the analog-loopback mixer
506*4882a593Smuzhiyun
507*4882a593Smuzhiyun
508*4882a593SmuzhiyunEarly Patching
509*4882a593Smuzhiyun--------------
510*4882a593SmuzhiyunWhen ``CONFIG_SND_HDA_PATCH_LOADER=y`` is set, you can pass a "patch"
511*4882a593Smuzhiyunas a firmware file for modifying the HD-audio setup before
512*4882a593Smuzhiyuninitializing the codec.  This can work basically like the
513*4882a593Smuzhiyunreconfiguration via sysfs in the above, but it does it before the
514*4882a593Smuzhiyunfirst codec configuration.
515*4882a593Smuzhiyun
516*4882a593SmuzhiyunA patch file is a plain text file which looks like below:
517*4882a593Smuzhiyun
518*4882a593Smuzhiyun::
519*4882a593Smuzhiyun
520*4882a593Smuzhiyun    [codec]
521*4882a593Smuzhiyun    0x12345678 0xabcd1234 2
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun    [model]
524*4882a593Smuzhiyun    auto
525*4882a593Smuzhiyun
526*4882a593Smuzhiyun    [pincfg]
527*4882a593Smuzhiyun    0x12 0x411111f0
528*4882a593Smuzhiyun
529*4882a593Smuzhiyun    [verb]
530*4882a593Smuzhiyun    0x20 0x500 0x03
531*4882a593Smuzhiyun    0x20 0x400 0xff
532*4882a593Smuzhiyun
533*4882a593Smuzhiyun    [hint]
534*4882a593Smuzhiyun    jack_detect = no
535*4882a593Smuzhiyun
536*4882a593Smuzhiyun
537*4882a593SmuzhiyunThe file needs to have a line ``[codec]``.  The next line should contain
538*4882a593Smuzhiyunthree numbers indicating the codec vendor-id (0x12345678 in the
539*4882a593Smuzhiyunexample), the codec subsystem-id (0xabcd1234) and the address (2) of
540*4882a593Smuzhiyunthe codec.  The rest patch entries are applied to this specified codec
541*4882a593Smuzhiyununtil another codec entry is given.  Passing 0 or a negative number to
542*4882a593Smuzhiyunthe first or the second value will make the check of the corresponding
543*4882a593Smuzhiyunfield be skipped.  It'll be useful for really broken devices that don't
544*4882a593Smuzhiyuninitialize SSID properly.
545*4882a593Smuzhiyun
546*4882a593SmuzhiyunThe ``[model]`` line allows to change the model name of the each codec.
547*4882a593SmuzhiyunIn the example above, it will be changed to model=auto.
548*4882a593SmuzhiyunNote that this overrides the module option.
549*4882a593Smuzhiyun
550*4882a593SmuzhiyunAfter the ``[pincfg]`` line, the contents are parsed as the initial
551*4882a593Smuzhiyundefault pin-configurations just like ``user_pin_configs`` sysfs above.
552*4882a593SmuzhiyunThe values can be shown in user_pin_configs sysfs file, too.
553*4882a593Smuzhiyun
554*4882a593SmuzhiyunSimilarly, the lines after ``[verb]`` are parsed as ``init_verbs``
555*4882a593Smuzhiyunsysfs entries, and the lines after ``[hint]`` are parsed as ``hints``
556*4882a593Smuzhiyunsysfs entries, respectively.
557*4882a593Smuzhiyun
558*4882a593SmuzhiyunAnother example to override the codec vendor id from 0x12345678 to
559*4882a593Smuzhiyun0xdeadbeef is like below:
560*4882a593Smuzhiyun::
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun    [codec]
563*4882a593Smuzhiyun    0x12345678 0xabcd1234 2
564*4882a593Smuzhiyun
565*4882a593Smuzhiyun    [vendor_id]
566*4882a593Smuzhiyun    0xdeadbeef
567*4882a593Smuzhiyun
568*4882a593Smuzhiyun
569*4882a593SmuzhiyunIn the similar way, you can override the codec subsystem_id via
570*4882a593Smuzhiyun``[subsystem_id]``, the revision id via ``[revision_id]`` line.
571*4882a593SmuzhiyunAlso, the codec chip name can be rewritten via ``[chip_name]`` line.
572*4882a593Smuzhiyun::
573*4882a593Smuzhiyun
574*4882a593Smuzhiyun    [codec]
575*4882a593Smuzhiyun    0x12345678 0xabcd1234 2
576*4882a593Smuzhiyun
577*4882a593Smuzhiyun    [subsystem_id]
578*4882a593Smuzhiyun    0xffff1111
579*4882a593Smuzhiyun
580*4882a593Smuzhiyun    [revision_id]
581*4882a593Smuzhiyun    0x10
582*4882a593Smuzhiyun
583*4882a593Smuzhiyun    [chip_name]
584*4882a593Smuzhiyun    My-own NEWS-0002
585*4882a593Smuzhiyun
586*4882a593Smuzhiyun
587*4882a593SmuzhiyunThe hd-audio driver reads the file via request_firmware().  Thus,
588*4882a593Smuzhiyuna patch file has to be located on the appropriate firmware path,
589*4882a593Smuzhiyuntypically, /lib/firmware.  For example, when you pass the option
590*4882a593Smuzhiyun``patch=hda-init.fw``, the file /lib/firmware/hda-init.fw must be
591*4882a593Smuzhiyunpresent.
592*4882a593Smuzhiyun
593*4882a593SmuzhiyunThe patch module option is specific to each card instance, and you
594*4882a593Smuzhiyunneed to give one file name for each instance, separated by commas.
595*4882a593SmuzhiyunFor example, if you have two cards, one for an on-board analog and one
596*4882a593Smuzhiyunfor an HDMI video board, you may pass patch option like below:
597*4882a593Smuzhiyun::
598*4882a593Smuzhiyun
599*4882a593Smuzhiyun    options snd-hda-intel patch=on-board-patch,hdmi-patch
600*4882a593Smuzhiyun
601*4882a593Smuzhiyun
602*4882a593SmuzhiyunPower-Saving
603*4882a593Smuzhiyun------------
604*4882a593SmuzhiyunThe power-saving is a kind of auto-suspend of the device.  When the
605*4882a593Smuzhiyundevice is inactive for a certain time, the device is automatically
606*4882a593Smuzhiyunturned off to save the power.  The time to go down is specified via
607*4882a593Smuzhiyun``power_save`` module option, and this option can be changed dynamically
608*4882a593Smuzhiyunvia sysfs.
609*4882a593Smuzhiyun
610*4882a593SmuzhiyunThe power-saving won't work when the analog loopback is enabled on
611*4882a593Smuzhiyunsome codecs.  Make sure that you mute all unneeded signal routes when
612*4882a593Smuzhiyunyou want the power-saving.
613*4882a593Smuzhiyun
614*4882a593SmuzhiyunThe power-saving feature might cause audible click noises at each
615*4882a593Smuzhiyunpower-down/up depending on the device.  Some of them might be
616*4882a593Smuzhiyunsolvable, but some are hard, I'm afraid.  Some distros such as
617*4882a593SmuzhiyunopenSUSE enables the power-saving feature automatically when the power
618*4882a593Smuzhiyuncable is unplugged.  Thus, if you hear noises, suspect first the
619*4882a593Smuzhiyunpower-saving.  See /sys/module/snd_hda_intel/parameters/power_save to
620*4882a593Smuzhiyuncheck the current value.  If it's non-zero, the feature is turned on.
621*4882a593Smuzhiyun
622*4882a593SmuzhiyunThe recent kernel supports the runtime PM for the HD-audio controller
623*4882a593Smuzhiyunchip, too.  It means that the HD-audio controller is also powered up /
624*4882a593Smuzhiyundown dynamically.  The feature is enabled only for certain controller
625*4882a593Smuzhiyunchips like Intel LynxPoint.  You can enable/disable this feature
626*4882a593Smuzhiyunforcibly by setting ``power_save_controller`` option, which is also
627*4882a593Smuzhiyunavailable at /sys/module/snd_hda_intel/parameters directory.
628*4882a593Smuzhiyun
629*4882a593Smuzhiyun
630*4882a593SmuzhiyunTracepoints
631*4882a593Smuzhiyun-----------
632*4882a593SmuzhiyunThe hd-audio driver gives a few basic tracepoints.
633*4882a593Smuzhiyun``hda:hda_send_cmd`` traces each CORB write while ``hda:hda_get_response``
634*4882a593Smuzhiyuntraces the response from RIRB (only when read from the codec driver).
635*4882a593Smuzhiyun``hda:hda_bus_reset`` traces the bus-reset due to fatal error, etc,
636*4882a593Smuzhiyun``hda:hda_unsol_event`` traces the unsolicited events, and
637*4882a593Smuzhiyun``hda:hda_power_down`` and ``hda:hda_power_up`` trace the power down/up
638*4882a593Smuzhiyunvia power-saving behavior.
639*4882a593Smuzhiyun
640*4882a593SmuzhiyunEnabling all tracepoints can be done like
641*4882a593Smuzhiyun::
642*4882a593Smuzhiyun
643*4882a593Smuzhiyun    # echo 1 > /sys/kernel/debug/tracing/events/hda/enable
644*4882a593Smuzhiyun
645*4882a593Smuzhiyunthen after some commands, you can traces from
646*4882a593Smuzhiyun/sys/kernel/debug/tracing/trace file.  For example, when you want to
647*4882a593Smuzhiyuntrace what codec command is sent, enable the tracepoint like:
648*4882a593Smuzhiyun::
649*4882a593Smuzhiyun
650*4882a593Smuzhiyun    # cat /sys/kernel/debug/tracing/trace
651*4882a593Smuzhiyun    # tracer: nop
652*4882a593Smuzhiyun    #
653*4882a593Smuzhiyun    #       TASK-PID    CPU#    TIMESTAMP  FUNCTION
654*4882a593Smuzhiyun    #          | |       |          |         |
655*4882a593Smuzhiyun	   <...>-7807  [002] 105147.774889: hda_send_cmd: [0:0] val=e3a019
656*4882a593Smuzhiyun	   <...>-7807  [002] 105147.774893: hda_send_cmd: [0:0] val=e39019
657*4882a593Smuzhiyun	   <...>-7807  [002] 105147.999542: hda_send_cmd: [0:0] val=e3a01a
658*4882a593Smuzhiyun	   <...>-7807  [002] 105147.999543: hda_send_cmd: [0:0] val=e3901a
659*4882a593Smuzhiyun	   <...>-26764 [001] 349222.837143: hda_send_cmd: [0:0] val=e3a019
660*4882a593Smuzhiyun	   <...>-26764 [001] 349222.837148: hda_send_cmd: [0:0] val=e39019
661*4882a593Smuzhiyun	   <...>-26764 [001] 349223.058539: hda_send_cmd: [0:0] val=e3a01a
662*4882a593Smuzhiyun	   <...>-26764 [001] 349223.058541: hda_send_cmd: [0:0] val=e3901a
663*4882a593Smuzhiyun
664*4882a593SmuzhiyunHere ``[0:0]`` indicates the card number and the codec address, and
665*4882a593Smuzhiyun``val`` shows the value sent to the codec, respectively.  The value is
666*4882a593Smuzhiyuna packed value, and you can decode it via hda-decode-verb program
667*4882a593Smuzhiyunincluded in hda-emu package below.  For example, the value e3a019 is
668*4882a593Smuzhiyunto set the left output-amp value to 25.
669*4882a593Smuzhiyun::
670*4882a593Smuzhiyun
671*4882a593Smuzhiyun    % hda-decode-verb 0xe3a019
672*4882a593Smuzhiyun    raw value = 0x00e3a019
673*4882a593Smuzhiyun    cid = 0, nid = 0x0e, verb = 0x3a0, parm = 0x19
674*4882a593Smuzhiyun    raw value: verb = 0x3a0, parm = 0x19
675*4882a593Smuzhiyun    verbname = set_amp_gain_mute
676*4882a593Smuzhiyun    amp raw val = 0xa019
677*4882a593Smuzhiyun    output, left, idx=0, mute=0, val=25
678*4882a593Smuzhiyun
679*4882a593Smuzhiyun
680*4882a593SmuzhiyunDevelopment Tree
681*4882a593Smuzhiyun----------------
682*4882a593SmuzhiyunThe latest development codes for HD-audio are found on sound git tree:
683*4882a593Smuzhiyun
684*4882a593Smuzhiyun* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
685*4882a593Smuzhiyun
686*4882a593SmuzhiyunThe master branch or for-next branches can be used as the main
687*4882a593Smuzhiyundevelopment branches in general while the development for the current
688*4882a593Smuzhiyunand next kernels are found in for-linus and for-next branches,
689*4882a593Smuzhiyunrespectively.
690*4882a593Smuzhiyun
691*4882a593Smuzhiyun
692*4882a593SmuzhiyunSending a Bug Report
693*4882a593Smuzhiyun--------------------
694*4882a593SmuzhiyunIf any model or module options don't work for your device, it's time
695*4882a593Smuzhiyunto send a bug report to the developers.  Give the following in your
696*4882a593Smuzhiyunbug report:
697*4882a593Smuzhiyun
698*4882a593Smuzhiyun* Hardware vendor, product and model names
699*4882a593Smuzhiyun* Kernel version (and ALSA-driver version if you built externally)
700*4882a593Smuzhiyun* ``alsa-info.sh`` output; run with ``--no-upload`` option.  See the
701*4882a593Smuzhiyun  section below about alsa-info
702*4882a593Smuzhiyun
703*4882a593SmuzhiyunIf it's a regression, at best, send alsa-info outputs of both working
704*4882a593Smuzhiyunand non-working kernels.  This is really helpful because we can
705*4882a593Smuzhiyuncompare the codec registers directly.
706*4882a593Smuzhiyun
707*4882a593SmuzhiyunSend a bug report either the following:
708*4882a593Smuzhiyun
709*4882a593Smuzhiyunkernel-bugzilla
710*4882a593Smuzhiyun    https://bugzilla.kernel.org/
711*4882a593Smuzhiyunalsa-devel ML
712*4882a593Smuzhiyun    alsa-devel@alsa-project.org
713*4882a593Smuzhiyun
714*4882a593Smuzhiyun
715*4882a593SmuzhiyunDebug Tools
716*4882a593Smuzhiyun===========
717*4882a593Smuzhiyun
718*4882a593SmuzhiyunThis section describes some tools available for debugging HD-audio
719*4882a593Smuzhiyunproblems.
720*4882a593Smuzhiyun
721*4882a593Smuzhiyunalsa-info
722*4882a593Smuzhiyun---------
723*4882a593SmuzhiyunThe script ``alsa-info.sh`` is a very useful tool to gather the audio
724*4882a593Smuzhiyundevice information.  It's included in alsa-utils package.  The latest
725*4882a593Smuzhiyunversion can be found on git repository:
726*4882a593Smuzhiyun
727*4882a593Smuzhiyun* git://git.alsa-project.org/alsa-utils.git
728*4882a593Smuzhiyun
729*4882a593SmuzhiyunThe script can be fetched directly from the following URL, too:
730*4882a593Smuzhiyun
731*4882a593Smuzhiyun* https://www.alsa-project.org/alsa-info.sh
732*4882a593Smuzhiyun
733*4882a593SmuzhiyunRun this script as root, and it will gather the important information
734*4882a593Smuzhiyunsuch as the module lists, module parameters, proc file contents
735*4882a593Smuzhiyunincluding the codec proc files, mixer outputs and the control
736*4882a593Smuzhiyunelements.  As default, it will store the information onto a web server
737*4882a593Smuzhiyunon alsa-project.org.  But, if you send a bug report, it'd be better to
738*4882a593Smuzhiyunrun with ``--no-upload`` option, and attach the generated file.
739*4882a593Smuzhiyun
740*4882a593SmuzhiyunThere are some other useful options.  See ``--help`` option output for
741*4882a593Smuzhiyundetails.
742*4882a593Smuzhiyun
743*4882a593SmuzhiyunWhen a probe error occurs or when the driver obviously assigns a
744*4882a593Smuzhiyunmismatched model, it'd be helpful to load the driver with
745*4882a593Smuzhiyun``probe_only=1`` option (at best after the cold reboot) and run
746*4882a593Smuzhiyunalsa-info at this state.  With this option, the driver won't configure
747*4882a593Smuzhiyunthe mixer and PCM but just tries to probe the codec slot.  After
748*4882a593Smuzhiyunprobing, the proc file is available, so you can get the raw codec
749*4882a593Smuzhiyuninformation before modified by the driver.  Of course, the driver
750*4882a593Smuzhiyunisn't usable with ``probe_only=1``.  But you can continue the
751*4882a593Smuzhiyunconfiguration via hwdep sysfs file if hda-reconfig option is enabled.
752*4882a593SmuzhiyunUsing ``probe_only`` mask 2 skips the reset of HDA codecs (use
753*4882a593Smuzhiyun``probe_only=3`` as module option). The hwdep interface can be used
754*4882a593Smuzhiyunto determine the BIOS codec initialization.
755*4882a593Smuzhiyun
756*4882a593Smuzhiyun
757*4882a593Smuzhiyunhda-verb
758*4882a593Smuzhiyun--------
759*4882a593Smuzhiyunhda-verb is a tiny program that allows you to access the HD-audio
760*4882a593Smuzhiyuncodec directly.  You can execute a raw HD-audio codec verb with this.
761*4882a593SmuzhiyunThis program accesses the hwdep device, thus you need to enable the
762*4882a593Smuzhiyunkernel config ``CONFIG_SND_HDA_HWDEP=y`` beforehand.
763*4882a593Smuzhiyun
764*4882a593SmuzhiyunThe hda-verb program takes four arguments: the hwdep device file, the
765*4882a593Smuzhiyunwidget NID, the verb and the parameter.  When you access to the codec
766*4882a593Smuzhiyunon the slot 2 of the card 0, pass /dev/snd/hwC0D2 to the first
767*4882a593Smuzhiyunargument, typically.  (However, the real path name depends on the
768*4882a593Smuzhiyunsystem.)
769*4882a593Smuzhiyun
770*4882a593SmuzhiyunThe second parameter is the widget number-id to access.  The third
771*4882a593Smuzhiyunparameter can be either a hex/digit number or a string corresponding
772*4882a593Smuzhiyunto a verb.  Similarly, the last parameter is the value to write, or
773*4882a593Smuzhiyuncan be a string for the parameter type.
774*4882a593Smuzhiyun
775*4882a593Smuzhiyun::
776*4882a593Smuzhiyun
777*4882a593Smuzhiyun    % hda-verb /dev/snd/hwC0D0 0x12 0x701 2
778*4882a593Smuzhiyun    nid = 0x12, verb = 0x701, param = 0x2
779*4882a593Smuzhiyun    value = 0x0
780*4882a593Smuzhiyun
781*4882a593Smuzhiyun    % hda-verb /dev/snd/hwC0D0 0x0 PARAMETERS VENDOR_ID
782*4882a593Smuzhiyun    nid = 0x0, verb = 0xf00, param = 0x0
783*4882a593Smuzhiyun    value = 0x10ec0262
784*4882a593Smuzhiyun
785*4882a593Smuzhiyun    % hda-verb /dev/snd/hwC0D0 2 set_a 0xb080
786*4882a593Smuzhiyun    nid = 0x2, verb = 0x300, param = 0xb080
787*4882a593Smuzhiyun    value = 0x0
788*4882a593Smuzhiyun
789*4882a593Smuzhiyun
790*4882a593SmuzhiyunAlthough you can issue any verbs with this program, the driver state
791*4882a593Smuzhiyunwon't be always updated.  For example, the volume values are usually
792*4882a593Smuzhiyuncached in the driver, and thus changing the widget amp value directly
793*4882a593Smuzhiyunvia hda-verb won't change the mixer value.
794*4882a593Smuzhiyun
795*4882a593SmuzhiyunThe hda-verb program is included now in alsa-tools:
796*4882a593Smuzhiyun
797*4882a593Smuzhiyun* git://git.alsa-project.org/alsa-tools.git
798*4882a593Smuzhiyun
799*4882a593SmuzhiyunAlso, the old stand-alone package is found in the ftp directory:
800*4882a593Smuzhiyun
801*4882a593Smuzhiyun* ftp://ftp.suse.com/pub/people/tiwai/misc/
802*4882a593Smuzhiyun
803*4882a593SmuzhiyunAlso a git repository is available:
804*4882a593Smuzhiyun
805*4882a593Smuzhiyun* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-verb.git
806*4882a593Smuzhiyun
807*4882a593SmuzhiyunSee README file in the tarball for more details about hda-verb
808*4882a593Smuzhiyunprogram.
809*4882a593Smuzhiyun
810*4882a593Smuzhiyun
811*4882a593Smuzhiyunhda-analyzer
812*4882a593Smuzhiyun------------
813*4882a593Smuzhiyunhda-analyzer provides a graphical interface to access the raw HD-audio
814*4882a593Smuzhiyuncontrol, based on pyGTK2 binding.  It's a more powerful version of
815*4882a593Smuzhiyunhda-verb.  The program gives you an easy-to-use GUI stuff for showing
816*4882a593Smuzhiyunthe widget information and adjusting the amp values, as well as the
817*4882a593Smuzhiyunproc-compatible output.
818*4882a593Smuzhiyun
819*4882a593SmuzhiyunThe hda-analyzer:
820*4882a593Smuzhiyun
821*4882a593Smuzhiyun* https://git.alsa-project.org/?p=alsa.git;a=tree;f=hda-analyzer
822*4882a593Smuzhiyun
823*4882a593Smuzhiyunis a part of alsa.git repository in alsa-project.org:
824*4882a593Smuzhiyun
825*4882a593Smuzhiyun* git://git.alsa-project.org/alsa.git
826*4882a593Smuzhiyun
827*4882a593SmuzhiyunCodecgraph
828*4882a593Smuzhiyun----------
829*4882a593SmuzhiyunCodecgraph is a utility program to generate a graph and visualizes the
830*4882a593Smuzhiyuncodec-node connection of a codec chip.  It's especially useful when
831*4882a593Smuzhiyunyou analyze or debug a codec without a proper datasheet.  The program
832*4882a593Smuzhiyunparses the given codec proc file and converts to SVG via graphiz
833*4882a593Smuzhiyunprogram.
834*4882a593Smuzhiyun
835*4882a593SmuzhiyunThe tarball and GIT trees are found in the web page at:
836*4882a593Smuzhiyun
837*4882a593Smuzhiyun* http://helllabs.org/codecgraph/
838*4882a593Smuzhiyun
839*4882a593Smuzhiyun
840*4882a593Smuzhiyunhda-emu
841*4882a593Smuzhiyun-------
842*4882a593Smuzhiyunhda-emu is an HD-audio emulator.  The main purpose of this program is
843*4882a593Smuzhiyunto debug an HD-audio codec without the real hardware.  Thus, it
844*4882a593Smuzhiyundoesn't emulate the behavior with the real audio I/O, but it just
845*4882a593Smuzhiyundumps the codec register changes and the ALSA-driver internal changes
846*4882a593Smuzhiyunat probing and operating the HD-audio driver.
847*4882a593Smuzhiyun
848*4882a593SmuzhiyunThe program requires a codec proc-file to simulate.  Get a proc file
849*4882a593Smuzhiyunfor the target codec beforehand, or pick up an example codec from the
850*4882a593Smuzhiyuncodec proc collections in the tarball.  Then, run the program with the
851*4882a593Smuzhiyunproc file, and the hda-emu program will start parsing the codec file
852*4882a593Smuzhiyunand simulates the HD-audio driver:
853*4882a593Smuzhiyun
854*4882a593Smuzhiyun::
855*4882a593Smuzhiyun
856*4882a593Smuzhiyun    % hda-emu codecs/stac9200-dell-d820-laptop
857*4882a593Smuzhiyun    # Parsing..
858*4882a593Smuzhiyun    hda_codec: Unknown model for STAC9200, using BIOS defaults
859*4882a593Smuzhiyun    hda_codec: pin nid 08 bios pin config 40c003fa
860*4882a593Smuzhiyun    ....
861*4882a593Smuzhiyun
862*4882a593Smuzhiyun
863*4882a593SmuzhiyunThe program gives you only a very dumb command-line interface.  You
864*4882a593Smuzhiyuncan get a proc-file dump at the current state, get a list of control
865*4882a593Smuzhiyun(mixer) elements, set/get the control element value, simulate the PCM
866*4882a593Smuzhiyunoperation, the jack plugging simulation, etc.
867*4882a593Smuzhiyun
868*4882a593SmuzhiyunThe program is found in the git repository below:
869*4882a593Smuzhiyun
870*4882a593Smuzhiyun* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git
871*4882a593Smuzhiyun
872*4882a593SmuzhiyunSee README file in the repository for more details about hda-emu
873*4882a593Smuzhiyunprogram.
874*4882a593Smuzhiyun
875*4882a593Smuzhiyun
876*4882a593Smuzhiyunhda-jack-retask
877*4882a593Smuzhiyun---------------
878*4882a593Smuzhiyunhda-jack-retask is a user-friendly GUI program to manipulate the
879*4882a593SmuzhiyunHD-audio pin control for jack retasking.  If you have a problem about
880*4882a593Smuzhiyunthe jack assignment, try this program and check whether you can get
881*4882a593Smuzhiyunuseful results.  Once when you figure out the proper pin assignment,
882*4882a593Smuzhiyunit can be fixed either in the driver code statically or via passing a
883*4882a593Smuzhiyunfirmware patch file (see "Early Patching" section).
884*4882a593Smuzhiyun
885*4882a593SmuzhiyunThe program is included in alsa-tools now:
886*4882a593Smuzhiyun
887*4882a593Smuzhiyun* git://git.alsa-project.org/alsa-tools.git
888