History log of /linux-master/sound/pci/hda/hda_generic.c
Revision Date Author Comments
# 19adbe96 13-Jan-2024 Heiner Kallweit <hkallweit1@gmail.com>

ALSA: hda: generic: Remove obsolete call to ledtrig_audio_get

Since 64f67b5240db ("leds: trigger: audio: Add an activate callback to
ensure the initial brightness is set") the audio triggers have an
activate callback which sets the LED brightness as soon as the
(default) trigger is bound to the LED device. So we can remove the
call to ledtrig_audio_get.

Positive side effect: We have no code dependency to ledtrig-audio any
longer, therefore, if built as module, it's no longer loaded if not
needed.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/3dc9167d-fb33-43a6-baa6-dbef8b5da7b9@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5f6af005 15-Sep-2023 Takashi Iwai <tiwai@suse.de>

ALSA: hda: generic: Check potential mixer name string truncation

add_control_with_pfx() constructs a mixer name element with the fixed
size, and it got compile warnings with -Wformat-truncation.

Although the size overflow is very unlikely, let's have a sanity check
of the string size and returns the error if it really doesn't fit
instead of silent truncation.

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


# 3b44ec8c 16-May-2023 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Fix Oops by 9.1 surround channel names

get_line_out_pfx() may trigger an Oops by overflowing the static array
with more than 8 channels. This was reported for MacBookPro 12,1 with
Cirrus codec.

As a workaround, extend for the 9.1 channels and also fix the
potential Oops by unifying the code paths accessing the same array
with the proper size check.

Reported-by: Olliver Schinagl <oliver@schinagl.nl>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/64d95eb0-dbdb-cff8-a8b1-988dc22b24cd@schinagl.nl
Link: https://lore.kernel.org/r/20230516184412.24078-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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


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


# a2befe93 11-Aug-2021 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - fix the 'Capture Switch' value change notifications

The original code in the cap_put_caller() function does not
handle correctly the positive values returned from the passed
function for multiple iterations. It means that the change
notifications may be lost.

Fixes: 352f7f914ebb ("ALSA: hda - Merge Realtek parser code to generic parser")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=213851
Cc: <stable@kernel.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20210811161441.1325250-1-perex@perex.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e73b4c9e 13-May-2021 Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

ALSA: hda: generic: Remove redundant assignment to dac

Variable dac is set to zero, but this value is never read as it is
overwritten or not used later on, hence it is a redundant assignment
and can be removed.

Clean up the following clang-analyzer warning:

sound/pci/hda/hda_generic.c:1436:4: warning: Value stored to 'dac' is
never read [clang-analyzer-deadcode.DeadStores].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/1620904271-76027-1-git-send-email-jiapeng.chong@linux.alibaba.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 08a4b904 31-May-2021 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Fix a regression in Capture Switch mixer read

The recent commit to drop the HDA-specific mute-LED control,
e65bf99718b5 ("ALSA: HDA - remove the custom implementation for the
audio LED trigger"), caused a regression on the mixer element read for
"Capture Switch" when it's built from bind controls. The function
create_bind_cap_vol_ctl() creates the snd_kcontrol_new object directly
via snd_hda_gen_add_kctl() instead of add_control(). Although the
commit above added a workaround for the SNDRV_CTL_ACCESS_READWRITE in
add_control() as default, this code path fell out from the radar. As
a result, now the driver gives -EPERM error because of the lack of the
proper access bit at reading "Capture Switch" element value.

Fix the regression by setting the access bit properly.

Fixes: e65bf99718b5 ("ALSA: HDA - remove the custom implementation for the audio LED trigger")
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1186634
Link: https://lore.kernel.org/r/20210531180633.27831-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f48652bb 04-May-2021 Hui Wang <hui.wang@canonical.com>

ALSA: hda: generic: change the DAC ctl name for LO+SPK or LO+HP

Without this change, the DAC ctl's name could be changed only when
the machine has both Speaker and Headphone, but we met some machines
which only has Lineout and Headhpone, and the Lineout and Headphone
share the Audio Mixer0 and DAC0, the ctl's name is set to "Front".

On most of machines, the "Front" is used for Speaker only or Lineout
only, but on this machine it is shared by Lineout and Headphone,
This introduces an issue in the pipewire and pulseaudio, suppose users
want the Headphone to be on and the Speaker/Lineout to be off, they
could turn off the "Front", this works on most of the machines, but on
this machine, the "Front" couldn't be turned off otherwise the
headphone will be off too. Here we do some change to let the ctl's
name change to "Headphone+LO" on this machine, and pipewire and
pulseaudio already could handle "Headphone+LO" and "Speaker+LO".
(https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/747)

BugLink: http://bugs.launchpad.net/bugs/804178
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20210504073917.22406-1-hui.wang@canonical.com
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>


# 2bf44e0e 11-Mar-2021 Hui Wang <hui.wang@canonical.com>

ALSA: hda: generic: Fix the micmute led init state

Recently we found the micmute led init state is not correct after
freshly installing the ubuntu linux on a Lenovo AIO machine. The
internal mic is not muted, but the micmute led is on and led mode is
'follow mute'. If we mute internal mic, the led is keeping on, then
unmute the internal mic, the led is off. And from then on, the
micmute led will work correctly.

So the micmute led init state is not correct. The led is controlled
by codec gpio (ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), in the
patch_realtek, the gpio data is set to 0x4 initially and the led is
on with this data. In the hda_generic, the led_value is set to
0 initially, suppose users set the 'capture switch' to on from
user space and the micmute led should change to be off with this
operation, but the check "if (val == spec->micmute_led.led_value)" in
the call_micmute_led_update() will skip the led setting.

To guarantee the led state will be set by the 1st time of changing
"Capture Switch", set -1 to the init led_value.

Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20210312041408.3776-1-hui.wang@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3531ba21 01-Mar-2021 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hda: fix kernel-doc warnings

v5.12-rc1 flags new warnings with make W=1, fix missing or broken
function descriptors.

sound/pci/hda/hda_codec.c:3492: warning: expecting prototype for
snd_hda_input_mux_info_info(). Prototype was for
snd_hda_input_mux_info() instead

sound/pci/hda/hda_codec.c:3521: warning: expecting prototype for
snd_hda_input_mux_info_put(). Prototype was for
snd_hda_input_mux_put() instead

sound/pci/hda/hda_codec.c:3958: warning: expecting prototype for
_snd_hda_pin_ctl(). Prototype was for _snd_hda_set_pin_ctl() instead

sound/pci/hda/hda_jack.c:223: warning: expecting prototype for
snd_hda_set_dirty_all(). Prototype was for
snd_hda_jack_set_dirty_all() instead

sound/pci/hda/hda_jack.c:309: warning: expecting prototype for
snd_hda_jack_detect_enable_mst(). Prototype was for
snd_hda_jack_detect_enable_callback_mst() instead

sound/pci/hda/hda_generic.c:3933: warning: expecting prototype for
snd_dha_gen_add_mute_led_cdev(). Prototype was for
snd_hda_gen_add_mute_led_cdev() instead

sound/pci/hda/hda_generic.c:4093: warning: expecting prototype for
snd_dha_gen_add_micmute_led_cdev(). Prototype was for
snd_hda_gen_add_micmute_led_cdev() instead

sound/pci/hda/patch_ca0132.c:2357: warning: expecting prototype for
Prepare and send the SCP message to DSP(). Prototype was for
dspio_scp() instead

sound/pci/hda/patch_ca0132.c:2883: warning: expecting prototype for
Allocate router ports(). Prototype was for dsp_allocate_router_ports()
instead

sound/pci/hda/patch_ca0132.c:3202: warning: expecting prototype for
Write a block of data into DSP code or data RAM using pre(). Prototype
was for dspxfr_one_seg() instead

sound/pci/hda/patch_ca0132.c:3397: warning: expecting prototype for
data overlay to DSP memories(). Prototype was for dspxfr_image()
instead

sound/hda/hdac_regmap.c:393: warning: expecting prototype for
snd_hdac_regmap_init(). Prototype was for snd_hdac_regmap_exit()
instead

sound/hda/ext/hdac_ext_controller.c:142: warning: expecting prototype
for snd_hdac_ext_bus_get_link_index(). Prototype was for
snd_hdac_ext_bus_get_link() instead

sound/hda/ext/hdac_ext_stream.c:140: warning: expecting prototype for
snd_hdac_ext_linkstream_start(). Prototype was for
snd_hdac_ext_link_stream_start() instead

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20210301174617.116960-1-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 75b1a8f9 04-Jan-2021 Joe Perches <joe@perches.com>

ALSA: Convert strlcpy to strscpy when return value is unused

strlcpy is deprecated. see: Documentation/process/deprecated.rst

Change the calls that do not use the strlcpy return value to the
preferred strscpy.

Done with cocci script:

@@
expression e1, e2, e3;
@@

- strlcpy(
+ strscpy(
e1, e2, e3);

This cocci script leaves the instances where the return value is
used unchanged.

After this patch, sound/ has 3 uses of strlcpy() that need to be
manually inspected for conversion and changed one day.

$ git grep -w strlcpy sound/
sound/usb/card.c: len = strlcpy(card->longname, s, sizeof(card->longname));
sound/usb/mixer.c: return strlcpy(buf, p->name, buflen);
sound/usb/mixer.c: return strlcpy(buf, p->names[index], buflen);

Miscellenea:

o Remove trailing whitespace in conversion of sound/core/hwdep.c

Link: https://lore.kernel.org/lkml/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com
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>


# c7fabbc5 05-Aug-2020 Randy Dunlap <rdunlap@infradead.org>

ALSA: pci: delete repeated words in comments

Drop duplicated words in sound/pci/.
{and, the, at}

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Link: https://lore.kernel.org/r/20200806021926.32418-1-rdunlap@infradead.org
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>


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

ALSA: hda: Let LED cdev handling suspend/resume

Set LED_CORE_SUSPENDRESUME to LED cdev flags, so that the LED core
would store and restore the LED status at suspend/resume.

In theory, the codec driver should be responsible for all LED bits,
but this might be safer and cover the overlooked cases.

Tested-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200618110842.27238-14-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>


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

ALSA: hda: generic: Always call led-trigger for mic mute LED

Instead of adding a special hook to trigger the mic-mute LED device,
call it always from the common callback function. It won't hurt even
if no corresponding led cdev is present.

This is basically a preliminary change for the later patches to
convert the all mic-mute LED handling to LED class cdev.

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


# 4f5c2653 13-Jan-2020 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hda: correct kernel-doc parameter descriptions

make W=1 throws warnings, provide missing documentation

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200113211405.28070-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1a462be5 09-Jan-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Manage concurrent reg access more properly

In the commit 8e85def5723e ("ALSA: hda: enable regmap internal
locking"), we re-enabled the regmap lock due to the reported
regression that showed the possible concurrent accesses. It was a
temporary workaround, and there are still a few opened races even
after the revert. In this patch, we cover those still opened windows
with a proper mutex lock and disable the regmap internal lock again.

First off, the patch introduces a new snd_hdac_device.regmap_lock
mutex that is applied for each snd_hdac_regmap_*() call, including
read, write and update helpers. The mutex is applied carefully so
that it won't block the self-power-up procedure in the helper
function. Also, this assures the protection for the accesses without
regmap, too.

The snd_hdac_regmap_update_raw() is refactored to use the standard
regmap_update_bits_check() function instead of the open-code. The
non-regmap case is still open-coded but it's an easy part. The all
read and write operations are in the single mutex protection, so it's
now race-free.

In addition, a couple of new helper functions are added:
snd_hdac_regmap_update_raw_once() and snd_hdac_regmap_sync(). Both
are called from HD-audio legacy driver. The former is to initialize
the given verb bits but only once when it's not initialized yet. Due
to this condition, the function invokes regcache_cache_only(), and
it's now performed inside the regmap_lock (formerly it was racy) too.
The latter function is for simply invoking regcache_sync() inside the
regmap_lock, which is called from the codec resume call path.
Along with that, the HD-audio codec driver code is slightly modified /
simplified to adapt those new functions.

And finally, snd_hdac_regmap_read_raw(), *_write_raw(), etc are
rewritten with the helper macro. It's just for simplification because
the code logic is identical among all those functions.

Tested-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200109090104.26073-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# caf3c043 03-Jan-2020 Michał Mirosław <mirq-linux@rere.qmqm.pl>

ALSA: hda - constify and cleanup static NodeID tables

Make hda_nid_t tables static const, as they are not intended to be
modified by callees.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/5150c94101c9534f4c8e987324f6912c16d459f6.1578043216.git.mirq-linux@rere.qmqm.pl
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>


# cfef67f0 09-Aug-2019 Wenwen Wang <wenwen@cs.uga.edu>

ALSA: hda - Fix a memory leak bug

In snd_hda_parse_generic_codec(), 'spec' is allocated through kzalloc().
Then, the pin widgets in 'codec' are parsed. However, if the parsing
process fails, 'spec' is not deallocated, leading to a memory leak.

To fix the above issue, free 'spec' before returning the error.

Fixes: 352f7f914ebb ("ALSA: hda - Merge Realtek parser code to generic parser")
Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

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

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 this driver is distributed in the hope
that it will be useful but without any warranty without even the
implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details you
should have received a copy of the gnu general public license along
with this program if not write to the free software foundation inc
59 temple place suite 330 boston ma 02111 1307 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 18 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/20190520170857.186505395@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>


# be57bfff 22-Aug-2018 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hda: move hda_codec.h to include/sound

As suggested by Takashi, move this header file to make it easier
to include from e.g. the Intel Skylake driver in follow-up patches

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# b4af16d6 22-Aug-2018 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hda: move hda_codec.h to include/sound

As suggested by Takashi, move this header file to make it easier
to include from e.g. the Intel Skylake driver in follow-up patches

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


# 401caff7 27-Jun-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Kill snd_hda_codec_update_cache()

snd_hda_codec_update_cache() used to serve for a slightly different
purpose from snd_hdac_write_cache(), but now both of them became
identical.

Let's unify and replace with the latter one consistently.

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


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

ALSA: hda - Allow multiple ADCs for mic mute LED controls

Instead of refusing, allow the configuration with the multiple ADCs
(thus multiple capture switches) for enabling the mic mute LED.
This has been done for Sigmatel/IDT codecs, and we treat the OR-ed
values from all capture switches as the boolean condition.

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>


# 51cdc8b6 13-May-2018 Takashi Sakamoto <o-takashi@sakamocchi.jp>

ALSA: hda: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a9c2dfc8 23-Apr-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use a macro for snd_array iteration loops

Introduce a new helper macro, snd_array_for_each(), to iterate for
each snd_array element. It slightly improves the readability than
lengthy open codes at each place.

Along with it, add const prefix to some obvious places.

There should be no functional changes by this.

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


# 0de7d835 13-Oct-2017 Dan Carpenter <dan.carpenter@oracle.com>

ALSA: hda - silence uninitialized variable warning in activate_amp_in()

If snd_hda_get_conn_list() fails then "conn" isn't initialized.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a8f20fd2 27-Jun-2017 Hui Wang <hui.wang@canonical.com>

ALSA: hda - set input_path bitmap to zero after moving it to new place

Recently we met a problem, the codec has valid adcs and input pins,
and they can form valid input paths, but the driver does not build
valid controls for them like "Mic boost", "Capture Volume" and
"Capture Switch".

Through debugging, I found the driver needs to shrink the invalid
adcs and input paths for this machine, so it will move the whole
column bitmap value to the previous column, after moving it, the
driver forgets to set the original column bitmap value to zero, as a
result, the driver will invalidate the path whose index value is the
original colume bitmap value. After executing this function, all
valid input paths are invalidated by a mistake, there are no any
valid input paths, so the driver won't build controls for them.

Fixes: 3a65bcdc577a ("ALSA: hda - Fix inconsistent input_paths after ADC reduction")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 698f5ee3 09-May-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move bind-mixer switch codes to generic parser

The generic parser is the only user of the bind-mixer controls, so we
can move the code there and clean up the core helper.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
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>


# 9f3dadb1 10-Apr-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - A new flag to enforce prefix to each pin

This is a preliminary patch for a smooth multi-codec support, and it
introduces a new flag, force_pin_prefix, to struct hda_codec.
This flag is used to force to add the pin location prefix to each
input pin. For example, when there is only one microphone pin,
usually the auto-parser assigns the string "Mic". With this flag on,
it'll be like "Front Mic". Also, the creation of "Master" or "PCM"
playback volume for a single pin is suppressed, too.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195305
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 81e43960 25-Jun-2016 Bob Copeland <me@bobcopeland.com>

ALSA: hda - fix read before array start

UBSAN reports the following warning from accessing path->path[-1]
in set_path_power():

[ 16.078040] ================================================================================
[ 16.078124] UBSAN: Undefined behaviour in sound/pci/hda/hda_generic.c:3981:17
[ 16.078198] index -1 is out of range for type 'hda_nid_t [10]'
[ 16.078270] CPU: 2 PID: 1738 Comm: modprobe Not tainted 4.7.0-rc1-wt+ #47
[ 16.078274] Hardware name: LENOVO 3443CTO/3443CTO, BIOS G6ET23WW (1.02 ) 08/14/2012
[ 16.078278] ffff8800cb246000 ffff8800cb3638b8 ffffffff815c4fe3 0000000000000032
[ 16.078286] ffff8800cb3638e0 ffffffffffffffff ffff8800cb3638d0 ffffffff8162443d
[ 16.078294] ffffffffa0894200 ffff8800cb363920 ffffffff81624af7 0000000000000292
[ 16.078302] Call Trace:
[ 16.078311] [<ffffffff815c4fe3>] dump_stack+0x86/0xd3
[ 16.078317] [<ffffffff8162443d>] ubsan_epilogue+0xd/0x40
[ 16.078324] [<ffffffff81624af7>] __ubsan_handle_out_of_bounds+0x67/0x70
[ 16.078335] [<ffffffffa087665f>] set_path_power+0x1bf/0x230 [snd_hda_codec_generic]
[ 16.078344] [<ffffffffa087880d>] add_pin_power_ctls+0x8d/0xc0 [snd_hda_codec_generic]
[ 16.078352] [<ffffffffa087f190>] ? pin_power_down_callback+0x20/0x20 [snd_hda_codec_generic]
[ 16.078360] [<ffffffffa0878947>] add_all_pin_power_ctls+0x107/0x150 [snd_hda_codec_generic]
[ 16.078370] [<ffffffffa08842b3>] snd_hda_gen_parse_auto_config+0x2d73/0x49e0 [snd_hda_codec_generic]
[ 16.078376] [<ffffffff81173360>] ? trace_hardirqs_on_caller+0x1b0/0x2c0
[ 16.078390] [<ffffffffa089df27>] alc_parse_auto_config+0x147/0x310 [snd_hda_codec_realtek]
[ 16.078402] [<ffffffffa08a332a>] patch_alc269+0x23a/0x560 [snd_hda_codec_realtek]
[ 16.078417] [<ffffffffa0838644>] hda_codec_driver_probe+0xa4/0x1a0 [snd_hda_codec]
[ 16.078424] [<ffffffff817bbac1>] driver_probe_device+0x101/0x380
[ 16.078430] [<ffffffff817bbdf9>] __driver_attach+0xb9/0x100
[ 16.078438] [<ffffffff817bbd40>] ? driver_probe_device+0x380/0x380
[ 16.078444] [<ffffffff817b8d20>] bus_for_each_dev+0x70/0xc0
[ 16.078449] [<ffffffff817bb087>] driver_attach+0x27/0x50
[ 16.078454] [<ffffffff817ba956>] bus_add_driver+0x166/0x2c0
[ 16.078460] [<ffffffffa0369000>] ? 0xffffffffa0369000
[ 16.078465] [<ffffffff817bd13d>] driver_register+0x7d/0x130
[ 16.078477] [<ffffffffa083816f>] __hda_codec_driver_register+0x6f/0x90 [snd_hda_codec]
[ 16.078488] [<ffffffffa036901e>] realtek_driver_init+0x1e/0x1000 [snd_hda_codec_realtek]
[ 16.078493] [<ffffffff8100215e>] do_one_initcall+0x4e/0x1d0
[ 16.078499] [<ffffffff8119f54d>] ? rcu_read_lock_sched_held+0x6d/0x80
[ 16.078504] [<ffffffff813701b1>] ? kmem_cache_alloc_trace+0x391/0x560
[ 16.078510] [<ffffffff812bb314>] ? do_init_module+0x28/0x273
[ 16.078515] [<ffffffff812bb387>] do_init_module+0x9b/0x273
[ 16.078522] [<ffffffff811e3782>] load_module+0x20b2/0x3410
[ 16.078527] [<ffffffff811df140>] ? m_show+0x210/0x210
[ 16.078533] [<ffffffff813b2b26>] ? kernel_read+0x66/0xe0
[ 16.078541] [<ffffffff811e4cfa>] SYSC_finit_module+0xba/0xc0
[ 16.078547] [<ffffffff811e4d1e>] SyS_finit_module+0xe/0x10
[ 16.078552] [<ffffffff81a860fc>] entry_SYSCALL_64_fastpath+0x1f/0xbd
[ 16.078556] ================================================================================

Fix by checking path->depth before use.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# fabc16fe 02-Jun-2016 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Turn off loopback mixing as default

So far, we enabled the loopback mixing control as default, as this
behavior made somewhat compatible with the earlier HD-audio drivers
for Realtek & co. However, it's getting annoying as we've got more
and more bug reports about the noise coming from the loopback route.
Since the loopback mixing is used fairly rarely and often harmful
(e.g. using PA), let's get rid of the default turn-on lines.

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


# 50fd4987 17-Apr-2016 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't trust the reported actual power state

We've got a regression report that the recording on Mac with a cirrus
codec doesn't work any longer. This turned out to be the missing
power up to D0 by power_save_node enablement.

After analyzing the traces, we found out that the culprit is that the
codec advertises the "actual" power state of a few nodes to be D0
while the "target" power state is D3. This inconsistency is usually
OK, as it implies the power transition. But in the case of cirrus
codec, this seems to be stuck to D3 while it's not actually D0.

This patch addresses the issue by checking the power state difference
more strictly. It sends the power-state change verb unless both the
target and the actual power states show the given value.

We may introduce yet another flag indicating the possible broken
hardware power state, but it's anyway safer to set the proper power
state even in a transition (at least it's harmless as long as the
target state is same). So this simpler change was applied now.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=116171
Cc: <stable@vger.kernel.org> # v4.4+
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4f29efc0 12-Apr-2016 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing capture_hook calls for dyn-ADC PCM streams

The calls for capture_hook were missing in dyn_adc_capture_pcm_prepare
and cleanup callbacks. Luckily there are no users of the capture
hooks with dyn-adc PCM, so far, thus this doesn't change the behavior
of existing devices, but it's a fix for a future usage.

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


# 2ebab40e 09-Feb-2016 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix bad dereference of jack object

The hda_jack_tbl entries are managed by snd_array for allowing
multiple jacks. It's good per se, but the problem is that struct
hda_jack_callback keeps the hda_jack_tbl pointer. Since snd_array
doesn't preserve each pointer at resizing the array, we can't keep the
original pointer but have to deduce the pointer at each time via
snd_array_entry() instead. Actually, this resulted in the deference
to the wrong pointer on codecs that have many pins such as CS4208.

This patch replaces the pointer to the NID value as the search key.
As an unexpected good side effect, this even simplifies the code, as
only NID is needed in most cases.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda - Implement loopback control switch for Realtek and other codecs

Many codecs, typically found on Realtek codecs, have the analog
loopback path merged to the secondary input of the middle of the
output paths. Currently, we don't offer the dynamic switching in such
configuration but let each loopback path mute by itself.

This should work well in theory, but in reality, we often see that
such a dead loopback path causes some background noises even if all
the elements get muted. Such a problem has been fixed by adding the
quirk accordingly to disable aamix, and it's the right fix, per se.
The only problem is that it's not so trivial to achieve it; user needs
to pass a hint string via patch module option or sysfs.

This patch gives a bit improvement on the situation: it adds "Loopback
Mixing" control element for such codecs like other codecs (e.g. IDT or
VIA codecs) with the individual loopback paths. User can turn on/off
the loopback path simply via a mixer app.

For keeping the compatibility, the loopback is still enabled on these
codecs. But user can try to turn it off if experiencing a suspicious
background or click noise on the fly, then build a static fixup later
once after the problem is addressed.

Other than the addition of the loopback enable/disablement control,
there should be no changes.

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>


# b9a94a9c 01-Oct-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - convert to hda_device_id

Finally we have a proper infrastructure to generate the modaliases
automatically, let's move to hda_device_id from the legacy
hda_codec_preset that contains basically the same information.

The patch function hook is stored in driver_data field, which is long,
and we need an explicit cast. Other than that, the conversion is
mostly straightforward. Each entry is even simplified using a macro,
and the lengthy (and error-prone) manual modaliases got removed.

As a result, we achieved a quite good diet:
14 files changed, 407 insertions(+), 595 deletions(-)

Reviewed-by: Vinod Koul <vinod.koul@intel.com>
Tested-by: Subhransu S Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c7cd0ef6 24-Aug-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix path power activation

The widget power-saving code tries to turn up/down the power of each
widget in the I/O paths that are modified at each jack plug/unplug.
The recent report revealed that the power activation leaves some
widgets unpowered after plugging. This is because
snd_hda_activate_path() turns on path->active flag at the end of the
function while the path power management is done before that. Then
it's regarded as if nothing is active, and the driver turns off the
power.

The fix is simply to set the flag at the beginning of the function,
before trying to power up.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=102521
Cc: <stable@vger.kernel.org> [v4.1+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9d2b48f7 24-Aug-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check all inputs for is_active_nid_for_any()

The is_active_nid_for_any() function in the generic parser is supposed
to check all connections from/to the given widget, but the current
code checks only the first input connection (index = 0).

This patch corrects the code to check all inputs by passing -1 to
index argument.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=102521
Cc: <stable@vger.kernel.org> [v4.1+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d1f15e06 08-Jul-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix a wrong busy check in alt PCM open

Currently, the alt PCM open callback returns -EBUSY when an
independent HP is turned off, supposing that it conflicts with the
main PCM. However, obviously, this check is wrong when the
independent HP itself isn't enabled but the alt PCM was explicitly
created via alc_dac_nid by a codec driver.

Reported-and-tested-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 49fb1897 27-May-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Set stream_pm ops automatically by generic parser

This allows user to test power_save_node feature via sysfs or patch
firmware even on the codecs that don't specify it. It'll also save a
few lines.

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


# 48f4b3a2 19-May-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Reduce verbs by node power-saves

The widget (node) power-saves restore the widget states at each
transition from D3 to D0 on each node. This was added in the commit
[d545a57c5f84:ALSA: hda - Sync node attributes at resume from widget
power saving]. However, the test was rater false-positive; this
wasn't needed for any codecs.

Since the resync may take significant number of additional verbs to be
executed, it's better to reduce it. Let's disable it for now again.

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


# 3e1b0c4a 27-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix click noise at start on Dell XPS13

Dell XPS13 produces a click noise at boot up, and Gabriele spotted out
that it's triggered by the initial pin control of the mic (NID 0x19).
This has to be set to Hi-Z Vref while the driver initializes to Vref
80% as a normal mic.

This patch fixes the generic parser code not to override the target
vref if it has been already set by the driver, and adds a proper
initialization of the target vref for this pin in the Realtek driver
side.

Reported-and-tested-by: Gabriele Mazzotta <gabriele.mzt@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 24fef902 09-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda/generic - Don't override power_filter when power_save_node is set

Currently the generic parser sets codec->power_filter when
power_save_node flag is set. But this overrides the existing filter
that has been already set by the codec driver, thus it looses some
features. Instead, set the default power_filter only when it's not
set yet.

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


# b6c09b3c 09-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda/generic - Make snd_hda_gen_path_power_filter() always applicable

Add the check of power_save_node flag at the beginning of the function
so that it skips the rest if the flag isn't set. In this way, we can
call this function safely no matter whether the widget power-saving is
really used or not.

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


# d5ac0100 09-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda/generic - Fix wrong initial power state for fixed pins

When the widget power-saving is enabled, the first automute hook
invocation checks through the whole pins and it also tries to
synchronize the power state. However, this results in a wrong state
because it calls unconditionally snd_hda_jack_detect_state().
This patch adds a check of jack detectability before the actual jack
detection call.

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


# 2206dc94 09-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda/generic - Check power state cap at updating the widget power

The new widget power-saving tries to apply the power change no matter
whether the node has a power cap or not. It's bad (although most of
codecs chip just ignore it). Check the capability properly
beforehand.

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


# d545a57c 03-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Sync node attributes at resume from widget power saving

So far we assumed that the node attributes like amp values remain
during the power state transition of the node itself. While this is
true for IDT/STAC codecs I've tested, but some other codecs don't seem
behaving in that way.

This patch implements a partial sync mechanism specific to the given
widget node. Now we've merged the regmap support, and it can be
easily written with regcache_sync_region().

Tested-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a551d914 25-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use regmap for command verb caches, too

Like the previous patches, this patch converts also to the regmap, at
this time, the cached verb writes are the target. But this conversion
needs a bit more caution than before.

- In the old code, we just record any verbs as is, and restore them at
resume. For the regmap scheme, this doesn't work, since a few verbs
like AMP or DIGI_CONVERT are asymmetrical. Such verbs are converted
either to the dedicated function (snd_hda_regmap_xxx_amp()) or
changed to the unified verb.

- Some verbs have to be declared as vendor-specific ones before
accessing via regmap.

Also, the minor optimization with codec->cached_write flag is dropped
in a few places, as this would confuse the operation. Further
optimizations will be brought in the later patches, if any.

This conversion ends up with a drop of significant amount of codes,
mostly the helper codes that are no longer used.

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


# 7639a06c 03-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move a part of hda_codec stuff into hdac_device

Now some codes and functionalities of hda_codec struct are moved to
hdac_device struct. A few basic attributes like the codec address,
vendor ID number, FG numbers, etc are moved to hdac_device, and they
are accessed like codec->core.addr. The basic verb exec functions are
moved, too.

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


# 967b1307 20-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Rename power_mgmt flag with power_save_node

David suggested that the name "power_mgmt" is too ambiguous. Rename
the flag with a bit clearer one "power_save_node".

Also, add the corresponding description to HD-Audio.txt, too.

Reported-by: David Henningsson <david.henningsson@canonical.com>
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>


# 5ccf835c 18-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Adjust power of beep widget and outputs

As the widget PM may turn off the pins, this might lead to the silent
output for beep when no explicit paths are given. This patch adds
fake output paths for the beep widget so that the output pins are
dynamically powered upon beep on/off.

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>


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

ALSA: hda - Simplify PCM setup overrides

This patch does two things:
- code refactoring with a local helper function,
- allow codec drivers to provide the specific PCM stream info pointers
only for overriding the non-NULL entries, instead of copying the
whole.

This simplifies the codec driver side (currently the only user is
alc269's 44kHz fixed rate).

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


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

ALSA: hda - Treat stereo-to-mono mix properly

The commit [ef403edb7558: ALSA: hda - Don't access stereo amps for
mono channel widgets] fixed the handling of mono widgets in general,
but it still misses an exceptional case: namely, a mono mixer widget
taking a single stereo input. In this case, it has stereo volumes
although it's a mono widget, and thus we have to take care of both
left and right input channels, as stated in HD-audio spec ("7.1.3
Widget Interconnection Rules").

This patch covers this missing piece by adding proper checks of stereo
amps in both the generic parser and the proc output codes.

Reported-by: Raymond Yau <superquad.vortex2@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ef403edb 12-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't access stereo amps for mono channel widgets

The current HDA generic parser initializes / modifies the amp values
always in stereo, but this seems causing the problem on ALC3229 codec
that has a few mono channel widgets: namely, these mono widgets react
to actions for both channels equally.

In the driver code, we do care the mono channel and create a control
only for the left channel (as defined in HD-audio spec) for such a
node. When the control is updated, only the left channel value is
changed. However, in the resume, the right channel value is also
restored from the initial value we took as stereo, and this overwrites
the left channel value. This ends up being the silent output as the
right channel has been never touched and remains muted.

This patch covers the places where unconditional stereo amp accesses
are done and converts to the conditional accesses.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=94581
Cc: <stable@vger.kernel.org>
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>


# d8a766a1 17-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Bind codecs via standard bus

Now we create the standard HD-audio bus (/sys/bus/hdaudio), and bind
the codec driver with the codec device over there. This is the first
step of the whole transition so that the changes to each codec driver
are kept as minimal as possible.

Each codec driver needs to register hda_codec_driver struct containing
the currently existing preset via the new helper macro
module_hda_codec_driver(). The old hda_codec_preset_list is replaced
with this infrastructure. The generic parsers (for HDMI and other)
are also included in the preset with the special IDs to bind
uniquely.

In HD-audio core side, the device binding code is split to
hda_bind.c. It provides the snd_hda_bus_type implementation to match
the codec driver with the given codec vendor ID. It also manages the
module auto-loading by itself like before: when the matching isn't
found, it tries to probe the corresponding codec modules, and finally
falls back to the generic drivers. (The special ID mentioned above is
set at this stage.)

The only visible change to outside is that the hdaudio sysfs entry now
appears in /sys/bus/devices, not as a sound class device.

More works to move the suspend/resume and remove ops will be
(hopefully) done in later patches.

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>


# 82d04e10 15-Dec-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Create capture source ctls when stereo mix input is added

When the stereo mix input is explicitly enabled via a user hint, the
driver should create always a capture source enum ctl and disable the
auto-mic switch. Otherwise the behavior gets confused. For doing it,
this patch just sets spec->suppress_auto_mic flag appropriately.

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


# dda42bd0 29-Oct-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add kerneldoc comments to hda_generic.c

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


# 3abb4f4d 16-Oct-2014 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Use "Line Out" name instead of "PCM" when there are other outputs

In case there are speakers or headphones as well, anything that only
covers the line out should not be labelled "PCM". Let's name it
"Line Out" instead for clarity.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 03ad6a8c 16-Oct-2014 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Fix "PCM" name being used on one DAC when there are two DACs

In the scenario where there is one "Line Out", one "Speaker" and one
"Headphone", and there are only two DACs, two outputs will share a DAC.
Currently any mixer on such a DAC will get the "PCM" name, which is
misleading. Instead use "Headphone+LO" or "Speaker+LO" to better
specify what the volume actually controls.

[fixed missing slave string additions by tiwai]

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 861a04ed 23-Sep-2014 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Move the function "check_amp_caps" to hda_codec.c

The next patch will use it, so make it visible across modules.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
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>


# d82353e5 05-Jul-2014 Joe Perches <joe@perches.com>

ALSA: hda - Fix and neaten print_nid_path/debug_badness

print_nid_path has a possible buffer overflow if
struct nid_path.path values are > 256.

Avoid this and neaten the output to remove the leading ':'

Neaten debug_badness to always verify arguments.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6194b99d 06-Jun-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Kill the rest of snd_print*() usages

Pass the codec object so that we can replace all the rest of
snd_print*() usages with the proper device-specific print helpers.

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


# d576422e 14-May-2014 Dan Carpenter <dan.carpenter@oracle.com>

ALSA: hda - if statement not indented

The "break;" should be indented.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d604b399 28-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix registration of beep input device

The beep input device is registered via input_register_device(), but
this is called in snd_hda_attach_beep_device() where the sound devices
aren't registered yet. This leads to the binding to non-existing
object, thus results in failure. And, even if the binding worked
(against the PCI object), it's still racy; the input device appears
before the sound objects.

For fixing this, register the input device properly at dev_register
ops of the codec object it's bound with. Also, call
snd_hda_detach_beep_device() at dev_disconnection so that it's
detached at the right timing. As a bonus, since it's called in the
codec's ops, we can get rid of the further call from the other codec
drivers.

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


# 4e76a883 24-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Replace with standard printk

Use dev_err() and co for messages from HD-audio controller and codec
drivers. The codec drivers are mostly bound with codec objects, so
some helper macros, codec_err(), codec_info(), etc, are provided.
They merely wrap the corresponding dev_xxx().

There are a few places still calling snd_printk() and its variants
as they are called without the codec or device context.

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>


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

ALSA: hda - Move HDA_FIXUP_ACT_FREE call in snd_hda_gen_free()

Now Realtek and Conexant codec parsers just call snd_hda_gen_free().

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>


# 8f0972df 27-Jan-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid unnecessary verbs write in snd_hda_activate_path()

... by using snd_Hda_codec_update_cache() instead of *_write_cache().
Since all path elements should have been updated by this function,
we are safe to assume that the cache contents are consistent.

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>


# 43a8e50a 07-Jan-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't create duplicated ctls for loopback paths

AD1986A mic pins (0x1d and 0x1f) share the same widget for controlling
the loopback volume/mute, but the generic parser didn't check it.
This ended up with the duplicated controls for the same effect.

This patch adds the check of the duplication for avoiding it.

After this fix, there will be only one control although it affects
both paths; this remaining issue should be fixed later in a different
patch.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=66621
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2698ea98 17-Dec-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Kill EXPORT_SYMBOL_HDA()

Replace all with the standard EXPORT_SYMBOL_GPL().

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>


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

ALSA: hda - Mute all aamix inputs as default

Not all channels have been initialized, so far, especially when aamix
NID itself doesn't have amps but its leaves have. This patch fixes
these holes. Otherwise you might get unexpected loopback inputs,
e.g. from surround channels.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f1e762dd 09-Dec-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Enable stereo mix as default for AD and VIA codecs

AD and VIA codecs had stereo mixer input enabled as default before
moving to the generic parser, and people think the lack of such a
regression. In this patch, the stereo mixer input is added back to
the input selection if no auto-mic is available, and if it's not
disabled explicitly via hint. This should satisfy most of demands,
i.e. stereo mix on desktop machines like what it worked before, and it
still keeps the new auto-mic feature on laptops.

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


# 4f7f67fb 03-Dec-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing initialization of aamix paths

The loopback mixing paths aren't initialized correctly at init
callback. Mostly this is harmless as codecs usually set the mute
state as default, but we still should make sure.

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


# c9e4bdb7 06-Dec-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow capture-only configuration

We have blindly assumed that all valid configurations should have
either analog or digital playback, but there can be capture-only
configurations. The parser shouldn't escape in such a case.

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


# 2ded3e5b 28-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check leaf nodes to find aamix amps

The current generic parser assumes blindly that the volume and mute
amps are found in the aamix node itself. But on some codecs,
typically Analog Devices ones, the aamix amps are separately
implemented in each leaf node of the aamix node, and the current
driver can't establish the correct amp controls. This is a regression
compared with the previous static quirks.

This patch extends the search for the amps to the leaf nodes for
allowing the aamix controls again on such codecs.
In this implementation, I didn't code to loop through the whole paths,
since usually one depth should suffice, and we can't search too
deeply, as it may result in the conflicting control assignments.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=65641
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 16c0cefe 26-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix hp-mic mode without VREF bits

When the hp mic pin has no VREF bits, the driver forgot to set PIN_IN
bit. Spotted during debugging old MacBook Airs.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=65681
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ced4cefc 26-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Create Headhpone Mic Jack Mode when really needed

When a headphone jack is configurable as input, the generic parser
tries to make it retaskable as Headphone Mic. The switching can be
done smoothly if Capture Source control exists (i.e. there is another
input source). Or when user explicitly enables the creation of jack
mode controls, "Headhpone Mic Jack Mode" will be created accordingly.

However, if the headphone mic is the only input source, we have to
create "Headphone Mic Jack Mode" control because there is no capture
source selection. Otherwise, the generic parser assumes that the
input is constantly enabled, thus the headphone is permanently set
as input. This situation happens on the old MacBook Airs where no
input is supported properly, for example.

This patch fixes the problem: now "Headphone Mic Jack Mode" is created
when such an input selection isn't possible.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=65681
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b21bdd0d 17-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Split the generic parser as an individual module

Drop the hard dependency on the generic parser code and load / unload
the generic parser code dynamically if built as a module. This allows
us to avoid the generic parser if only HDMI/DP codecs are found.

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


# 468ac413 12-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check keep_eapd_on before inv_eapd

We don't change the EAPD bit in set_pin_eapd() if keep_eapd_on flag is
set by the codec driver and enable is false. But, we also apply the
flipping of enable value according to inv_eapd flag in the same
function, and this confused the former check, handled as if it's
turned ON. The inverted EAPD check must be applied after keep_eapd_on
check, instead.

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>


# b63eae0a 25-Oct-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing initial vmaster hook at build_controls callback

The generic parser has a support of vmaster hook, but this is
initialized only in the init callback with the check of the presence
of the corresponding kctl. However, since kctl is NULL at the very
first init callback that is called before build_controls callback, the
vmaster hook sync is skipped there. Eventually this leads to the
uninitialized state depending on the hook implementation.

This patch adds a simple workaround, just calling the sync function
explicitly at build_controls callback.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ccb04157 14-Oct-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Fix inverted internal mic not indicated on some machines

The create_bind_cap_vol_ctl does not create any control indicating
that an inverted dmic is present. Therefore, create multiple
capture volumes in this scenario, so we always have some indication
that the internal mic is inverted.

This happens on the Lenovo Ideapad U310 as well as the Lenovo Yoga 13
(both are based on the CX20590 codec), but the fix is generic and
could be needed for other codecs/machines too.

Thanks to Szymon Acedański for the pointer and a draft patch.

BugLink: https://bugs.launchpad.net/bugs/1239392
BugLink: https://bugs.launchpad.net/bugs/1227491
Reported-by: Szymon Acedański <accek@mimuw.edu.pl>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e80c60f3 12-Aug-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Mute the right widget in auto_mute_via_amp mode

The current generic parser code assumes that always a pin widget
controls the mute for an output blindly although it might be a
different widget in the middle. Instead of the fixed assumption,
check each parsed path and just pick up the right widget that has been
already defined as a mute control.

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


# bc2eee29 09-Aug-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow auto_mute_via_amp on bind mute controls

The auto-mute using the amp currently works only for a single amp on a
pin. Make it working also with HDA_CTL_BIND_MUTE type, too.

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


# f69910dd 08-Aug-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix missing mute controls for CX5051

We've added a fake mute control (setting the amp volume to zero) for
CX5051 at commit [3868137e: ALSA: hda - Add a fake mute feature], but
this feature was overlooked in the generic parser implementation. Now
the driver lacks of mute controls on these codecs.

The fix is just to check both AC_AMPCAP_MUTE and AC_AMPCAP_MIN_MUTE
bits in each place checking the amp capabilities.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=59001
Cc: <stable@vger.kernel.org> [v3.9+]
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>


# 60ea8ca2 19-Jul-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_jack_detect_state() helper function

snd_hda_jack_detect() function returns a boolean value for a jack
plugged in or not, but it also returns always true when the
corresponding pin is phantom (i.e. fixed). This is OK in most cases,
but it makes the generic parser misbehaving about the auto-mute or
auto-mic switching, e.g. when one of headphone pins is a fixed.
Namely, the driver decides whether to mute the speaker or not, just
depending on the headphone plug state: if one of the headphone jacks
is seen as active, then the speaker is muted. Thus this will result
always in the muted speaker output.

So, the problem is the function returns a boolean, after all, although
we need to think of "phantom" jack. Now a new function,
snd_hda_jack_detect_state() is introduced to return these tristates.
The generic parser uses this function for checking the headphone or
mic jack states.

Meanwhile, the behavior of snd_hda_jack_detect() is kept as is, for
keeping compatibility in other driver codes.

Acked-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 975cc02a 28-Jun-2013 Takashi Iwai <tiwai@suse.de>

ALSA: Replace the magic number 44 with const

The char arrays with size 44 are for the name string of
snd_ctl_elem_id. Define the constant and replace the raw numbers with
it for clarifying better.

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


# 0c055b34 28-Jun-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix the max length of control name in generic parser

add_control_with_pfx() in hda_generic.c assumes a shorter name string
for the control element, and this resulted in the truncation of the
long but valid string like "Headphone Surround Switch" in the middle.

This patch aligns the max size to the actual limit of snd_ctl_elem_id,
44.

Cc: <stable@vger.kernel.org> [v3.9+]
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>


# 963afde9 31-May-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda/via - Clean up duplicated codes

The previous commit was written in the way to make the backport to
3.9.y easier, and left the duplicated open codes intentionally.
Now let's clean up the duplicated codes.

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>


# 77afe0e9 31-May-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow setting automute/automic hooks after parsing

Some codec drivers (VIA codecs and some Realtek fixups) set the
automute and automic hooks after calling
snd_hda_gen_parse_auto_config(). In the current code, the hook
pointers are referred only in snd_hda_gen_parse_auto_config() and
passed to snd_hda_jack_detect_enable_callback(), thus changing the
hook values won't change the actually called callbacks properly.

This patch fixes this bug by setting the static functions as the
primary callback functions for the jack detection, and let them
calling the appropriate hooks dynamically.

Cc: <stable@vger.kernel.org> [v3.9]
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b1b9fbd0 13-May-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check the activity of the NID to be powered down

When an inactive path is powered down with spec->power_down_unused
flag, we should check the activity of each widget in the path whether
it's still referred from any active path.

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


# 5ead56f2 16-Apr-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use the primary DAC for all aamix outputs

When setting up the aamix output paths, use the primary DAC instead of
the individual DAC for each output as default. Otherwise multiple
DACs will be turned on for a single aamix widget, which results in
doubly or more volumes, because the duplicated signals will be sent
through all these DACs for a single stream.

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


# 65033cc8 15-Apr-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix aamix activation with loopback control on VIA codecs

When we have a loopback mixer control, this should manage the state
whether the output paths include the aamix or not. But the current
code blindly initializes the output paths with aamix = true, thus the
aamix is enabled unless the loopback mixer control is changed.

Also, update_aamix_paths() called by the loopback mixer control put
callback invokes snd_hda_activate_path() with aamix = true even for
disabling the mixing. This leaves the aamix path even though the
loopback control is turned off.

This patch fixes these issues:
- Introduced aamix_default() helper to indicate whether with_aamix is
true or false as default
- Fix the argument in update_aamix_paths() for disabling loopback

Reported-by: Lydia Wang <LydiaWang@viatech.com.cn>
Cc: <stable@vger.kernel.org> [v3.9+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b26b5116 11-Apr-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Handle Headphone Mic jack more generic

Now that we have a flag for headphone mics, we can use that flag
in the jack creation instead of creating the jack manually.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# cb420b11 11-Apr-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - allow "Headphone Mic" parser flag

This allows a specific mic to get the "Headphone Mic" name, in addition
to the existing "Headset Mic" name.

Also, it allows for a special mark: if the sequence number is set
to 0xc, that's an indication to prefer it for headset mic, and if it's
set to 0xd, that's an indication to prefer it for headphone mic.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 868211db 04-Apr-2013 Jiri Slaby <jirislaby@kernel.org>

ALSA: hda/generic - fix uninitialized variable

changed is not initialized in path_power_down_sync, but it is expected
to be false in case no change happened in the loop. So set it to
false.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda - Lower the badness for independent HP penalty

The lack of independent HP mode shouldn't be too bad, but currently
its badness is set a bit too high. Let's lower it.

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>


# 55a63d4d 21-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix DAC assignment for independent HP

The generic parser should evaluate the availability of the independent
HP when specified. Otherwise a DAC without the direct connection to
the corresponding pin may be assigned for the HP, but the driver
doesn't check it at all. The problem was actually seen on some
machines with VT1708s or equivalent codec, where DAC0 is assigned to
HP although it can be connected only via aamix.

This patch adds the badness evaluation for the independent HP to make
it working properly.

Reported-by: Lydia Wang <LydiaWang@viatech.com.cn>
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>


# 93c9d8ae 11-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't re-initialize shared hp/mic pinctl

When a headphone pin is set up as a shared hp/mic pin, we rather want
to keep it as a headphone primarily as default, but the driver
overrides it always as a mic pin, just because the input controls are
created after outputs. Add a check of pin NID and skip the
re-initialization of pinctl for such a shared hp/mic pin.

Reported-by: Jonathan Woithe <jwoithe@just42.net>
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>


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

ALSA: hda - Allow to change I/O direction in hp/mic jack mode ctl

The previous commits added the capability to change the pin control of
hp/mic shared jack, but it actually didn't work as expected when the
value is changed from the output to the input, since I forgot to reset
the pin I/O bit in that case. This patch fixes the problem.

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


# 5f171baa 19-Feb-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Handle shared hp/mic jack mode

When a headphone jack is configured as a shared hp/mic jack, the jack
mode enum needs to handle both input and output directions.

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>


# 1d739066 13-Feb-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Increase badness for missing multi-io

The current badness value used for the missing multi-io seems too
weak, and the multi-io tends to be skipped for desktop configurations
when no enough DACs are available. It's because the total badness of
the multi-io becomes often larger than the badness with assigning an
individual DAC to a headphone jack. This is good for one side, but it
seems that the surround outputs are more demanded by that.

This patch increases the badness value for the missing multi-io
slightly so that the multi-io would be preferred than the individual
headphone DAC if they conflict. Through the tests with hda-emu,
mostly only desktop configurations with ALC662/663 and CMI codecs are
affected by this change, and all look reasonable.

Reported-by: Raymond Yau <superquad.vortex2@gmail.com>
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>


# 86b27237 25-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: Make snd_printd() and snd_printdd() inline

Because currently snd_printd() and snd_printdd() macros are expanded
to empty when CONFIG_SND_DEBUG=n, a compile warning like below
appears sometimes, and we had to covert it by ugly ifdefs:
sound/pci/hda/patch_sigmatel.c: In function ‘stac92hd71bxx_fixup_hp’:
sound/pci/hda/patch_sigmatel.c:2434:24: warning: unused variable ‘spec’ [-Wunused-variable]

For "fixing" these issues better, this patch replaces snd_printd() and
snd_printdd() definitions with empty inline functions instead of
macros. This should have the same effect but shut up warnings like
above.

But since we had already put ifdefs, changing to inline functions
would trigger compile errors. So, such ifdefs is removed in this
patch.

In addition, snd_pci_quirk name field is defined only when
CONFIG_SND_DEBUG_VERBOSE is set, and the reference to it in
snd_printdd() argument triggers the build errors, too. For avoiding
these errors, introduce a new macro snd_pci_quirk_name() that is
defined no matter how the debug option is set.

Reported-by: Stratos Karafotis <stratosk@semaphore.gr>
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>


# 7dddf2ae 24-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix wrong arguments for path deactivation checks

The arguments to call is_active_nid() in activate_amp() were swapped,
and this resulted in the muted amp on some SPDIF output pins.

Also, the index to be passed to is_active_nid() must be idx_to_check.
Otherwise it checks the wrong connection in the case of implicit aamix
connection paths.

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


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

ALSA: hda - Small code refactoring about path re-initialization

Introduce a helper function to do the same thing.

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>


# dc870f38 22-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Combine snd_hda_codec_flush_*_cache() to a single function

Since both snd_hda_codec_flush_amp_cache() and
snd_hda_codec_flush_cmd_cache() are called usually at the same time,
we can simply combine them to a single function,
snd_hda_codec_flush_cache().

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


# a836dbf6 22-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix missing call of cmd flush in capture volume put callback

The capture volume put callback may call the node selection change,
and its actual call won't be triggered unless flushed. In general,
we always need to call both snd_hda_codec_flush_amp_cache() and
snd_hda_codec_flush_cmd_cache() at the same place...

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


# 4bd01e93 22-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing exports to helper functions

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


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

ALSA: hda - Disable HP auto-mute during independent HP mode

Both the HP auto-mute and the independent HP mode conflict with each
other. Make HP auto-mute disabled (only for the affected HP jack)
during the driver is in HP independent mode.

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>


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

ALSA: hda - Check aamix-output paths from other DACs, too

Many codecs provide routes to multiple output pins through an aamix
widget, but most of them do it only from a single DAC. However, the
current generic parser checks only the aamix paths from the original
(directly bound) DACs through aamix NID, and miss the path:
primary DAC -> aamix -> target out pin

This patch adds a more check for the routes like the above.

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


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

ALSA: hda - Add missing badness evaluation for unresolved paths

When a patch couldn't be resolved in try_assign_dacs() although the
target DAC is expected, we forgot to add a proper badness value but
continued.

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


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

ALSA: hda - Set the pin targets after deciding output config

Since fill_and_eval_dacs() may be called repeatedly with different
configurations, setting pinctls at each time there isn't optimal.
We can set it better only once after deciding the output configuration
in parse_output_paths().

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


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

ALSA: hda - Improve debug prints for output paths

Print the information of outputs in a bit more details and concisely
in a single place instead of printing the path at each time when
detected.

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


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

ALSA: hda - Fix the wrong adc_idx for capture source

The patch "ALSA: hda - fix wrong adc_idx in generic parser" fixed the
adc_idx for the capture volume and capture switch controls. But also
modified the adc_idx retrieval for the capture source controls
wrongly. As multiple capture source controls are created in a single
shot with counts > 1, the id.index doesn't contain the real value.
The real index has to be taken via snd_ctl_get_ioffidx() as in the
original code.

This patch reverts the fixes partially to recover from the
regression.

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


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

ALSA: hda - don't compare with yourself in fill_input_pin_labels

Just stumbled over this one while reading the code.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
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>


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

ALSA: hda - Add boost to line inputs, too

Although I commented that boost volumes would be added only for
line-in and mic pins in the source code, the actual code excludes but
for mic-in. Fix it to accept the line-ins, too.

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>


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

ALSA: hda - Fix missing call of capture_switch_hook

When a standard capture switch without multiple binding is used, the
call for capture_switch_hook isn't called properly. Replace the put
ops to add the hook call in that case.

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


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

ALSA: hda - Look for boost controls more deeply

In the current generic parser code, we look for the (mic) boost
controls only on input pins. But many codecs assign the boost volume
to a widget connected to each input pin instead of the input amp of
the pin itself.

In this patch, the parser tries to look through more widgets connected
to the pin and find a boost amp.

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


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

ALSA: hda - Fix invalid mute in path activation

When an amp in the activation path is associated with mixer controls,
activate_amp() tries to skip the initialization. It's good, but only
if the mixer really initializes both mute and volume. Otherwise,
either the mute of the volume is left uninitialized.

This patch adds this missing check and properly initialize the
partially controlled amps in an activation path.

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>


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

ALSA: hda - Keep autocfg.input idx value in imux table

Since the imux table entries can be a subset of autocfg.input table,
the indices of these aren't always same. For passing the proper index
value of autocfg.input at creating input ctl labels (via
snd_hda_autocfg_input_label()), keep the corresponding autocfg.input
idx value in the index field of each imux item, which isn't used in
the generic driver.

Also, this makes easier to check the invalid imux pin for stereo mix.

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


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

ALSA: hda - Improve naming rule for primary output

When the volume or mute control of the primary output is shared with
other (headphone or speaker) outputs, we shouldn't name it as a
specific output type but rather name it with the channel name or a
generic name like "PCM".

Also, this check should be performed individually for the volume and
the mute controls because some codecs may have shared volumes but
separate mute controls.

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>


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


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

ALSA: hda - Properly call automute/switch hooks at init

... and a little bit of code refactoring.

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


# 6fc4cb97 16-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Make sure fill_all_dac_nids is called for digital only codecs

Otherwise no PCM will be built for codecs without analog I/O.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 99a5592d 16-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - force different capture controls if amp caps differ

Otherwise setting the capture volume for amps will be weird and
inconsistent (it will try to set values outside the range of the
second amp based on capabilities of the first amp).

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 02aba550 16-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - do not add non-existing Mic boost controls

If the input node does not have any volume capable input amp,
don't add such a control.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c0f3b216 16-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - initialize channel counts correctly

Even a single DAC can output two channels, so the channel count
is twice the number of DACs.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a053d1e3 16-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - fix wrong adc_idx in generic parser

We use knew->index for adc_idx when we create "Capture Volume" and
"Capture Switch", so use the same to retrieve adc_idx.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b56fa1ed 16-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Check array bounds in get_input_path

This gives us some additional safety.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
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>


# 1c70a583 11-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow user to give hints for codec parser behavior

Through the hints via sysfs or patch, user can set specific behavior
flags for the generic parser now.

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>


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

ALSA: hda - Update automute / automic upon jack retasking

When a multi-io jack is switched to another direction, call the
automute and autoswitch update functions, as this jack won't be used
as the headphone or the mic jack that may turn off others.

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


# 0b4df931 10-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid auto-mute or auto-mic of retasked jacks

When a jack is retasked as a different direction (e.g. a mic jack is
used as a CLFE output), such a jack shouldn't be counted as the target
for the automatic jack switching. Skip the automute or the autoswitch
when the current pinctl direction is different from what we suppose.

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


# 2c12c30d 10-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Manage current pinctl values in generic parser

Use the new pin target accessors for managing the current pinctl
values in the generic parser. The pinctl values of all active pins
are once determined at the initialization phase, and stored via
snd_hda_codec_set_pin_target(). This will be referred again in the
codec init or resume phase to set the actual pinctl.

This value is kept while the auto-mute. When a line-out or a speaker
pin is muted by auto-mute, the driver simply disables the pin, but it
doesn't touch the cached pinctl target value. Upon unmute, this value
is used to restore the original pinctl in return.

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


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

ALSA: hda - Clear the dropped paths properly

When a DAC is reassigned from surrounds to front or ADCs are reduced
due to incomplete imux, we clear the path indices but the path
instances remain as is. Since the paths might be still referred
through the whole path list parsing (e.g. is_active_nid()), we should
clear these path instances as well.

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>


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

ALSA: hda - Fix inconsistent input_paths after ADC reduction

In the current parser code, the input_paths[] may become inconsistent
when some of detected ADCs are dropped due to incomplete inputs, since
the driver rearranges only adc_nids[] but doesn't touch input_paths[].

This patch fixes the issue, and also it optimizes the reachability
checks by simply referring to the parsed input_paths[] instead of
calling is_reachable() again for each connection.

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


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

ALSA: hda - Return "Headphone Mic" from hda_get_autocfg_input_label()

Instead of handling special cases in the caller side, give a proper
name string "Headphone Mic" from hda_get_autocfg_input_label() when
the headhpone jack pin is specified as an input.

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


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

ALSA: hda - Exclude aamix from capture paths

The capture paths shouldn't contain the analog loopback mixer.
Pass a proper argument to exclude the aamix NID.

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>


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

ALSA: hda - Remove unused dac reference in create_multi_out_ctls()

Remove useless code.

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


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

ALSA: hda - Use direct path reference in assign_out_path_ctls()

Instead of looking through paths with the dac -> pin connection at
each time, just pass the already parsed path index to
assign_out_path_ctls(). This simplifies the code a bit.

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


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

ALSA: hda - Clear path indices properly at each re-evaluation

The path indices must be reset at each evaluation of DAC assignment.
Otherwise the badness value will be wrongly calculated and mixers may
be inconsistently assigned.

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


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

ALSA: hda - Add brief comments to exported snd_hda_gen_*_() functions

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


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

ALSA: hda - Remove dead HDA_CTL_BIND_VOL and HDA_CTL_BIND_SW codes

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>


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

ALSA: hda - Drop unneeded pin argument from set_output_and_unmute()

Just a minor refactoring.

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


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

ALSA: hda - Add missing slave names for Speaker Surround, etc

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


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

ALSA: hda - Prefer binding the primary CLFE output

When 5.1 or more multiple speakers with found but not enough DACs are
available, it's better to bind such pins to the DACs of the primary
outputs with the same channels rather than binding to the first DAC
(i.e. the front channel). For the cases with two speaker pins, it's
rather regarded as front + bass combination, thus it's more practical
to still bind to the front, though.

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


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

ALSA: hda - Fix truncated control names

... like "Speaker Surround Playback Switch".
This fix had been already applied to patch_conexant.c but was
forgotten in other places, then migrated to hda_generic.c.

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>


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

ALSA: hda - Correct aamix output paths

The output paths including aamix should be parsed only for the first
output. The surround paths including aamix must be wrong, since it
would mix all streams, i.e. all channels would be mixed into a single
and multiplexed again.

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>


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

ALSA: hda - Fix multi-io pin assignment in create_multi_out_ctls()

The multi-io pins are calculated with a blind assumption of
cfg->line_outs = 1. This isn't always true.

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


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

ALSA: hda - Simplify the multi-io assignment with multi speakers

When speakers are chosen as the the primary output during evaluation,
we did some tricks to assign the possible multi-io jacks with a
certain offset value to multi_out dacs. This was a workaround for the
case with multiple speakers like Acer Aspire. But this is quite ugly
at the same time and the resultant code is hard to understand. More
badly, it works wrongly for 2.1 speakers like Apple iMac91.

In this patch, instead of fiddling with the offset to multi_out dacs,
simply add a certain badness number if headphone(s) + multi-ios are
possible. This simplify the code a bit, and it's more robust.

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>


# 1e0b5286 03-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid duplicated path creations

When the paths are created in map_singles(), we don't have to
re-create new paths in try_assign_dacs(). Just evaluate the badness
and skip to the next item.

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


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

ALSA: hda - Initialize output paths with current active states

Set path->active flag at the path creation time and let the paths
initialized according to the current path->active state in
set_output_and_unmute(). This allows to modify the active flag of
some output paths dynamically, e.g. switching the front output route
with or without aamix like patch_via.c.

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


# 985803ca 03-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't skip amp init for activated paths

activate_amp() in the generic parser checks whether the given NID is
included in any active paths and skips it if found. This was a
workaround for avoiding disabling the widgets in the active paths when
one path is disabled, thus it shouldn't be applied to the case for
path activation. Due to this wrong check, some analog loopback paths
haven't been initialized correctly.

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>


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

ALSA: hda - Revive snd_hda_get_conn_list()

Manage the connection list cache using linked lists instead of
snd_array, and revive snd_hda_get_conn_list() again, so that we don't
have to keep the expanded values locally.
This will reduce the stack usage by recursive call of
snd_hda_get_conn_index() or parse_nid_path() of the generic parser.

The list management doesn't include any mutex protection, thus the
caller needs to take care of race appropriately.

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


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

ALSA: hda - Add inv_eapd flag to struct hda_codec

Add the new flag, codec->inv_eapd, indicating that the EAPD
implementation is inverted.

There are always broken hardware in the world.

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>


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

ALSA: hda - Allow aamix in the primary output path

Allow the path including the loopback mixer widget in the primary
output channel as an alternative in the generic codec parser.

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>


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

ALSA: hda - Fix typos in debug_show_configs()

It never showed the 4th line out and headphone pins since quite ago.
Oh well.

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


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

ALSA: hda - Add more debug prints about new paths

Add a better debug print code to show the new assigned paths in
generic parser. It appears only with CONFIG_SND_DEBUG_VERBOSE=y.

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>


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

ALSA: hda - Fix PCM name string for generic parser

When a PCM name string is generated from the chip name, it might
become strange like "CX20549 (Venice) Analog". In this patch, the
parser tries to drop the invalid words like "(Venice)" in the PCM name
string. Also, when the name string is given beforehand by the caller,
respect it and use it as is.

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


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

ALSA: hda - Use cached version for changing pins in hda_generic.c

There is no reason to avoid snd_hda_set_pin_ctl_cache() there.

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


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

ALSA: hda - Dynamically turn on/off EAPD in generic codec driver

When spec->own_eapd_ctl isn't set, try to turn on/off EAPD on demand
for each pin.

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


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

ALSA: hda - Fix initialization of primary outputs in hda_generic.c

There were some old codes that look not stable enough, which was
derived from the old Realtek code. The initialization for primary
output in init_multi_out() needs to consider the case of shared DAC.

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


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

ALSA: hda - Refactor init_extra_out() in hda_generic.c

Just a small clean up by splitting a function.
No functional changes at all.

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


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

ALSA: hda - Clear unsol enable bits on unused pins in generic parser

For preliminary works to migrate the generic parser for Conexant
codecs: the same function is ported to hda_generic.c.
But now it looks through the jack detect table so that it can cover
better.

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>


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

ALSA: hda - Do sequential writes in snd_hda_gen_init()

This would reduce the number of actually executed verbs.

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


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

ALSA: hda - Add / fix comments about capture vol/sw controls in hda_generic.c

A bit of details won't hurt.

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


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

ALSA: hda - Add missing amp cache flush for bound capture vol/sw ctls

The bound capture volume and switch controls use the cached amp
updates, but it's missing the flushing at the end.

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


# 624d914d 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use "Capture Source" for single sources

In general we prefer "Capture Source" to "Input Source".
The latter was chosen in many places just because "Capture Source"
label doesn't work well with the current alsa-lib mixer abstraction
when multiple instances are present. But when we know that there is a
single input-source element, we can safely choose "Capture Source"
label.

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>


# 36502d02 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix NULL dereference in snd_hda_gen_build_controls()

When no controls are assigned in the parser (e.g. no analog path),
spec->kctls.list is still NULL. We need to check it before passing to
snd_hda_add_new_ctls().

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>


# 83012a7c 24-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Clean up CONFIG_SND_HDA_POWER_SAVE

CONFIG_SND_HDA_POWER_SAVE is no longer an experimental feature and its
behavior can be well controlled via the default value and module
parameter. Let's just replace it with the standard CONFIG_PM.

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


# d81a6d71 22-Sep-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

sound: Add export.h for THIS_MODULE/EXPORT_SYMBOL where needed

These aren't modules, but they do make use of these macros, so
they will need export.h to get that definition. Previously,
they got it via the implicit module.h inclusion.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# ea734963 17-Jan-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - consitify string arrays

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


# 10a20af7 09-Sep-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Improve the input source name labels

This patch improves the input-source label strings to be generated from
the pin information instead of fixed strings per AUTO_PIN_* type.
This gives more suitable labels, especially for mic and line-in pins.

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


# b5786e85 09-Sep-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Keep char arrays in input_mux items

Keep char array in the input_mux item itself instead of pointing to
an external string. This is a preliminary work for improving the
input-mux name based on the pin role.

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


# 5b0cb1d8 08-Dec-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - add more NID->Control mapping

This set of changes add missing NID values to some static control
elemenents. Also, it handles all "Capture Source" or "Input Source"
controls.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 3911a4c1 11-Nov-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - proc - introduce Control: lines to show mixer<->NID assignment

This is an initial patch to show universal control<->NID assigment in
proc codec file. The change helps to debug codec related problems.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a22d543a 26-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce get_wcaps_type() macro

Add a helper macro to retrieve the widget type from wiget cap bits.

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


# 254da007 22-Jul-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda_generic: use AC_WCAP_CONN_LIST check for widget connections

Previous patch used widget type, but the presence flag of the connection
list is in the widget capabilities.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 05296048 22-Jul-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda_generic: do not read connections for widged with an unknown type

Reading node connections for an unknown widget can confuse HDA codec bus.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1327a32b 23-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Cache pin-cap values

Added snd_hda_query_pin_caps() to read and cache pin-cap values
to avoid too frequently issuing the same verbs.

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


# c17a1aba 23-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use snd_hda_codec_get_pincfg() in the rest places

Replace with snd_hda_codec_get_pincfg() in the places where available.

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


# 1289e9e8 27-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Modularize HD-audio driver

Split the monolithc HD-audio driver into several pieces:
- snd-hda-intel HD-audio PCI controller driver; loaded via udev
- snd-hda-codec HD-audio codec bus driver
- snd-hda-codec-* Specific HD-audio codec drivers

When built as modules, snd-hda-codec (that is invoked by snd-hda-intel)
looks up the codec vendor ID and loads the corresponding codec module
automatically via request_module().

When built in a kernel, each codec drivers are statically hooked up
before probing the PCI.

This patch adds appropriate EXPORT_SYMBOL_GPL()'s and the module
information for each driver, and driver-linking codes between
codec-bus and codec drivers.

TODO:
- Avoid EXPORT_SYMBOL*() when built-in kernel
- Restore __devinit appropriately depending on the condition

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


# d13bd412 30-Jul-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Manage kcontrol lists

Manage all kcontrol elements created in the hda-intel driver.
This makes it possible to remove and reconfigure the controls
of each codec.

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


# da3cec35 08-Aug-2008 Takashi Iwai <tiwai@suse.de>

ALSA: Kill snd_assert() in sound/pci/*

Kill snd_assert() in sound/pci/*, either removed or replaced with
if () with snd_BUG_ON().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 888afa15 18-Mar-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - keep the format verb at closing PCM streams

Keep the format verb at closing PCM streams.
Introduced snd_hda_codec_cleanup_stream() for the parcicular purpose.

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


# 9004acc7 08-Jan-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] Remove sound/driver.h

This header file exists only for some hacks to adapt alsa-driver
tree. It's useless for building in the kernel. Let's move a few
lines in it to sound/core.h and remove it.
With this patch, sound/driver.h isn't removed but has just a single
compile warning to include it. This should be really killed in
future.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 33206e86 17-Sep-2007 Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

[ALSA] Intel HD Audio: Use list_for_each_entry(_safe)

Intel HD Audio: Use list_for_each_entry(_safe) instead of
list_for_each(_safe)

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# cb53c626 10-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Add POWER_SAVE option

Added CONFIG_SND_HDA_POWER_SAVE kconfig. It's an experimental option
to achieve an aggressive power-saving. With this option, the driver
will turn on/off the power of each codec and controller chip dynamically
on demand.
The patch introduces a new module option 'power_save'. It specifies
the second of time-out for automatic power-down. As default, it's
10 seconds. Setting 0 means to suppress the power-saving feature.
The codec may have analog-input loopbacks, which are usually represented
by mixer elements such as 'Mic Playback Switch' or 'CD Playback Switch'.
When these are on, we cannot turn off the mixer and the codec chip has
to be kept on. For bookkeeping these states, a new codec-callback is
introduced.
For the bus-controller side, a new callback pm_notify is introduced,
which can be used to turn on/off the contoller appropriately.
Note that this power-saving might cause slight click-noise at
power-on/off. Also, it might take some time to wake up the codec, and
might even drop some tones at the very beginning. This seems to be the
side-effect of turning off the controller chip.
This turn-off of the controller can be disabled by undefining
HDA_POWER_SAVE_RESET_CONTOLLER in hda_intel.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 47fd830a 10-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - add snd_hda_codec_stereo() function

Added snd_hda_codec_amp_stereo() function that changes both of stereo
channels with the same mask and value bits. It simplifies most of
amp-handling codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 82beb8fd 10-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - optimize resume using caches

So far, the driver looked the table of snd_kcontrol_new used for creating
mixer elements and forces to call each of its put callbacks in PM resume
code. This is too ugly and hackish.
Now, the resume is simplified using the codec amp and command register
caches. The driver simply restores the values that have been written
in the cache table. With this simplification, most codec support codes
don't require any special resume callback.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 0bbed758 08-May-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix connection list in generic parser

Fix the retrival of widget connection list in the generic parser.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 6473d160 06-Mar-2007 Jean Delvare <khali@linux-fr.org>

PCI: Cleanup the includes of <linux/pci.h>

I noticed that many source files include <linux/pci.h> while they do
not appear to need it. Here is an attempt to clean it all up.

In order to find all possibly affected files, I searched for all
files including <linux/pci.h> but without any other occurence of "pci"
or "PCI". I removed the include statement from all of these, then I
compiled an allmodconfig kernel on both i386 and x86_64 and fixed the
false positives manually.

My tests covered 66% of the affected files, so there could be false
positives remaining. Untested files are:

arch/alpha/kernel/err_common.c
arch/alpha/kernel/err_ev6.c
arch/alpha/kernel/err_ev7.c
arch/ia64/sn/kernel/huberror.c
arch/ia64/sn/kernel/xpnet.c
arch/m68knommu/kernel/dma.c
arch/mips/lib/iomap.c
arch/powerpc/platforms/pseries/ras.c
arch/ppc/8260_io/enet.c
arch/ppc/8260_io/fcc_enet.c
arch/ppc/8xx_io/enet.c
arch/ppc/syslib/ppc4xx_sgdma.c
arch/sh64/mach-cayman/iomap.c
arch/xtensa/kernel/xtensa_ksyms.c
arch/xtensa/platform-iss/setup.c
drivers/i2c/busses/i2c-at91.c
drivers/i2c/busses/i2c-mpc.c
drivers/media/video/saa711x.c
drivers/misc/hdpuftrs/hdpu_cpustate.c
drivers/misc/hdpuftrs/hdpu_nexus.c
drivers/net/au1000_eth.c
drivers/net/fec_8xx/fec_main.c
drivers/net/fec_8xx/fec_mii.c
drivers/net/fs_enet/fs_enet-main.c
drivers/net/fs_enet/mac-fcc.c
drivers/net/fs_enet/mac-fec.c
drivers/net/fs_enet/mac-scc.c
drivers/net/fs_enet/mii-bitbang.c
drivers/net/fs_enet/mii-fec.c
drivers/net/ibm_emac/ibm_emac_core.c
drivers/net/lasi_82596.c
drivers/parisc/hppb.c
drivers/sbus/sbus.c
drivers/video/g364fb.c
drivers/video/platinumfb.c
drivers/video/stifb.c
drivers/video/valkyriefb.c
include/asm-arm/arch-ixp4xx/dma.h
sound/oss/au1550_ac97.c

I would welcome test reports for these files. I am fine with removing
the untested files from the patch if the general opinion is that these
changes aren't safe. The tested part would still be nice to have.

Note that this patch depends on another header fixup patch I submitted
to LKML yesterday:
[PATCH] scatterlist.h needs types.h
http://lkml.org/lkml/2007/3/01/141

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Badari Pulavarty <pbadari@us.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 6afeb11d 18-Dec-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix NULL dereference in generic hda code

Fix NULL dereference in hda_generic.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# a7da6ce5 06-Sep-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add independent headphone volume control

This patch addes the support of the independent 'Headphone' volume
control to the generic codec parser. Some codecs (e.g. Conexant)
have separate connections to the headphone and the independent amp
adjustment is needed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 071c73ad 23-Aug-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix mic capture with generic parser

Fixed the mic capture with generic parser of hda-codec driver
- Use VREF80 for mic pins if available
- Handle multiple inputs correctly on audio-input widget node.
Confirmed on a conexant codec chip.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 97ec558a 21-Mar-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix generic auto-configurator

Modules: HDA generic driver

Fixed the generic auto-configurator to check speaker pins in
addition.

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


# d2569505 21-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Allocate connection lists dynamically in generic parser

Modules: HDA generic driver

Allocate connection lists dynamically in generic parser.

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


# c8b6bf9b 17-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Remove xxx_t typedefs: HD-Audio codec

Modules: HDA Codec driver,HDA generic driver

Remove xxx_t typedefs from the HD-Audio codec support codes.

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


# 84802f0d 13-Sep-2005 Sasha Khapyorsky <sashak@smlink.com>

[ALSA] hda-codec - 'empty' generic mfg-only codec

HDA generic driver
This creates 'empty' hda generic for unknown MFG-only codecs.

Signed-off-by: Sasha Khapyorsky <sashak@smlink.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e560d8d8 09-Sep-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Replace with kzalloc() - pci stuff

AD1889 driver,ATIIXP driver,ATIIXP-modem driver,AZT3328 driver
BT87x driver,CMIPCI driver,CS4281 driver,ENS1370/1+ driver
ES1938 driver,ES1968 driver,FM801 driver,Intel8x0 driver
Intel8x0-modem driver,Maestro3 driver,SonicVibes driver,VIA82xx driver
VIA82xx-modem driver,AC97 Codec,AK4531 codec,au88x0 driver
CA0106 driver,CS46xx driver,EMU10K1/EMU10K2 driver,HDA Codec driver
HDA generic driver,HDA Intel driver,ICE1712 driver,ICE1724 driver
KORG1212 driver,MIXART driver,NM256 driver,Trident driver,YMFPCI driver
Replace kcalloc(1,..) with kzalloc().

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


# 673b683a 11-Aug-2005 Sasha Khapyorsky <sashak@smlink.com>

ALSA CVS update
HDA Codec driver,HDA generic driver
Summar: hda-codec - MFG support

This adds Modem Functional Group (MFG) support and option for 9600
sample rate.

Signed-off-by: Sasha Khapyorsky <sashak@smlink.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e9edcee0 13-Jun-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - More fix of ALC880 codec support

Documentation,HDA Codec driver,HDA generic driver,HDA Intel driver
- Fix some invalid configurations, typos in the last patch
- Make init_verbs chainable, so that different configs can share the same
init_verbs
- Reorder and clean up the source codes in patch_realtek.c
- Add the pin default configuration parser, used commonly in cmedia
and realtek patch codes.
- Add 'auto' model to ALC880 for auto-configuration from BIOS
Use this model as default, and 3-stack as fallback

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


# c3132925 20-Apr-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Fix a typo in comments

HDA generic driver
Fix a typo in comments.

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


# 1a12de1e 13-Apr-2005 Matt <matt@embeddedalley.com>

[ALSA] hda: fix vref cap and ctl values

HDA Codec driver,HDA generic driver
Fix some vref defines so they are valid for the different bits in
the pin cap and pin control registers. Please apply.

Signed-off-by: Matt <matt@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!