1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
| The codec proc-file is a treasure-chest for debugging HD-audio. It shows most of useful information of each codec widget.
The proc file is located in /proc/asound/card*/codec#*, one file per each codec slot. You can know the codec vendor, product id and names, the type of each widget, capabilities and so on. This file, however, doesn't show the jack sensing state, so far. This is because the jack-sensing might be depending on the trigger state.
This file will be picked up by the debug tools, and also it can be fed to the emulator as the primary codec information. See the debug tools section below.
This proc file can be also used to check whether the generic parser is used. When the generic parser is used, the vendor/product ID name will appear as "Realtek ID 0262", instead of "Realtek ALC262".
HD-Audio Reconfiguration ~~~~~~~~~~~~~~~~~~~~~~~~ This is an experimental feature to allow you re-configure the HD-audio codec dynamically without reloading the driver. The following sysfs files are available under each codec-hwdep device directory (e.g. /sys/class/sound/hwC0D0):
vendor_id:: Shows the 32bit codec vendor-id hex number. You can change the vendor-id value by writing to this file. subsystem_id:: Shows the 32bit codec subsystem-id hex number. You can change the subsystem-id value by writing to this file. revision_id:: Shows the 32bit codec revision-id hex number. You can change the revision-id value by writing to this file. afg:: Shows the AFG ID. This is read-only. mfg:: Shows the MFG ID. This is read-only. name:: Shows the codec name string. Can be changed by writing to this file. modelname:: Shows the currently set `model` option. Can be changed by writing to this file. init_verbs:: The extra verbs to execute at initialization. You can add a verb by writing to this file. Pass three numbers: nid, verb and parameter (separated with a space). hints:: Shows / stores hint strings for codec parsers for any use. Its format is `key = value`. For example, passing `jack_detect = no` will disable the jack detection of the machine completely. init_pin_configs:: Shows the initial pin default config values set by BIOS. driver_pin_configs:: Shows the pin default values set by the codec parser explicitly. This doesn't show all pin values but only the changed values by the parser. That is, if the parser doesn't change the pin default config values by itself, this will contain nothing. user_pin_configs:: Shows the pin default config values to override the BIOS setup. Writing this (with two numbers, NID and value) appends the new value. The given will be used instead of the initial BIOS value at the next reconfiguration time. Note that this config will override even the driver pin configs, too. reconfig:: Triggers the codec re-configuration. When any value is written to this file, the driver re-initialize and parses the codec tree again. All the changes done by the sysfs entries above are taken into account. clear:: Resets the codec, removes the mixer elements and PCM stuff of the specified codec, and clear all init verbs and hints.
For example, when you want to change the pin default configuration value of the pin widget 0x14 to 0x9993013f, and let the driver re-configure based on that state, run like below: ------------------------------------------------------------------------ # echo 0x14 0x9993013f > /sys/class/sound/hwC0D0/user_pin_configs # echo 1 > /sys/class/sound/hwC0D0/reconfig ------------------------------------------------------------------------
Hint Strings ~~~~~~~~~~~~ The codec parser have several switches and adjustment knobs for matching better with the actual codec or device behavior. Many of them can be adjusted dynamically via "hints" strings as mentioned in the section above. For example, by passing `jack_detect = no` string via sysfs or a patch file, you can disable the jack detection, thus the codec parser will skip the features like auto-mute or mic auto-switch. As a boolean value, either `yes`, `no`, `true`, `false`, `1` or `0` can be passed.
The generic parser supports the following hints:
- jack_detect (bool): specify whether the jack detection is available at all on this machine; default true - inv_jack_detect (bool): indicates that the jack detection logic is inverted - trigger_sense (bool): indicates that the jack detection needs the explicit call of AC_VERB_SET_PIN_SENSE verb - inv_eapd (bool): indicates that the EAPD is implemented in the inverted logic - pcm_format_first (bool): sets the PCM format before the stream tag and channel ID - sticky_stream (bool): keep the PCM format, stream tag and ID as long as possible; default true - spdif_status_reset (bool): reset the SPDIF status bits at each time the SPDIF stream is set up - pin_amp_workaround (bool): the output pin may have multiple amp values - single_adc_amp (bool): ADCs can have only single input amps - auto_mute (bool): enable/disable the headphone auto-mute feature; default true - auto_mic (bool): enable/disable the mic auto-switch feature; default true - line_in_auto_switch (bool): enable/disable the line-in auto-switch feature; default false - need_dac_fix (bool): limits the DACs depending on the channel count - primary_hp (bool): probe headphone jacks as the primary outputs; default true - multi_io (bool): try probing multi-I/O config (e.g. shared line-in/surround, mic/clfe jacks) - multi_cap_vol (bool): provide multiple capture volumes - inv_dmic_split (bool): provide split internal mic volume/switch for phase-inverted digital mics - indep_hp (bool): provide the independent headphone PCM stream and the corresponding mixer control, if available - add_stereo_mix_input (bool): add the stereo mix (analog-loopback mix) to the input mux if available - add_jack_modes (bool): add "xxx Jack Mode" enum controls to each I/O jack for allowing to change the headphone amp and mic bias VREF capabilities - power_save_node (bool): advanced power management for each widget, controlling the power sate (D0/D3) of each widget node depending on the actual pin and stream states - power_down_unused (bool): power down the unused widgets, a subset of power_save_node, and will be dropped in future - add_hp_mic (bool): add the headphone to capture source if possible - hp_mic_detect (bool): enable/disable the hp/mic shared input for a single built-in mic case; default true - mixer_nid (int): specifies the widget NID of the analog-loopback mixer
Early Patching ~~~~~~~~~~~~~~ When CONFIG_SND_HDA_PATCH_LOADER=y is set, you can pass a "patch" as a firmware file for modifying the HD-audio setup before initializing the codec. This can work basically like the reconfiguration via sysfs in the above, but it does it before the first codec configuration.
A patch file is a plain text file which looks like below:
------------------------------------------------------------------------ [codec] 0x12345678 0xabcd1234 2
[model] auto
[pincfg] 0x12 0x411111f0
[verb] 0x20 0x500 0x03 0x20 0x400 0xff
[hint] jack_detect = no ------------------------------------------------------------------------
The file needs to have a line `[codec]`. The next line should contain three numbers indicating the codec vendor-id (0x12345678 in the example), the codec subsystem-id (0xabcd1234) and the address (2) of the codec. The rest patch entries are applied to this specified codec until another codec entry is given. Passing 0 or a negative number to the first or the second value will make the check of the corresponding field be skipped. It'll be useful for really broken devices that don't initialize SSID properly.
The `[model]` line allows to change the model name of the each codec. In the example above, it will be changed to model=auto. Note that this overrides the module option.
After the `[pincfg]` line, the contents are parsed as the initial default pin-configurations just like `user_pin_configs` sysfs above. The values can be shown in user_pin_configs sysfs file, too.
Similarly, the lines after `[verb]` are parsed as `init_verbs` sysfs entries, and the lines after `[hint]` are parsed as `hints` sysfs entries, respectively.
Another example to override the codec vendor id from 0x12345678 to 0xdeadbeef is like below: ------------------------------------------------------------------------ [codec] 0x12345678 0xabcd1234 2
[vendor_id] 0xdeadbeef ------------------------------------------------------------------------
In the similar way, you can override the codec subsystem_id via `[subsystem_id]`, the revision id via `[revision_id]` line. Also, the codec chip name can be rewritten via `[chip_name]` line. ------------------------------------------------------------------------ [codec] 0x12345678 0xabcd1234 2
[subsystem_id] 0xffff1111
[revision_id] 0x10
[chip_name] My-own NEWS-0002 ------------------------------------------------------------------------
The hd-audio driver reads the file via request_firmware(). Thus, a patch file has to be located on the appropriate firmware path, typically, /lib/firmware. For example, when you pass the option `patch=hda-init.fw`, the file /lib/firmware/hda-init.fw must be present.
The patch module option is specific to each card instance, and you need to give one file name for each instance, separated by commas. For example, if you have two cards, one for an on-board analog and one for an HDMI video board, you may pass patch option like below: ------------------------------------------------------------------------ options snd-hda-intel patch=on-board-patch,hdmi-patch ------------------------------------------------------------------------
Power-Saving ~~~~~~~~~~~~ The power-saving is a kind of auto-suspend of the device. When the device is inactive for a certain time, the device is automatically turned off to save the power. The time to go down is specified via `power_save` module option, and this option can be changed dynamically via sysfs.
The power-saving won't work when the analog loopback is enabled on some codecs. Make sure that you mute all unneeded signal routes when you want the power-saving.
The power-saving feature might cause audible click noises at each power-down/up depending on the device. Some of them might be solvable, but some are hard, I'm afraid. Some distros such as openSUSE enables the power-saving feature automatically when the power cable is unplugged. Thus, if you hear noises, suspect first the power-saving. See /sys/module/snd_hda_intel/parameters/power_save to check the current value. If it's non-zero, the feature is turned on.
The recent kernel supports the runtime PM for the HD-audio controller chip, too. It means that the HD-audio controller is also powered up / down dynamically. The feature is enabled only for certain controller chips like Intel LynxPoint. You can enable/disable this feature forcibly by setting `power_save_controller` option, which is also available at /sys/module/snd_hda_intel/parameters directory.
Tracepoints ~~~~~~~~~~~ The hd-audio driver gives a few basic tracepoints. `hda:hda_send_cmd` traces each CORB write while `hda:hda_get_response` traces the response from RIRB (only when read from the codec driver). `hda:hda_bus_reset` traces the bus-reset due to fatal error, etc, `hda:hda_unsol_event` traces the unsolicited events, and `hda:hda_power_down` and `hda:hda_power_up` trace the power down/up via power-saving behavior.
Enabling all tracepoints can be done like ------------------------------------------------------------------------ # echo 1 > /sys/kernel/debug/tracing/events/hda/enable ------------------------------------------------------------------------ then after some commands, you can traces from /sys/kernel/debug/tracing/trace file. For example, when you want to trace what codec command is sent, enable the tracepoint like: ------------------------------------------------------------------------ # cat /sys/kernel/debug/tracing/trace # tracer: nop # # TASK-PID CPU# TIMESTAMP FUNCTION # | | | | | <...>-7807 [002] 105147.774889: hda_send_cmd: [0:0] val=e3a019 <...>-7807 [002] 105147.774893: hda_send_cmd: [0:0] val=e39019 <...>-7807 [002] 105147.999542: hda_send_cmd: [0:0] val=e3a01a <...>-7807 [002] 105147.999543: hda_send_cmd: [0:0] val=e3901a <...>-26764 [001] 349222.837143: hda_send_cmd: [0:0] val=e3a019 <...>-26764 [001] 349222.837148: hda_send_cmd: [0:0] val=e39019 <...>-26764 [001] 349223.058539: hda_send_cmd: [0:0] val=e3a01a <...>-26764 [001] 349223.058541: hda_send_cmd: [0:0] val=e3901a ------------------------------------------------------------------------ Here `[0:0]` indicates the card number and the codec address, and `val` shows the value sent to the codec, respectively. The value is a packed value, and you can decode it via hda-decode-verb program included in hda-emu package below. For example, the value e3a019 is to set the left output-amp value to 25. ------------------------------------------------------------------------ % hda-decode-verb 0xe3a019 raw value = 0x00e3a019 cid = 0, nid = 0x0e, verb = 0x3a0, parm = 0x19 raw value: verb = 0x3a0, parm = 0x19 verbname = set_amp_gain_mute amp raw val = 0xa019 output, left, idx=0, mute=0, val=25 ------------------------------------------------------------------------
Development Tree ~~~~~~~~~~~~~~~~ The latest development codes for HD-audio are found on sound git tree:
- git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
The master branch or for-next branches can be used as the main development branches in general while the development for the current and next kernels are found in for-linus and for-next branches, respectively.
If you are using the latest Linus tree, it'd be better to pull the above GIT tree onto it. If you are using the older kernels, an easy way to try the latest ALSA code is to build from the snapshot tarball. There are daily tarballs and the latest snapshot tarball. All can be built just like normal alsa-driver release packages, that is, installed via the usual spells: configure, make and make install(-modules). See INSTALL in the package. The snapshot tarballs are found at:
- ftp://ftp.suse.com/pub/people/tiwai/snapshot/
Sending a Bug Report ~~~~~~~~~~~~~~~~~~~~ If any model or module options don't work for your device, it's time to send a bug report to the developers. Give the following in your bug report:
- Hardware vendor, product and model names - Kernel version (and ALSA-driver version if you built externally) - `alsa-info.sh` output; run with `--no-upload` option. See the section below about alsa-info
If it's a regression, at best, send alsa-info outputs of both working and non-working kernels. This is really helpful because we can compare the codec registers directly.
Send a bug report either the followings:
kernel-bugzilla:: https://bugzilla.kernel.org/ alsa-devel ML:: alsa-devel@alsa-project.org
DEBUG TOOLS -----------
This section describes some tools available for debugging HD-audio problems.
alsa-info ~~~~~~~~~ The script `alsa-info.sh` is a very useful tool to gather the audio device information. You can fetch the latest version from:
- http://www.alsa-project.org/alsa-info.sh
Run this script as root, and it will gather the important information such as the module lists, module parameters, proc file contents including the codec proc files, mixer outputs and the control elements. As default, it will store the information onto a web server on alsa-project.org. But, if you send a bug report, it'd be better to run with `--no-upload` option, and attach the generated file.
There are some other useful options. See `--help` option output for details.
When a probe error occurs or when the driver obviously assigns a mismatched model, it'd be helpful to load the driver with `probe_only=1` option (at best after the cold reboot) and run alsa-info at this state. With this option, the driver won't configure the mixer and PCM but just tries to probe the codec slot. After probing, the proc file is available, so you can get the raw codec information before modified by the driver. Of course, the driver isn't usable with `probe_only=1`. But you can continue the configuration via hwdep sysfs file if hda-reconfig option is enabled. Using `probe_only` mask 2 skips the reset of HDA codecs (use `probe_only=3` as module option). The hwdep interface can be used to determine the BIOS codec initialization.
hda-verb ~~~~~~~~ hda-verb is a tiny program that allows you to access the HD-audio codec directly. You can execute a raw HD-audio codec verb with this. This program accesses the hwdep device, thus you need to enable the kernel config `CONFIG_SND_HDA_HWDEP=y` beforehand.
The hda-verb program takes four arguments: the hwdep device file, the widget NID, the verb and the parameter. When you access to the codec on the slot 2 of the card 0, pass /dev/snd/hwC0D2 to the first argument, typically. (However, the real path name depends on the system.)
The second parameter is the widget number-id to access. The third parameter can be either a hex/digit number or a string corresponding to a verb. Similarly, the last parameter is the value to write, or can be a string for the parameter type.
------------------------------------------------------------------------ % hda-verb /dev/snd/hwC0D0 0x12 0x701 2 nid = 0x12, verb = 0x701, param = 0x2 value = 0x0
% hda-verb /dev/snd/hwC0D0 0x0 PARAMETERS VENDOR_ID nid = 0x0, verb = 0xf00, param = 0x0 value = 0x10ec0262
% hda-verb /dev/snd/hwC0D0 2 set_a 0xb080 nid = 0x2, verb = 0x300, param = 0xb080 value = 0x0 ------------------------------------------------------------------------
Although you can issue any verbs with this program, the driver state won't be always updated. For example, the volume values are usually cached in the driver, and thus changing the widget amp value directly via hda-verb won't change the mixer value.
The hda-verb program is included now in alsa-tools:
- git://git.alsa-project.org/alsa-tools.git
Also, the old stand-alone package is found in the ftp directory:
- ftp://ftp.suse.com/pub/people/tiwai/misc/
Also a git repository is available:
- git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-verb.git
See README file in the tarball for more details about hda-verb program.
hda-analyzer ~~~~~~~~~~~~ hda-analyzer provides a graphical interface to access the raw HD-audio control, based on pyGTK2 binding. It's a more powerful version of hda-verb. The program gives you an easy-to-use GUI stuff for showing the widget information and adjusting the amp values, as well as the proc-compatible output.
The hda-analyzer:
- http://git.alsa-project.org/?p=alsa.git;a=tree;f=hda-analyzer
is a part of alsa.git repository in alsa-project.org:
- git://git.alsa-project.org/alsa.git
Codecgraph ~~~~~~~~~~ Codecgraph is a utility program to generate a graph and visualizes the codec-node connection of a codec chip. It's especially useful when you analyze or debug a codec without a proper datasheet. The program parses the given codec proc file and converts to SVG via graphiz program.
The tarball and GIT trees are found in the web page at:
- http://helllabs.org/codecgraph/
hda-emu ~~~~~~~ hda-emu is an HD-audio emulator. The main purpose of this program is to debug an HD-audio codec without the real hardware. Thus, it doesn't emulate the behavior with the real audio I/O, but it just dumps the codec register changes and the ALSA-driver internal changes at probing and operating the HD-audio driver.
The program requires a codec proc-file to simulate. Get a proc file for the target codec beforehand, or pick up an example codec from the codec proc collections in the tarball. Then, run the program with the proc file, and the hda-emu program will start parsing the codec file and simulates the HD-audio driver:
------------------------------------------------------------------------ % hda-emu codecs/stac9200-dell-d820-laptop # Parsing.. hda_codec: Unknown model for STAC9200, using BIOS defaults hda_codec: pin nid 08 bios pin config 40c003fa .... ------------------------------------------------------------------------
The program gives you only a very dumb command-line interface. You can get a proc-file dump at the current state, get a list of control (mixer) elements, set/get the control element value, simulate the PCM operation, the jack plugging simulation, etc.
The package is found in:
- ftp://ftp.suse.com/pub/people/tiwai/misc/
A git repository is available:
- git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git
See README file in the tarball for more details about hda-emu program.
hda-jack-retask
|