History log of /linux-master/sound/pci/hda/hda_generic.h
Revision Date Author Comments
# 64e05321 21-Jul-2023 Richard Fitzgerald <rf@opensource.cirrus.com>

ALSA: hda: Fix missing header dependencies

Add #includes of dependencies into hda_auto_parser.h and hda_generic.h

hda_auto_parser.h uses definitions in hda_local.h.

hda_generic.h uses definitions in hda_local.h and hda_auto_parser.h.
It also references struct hda_jack_callback, but only as a pointer.
This has been forward-declared so hda_jack.h only needs to be
included in source that actually uses it.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20230721132120.5523-11-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 549f8ffc 26-Jan-2022 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Fix UAF of leds class devs at unbinding

The LED class devices that are created by HD-audio codec drivers are
registered via devm_led_classdev_register() and associated with the
HD-audio codec device. Unfortunately, it turned out that the devres
release doesn't work for this case; namely, since the codec resource
release happens before the devm call chain, it triggers a NULL
dereference or a UAF for a stale set_brightness_delay callback.

For fixing the bug, this patch changes the LED class device register
and unregister in a manual manner without devres, keeping the
instances in hda_gen_spec.

Reported-by: Alexander Sergeyev <sergeev917@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.localdomain
Link: https://lore.kernel.org/r/20220126145011.16728-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d13a8f6d 04-Dec-2021 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

ALSA: Fix some typo

Some comments and include guards are not consistent with the name of the
file where they can be found.

This is likely some typo or cut'n'paste issues.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/7b2bcbda298f02a34d46d8b6593daaaed9a09a45.1638602790.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 327b34f2 13-Aug-2021 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Nuke unused reboot_notify callback

As reboot_notify callback is no longer used by the codec core, let's
get rid of the unused code. Conexant codec needs a slight code change
as it used to call the reboot_notify at the codec removal, too.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214045
Link: https://lore.kernel.org/r/20210813081230.4268-4-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e65bf997 17-Mar-2021 Jaroslav Kysela <perex@perex.cz>

ALSA: HDA - remove the custom implementation for the audio LED trigger

With the new snd-ctl-led module, we have a generic way
to trigger audio LEDs based on the sound control changes.

Remove the custom implementation from the HDA driver.

Move the LED initialization before snd_hda_gen_parse_auto_config()
call in all drivers to create marked controls there.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210317172945.842280-5-perex@perex.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 242d990c 27-Nov-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda/generic: Add option to enforce preferred_dacs pairs

The generic parser accepts the preferred_dacs[] pairs as a hint for
assigning a DAC to each pin, but this hint doesn't work always
effectively. Currently it's merely a secondary choice after the trial
with the path index failed. This made sometimes it difficult to
assign DACs without mimicking the connection list and/or the badness
table.

This patch adds a new flag, obey_preferred_dacs, that changes the
behavior of the parser. As its name stands, the parser obeys the
given preferred_dacs[] pairs by skipping the path index matching and
giving a high penalty if no DAC is assigned by the pairs. This mode
will help for assigning the fixed DACs forcibly from the codec
driver.

Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201127141104.11041-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9ab0cb30 17-Jul-2020 Takashi Iwai <tiwai@suse.de>

ALSA: Replace the word "slave" in vmaster API

Follow the recent inclusive terminology guidelines and replace the
word "slave" in vmaster API. I chose the word "follower" at this time
since it seems fitting for the purpose.

Note that the word "master" is kept in API, since it refers rather to
audio master volume control.

Also, while we're at it, a typo in comments is corrected, too.

Link: https://lore.kernel.org/r/20200717154517.27599-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 15509b63 18-Jun-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: generic: Add vmaster mute LED helper

Like mic-mute LED handling, add a new helper to deal with the master
mute LED with LED classdev. Unlike the mic-mute case, the playback
master mute is hooked on vmaster, and we suppose no nested hooks
allowed there.

The classdev creation code is factored out to a common function that
is called from both mute and mic-mute LED helpers.

Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200618110842.27238-9-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fe1a1621 18-Jun-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: generic: Drop the old mic-mute LED hook

