notes.rst 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. =============================
  2. More Notes on HD-Audio Driver
  3. =============================
  4. Takashi Iwai <[email protected]>
  5. General
  6. =======
  7. HD-audio is the new standard on-board audio component on modern PCs
  8. after AC97. Although Linux has been supporting HD-audio since long
  9. time ago, there are often problems with new machines. A part of the
  10. problem is broken BIOS, and the rest is the driver implementation.
  11. This document explains the brief trouble-shooting and debugging
  12. methods for the HD-audio hardware.
  13. The HD-audio component consists of two parts: the controller chip and
  14. the codec chips on the HD-audio bus. Linux provides a single driver
  15. for all controllers, snd-hda-intel. Although the driver name contains
  16. a word of a well-known hardware vendor, it's not specific to it but for
  17. all controller chips by other companies. Since the HD-audio
  18. controllers are supposed to be compatible, the single snd-hda-driver
  19. should work in most cases. But, not surprisingly, there are known
  20. bugs and issues specific to each controller type. The snd-hda-intel
  21. driver has a bunch of workarounds for these as described below.
  22. A controller may have multiple codecs. Usually you have one audio
  23. codec and optionally one modem codec. In theory, there might be
  24. multiple audio codecs, e.g. for analog and digital outputs, and the
  25. driver might not work properly because of conflict of mixer elements.
  26. This should be fixed in future if such hardware really exists.
  27. The snd-hda-intel driver has several different codec parsers depending
  28. on the codec. It has a generic parser as a fallback, but this
  29. functionality is fairly limited until now. Instead of the generic
  30. parser, usually the codec-specific parser (coded in patch_*.c) is used
  31. for the codec-specific implementations. The details about the
  32. codec-specific problems are explained in the later sections.
  33. If you are interested in the deep debugging of HD-audio, read the
  34. HD-audio specification at first. The specification is found on
  35. Intel's web page, for example:
  36. * https://www.intel.com/standards/hdaudio/
  37. HD-Audio Controller
  38. ===================
  39. DMA-Position Problem
  40. --------------------
  41. The most common problem of the controller is the inaccurate DMA
  42. pointer reporting. The DMA pointer for playback and capture can be
  43. read in two ways, either via a LPIB register or via a position-buffer
  44. map. As default the driver tries to read from the io-mapped
  45. position-buffer, and falls back to LPIB if the position-buffer appears
  46. dead. However, this detection isn't perfect on some devices. In such
  47. a case, you can change the default method via ``position_fix`` option.
  48. ``position_fix=1`` means to use LPIB method explicitly.
  49. ``position_fix=2`` means to use the position-buffer.
  50. ``position_fix=3`` means to use a combination of both methods, needed
  51. for some VIA controllers. The capture stream position is corrected
  52. by comparing both LPIB and position-buffer values.
  53. ``position_fix=4`` is another combination available for all controllers,
  54. and uses LPIB for the playback and the position-buffer for the capture
  55. streams.
  56. ``position_fix=5`` is specific to Intel platforms, so far, for Skylake
  57. and onward. It applies the delay calculation for the precise position
  58. reporting.
  59. ``position_fix=6`` is to correct the position with the fixed FIFO
  60. size, mainly targeted for the recent AMD controllers.
  61. 0 is the default value for all other
  62. controllers, the automatic check and fallback to LPIB as described in
  63. the above. If you get a problem of repeated sounds, this option might
  64. help.
  65. In addition to that, every controller is known to be broken regarding
  66. the wake-up timing. It wakes up a few samples before actually
  67. processing the data on the buffer. This caused a lot of problems, for
  68. example, with ALSA dmix or JACK. Since 2.6.27 kernel, the driver puts
  69. an artificial delay to the wake up timing. This delay is controlled
  70. via ``bdl_pos_adj`` option.
  71. When ``bdl_pos_adj`` is a negative value (as default), it's assigned to
  72. an appropriate value depending on the controller chip. For Intel
  73. chips, it'd be 1 while it'd be 32 for others. Usually this works.
  74. Only in case it doesn't work and you get warning messages, you should
  75. change this parameter to other values.
  76. Codec-Probing Problem
  77. ---------------------
  78. A less often but a more severe problem is the codec probing. When
  79. BIOS reports the available codec slots wrongly, the driver gets
  80. confused and tries to access the non-existing codec slot. This often
  81. results in the total screw-up, and destructs the further communication
  82. with the codec chips. The symptom appears usually as error messages
  83. like:
  84. ::
  85. hda_intel: azx_get_response timeout, switching to polling mode:
  86. last cmd=0x12345678
  87. hda_intel: azx_get_response timeout, switching to single_cmd mode:
  88. last cmd=0x12345678
  89. The first line is a warning, and this is usually relatively harmless.
  90. It means that the codec response isn't notified via an IRQ. The
  91. driver uses explicit polling method to read the response. It gives
  92. very slight CPU overhead, but you'd unlikely notice it.
  93. The second line is, however, a fatal error. If this happens, usually
  94. it means that something is really wrong. Most likely you are
  95. accessing a non-existing codec slot.
  96. Thus, if the second error message appears, try to narrow the probed
  97. codec slots via ``probe_mask`` option. It's a bitmask, and each bit
  98. corresponds to the codec slot. For example, to probe only the first
  99. slot, pass ``probe_mask=1``. For the first and the third slots, pass
  100. ``probe_mask=5`` (where 5 = 1 | 4), and so on.
  101. Since 2.6.29 kernel, the driver has a more robust probing method, so
  102. this error might happen rarely, though.
  103. On a machine with a broken BIOS, sometimes you need to force the
  104. driver to probe the codec slots the hardware doesn't report for use.
  105. In such a case, turn the bit 8 (0x100) of ``probe_mask`` option on.
  106. Then the rest 8 bits are passed as the codec slots to probe
  107. unconditionally. For example, ``probe_mask=0x103`` will force to probe
  108. the codec slots 0 and 1 no matter what the hardware reports.
  109. Interrupt Handling
  110. ------------------
  111. HD-audio driver uses MSI as default (if available) since 2.6.33
  112. kernel as MSI works better on some machines, and in general, it's
  113. better for performance. However, Nvidia controllers showed bad
  114. regressions with MSI (especially in a combination with AMD chipset),
  115. thus we disabled MSI for them.
  116. There seem also still other devices that don't work with MSI. If you
  117. see a regression wrt the sound quality (stuttering, etc) or a lock-up
  118. in the recent kernel, try to pass ``enable_msi=0`` option to disable
  119. MSI. If it works, you can add the known bad device to the blacklist
  120. defined in hda_intel.c. In such a case, please report and give the
  121. patch back to the upstream developer.
  122. HD-Audio Codec
  123. ==============
  124. Model Option
  125. ------------
  126. The most common problem regarding the HD-audio driver is the
  127. unsupported codec features or the mismatched device configuration.
  128. Most of codec-specific code has several preset models, either to
  129. override the BIOS setup or to provide more comprehensive features.
  130. The driver checks PCI SSID and looks through the static configuration
  131. table until any matching entry is found. If you have a new machine,
  132. you may see a message like below:
  133. ::
  134. hda_codec: ALC880: BIOS auto-probing.
  135. Meanwhile, in the earlier versions, you would see a message like:
  136. ::
  137. hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...
  138. Even if you see such a message, DON'T PANIC. Take a deep breath and
  139. keep your towel. First of all, it's an informational message, no
  140. warning, no error. This means that the PCI SSID of your device isn't
  141. listed in the known preset model (white-)list. But, this doesn't mean
  142. that the driver is broken. Many codec-drivers provide the automatic
  143. configuration mechanism based on the BIOS setup.
  144. The HD-audio codec has usually "pin" widgets, and BIOS sets the default
  145. configuration of each pin, which indicates the location, the
  146. connection type, the jack color, etc. The HD-audio driver can guess
  147. the right connection judging from these default configuration values.
  148. However -- some codec-support codes, such as patch_analog.c, don't
  149. support the automatic probing (yet as of 2.6.28). And, BIOS is often,
  150. yes, pretty often broken. It sets up wrong values and screws up the
  151. driver.
  152. The preset model (or recently called as "fix-up") is provided
  153. basically to overcome such a situation. When the matching preset
  154. model is found in the white-list, the driver assumes the static
  155. configuration of that preset with the correct pin setup, etc.
  156. Thus, if you have a newer machine with a slightly different PCI SSID
  157. (or codec SSID) from the existing one, you may have a good chance to
  158. re-use the same model. You can pass the ``model`` option to specify the
  159. preset model instead of PCI (and codec-) SSID look-up.
  160. What ``model`` option values are available depends on the codec chip.
  161. Check your codec chip from the codec proc file (see "Codec Proc-File"
  162. section below). It will show the vendor/product name of your codec
  163. chip. Then, see Documentation/sound/hd-audio/models.rst file,
  164. the section of HD-audio driver. You can find a list of codecs
  165. and ``model`` options belonging to each codec. For example, for Realtek
  166. ALC262 codec chip, pass ``model=ultra`` for devices that are compatible
  167. with Samsung Q1 Ultra.
  168. Thus, the first thing you can do for any brand-new, unsupported and
  169. non-working HD-audio hardware is to check HD-audio codec and several
  170. different ``model`` option values. If you have any luck, some of them
  171. might suit with your device well.
  172. There are a few special model option values:
  173. * when 'nofixup' is passed, the device-specific fixups in the codec
  174. parser are skipped.
  175. * when ``generic`` is passed, the codec-specific parser is skipped and
  176. only the generic parser is used.
  177. A new style for the model option that was introduced since 5.15 kernel
  178. is to pass the PCI or codec SSID in the form of ``model=XXXX:YYYY``
  179. where XXXX and YYYY are the sub-vendor and sub-device IDs in hex
  180. numbers, respectively. This is a kind of aliasing to another device;
  181. when this form is given, the driver will refer to that SSID as a
  182. reference to the quirk table. It'd be useful especially when the
  183. target quirk isn't listed in the model table. For example, passing
  184. model=103c:8862 will apply the quirk for HP ProBook 445 G8 (which
  185. isn't found in the model table as of writing) as long as the device is
  186. handled equivalently by the same driver.
  187. Speaker and Headphone Output
  188. ----------------------------
  189. One of the most frequent (and obvious) bugs with HD-audio is the
  190. silent output from either or both of a built-in speaker and a
  191. headphone jack. In general, you should try a headphone output at
  192. first. A speaker output often requires more additional controls like
  193. the external amplifier bits. Thus a headphone output has a slightly
  194. better chance.
  195. Before making a bug report, double-check whether the mixer is set up
  196. correctly. The recent version of snd-hda-intel driver provides mostly
  197. "Master" volume control as well as "Front" volume (where Front
  198. indicates the front-channels). In addition, there can be individual
  199. "Headphone" and "Speaker" controls.
  200. Ditto for the speaker output. There can be "External Amplifier"
  201. switch on some codecs. Turn on this if present.
  202. Another related problem is the automatic mute of speaker output by
  203. headphone plugging. This feature is implemented in most cases, but
  204. not on every preset model or codec-support code.
  205. In anyway, try a different model option if you have such a problem.
  206. Some other models may match better and give you more matching
  207. functionality. If none of the available models works, send a bug
  208. report. See the bug report section for details.
  209. If you are masochistic enough to debug the driver problem, note the
  210. following:
  211. * The speaker (and the headphone, too) output often requires the
  212. external amplifier. This can be set usually via EAPD verb or a
  213. certain GPIO. If the codec pin supports EAPD, you have a better
  214. chance via SET_EAPD_BTL verb (0x70c). On others, GPIO pin (mostly
  215. it's either GPIO0 or GPIO1) may turn on/off EAPD.
  216. * Some Realtek codecs require special vendor-specific coefficients to
  217. turn on the amplifier. See patch_realtek.c.
  218. * IDT codecs may have extra power-enable/disable controls on each
  219. analog pin. See patch_sigmatel.c.
  220. * Very rare but some devices don't accept the pin-detection verb until
  221. triggered. Issuing GET_PIN_SENSE verb (0xf09) may result in the
  222. codec-communication stall. Some examples are found in
  223. patch_realtek.c.
  224. Capture Problems
  225. ----------------
  226. The capture problems are often because of missing setups of mixers.
  227. Thus, before submitting a bug report, make sure that you set up the
  228. mixer correctly. For example, both "Capture Volume" and "Capture
  229. Switch" have to be set properly in addition to the right "Capture
  230. Source" or "Input Source" selection. Some devices have "Mic Boost"
  231. volume or switch.
  232. When the PCM device is opened via "default" PCM (without pulse-audio
  233. plugin), you'll likely have "Digital Capture Volume" control as well.
  234. This is provided for the extra gain/attenuation of the signal in
  235. software, especially for the inputs without the hardware volume
  236. control such as digital microphones. Unless really needed, this
  237. should be set to exactly 50%, corresponding to 0dB -- neither extra
  238. gain nor attenuation. When you use "hw" PCM, i.e., a raw access PCM,
  239. this control will have no influence, though.
  240. It's known that some codecs / devices have fairly bad analog circuits,
  241. and the recorded sound contains a certain DC-offset. This is no bug
  242. of the driver.
  243. Most of modern laptops have no analog CD-input connection. Thus, the
  244. recording from CD input won't work in many cases although the driver
  245. provides it as the capture source. Use CDDA instead.
  246. The automatic switching of the built-in and external mic per plugging
  247. is implemented on some codec models but not on every model. Partly
  248. because of my laziness but mostly lack of testers. Feel free to
  249. submit the improvement patch to the author.
  250. Direct Debugging
  251. ----------------
  252. If no model option gives you a better result, and you are a tough guy
  253. to fight against evil, try debugging via hitting the raw HD-audio
  254. codec verbs to the device. Some tools are available: hda-emu and
  255. hda-analyzer. The detailed description is found in the sections
  256. below. You'd need to enable hwdep for using these tools. See "Kernel
  257. Configuration" section.
  258. Other Issues
  259. ============
  260. Kernel Configuration
  261. --------------------
  262. In general, I recommend you to enable the sound debug option,
  263. ``CONFIG_SND_DEBUG=y``, no matter whether you are debugging or not.
  264. This enables snd_printd() macro and others, and you'll get additional
  265. kernel messages at probing.
  266. In addition, you can enable ``CONFIG_SND_DEBUG_VERBOSE=y``. But this
  267. will give you far more messages. Thus turn this on only when you are
  268. sure to want it.
  269. Don't forget to turn on the appropriate ``CONFIG_SND_HDA_CODEC_*``
  270. options. Note that each of them corresponds to the codec chip, not
  271. the controller chip. Thus, even if lspci shows the Nvidia controller,
  272. you may need to choose the option for other vendors. If you are
  273. unsure, just select all yes.
  274. ``CONFIG_SND_HDA_HWDEP`` is a useful option for debugging the driver.
  275. When this is enabled, the driver creates hardware-dependent devices
  276. (one per each codec), and you have a raw access to the device via
  277. these device files. For example, ``hwC0D2`` will be created for the
  278. codec slot #2 of the first card (#0). For debug-tools such as
  279. hda-verb and hda-analyzer, the hwdep device has to be enabled.
  280. Thus, it'd be better to turn this on always.
  281. ``CONFIG_SND_HDA_RECONFIG`` is a new option, and this depends on the
  282. hwdep option above. When enabled, you'll have some sysfs files under
  283. the corresponding hwdep directory. See "HD-audio reconfiguration"
  284. section below.
  285. ``CONFIG_SND_HDA_POWER_SAVE`` option enables the power-saving feature.
  286. See "Power-saving" section below.
  287. Codec Proc-File
  288. ---------------
  289. The codec proc-file is a treasure-chest for debugging HD-audio.
  290. It shows most of useful information of each codec widget.
  291. The proc file is located in /proc/asound/card*/codec#*, one file per
  292. each codec slot. You can know the codec vendor, product id and
  293. names, the type of each widget, capabilities and so on.
  294. This file, however, doesn't show the jack sensing state, so far. This
  295. is because the jack-sensing might be depending on the trigger state.
  296. This file will be picked up by the debug tools, and also it can be fed
  297. to the emulator as the primary codec information. See the debug tools
  298. section below.
  299. This proc file can be also used to check whether the generic parser is
  300. used. When the generic parser is used, the vendor/product ID name
  301. will appear as "Realtek ID 0262", instead of "Realtek ALC262".
  302. HD-Audio Reconfiguration
  303. ------------------------
  304. This is an experimental feature to allow you re-configure the HD-audio
  305. codec dynamically without reloading the driver. The following sysfs
  306. files are available under each codec-hwdep device directory (e.g.
  307. /sys/class/sound/hwC0D0):
  308. vendor_id
  309. Shows the 32bit codec vendor-id hex number. You can change the
  310. vendor-id value by writing to this file.
  311. subsystem_id
  312. Shows the 32bit codec subsystem-id hex number. You can change the
  313. subsystem-id value by writing to this file.
  314. revision_id
  315. Shows the 32bit codec revision-id hex number. You can change the
  316. revision-id value by writing to this file.
  317. afg
  318. Shows the AFG ID. This is read-only.
  319. mfg
  320. Shows the MFG ID. This is read-only.
  321. name
  322. Shows the codec name string. Can be changed by writing to this
  323. file.
  324. modelname
  325. Shows the currently set ``model`` option. Can be changed by writing
  326. to this file.
  327. init_verbs
  328. The extra verbs to execute at initialization. You can add a verb by
  329. writing to this file. Pass three numbers: nid, verb and parameter
  330. (separated with a space).
  331. hints
  332. Shows / stores hint strings for codec parsers for any use.
  333. Its format is ``key = value``. For example, passing ``jack_detect = no``
  334. will disable the jack detection of the machine completely.
  335. init_pin_configs
  336. Shows the initial pin default config values set by BIOS.
  337. driver_pin_configs
  338. Shows the pin default values set by the codec parser explicitly.
  339. This doesn't show all pin values but only the changed values by
  340. the parser. That is, if the parser doesn't change the pin default
  341. config values by itself, this will contain nothing.
  342. user_pin_configs
  343. Shows the pin default config values to override the BIOS setup.
  344. Writing this (with two numbers, NID and value) appends the new
  345. value. The given will be used instead of the initial BIOS value at
  346. the next reconfiguration time. Note that this config will override
  347. even the driver pin configs, too.
  348. reconfig
  349. Triggers the codec re-configuration. When any value is written to
  350. this file, the driver re-initialize and parses the codec tree
  351. again. All the changes done by the sysfs entries above are taken
  352. into account.
  353. clear
  354. Resets the codec, removes the mixer elements and PCM stuff of the
  355. specified codec, and clear all init verbs and hints.
  356. For example, when you want to change the pin default configuration
  357. value of the pin widget 0x14 to 0x9993013f, and let the driver
  358. re-configure based on that state, run like below:
  359. ::
  360. # echo 0x14 0x9993013f > /sys/class/sound/hwC0D0/user_pin_configs
  361. # echo 1 > /sys/class/sound/hwC0D0/reconfig
  362. Hint Strings
  363. ------------
  364. The codec parser have several switches and adjustment knobs for
  365. matching better with the actual codec or device behavior. Many of
  366. them can be adjusted dynamically via "hints" strings as mentioned in
  367. the section above. For example, by passing ``jack_detect = no`` string
  368. via sysfs or a patch file, you can disable the jack detection, thus
  369. the codec parser will skip the features like auto-mute or mic
  370. auto-switch. As a boolean value, either ``yes``, ``no``, ``true``, ``false``,
  371. ``1`` or ``0`` can be passed.
  372. The generic parser supports the following hints:
  373. jack_detect (bool)
  374. specify whether the jack detection is available at all on this
  375. machine; default true
  376. inv_jack_detect (bool)
  377. indicates that the jack detection logic is inverted
  378. trigger_sense (bool)
  379. indicates that the jack detection needs the explicit call of
  380. AC_VERB_SET_PIN_SENSE verb
  381. inv_eapd (bool)
  382. indicates that the EAPD is implemented in the inverted logic
  383. pcm_format_first (bool)
  384. sets the PCM format before the stream tag and channel ID
  385. sticky_stream (bool)
  386. keep the PCM format, stream tag and ID as long as possible;
  387. default true
  388. spdif_status_reset (bool)
  389. reset the SPDIF status bits at each time the SPDIF stream is set
  390. up
  391. pin_amp_workaround (bool)
  392. the output pin may have multiple amp values
  393. single_adc_amp (bool)
  394. ADCs can have only single input amps
  395. auto_mute (bool)
  396. enable/disable the headphone auto-mute feature; default true
  397. auto_mic (bool)
  398. enable/disable the mic auto-switch feature; default true
  399. line_in_auto_switch (bool)
  400. enable/disable the line-in auto-switch feature; default false
  401. need_dac_fix (bool)
  402. limits the DACs depending on the channel count
  403. primary_hp (bool)
  404. probe headphone jacks as the primary outputs; default true
  405. multi_io (bool)
  406. try probing multi-I/O config (e.g. shared line-in/surround,
  407. mic/clfe jacks)
  408. multi_cap_vol (bool)
  409. provide multiple capture volumes
  410. inv_dmic_split (bool)
  411. provide split internal mic volume/switch for phase-inverted
  412. digital mics
  413. indep_hp (bool)
  414. provide the independent headphone PCM stream and the corresponding
  415. mixer control, if available
  416. add_stereo_mix_input (bool)
  417. add the stereo mix (analog-loopback mix) to the input mux if
  418. available
  419. add_jack_modes (bool)
  420. add "xxx Jack Mode" enum controls to each I/O jack for allowing to
  421. change the headphone amp and mic bias VREF capabilities
  422. power_save_node (bool)
  423. advanced power management for each widget, controlling the power
  424. sate (D0/D3) of each widget node depending on the actual pin and
  425. stream states
  426. power_down_unused (bool)
  427. power down the unused widgets, a subset of power_save_node, and
  428. will be dropped in future
  429. add_hp_mic (bool)
  430. add the headphone to capture source if possible
  431. hp_mic_detect (bool)
  432. enable/disable the hp/mic shared input for a single built-in mic
  433. case; default true
  434. vmaster (bool)
  435. enable/disable the virtual Master control; default true
  436. mixer_nid (int)
  437. specifies the widget NID of the analog-loopback mixer
  438. Early Patching
  439. --------------
  440. When ``CONFIG_SND_HDA_PATCH_LOADER=y`` is set, you can pass a "patch"
  441. as a firmware file for modifying the HD-audio setup before
  442. initializing the codec. This can work basically like the
  443. reconfiguration via sysfs in the above, but it does it before the
  444. first codec configuration.
  445. A patch file is a plain text file which looks like below:
  446. ::
  447. [codec]
  448. 0x12345678 0xabcd1234 2
  449. [model]
  450. auto
  451. [pincfg]
  452. 0x12 0x411111f0
  453. [verb]
  454. 0x20 0x500 0x03
  455. 0x20 0x400 0xff
  456. [hint]
  457. jack_detect = no
  458. The file needs to have a line ``[codec]``. The next line should contain
  459. three numbers indicating the codec vendor-id (0x12345678 in the
  460. example), the codec subsystem-id (0xabcd1234) and the address (2) of
  461. the codec. The rest patch entries are applied to this specified codec
  462. until another codec entry is given. Passing 0 or a negative number to
  463. the first or the second value will make the check of the corresponding
  464. field be skipped. It'll be useful for really broken devices that don't
  465. initialize SSID properly.
  466. The ``[model]`` line allows to change the model name of the each codec.
  467. In the example above, it will be changed to model=auto.
  468. Note that this overrides the module option.
  469. After the ``[pincfg]`` line, the contents are parsed as the initial
  470. default pin-configurations just like ``user_pin_configs`` sysfs above.
  471. The values can be shown in user_pin_configs sysfs file, too.
  472. Similarly, the lines after ``[verb]`` are parsed as ``init_verbs``
  473. sysfs entries, and the lines after ``[hint]`` are parsed as ``hints``
  474. sysfs entries, respectively.
  475. Another example to override the codec vendor id from 0x12345678 to
  476. 0xdeadbeef is like below:
  477. ::
  478. [codec]
  479. 0x12345678 0xabcd1234 2
  480. [vendor_id]
  481. 0xdeadbeef
  482. In the similar way, you can override the codec subsystem_id via
  483. ``[subsystem_id]``, the revision id via ``[revision_id]`` line.
  484. Also, the codec chip name can be rewritten via ``[chip_name]`` line.
  485. ::
  486. [codec]
  487. 0x12345678 0xabcd1234 2
  488. [subsystem_id]
  489. 0xffff1111
  490. [revision_id]
  491. 0x10
  492. [chip_name]
  493. My-own NEWS-0002
  494. The hd-audio driver reads the file via request_firmware(). Thus,
  495. a patch file has to be located on the appropriate firmware path,
  496. typically, /lib/firmware. For example, when you pass the option
  497. ``patch=hda-init.fw``, the file /lib/firmware/hda-init.fw must be
  498. present.
  499. The patch module option is specific to each card instance, and you
  500. need to give one file name for each instance, separated by commas.
  501. For example, if you have two cards, one for an on-board analog and one
  502. for an HDMI video board, you may pass patch option like below:
  503. ::
  504. options snd-hda-intel patch=on-board-patch,hdmi-patch
  505. Power-Saving
  506. ------------
  507. The power-saving is a kind of auto-suspend of the device. When the
  508. device is inactive for a certain time, the device is automatically
  509. turned off to save the power. The time to go down is specified via
  510. ``power_save`` module option, and this option can be changed dynamically
  511. via sysfs.
  512. The power-saving won't work when the analog loopback is enabled on
  513. some codecs. Make sure that you mute all unneeded signal routes when
  514. you want the power-saving.
  515. The power-saving feature might cause audible click noises at each
  516. power-down/up depending on the device. Some of them might be
  517. solvable, but some are hard, I'm afraid. Some distros such as
  518. openSUSE enables the power-saving feature automatically when the power
  519. cable is unplugged. Thus, if you hear noises, suspect first the
  520. power-saving. See /sys/module/snd_hda_intel/parameters/power_save to
  521. check the current value. If it's non-zero, the feature is turned on.
  522. The recent kernel supports the runtime PM for the HD-audio controller
  523. chip, too. It means that the HD-audio controller is also powered up /
  524. down dynamically. The feature is enabled only for certain controller
  525. chips like Intel LynxPoint. You can enable/disable this feature
  526. forcibly by setting ``power_save_controller`` option, which is also
  527. available at /sys/module/snd_hda_intel/parameters directory.
  528. Tracepoints
  529. -----------
  530. The hd-audio driver gives a few basic tracepoints.
  531. ``hda:hda_send_cmd`` traces each CORB write while ``hda:hda_get_response``
  532. traces the response from RIRB (only when read from the codec driver).
  533. ``hda:hda_bus_reset`` traces the bus-reset due to fatal error, etc,
  534. ``hda:hda_unsol_event`` traces the unsolicited events, and
  535. ``hda:hda_power_down`` and ``hda:hda_power_up`` trace the power down/up
  536. via power-saving behavior.
  537. Enabling all tracepoints can be done like
  538. ::
  539. # echo 1 > /sys/kernel/debug/tracing/events/hda/enable
  540. then after some commands, you can traces from
  541. /sys/kernel/debug/tracing/trace file. For example, when you want to
  542. trace what codec command is sent, enable the tracepoint like:
  543. ::
  544. # cat /sys/kernel/debug/tracing/trace
  545. # tracer: nop
  546. #
  547. # TASK-PID CPU# TIMESTAMP FUNCTION
  548. # | | | | |
  549. <...>-7807 [002] 105147.774889: hda_send_cmd: [0:0] val=e3a019
  550. <...>-7807 [002] 105147.774893: hda_send_cmd: [0:0] val=e39019
  551. <...>-7807 [002] 105147.999542: hda_send_cmd: [0:0] val=e3a01a
  552. <...>-7807 [002] 105147.999543: hda_send_cmd: [0:0] val=e3901a
  553. <...>-26764 [001] 349222.837143: hda_send_cmd: [0:0] val=e3a019
  554. <...>-26764 [001] 349222.837148: hda_send_cmd: [0:0] val=e39019
  555. <...>-26764 [001] 349223.058539: hda_send_cmd: [0:0] val=e3a01a
  556. <...>-26764 [001] 349223.058541: hda_send_cmd: [0:0] val=e3901a
  557. Here ``[0:0]`` indicates the card number and the codec address, and
  558. ``val`` shows the value sent to the codec, respectively. The value is
  559. a packed value, and you can decode it via hda-decode-verb program
  560. included in hda-emu package below. For example, the value e3a019 is
  561. to set the left output-amp value to 25.
  562. ::
  563. % hda-decode-verb 0xe3a019
  564. raw value = 0x00e3a019
  565. cid = 0, nid = 0x0e, verb = 0x3a0, parm = 0x19
  566. raw value: verb = 0x3a0, parm = 0x19
  567. verbname = set_amp_gain_mute
  568. amp raw val = 0xa019
  569. output, left, idx=0, mute=0, val=25
  570. Development Tree
  571. ----------------
  572. The latest development codes for HD-audio are found on sound git tree:
  573. * git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
  574. The master branch or for-next branches can be used as the main
  575. development branches in general while the development for the current
  576. and next kernels are found in for-linus and for-next branches,
  577. respectively.
  578. Sending a Bug Report
  579. --------------------
  580. If any model or module options don't work for your device, it's time
  581. to send a bug report to the developers. Give the following in your
  582. bug report:
  583. * Hardware vendor, product and model names
  584. * Kernel version (and ALSA-driver version if you built externally)
  585. * ``alsa-info.sh`` output; run with ``--no-upload`` option. See the
  586. section below about alsa-info
  587. If it's a regression, at best, send alsa-info outputs of both working
  588. and non-working kernels. This is really helpful because we can
  589. compare the codec registers directly.
  590. Send a bug report either the following:
  591. kernel-bugzilla
  592. https://bugzilla.kernel.org/
  593. alsa-devel ML
  594. [email protected]
  595. Debug Tools
  596. ===========
  597. This section describes some tools available for debugging HD-audio
  598. problems.
  599. alsa-info
  600. ---------
  601. The script ``alsa-info.sh`` is a very useful tool to gather the audio
  602. device information. It's included in alsa-utils package. The latest
  603. version can be found on git repository:
  604. * git://git.alsa-project.org/alsa-utils.git
  605. The script can be fetched directly from the following URL, too:
  606. * https://www.alsa-project.org/alsa-info.sh
  607. Run this script as root, and it will gather the important information
  608. such as the module lists, module parameters, proc file contents
  609. including the codec proc files, mixer outputs and the control
  610. elements. As default, it will store the information onto a web server
  611. on alsa-project.org. But, if you send a bug report, it'd be better to
  612. run with ``--no-upload`` option, and attach the generated file.
  613. There are some other useful options. See ``--help`` option output for
  614. details.
  615. When a probe error occurs or when the driver obviously assigns a
  616. mismatched model, it'd be helpful to load the driver with
  617. ``probe_only=1`` option (at best after the cold reboot) and run
  618. alsa-info at this state. With this option, the driver won't configure
  619. the mixer and PCM but just tries to probe the codec slot. After
  620. probing, the proc file is available, so you can get the raw codec
  621. information before modified by the driver. Of course, the driver
  622. isn't usable with ``probe_only=1``. But you can continue the
  623. configuration via hwdep sysfs file if hda-reconfig option is enabled.
  624. Using ``probe_only`` mask 2 skips the reset of HDA codecs (use
  625. ``probe_only=3`` as module option). The hwdep interface can be used
  626. to determine the BIOS codec initialization.
  627. hda-verb
  628. --------
  629. hda-verb is a tiny program that allows you to access the HD-audio
  630. codec directly. You can execute a raw HD-audio codec verb with this.
  631. This program accesses the hwdep device, thus you need to enable the
  632. kernel config ``CONFIG_SND_HDA_HWDEP=y`` beforehand.
  633. The hda-verb program takes four arguments: the hwdep device file, the
  634. widget NID, the verb and the parameter. When you access to the codec
  635. on the slot 2 of the card 0, pass /dev/snd/hwC0D2 to the first
  636. argument, typically. (However, the real path name depends on the
  637. system.)
  638. The second parameter is the widget number-id to access. The third
  639. parameter can be either a hex/digit number or a string corresponding
  640. to a verb. Similarly, the last parameter is the value to write, or
  641. can be a string for the parameter type.
  642. ::
  643. % hda-verb /dev/snd/hwC0D0 0x12 0x701 2
  644. nid = 0x12, verb = 0x701, param = 0x2
  645. value = 0x0
  646. % hda-verb /dev/snd/hwC0D0 0x0 PARAMETERS VENDOR_ID
  647. nid = 0x0, verb = 0xf00, param = 0x0
  648. value = 0x10ec0262
  649. % hda-verb /dev/snd/hwC0D0 2 set_a 0xb080
  650. nid = 0x2, verb = 0x300, param = 0xb080
  651. value = 0x0
  652. Although you can issue any verbs with this program, the driver state
  653. won't be always updated. For example, the volume values are usually
  654. cached in the driver, and thus changing the widget amp value directly
  655. via hda-verb won't change the mixer value.
  656. The hda-verb program is included now in alsa-tools:
  657. * git://git.alsa-project.org/alsa-tools.git
  658. Also, the old stand-alone package is found in the ftp directory:
  659. * ftp://ftp.suse.com/pub/people/tiwai/misc/
  660. Also a git repository is available:
  661. * git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-verb.git
  662. See README file in the tarball for more details about hda-verb
  663. program.
  664. hda-analyzer
  665. ------------
  666. hda-analyzer provides a graphical interface to access the raw HD-audio
  667. control, based on pyGTK2 binding. It's a more powerful version of
  668. hda-verb. The program gives you an easy-to-use GUI stuff for showing
  669. the widget information and adjusting the amp values, as well as the
  670. proc-compatible output.
  671. The hda-analyzer:
  672. * https://git.alsa-project.org/?p=alsa.git;a=tree;f=hda-analyzer
  673. is a part of alsa.git repository in alsa-project.org:
  674. * git://git.alsa-project.org/alsa.git
  675. Codecgraph
  676. ----------
  677. Codecgraph is a utility program to generate a graph and visualizes the
  678. codec-node connection of a codec chip. It's especially useful when
  679. you analyze or debug a codec without a proper datasheet. The program
  680. parses the given codec proc file and converts to SVG via graphiz
  681. program.
  682. The tarball and GIT trees are found in the web page at:
  683. * http://helllabs.org/codecgraph/
  684. hda-emu
  685. -------
  686. hda-emu is an HD-audio emulator. The main purpose of this program is
  687. to debug an HD-audio codec without the real hardware. Thus, it
  688. doesn't emulate the behavior with the real audio I/O, but it just
  689. dumps the codec register changes and the ALSA-driver internal changes
  690. at probing and operating the HD-audio driver.
  691. The program requires a codec proc-file to simulate. Get a proc file
  692. for the target codec beforehand, or pick up an example codec from the
  693. codec proc collections in the tarball. Then, run the program with the
  694. proc file, and the hda-emu program will start parsing the codec file
  695. and simulates the HD-audio driver:
  696. ::
  697. % hda-emu codecs/stac9200-dell-d820-laptop
  698. # Parsing..
  699. hda_codec: Unknown model for STAC9200, using BIOS defaults
  700. hda_codec: pin nid 08 bios pin config 40c003fa
  701. ....
  702. The program gives you only a very dumb command-line interface. You
  703. can get a proc-file dump at the current state, get a list of control
  704. (mixer) elements, set/get the control element value, simulate the PCM
  705. operation, the jack plugging simulation, etc.
  706. The program is found in the git repository below:
  707. * git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git
  708. See README file in the repository for more details about hda-emu
  709. program.
  710. hda-jack-retask
  711. ---------------
  712. hda-jack-retask is a user-friendly GUI program to manipulate the
  713. HD-audio pin control for jack retasking. If you have a problem about
  714. the jack assignment, try this program and check whether you can get
  715. useful results. Once when you figure out the proper pin assignment,
  716. it can be fixed either in the driver code statically or via passing a
  717. firmware patch file (see "Early Patching" section).
  718. The program is included in alsa-tools now:
  719. * git://git.alsa-project.org/alsa-tools.git