The recent change to shuffle the codec initialization procedure for
Realtek via commit 607ca3bd22 ("ALSA: hda/realtek - EAPD turn on
later") caused the silent output on some machines. This change was
supposed to be safe, but it isn't actually; some devices have quirk
setups to override the EAPD via COEF or BTL in the additional verb
table, which is applied at the beginning of snd_hda_gen_init(). And
this EAPD setup is again overridden in alc_auto_init_amp().
For recovering from the regression, tell snd_hda_gen_init() not to
apply the verbs there by a new flag, then apply the verbs in
alc_init().
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=204727
Fixes: 607ca3bd22 ("ALSA: hda/realtek - EAPD turn on later")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Make codec enter D3 before rebooting or poweroff can fix the noise
issue on some laptops. And in theory it is harmless for all codecs
to enter D3 before rebooting or poweroff, let us add a generic
reboot_notify, then realtek and conexant drivers can call this
function.
Cc: stable@vger.kernel.org
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Based on 1 normalized pattern(s):
this driver is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license or at
your option any later version
extracted by the scancode license scanner the SPDX license identifier
GPL-2.0-or-later
has been chosen to replace the boilerplate/reference in 5 file(s).
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190520170858.461662648@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Now all relevant platform drivers are providing the LED audio trigger,
we can switch the mute LED control with the LED trigger, finally.
For the mic-mute LED trigger, a common fixup function,
snd_hda_gen_fixup_micmute_led(), is provided to be called for the
corresponding quirk entries. This sets up the capture sync hook with
ledtrig_audio_set() call appropriately.
For the mute LED trigger, which is done currently only for
thinkpad_acpi, the call is replaced with ledtrig_audio_set() as well.
Overall, the beauty of the new implementation is that the whole ugly
bindings with request_symbol() are dropped, and also that it provides
more flexibility to users.
One potential behavior change by this patch is that the mute LED enum
may be created on machines that actually have no LED device. In the
former code, we did test-call and abort binding if the test failed.
But with the LED-trigger binding, this test isn't possible, and the
actual check is done in the LED class device side. So it's the
downside of simpleness.
Also, note that the HD-audio codec driver doesn't select CONFIG_LEDS
and co by itself. It's supposed to be selected by the platform
drivers instead.
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Move the code for setting up and controlling the mic mute LED hook
from dell-wmi helper to the generic parser, so that it can be referred
from the multiple driver codes.
No functional change.
Tested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Another preliminary patch for the dual-codec support: since the
support of vmaster over multiple codecs is difficult, simply disable
it by a new flag to hda_codec struct. A new user hint is added as
well for consistency.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
An exported function snd_hda_parse_nid_path() is used only inside
hda_generic.c. Let's make it a static local function for a better
code optimization.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Some pins are used for controlling the LED with the VREF value.
This patch changes the power behavior of such pins to be constantly
up. A new state, pin_fixed, is introduced to nid_path to indicate
that the path contains the fixed pin. This improves also the
readability a bit for other static routes, too.
Then a helper function snd_hda_gen_fix_pin_power() is called from the
codec driver for such fixed pins, and it will create fake paths
containing only these pins with pin_fixed=1 flag.
Reported-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch enables the finer power state control of each widget
depending on the jack plug state and streaming state in addition to
the existing power_down_unused power optimization. The new feature is
enabled only when codec->power_mgmt flag is set.
Two new flags, pin_enabled and stream_enabled, are introduced in
nid_path struct for marking the two individual power states: the pin
plug/unplug and DAC/ADC stream, respectively. They can be set
statically in case they are static routes (e.g. some mixer paths),
too.
The power up and down events for each pin are triggered via the
standard hda_jack table. The call order is hard-coded, relying on the
current implementation of jack event chain (a la FILO/stack order).
One point to be dealt carefully is that DAC/ADC cannot be powered
on/off while streaming. They are pinned as long as the stream is
running. For controlling the power of DAC/ADC, a new patch_ops is
added. The generic parser provides the default callback for that.
As of this patch, only IDT/Sigmatel codec driver enables the flag.
The support on other codecs will follow.
An assumption we made in this code is that the widget state (e.g. amp,
pinctl, connections) remains after the widget power transition (not
about FG power transition). This is true for IDT codecs, at least.
But if the widget state is lost at widget power transition, we'd need
to implement additional code to sync the cached amp/verbs for the
specific NID.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
So far, the hda_codec object kept the hda_pcm list in an array, and
the codec driver was expected to assign the array. However, this
makes the object life cycle management harder, because the assigned
array is freed at the codec driver detach while it might be still
accessed by the opened streams.
In this patch, we allocate each hda_pcm object dynamically and manage
it as a linked list. Each object has a kref refcount, and both the
codec driver binder and the PCM open/close touches it, so that the
object won't be freed while in use.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
... for distinguishing whether it's explicitly enabled via a user hint
or enabled by a driver as a fallback. Now the former case corresponds
to HDA_HINT_STEREO_MIX_ENABLE while the latter to
HDA_HINT_STEREO_MIX_AUTO.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
So far, hda_jack infrastructure allows only one callback per jack, and
this makes things slightly complicated when a driver wants to assign
multiple tasks to a jack, e.g. the standard auto-mute with a power
up/down sequence. This can be simplified if the hda_jack accepts
multiple callbacks.
This patch is such an extension: the callback-specific part (the
function and private_data) is split to another struct from
hda_jack_tbl, and multiple such objects can be assigned to a single
hda_jack_tbl entry.
The new struct hda_jack_callback is passed to each callback function
now, thus the patch became bigger than expected. But these changes
are mostly trivial.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The action value assigned to each hda_jack_tbl entry is mostly
superfluous. The actually used values are either the widget NID or a
value specific to the callback.
The former case can be simply replaced by a reference to widget NID
itself. The only place doing the latter is STAC/IDT codec driver for
the powermap handling. But, the code doesn't need to check the action
field at all -- the function jack_update_power() is called either with
a specific pin or with NULL. So the check of jack->action can be
removed completely there, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The DACs on Sigmatel/IDT codecs do mute at the lowest volume level,
and in the earlier drivers, we passed TLV_DB_SCALE_MUTE bit for each
volume control element like Speaker and Headphone as well as Master.
Along with the translation to the generic parser, however, the TLV bit
was lost for the slave controls (e.g. Speaker) but set only to
Master. In theory this should have sufficed, but apps, particularly
PA, do care the slave volume bits, so we seem to see a regression in
the volume controls.
This patch adds a flag to hda_gen_spec to specify the DAC mute
feature, and adds the TLV bit properly for all relevant volume
controls. Also, the TLV bit for vmaster is set in hda_generic.c, so
that we can get rid of all tricks from the codec driver side.
As the similar hack is applied to Conexant 5051 stuff, we can get rid
of it as well.
BugLink: https://bugs.launchpad.net/bugs/1357928
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The last user of snd_hda_gen_spec_free() is patch_via.c, and we can
rewrite it safely with snd_hda_gen_free(), so that
snd_hda_gen_spec_free() can be a local function in hda_generic.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The current code for controlling mic mute LED in patch_sigmatel.c
blindly assumes that there is a single capture switch. But, there can
be multiple multiple ones, and each of them flips the state, ended up
in an inconsistent state.
For fixing this problem, this patch adds kcontrol to be passed to the
hook function so that the callee can check which switch is being
accessed. In stac_capture_led_hook(), the state is checked as a
bitmask, and turns on the LED when all capture switches are off.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Apply the codec->power_filter to the FG nodes in general for reducing
hackish set_power_state ops override in patch_sigmatel.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
AD1986A codec is a pretty old codec and has really many hidden
restrictions. One of such is that each DAC is dedicated to certain
pin although there are possible connections. Currently, the generic
parser tries to assign individual DACs as much as possible, and this
lead to two bad situations: connections where the sound actually
doesn't work, and connections conflicting other channels.
We may fix this by trying to find the best connections more harder,
but as of now, it's easier to give some hints for paired DAC/pin
connections and honor them if available, since such a hint is needed
only for specific codecs (right now only AD1986A, and there will be
unlikely any others in future).
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64971
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=66621
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a bitmask to hda_gen_spec indicating NIDs to exclude from the
possible volume controls. That is, when the bit is set, the NID
corresponding to the bit won't be picked as an output volume control
any longer.
Basically this is just a band-aid for working around the issue found
with CS4208 codec, where only the headphone pin has a volume AMP with
different dB steps.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=60811
Cc: <stable@vger.kernel.org> [v3.12+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
VAIO-Z laptops need to use the specific DAC for the speaker output
by some unknown reason although the codec itself supports the flexible
connection. So we implemented a workaround by a new flag,
no_primary_hp, for assigning the speaker pin first.
This worked until 3.8 kernel, but it got broken because the driver
learned for a better multi-io pin mapping, and not it can assign two
mic pins for multi-io. Since the multi-io requires to be the primary
output, the hp and two mic pins are assigned in prior to the speaker
in the end.
Although the machine has two mic pins, one of them is used as a noise-
canceling headphone, thus it's no real retaskable mic jack. Thus, at
best, we can disable the multi-io assignment and make the parser
behavior back to the state before the multi-io.
This patch adds again a new flag, no_multi_io, to indicate that the
device has no multi-io capability, and set it in the fixup for
VAIO-Z. The no_multi_io flag itself can be used generically, added
via a helper line, too.
Reported-by: Tormen <my.nl.abos@gmail.com>
Reported-by: Adam Williamson <awilliam@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a new flag, auto_mute_via_amp, to determine the behavior of the
headphone / line-out auto-mute. When this flag is set, the generic
driver mutes the speaker and line outputs via the amp mute of each
pin, instead of changing the pin control values.
This is introduced for devices that don't work expectedly with the pin
control values; for example, some devices are known to keep enabling
the speaker outputs no matter which pin control values are set on the
speaker pins.
The driver doesn't check actually whether the pins have the output amp
caps, but assumes that the proper mixer (mute) controls are created on
all these pins. If not the case, you can't use this flag for your
device.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
VT1802 codec seems to reset EAPD of other pins in the hardware level,
and this was another reason of the silent headphone output on some
machines. As a workaround, introduce a new flag indicating to keep
the EPAD on to the generic parser, and set it in patch_via.c.
Reported-by: Alex Riesen <raa.lkml@gmail.com>
Cc: <stable@vger.kernel.org> [v3.9]
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The standard badness values don't seem to fit to all preferences.
Some configuration prefer the side output over the headphone, some
want the speaker over the surround, etc.
This patch moves the badness table pointers into hda_gen_spec, so that
the codec driver can override them.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Instead of calling snd_hda_attach_beep_device() and
snd_hda_detach_beep_device() in each codec driver, move them to the
generic parser. The codec driver just needs to set spec->beep_nid for
activating the digital beep.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
When the headphone mic jack enum control is created (via explicitly
specification by user), it doesn't make much sense to change the I/O
direction dynamically per capture source change, since the I/O
direction is rather controlled over the enum ctl.
This also reduces the implicit dependency between the capture source
and the hp mic jack enum ctls, which might confuse a program accessing
the whole control elements at once like alsactl.
In addition, this patch introduces update_hp_automute_hook() function
to call the proper hook function. It's just to remove the open codes
in multiple places in hda_generic.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
There is no big merit to distinguish these two hints. Instead, just
have a single flag, add_jack_modes, for creating the jack mode enum
ctls for both I/O directions.
The hint string parser code is left and translated as add_jack_modes
just for keeping compatibility.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch improves the generic parser code to allow to set up the
headphone jack as a mic input. User can enable this feature by giving
hp_mic hint string.
The former shared hp/mic feature for the single built-in mic is still
retained. This detection can be disabled now via hp_mic_detect hint
string, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
The loopback list is referred by the VIA codec driver no matter
whether CONFIG_PM is set or not, thus we need to enable it always.
Otherwise it gets compile errors.
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch adds a better power filter hook for powering down unused
widgets in the generic parser.
The feature is enabled by setting hda_gen_spec.power_down_unused
flag.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
AD1988 family and AD1882 codecs have another mixer widget (0x21)
between the analog-loopback mixer widget (0x20) and the actual
outputs. Due to this hole, the analog-loopbacks aren't sent properly
to the output pins.
As a band-aid fix, introduce another fields holding the aamix merge
path, and activate it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
It'd be better to give another name to the secondary (alt) analog PCM
stream, which is dedicated for the independent HP out and extra
inputs.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This patch eventually fixes two issues:
- Handle the case where the primary output is a headphone and can have
independent HP mode;
so far we checked only the case where the headphone is the secondary
output.
- Fix the conflict of HP independent mode and aamix mode;
when switched to aamix mode, the DAC might be also switched to
another widget shared with other outputs. Then even if we disable
the DAC for the original output, it doesn't change -- because the
active route is from another (shared) DAC to HP pin through aamix.
So, in such a case, we have to prohibit the switch to aamix for HP
routes.
This fixes issues appearing on VT codecs.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Looking through the whole definitions, some fields have inappropriate
array sizes, especially about the capture. The array assigned to each
input (pin) should have HDA_MAX_NUM_INPUTS entries while the array
assigned to each ADC should have AUTO_CFG_MAX_INS entries.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
I found a codec configuration which had six inputs, so the max of
five was not appropriate.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Two hooks in hda_gen_spec, cap_sync_hook and capture_switch_hook, play
very similar roles. The only differences are that the former is
called more often (e.g. at init or switching capsrc) while the latter
can take an on/off argument.
As a more generic implementation, consolidate these two hooks, and
pass snd_ctl_elem_value pointer as the second argument. If the
secondary argument is non-NULL, it can take the on/off value, so the
caller handles it like the former capture_switch_hook. If it's NULL,
it's called in the init or capsrc switch case.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
There are a few places creating the labels and indices of kctls for
each input pin in the current generic parser code. This is redundant
and makes harder to maintain. Let's create the labels and indices at
once and keep them in hda_gen_spec.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since the generic parser reduces the ADC list, copy the list of the
all detected ADCs and keep it.
This list can be later referred by the codec driver for finer power
controls.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add vmaster_tlv[] to hda_gen_spec and store the suggested TLV data
in snd_hda_gen_parse_auto_config(). This allows the codec driver to
correct the TLV data (e.g. mute capability) before actually creating
vmaster instance.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Just like the jack mode enum ctls for output jacks, add the support
for similar enum ctls for input pins to control the bias Vref.
The new controls will be added when spec->add_in_jack_modes is set
either by the codec driver or by a hint string.
Note that ground and 100% vrefs are excluded from the list for
simplicity, currently. We may add a new flag to allow them, too.
But I guess it's easier to put a value override in the pinfix in such
a case.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
A new flag to skip the auto-mute handling in the generic parser, just
like suppress_auto_mic flag. It has to be set before calling
snd_hda_gen_parse_auto_config().
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add a new flag to indicate whether HP amp is turned on as default for
speaker or line-outs, and enable this for ALC260 codec, as many
machines with this codec require the HP amp even for speakers.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Add the enum controls for changing the headphone amp bits of output
jacks, such as "Headphone Jack Mode". This feature isn't enabled as
default, so far, unless spec->add_out_jack_modes flag is set.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Since some codecs can choose the aamix as a capture source, we should
support it as well. When spec->add_stereo_mix_input flag is set, the
parser checks the availability of aamix as the input source, and adds
the paths automatically when possible.
Signed-off-by: Takashi Iwai <tiwai@suse.de>