Now all users of the old snd_hda_gen_add_micmute_led() have been
converted to the new LED-classdev variant, and we can make it local,
and remove the unused hda_gen_spec.micmute_led.update callback field.

Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200618110842.27238-8-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5fc0f693 18-Jun-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: generic: Drop unused snd_hda_gen_fixup_micmute_led()

The fixup function is no longer used. Let's drop.

Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200618110842.27238-7-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7cdf8c49 18-Jun-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: generic: Add a helper for mic-mute LED with LED classdev

A new helper, snd_hda_gen_add_micmute_led_cdev(), is introduced here
for creating a LED classdev and setting up the hook to the capture
control for controlling the mic-mute LED to follow the capture switch
change. This will replace the existing users of
snd_hda_gen_add_micmute_led() in later patches.

Also, introduce a new kconfig CONFIG_SND_HDA_GENERIC_LEDS, to indicate
the usage of mute / mic-mute LED helpers. It's selected by the codec
drivers (Realtek, Conexant and Sigmatel), while it selects the
necessary LED class dependencies.

Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200618110842.27238-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 89781d08 29-Aug-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda/realtek - Fix overridden device-specific initialization

The recent change to shuffle the codec initialization procedure for
Realtek via commit 607ca3bd220f ("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: 607ca3bd220f ("ALSA: hda/realtek - EAPD turn on later")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 871b9066 13-Aug-2019 Hui Wang <hui.wang@canonical.com>

ALSA: hda - Add a generic reboot_notify

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>


# 62810dbd 20-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 46

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>


# b3802783 26-Nov-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Support led audio trigger

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>


# f567b788 18-Jun-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move mic mute LED helper to the generic parser

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>


# 7480316c 10-Apr-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow to enable/disable vmaster build explicitly

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>


# c4a58c30 08-Dec-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make snd_hda_parse_nid_path() local

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>


# 1e73bf78 08-Dec-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove unused snd_hda_get_nid_path()

An exported helper function snd_hda_get_nid_path() is nowhere used.
Let's remove it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6b275b14 20-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix power of pins used for mute LED with vrefs

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>


# e6feb5d0 16-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Support advanced power state controls

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>


# bbbc7e85 27-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allocate hda_pcm objects dynamically

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>


# 74f14b36 15-Dec-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make add_stereo_mix_input flag tristate

... 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>


# 1a4f69d5 11-Sep-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow multiple callbacks for jack

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>


# 62f949bf 11-Sep-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Get rid of action field from struct hda_jack_tbl

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>


# d89c6c0c 01-Sep-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add TLV_DB_SCALE_MUTE bit for relevant controls

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>


# a8dca460 10-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make snd_hda_gen_spec_free() static

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>


# 7fe30711 30-Jan-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix inconsistent Mic mute LED

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>


# dfc6e469 13-Jan-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Apply codec power_filter to FG nodes

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>


# 3690739b 10-Dec-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add static DAC/pin mapping for AD1986A codec

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>


# a1114a8c 04-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce the bitmask for excluding output volume

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>


# da96fb5b 29-Jul-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix invalid multi-io creation on VAIO-Z laptops

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>


# 7eebffd3 24-Jun-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add auto_mute_via_amp flag to generic parser

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>


# 05909d5c 31-May-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add keep_eapd_on flag to generic parser

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>


# 98bd1115 22-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow codec drivers to give own badness tables

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>


# 7504b6cd 18-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move beep attach/detach calls in hda_generic.c

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>


# 8ba955ce 07-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid automatic pin-ctl update for hp/mic when jack ctl exists

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>


# f811c3cf 07-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Consolidate add_in_jack_modes and add_out_jack_modes hints

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>


# 967303da 19-Feb-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add the generic Headphone Mic feature

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>


# 0186f4f4 07-Feb-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use generic array for loopback list management

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 46a14481 07-Feb-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Enable loopback accounts for CONFIG_PM=n, too

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>


# 55196fff 24-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Implement path-based power filter to the generic parser

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>


# e4a395e7 23-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix missing path between aamix and outputs in AD codecs

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>


# a607148f 21-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Set individual name to secondary analog PCM stream

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>


# a1e908ed 21-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix conflicts between Loopback Mixing and Independent HP

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>


# cf799aa3 18-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Correct more array rooms in hda_gen_spec

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>


# d3d982f7 18-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - make sure there are enough input labels and paths

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>


# a90229e0 18-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Consolidate cap_sync_hook and capture_switch_hook

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>


# c970042c 18-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Unify input label creations in generic parser

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>


# ac2e8736 17-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add PCM capture hook to hda_gen_spec

Not only PCM playback, a hook for PCM capture would be required for
power controls in codec drivers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0ffd534e 17-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Record all detected ADCs in hda_gen_spec

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>


# 7a71bbf3 17-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move vmaster TLV parsing to snd_hda_gen_parse_auto_config()

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>


# 29476558 17-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add input jack mode enum controls to generic parser

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>


# acc47aaf 16-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Give more comments to hda_gen_spec flags

Since we have many bit flags in hda_gen_spec, rearrange in sections
and give more comments there.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f72706be 16-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add suppress_auto_mute flag to hda_gen_spec

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>


# 47b9ddb8 16-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Record the current speaker / LO mute status in hda_gen_spec

... to be referred by the codec driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ea46c3c8 15-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add prefer_hp_amp flag to hda_gen_spec

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>


# ae177c3f 13-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add capture_switch_hook to generic parser

Add a hook for the capture mixer switch. This will be used by IDT
codecs for controlling the mic-mute LED.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 978e77e7 10-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add output jack mode enum controls

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>


# f3fc0b0b 09-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow aamix as a capture source

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>


# d12daf6f 07-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add a flag to suppress mic auto-switch

Add a new flag spec->suppress_mic_auto_switch for codecs that don't
support unsol events properly like VT1708.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3ca529d3 07-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Re-define snd_hda_parse_nid_path()

This commit modifies the definition of snd_hda_parse_nid_path()
slightly, now with_aa_mix argument is changed to anchor_nid, so that
it can handle any NID generically as an anchor point to include or
exclude.

The with_aa_mix field in struct nid_path is removed again by this
change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c697b716 07-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Manage input paths via path indices

... like we did for output and loopback paths.
It makes the code slightly easier.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a07a949b 07-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix multi-io channel mode management

The multi-io channels can vary not only from 1 to 6 but also may vary
from 6 to 8 or such. At the same time, there are more speaker pins
available than the primary output pins. So, we need three variables
to check: the minimum channel counts for primary outputs, the current
channel counts for primary outputs, and the minimum channel counts for
all outputs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fce52a3b 06-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_gen_free() and snd_hda_gen_check_power_status()

Just to remove duplicated codes.
Also fixed EXPORT_SYMBOL() in hda_generic.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e6b85f3c 07-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add pcm_playback_hook to hda_gen_spec

The new hook which is called at each PCM playback ops.
It can be used to control the codec-specific power-saving feature in
each codec driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c2c80383 07-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Drop bind-volume workaround

The bind-volume workaround was introduced for simplifying the mixer
abstraction in the case where one or more pins of multiple outputs
lack of individual volume controls. This was essentially the case
like Acer Aspire 5935, which has 5.1 speakers and 5.1 (multi-io)
jacks although there are 5 DACs, so some of them must share a DAC.

However, the recent code rewrite changed the DAC assignment policy to
share with the same channel instead of binding to the front, thus
binding the volumes for all channels makes little sense now, rather
it's confusing. So in this patch, the ugly workaround is finally
dropped and simply create the volume control corresponding to the
parsed path position.

For dual headphones or 2.1 speakers with a shared volume control, it's
anyway bound to the same DAC if needed, so this change shouldn't bring
any practical difference.

And, as a good bonus, we can cut off the whole code handling the bind
volume elements.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c30aa7b2 04-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add Loopback Mixing control

For codecs that have individual routes going through a loopback mixer
(like VIA codecs), we need to provide an explicit switch to choose
whether the output goes through mixer or directly from DAC.

This patch adds the check for such paths and creates "Loopback Mixing"
enum control when available.

It won't influence on codecs like Realtek or others where the loopback
mixer is connected independently from the primary output routes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2430d7b7 04-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Initialize digital-input path properly

Call the path activation for the digital input pin properly, not only
setting the pin control. Also add spec->digin_path for keeping the
path index.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 196c1766 04-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Manage using output/loopback path indices

Instead of search for the path with the certain route at each time,
keep the path index for each output and loopback, and just use it when
referred.

In this implementation, the path index number begins with one, not
zero (although I've been writing in C over decades). It's just to
make the check for uninitialized values easier.

So far, the input paths aren't handled with indices yet, but still
picked up via snd_hda_get_nid_path() at each time.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f5172a7e 04-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check the existing path in snd_hda_add_new_path()

If the requested path has been already added, return the existing path
instance instead of adding a duplicated instance.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2e03e952 03-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add hooks for HP/line/mic auto switching

... as a preliminary work for migrating patch_sigmatel.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 38cf6f1a 21-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Implement independent HP control

Similar like the implementation in patch_analog.c and patch_via.c,
the generic parser can provide the independent HP PCM stream now.
It's enabled when spec->indep_hp is set by the caller while parsing.

Currently no dynamic PCM switching as in patch_via.c is implemented
yet. The control returns -EBUSY when the value is changed during PCM
operations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4ac0eefa 20-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Define HDA_PARSE_* for snd_hda_parse_nid_path() argument

... instead of numbers.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 545502de 20-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Drop spec->channel_mode field from hda_gen_spec

It's never used in the generic parser. It was there from the old
Realtek code, which has been dropped quite ago, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fd25a97a 20-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add spec->vmaster_mute_enum flag to generic parser

Add a flag to indicate whether the vmaster mute hook enum is exposed
or not. Conexant codecs may want not to expose the control depending
on the model.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 406b285d 20-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Begin HDA_GEN_* event tag from 1

... to distinguish from the invalid event type.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d94ddd85 20-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Increase the max depth of widget connections

Old codecs like AD1986A tend to have long paths as they were just made
to be the way like AC97. The current max depth 5 can be too short for
such devices.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5d550e15 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Export standard jack event handlers for generic parser

These handlers are supposed to be called externally from the codec
drivers once when they need to handle own jack events.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9eb413e5 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move the call of snd_hda_parse_pin_defcfg() from snd_hda_gen_parse_auto_config()

In some cases, we want to manipulate the auto_pin_cfg table before
passing to snd_hda_gen_parse_auto_config() (e.g. Realtek SSID check
code fiddles with the headphone pin). Also passing ignore_pins just
for snd_hda_parse_pin_defcfg() isn't good.

In this patch, snd_hda_gen_parse_auto_config() is changed to receive
the auto_pin_cfg table to be parsed. The passed auto_pin_cfg table
must have been initialized (typically by calling
snd_hda_gen_parse_auto_config()) beforehand by the caller.

Also together with this change, spec->parse_flags is also removed.
Since this was referred only at the place calling
snd_hda_parse_pin_defcfg(), no longer needed to be kept in spec.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 12c93df6 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Export snd_hda_gen_add_kctl()

It may be used in other codec drivers, so let it free.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 731dc301 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add EAPD control to generic parser

Enable EAPD in output path initializations automatically unless the
new flag spec->own_eapd_ctl is set.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 352f7f91 18-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Merge Realtek parser code to generic parser

Finally the whole generic parser code in Realtek driver is moved into
hda_generic.c so that it can be used for generic codec driver.
The old dumb generic driver is replaced. Yay.

The future plan is to adapt this generic parser for other codecs,
i.e. the codec driver calls the exported functions in generic driver
but adds some codec-specific fixes and setups.

As of this commit, the complete driver code is still duplicated in
Realtek codec driver. The big code reduction will come from now on.

Signed-off-by: Takashi Iwai <tiwai@suse.de>