요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
=============================
More Notes on HD-Audio Driver
=============================
Takashi Iwai <tiwai@suse.de>
General
=======
HD-audio is the new standard on-board audio component on modern PCs
after AC97. Although Linux has been supporting HD-audio since long
time ago, there are often problems with new machines. A part of the
problem is broken BIOS, and the rest is the driver implementation.
This document explains the brief trouble-shooting and debugging
methods for the HD-audio hardware.
The HD-audio component consists of two parts: the controller chip and
the codec chips on the HD-audio bus. Linux provides a single driver
for all controllers, snd-hda-intel. Although the driver name contains
a word of a well-known hardware vendor, it's not specific to it but for
all controller chips by other companies. Since the HD-audio
controllers are supposed to be compatible, the single snd-hda-driver
should work in most cases. But, not surprisingly, there are known
bugs and issues specific to each controller type. The snd-hda-intel
driver has a bunch of workarounds for these as described below.
A controller may have multiple codecs. Usually you have one audio
codec and optionally one modem codec. In theory, there might be
multiple audio codecs, e.g. for analog and digital outputs, and the
driver might not work properly because of conflict of mixer elements.
This should be fixed in future if such hardware really exists.
The snd-hda-intel driver has several different codec parsers depending
on the codec. It has a generic parser as a fallback, but this
functionality is fairly limited until now. Instead of the generic
parser, usually the codec-specific parser (coded in patch_*.c) is used
for the codec-specific implementations. The details about the
codec-specific problems are explained in the later sections.
If you are interested in the deep debugging of HD-audio, read the
HD-audio specification at first. The specification is found on
Intel's web page, for example:
* https://www.intel.com/content/www/us/en/standards/high-definition-audio-specification.html
HD-Audio Controller
===================
DMA-Position Problem
--------------------
The most common problem of the controller is the inaccurate DMA
pointer reporting. The DMA pointer for playback and capture can be
read in two ways, either via a LPIB register or via a position-buffer
map. As default the driver tries to read from the io-mapped
position-buffer, and falls back to LPIB if the position-buffer appears
dead. However, this detection isn't perfect on some devices. In such
a case, you can change the default method via ``position_fix`` option.
``position_fix=1`` means to use LPIB method explicitly.
``position_fix=2`` means to use the position-buffer.
``position_fix=3`` means to use a combination of both methods, needed
for some VIA controllers. The capture stream position is corrected
by comparing both LPIB and position-buffer values.
``position_fix=4`` is another combination available for all controllers,
and uses LPIB for the playback and the position-buffer for the capture
streams.
``position_fix=5`` is specific to Intel platforms, so far, for Skylake
and onward. It applies the delay calculation for the precise position
reporting.
``position_fix=6`` is to correct the position with the fixed FIFO
size, mainly targeted for the recent AMD controllers.
0 is the default value for all other
controllers, the automatic check and fallback to LPIB as described in
the above. If you get a problem of repeated sounds, this option might
help.
In addition to that, every controller is known to be broken regarding
the wake-up timing. It wakes up a few samples before actually
processing the data on the buffer. This caused a lot of problems, for
example, with ALSA dmix or JACK. Since 2.6.27 kernel, the driver puts
an artificial delay to the wake up timing. This delay is controlled
via ``bdl_pos_adj`` option.
When ``bdl_pos_adj`` is a negative value (as default), it's assigned to
an appropriate value depending on the controller chip. For Intel
chips, it'd be 1 while it'd be 32 for others. Usually this works.
Only in case it doesn't work and you get warning messages, you should
change this parameter to other values.
Codec-Probing Problem
---------------------
A less often but a more severe problem is the codec probing. When
BIOS reports the available codec slots wrongly, the driver gets
confused and tries to access the non-existing codec slot. This often
results in the total screw-up, and destructs the further communication
with the codec chips. The symptom appears usually as error messages
like:
::
hda_intel: azx_get_response timeout, switching to polling mode:
last cmd=0x12345678
hda_intel: azx_get_response timeout, switching to single_cmd mode:
last cmd=0x12345678
The first line is a warning, and this is usually relatively harmless.
It means that the codec response isn't notified via an IRQ. The
driver uses explicit polling method to read the response. It gives
very slight CPU overhead, but you'd unlikely notice it.
The second line is, however, a fatal error. If this happens, usually
it means that something is really wrong. Most likely you are
accessing a non-existing codec slot.
Thus, if the second error message appears, try to narrow the probed
codec slots via ``probe_mask`` option. It's a bitmask, and each bit
corresponds to the codec slot. For example, to probe only the first
slot, pass ``probe_mask=1``. For the first and the third slots, pass
``probe_mask=5`` (where 5 = 1 | 4), and so on.
Since 2.6.29 kernel, the driver has a more robust probing method, so
this error might happen rarely, though.
On a machine with a broken BIOS, sometimes you need to force the
driver to probe the codec slots the hardware doesn't report for use.
In such a case, turn the bit 8 (0x100) of ``probe_mask`` option on.
Then the rest 8 bits are passed as the codec slots to probe
unconditionally. For example, ``probe_mask=0x103`` will force to probe
the codec slots 0 and 1 no matter what the hardware reports.
Interrupt Handling
------------------
HD-audio driver uses MSI as default (if available) since 2.6.33
kernel as MSI works better on some machines, and in general, it's
better for performance. However, Nvidia controllers showed bad
regressions with MSI (especially in a combination with AMD chipset),
thus we disabled MSI for them.
There seem also still other devices that don't work with MSI. If you
see a regression wrt the sound quality (stuttering, etc) or a lock-up
in the recent kernel, try to pass ``enable_msi=0`` option to disable
MSI. If it works, you can add the known bad device to the blacklist
defined in hda_intel.c. In such a case, please report and give the
patch back to the upstream developer.
HD-Audio Codec
==============
Model Option
------------
The most common problem regarding the HD-audio driver is the
unsupported codec features or the mismatched device configuration.
Most of codec-specific code has several preset models, either to
override the BIOS setup or to provide more comprehensive features.
The driver checks PCI SSID and looks through the static configuration
table until any matching entry is found. If you have a new machine,
you may see a message like below:
::
hda_codec: ALC880: BIOS auto-probing.
Meanwhile, in the earlier versions, you would see a message like:
::
hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...
Even if you see such a message, DON'T PANIC. Take a deep breath and
keep your towel. First of all, it's an informational message, no
warning, no error. This means that the PCI SSID of your device isn't
listed in the known preset model (white-)list. But, this doesn't mean
that the driver is broken. Many codec-drivers provide the automatic
configuration mechanism based on the BIOS setup.
The HD-audio codec has usually "pin" widgets, and BIOS sets the default
configuration of each pin, which indicates the location, the
connection type, the jack color, etc. The HD-audio driver can guess
the right connection judging from these default configuration values.
However -- some codec-support codes, such as patch_analog.c, don't
support the automatic probing (yet as of 2.6.28). And, BIOS is often,
yes, pretty often broken. It sets up wrong values and screws up the
driver.
The preset model (or recently called as "fix-up") is provided
basically to overcome such a situation. When the matching preset
model is found in the white-list, the driver assumes the static
configuration of that preset with the correct pin setup, etc.
Thus, if you have a newer machine with a slightly different PCI SSID
(or codec SSID) from the existing one, you may have a good chance to
re-use the same model. You can pass the ``model`` option to specify the
preset model instead of PCI (and codec-) SSID look-up.
What ``model`` option values are available depends on the codec chip.
Check your codec chip from the codec proc file (see "Codec Proc-File"
section below). It will show the vendor/product name of your codec
chip. Then, see Documentation/sound/hd-audio/models.rst file,
the section of HD-audio driver. You can find a list of codecs
and ``model`` options belonging to each codec. For example, for Realtek
ALC262 codec chip, pass ``model=ultra`` for devices that are compatible
with Samsung Q1 Ultra.
Thus, the first thing you can do for any brand-new, unsupported and
non-working HD-audio hardware is to check HD-audio codec and several
different ``model`` option values. If you have any luck, some of them
might suit with your device well.
There are a few special model option values:
* when 'nofixup' is passed, the device-specific fixups in the codec
parser are skipped.
* when ``generic`` is passed, the codec-specific parser is skipped and
only the generic parser is used.
A new style for the model option that was introduced since 5.15 kernel
is to pass the PCI or codec SSID in the form of ``model=XXXX:YYYY``
where XXXX and YYYY are the sub-vendor and sub-device IDs in hex
numbers, respectively. This is a kind of aliasing to another device;
when this form is given, the driver will refer to that SSID as a
reference to the quirk table. It'd be useful especially when the
target quirk isn't listed in the model table. For example, passing
model=103c:8862 will apply the quirk for HP ProBook 445 G8 (which
isn't found in the model table as of writing) as long as the device is
handled equivalently by the same driver.
Speaker and Headphone Output
----------------------------
One of the most frequent (and obvious) bugs with HD-audio is the
silent output from either or both of a built-in speaker and a
headphone jack. In general, you should try a headphone output at
first. A speaker output often requires more additional controls like
the external amplifier bits. Thus a headphone output has a slightly
better chance.
Before making a bug report, double-check whether the mixer is set up
correctly. The recent version of snd-hda-intel driver provides mostly
"Master" volume control as well as "Front" volume (where Front
indicates the front-channels). In addition, there can be individual
"Headphone" and "Speaker" controls.
Ditto for the speaker output. There can be "External Amplifier"
switch on some codecs. Turn on this if present.
Another related problem is the automatic mute of speaker output by
headphone plugging. This feature is implemented in most cases, but
not on every preset model or codec-support code.
In anyway, try a different model option if you have such a problem.
Some other models may match better and give you more matching
functionality. If none of the available models works, send a bug
report. See the bug report section for details.
If you are masochistic enough to debug the driver problem, note the
following:
* The speaker (and the headphone, too) output often requires the
external amplifier. This can be set usually via EAPD verb or a
certain GPIO. If the codec pin supports EAPD, you have a better
chance via SET_EAPD_BTL verb (0x70c). On others, GPIO pin (mostly
it's either GPIO0 or GPIO1) may turn on/off EAPD.
* Some Realtek codecs require special vendor-specific coefficients to
turn on the amplifier. See patch_realtek.c.
* IDT codecs may have extra power-enable/disable controls on each
analog pin. See patch_sigmatel.c.
* Very rare but some devices don't accept the pin-detection verb until
triggered. Issuing GET_PIN_SENSE verb (0xf09) may result in the
codec-communication stall. Some examples are found in
patch_realtek.c.
Capture Problems
----------------
The capture problems are often because of missing setups of mixers.
Thus, before submitting a bug report, make sure that you set up the
mixer correctly. For example, both "Capture Volume" and "Capture
Switch" have to be set properly in addition to the right "Capture
Source" or "Input Source" selection. Some devices have "Mic Boost"
volume or switch.
When the PCM device is opened via "default" PCM (without pulse-audio
plugin), you'll likely have "Digital Capture Volume" control as well.
This is provided for the extra gain/attenuation of the signal in
software, especially for the inputs without the hardware volume
control such as digital microphones. Unless really needed, this
should be set to exactly 50%, corresponding to 0dB -- neither extra
gain nor attenuation. When you use "hw" PCM, i.e., a raw access PCM,
this control will have no influence, though.
It's known that some codecs / devices have fairly bad analog circuits,
and the recorded sound contains a certain DC-offset. This is no bug
of the driver.
Most of modern laptops have no analog CD-input connection. Thus, the
recording from CD input won't work in many cases although the driver
provides it as the capture source. Use CDDA instead.
The automatic switching of the built-in and external mic per plugging
is implemented on some codec models but not on every model. Partly
because of my laziness but mostly lack of testers. Feel free to
submit the improvement patch to the author.
Direct Debugging
----------------
If no model option gives you a better result, and you are a tough guy
to fight against evil, try debugging via hitting the raw HD-audio
codec verbs to the device. Some tools are available: hda-emu and
hda-analyzer. The detailed description is found in the sections
below. You'd need to enable hwdep for using these tools. See "Kernel
Configuration" section.
Other Issues
============
Kernel Configuration
--------------------
In general, I recommend you to enable the sound debug option,
``CONFIG_SND_DEBUG=y``, no matter whether you are debugging or not.
Don't forget to turn on the appropriate ``CONFIG_SND_HDA_CODEC_*``
options. Note that each of them corresponds to the codec chip, not
the controller chip. Thus, even if lspci shows the Nvidia controller,
you may need to choose the option for other vendors. If you are
unsure, just select all yes.
``CONFIG_SND_HDA_HWDEP`` is a useful option for debugging the driver.
When this is enabled, the driver creates hardware-dependent devices
(one per each codec), and you have a raw access to the device via
these device files. For example, ``hwC0D2`` will be created for the
codec slot #2 of the first card (#0). For debug-tools such as
hda-verb and hda-analyzer, the hwdep device has to be enabled.
Thus, it'd be better to turn this on always.
``CONFIG_SND_HDA_RECONFIG`` is a new option, and this depends on the
hwdep option above. When enabled, you'll have some sysfs files under
the corresponding hwdep directory. See "HD-audio reconfiguration"
section below.
``CONFIG_SND_HDA_POWER_SAVE`` option enables the power-saving feature.
See "Power-saving" section below.
Codec Proc-File
---------------
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
state (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
vmaster (bool)
enable/disable the virtual Master control; 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/tracing/events/hda/enable
then after some commands, you can traces from
/sys/kernel/tracing/trace file. For example, when you want to
trace what codec command is sent, enable the tracepoint like:
::
# cat /sys/kernel/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.
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 following:
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. It's included in alsa-utils package. The latest
version can be found on git repository:
* git://git.alsa-project.org/alsa-utils.git
The script can be fetched directly from the following URL, too:
* https://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:
* https://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 program is found in the git repository below:
* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git
See README file in the repository for more details about hda-emu
program.
hda-jack-retask
---------------
hda-jack-retask is a user-friendly GUI program to manipulate the
HD-audio pin control for jack retasking. If you have a problem about
the jack assignment, try this program and check whether you can get
useful results. Once when you figure out the proper pin assignment,
it can be fixed either in the driver code statically or via passing a
firmware patch file (see "Early Patching" section).
The program is included in alsa-tools now:
* git://git.alsa-project.org/alsa-tools.git
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
일반 구조와 문서 범위
1-47이 문서는 Takashi Iwai가 작성한 HD-Audio hardware의 간단한 문제 해결 및 debugging 안내입니다. HD-Audio는 AC97 이후 현대 PC의 표준 onboard audio component가 되었지만, 새 시스템에서는 잘못된 BIOS와 driver 구현 문제 때문에 여전히 장애가 발생합니다.
HD-Audio component는 controller chip과 HD-Audio bus의 codec chip으로 구성됩니다. Linux의 `snd-hda-intel`은 이름과 달리 Intel 전용이 아니라 호환 가능한 여러 회사 controller를 위한 단일 driver입니다. Controller별 알려진 bug에는 driver workaround가 적용됩니다.
Controller 하나에 codec이 여러 개 있을 수 있습니다. 보통 audio codec 하나와 선택적인 modem codec 하나가 있지만, analog/digital 출력용 audio codec이 여러 개면 mixer element 충돌 때문에 driver가 제대로 동작하지 않을 수 있습니다. 원문은 실제 hardware가 존재하면 향후 수정해야 한다고 설명합니다.
`snd-hda-intel`은 codec에 따라 서로 다른 parser를 사용합니다. 제한적인 generic parser가 fallback으로 존재하지만, 보통 `patch_*.c`에 구현된 codec-specific parser를 사용합니다. 깊은 debugging 전에는 Intel의 High Definition Audio specification을 먼저 읽는 것이 권장됩니다.
Controller와 codec parser의 역할을 구분합니다.
증상을 controller와 codec 문제로 먼저 분리합니다.
=============================
More Notes on HD-Audio Driver
=============================
Takashi Iwai <tiwai@suse.de>
General
=======
HD-audio is the new standard on-board audio component on modern PCs
after AC97. Although Linux has been supporting HD-audio since long
time ago, there are often problems with new machines. A part of the
problem is broken BIOS, and the rest is the driver implementation.
This document explains the brief trouble-shooting and debugging
methods for the HD-audio hardware.
The HD-audio component consists of two parts: the controller chip and
the codec chips on the HD-audio bus. Linux provides a single driver
for all controllers, snd-hda-intel. Although the driver name contains
a word of a well-known hardware vendor, it's not specific to it but for
all controller chips by other companies. Since the HD-audio
controllers are supposed to be compatible, the single snd-hda-driver
should work in most cases. But, not surprisingly, there are known
bugs and issues specific to each controller type. The snd-hda-intel
driver has a bunch of workarounds for these as described below.
A controller may have multiple codecs. Usually you have one audio
codec and optionally one modem codec. In theory, there might be
multiple audio codecs, e.g. for analog and digital outputs, and the
driver might not work properly because of conflict of mixer elements.
This should be fixed in future if such hardware really exists.
The snd-hda-intel driver has several different codec parsers depending
on the codec. It has a generic parser as a fallback, but this
functionality is fairly limited until now. Instead of the generic
parser, usually the codec-specific parser (coded in patch_*.c) is used
for the codec-specific implementations. The details about the
codec-specific problems are explained in the later sections.
If you are interested in the deep debugging of HD-audio, read the
HD-audio specification at first. The specification is found on
Intel's web page, for example:
* https://www.intel.com/content/www/us/en/standards/high-definition-audio-specification.html
DMA position 문제
48-92Controller의 가장 흔한 문제는 부정확한 DMA pointer 보고입니다. Playback/capture 위치는 `LPIB` register 또는 position-buffer map에서 읽을 수 있습니다. Driver는 기본적으로 I/O-mapped position-buffer를 사용하고 죽은 것으로 보이면 LPIB로 fallback하지만, 일부 장치에서는 감지가 완전하지 않습니다.
`position_fix` option으로 위치 산정 방식을 명시할 수 있습니다. 반복 재생 같은 증상에서는 이 option이 도움이 될 수 있습니다.
각 값이 선택하는 DMA 위치 보고 방식입니다.
모든 controller는 실제 buffer 처리보다 몇 sample 일찍 wake-up하는 timing 문제가 알려져 있습니다. ALSA `dmix`나 JACK에 문제를 일으켜 kernel 2.6.27부터 driver가 인위적 delay를 넣으며, `bdl_pos_adj` option으로 제어합니다.
`bdl_pos_adj`가 기본처럼 음수이면 controller에 맞는 값을 자동 할당합니다. Intel chip은 1, 그 밖의 chip은 32가 일반적입니다. 보통 그대로 동작하며 warning이 발생하는 경우에만 다른 값을 시험해야 합니다.
자동 방식이 실패할 때 option을 단계적으로 좁힙니다.
HD-Audio Controller
===================
DMA-Position Problem
--------------------
The most common problem of the controller is the inaccurate DMA
pointer reporting. The DMA pointer for playback and capture can be
read in two ways, either via a LPIB register or via a position-buffer
map. As default the driver tries to read from the io-mapped
position-buffer, and falls back to LPIB if the position-buffer appears
dead. However, this detection isn't perfect on some devices. In such
a case, you can change the default method via ``position_fix`` option.
``position_fix=1`` means to use LPIB method explicitly.
``position_fix=2`` means to use the position-buffer.
``position_fix=3`` means to use a combination of both methods, needed
for some VIA controllers. The capture stream position is corrected
by comparing both LPIB and position-buffer values.
``position_fix=4`` is another combination available for all controllers,
and uses LPIB for the playback and the position-buffer for the capture
streams.
``position_fix=5`` is specific to Intel platforms, so far, for Skylake
and onward. It applies the delay calculation for the precise position
reporting.
``position_fix=6`` is to correct the position with the fixed FIFO
size, mainly targeted for the recent AMD controllers.
0 is the default value for all other
controllers, the automatic check and fallback to LPIB as described in
the above. If you get a problem of repeated sounds, this option might
help.
In addition to that, every controller is known to be broken regarding
the wake-up timing. It wakes up a few samples before actually
processing the data on the buffer. This caused a lot of problems, for
example, with ALSA dmix or JACK. Since 2.6.27 kernel, the driver puts
an artificial delay to the wake up timing. This delay is controlled
via ``bdl_pos_adj`` option.
When ``bdl_pos_adj`` is a negative value (as default), it's assigned to
an appropriate value depending on the controller chip. For Intel
chips, it'd be 1 while it'd be 32 for others. Usually this works.
Only in case it doesn't work and you get warning messages, you should
change this parameter to other values.
Codec probing 문제
93-133BIOS가 사용 가능한 codec slot을 잘못 보고하면 driver가 존재하지 않는 slot에 접근해 이후 codec 통신까지 망가질 수 있습니다. 대표 증상은 `azx_get_response timeout` 메시지입니다.
hda_intel: azx_get_response timeout, switching to polling mode:
last cmd=0x12345678
hda_intel: azx_get_response timeout, switching to single_cmd mode:
last cmd=0x12345678
첫 번째 polling mode 전환은 보통 비교적 무해합니다. IRQ로 codec response가 통지되지 않아 명시적 polling으로 읽는다는 뜻이며 CPU overhead는 매우 작습니다. 두 번째 single_cmd mode 전환은 fatal error로, 대개 존재하지 않는 codec slot 접근을 뜻합니다.
Fatal message가 나오면 `probe_mask` bitmask로 probing할 slot을 제한합니다. Bit마다 codec slot 하나가 대응하므로 slot 0만 검사할 때는 `probe_mask=1`, slot 0과 2는 `probe_mask=5`를 사용합니다.
Kernel 2.6.29부터 probing이 더 견고해졌습니다. 반대로 hardware가 사용 가능하다고 보고하지 않은 slot까지 강제로 검사해야 하는 잘못된 BIOS에서는 `probe_mask`의 bit 8(`0x100`)을 켭니다. 예를 들어 `probe_mask=0x103`은 hardware 보고와 무관하게 slot 0과 1을 강제 probing합니다.
하위 8 bit는 slot, bit 8은 강제 probing 의미입니다.
Codec-Probing Problem
---------------------
A less often but a more severe problem is the codec probing. When
BIOS reports the available codec slots wrongly, the driver gets
confused and tries to access the non-existing codec slot. This often
results in the total screw-up, and destructs the further communication
with the codec chips. The symptom appears usually as error messages
like:
::
hda_intel: azx_get_response timeout, switching to polling mode:
last cmd=0x12345678
hda_intel: azx_get_response timeout, switching to single_cmd mode:
last cmd=0x12345678
The first line is a warning, and this is usually relatively harmless.
It means that the codec response isn't notified via an IRQ. The
driver uses explicit polling method to read the response. It gives
very slight CPU overhead, but you'd unlikely notice it.
The second line is, however, a fatal error. If this happens, usually
it means that something is really wrong. Most likely you are
accessing a non-existing codec slot.
Thus, if the second error message appears, try to narrow the probed
codec slots via ``probe_mask`` option. It's a bitmask, and each bit
corresponds to the codec slot. For example, to probe only the first
slot, pass ``probe_mask=1``. For the first and the third slots, pass
``probe_mask=5`` (where 5 = 1 | 4), and so on.
Since 2.6.29 kernel, the driver has a more robust probing method, so
this error might happen rarely, though.
On a machine with a broken BIOS, sometimes you need to force the
driver to probe the codec slots the hardware doesn't report for use.
In such a case, turn the bit 8 (0x100) of ``probe_mask`` option on.
Then the rest 8 bits are passed as the codec slots to probe
unconditionally. For example, ``probe_mask=0x103`` will force to probe
the codec slots 0 and 1 no matter what the hardware reports.
Interrupt handling
134-149HD-Audio driver는 kernel 2.6.33부터 가능하면 MSI를 기본 사용합니다. 일부 시스템에서 더 안정적이고 일반적으로 성능에도 유리하기 때문입니다. 그러나 Nvidia controller는 특히 AMD chipset과 조합할 때 MSI regression을 보여 기본 비활성화됐습니다.
그 밖에도 MSI가 동작하지 않는 장치가 있습니다. 최신 kernel에서 stuttering 같은 음질 regression이나 lock-up이 생기면 `enable_msi=0`을 시험합니다. 효과가 있으면 `hda_intel.c` blacklist에 장치를 추가하고 upstream에 보고 및 patch를 제출해야 합니다.
음질이나 lock-up 문제가 interrupt 방식 때문인지 확인합니다.
Interrupt Handling
------------------
HD-audio driver uses MSI as default (if available) since 2.6.33
kernel as MSI works better on some machines, and in general, it's
better for performance. However, Nvidia controllers showed bad
regressions with MSI (especially in a combination with AMD chipset),
thus we disabled MSI for them.
There seem also still other devices that don't work with MSI. If you
see a regression wrt the sound quality (stuttering, etc) or a lock-up
in the recent kernel, try to pass ``enable_msi=0`` option to disable
MSI. If it works, you can add the known bad device to the blacklist
defined in hda_intel.c. In such a case, please report and give the
patch back to the upstream developer.
Codec model option
150-229HD-Audio driver의 가장 흔한 codec 문제는 지원하지 않는 기능 또는 장치 구성 불일치입니다. Codec-specific code는 BIOS 설정을 override하거나 더 포괄적인 기능을 제공하는 preset model을 여러 개 가집니다.
Driver는 PCI SSID를 static configuration table에서 찾습니다. 새 시스템에 일치 항목이 없으면 `BIOS auto-probing` 또는 구형 driver의 `Unknown model ... trying auto-probe from BIOS` 같은 정보 메시지가 나옵니다. 이는 warning이나 error가 아니라 SSID가 알려진 preset whitelist에 없다는 뜻입니다.
hda_codec: ALC880: BIOS auto-probing.
hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...
Codec의 pin widget에는 BIOS가 위치, connection type, jack color 등의 default configuration을 설정합니다. Driver는 이를 바탕으로 연결을 추론하지만 일부 parser는 자동 probing을 지원하지 않고 BIOS 값도 자주 잘못됩니다.
Preset model, 최근 용어로 fix-up은 이런 상황을 보정합니다. PCI 또는 codec SSID가 기존 장치와 조금만 다르면 같은 model을 재사용할 수 있으며, `model` option을 주면 SSID lookup 대신 지정한 preset을 사용합니다.
사용 가능한 값은 codec chip마다 다릅니다. `/proc/asound/card*/codec#*`에서 vendor/product를 확인한 뒤 `Documentation/sound/hd-audio/models.rst`의 해당 codec 목록을 봅니다. 원문의 예는 Samsung Q1 Ultra 호환 ALC262에 `model=ultra`를 적용하는 것입니다.
Preset table lookup을 바꾸는 특수 값과 새 alias 형식입니다.
`model=XXXX:YYYY` 형식은 kernel 5.15부터 도입됐습니다. Target quirk가 model table에 이름으로 노출되지 않았을 때 다른 장치 SSID를 alias로 참조하는 데 유용합니다.
자동 구성이 실패한 장치에서 model을 검토하는 순서입니다.
HD-Audio Codec
==============
Model Option
------------
The most common problem regarding the HD-audio driver is the
unsupported codec features or the mismatched device configuration.
Most of codec-specific code has several preset models, either to
override the BIOS setup or to provide more comprehensive features.
The driver checks PCI SSID and looks through the static configuration
table until any matching entry is found. If you have a new machine,
you may see a message like below:
::
hda_codec: ALC880: BIOS auto-probing.
Meanwhile, in the earlier versions, you would see a message like:
::
hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...
Even if you see such a message, DON'T PANIC. Take a deep breath and
keep your towel. First of all, it's an informational message, no
warning, no error. This means that the PCI SSID of your device isn't
listed in the known preset model (white-)list. But, this doesn't mean
that the driver is broken. Many codec-drivers provide the automatic
configuration mechanism based on the BIOS setup.
The HD-audio codec has usually "pin" widgets, and BIOS sets the default
configuration of each pin, which indicates the location, the
connection type, the jack color, etc. The HD-audio driver can guess
the right connection judging from these default configuration values.
However -- some codec-support codes, such as patch_analog.c, don't
support the automatic probing (yet as of 2.6.28). And, BIOS is often,
yes, pretty often broken. It sets up wrong values and screws up the
driver.
The preset model (or recently called as "fix-up") is provided
basically to overcome such a situation. When the matching preset
model is found in the white-list, the driver assumes the static
configuration of that preset with the correct pin setup, etc.
Thus, if you have a newer machine with a slightly different PCI SSID
(or codec SSID) from the existing one, you may have a good chance to
re-use the same model. You can pass the ``model`` option to specify the
preset model instead of PCI (and codec-) SSID look-up.
What ``model`` option values are available depends on the codec chip.
Check your codec chip from the codec proc file (see "Codec Proc-File"
section below). It will show the vendor/product name of your codec
chip. Then, see Documentation/sound/hd-audio/models.rst file,
the section of HD-audio driver. You can find a list of codecs
and ``model`` options belonging to each codec. For example, for Realtek
ALC262 codec chip, pass ``model=ultra`` for devices that are compatible
with Samsung Q1 Ultra.
Thus, the first thing you can do for any brand-new, unsupported and
non-working HD-audio hardware is to check HD-audio codec and several
different ``model`` option values. If you have any luck, some of them
might suit with your device well.
There are a few special model option values:
* when 'nofixup' is passed, the device-specific fixups in the codec
parser are skipped.
* when ``generic`` is passed, the codec-specific parser is skipped and
only the generic parser is used.
A new style for the model option that was introduced since 5.15 kernel
is to pass the PCI or codec SSID in the form of ``model=XXXX:YYYY``
where XXXX and YYYY are the sub-vendor and sub-device IDs in hex
numbers, respectively. This is a kind of aliasing to another device;
when this form is given, the driver will refer to that SSID as a
reference to the quirk table. It'd be useful especially when the
target quirk isn't listed in the model table. For example, passing
model=103c:8862 will apply the quirk for HP ProBook 445 G8 (which
isn't found in the model table as of writing) as long as the device is
handled equivalently by the same driver.
Speaker와 headphone 출력
230-274내장 speaker나 headphone jack이 무음인 문제는 매우 흔합니다. 먼저 headphone 출력을 시험하는 편이 좋습니다. Speaker는 external amplifier bit 같은 추가 제어가 필요한 경우가 많아 headphone이 성공할 가능성이 조금 더 높습니다.
Bug report 전에 mixer 설정을 다시 확인합니다. 최신 `snd-hda-intel`은 대개 `Master`, front channel을 뜻하는 `Front`, 그리고 별도의 `Headphone`, `Speaker` control을 제공합니다. Codec에 `External Amplifier` switch가 있으면 켭니다.
Headphone 삽입 시 speaker를 자동 mute하는 기능은 대부분 구현돼 있지만 모든 preset이나 codec code에 있는 것은 아닙니다. 다른 model이 더 잘 맞을 수 있으며 어느 model도 동작하지 않으면 bug report를 제출합니다.
Driver 내부를 직접 확인할 때의 주요 hardware 제어입니다.
Speaker and Headphone Output
----------------------------
One of the most frequent (and obvious) bugs with HD-audio is the
silent output from either or both of a built-in speaker and a
headphone jack. In general, you should try a headphone output at
first. A speaker output often requires more additional controls like
the external amplifier bits. Thus a headphone output has a slightly
better chance.
Before making a bug report, double-check whether the mixer is set up
correctly. The recent version of snd-hda-intel driver provides mostly
"Master" volume control as well as "Front" volume (where Front
indicates the front-channels). In addition, there can be individual
"Headphone" and "Speaker" controls.
Ditto for the speaker output. There can be "External Amplifier"
switch on some codecs. Turn on this if present.
Another related problem is the automatic mute of speaker output by
headphone plugging. This feature is implemented in most cases, but
not on every preset model or codec-support code.
In anyway, try a different model option if you have such a problem.
Some other models may match better and give you more matching
functionality. If none of the available models works, send a bug
report. See the bug report section for details.
If you are masochistic enough to debug the driver problem, note the
following:
* The speaker (and the headphone, too) output often requires the
external amplifier. This can be set usually via EAPD verb or a
certain GPIO. If the codec pin supports EAPD, you have a better
chance via SET_EAPD_BTL verb (0x70c). On others, GPIO pin (mostly
it's either GPIO0 or GPIO1) may turn on/off EAPD.
* Some Realtek codecs require special vendor-specific coefficients to
turn on the amplifier. See patch_realtek.c.
* IDT codecs may have extra power-enable/disable controls on each
analog pin. See patch_sigmatel.c.
* Very rare but some devices don't accept the pin-detection verb until
triggered. Issuing GET_PIN_SENSE verb (0xf09) may result in the
codec-communication stall. Some examples are found in
patch_realtek.c.
Capture 문제
275-306Capture 문제는 mixer 설정 누락 때문인 경우가 많습니다. `Capture Source` 또는 `Input Source`를 올바르게 고르는 것 외에 `Capture Volume`, `Capture Switch`, 장치에 따라 `Mic Boost` volume/switch도 설정해야 합니다.
PulseAudio plugin 없는 `default` PCM으로 열면 `Digital Capture Volume`이 나타날 수 있습니다. Hardware volume이 없는 digital mic 등에 software gain/attenuation을 제공하며, 특별히 필요하지 않으면 0 dB에 해당하는 정확히 50%로 둡니다. Raw access인 `hw` PCM에는 이 control이 영향을 주지 않습니다.
일부 codec/장치는 analog circuit 품질 때문에 녹음에 DC offset이 섞이지만 driver bug는 아닙니다. 현대 laptop 대부분은 analog CD input이 없으므로 source가 보여도 CD 입력 녹음은 동작하지 않을 수 있으며 이 경우 CDDA를 사용합니다.
Plug 상태에 따른 내장/external mic 자동 전환은 일부 model에만 구현돼 있습니다. Tester 부족이 주요 이유이며 개선 patch 제출을 환영한다고 원문은 설명합니다.
무음 또는 왜곡 녹음에서 확인할 항목입니다.
Capture Problems
----------------
The capture problems are often because of missing setups of mixers.
Thus, before submitting a bug report, make sure that you set up the
mixer correctly. For example, both "Capture Volume" and "Capture
Switch" have to be set properly in addition to the right "Capture
Source" or "Input Source" selection. Some devices have "Mic Boost"
volume or switch.
When the PCM device is opened via "default" PCM (without pulse-audio
plugin), you'll likely have "Digital Capture Volume" control as well.
This is provided for the extra gain/attenuation of the signal in
software, especially for the inputs without the hardware volume
control such as digital microphones. Unless really needed, this
should be set to exactly 50%, corresponding to 0dB -- neither extra
gain nor attenuation. When you use "hw" PCM, i.e., a raw access PCM,
this control will have no influence, though.
It's known that some codecs / devices have fairly bad analog circuits,
and the recorded sound contains a certain DC-offset. This is no bug
of the driver.
Most of modern laptops have no analog CD-input connection. Thus, the
recording from CD input won't work in many cases although the driver
provides it as the capture source. Use CDDA instead.
The automatic switching of the built-in and external mic per plugging
is implemented on some codec models but not on every model. Partly
because of my laziness but mostly lack of testers. Feel free to
submit the improvement patch to the author.
Raw verb 직접 debugging
307-319어떤 model option도 개선하지 못하면 raw HD-Audio codec verb를 직접 보내 debugging할 수 있습니다. `hda-emu`와 `hda-analyzer` 같은 tool이 있으며 사용하려면 hwdep를 활성화해야 합니다.
이 절 뒤부터는 kernel configuration, proc/sysfs, patch loader, power, trace 및 debug tool을 다루는 기타 문제 영역입니다.
Preset 비교가 실패한 뒤 raw interface로 이동합니다.
Direct Debugging
----------------
If no model option gives you a better result, and you are a tough guy
to fight against evil, try debugging via hitting the raw HD-audio
codec verbs to the device. Some tools are available: hda-emu and
hda-analyzer. The detailed description is found in the sections
below. You'd need to enable hwdep for using these tools. See "Kernel
Configuration" section.
Other Issues
============
Kernel configuration
320-347Debug 여부와 무관하게 `CONFIG_SND_DEBUG=y`를 활성화하는 것이 권장됩니다. `CONFIG_SND_HDA_CODEC_*`는 controller vendor가 아니라 codec chip에 대응하므로 `lspci`가 Nvidia controller를 보여도 다른 vendor codec option이 필요할 수 있습니다. 확실하지 않으면 모두 활성화합니다.
`CONFIG_SND_HDA_HWDEP`는 codec마다 hardware-dependent device를 만들어 raw access를 제공합니다. 예를 들어 첫 card의 codec slot 2에는 `hwC0D2`가 생깁니다. `hda-verb`, `hda-analyzer`에는 이 hwdep device가 필요합니다.
`CONFIG_SND_HDA_RECONFIG`는 hwdep에 의존하며 codec hwdep directory 아래에 동적 재구성용 sysfs file을 만듭니다. `CONFIG_SND_HDA_POWER_SAVE`는 power-saving 기능을 활성화합니다.
문서가 권장하거나 뒤 절에서 사용하는 option입니다.
Kernel Configuration
--------------------
In general, I recommend you to enable the sound debug option,
``CONFIG_SND_DEBUG=y``, no matter whether you are debugging or not.
Don't forget to turn on the appropriate ``CONFIG_SND_HDA_CODEC_*``
options. Note that each of them corresponds to the codec chip, not
the controller chip. Thus, even if lspci shows the Nvidia controller,
you may need to choose the option for other vendors. If you are
unsure, just select all yes.
``CONFIG_SND_HDA_HWDEP`` is a useful option for debugging the driver.
When this is enabled, the driver creates hardware-dependent devices
(one per each codec), and you have a raw access to the device via
these device files. For example, ``hwC0D2`` will be created for the
codec slot #2 of the first card (#0). For debug-tools such as
hda-verb and hda-analyzer, the hwdep device has to be enabled.
Thus, it'd be better to turn this on always.
``CONFIG_SND_HDA_RECONFIG`` is a new option, and this depends on the
hwdep option above. When enabled, you'll have some sysfs files under
the corresponding hwdep directory. See "HD-audio reconfiguration"
section below.
``CONFIG_SND_HDA_POWER_SAVE`` option enables the power-saving feature.
See "Power-saving" section below.
Codec proc-file
348-367Codec proc-file은 HD-Audio debugging의 핵심 자료입니다. `/proc/asound/card*/codec#*`에 codec slot마다 하나씩 있으며 vendor, product ID/name, widget type, capability 등을 보여줍니다.
Jack sensing은 trigger state에 의존할 수 있어 현재 proc-file에는 표시되지 않습니다. Debug tool이 이 file을 읽고 emulator의 기본 codec 정보로도 사용할 수 있습니다.
Generic parser 사용 여부도 확인할 수 있습니다. Generic parser일 때 vendor/product 이름은 `Realtek ALC262` 대신 `Realtek ID 0262`처럼 나타납니다.
한 파일에서 얻는 주요 정보입니다.
Codec Proc-File
---------------
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 동적 재구성
368-432Driver reload 없이 codec을 동적으로 다시 구성하는 experimental 기능입니다. 각 codec hwdep directory, 예를 들어 `/sys/class/sound/hwC0D0` 아래의 sysfs file을 사용합니다.
재구성 interface의 읽기/쓰기 의미를 원문 정의 목록대로 정리했습니다.
예를 들어 pin widget `0x14`의 default configuration을 `0x9993013f`로 바꾸고 재구성하려면 다음 명령을 사용합니다.
# echo 0x14 0x9993013f > /sys/class/sound/hwC0D0/user_pin_configs
# echo 1 > /sys/class/sound/hwC0D0/reconfig
Override를 기록하고 codec tree를 다시 parse합니다.
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
Parser hint 문자열
433-512Codec parser에는 실제 codec/장치 동작에 맞추기 위한 switch와 조정값이 있습니다. Sysfs 또는 patch file의 `hints`로 동적으로 바꿀 수 있습니다. 예를 들어 `jack_detect = no`는 jack detection을 끄고 auto-mute와 mic auto-switch를 건너뜁니다.
Boolean 값에는 `yes`, `no`, `true`, `false`, `1`, `0`을 사용할 수 있습니다.
원문의 지원 hint와 동작을 모두 보존했습니다.
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
state (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
vmaster (bool)
enable/disable the virtual Master control; default true
mixer_nid (int)
specifies the widget NID of the analog-loopback mixer
초기 firmware patch
513-606`CONFIG_SND_HDA_PATCH_LOADER=y`이면 codec 최초 초기화 전에 HD-Audio 설정을 수정하는 text firmware patch를 전달할 수 있습니다. 위 sysfs 재구성과 비슷하지만 첫 codec configuration보다 먼저 적용됩니다.
[codec]
0x12345678 0xabcd1234 2
[model]
auto
[pincfg]
0x12 0x411111f0
[verb]
0x20 0x500 0x03
0x20 0x400 0xff
[hint]
jack_detect = no
`[codec]` 다음 줄에는 vendor ID, subsystem ID, codec address 세 수를 씁니다. 다음 `[codec]` 전까지의 entry가 해당 codec에 적용됩니다. 첫째 또는 둘째 값에 0이나 음수를 주면 그 field 검사를 생략하므로 SSID 초기화가 망가진 장치에 유용합니다.
`[model]`은 codec model 이름을 바꾸며 module option보다 우선합니다. `[pincfg]` 뒤는 `user_pin_configs`, `[verb]` 뒤는 `init_verbs`, `[hint]` 뒤는 `hints` sysfs entry와 같은 형식으로 parse됩니다.
Firmware patch의 section별 역할입니다.
Vendor ID를 `0x12345678`에서 `0xdeadbeef`로 바꾸거나 subsystem/revision/chip name을 바꾸는 예도 제공됩니다.
[codec]
0x12345678 0xabcd1234 2
[vendor_id]
0xdeadbeef
[codec]
0x12345678 0xabcd1234 2
[subsystem_id]
0xffff1111
[revision_id]
0x10
[chip_name]
My-own NEWS-0002
Driver는 `request_firmware()`로 file을 읽으므로 보통 `/lib/firmware`에 둡니다. `patch=hda-init.fw`이면 `/lib/firmware/hda-init.fw`가 있어야 합니다. `patch` option은 card instance별이며 여러 card는 comma로 file name을 구분합니다.
options snd-hda-intel patch=on-board-patch,hdmi-patch
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
607-634Power-saving은 일정 시간 inactive인 device를 자동으로 끄는 auto-suspend입니다. Suspend까지의 시간은 `power_save` module option으로 지정하고 sysfs에서 동적으로 바꿀 수 있습니다.
일부 codec은 analog loopback이 활성화돼 있으면 power-saving이 동작하지 않으므로 필요 없는 signal route를 모두 mute해야 합니다.
장치에 따라 power-down/up 때 click noise가 날 수 있습니다. OpenSUSE 같은 distribution은 전원 cable을 뽑으면 자동으로 power-saving을 켜므로 noise가 들리면 먼저 `/sys/module/snd_hda_intel/parameters/power_save`를 확인합니다. 0이 아니면 기능이 켜진 상태입니다.
최신 kernel은 Intel LynxPoint 같은 일부 HD-Audio controller의 runtime PM도 지원합니다. `power_save_controller` option과 `/sys/module/snd_hda_intel/parameters`에서 강제로 활성화/비활성화할 수 있습니다.
Codec와 controller의 절전 범위를 구분합니다.
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.
Tracepoint와 verb decoding
635-684HD-Audio driver는 CORB write, RIRB response, bus reset, unsolicited event, power transition을 위한 기본 tracepoint를 제공합니다.
각 event가 기록하는 동작입니다.
모든 HDA tracepoint는 다음 명령으로 켭니다. 이후 `/sys/kernel/tracing/trace`에서 기록을 읽습니다.
# echo 1 > /sys/kernel/tracing/events/hda/enable
# cat /sys/kernel/tracing/trace
Trace의 `[0:0]`은 card number와 codec address이고 `val`은 codec으로 보낸 packed value입니다. `hda-emu` package의 `hda-decode-verb`로 해석할 수 있습니다. 예제 `e3a019`는 left output amp 값을 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
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/tracing/events/hda/enable
then after some commands, you can traces from
/sys/kernel/tracing/trace file. For example, when you want to
trace what codec command is sent, enable the tracepoint like:
::
# cat /sys/kernel/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
685-696최신 HD-Audio 개발 code는 `git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git`의 sound git tree에 있습니다.
일반적인 주 개발 branch로 `master` 또는 `for-next`를 사용할 수 있고, 현재 kernel과 다음 kernel을 위한 개발은 각각 `for-linus`와 `for-next`에서 찾을 수 있습니다.
원문이 설명하는 개발 branch 용도입니다.
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.
Bug report 제출
697-719어떤 model이나 module option도 동작하지 않으면 developer에게 bug report를 제출합니다. Hardware vendor/product/model, kernel version, 외부 build라면 ALSA-driver version, `alsa-info.sh --no-upload` 출력을 포함해야 합니다.
Regression이면 동작하는 kernel과 실패하는 kernel 양쪽의 alsa-info 출력이 가장 유용합니다. Codec register를 직접 비교할 수 있기 때문입니다.
원문에 제시된 두 제출 경로입니다.
재현 가능한 최소 정보와 비교 자료를 모읍니다.
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 following:
kernel-bugzilla
https://bugzilla.kernel.org/
alsa-devel ML
alsa-devel@alsa-project.org
Debug tool 개요와 alsa-info
720-761`alsa-info.sh`는 audio device 정보를 수집하는 유용한 script이며 `alsa-utils` package에 포함됩니다. 최신 source는 `git://git.alsa-project.org/alsa-utils.git` 또는 `https://www.alsa-project.org/alsa-info.sh`에서 얻을 수 있습니다.
Root로 실행하면 module 목록/parameter, codec proc-file을 포함한 proc 내용, mixer 출력, control element를 수집합니다. 기본 동작은 alsa-project.org web server에 올리지만 bug report에는 `--no-upload`로 local file을 만들어 첨부하는 편이 좋습니다. 다른 option은 `--help`에서 확인합니다.
Probe error나 명백한 model mismatch에서는 가능하면 cold reboot 후 `probe_only=1`로 driver를 load하고 alsa-info를 실행합니다. Mixer/PCM은 구성하지 않고 codec slot만 probe하므로 driver가 바꾸기 전 raw codec 정보를 얻을 수 있지만 audio에는 사용할 수 없습니다. HDA reconfig가 켜져 있으면 hwdep sysfs로 구성을 계속할 수 있습니다.
`probe_only` mask 2는 HDA codec reset을 생략합니다. Module option으로 `probe_only=3`을 주면 probe-only와 reset 생략을 함께 적용하며, hwdep interface로 BIOS codec 초기화 상태를 조사할 수 있습니다.
Debug용 probing 동작을 구분합니다.
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. It's included in alsa-utils package. The latest
version can be found on git repository:
* git://git.alsa-project.org/alsa-utils.git
The script can be fetched directly from the following URL, too:
* https://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
762-815`hda-verb`는 HD-Audio codec에 raw verb를 직접 실행하는 작은 program입니다. Hwdep device를 사용하므로 미리 `CONFIG_SND_HDA_HWDEP=y`가 필요합니다.
Argument는 hwdep device file, widget NID, verb, parameter 네 개입니다. Card 0의 codec slot 2는 보통 `/dev/snd/hwC0D2`이지만 실제 path는 시스템에 따라 다릅니다. Verb와 parameter는 hex/decimal number 또는 대응 string을 사용할 수 있습니다.
% 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
어떤 verb든 보낼 수 있지만 driver state가 항상 갱신되는 것은 아닙니다. Volume은 driver가 cache하므로 `hda-verb`로 widget amp를 직접 바꿔도 mixer 값은 바뀌지 않습니다.
Program은 현재 `alsa-tools`에 포함됩니다. 구형 standalone package와 `git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-verb.git` repository도 원문에 안내돼 있으며 자세한 내용은 tarball의 README를 봅니다.
네 argument의 순서와 의미입니다.
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와 Codecgraph
816-844`hda-analyzer`는 pyGTK2 binding 기반 GUI로 raw HD-Audio control에 접근합니다. `hda-verb`보다 강력하며 widget 정보 표시, amp 값 조정, proc-compatible 출력을 제공합니다. Alsa-project의 `alsa.git` 안 `hda-analyzer` directory에 있습니다.
Codecgraph는 codec chip의 node 연결을 graph로 시각화하는 utility입니다. Datasheet가 없는 codec 분석/debugging에 특히 유용하며 codec proc-file을 parse해 Graphviz program으로 SVG를 생성합니다.
두 tool의 입력과 결과를 비교합니다.
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:
* https://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
845-880`hda-emu`는 실제 hardware 없이 HD-Audio codec을 debug하는 emulator입니다. 실제 audio I/O 동작을 흉내 내지는 않고 driver probing/operation 과정의 codec register와 ALSA-driver 내부 변경을 dump합니다.
Simulation할 codec proc-file이 필요합니다. 대상 codec의 proc-file을 미리 얻거나 tarball의 collection에서 example을 고른 뒤 file path로 실행합니다.
% 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
....
Command-line interface는 단순하지만 현재 state의 proc dump, mixer control 목록, control 값 set/get, PCM operation, jack plugging simulation 등을 제공합니다. Source는 `git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git`에 있으며 README에 자세한 사용법이 있습니다.
실제 hardware 없이 parser와 fixup 동작을 재현합니다.
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 program is found in the git repository below:
* git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/hda-emu.git
See README file in the repository for more details about hda-emu
program.
hda-jack-retask
881-892`hda-jack-retask`는 jack retasking을 위해 HD-Audio pin control을 조작하는 사용자 친화적 GUI입니다. Jack assignment 문제가 있으면 이 program으로 유효한 pin 배치를 찾을 수 있습니다.
올바른 pin assignment를 확인한 뒤 driver code에 정적으로 반영하거나 `Early Patching` 절의 firmware patch file로 전달할 수 있습니다. Program은 현재 `alsa-tools`에 포함됩니다.
임시 GUI 실험을 재현 가능한 fixup으로 옮깁니다.
hda-jack-retask
---------------
hda-jack-retask is a user-friendly GUI program to manipulate the
HD-audio pin control for jack retasking. If you have a problem about
the jack assignment, try this program and check whether you can get
useful results. Once when you figure out the proper pin assignment,
it can be fixed either in the driver code statically or via passing a
firmware patch file (see "Early Patching" section).
The program is included in alsa-tools now:
* git://git.alsa-project.org/alsa-tools.git
요약·해설
notes.rst:1-892HD-Audio의 controller DMA/IRQ/probing, codec model과 capture/output, sysfs 재구성, parser hint, firmware patch, 절전, tracepoint 및 debugging tool을 종합적으로 설명합니다.
문제 해결의 핵심은 controller 문제와 codec 구성 문제를 분리하는 것입니다. 반복음과 timeout은 DMA 위치/codec slot/interrupt를 먼저 보고, 무음과 jack/mic 문제는 codec proc-file, mixer, pin default, model fixup을 확인합니다.
긴 문서에서 진단 출발점을 빠르게 찾는 표입니다.
비파괴 정보 수집에서 raw verb와 patch로 점진적으로 이동합니다.