18c2ecf20Sopenharmony_ci=============================
28c2ecf20Sopenharmony_ciMore Notes on HD-Audio Driver
38c2ecf20Sopenharmony_ci=============================
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ciTakashi Iwai <tiwai@suse.de>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ciGeneral
98c2ecf20Sopenharmony_ci=======
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciHD-audio is the new standard on-board audio component on modern PCs
128c2ecf20Sopenharmony_ciafter AC97.  Although Linux has been supporting HD-audio since long
138c2ecf20Sopenharmony_citime ago, there are often problems with new machines.  A part of the
148c2ecf20Sopenharmony_ciproblem is broken BIOS, and the rest is the driver implementation.
158c2ecf20Sopenharmony_ciThis document explains the brief trouble-shooting and debugging
168c2ecf20Sopenharmony_cimethods for the	HD-audio hardware.
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ciThe HD-audio component consists of two parts: the controller chip and 
198c2ecf20Sopenharmony_cithe codec chips on the HD-audio bus.  Linux provides a single driver
208c2ecf20Sopenharmony_cifor all controllers, snd-hda-intel.  Although the driver name contains
218c2ecf20Sopenharmony_cia word of a well-known hardware vendor, it's not specific to it but for
228c2ecf20Sopenharmony_ciall controller chips by other companies.  Since the HD-audio
238c2ecf20Sopenharmony_cicontrollers are supposed to be compatible, the single snd-hda-driver
248c2ecf20Sopenharmony_cishould work in most cases.  But, not surprisingly, there are known
258c2ecf20Sopenharmony_cibugs and issues specific to each controller type.  The snd-hda-intel
268c2ecf20Sopenharmony_cidriver has a bunch of workarounds for these as described below.
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciA controller may have multiple codecs.  Usually you have one audio
298c2ecf20Sopenharmony_cicodec and optionally one modem codec.  In theory, there might be
308c2ecf20Sopenharmony_cimultiple audio codecs, e.g. for analog and digital outputs, and the
318c2ecf20Sopenharmony_cidriver might not work properly because of conflict of mixer elements.
328c2ecf20Sopenharmony_ciThis should be fixed in future if such hardware really exists.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciThe snd-hda-intel driver has several different codec parsers depending
358c2ecf20Sopenharmony_cion the codec.  It has a generic parser as a fallback, but this
368c2ecf20Sopenharmony_cifunctionality is fairly limited until now.  Instead of the generic
378c2ecf20Sopenharmony_ciparser, usually the codec-specific parser (coded in patch_*.c) is used
388c2ecf20Sopenharmony_cifor the codec-specific implementations.  The details about the
398c2ecf20Sopenharmony_cicodec-specific problems are explained in the later sections.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciIf you are interested in the deep debugging of HD-audio, read the
428c2ecf20Sopenharmony_ciHD-audio specification at first.  The specification is found on
438c2ecf20Sopenharmony_ciIntel's web page, for example:
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci* https://www.intel.com/standards/hdaudio/
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciHD-Audio Controller
498c2ecf20Sopenharmony_ci===================
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciDMA-Position Problem
528c2ecf20Sopenharmony_ci--------------------
538c2ecf20Sopenharmony_ciThe most common problem of the controller is the inaccurate DMA
548c2ecf20Sopenharmony_cipointer reporting.  The DMA pointer for playback and capture can be
558c2ecf20Sopenharmony_ciread in two ways, either via a LPIB register or via a position-buffer
568c2ecf20Sopenharmony_cimap.  As default the driver tries to read from the io-mapped
578c2ecf20Sopenharmony_ciposition-buffer, and falls back to LPIB if the position-buffer appears
588c2ecf20Sopenharmony_cidead.  However, this detection isn't perfect on some devices.  In such
598c2ecf20Sopenharmony_cia case, you can change the default method via ``position_fix`` option.
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci``position_fix=1`` means to use LPIB method explicitly.
628c2ecf20Sopenharmony_ci``position_fix=2`` means to use the position-buffer.
638c2ecf20Sopenharmony_ci``position_fix=3`` means to use a combination of both methods, needed
648c2ecf20Sopenharmony_cifor some VIA controllers.  The capture stream position is corrected
658c2ecf20Sopenharmony_ciby comparing both LPIB and position-buffer values.
668c2ecf20Sopenharmony_ci``position_fix=4`` is another combination available for all controllers,
678c2ecf20Sopenharmony_ciand uses LPIB for the playback and the position-buffer for the capture
688c2ecf20Sopenharmony_cistreams.
698c2ecf20Sopenharmony_ci``position_fix=5`` is specific to Intel platforms, so far, for Skylake
708c2ecf20Sopenharmony_ciand onward.  It applies the delay calculation for the precise position
718c2ecf20Sopenharmony_cireporting.
728c2ecf20Sopenharmony_ci``position_fix=6`` is to correct the position with the fixed FIFO
738c2ecf20Sopenharmony_cisize, mainly targeted for the recent AMD controllers.
748c2ecf20Sopenharmony_ci0 is the default value for all other
758c2ecf20Sopenharmony_cicontrollers, the automatic check and fallback to LPIB as described in
768c2ecf20Sopenharmony_cithe above.  If you get a problem of repeated sounds, this option might
778c2ecf20Sopenharmony_cihelp.
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ciIn addition to that, every controller is known to be broken regarding
808c2ecf20Sopenharmony_cithe wake-up timing.  It wakes up a few samples before actually
818c2ecf20Sopenharmony_ciprocessing the data on the buffer.  This caused a lot of problems, for
828c2ecf20Sopenharmony_ciexample, with ALSA dmix or JACK.  Since 2.6.27 kernel, the driver puts
838c2ecf20Sopenharmony_cian artificial delay to the wake up timing.  This delay is controlled
848c2ecf20Sopenharmony_civia ``bdl_pos_adj`` option. 
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciWhen ``bdl_pos_adj`` is a negative value (as default), it's assigned to
878c2ecf20Sopenharmony_cian appropriate value depending on the controller chip.  For Intel
888c2ecf20Sopenharmony_cichips, it'd be 1 while it'd be 32 for others.  Usually this works.
898c2ecf20Sopenharmony_ciOnly in case it doesn't work and you get warning messages, you should
908c2ecf20Sopenharmony_cichange this parameter to other values.
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ciCodec-Probing Problem
948c2ecf20Sopenharmony_ci---------------------
958c2ecf20Sopenharmony_ciA less often but a more severe problem is the codec probing.  When
968c2ecf20Sopenharmony_ciBIOS reports the available codec slots wrongly, the driver gets
978c2ecf20Sopenharmony_ciconfused and tries to access the non-existing codec slot.  This often
988c2ecf20Sopenharmony_ciresults in the total screw-up, and destructs the further communication
998c2ecf20Sopenharmony_ciwith the codec chips.  The symptom appears usually as error messages
1008c2ecf20Sopenharmony_cilike:
1018c2ecf20Sopenharmony_ci::
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci    hda_intel: azx_get_response timeout, switching to polling mode:
1048c2ecf20Sopenharmony_ci          last cmd=0x12345678
1058c2ecf20Sopenharmony_ci    hda_intel: azx_get_response timeout, switching to single_cmd mode:
1068c2ecf20Sopenharmony_ci          last cmd=0x12345678
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciThe first line is a warning, and this is usually relatively harmless.
1098c2ecf20Sopenharmony_ciIt means that the codec response isn't notified via an IRQ.  The
1108c2ecf20Sopenharmony_cidriver uses explicit polling method to read the response.  It gives
1118c2ecf20Sopenharmony_civery slight CPU overhead, but you'd unlikely notice it.
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ciThe second line is, however, a fatal error.  If this happens, usually
1148c2ecf20Sopenharmony_ciit means that something is really wrong.  Most likely you are
1158c2ecf20Sopenharmony_ciaccessing a non-existing codec slot.
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ciThus, if the second error message appears, try to narrow the probed
1188c2ecf20Sopenharmony_cicodec slots via ``probe_mask`` option.  It's a bitmask, and each bit
1198c2ecf20Sopenharmony_cicorresponds to the codec slot.  For example, to probe only the first
1208c2ecf20Sopenharmony_cislot, pass ``probe_mask=1``.  For the first and the third slots, pass
1218c2ecf20Sopenharmony_ci``probe_mask=5`` (where 5 = 1 | 4), and so on.
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ciSince 2.6.29 kernel, the driver has a more robust probing method, so
1248c2ecf20Sopenharmony_cithis error might happen rarely, though.
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ciOn a machine with a broken BIOS, sometimes you need to force the
1278c2ecf20Sopenharmony_cidriver to probe the codec slots the hardware doesn't report for use.
1288c2ecf20Sopenharmony_ciIn such a case, turn the bit 8 (0x100) of ``probe_mask`` option on.
1298c2ecf20Sopenharmony_ciThen the rest 8 bits are passed as the codec slots to probe
1308c2ecf20Sopenharmony_ciunconditionally.  For example, ``probe_mask=0x103`` will force to probe
1318c2ecf20Sopenharmony_cithe codec slots 0 and 1 no matter what the hardware reports.
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ciInterrupt Handling
1358c2ecf20Sopenharmony_ci------------------
1368c2ecf20Sopenharmony_ciHD-audio driver uses MSI as default (if available) since 2.6.33
1378c2ecf20Sopenharmony_cikernel as MSI works better on some machines, and in general, it's
1388c2ecf20Sopenharmony_cibetter for performance.  However, Nvidia controllers showed bad
1398c2ecf20Sopenharmony_ciregressions with MSI (especially in a combination with AMD chipset),
1408c2ecf20Sopenharmony_cithus we disabled MSI for them.
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ciThere seem also still other devices that don't work with MSI.  If you
1438c2ecf20Sopenharmony_cisee a regression wrt the sound quality (stuttering, etc) or a lock-up
1448c2ecf20Sopenharmony_ciin the recent kernel, try to pass ``enable_msi=0`` option to disable
1458c2ecf20Sopenharmony_ciMSI.  If it works, you can add the known bad device to the blacklist
1468c2ecf20Sopenharmony_cidefined in hda_intel.c.  In such a case, please report and give the
1478c2ecf20Sopenharmony_cipatch back to the upstream developer. 
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ciHD-Audio Codec
1518c2ecf20Sopenharmony_ci==============
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ciModel Option
1548c2ecf20Sopenharmony_ci------------
1558c2ecf20Sopenharmony_ciThe most common problem regarding the HD-audio driver is the
1568c2ecf20Sopenharmony_ciunsupported codec features or the mismatched device configuration.
1578c2ecf20Sopenharmony_ciMost of codec-specific code has several preset models, either to
1588c2ecf20Sopenharmony_cioverride the BIOS setup or to provide more comprehensive features.
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ciThe driver checks PCI SSID and looks through the static configuration
1618c2ecf20Sopenharmony_citable until any matching entry is found.  If you have a new machine,
1628c2ecf20Sopenharmony_ciyou may see a message like below:
1638c2ecf20Sopenharmony_ci::
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci    hda_codec: ALC880: BIOS auto-probing.
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ciMeanwhile, in the earlier versions, you would see a message like:
1688c2ecf20Sopenharmony_ci::
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci    hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ciEven if you see such a message, DON'T PANIC.  Take a deep breath and
1738c2ecf20Sopenharmony_cikeep your towel.  First of all, it's an informational message, no
1748c2ecf20Sopenharmony_ciwarning, no error.  This means that the PCI SSID of your device isn't
1758c2ecf20Sopenharmony_cilisted in the known preset model (white-)list.  But, this doesn't mean
1768c2ecf20Sopenharmony_cithat the driver is broken.  Many codec-drivers provide the automatic
1778c2ecf20Sopenharmony_ciconfiguration mechanism based on the BIOS setup.
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ciThe HD-audio codec has usually "pin" widgets, and BIOS sets the default
1808c2ecf20Sopenharmony_ciconfiguration of each pin, which indicates the location, the
1818c2ecf20Sopenharmony_ciconnection type, the jack color, etc.  The HD-audio driver can guess
1828c2ecf20Sopenharmony_cithe right connection judging from these default configuration values.
1838c2ecf20Sopenharmony_ciHowever -- some codec-support codes, such as patch_analog.c, don't
1848c2ecf20Sopenharmony_cisupport the automatic probing (yet as of 2.6.28).  And, BIOS is often,
1858c2ecf20Sopenharmony_ciyes, pretty often broken.  It sets up wrong values and screws up the
1868c2ecf20Sopenharmony_cidriver.
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ciThe preset model (or recently called as "fix-up") is provided
1898c2ecf20Sopenharmony_cibasically to overcome such a situation.  When the matching preset
1908c2ecf20Sopenharmony_cimodel is found in the white-list, the driver assumes the static
1918c2ecf20Sopenharmony_ciconfiguration of that preset with the correct pin setup, etc.
1928c2ecf20Sopenharmony_ciThus, if you have a newer machine with a slightly different PCI SSID
1938c2ecf20Sopenharmony_ci(or codec SSID) from the existing one, you may have a good chance to
1948c2ecf20Sopenharmony_cire-use the same model.  You can pass the ``model`` option to specify the
1958c2ecf20Sopenharmony_cipreset model instead of PCI (and codec-) SSID look-up.
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ciWhat ``model`` option values are available depends on the codec chip.
1988c2ecf20Sopenharmony_ciCheck your codec chip from the codec proc file (see "Codec Proc-File"
1998c2ecf20Sopenharmony_cisection below).  It will show the vendor/product name of your codec
2008c2ecf20Sopenharmony_cichip.  Then, see Documentation/sound/hd-audio/models.rst file,
2018c2ecf20Sopenharmony_cithe section of HD-audio driver.  You can find a list of codecs
2028c2ecf20Sopenharmony_ciand ``model`` options belonging to each codec.  For example, for Realtek
2038c2ecf20Sopenharmony_ciALC262 codec chip, pass ``model=ultra`` for devices that are compatible
2048c2ecf20Sopenharmony_ciwith Samsung Q1 Ultra.
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_ciThus, the first thing you can do for any brand-new, unsupported and
2078c2ecf20Sopenharmony_cinon-working HD-audio hardware is to check HD-audio codec and several
2088c2ecf20Sopenharmony_cidifferent ``model`` option values.  If you have any luck, some of them
2098c2ecf20Sopenharmony_cimight suit with your device well.
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ciThere are a few special model option values:
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci* when 'nofixup' is passed, the device-specific fixups in the codec
2148c2ecf20Sopenharmony_ci  parser are skipped.
2158c2ecf20Sopenharmony_ci* when ``generic`` is passed, the codec-specific parser is skipped and
2168c2ecf20Sopenharmony_ci  only the generic parser is used.
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ciSpeaker and Headphone Output
2208c2ecf20Sopenharmony_ci----------------------------
2218c2ecf20Sopenharmony_ciOne of the most frequent (and obvious) bugs with HD-audio is the
2228c2ecf20Sopenharmony_cisilent output from either or both of a built-in speaker and a
2238c2ecf20Sopenharmony_ciheadphone jack.  In general, you should try a headphone output at
2248c2ecf20Sopenharmony_cifirst.  A speaker output often requires more additional controls like
2258c2ecf20Sopenharmony_cithe external amplifier bits.  Thus a headphone output has a slightly
2268c2ecf20Sopenharmony_cibetter chance.
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ciBefore making a bug report, double-check whether the mixer is set up
2298c2ecf20Sopenharmony_cicorrectly.  The recent version of snd-hda-intel driver provides mostly
2308c2ecf20Sopenharmony_ci"Master" volume control as well as "Front" volume (where Front
2318c2ecf20Sopenharmony_ciindicates the front-channels).  In addition, there can be individual
2328c2ecf20Sopenharmony_ci"Headphone" and "Speaker" controls.
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ciDitto for the speaker output.  There can be "External Amplifier"
2358c2ecf20Sopenharmony_ciswitch on some codecs.  Turn on this if present.
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ciAnother related problem is the automatic mute of speaker output by
2388c2ecf20Sopenharmony_ciheadphone plugging.  This feature is implemented in most cases, but
2398c2ecf20Sopenharmony_cinot on every preset model or codec-support code.
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ciIn anyway, try a different model option if you have such a problem.
2428c2ecf20Sopenharmony_ciSome other models may match better and give you more matching
2438c2ecf20Sopenharmony_cifunctionality.  If none of the available models works, send a bug
2448c2ecf20Sopenharmony_cireport.  See the bug report section for details.
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ciIf you are masochistic enough to debug the driver problem, note the
2478c2ecf20Sopenharmony_cifollowing:
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci* The speaker (and the headphone, too) output often requires the
2508c2ecf20Sopenharmony_ci  external amplifier.  This can be set usually via EAPD verb or a
2518c2ecf20Sopenharmony_ci  certain GPIO.  If the codec pin supports EAPD, you have a better
2528c2ecf20Sopenharmony_ci  chance via SET_EAPD_BTL verb (0x70c).  On others, GPIO pin (mostly
2538c2ecf20Sopenharmony_ci  it's either GPIO0 or GPIO1) may turn on/off EAPD.
2548c2ecf20Sopenharmony_ci* Some Realtek codecs require special vendor-specific coefficients to
2558c2ecf20Sopenharmony_ci  turn on the amplifier.  See patch_realtek.c.
2568c2ecf20Sopenharmony_ci* IDT codecs may have extra power-enable/disable controls on each
2578c2ecf20Sopenharmony_ci  analog pin.  See patch_sigmatel.c.
2588c2ecf20Sopenharmony_ci* Very rare but some devices don't accept the pin-detection verb until
2598c2ecf20Sopenharmony_ci  triggered.  Issuing GET_PIN_SENSE verb (0xf09) may result in the
2608c2ecf20Sopenharmony_ci  codec-communication stall.  Some examples are found in
2618c2ecf20Sopenharmony_ci  patch_realtek.c.
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ciCapture Problems
2658c2ecf20Sopenharmony_ci----------------
2668c2ecf20Sopenharmony_ciThe capture problems are often because of missing setups of mixers.
2678c2ecf20Sopenharmony_ciThus, before submitting a bug report, make sure that you set up the
2688c2ecf20Sopenharmony_cimixer correctly.  For example, both "Capture Volume" and "Capture
2698c2ecf20Sopenharmony_ciSwitch" have to be set properly in addition to the right "Capture
2708c2ecf20Sopenharmony_ciSource" or "Input Source" selection.  Some devices have "Mic Boost"
2718c2ecf20Sopenharmony_civolume or switch.
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ciWhen the PCM device is opened via "default" PCM (without pulse-audio
2748c2ecf20Sopenharmony_ciplugin), you'll likely have "Digital Capture Volume" control as well.
2758c2ecf20Sopenharmony_ciThis is provided for the extra gain/attenuation of the signal in
2768c2ecf20Sopenharmony_cisoftware, especially for the inputs without the hardware volume
2778c2ecf20Sopenharmony_cicontrol such as digital microphones.  Unless really needed, this
2788c2ecf20Sopenharmony_cishould be set to exactly 50%, corresponding to 0dB -- neither extra
2798c2ecf20Sopenharmony_cigain nor attenuation.  When you use "hw" PCM, i.e., a raw access PCM,
2808c2ecf20Sopenharmony_cithis control will have no influence, though.
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ciIt's known that some codecs / devices have fairly bad analog circuits,
2838c2ecf20Sopenharmony_ciand the recorded sound contains a certain DC-offset.  This is no bug
2848c2ecf20Sopenharmony_ciof the driver.
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_ciMost of modern laptops have no analog CD-input connection.  Thus, the
2878c2ecf20Sopenharmony_cirecording from CD input won't work in many cases although the driver
2888c2ecf20Sopenharmony_ciprovides it as the capture source.  Use CDDA instead.
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ciThe automatic switching of the built-in and external mic per plugging
2918c2ecf20Sopenharmony_ciis implemented on some codec models but not on every model.  Partly
2928c2ecf20Sopenharmony_cibecause of my laziness but mostly lack of testers.  Feel free to
2938c2ecf20Sopenharmony_cisubmit the improvement patch to the author.
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ciDirect Debugging
2978c2ecf20Sopenharmony_ci----------------
2988c2ecf20Sopenharmony_ciIf no model option gives you a better result, and you are a tough guy
2998c2ecf20Sopenharmony_cito fight against evil, try debugging via hitting the raw HD-audio
3008c2ecf20Sopenharmony_cicodec verbs to the device.  Some tools are available: hda-emu and
3018c2ecf20Sopenharmony_cihda-analyzer.  The detailed description is found in the sections
3028c2ecf20Sopenharmony_cibelow.  You'd need to enable hwdep for using these tools.  See "Kernel
3038c2ecf20Sopenharmony_ciConfiguration" section.
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ciOther Issues
3078c2ecf20Sopenharmony_ci============
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_ciKernel Configuration
3108c2ecf20Sopenharmony_ci--------------------
3118c2ecf20Sopenharmony_ciIn general, I recommend you to enable the sound debug option,
3128c2ecf20Sopenharmony_ci``CONFIG_SND_DEBUG=y``, no matter whether you are debugging or not.
3138c2ecf20Sopenharmony_ciThis enables snd_printd() macro and others, and you'll get additional
3148c2ecf20Sopenharmony_cikernel messages at probing.
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ciIn addition, you can enable ``CONFIG_SND_DEBUG_VERBOSE=y``.  But this
3178c2ecf20Sopenharmony_ciwill give you far more messages.  Thus turn this on only when you are
3188c2ecf20Sopenharmony_cisure to want it.
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ciDon't forget to turn on the appropriate ``CONFIG_SND_HDA_CODEC_*``
3218c2ecf20Sopenharmony_cioptions.  Note that each of them corresponds to the codec chip, not
3228c2ecf20Sopenharmony_cithe controller chip.  Thus, even if lspci shows the Nvidia controller,
3238c2ecf20Sopenharmony_ciyou may need to choose the option for other vendors.  If you are
3248c2ecf20Sopenharmony_ciunsure, just select all yes.
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci``CONFIG_SND_HDA_HWDEP`` is a useful option for debugging the driver.
3278c2ecf20Sopenharmony_ciWhen this is enabled, the driver creates hardware-dependent devices
3288c2ecf20Sopenharmony_ci(one per each codec), and you have a raw access to the device via
3298c2ecf20Sopenharmony_cithese device files.  For example, ``hwC0D2`` will be created for the
3308c2ecf20Sopenharmony_cicodec slot #2 of the first card (#0).  For debug-tools such as
3318c2ecf20Sopenharmony_cihda-verb and hda-analyzer, the hwdep device has to be enabled.
3328c2ecf20Sopenharmony_ciThus, it'd be better to turn this on always.
3338c2ecf20Sopenharmony_ci
3348c2ecf20Sopenharmony_ci``CONFIG_SND_HDA_RECONFIG`` is a new option, and this depends on the
3358c2ecf20Sopenharmony_cihwdep option above.  When enabled, you'll have some sysfs files under
3368c2ecf20Sopenharmony_cithe corresponding hwdep directory.  See "HD-audio reconfiguration"
3378c2ecf20Sopenharmony_cisection below.
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci``CONFIG_SND_HDA_POWER_SAVE`` option enables the power-saving feature.
3408c2ecf20Sopenharmony_ciSee "Power-saving" section below.
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ciCodec Proc-File
3448c2ecf20Sopenharmony_ci---------------
3458c2ecf20Sopenharmony_ciThe codec proc-file is a treasure-chest for debugging HD-audio.
3468c2ecf20Sopenharmony_ciIt shows most of useful information of each codec widget.
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ciThe proc file is located in /proc/asound/card*/codec#*, one file per
3498c2ecf20Sopenharmony_cieach codec slot.  You can know the codec vendor, product id and
3508c2ecf20Sopenharmony_cinames, the type of each widget, capabilities and so on.
3518c2ecf20Sopenharmony_ciThis file, however, doesn't show the jack sensing state, so far.  This
3528c2ecf20Sopenharmony_ciis because the jack-sensing might be depending on the trigger state.
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ciThis file will be picked up by the debug tools, and also it can be fed
3558c2ecf20Sopenharmony_cito the emulator as the primary codec information.  See the debug tools
3568c2ecf20Sopenharmony_cisection below.
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ciThis proc file can be also used to check whether the generic parser is
3598c2ecf20Sopenharmony_ciused.  When the generic parser is used, the vendor/product ID name
3608c2ecf20Sopenharmony_ciwill appear as "Realtek ID 0262", instead of "Realtek ALC262".
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ciHD-Audio Reconfiguration
3648c2ecf20Sopenharmony_ci------------------------
3658c2ecf20Sopenharmony_ciThis is an experimental feature to allow you re-configure the HD-audio
3668c2ecf20Sopenharmony_cicodec dynamically without reloading the driver.  The following sysfs
3678c2ecf20Sopenharmony_cifiles are available under each codec-hwdep device directory (e.g. 
3688c2ecf20Sopenharmony_ci/sys/class/sound/hwC0D0):
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_civendor_id
3718c2ecf20Sopenharmony_ci    Shows the 32bit codec vendor-id hex number.  You can change the
3728c2ecf20Sopenharmony_ci    vendor-id value by writing to this file.
3738c2ecf20Sopenharmony_cisubsystem_id
3748c2ecf20Sopenharmony_ci    Shows the 32bit codec subsystem-id hex number.  You can change the
3758c2ecf20Sopenharmony_ci    subsystem-id value by writing to this file.
3768c2ecf20Sopenharmony_cirevision_id
3778c2ecf20Sopenharmony_ci    Shows the 32bit codec revision-id hex number.  You can change the
3788c2ecf20Sopenharmony_ci    revision-id value by writing to this file.
3798c2ecf20Sopenharmony_ciafg
3808c2ecf20Sopenharmony_ci    Shows the AFG ID.  This is read-only.
3818c2ecf20Sopenharmony_cimfg
3828c2ecf20Sopenharmony_ci    Shows the MFG ID.  This is read-only.
3838c2ecf20Sopenharmony_ciname
3848c2ecf20Sopenharmony_ci    Shows the codec name string.  Can be changed by writing to this
3858c2ecf20Sopenharmony_ci    file.
3868c2ecf20Sopenharmony_cimodelname
3878c2ecf20Sopenharmony_ci    Shows the currently set ``model`` option.  Can be changed by writing
3888c2ecf20Sopenharmony_ci    to this file.
3898c2ecf20Sopenharmony_ciinit_verbs
3908c2ecf20Sopenharmony_ci    The extra verbs to execute at initialization.  You can add a verb by
3918c2ecf20Sopenharmony_ci    writing to this file.  Pass three numbers: nid, verb and parameter
3928c2ecf20Sopenharmony_ci    (separated with a space).
3938c2ecf20Sopenharmony_cihints
3948c2ecf20Sopenharmony_ci    Shows / stores hint strings for codec parsers for any use.
3958c2ecf20Sopenharmony_ci    Its format is ``key = value``.  For example, passing ``jack_detect = no``
3968c2ecf20Sopenharmony_ci    will disable the jack detection of the machine completely.
3978c2ecf20Sopenharmony_ciinit_pin_configs
3988c2ecf20Sopenharmony_ci    Shows the initial pin default config values set by BIOS.
3998c2ecf20Sopenharmony_cidriver_pin_configs
4008c2ecf20Sopenharmony_ci    Shows the pin default values set by the codec parser explicitly.
4018c2ecf20Sopenharmony_ci    This doesn't show all pin values but only the changed values by
4028c2ecf20Sopenharmony_ci    the parser.  That is, if the parser doesn't change the pin default
4038c2ecf20Sopenharmony_ci    config values by itself, this will contain nothing.
4048c2ecf20Sopenharmony_ciuser_pin_configs
4058c2ecf20Sopenharmony_ci    Shows the pin default config values to override the BIOS setup.
4068c2ecf20Sopenharmony_ci    Writing this (with two numbers, NID and value) appends the new
4078c2ecf20Sopenharmony_ci    value.  The given will be used instead of the initial BIOS value at
4088c2ecf20Sopenharmony_ci    the next reconfiguration time.  Note that this config will override
4098c2ecf20Sopenharmony_ci    even the driver pin configs, too.
4108c2ecf20Sopenharmony_cireconfig
4118c2ecf20Sopenharmony_ci    Triggers the codec re-configuration.  When any value is written to
4128c2ecf20Sopenharmony_ci    this file, the driver re-initialize and parses the codec tree
4138c2ecf20Sopenharmony_ci    again.  All the changes done by the sysfs entries above are taken
4148c2ecf20Sopenharmony_ci    into account.
4158c2ecf20Sopenharmony_ciclear
4168c2ecf20Sopenharmony_ci    Resets the codec, removes the mixer elements and PCM stuff of the
4178c2ecf20Sopenharmony_ci    specified codec, and clear all init verbs and hints.
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_ciFor example, when you want to change the pin default configuration
4208c2ecf20Sopenharmony_civalue of the pin widget 0x14 to 0x9993013f, and let the driver
4218c2ecf20Sopenharmony_cire-configure based on that state, run like below:
4228c2ecf20Sopenharmony_ci::
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ci    # echo 0x14 0x9993013f > /sys/class/sound/hwC0D0/user_pin_configs
4258c2ecf20Sopenharmony_ci    # echo 1 > /sys/class/sound/hwC0D0/reconfig  
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ciHint Strings
4298c2ecf20Sopenharmony_ci------------
4308c2ecf20Sopenharmony_ciThe codec parser have several switches and adjustment knobs for
4318c2ecf20Sopenharmony_cimatching better with the actual codec or device behavior.  Many of
4328c2ecf20Sopenharmony_cithem can be adjusted dynamically via "hints" strings as mentioned in
4338c2ecf20Sopenharmony_cithe section above.  For example, by passing ``jack_detect = no`` string
4348c2ecf20Sopenharmony_civia sysfs or a patch file, you can disable the jack detection, thus
4358c2ecf20Sopenharmony_cithe codec parser will skip the features like auto-mute or mic
4368c2ecf20Sopenharmony_ciauto-switch.  As a boolean value, either ``yes``, ``no``, ``true``, ``false``,
4378c2ecf20Sopenharmony_ci``1`` or ``0`` can be passed.
4388c2ecf20Sopenharmony_ci
4398c2ecf20Sopenharmony_ciThe generic parser supports the following hints:
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_cijack_detect (bool)
4428c2ecf20Sopenharmony_ci    specify whether the jack detection is available at all on this
4438c2ecf20Sopenharmony_ci    machine; default true
4448c2ecf20Sopenharmony_ciinv_jack_detect (bool)
4458c2ecf20Sopenharmony_ci    indicates that the jack detection logic is inverted
4468c2ecf20Sopenharmony_citrigger_sense (bool)
4478c2ecf20Sopenharmony_ci    indicates that the jack detection needs the explicit call of
4488c2ecf20Sopenharmony_ci    AC_VERB_SET_PIN_SENSE verb
4498c2ecf20Sopenharmony_ciinv_eapd (bool)
4508c2ecf20Sopenharmony_ci    indicates that the EAPD is implemented in the inverted logic
4518c2ecf20Sopenharmony_cipcm_format_first (bool)
4528c2ecf20Sopenharmony_ci    sets the PCM format before the stream tag and channel ID
4538c2ecf20Sopenharmony_cisticky_stream (bool)
4548c2ecf20Sopenharmony_ci    keep the PCM format, stream tag and ID as long as possible;
4558c2ecf20Sopenharmony_ci    default true
4568c2ecf20Sopenharmony_cispdif_status_reset (bool)
4578c2ecf20Sopenharmony_ci    reset the SPDIF status bits at each time the SPDIF stream is set
4588c2ecf20Sopenharmony_ci    up
4598c2ecf20Sopenharmony_cipin_amp_workaround (bool)
4608c2ecf20Sopenharmony_ci    the output pin may have multiple amp values
4618c2ecf20Sopenharmony_cisingle_adc_amp (bool)
4628c2ecf20Sopenharmony_ci    ADCs can have only single input amps
4638c2ecf20Sopenharmony_ciauto_mute (bool)
4648c2ecf20Sopenharmony_ci    enable/disable the headphone auto-mute feature; default true
4658c2ecf20Sopenharmony_ciauto_mic (bool)
4668c2ecf20Sopenharmony_ci    enable/disable the mic auto-switch feature; default true
4678c2ecf20Sopenharmony_ciline_in_auto_switch (bool)
4688c2ecf20Sopenharmony_ci    enable/disable the line-in auto-switch feature; default false
4698c2ecf20Sopenharmony_cineed_dac_fix (bool)
4708c2ecf20Sopenharmony_ci    limits the DACs depending on the channel count
4718c2ecf20Sopenharmony_ciprimary_hp (bool)
4728c2ecf20Sopenharmony_ci    probe headphone jacks as the primary outputs; default true
4738c2ecf20Sopenharmony_cimulti_io (bool)
4748c2ecf20Sopenharmony_ci    try probing multi-I/O config (e.g. shared line-in/surround,
4758c2ecf20Sopenharmony_ci    mic/clfe jacks)
4768c2ecf20Sopenharmony_cimulti_cap_vol (bool)
4778c2ecf20Sopenharmony_ci    provide multiple capture volumes
4788c2ecf20Sopenharmony_ciinv_dmic_split (bool)
4798c2ecf20Sopenharmony_ci    provide split internal mic volume/switch for phase-inverted
4808c2ecf20Sopenharmony_ci    digital mics
4818c2ecf20Sopenharmony_ciindep_hp (bool)
4828c2ecf20Sopenharmony_ci    provide the independent headphone PCM stream and the corresponding
4838c2ecf20Sopenharmony_ci    mixer control, if available
4848c2ecf20Sopenharmony_ciadd_stereo_mix_input (bool)
4858c2ecf20Sopenharmony_ci    add the stereo mix (analog-loopback mix) to the input mux if
4868c2ecf20Sopenharmony_ci    available 
4878c2ecf20Sopenharmony_ciadd_jack_modes (bool)
4888c2ecf20Sopenharmony_ci    add "xxx Jack Mode" enum controls to each I/O jack for allowing to
4898c2ecf20Sopenharmony_ci    change the headphone amp and mic bias VREF capabilities
4908c2ecf20Sopenharmony_cipower_save_node (bool)
4918c2ecf20Sopenharmony_ci    advanced power management for each widget, controlling the power
4928c2ecf20Sopenharmony_ci    sate (D0/D3) of each widget node depending on the actual pin and
4938c2ecf20Sopenharmony_ci    stream states
4948c2ecf20Sopenharmony_cipower_down_unused (bool)
4958c2ecf20Sopenharmony_ci    power down the unused widgets, a subset of power_save_node, and
4968c2ecf20Sopenharmony_ci    will be dropped in future 
4978c2ecf20Sopenharmony_ciadd_hp_mic (bool)
4988c2ecf20Sopenharmony_ci    add the headphone to capture source if possible
4998c2ecf20Sopenharmony_cihp_mic_detect (bool)
5008c2ecf20Sopenharmony_ci    enable/disable the hp/mic shared input for a single built-in mic
5018c2ecf20Sopenharmony_ci    case; default true
5028c2ecf20Sopenharmony_civmaster (bool)
5038c2ecf20Sopenharmony_ci    enable/disable the virtual Master control; default true
5048c2ecf20Sopenharmony_cimixer_nid (int)
5058c2ecf20Sopenharmony_ci    specifies the widget NID of the analog-loopback mixer
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci
5088c2ecf20Sopenharmony_ciEarly Patching
5098c2ecf20Sopenharmony_ci--------------
5108c2ecf20Sopenharmony_ciWhen ``CONFIG_SND_HDA_PATCH_LOADER=y`` is set, you can pass a "patch"
5118c2ecf20Sopenharmony_cias a firmware file for modifying the HD-audio setup before
5128c2ecf20Sopenharmony_ciinitializing the codec.  This can work basically like the
5138c2ecf20Sopenharmony_cireconfiguration via sysfs in the above, but it does it before the
5148c2ecf20Sopenharmony_cifirst codec configuration.
5158c2ecf20Sopenharmony_ci
5168c2ecf20Sopenharmony_ciA patch file is a plain text file which looks like below:
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci::
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_ci    [codec]
5218c2ecf20Sopenharmony_ci    0x12345678 0xabcd1234 2
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_ci    [model]
5248c2ecf20Sopenharmony_ci    auto
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ci    [pincfg]
5278c2ecf20Sopenharmony_ci    0x12 0x411111f0
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_ci    [verb]
5308c2ecf20Sopenharmony_ci    0x20 0x500 0x03
5318c2ecf20Sopenharmony_ci    0x20 0x400 0xff
5328c2ecf20Sopenharmony_ci
5338c2ecf20Sopenharmony_ci    [hint]
5348c2ecf20Sopenharmony_ci    jack_detect = no
5358c2ecf20Sopenharmony_ci
5368c2ecf20Sopenharmony_ci
5378c2ecf20Sopenharmony_ciThe file needs to have a line ``[codec]``.  The next line should contain
5388c2ecf20Sopenharmony_cithree numbers indicating the codec vendor-id (0x12345678 in the
5398c2ecf20Sopenharmony_ciexample), the codec subsystem-id (0xabcd1234) and the address (2) of
5408c2ecf20Sopenharmony_cithe codec.  The rest patch entries are applied to this specified codec
5418c2ecf20Sopenharmony_ciuntil another codec entry is given.  Passing 0 or a negative number to
5428c2ecf20Sopenharmony_cithe first or the second value will make the check of the corresponding
5438c2ecf20Sopenharmony_cifield be skipped.  It'll be useful for really broken devices that don't
5448c2ecf20Sopenharmony_ciinitialize SSID properly.
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ciThe ``[model]`` line allows to change the model name of the each codec.
5478c2ecf20Sopenharmony_ciIn the example above, it will be changed to model=auto.
5488c2ecf20Sopenharmony_ciNote that this overrides the module option.
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ciAfter the ``[pincfg]`` line, the contents are parsed as the initial
5518c2ecf20Sopenharmony_cidefault pin-configurations just like ``user_pin_configs`` sysfs above.
5528c2ecf20Sopenharmony_ciThe values can be shown in user_pin_configs sysfs file, too.
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_ciSimilarly, the lines after ``[verb]`` are parsed as ``init_verbs``
5558c2ecf20Sopenharmony_cisysfs entries, and the lines after ``[hint]`` are parsed as ``hints``
5568c2ecf20Sopenharmony_cisysfs entries, respectively.
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ciAnother example to override the codec vendor id from 0x12345678 to
5598c2ecf20Sopenharmony_ci0xdeadbeef is like below:
5608c2ecf20Sopenharmony_ci::
5618c2ecf20Sopenharmony_ci
5628c2ecf20Sopenharmony_ci    [codec]
5638c2ecf20Sopenharmony_ci    0x12345678 0xabcd1234 2
5648c2ecf20Sopenharmony_ci
5658c2ecf20Sopenharmony_ci    [vendor_id]
5668c2ecf20Sopenharmony_ci    0xdeadbeef
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ciIn the similar way, you can override the codec subsystem_id via
5708c2ecf20Sopenharmony_ci``[subsystem_id]``, the revision id via ``[revision_id]`` line.
5718c2ecf20Sopenharmony_ciAlso, the codec chip name can be rewritten via ``[chip_name]`` line.
5728c2ecf20Sopenharmony_ci::
5738c2ecf20Sopenharmony_ci
5748c2ecf20Sopenharmony_ci    [codec]
5758c2ecf20Sopenharmony_ci    0x12345678 0xabcd1234 2
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ci    [subsystem_id]
5788c2ecf20Sopenharmony_ci    0xffff1111
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci    [revision_id]
5818c2ecf20Sopenharmony_ci    0x10
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci    [chip_name]
5848c2ecf20Sopenharmony_ci    My-own NEWS-0002
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ciThe hd-audio driver reads the file via request_firmware().  Thus,
5888c2ecf20Sopenharmony_cia patch file has to be located on the appropriate firmware path,
5898c2ecf20Sopenharmony_citypically, /lib/firmware.  For example, when you pass the option
5908c2ecf20Sopenharmony_ci``patch=hda-init.fw``, the file /lib/firmware/hda-init.fw must be
5918c2ecf20Sopenharmony_cipresent.
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ciThe patch module option is specific to each card instance, and you
5948c2ecf20Sopenharmony_cineed to give one file name for each instance, separated by commas.
5958c2ecf20Sopenharmony_ciFor example, if you have two cards, one for an on-board analog and one 
5968c2ecf20Sopenharmony_cifor an HDMI video board, you may pass patch option like below:
5978c2ecf20Sopenharmony_ci::
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci    options snd-hda-intel patch=on-board-patch,hdmi-patch
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ciPower-Saving
6038c2ecf20Sopenharmony_ci------------
6048c2ecf20Sopenharmony_ciThe power-saving is a kind of auto-suspend of the device.  When the
6058c2ecf20Sopenharmony_cidevice is inactive for a certain time, the device is automatically
6068c2ecf20Sopenharmony_citurned off to save the power.  The time to go down is specified via
6078c2ecf20Sopenharmony_ci``power_save`` module option, and this option can be changed dynamically
6088c2ecf20Sopenharmony_civia sysfs.
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ciThe power-saving won't work when the analog loopback is enabled on
6118c2ecf20Sopenharmony_cisome codecs.  Make sure that you mute all unneeded signal routes when
6128c2ecf20Sopenharmony_ciyou want the power-saving.
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_ciThe power-saving feature might cause audible click noises at each
6158c2ecf20Sopenharmony_cipower-down/up depending on the device.  Some of them might be
6168c2ecf20Sopenharmony_cisolvable, but some are hard, I'm afraid.  Some distros such as
6178c2ecf20Sopenharmony_ciopenSUSE enables the power-saving feature automatically when the power
6188c2ecf20Sopenharmony_cicable is unplugged.  Thus, if you hear noises, suspect first the
6198c2ecf20Sopenharmony_cipower-saving.  See /sys/module/snd_hda_intel/parameters/power_save to
6208c2ecf20Sopenharmony_cicheck the current value.  If it's non-zero, the feature is turned on.
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_ciThe recent kernel supports the runtime PM for the HD-audio controller
6238c2ecf20Sopenharmony_cichip, too.  It means that the HD-audio controller is also powered up /
6248c2ecf20Sopenharmony_cidown dynamically.  The feature is enabled only for certain controller
6258c2ecf20Sopenharmony_cichips like Intel LynxPoint.  You can enable/disable this feature
6268c2ecf20Sopenharmony_ciforcibly by setting ``power_save_controller`` option, which is also
6278c2ecf20Sopenharmony_ciavailable at /sys/module/snd_hda_intel/parameters directory.
6288c2ecf20Sopenharmony_ci
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ciTracepoints
6318c2ecf20Sopenharmony_ci-----------
6328c2ecf20Sopenharmony_ciThe hd-audio driver gives a few basic tracepoints.
6338c2ecf20Sopenharmony_ci``hda:hda_send_cmd`` traces each CORB write while ``hda:hda_get_response``
6348c2ecf20Sopenharmony_citraces the response from RIRB (only when read from the codec driver).
6358c2ecf20Sopenharmony_ci``hda:hda_bus_reset`` traces the bus-reset due to fatal error, etc,
6368c2ecf20Sopenharmony_ci``hda:hda_unsol_event`` traces the unsolicited events, and
6378c2ecf20Sopenharmony_ci``hda:hda_power_down`` and ``hda:hda_power_up`` trace the power down/up
6388c2ecf20Sopenharmony_civia power-saving behavior.
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ciEnabling all tracepoints can be done like
6418c2ecf20Sopenharmony_ci::
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci    # echo 1 > /sys/kernel/debug/tracing/events/hda/enable
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_cithen after some commands, you can traces from
6468c2ecf20Sopenharmony_ci/sys/kernel/debug/tracing/trace file.  For example, when you want to
6478c2ecf20Sopenharmony_citrace what codec command is sent, enable the tracepoint like:
6488c2ecf20Sopenharmony_ci::
6498c2ecf20Sopenharmony_ci
6508c2ecf20Sopenharmony_ci    # cat /sys/kernel/debug/tracing/trace
6518c2ecf20Sopenharmony_ci    # tracer: nop
6528c2ecf20Sopenharmony_ci    #
6538c2ecf20Sopenharmony_ci    #       TASK-PID    CPU#    TIMESTAMP  FUNCTION
6548c2ecf20Sopenharmony_ci    #          | |       |          |         |
6558c2ecf20Sopenharmony_ci	   <...>-7807  [002] 105147.774889: hda_send_cmd: [0:0] val=e3a019
6568c2ecf20Sopenharmony_ci	   <...>-7807  [002] 105147.774893: hda_send_cmd: [0:0] val=e39019
6578c2ecf20Sopenharmony_ci	   <...>-7807  [002] 105147.999542: hda_send_cmd: [0:0] val=e3a01a
6588c2ecf20Sopenharmony_ci	   <...>-7807  [002] 105147.999543: hda_send_cmd: [0:0] val=e3901a
6598c2ecf20Sopenharmony_ci	   <...>-26764 [001] 349222.837143: hda_send_cmd: [0:0] val=e3a019
6608c2ecf20Sopenharmony_ci	   <...>-26764 [001] 349222.837148: hda_send_cmd: [0:0] val=e39019
6618c2ecf20Sopenharmony_ci	   <...>-26764 [001] 349223.058539: hda_send_cmd: [0:0] val=e3a01a
6628c2ecf20Sopenharmony_ci	   <...>-26764 [001] 349223.058541: hda_send_cmd: [0:0] val=e3901a
6638c2ecf20Sopenharmony_ci
6648c2ecf20Sopenharmony_ciHere ``[0:0]`` indicates the card number and the codec address, and
6658c2ecf20Sopenharmony_ci``val`` shows the value sent to the codec, respectively.  The value is
6668c2ecf20Sopenharmony_cia packed value, and you can decode it via hda-decode-verb program
6678c2ecf20Sopenharmony_ciincluded in hda-emu package below.  For example, the value e3a019 is
6688c2ecf20Sopenharmony_cito set the left output-amp value to 25.
6698c2ecf20Sopenharmony_ci::
6708c2ecf20Sopenharmony_ci
6718c2ecf20Sopenharmony_ci    % hda-decode-verb 0xe3a019
6728c2ecf20Sopenharmony_ci    raw value = 0x00e3a019
6738c2ecf20Sopenharmony_ci    cid = 0, nid = 0x0e, verb = 0x3a0, parm = 0x19
6748c2ecf20Sopenharmony_ci    raw value: verb = 0x3a0, parm = 0x19
6758c2ecf20Sopenharmony_ci    verbname = set_amp_gain_mute
6768c2ecf20Sopenharmony_ci    amp raw val = 0xa019
6778c2ecf20Sopenharmony_ci    output, left, idx=0, mute=0, val=25
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ciDevelopment Tree
6818c2ecf20Sopenharmony_ci----------------
6828c2ecf20Sopenharmony_ciThe latest development codes for HD-audio are found on sound git tree:
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_ci* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
6858c2ecf20Sopenharmony_ci
6868c2ecf20Sopenharmony_ciThe master branch or for-next branches can be used as the main
6878c2ecf20Sopenharmony_cidevelopment branches in general while the development for the current
6888c2ecf20Sopenharmony_ciand next kernels are found in for-linus and for-next branches,
6898c2ecf20Sopenharmony_cirespectively.
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_ci
6928c2ecf20Sopenharmony_ciSending a Bug Report
6938c2ecf20Sopenharmony_ci--------------------
6948c2ecf20Sopenharmony_ciIf any model or module options don't work for your device, it's time
6958c2ecf20Sopenharmony_cito send a bug report to the developers.  Give the following in your
6968c2ecf20Sopenharmony_cibug report:
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci* Hardware vendor, product and model names
6998c2ecf20Sopenharmony_ci* Kernel version (and ALSA-driver version if you built externally)
7008c2ecf20Sopenharmony_ci* ``alsa-info.sh`` output; run with ``--no-upload`` option.  See the
7018c2ecf20Sopenharmony_ci  section below about alsa-info
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ciIf it's a regression, at best, send alsa-info outputs of both working
7048c2ecf20Sopenharmony_ciand non-working kernels.  This is really helpful because we can
7058c2ecf20Sopenharmony_cicompare the codec registers directly.
7068c2ecf20Sopenharmony_ci
7078c2ecf20Sopenharmony_ciSend a bug report either the following:
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_cikernel-bugzilla
7108c2ecf20Sopenharmony_ci    https://bugzilla.kernel.org/
7118c2ecf20Sopenharmony_cialsa-devel ML
7128c2ecf20Sopenharmony_ci    alsa-devel@alsa-project.org
7138c2ecf20Sopenharmony_ci
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ciDebug Tools
7168c2ecf20Sopenharmony_ci===========
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_ciThis section describes some tools available for debugging HD-audio
7198c2ecf20Sopenharmony_ciproblems.
7208c2ecf20Sopenharmony_ci
7218c2ecf20Sopenharmony_cialsa-info
7228c2ecf20Sopenharmony_ci---------
7238c2ecf20Sopenharmony_ciThe script ``alsa-info.sh`` is a very useful tool to gather the audio
7248c2ecf20Sopenharmony_cidevice information.  It's included in alsa-utils package.  The latest
7258c2ecf20Sopenharmony_civersion can be found on git repository:
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_ci* git://git.alsa-project.org/alsa-utils.git
7288c2ecf20Sopenharmony_ci
7298c2ecf20Sopenharmony_ciThe script can be fetched directly from the following URL, too:
7308c2ecf20Sopenharmony_ci
7318c2ecf20Sopenharmony_ci* https://www.alsa-project.org/alsa-info.sh
7328c2ecf20Sopenharmony_ci
7338c2ecf20Sopenharmony_ciRun this script as root, and it will gather the important information
7348c2ecf20Sopenharmony_cisuch as the module lists, module parameters, proc file contents
7358c2ecf20Sopenharmony_ciincluding the codec proc files, mixer outputs and the control
7368c2ecf20Sopenharmony_cielements.  As default, it will store the information onto a web server
7378c2ecf20Sopenharmony_cion alsa-project.org.  But, if you send a bug report, it'd be better to
7388c2ecf20Sopenharmony_cirun with ``--no-upload`` option, and attach the generated file.
7398c2ecf20Sopenharmony_ci
7408c2ecf20Sopenharmony_ciThere are some other useful options.  See ``--help`` option output for
7418c2ecf20Sopenharmony_cidetails.
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_ciWhen a probe error occurs or when the driver obviously assigns a
7448c2ecf20Sopenharmony_cimismatched model, it'd be helpful to load the driver with
7458c2ecf20Sopenharmony_ci``probe_only=1`` option (at best after the cold reboot) and run
7468c2ecf20Sopenharmony_cialsa-info at this state.  With this option, the driver won't configure
7478c2ecf20Sopenharmony_cithe mixer and PCM but just tries to probe the codec slot.  After
7488c2ecf20Sopenharmony_ciprobing, the proc file is available, so you can get the raw codec
7498c2ecf20Sopenharmony_ciinformation before modified by the driver.  Of course, the driver
7508c2ecf20Sopenharmony_ciisn't usable with ``probe_only=1``.  But you can continue the
7518c2ecf20Sopenharmony_ciconfiguration via hwdep sysfs file if hda-reconfig option is enabled.
7528c2ecf20Sopenharmony_ciUsing ``probe_only`` mask 2 skips the reset of HDA codecs (use
7538c2ecf20Sopenharmony_ci``probe_only=3`` as module option). The hwdep interface can be used
7548c2ecf20Sopenharmony_cito determine the BIOS codec initialization.
7558c2ecf20Sopenharmony_ci
7568c2ecf20Sopenharmony_ci
7578c2ecf20Sopenharmony_cihda-verb
7588c2ecf20Sopenharmony_ci--------
7598c2ecf20Sopenharmony_cihda-verb is a tiny program that allows you to access the HD-audio
7608c2ecf20Sopenharmony_cicodec directly.  You can execute a raw HD-audio codec verb with this.
7618c2ecf20Sopenharmony_ciThis program accesses the hwdep device, thus you need to enable the
7628c2ecf20Sopenharmony_cikernel config ``CONFIG_SND_HDA_HWDEP=y`` beforehand.
7638c2ecf20Sopenharmony_ci
7648c2ecf20Sopenharmony_ciThe hda-verb program takes four arguments: the hwdep device file, the
7658c2ecf20Sopenharmony_ciwidget NID, the verb and the parameter.  When you access to the codec
7668c2ecf20Sopenharmony_cion the slot 2 of the card 0, pass /dev/snd/hwC0D2 to the first
7678c2ecf20Sopenharmony_ciargument, typically.  (However, the real path name depends on the
7688c2ecf20Sopenharmony_cisystem.)
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ciThe second parameter is the widget number-id to access.  The third
7718c2ecf20Sopenharmony_ciparameter can be either a hex/digit number or a string corresponding
7728c2ecf20Sopenharmony_cito a verb.  Similarly, the last parameter is the value to write, or
7738c2ecf20Sopenharmony_cican be a string for the parameter type.
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ci::
7768c2ecf20Sopenharmony_ci
7778c2ecf20Sopenharmony_ci    % hda-verb /dev/snd/hwC0D0 0x12 0x701 2
7788c2ecf20Sopenharmony_ci    nid = 0x12, verb = 0x701, param = 0x2
7798c2ecf20Sopenharmony_ci    value = 0x0
7808c2ecf20Sopenharmony_ci
7818c2ecf20Sopenharmony_ci    % hda-verb /dev/snd/hwC0D0 0x0 PARAMETERS VENDOR_ID
7828c2ecf20Sopenharmony_ci    nid = 0x0, verb = 0xf00, param = 0x0
7838c2ecf20Sopenharmony_ci    value = 0x10ec0262
7848c2ecf20Sopenharmony_ci
7858c2ecf20Sopenharmony_ci    % hda-verb /dev/snd/hwC0D0 2 set_a 0xb080
7868c2ecf20Sopenharmony_ci    nid = 0x2, verb = 0x300, param = 0xb080
7878c2ecf20Sopenharmony_ci    value = 0x0
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_ciAlthough you can issue any verbs with this program, the driver state
7918c2ecf20Sopenharmony_ciwon't be always updated.  For example, the volume values are usually
7928c2ecf20Sopenharmony_cicached in the driver, and thus changing the widget amp value directly
7938c2ecf20Sopenharmony_civia hda-verb won't change the mixer value.
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ciThe hda-verb program is included now in alsa-tools:
7968c2ecf20Sopenharmony_ci
7978c2ecf20Sopenharmony_ci* git://git.alsa-project.org/alsa-tools.git
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_ciAlso, the old stand-alone package is found in the ftp directory:
8008c2ecf20Sopenharmony_ci
8018c2ecf20Sopenharmony_ci* ftp://ftp.suse.com/pub/people/tiwai/misc/
8028c2ecf20Sopenharmony_ci
8038c2ecf20Sopenharmony_ciAlso a git repository is available:
8048c2ecf20Sopenharmony_ci
8058c2ecf20Sopenharmony_ci* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-verb.git
8068c2ecf20Sopenharmony_ci
8078c2ecf20Sopenharmony_ciSee README file in the tarball for more details about hda-verb
8088c2ecf20Sopenharmony_ciprogram.
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ci
8118c2ecf20Sopenharmony_cihda-analyzer
8128c2ecf20Sopenharmony_ci------------
8138c2ecf20Sopenharmony_cihda-analyzer provides a graphical interface to access the raw HD-audio
8148c2ecf20Sopenharmony_cicontrol, based on pyGTK2 binding.  It's a more powerful version of
8158c2ecf20Sopenharmony_cihda-verb.  The program gives you an easy-to-use GUI stuff for showing
8168c2ecf20Sopenharmony_cithe widget information and adjusting the amp values, as well as the
8178c2ecf20Sopenharmony_ciproc-compatible output.
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ciThe hda-analyzer:
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_ci* https://git.alsa-project.org/?p=alsa.git;a=tree;f=hda-analyzer
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ciis a part of alsa.git repository in alsa-project.org:
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci* git://git.alsa-project.org/alsa.git
8268c2ecf20Sopenharmony_ci
8278c2ecf20Sopenharmony_ciCodecgraph
8288c2ecf20Sopenharmony_ci----------
8298c2ecf20Sopenharmony_ciCodecgraph is a utility program to generate a graph and visualizes the
8308c2ecf20Sopenharmony_cicodec-node connection of a codec chip.  It's especially useful when
8318c2ecf20Sopenharmony_ciyou analyze or debug a codec without a proper datasheet.  The program
8328c2ecf20Sopenharmony_ciparses the given codec proc file and converts to SVG via graphiz
8338c2ecf20Sopenharmony_ciprogram.
8348c2ecf20Sopenharmony_ci
8358c2ecf20Sopenharmony_ciThe tarball and GIT trees are found in the web page at:
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ci* http://helllabs.org/codecgraph/
8388c2ecf20Sopenharmony_ci
8398c2ecf20Sopenharmony_ci
8408c2ecf20Sopenharmony_cihda-emu
8418c2ecf20Sopenharmony_ci-------
8428c2ecf20Sopenharmony_cihda-emu is an HD-audio emulator.  The main purpose of this program is
8438c2ecf20Sopenharmony_cito debug an HD-audio codec without the real hardware.  Thus, it
8448c2ecf20Sopenharmony_cidoesn't emulate the behavior with the real audio I/O, but it just
8458c2ecf20Sopenharmony_cidumps the codec register changes and the ALSA-driver internal changes
8468c2ecf20Sopenharmony_ciat probing and operating the HD-audio driver.
8478c2ecf20Sopenharmony_ci
8488c2ecf20Sopenharmony_ciThe program requires a codec proc-file to simulate.  Get a proc file
8498c2ecf20Sopenharmony_cifor the target codec beforehand, or pick up an example codec from the
8508c2ecf20Sopenharmony_cicodec proc collections in the tarball.  Then, run the program with the
8518c2ecf20Sopenharmony_ciproc file, and the hda-emu program will start parsing the codec file
8528c2ecf20Sopenharmony_ciand simulates the HD-audio driver:
8538c2ecf20Sopenharmony_ci
8548c2ecf20Sopenharmony_ci::
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_ci    % hda-emu codecs/stac9200-dell-d820-laptop
8578c2ecf20Sopenharmony_ci    # Parsing..
8588c2ecf20Sopenharmony_ci    hda_codec: Unknown model for STAC9200, using BIOS defaults
8598c2ecf20Sopenharmony_ci    hda_codec: pin nid 08 bios pin config 40c003fa
8608c2ecf20Sopenharmony_ci    ....
8618c2ecf20Sopenharmony_ci
8628c2ecf20Sopenharmony_ci
8638c2ecf20Sopenharmony_ciThe program gives you only a very dumb command-line interface.  You
8648c2ecf20Sopenharmony_cican get a proc-file dump at the current state, get a list of control
8658c2ecf20Sopenharmony_ci(mixer) elements, set/get the control element value, simulate the PCM
8668c2ecf20Sopenharmony_cioperation, the jack plugging simulation, etc.
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_ciThe program is found in the git repository below:
8698c2ecf20Sopenharmony_ci
8708c2ecf20Sopenharmony_ci* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git
8718c2ecf20Sopenharmony_ci
8728c2ecf20Sopenharmony_ciSee README file in the repository for more details about hda-emu
8738c2ecf20Sopenharmony_ciprogram.
8748c2ecf20Sopenharmony_ci
8758c2ecf20Sopenharmony_ci
8768c2ecf20Sopenharmony_cihda-jack-retask
8778c2ecf20Sopenharmony_ci---------------
8788c2ecf20Sopenharmony_cihda-jack-retask is a user-friendly GUI program to manipulate the
8798c2ecf20Sopenharmony_ciHD-audio pin control for jack retasking.  If you have a problem about
8808c2ecf20Sopenharmony_cithe jack assignment, try this program and check whether you can get
8818c2ecf20Sopenharmony_ciuseful results.  Once when you figure out the proper pin assignment,
8828c2ecf20Sopenharmony_ciit can be fixed either in the driver code statically or via passing a
8838c2ecf20Sopenharmony_cifirmware patch file (see "Early Patching" section).
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_ciThe program is included in alsa-tools now:
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_ci* git://git.alsa-project.org/alsa-tools.git
888