History log of /linux-master/sound/pci/hda/hda_codec.c
Revision Date Author Comments
# ee14bad1 26-Feb-2024 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Reuse for_each_pcm_streams()

Use the macro to improve readability.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20240226124432.1203798-6-cezary.rojewski@intel.com


# a7fc8b86 17-Nov-2023 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Honor subformat when querying PCMs

Update mechanism for querying supported PCMs to allow for granular
format selection when container size is 32 bits. Currently always the
highest bit depth is selected, regardless of how many actual formats
codec in question supports.

Acked-by: Mark Brown <broonie@kernel.org>
Co-developed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20231117120610.1755254-3-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 81420faf 22-Sep-2023 Kees Cook <keescook@chromium.org>

ALSA: hda: Annotate struct hda_conn_list with __counted_by

Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).

As found with Coccinelle[1], add __counted_by for struct hda_conn_list.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20230922175042.work.547-kees@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 192c4ccc 18-Jul-2023 Takashi Iwai <tiwai@suse.de>

ALSA: control: Take controls_rwsem lock in snd_ctl_remove()

So far, snd_ctl_remove() requires its caller to take
card->controls_rwsem manually before the call for avoiding possible
races. However, many callers don't care and miss the locking.

Basically it's cumbersome and error-prone to enforce it to each
caller. Moreover, card->controls_rwsem is a field that should be used
only by internal or proper helpers, and it's not to be touched at
random external places.

This patch is an attempt to make those calls more consistent: now
snd_ctl_remove() takes the card->controls_rwsem internally, just like
other API functions for kctls. Since a few callers already take the
controls_rwsem locks, the patch removes those locks at the same time,
too.

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


# 5c219a34 06-Jun-2023 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Fix kctl->id initialization

HD-audio core code replaces the kctl->id.index of SPDIF-related
controls after assigning via snd_ctl_add(). This doesn't work any
longer with the new Xarray lookup change. The change of the kctl->id
content has to be done via snd_ctl_rename_id() helper, instead.

Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups")
Cc: <stable@vger.kernel.org>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230606093855.14685-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d045bcef 02-Feb-2023 Jaroslav Kysela <perex@perex.cz>

ALSA: hda: Fix the control element identification for multiple codecs

Some motherboards have multiple HDA codecs connected to the serial bus.
The current code may create multiple mixer controls with the almost
identical identification.

The current code use id.device field from the control element structure
to store the codec address to avoid such clashes for multiple codecs.
Unfortunately, the user space do not handle this correctly. For mixer
controls, only name and index are used for the identifiers.

This patch fixes this problem to compose the index using the codec
address as an offset in case, when the control already exists. It is
really unlikely that one codec will create 10 similar controls.

This patch adds new kernel module parameter 'ctl_dev_id' to allow
select the old behaviour, too. The CONFIG_SND_HDA_CTL_DEV_ID Kconfig
option sets the default value.

BugLink: https://github.com/alsa-project/alsa-lib/issues/294
BugLink: https://github.com/alsa-project/alsa-lib/issues/205
Fixes: 54d174031576 ("[ALSA] hda-codec - Fix connection list parsing")
Fixes: 1afe206ab699 ("ALSA: hda - Try to find an empty control index when it's occupied")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230202092013.4066998-1-perex@perex.cz
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3af4a4f7 10-Feb-2023 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Fix codec device field initializan

Commit f2bd1c5ae2cb ("ALSA: hda: Fix page fault in
snd_hda_codec_shutdown()") relocated initialization of several codec
device fields. Due to differences between codec_exec_verb() and
snd_hdac_bus_exec_bus() in how they handle VERB execution - the latter
does not touch PM - assigning ->exec_verb to codec_exec_verb() causes PM
to be engaged before it is configured for the device. Configuration of
PM for the ASoC HDAudio sound card is done with snd_hda_set_power_save()
during skl_hda_audio_probe() whereas the assignment happens early, in
snd_hda_codec_device_init().

Revert to previous behavior to avoid problems caused by too early PM
manipulation.

Suggested-by: Jason Montleon <jmontleo@redhat.com>
Link: https://lore.kernel.org/regressions/CALFERdzKUodLsm6=Ub3g2+PxpNpPtPq3bGBLbff=eZr9_S=YVA@mail.gmail.com
Fixes: f2bd1c5ae2cb ("ALSA: hda: Fix page fault in snd_hda_codec_shutdown()")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230210165541.3543604-1-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 87978e6a 19-Jan-2023 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Do not unset preset when cleaning up codec

Several functions that take part in codec's initialization and removal
are re-used by ASoC codec drivers implementations. Drivers mimic the
behavior of hda_codec_driver_probe/remove() found in
sound/pci/hda/hda_bind.c with their component->probe/remove() instead.

One of the reasons for that is the expectation of
snd_hda_codec_device_new() to receive a valid pointer to an instance of
struct snd_card. This expectation can be met only once sound card
components probing commences.

As ASoC sound card may be unbound without codec device being actually
removed from the system, unsetting ->preset in
snd_hda_codec_cleanup_for_unbind() interferes with module unload -> load
scenario causing null-ptr-deref. Preset is assigned only once, during
device/driver matching whereas ASoC codec driver's module reloading may
occur several times throughout the lifetime of an audio stack.

Suggested-by: Takashi Iwai <tiwai@suse.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230119143235.1159814-1-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ee0b089d 08-Dec-2022 Kai Vehmanen <kai.vehmanen@linux.intel.com>

ALSA: hda/hdmi: fix stream-id config keep-alive for rt suspend

When the new style KAE keep-alive implementation is used on compatible
Intel hardware, the clocks are maintained when codec is in D3. The
generic code in hda_cleanup_all_streams() can however interfere with
generation of audio samples in this mode, by setting the stream and
channel ids to zero.

To get full benefit of the keepalive, set the new
no_stream_clean_at_suspend quirk bit on affected Intel hardware. When
this bit is set, stream cleanup is skipped in hda_call_codec_suspend().

Special handling is needed for the case when system goes to suspend. The
stream id programming can be lost in this case. This will also cause
codec->cvt_setups to be out of sync. Handle this by implementing custom
suspend/resume handlers. If keep-alive is active for any converter, set
the quirk flags no_stream_clean_at_suspend and forced_resume. Upon
resume, keepalive programming is restored if needed.

Fixes: 15175a4f2bbb ("ALSA: hda/hdmi: add keep-alive support for ADL-P and DG2")
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20221209101822.3893675-4-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f2bd1c5a 16-Aug-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Fix page fault in snd_hda_codec_shutdown()

If early probe of HDAudio bus driver fails e.g.: due to missing
firmware file, snd_hda_codec_shutdown() ends in manipulating
uninitialized codec->pcm_list_head causing page fault.

Initialization of HDAudio codec in ASoC is split in two:
- snd_hda_codec_device_init()
- snd_hda_codec_device_new()

snd_hda_codec_device_init() is called during probe_codecs() by HDAudio
bus driver while snd_hda_codec_device_new() is called by
codec-component's ->probe(). The second call will not happen until all
components required by related sound card are present within the ASoC
framework. With firmware failing to load during the PCI's deferred
initialization i.e.: probe_work(), no platform components are ever
registered. HDAudio codec enumeration is done at that point though, so
the codec components became registered to ASoC framework, calling
snd_hda_codec_device_init() in the process.

Now, during platform reboot snd_hda_codec_shutdown() is called for every
codec found on the HDAudio bus causing oops if any of them has not
completed both of their initialization steps. Relocating field
initialization fixes the issue.

Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220816111727.3218543-7-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0c5c29ca 16-Aug-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Always free codec on the device release

With all HDAudio drivers aligned to make use of the same constructor,
have codec freed on the device release regardless of its type.

Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220816111727.3218543-5-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 636aa880 10-Aug-2022 Mohan Kumar <mkumard@nvidia.com>

ALSA: hda: Fix crash due to jack poll in suspend

With jackpoll_in_suspend flag set, there is a possibility that
jack poll worker thread will run even after system suspend was
completed. Any register access after system pm callback flow
will result in kernel crash as still jack poll worker thread
tries to access registers.

To fix the crash issue during system flow, cancel the jack poll
worker thread during system pm prepare callback and cancel the
worker thread at start of runtime suspend callback and re-schedule
at last to avoid any unwarranted access of register by worker thread
during suspend flow.

Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Fixes: b33115bd05af ("ALSA: hda: Jack detection poll in suspend state")
Link: https://lore.kernel.org/r/20220811052704.2944-1-mkumard@nvidia.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 53f07e9b 15-Jul-2022 Takashi Iwai <tiwai@suse.de>

Revert "ALSA: hda: Fix page fault in snd_hda_codec_shutdown()"

This reverts commit 980b3a8790b402e959a6d773b38b771019682be1.

The commit didn't consider the fact that ASoC hdac-hda driver
initializes the HD-audio stuff without calling
snd_hda_codec_device_init(). Hence this caused a regression leading
to Oops.

Revert the commit to restore the behavior.

Fixes: 980b3a8790b4 ("ALSA: hda: Fix page fault in snd_hda_codec_shutdown()")
Link: https://lore.kernel.org/r/3c40df55-3aee-1e08-493b-7b30cd84dc00@linux.intel.com
Link: https://lore.kernel.org/r/20220715182903.19594-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# e7255c00 06-Jul-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Skip event processing for unregistered codecs

When codec is unbound but not yet removed, in the eyes of
snd_hdac_bus_process_unsol_events() it is still a valid target to
delegate work to. Such behaviour may lead to use-after-free errors.
Address by verifying if codec is actually registered.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-6-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 980b3a87 06-Jul-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Fix page fault in snd_hda_codec_shutdown()

If early probe of HDAudio bus driver fails e.g.: due to missing
firmware file, snd_hda_codec_shutdown() ends in manipulating
uninitialized codec->pcm_list_head causing page fault.

Iinitialization of HDAudio codec in ASoC is split in two:
- snd_hda_codec_device_init()
- snd_hda_codec_device_new()

snd_hda_codec_device_init() is called during probe_codecs() by HDAudio
bus driver while snd_hda_codec_device_new() is called by
codec-component's ->probe(). The second call will not happen until all
components required by related sound card are present within the ASoC
framework. With firmware failing to load during the PCI's deferred
initialization i.e.: probe_work(), no platform components are ever
registered. HDAudio codec enumeration is done at that point though, so
the codec components became registered to ASoC framework, calling
snd_hda_codec_device_init() in the process.

Now, during platform reboot snd_hda_codec_shutdown() is called for every
codec found on the HDAudio bus causing oops if any of them has not
completed both of their initialization steps. Relocating field
initialization fixes the issue.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-7-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ebe043a3 06-Jul-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Fix put_device() inconsistency in error path

AVS HDAudio bus driver does not tie with codec drivers tighly. Codec
device and its respective driver cleanup procedures are split and may
not occur one after the other. Device cleanup is performed only on
snd_hdac_ext_bus_device_remove() i.e. it's the bus driver's
responsibility. If codec component probing fails, put_device() found in
snd_hda_codec_device_new() may lead to page fault. Relocate it to
snd_hda_codec_new() to address the problem on ASoC side while keeping
status quo for snd_hda_intel.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-5-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9c76958b 06-Jul-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Make device usage_count consistent across subsequent probing

AVS HDAudio bus driver does not tie with codec drivers tighly and
snd_hda_codec_device_new() can be called after codec's module reload. In
such case, rpm is forbidden and invoking pm_runtime_forbid()
unconditionally causes device's usage_count to become unbalanced. This
is later caught by WARN_ON() found in sound/soc/hda.c. Detect such
circumstance and bump the usage_count instead.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220706120230.427296-4-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b33115bd 11-Apr-2022 Mohan Kumar <mkumard@nvidia.com>

ALSA: hda: Jack detection poll in suspend state

HDA Jack detection logic doesn't work when the HDACODEC
in runtime suspended state as unsol event won't be triggered
during D3 state. As pulseaudio server in userspace rely on the
jack mixer control status to show the audio devices in gui and
any display sink device hotplug event during D3 state will never
updates the jack status which will result in no audio device option
available in userspace settings.

The possible option available to resolve this issue is to run Jack
polling worker thread even after codec suspend state. The choice can
be made based on compromise between power saving or Jack detection in
suspend state.

Signed-off-by: Mohan Kumar <mkumard@nvidia.com>
Link: https://lore.kernel.org/r/20220411073210.23445-2-mkumard@nvidia.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bb682f7a 14-Feb-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Expose codec cleanup and power-save functions

With few changes, snd_hda_codec_set_power_save() and
snd_hda_codec_cleanup_for_unbind() can be re-used by ASoC drivers.
While at it, provide kernel doc for the exposed functions.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220214101404.4074026-5-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 17e0c4cb 14-Feb-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Update and expose codec register procedures

With few changes, snd_hda_codec_register() and its
unregister-counterpart can be re-used by ASoC drivers. While at it,
provide kernel doc for the exposed functions.

Due to ALSA-device vs ASoC-component organization differences, new
'snddev_managed' argument is specified allowing for better control over
codec registration process.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220214101404.4074026-4-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 595511a3 14-Feb-2022 Cezary Rojewski <cezary.rojewski@intel.com>

ALSA: hda: Update and expose snd_hda_codec_device_init()

With few changes, snd_hda_codec_device_init() can be re-used by ASoC
drivers. While at it, provide kernel doc for the exposed function.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20220214101404.4074026-3-cezary.rojewski@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1c7f0e34 01-Feb-2022 Peter Ujfalusi <peter.ujfalusi@linux.intel.com>

ALSA: hda: Skip codec shutdown in case the codec is not registered

If the codec->registered is not set then it means that pm_runtime is
not yet enabled and the codec->pcm_list_head has not been initialized.

The access to the not initialized pcm_list_head will lead a kernel crash
during shutdown.

Reported-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Tested-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Fixes: b98444ed597d ("ALSA: hda: Suspend codec at shutdown")
Link: https://lore.kernel.org/r/20220201112144.29411-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7206998f 16-Nov-2021 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Fix potential deadlock at codec unbinding

When a codec is unbound dynamically via sysfs while its stream is in
use, we may face a potential deadlock at the proc remove or a UAF.
This happens since the hda_pcm is managed by a linked list, as it
handles the hda_pcm object release via kref.

When a PCM is opened at the unbinding time, the release of hda_pcm
gets delayed and it ends up with the close of the PCM stream releasing
the associated hda_pcm object of its own. The hda_pcm destructor
contains the PCM device release that includes the removal of procfs
entries. And, this removal has the sync of the close of all in-use
files -- which would never finish because it's called from the PCM
file descriptor itself, i.e. it's trying to shoot its foot.

For addressing the deadlock above, this patch changes the way to
manage and release the hda_pcm object. The kref of hda_pcm is
dropped, and instead a simple refcount is introduced in hda_codec for
keeping the track of the active PCM streams, and at each PCM open and
close, this refcount is adjusted accordingly. At unbinding, the
driver calls snd_device_disconnect() for each PCM stream, then
synchronizes with the refcount finish, and finally releases the object
resources.

Fixes: bbbc7e8502c9 ("ALSA: hda - Allocate hda_pcm objects dynamically")
Link: https://lore.kernel.org/r/20211116072459.18930-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 80bd64af 16-Nov-2021 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Add missing rwsem around snd_ctl_remove() calls

snd_ctl_remove() has to be called with card->controls_rwsem held (when
called after the card instantiation). This patch add the missing
rwsem calls around it.

Fixes: d13bd412dce2 ("ALSA: hda - Manage kcontrol lists")
Link: https://lore.kernel.org/r/20211116071314.15065-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c0f1886d 06-Oct-2021 Takashi Iwai <tiwai@suse.de>

ALSA: hda: intel: Allow repeatedly probing on codec configuration errors

It seems that a few recent AMD systems show the codec configuration
errors at the early boot, while loading the driver at a later stage
works magically. Although the root cause of the error isn't clear,
it's certainly not bad to allow retrying the codec probe in such a
case if that helps.

This patch adds the capability for retrying the probe upon codec probe
errors on the certain AMD platforms. The probe_work is changed to a
delayed work, and at the secondary call, it'll jump to the codec
probing.

Note that, not only adding the re-probing, this includes the behavior
changes in the codec configuration function. Namely,
snd_hda_codec_configure() won't unregister the codec at errors any
longer. Instead, its caller, azx_codec_configure() unregisters the
codecs with the probe failures *if* any codec has been successfully
configured. If all codec probe failed, it doesn't unregister but let
it re-probed -- which is the most case we're seeing and this patch
tries to improve.

Even if the driver doesn't re-probe or give up, it will go to the
"free-all" error path, hence the leftover codecs shall be disabled /
deleted in anyway.

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


# 2eaf1635 26-Aug-2021 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Disable runtime resume at shutdown

Although we modified the codec shutdown callback to perform
runtime-suspend, it's still not fully effective, as this may be
resumed again at any time later.

For fixing such an unwanted resume, this patch replaces
pm_runtime_suspend() with pm_runtime_force_suspend(), and call
pm_runtime_disable() afterward. It assures to keep the device
suspended.

Also for code simplification, we apply the code unconditionally; when
it's been already suspended, nothing would happen by calls of
snd_pcm_suspend_all() and pm_runtime_force_suspend(), just proceed to
pm_runtime_disable().

Fixes: b98444ed597d ("ALSA: hda: Suspend codec at shutdown")
Reported-and-tested-by: Vitaly Rodionov <vitalyr@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210826154752.25674-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda: Suspend codec at shutdown

So far we have a few workarounds at shutdown for each codec,
e.g. turning off the display power and setting the codec to D3.
But all those are basically a part of the suspend procedure.
Moreover, the streams are still active after that call, hence it might
hit the update on the codec that has been already put to D3.

In this patch, instead of calling each reboot_notify callback, simply
put the codec into the runtime-suspended state after the manual
suspend of all PCM streams. It makes the code and the behavior more
consistent.

The reboot_notify callback is no longer used after this patch, and
will be cleaned up later.

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


# 3099406e 23-Jun-2021 Imre Deak <imre.deak@intel.com>

ALSA: hda: Release codec display power during shutdown/reboot

Similarly to the previous patch for the HDA controller make sure here
that codecs also drop the display power reference during shutdown and
reboot.

This fixes a power ref leaked WARN in i915 during shutdown if the HDA
driver is built with CONFIG_PM=n.

Suggested-by: Takashi Iwai <tiwai@suse.de>
References: https://gitlab.freedesktop.org/drm/intel/-/issues/3618
References: https://lore.kernel.org/intel-gfx/s5hzgvhngw6.wl-tiwai@suse.de
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://lore.kernel.org/r/20210623134601.2128663-2-imre.deak@intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b8b90c17 02-Jun-2021 Hui Wang <hui.wang@canonical.com>

ALSA: hda: update the power_state during the direct-complete

The patch_realtek.c needs to check if the power_state.event equals
PM_EVENT_SUSPEND, after using the direct-complete, the suspend() and
resume() will be skipped if the codec is already rt_suspended, in this
case, the patch_realtek.c will always get PM_EVENT_ON even the system
is really resumed from S3.

We could set power_state to PMSG_SUSPEND in the prepare(), if other
PM functions are called before complete(), those functions will
override power_state; if no other PM functions are called before
complete(), we could know the suspend() and resume() are skipped since
only S3 pm functions could be skipped by direct-complete, in this case
set power_state to PMSG_RESUME in the complete(). This could guarantee
the first time of calling hda_codec_runtime_resume() after complete()
has the correct power_state.

Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20210602145424.3132-1-hui.wang@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 618fad3d 09-Apr-2021 Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

ALSA: HDA: Add access description in __snd_hda_add_vmaster

Add description for access parameter in __snd_hda_add_vmaster()
to prevent the compilation warning:
warning: Function parameter or member 'access' not described in '__snd_hda_add_vmaster'

Fixes: e65bf99718b5 ("ALSA: HDA - remove the custom implementation for the audio LED trigger")
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20210409214616.1539685-1-ranjani.sridharan@linux.intel.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>


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


# 2b73649c 19-Jan-2021 Kai-Heng Feng <kai.heng.feng@canonical.com>

ALSA: hda: Balance runtime/system PM if direct-complete is disabled

After hibernation, HDA controller can't be runtime-suspended after
commit 215a22ed31a1 ("ALSA: hda: Refactor codjc PM to use
direct-complete optimization"), which enables direct-complete for HDA
codec.

The HDA codec driver didn't expect direct-complete will be disabled
after it returns a positive value from prepare() callback. However,
there are some places that PM core can disable direct-complete. For
instance, system hibernation or when codec has subordinates like LEDs.

So if the codec is prepared for direct-complete but PM core still calls
codec's suspend or freeze callback, partially revert the commit and take
the original approach, which uses pm_runtime_force_*() helpers to
ensure PM refcount are balanced. Meanwhile, still keep prepare() and
complete() callbacks to enable direct-complete and request a resume for
jack detection, respectively.

Reported-by: Kenneth R. Crudup <kenny@panix.com>
Fixes: 215a22ed31a1 ("ALSA: hda: Refactor codec PM to use direct-complete optimization")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20210119152145.346558-1-kai.heng.feng@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2506318e 09-Dec-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Fix regressions on clear and reconfig sysfs

It seems that the HD-audio clear and reconfig sysfs don't work any
longer after the recent driver core change. There are multiple issues
around that: the linked list corruption and the dead device handling.
The former issue is fixed by another patch for the driver core itself,
while the latter patch needs to be addressed in HD-audio side.

This patch corresponds to the latter, it recovers those broken
functions by replacing the device detach and attach actions with the
standard core API functions, which are almost equivalent with unbind
and bind actions.

Fixes: 654888327e9f ("driver core: Avoid binding drivers to dead devices")
Cc: <stable@vger.kernel.org>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209207
Link: https://lore.kernel.org/r/20201209150119.7705-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 215a22ed 27-Oct-2020 Kai-Heng Feng <kai.heng.feng@canonical.com>

ALSA: hda: Refactor codec PM to use direct-complete optimization

Upon system resume, hda_codec_pm_resume() uses hda_codec_force_resume()
to resume the codec. However, pm_runtime_force_resume() won't really
resume the codec because of pm_runtime_need_not_resume() check.

Hence, hda_codec_force_resume() schedules a jackpoll work, which is to
really power up the codec.

Instead of doing that, we can use direct-complete to make the PM flow
more straightforward, and keep codec always suspended through system PM
flow if conditions are met.

On system suspend, PM core will decide what to do based on
hda_codec_pm_prepare():
- If codec is not runtime-suspended, PM core will suspend and resume the
device as normal.
- If codec is runtime-suspended, PM core will try to keep it suspended.
If it's still suspended after system resume, we use
hda_codec_pm_complete() to resume codec if it's needed.

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


# a0645daf 30-Sep-2020 Harsha Priya <harshapriya.n@intel.com>

ALSA: HDA: Early Forbid of runtime PM

For certain codecs (like Realtek), pm_runtime_forbid() is invoked
in the probe function after build_controls(). In a stress test,
its observed occasionally that runtime PM calls are invoked
before controls are built. This causes the codec to be
runtime suspended before probe completes. Because of this, not all
controls are enumerated correctly, and audio does not work until
system is rebooted.

This issue being common across all codecs, pm_runtime_forbid() is
called when the codec object is created to fix this issue.
A codec enables or disables runtime pm in its own probe function.

Multiple stress tests of 2000+ cycles has been done to test the fix.

Signed-off-by: Harsha Priya <harshapriya.n@intel.com>
Signed-off-by: Emmanuel Jillela <emmanuel.jillela@intel.com>
Reviewed-by: Kailang Yang <kailang@realtek.com>
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200930114140.3839617-2-kai.vehmanen@linux.intel.com
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>


# 7fcd9bb5 28-Jul-2020 Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

ALSA: hda: fix NULL pointer dereference during suspend

When the ASoC card registration fails and the codec component driver
never probes, the codec device is not initialized and therefore
memory for codec->wcaps is not allocated. This results in a NULL pointer
dereference when the codec driver suspend callback is invoked during
system suspend. Fix this by returning without performing any actions
during codec suspend/resume if the card was not registered successfully.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/20200728231011.1454066-1-ranjani.sridharan@linux.intel.com
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>


# 95ce82ac 15-Jul-2020 Kai Vehmanen <kai.vehmanen@linux.intel.com>

ALSA: hda: fix snd_hda_codec_cleanup() documentation

Fix a copy and paste error in snd_hda_codec_cleanup()
documentation.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200715174551.3730165-3-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# cc1d0cd8 15-Jul-2020 Kai Vehmanen <kai.vehmanen@linux.intel.com>

ALSA: hda: export snd_hda_codec_cleanup_for_unbind()

To avoid duplicated code for cleanup, and match the already exported
snd_hda_codec_pcm_new(), also export snd_hda_codec_cleanup_for_unbind().

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20200715174551.3730165-2-kai.vehmanen@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 8d6762af 22-Apr-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Always use jackpoll helper for jack update after resume

HD-audio codec driver applies a tricky procedure to forcibly perform
the runtime resume by mimicking the usage count even if the device has
been runtime-suspended beforehand. This was needed to assure to
trigger the jack detection update after the system resume.

And recently we also applied the similar logic to the HD-audio
controller side. However this seems leading to some inconsistency,
and eventually PCI controller gets screwed up.

This patch is an attempt to fix and clean up those behavior: instead
of the tricky runtime resume procedure, the existing jackpoll work is
scheduled when such a forced codec resume is required. The jackpoll
work will power up the codec, and this alone should suffice for the
jack status update in usual cases. If the extra polling is requested
(by checking codec->jackpoll_interval), the manual update is invoked
after that, and the codec is powered down again.

Also, we filter the spurious wake up of the codec from the controller
runtime resume by checking codec->relaxed_resume flag. If this flag
is set, basically we don't need to wake up explicitly, but it's
supposed to be done via the audio component notifier.

Fixes: c4c8dd6ef807 ("ALSA: hda: Skip controller resume if not needed")
Link: https://lore.kernel.org/r/20200422203744.26299-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c4c8dd6e 13-Apr-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Skip controller resume if not needed

The HD-audio controller does system-suspend and resume operations by
directly calling its helpers __azx_runtime_suspend() and
__azx_runtime_resume(). However, in general, we don't have to resume
always the device fully at the system resume; typically, if a device
has been runtime-suspended, we can leave it to runtime resume.

Usually for achieving this, the driver would call
pm_runtime_force_suspend() and pm_runtime_force_resume() pairs in the
system suspend and resume ops. Unfortunately, this doesn't work for
the resume path in our case. For handling the jack detection at the
system resume, a child codec device may need the (literally) forcibly
resume even if it's been runtime-suspended, and for that, the
controller device must be also resumed even if it's been suspended.

This patch is an attempt to improve the situation. It replaces the
direct __azx_runtime_suspend()/_resume() calls with with
pm_runtime_force_suspend() and pm_runtime_force_resume() with a slight
trick as we've done for the codec side. More exactly:

- azx_has_pm_runtime() check is dropped from azx_runtime_suspend() and
azx_runtime_resume(), so that it can be properly executed from the
system-suspend/resume path

- The WAKEEN handling depends on the card's power state now; it's set
and cleared only for the runtime-suspend

- azx_resume() checks whether any codec may need the forcible resume
beforehand. If the forcible resume is required, it does temporary
PM refcount up/down for actually triggering the runtime resume.

- A new helper function, hda_codec_need_resume(), is introduced for
checking whether the codec needs a forcible runtime-resume, and the
existing code is rewritten with that.

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


# 44eeb081 18-Feb-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs

Some code in HD-audio driver calls snprintf() in a loop and still
expects that the return value were actually written size, while
snprintf() returns the expected would-be length instead. When the
given buffer limit were small, this leads to a buffer overflow.

Use scnprintf() for addressing those issues. It returns the actually
written size unlike snprintf().

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


# bb80b964 11-Feb-2020 Gustavo A. R. Silva <gustavo@embeddedor.com>

ALSA: hda_codec: Replace zero-length array with flexible-array member

The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
int stuff;
struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertenly introduced[3] to the codebase from now on.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Link: https://lore.kernel.org/r/20200211200739.GA12948@embeddedor
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>


# bf82326f 05-Jan-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: More constifications

Apply const prefix to the remaining possible places: the string
tables, the rate tables, the verb tables, the index tables, etc.

Just for minor optimization and no functional changes.

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


# 35ace5e8 03-Jan-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Constify snd_kcontrol_new items

Most of snd_kcontrol_new definitions are read-only and passed as-is.
Let's declare them as const for further optimization.

There should be no functional changes by this patch.

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


# 41f394a8 03-Jan-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Constify snd_device_ops definitions

Now we may declare const for snd_device_ops definitions, so let's do
it for optimization.

There should be no functional changes by this patch.

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


# ef9bec27 26-Jun-2019 Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

ASoC: SOF: Intel: hda: Make hdac_device device-managed

snd_hdac_ext_bus_device_exit() has been recently modified
to no longer free the hdac device. SOF allocates memory for
hdac_device and hda_hda_priv with kzalloc. Make them
device-managed instead so that they will be freed when the
SOF driver is unloaded.

Because of the above change, hda_codec is device-managed and
it will be freed when the ASoC device is removed. Freeing
the codec in snd_hda_codec_dev_release() leads to kernel
panic while unloading and reloading the ASoC driver. So,
avoid freeing the hda_codec for ASoC driver. This is done in
the same patch to avoid bisect failure.

Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20190626070450.7229-1-ranjani.sridharan@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>


# 59d81c1e 16-Jul-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Optimize resume for codecs without jack detection

The codecs without jack detection also don't have to be resumed
forcibly because, obviously, they have no jack. Skip the forced
resume in such a case as optimization as well.

Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4914da2f 16-Jul-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't resume forcibly i915 HDMI/DP codec

We apply the codec resume forcibly at system resume callback for
updating and syncing the jack detection state that may have changed
during sleeping. This is, however, superfluous for the codec like
Intel HDMI/DP, where the jack detection is managed via the audio
component notification; i.e. the jack state change shall be reported
sooner or later from the graphics side at mode change.

This patch changes the codec resume callback to avoid the forcible
resume conditionally with a new flag, codec->relaxed_resume, for
reducing the resume time. The flag is set in the codec probe.

Although this doesn't fix the entire bug mentioned in the bugzilla
entry below, it's still a good optimization and some improvements are
seen.

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


# 774a075a 03-Jul-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Simplify snd_hdac_refresh_widgets()

Along with the recent fix for the races of snd_hdac_refresh_widgets()
it turned out that the instantiation of widgets sysfs at
snd_hdac_sysfs_reinit() could cause a race. The race itself was
already covered later by extending the mutex protection range, the
commit 98482377dc72 ("ALSA: hda: Fix widget_mutex incomplete
protection"), but this also indicated that the call of *_reinit() is
basically superfluous, as the widgets shall be created sooner or later
from snd_hdac_device_register().

This patch removes the redundant call of snd_hdac_sysfs_reinit() at
first. By this removal, the sysfs argument itself in
snd_hdac_refresh_widgets() becomes superfluous, too, because the only
case sysfs=false is always with codec->widgets=NULL. So, we drop this
redundant argument as well.

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


# d6947bb2 31-May-2019 Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

ASoC: hda: fix unbalanced codec dev refcount for HDA_DEV_ASOC

HDA_DEV_ASOC type codec device refcounts are managed differently
from HDA_DEV_LEGACY devices. The refcount is released explicitly
in snd_hdac_ext_bus_device_remove() for ASOC type devices.
So, remove the put_device() call in snd_hda_codec_dev_free()
for such devices to make the refcount balanced. This will prevent
the NULL pointer exception when the codec driver is released
after the card is freed.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>


# a2d4560f 31-May-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Use struct_size()

For code simplification and safety, use struct_size() macro for
calculating the hda_conn_list object size with the variable array.

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>


# 4d95c517 27-Apr-2019 Bard liao <yung-chuan.liao@linux.intel.com>

ALSA: hda: fix unregister device twice on ASoC driver

snd_hda_codec_device_new() is used by both legacy HDA and ASoC
driver. However, we will call snd_hdac_device_unregister() in
snd_hdac_ext_bus_device_remove() for ASoC device. This patch uses
the type flag in hdac_device struct to determine is it a ASoC device
or legacy HDA device and call snd_hdac_device_unregister() in
snd_hda_codec_dev_free() only if it is a legacy HDA device.

Signed-off-by: Bard liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 183ab39e 13-Apr-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Initialize power_state field properly

The recent commit 98081ca62cba ("ALSA: hda - Record the current power
state before suspend/resume calls") made the HD-audio driver to store
the PM state in power_state field. This forgot, however, the
initialization at power up. Although the codec drivers usually don't
need to refer to this field in the normal operation, let's initialize
it properly for consistency.

Fixes: 98081ca62cba ("ALSA: hda - Record the current power state before suspend/resume calls")
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b5a236c1 18-Mar-2019 Hui Wang <hui.wang@canonical.com>

ALSA: hda - Enforces runtime_resume after S3 and S4 for each codec

Recently we found the audio jack detection stop working after suspend
on many machines with Realtek codec. Sometimes the audio selection
dialogue didn't show up after users plugged headhphone/headset into
the headset jack, sometimes after uses plugged headphone/headset, then
click the sound icon on the upper-right corner of gnome-desktop, it
also showed the speaker rather than the headphone.

The root cause is that before suspend, the codec already call the
runtime_suspend since this codec is not used by any apps, then in
resume, it will not call runtime_resume for this codec. But for some
realtek codec (so far, alc236, alc255 and alc891) with the specific
BIOS, if it doesn't run runtime_resume after suspend, all codec
functions including jack detection stop working anymore.

This problem existed for a long time, but it was not exposed, that is
because when problem happens, if users play sound or open
sound-setting to check audio device, this will trigger calling to
runtime_resume (via snd_hda_power_up), then the codec starts working
again before users notice this problem.

Since we don't know how many codec and BIOS combinations have this
problem, to fix it, let the driver call runtime_resume for all codecs
in pm_resume, maybe for some codecs, this is not needed, but it is
harmless. After a codec is runtime resumed, if it is not used by any
apps, it will be runtime suspended soon and furthermore we don't run
suspend frequently, this change will not add much power consumption.

Fixes: cc72da7d4d06 ("ALSA: hda - Use standard runtime PM for codec power-save control")
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 45571bb8 24-Jan-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use standard device registration for beep

Currently the registration and free of beep input device was done
manually from the register and the disconnect callbacks of the
assigned codec object. This seems working in most cases, but this may
be a cause of some races at probe. Moreover, due to these manual
calls, the total code became unnecessarily lengthy.

This patch rewrites the beep registration code to follow the standard
sound device object style. This allows us reducing the code, in
addition to avoiding the nested device registration calls.

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


# 98081ca6 29-Jan-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Record the current power state before suspend/resume calls

Currently we deal with single codec and suspend codec callbacks for
all S3, S4 and runtime PM handling. But it turned out that we want
distinguish the call patterns sometimes, e.g. for applying some init
sequence only at probing and restoring from hibernate.

This patch slightly modifies the common PM callbacks for HD-audio
codec and stores the currently processed PM event in power_state of
the codec's device.power field, which is currently unused. The codec
callback can take a look at this event value and judges which purpose
it's being called.

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


# 3bb700e7 21-Jan-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix unused variable warning

The unused variable was forgotten to be removed and now we get a
compiler warning:
sound/pci/hda/hda_codec.c: In function 'hda_codec_runtime_suspend':
sound/pci/hda/hda_codec.c:2926:18: warning: unused variable 'pcm'

Fixes: 17bc4815de58 ("ALSA: pci: Remove superfluous snd_pcm_suspend*() calls")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 17bc4815 11-Jan-2019 Takashi Iwai <tiwai@suse.de>

ALSA: pci: Remove superfluous snd_pcm_suspend*() calls

The call of snd_pcm_suspend_all() & co became superfluous since we
call it in the PCM PM ops. Let's remove them.

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


# 029d92c2 08-Dec-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Refactor display power management

The current HD-audio code manages the DRM audio power via too complex
redirections, and this seems even still unbalanced in a corner case as
Intel DRM CI has been intermittently reporting. This patch is a big
surgery for addressing the complexity and the possible unbalance.

Basically the patch changes the display PM in the following ways:

- Both HD-audio controller and codec drivers call a single helper,
snd_hdac_display_power(). (Formerly, the display power control from
a codec was done indirectly via link_power bus ops.)

- snd_hdac_display_power() receives the codec address index. For
turning on/off from the controller, pass HDA_CODEC_IDX_CONTROLLER.

- snd_hdac_display_power() doesn't manage refcounts any longer, but
keeps the power status in bitmap. If any of controller or codecs is
turned on, the function updates the DRM power state via get_power()
or put_power().

Also this refactor allows us more cleanup:

- The link_power bus ops is dropped, so there is no longer indirect
management, as mentioned in the above.

- hdac_device link_power_control flag is moved to hda_codec
display_power_control flag, as it's only for HDA legacy.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106525
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>


# 16037643 30-Aug-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix cancel_work_sync() stall from jackpoll work

On AMD/ATI controllers, the HD-audio controller driver allows a bus
reset upon the error recovery, and its procedure includes the
cancellation of pending jack polling work as found in
snd_hda_bus_codec_reset(). This works usually fine, but it becomes a
problem when the reset happens from the jack poll work itself; then
calling cancel_work_sync() from the work being processed tries to wait
the finish endlessly.

As a workaround, this patch adds the check of current_work() and
applies the cancel_work_sync() only when it's not from the
jackpoll_work.

This doesn't fix the root cause of the reported error below, but at
least, it eases the unexpected stall of the whole system.

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


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


# ebd836ed 25-Jul-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix a sparse warning about snd_ctl_elem_iface_t

The knew->iface field is in snd_ctl_elem_iface_t, which is with
__bitwise, hence it can't be converted implicitly from integer.
Give an explicit cast for the invalid type.

Spotted by sparse:
sound/pci/hda/hda_codec.c:3280:25: warning: restricted snd_ctl_elem_iface_t degrades to integer

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


# 24494d3f 01-Jun-2018 Rakesh Ughreja <rakesh.a.ughreja@intel.com>

ALSA: hda: split snd_hda_codec_new function

Split snd_hda_codec_new into two separate functions.
snd_hda_codec_device_init allocates memory and registers with bus.
snd_hda_codec_device_new initialializes the fields and performs
snd_device_new. This enables reuse of legacy HDA codec drivers as ASoC
codec drivers.

In addition mark some functions with EXPORT_SYMBOL_GPL so that it can
be called by ASoC wrapper around the legacy HDA driver (hdac_hda).

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda - Move in_pm accessors to HDA core

The in_pm atomic in hdac_device is an important field used as a flag
as well as a refcount for PM. The existing snd_hdac_power_up/down
helpers already refer to it in the HD-audio core code, while the code
to actually setting the value (atomic_inc() / _dec()) is open-coded in
HDA legacy side, which is hard to find.

This patch adds the helper functions to set/reset the in_pm counter to
HDA core and use them in HDA legacy side, for making it clearer who /
where the PM is managed.

There is no functional changes, just code refactoring.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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


# 57cb54e5 21-Jun-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMI

Henning Kühn reported that the discrete AMD GPU on his hybrid graphics
laptop no longer runtime-suspends due to the recent commit
07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").

The root cause is that the HDMI codec on AMD GPU doesn't support
CLKSTOP and EPSS, which are currently mandatory for powering down the
HD-audio link at runtime suspend. Because the HD-audio link is still
up, HD-audio controller driver blocks the transition to D3.

For addressing the regression, this patch adds a new flag to indicate
the forced link-down, and sets it for AMD HDMI codecs appropriately
in the codec driver.

Fixes: 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106957
Reported-by: Lukas Wunner <lukas@wunner.de>
Reported-and-tested-by: Henning Kühn <prg@cooco.de>
Cc: <stable@vger.kernel.org> # v4.17+
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6da2ec56 12-Jun-2018 Kees Cook <keescook@chromium.org>

treewide: kmalloc() -> kmalloc_array()

The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
patch replaces cases of:

kmalloc(a * b, gfp)

with:
kmalloc_array(a * b, gfp)

as well as handling cases of:

kmalloc(a * b * c, gfp)

with:

kmalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

kmalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

kmalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The tools/ directory was manually excluded, since it has its own
implementation of kmalloc().

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
kmalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
, ...)
|
kmalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
, ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
kmalloc(
- sizeof(u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
, ...)
|
kmalloc(
- sizeof(u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(__u8) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(char) * COUNT
+ COUNT
, ...)
|
kmalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
, ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
, ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kmalloc
+ kmalloc_array
(
- SIZE * COUNT
+ COUNT, SIZE
, ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
kmalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
|
kmalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
, ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
kmalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
|
kmalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
, ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
kmalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
|
kmalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
, ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
, ...)
|
kmalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
, ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
kmalloc(sizeof(THING) * C2, ...)
|
kmalloc(sizeof(TYPE) * C2, ...)
|
kmalloc(C1 * C2 * C3, ...)
|
kmalloc(C1 * C2, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- sizeof(THING) * E2
+ E2, sizeof(THING)
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * E2
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- (E1) * (E2)
+ E1, E2
, ...)
|
- kmalloc
+ kmalloc_array
(
- E1 * E2
+ E1, E2
, ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>


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


# 08605068 24-Apr-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Sanity check of access to SPDIF controls array

Put WARN_ON() and bail out if the given index is over the allocated
array of the given SPDIF controls. It's merely a sanity check to
catch any potential issues (if any).

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>


# 3b5b899c 23-Jan-2018 Abhijeet Kumar <abhijeet.kumar@intel.com>

ALSA: hda: Make use of core codec functions to sync power state

Since sync_power_state is moved to core it's better to use the helper
function to ensure the actual power state reaches target instead of
using the local helper functions already exsisting in hda code.

Signed-off-by: Abhijeet Kumar <abhijeet.kumar@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d6c0615f 21-Nov-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix yet remaining issue with vmaster 0dB initialization

The previous fix for addressing the breakage in vmaster slave
initialization, commit a91d66129fb9 ("ALSA: hda - Fix incorrect TLV
callback check introduced during set_fs() removal"), introduced a new
helper to process over each slave kctl. However, this helper passes
only the original kctl, not the virtual slave kctl. As a result,
HD-audio driver (which is the only user so far) couldn't initialize
the slave correctly because it's trying to update the value directly
with the original kctl, not with the mapped kctl.

This patch fixes the situation again by passing both the mapped slaved
and original slave kctls to the function. Luckily there is a single
caller as of now, so changing the call signature is no big matter.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=197959
Fixes: a91d66129fb9 ("ALSA: hda - Fix incorrect TLV callback check introduced during set_fs() removal")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9780ded3 18-Oct-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Avoid racy recreation of widget kobjects

The refresh of HD-audio widget sysfs kobjects via
snd_hdac_refresh_widget_sysfs() is slightly racy.
The driver recreates the whole tree from scratch after deleting the
whole. When CONFIG_DEBUG_KOBJECT_RELEASE option is used, kobject
release doesn't happen immediately but delayed, while the re-creation
of the same named kobject happens soon after invoking kobject_put().
This may end up with the conflicts of duplicated kobjects, as found in
the bug report below.

In this patch, we take another approach to refresh the tree: instead
of recreating the whole tree, just add the new nodes and delete the
non-existing nodes. Since the refresh happens only once at
initialization, no longer race would happen.

Along with the code change, merge snd_hdac_refresh_widget_sysfs() with
the existing snd_hdac_refresh_widgets() with an additional bool flag
for simplifying the code.

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


# a91d6612 16-Oct-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix incorrect TLV callback check introduced during set_fs() removal

The commit 99b5c5bb9a54 ("ALSA: hda - Remove the use of set_fs()")
converted the get_kctl_0dB_offset() call for killing set_fs() usage in
HD-audio codec code. The conversion assumed that the TLV callback
used in HD-audio code is only snd_hda_mixer_amp() and applies the TLV
calculation locally.

Although this assumption is correct, and all slave kctls are actually
with that callback, the current code is still utterly buggy; it
doesn't hit this condition and falls back to the next check. It's
because the function gets called after adding slave kctls to vmaster.
By assigning a slave kctl, the slave kctl object is faked inside
vmaster code, and the whole kctl ops are overridden. Thus the
callback op points to a different value from what we've assumed.

More badly, as reported by the KERNEXEC and UDEREF features of PaX,
the code flow turns into the unexpected pitfall. The next fallback
check is SNDRV_CTL_ELEM_ACCESS_TLV_READ access bit, and this always
hits for each kctl with TLV. Then it evaluates the callback function
pointer wrongly as if it were a TLV array. Although currently its
side-effect is fairly limited, this incorrect reference may lead to an
unpleasant result.

For addressing the regression, this patch introduces a new helper to
vmaster code, snd_ctl_apply_vmaster_slaves(). This works similarly
like the existing map_slaves() in hda_codec.c: it loops over the slave
list of the given master, and applies the given function to each
slave. Then the initializer function receives the right kctl object
and we can compare the correct pointer instead of the faked one.

Also, for catching the similar breakage in future, give an error
message when the unexpected TLV callback is found and bail out
immediately.

Fixes: 99b5c5bb9a54 ("ALSA: hda - Remove the use of set_fs()")
Reported-by: PaX Team <pageexec@freemail.hu>
Cc: <stable@vger.kernel.org> # v4.13
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6bf88a34 17-Oct-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Remove superfluous '-' added by printk conversion

While converting the error messages to the standard macros in the
commit 4e76a8833fac ("ALSA: hda - Replace with standard printk"), a
superfluous '-' slipped in the code mistakenly. Its influence is
almost negligible, merely shows a dB value as negative integer instead
of positive integer (or vice versa) in the rare error message.
So let's kill this embarrassing byte to show more correct value.

Fixes: 4e76a8833fac ("ALSA: hda - Replace with standard printk")
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1f7f51a6 03-Sep-2017 Wang YanQing <udknight@gmail.com>

ALSA: hda: Fix regression of hdmi eld control created based on invalid pcm

Commit fb087eaaef72 ("ALSA: hda - hdmi eld control created based on pcm")
forget to filter out invalid pcm numbers, if there is only one invalid pcm
number, then this issue causes we create eld control for invalid pcm silently,
but when there are more than one invalid pcm numbers, then this issue bring
probe error looks like below dmesg:
"
kernel: [ 1.647283] snd_hda_intel 0000:00:03.0: bound 0000:00:02.0 (ops 0xc2967540)
kernel: [ 1.651192] snd_hda_intel 0000:00:03.0: Too many HDMI devices
kernel: [ 1.651195] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y
kernel: [ 1.651197] snd_hda_intel 0000:00:03.0: Too many HDMI devices
kernel: [ 1.651199] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y
kernel: [ 1.651201] snd_hda_intel 0000:00:03.0: Too many HDMI devices
kernel: [ 1.651203] snd_hda_intel 0000:00:03.0: Consider building the kernel with CONFIG_SND_DYNAMIC_MINORS=y
kernel: [ 1.651676] snd_hda_intel 0000:00:03.0: control 3:0:0:ELD:0 is already present
kernel: [ 1.651787] snd_hda_codec_hdmi: probe of hdaudioC0D0 failed with error -16
"

This patch add invalid pcm number filter before calling hdmi_create_eld_ctl.

Fixes: fb087eaaef72 ("ALSA: hda - hdmi eld control created based on pcm")
Signed-off-by: Wang YanQing <udknight@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 88c125b6 09-May-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove superfluous header inclusions

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


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

ALSA: hda - Fix a typo in comment

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


# 99b5c5bb 09-May-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove the use of set_fs()

set_fs() is used in HD-audio vmaster code to retrieve the TLV data of
each slave kctl. Since the slave is supposed to be a standard amp
kctl, we can call directly the supposed tlv callback instead of the
indirect call, so that we can remove the set_fs() hack.

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


# 3db9e970 09-May-2017 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove the generic bind ctl helpers

Now all the users of this workaround code is gone, and we can finally
remove the legacy codes from the core HD-audio module.

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


# f3b827e0 19-Feb-2017 Bhumika Goyal <bhumirks@gmail.com>

ALSA: pci: constify snd_kcontrol_new structures

Declare snd_kcontrol_new structures as const as they are only passed as
an argument to the function snd_ctl_new1. This argument is of type
const, so snd_kcontrol_new structures having the same property can be
made const too.
Done using Coccinelle:

@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct snd_kcontrol_new i@p = {...};

@ok1@
identifier r1.i;
position p;
expression e1;
@@
snd_ctl_new1(&i@p,e1)

@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct snd_kcontrol_new i;

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9152085d 12-Jan-2017 Libin Yang <libin.yang@linux.intel.com>

ALSA: hda - add DP MST audio support

This patch adds the DP MST audio support on i915 platform and
it will enable dyn_pcm_assign feature.

DP MST supports several device entry on the same port and each
device entry can map to one pcm stream. For example, on i915,
there are 3 pins, and each pin has 3 device entries. This means
there should be 3x3 pcms. However, there is only 3 pipe lines in
i915. This means 3 pcms are actived at most at the same moment.
We will create 5 pcms (pin number + dev entry num - 1) in this case.
For the details, please refer commit a76056f2e57e
("ALSA: hda - hdmi dynamically bind PCM to pin when monitor hotplug")

Each device entry is a virtual pin. It is described by pin_nid and dev_id
in struct hdmi_spec_per_pin.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1484208294-8637-3-git-send-email-libin.yang@intel.com


# 13800f39 12-Jan-2017 Libin Yang <libin.yang@linux.intel.com>

ALSA: hda - add DP mst verb support

Add snd_hda_get_dev_select() and snd_hda_set_dev_select() functions
for DP MST audio support.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1484208294-8637-2-git-send-email-libin.yang@intel.com


# 960a581e 15-Jun-2016 Libin Yang <libin.yang@linux.intel.com>

ALSA: hda: fix some klockwork scan warnings

This patch fixes some warnings from klockwork.

These warnings are not the real issues. The patch
adds the sanity check.

Signed-off-by: Libin Yang <libin.yang@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d289619a 20-Oct-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix deadlock at error in building PCM

The HDA codec driver issues snd_hda_codec_reset() at the error path of
PCM build. This was needed in the earlier code base, but the recent
rewrite to use the standard bus binding made this a deadlock:
modprobe D 0000000000000005 0 720 716 0x00000080
Call Trace:
[<ffffffff816a5dbe>] schedule+0x3e/0x90
[<ffffffff816a61a5>] schedule_preempt_disabled+0x15/0x20
[<ffffffff816a7ae5>] __mutex_lock_slowpath+0xb5/0x120
[<ffffffff816a7b6b>] mutex_lock+0x1b/0x30
[<ffffffff8148656b>] device_release_driver+0x1b/0x30
[<ffffffff81485c15>] bus_remove_device+0x105/0x180
[<ffffffff814822b9>] device_del+0x139/0x260
[<ffffffffa05e0ec5>] snd_hdac_device_unregister+0x25/0x30 [snd_hda_core]
[<ffffffffa074fa6a>] snd_hda_codec_reset+0x2a/0x70 [snd_hda_codec]
[<ffffffffa075007b>] snd_hda_codec_build_pcms+0x18b/0x1b0 [snd_hda_codec]
[<ffffffffa074a44e>] hda_codec_driver_probe+0xbe/0x140 [snd_hda_codec]
[<ffffffff81486ac4>] driver_probe_device+0x1f4/0x460
[<ffffffff81486dc0>] __driver_attach+0x90/0xa0
[<ffffffff81484844>] bus_for_each_dev+0x64/0xa0
[<ffffffff814862de>] driver_attach+0x1e/0x20
[<ffffffff81485e7b>] bus_add_driver+0x1eb/0x280
[<ffffffff81487680>] driver_register+0x60/0xe0
[<ffffffffa074a0da>] __hda_codec_driver_register+0x5a/0x60 [snd_hda_codec]
[<ffffffffa070a01e>] realtek_driver_init+0x1e/0x1000 [snd_hda_codec_realtek]
[<ffffffff810002f3>] do_one_initcall+0xb3/0x200
[<ffffffff816a1fc5>] do_init_module+0x60/0x1f8
[<ffffffff810ee5c3>] load_module+0x1653/0x1bd0
[<ffffffff810eed48>] SYSC_finit_module+0x98/0xc0
[<ffffffff810eed8e>] SyS_finit_module+0xe/0x10
[<ffffffff816aa032>] entry_SYSCALL_64_fastpath+0x16/0x75

The simple fix is just to remove this call, since we don't need to
think about unbinding at there any longer.

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


# 2f0eaad9 17-Oct-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix bogus codec address check for mixer name assignment

The recent commit [7fbe824a0f0e: ALSA: hda - Update mixer name for the
lower codec address] tried to improve the mixer chip name assignment
in the order of codec address. However, this fix was utterly bogus;
it checks the field set in each codec, thus this value is reset at
each codec creation, of course. For really handling this priority,
the assignment has to be remembered in the common place, namely in
hda_bus, instead of hda_codec.

Fixes: 7fbe824a0f0e ('ALSA: hda - Update mixer name for the lower codec address')
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7fbe824a 15-Oct-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Update mixer name for the lower codec address

In most cases, we prefer the onboard codec as the primary device, thus
it's better to set it as the mixer name. Currently, however, the
mixer name is updated per the device instantiation order, and user
gets often HDMI/DP or other seen as a mixer chip name. Also, if a
codec name is renamed by the driver, the old chip name might be left
still as the mixer name.

This patch addresses these issues by remembering the chip address that
was referred as the mixer name. When a codec with the same or lower
address gives its name, renew the mixer name accordingly, as it's
either the update of the codec name or we get likely the more
appropriate chip as the reference.

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


# 70b4891c 08-Oct-2015 Vinod Koul <vkoul@kernel.org>

ALSA: hda: make use of core codec fns

Now that we have introduced the core fns we should make hda use these
helpers

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b25cf30a 26-Aug-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove superfluous pcm NULL check

The variable pcm can be never NULL since it was rewritten with
list_for_each_entry().

Suggested-by: Markus Osterhoff <linux-kernel@k-raum.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9dcc144b 25-Aug-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Refresh sysfs at snd_hda_codec_update_widgets()

In the commit [fa4f18b4f402: ALSA: hda - Refresh widgets sysfs at
probing Haswell+ HDMI codecs], snd_hdac_refresh_widget_sysfs() is
explicitly called in the codec driver. But this results in refreshing
twice, as snd_hdac_refresh_widget_sysfs() itself calls
snd_hdac_refresh_widgets() function.

Instead, we can replace the call in snd_hda_codec_update_widgets()
with snd_hdac_refresh_widget_sysfs(). This also fixes the missing
sysfs update for ca0132, too.

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


# c7e69ae6 24-Aug-2015 Markus Osterhoff <linux-kernel@k-raum.org>

ALSA: hda: fix possible NULL dereference

After a for-loop was replaced by list_for_each_entry, see
Commit bbbc7e8502c9 ("ALSA: hda - Allocate hda_pcm objects dynamically"),
Commit 751e2216899c ("ALSA: hda: fix possible null dereference"),
a possible NULL pointer dereference has been introduced; this patch adds
the NULL check on pcm->pcm, while leaving a potentially superfluous
check on pcm itself untouched.

Signed-off-by: Markus Osterhoff <linux-kernel@k-raum.org>
Cc: <stable@vger.kernel.org> #v4.1+
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d2c6b63d 17-Aug-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make some helper functions local

A few helper functions to convert the pin information to strings have
been exported with assumption that they were used by other drivers.
But they are referred only in the proc interface in the end.

Let's make them local so that we can get rid of a few exports.

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


# 6986a0e2 16-Jul-2015 Heloise NH <kernelpatch_update@163.com>

ALSA: hda: fix kstrdup return value

In kstrdup we should return -ENOMEM when it reports an
memory allocation failure, while the -ENODEV is referred
to a failure in finding the cpu node in the device tree.

Signed-off-by: Heloise NH <kernelpatch_update@163.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a457782a 11-Jun-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix link power unbalance at device removal

snd_hdac_link_power() has to be called after unregistering the codec
device. Otherwise the device might be already runtime-suspended, thus
the refcount goes under zero, triggering a warning like:

WARNING: CPU: 7 PID: 2014 at sound/hda/hdac_i915.c:63 snd_hdac_display_power+0x106/0x120 [snd_hda_core]()
CPU: 7 PID: 2014 Comm: modprobe Not tainted 4.1.0-rc7-test+ #1
Call Trace:
[<ffffffff81697fe3>] dump_stack+0x4c/0x6e
[<ffffffff810696da>] warn_slowpath_common+0x8a/0xc0
[<ffffffff810697ca>] warn_slowpath_null+0x1a/0x20
[<ffffffffa02dd526>] snd_hdac_display_power+0x106/0x120 [snd_hda_core]
[<ffffffffa030b422>] azx_intel_link_power+0x12/0x20 [snd_hda_intel]
[<ffffffffa037139f>] azx_link_power+0x1f/0x30 [snd_hda_codec]
[<ffffffffa02d89fe>] snd_hdac_link_power+0x2e/0x40 [snd_hda_core]
[<ffffffffa0368524>] snd_hda_codec_dev_free+0x34/0x50 [snd_hda_codec]
[<ffffffffa0252061>] __snd_device_free+0x51/0xa0 [snd]
.....

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


# a686ec4c 11-Jun-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Re-add the lost fake mute support

Yet another regression by the transition to regmap cache; for better
usability, we had the fake mute control using the zero amp value for
Conexant codecs, and this was forgotten in the new hda core code.

Since the bits 4-7 are unused for the amp registers (as we follow the
syntax of AMP_GET verb), the bit 4 is now used to indicate the fake
mute. For setting this flag, snd_hda_codec_amp_update() becomes a
function from a simple macro. The bonus is that it gained a proper
function description.

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


# 2377c3c3 09-Jun-2015 Lu, Han <han.lu@intel.com>

ALSA: hda: Intel: enable automatic runtime pm for HDMI codecs by default

Enable runtime PM of the HDMI audio codec on the latest Intel platforms.
So the HD-A controller or HDMI codec can suspend when idle timeout by
default and release the GFX power well.
The patch influences HSW/BDW/BYT/BSW/SKL. Eariler platforms and third
party analog codecs will not be influenced.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 132bd96b 08-Jun-2015 Dave Airlie <airlied@redhat.com>

ALSA: hda - fix number of devices query on hotplug

The new regmap code seems to cache this, which isn't helpful
for the hotplug dock situation where this gets updated.

Use the uncached query for this.

Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a5e7e07c 29-Apr-2015 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - allow a codec to control the link power

A flag "link_power_control" is added to indicate whether a codec needs to
control the link power. And a new bus ops link_power() is defined for the
codec to request to enable/disable the link power.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 30e5f003 27-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix missing va_end() call in snd_hda_codec_pcm_new()

Reported by coverity CID 1296024.

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


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

ALSA: hda - Fix mute-LED fixed mode

The mute-LED mode control has the fixed on/off states that are
supposed to remain on/off regardless of the master switch. However,
this doesn't work actually because the vmaster hook is called in the
vmaster code itself.

This patch fixes it by calling the hook indirectly after checking the
mute LED mode.

Reported-and-tested-by: Pali Rohár <pali.rohar@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0a50575b 16-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Replace hda_bus_ops with static binding

Originally hda_bus takes its own ops (hda_bus_ops) to allow different
controller drivers giving individual implementations of PCM
attachment, etc. But this never happened and we finally merged both
codec and controller helper codes. Thus there is no merit to keep the
indirect accesses to functions via hda_bus_ops.

This patch replaces these calls with the direct local function calls
for simplification.

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


# 7d4b5e97 16-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix regression for slave SPDIF setups

The commit [a551d91473e5: ALSA: hda - Use regmap for command verb
caches, too] introduced a regression due to a typo in the conversion;
the IEC958 status bits of slave digital devices aren't updated
correctly. This patch corrects it.

Fixes: a551d91473e5 ('ALSA: hda - Use regmap for command verb caches, too')
Reported-and-tested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b7d023e1 16-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move PCM format and rate handling code to core library

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


# a41d1224 14-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Embed bus into controller object

... and replace with the existing hda-core helper codes.
This reduces lots of lines, finally.

Since struct hda_bus is now embedded into struct azx,
snd_hda_bus_new() is moved and expanded from hda_codec.c to
hda_controller.c, accordingly. Also private_free bus ops and
private_data field are removed because we no longer need to point azx
object from bus (we can use container_of())

The spin locks are consolidated into the single one, bus->reg_lock.

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


# a43ff5ba 14-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Pass bus io_ops directly from the top-level driver

One less redirection again. This also requires the change of the call
order in the toplevel divers. Namely, the bus has to be created at
first before other initializations since the memory allocation ops are
called through bus object now.

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


# 7e8be1b3 14-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move send_cmd / get_response to hdac_bus_ops

One less redirection.

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


# 14752412 13-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add the controller helper codes to hda-core module

This patch adds the controller helper codes to hda-core library.
The I/O access ops are added to the bus ops. The CORB/RIRB, the basic
attributes like irq# and iomap address, some locks and the list of
streams are added to the bus object, together with the stream object
and its helpers.

Currently the codes are just copied from the legacy driver, so you can
find duplicated codes in both directories. Only constants are removed
from the original hda_controller.h. More integration work will follow
in the later patches.

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


# cad372f1 25-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Handle error from get_response bus ops directly

... and drop bus->rirb_error flag. This makes the code simpler.

We treat -EAGAIN from get_response ops as a special meaning: it allows
the caller to retry after bus reset.

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


# 664c7155 08-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Work around races of power up/down with runtime PM

Currently, snd_hdac_power_up()/down() helpers checks whether the codec
is being in pm (suspend/resume), and skips the call of runtime get/put
during it. This is needed as there are lots of power up/down
sequences called in the paths that are also used in the PM itself. An
example is found in hda_codec.c::codec_exec_verb(), where this can
power up the codec while it may be called again in its power up
sequence, too.

The above works in most cases, but sometimes we really want to wait
for the real power up. For example, the control element get/put may
want explicit power up so that the value change is assured to reach to
the hardware. Using the current snd_hdac_power_up(), however,
results in a race, e.g. when it's called during the runtime suspend is
being performed. In the worst case, as found in patch_ca0132.c, it
can even lead to the deadlock because the code assumes the power up
while it was skipped due to the check above.

For dealing with such cases, this patch makes snd_hdac_power_up() and
_down() to two variants: with and without in_pm flag check. The
version with pm flag check is named as snd_hdac_power_up_pm() while
the version without pm flag check is still kept as
snd_hdac_power_up(). (Just because the usage of the former is fewer.)

Then finally, the patch replaces each call potentially done in PM with
the new _pm() variant.

In theory, we can implement a unified version -- if we can distinguish
the current context whether it's in the pm path. But such an
implementation is cumbersome, so leave the code like this a bit messy
way for now...

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


# 751e2216 02-Apr-2015 Sudip Mukherjee <sudipm.mukherjee@gmail.com>

ALSA: hda: fix possible null dereference

we are dereferencing pcm first then checking pcm. instead now lets put
them in same if condition so that pcm is checked first.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
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>


# faa75f8a 26-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use regmap for parameter caches, too

The amp hash table was used for recording the cached reads of some
capability values like pin caps or amp caps. Now all these are moved
to regmap as well.

One addition to the regmap helper is codec->caps_overwriting flag.
This is set in snd_hdac_override_parm(), and the regmap helper accepts
any register while this flag is set, so that it can overwrite even the
read-only verb like AC_VERB_PARAMETERS. The flag is cleared
immediately in snd_hdac_override_parm(), as it's a once-off flag.

Along with these changes, the no longer needed amp hash and relevant
fields are removed from hda_codec struct now.

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


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

ALSA: hda - Use regmap for amp accesses

This patch converts the amp access functions to the regmap helpers.
The amp values were formerly cached in the own hash table. Now it's
dropped by the regmap's cache.

The only tricky conversion is snd_hda_codec_amp_init(). This function
shouldn't do anything if the amp was already initialized. For
achieving this behavior, a value is read once at first temporarily in
the cache-only mode. Only if it returns an error, i.e. the item
still doesn't exist in the cache, it proceeds to the update.

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


# 9ba17b4d 03-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Implement uncached version of parameter reads

Sometimes we need the uncached reads, e.g. for refreshing the tree.
This patch provides the helper function for that and uses it for
refreshing widgets, reading subtrees and the whole proc reads.

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


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

ALSA: hda - Add regmap support

This patch adds an infrastructure to support regmap-based verb
accesses. Because o the asymmetric nature of HD-audio verbs,
especially the amp verbs, we need to translate the verbs as a sort of
pseudo registers to be mapped uniquely in regmap.

In this patch, a pseudo register is built from the NID, the
AC_VERB_GET_* and 8bit parameters, i.e. almost in the form to be sent
to HD-audio bus but without codec address field. OTOH, for writing,
the same pseudo register is translated to AC_VERB_SET_* automatically.
The AC_VERB_SET_AMP_* verb is re-encoded from the corresponding
AC_VERB_GET_AMP_* verb and parameter at writing.

Some verbs has a single command for read but multiple for writes. A
write for such a verb is split automatically to multiple verbs.

The patch provides also a few handy helper functions. They are
designed to be accessible even without regmap. When no regmap is set
up (e.g. before the codec device instantiation), the direct hardware
access is used. Also, it tries to avoid the unnecessary power-up.
The power up/down sequence is performed only on demand.

The codec driver needs to call snd_hdac_regmap_exit() and
snd_hdac_regmap_exit() at probe and remove if it wants the regmap
access.

There is one flag added to hdac_device. When the flag lazy_cache is
set, regmap helper ignores a write for a suspended device and returns
as if it was actually written. It reduces the hardware access pretty
much, e.g. when adjusting the mixer volume while in idle. This
assumes that the driver will sync the cache later at resume properly,
so use it carefully.

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


# 71fc4c7e 03-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move generic array helpers to core lib

This will be used by the regmap support.

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


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

ALSA: hda - Fix possible runtime PM refcount unbalance

When the driver is unloaded before the codec is bound, it still keeps
the runtime PM refcount up, and results in the unbalance. This patch
covers these cases by introducing a flag indicating the runtime PM
initialization and handling the codec registration procedure more
properly. It also fixes the missing input beep device as a gratis,
too.

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


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

ALSA: hda - Support indirect execution of verbs

Add an overriding exec_verb op to struct hdac_device so that the call
via snd_hdac_exec_verb() can switch to a different route depending on
the setup. The codec driver sets this field so that it can handle the
errors or applying quirks appropriately. Furthermore, this mechanism
will be used for smooth transition for the regmap support in later
patches.

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


# 3256be65 24-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add widget sysfs tree

This patch changes the sysfs files assigned to the codec device on the
bus which were formerly identical with hwdep sysfs files. Now it
shows only a few core parameter, vendor_id, subsystem_id, revision_id,
afg, mfg, vendor_name and chip_name.

In addition, now a widget tree is added to the bus device sysfs
directory for showing the widget topology and attributes. It's just a
flat tree consisting of subdirectories named as the widget NID
including various attributes like widget capability bits. The AFG
(usually NID 0x01) is always found there, and it contains always
amp_in_caps, amp_out_caps and power_caps files. Each of these
attributes show a single value. The rest are the widget nodes
belonging to that AFG. Note that the child node might not start from
0x02 but from another value like 0x0a.

Each child node may contain caps, pin_caps, amp_in_caps, amp_out_caps,
power_caps and connections files. The caps (representing the widget
capability bits) always contain a value. The rest may contain
value(s) if the attribute exists on the node. Only connections file
show multiple values while other attributes have zero or one single
value.

An example of ls -R output is like below:
% ls -R /sys/bus/hdaudio/devices/hdaudioC0D0/
/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/:
01/ 04/ 07/ 0a/ 0d/ 10/ 13/ 16/ 19/ 1c/ 1f/ 22/
02/ 05/ 08/ 0b/ 0e/ 11/ 14/ 17/ 1a/ 1d/ 20/ 23/
03/ 06/ 09/ 0c/ 0f/ 12/ 15/ 18/ 1b/ 1e/ 21/

/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/01:
amp_in_caps amp_out_caps power_caps

/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/02:
amp_in_caps amp_out_caps caps connections pin_caps pin_cfg
power_caps

/sys/bus/hdaudio/devices/hdaudioC0D0/widgets/03:
.....

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>


# d068ebc2 02-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move some codes up to hdac_bus struct

A few basic codes for communicating over HD-audio bus are moved to
struct hdac_bus now. It has only command and get_response ops in
addition to the unsolicited event handling.

Note that the codec-side tracing support is disabled temporarily
during this transition due to the code shuffling. It will be
re-enabled later once when all pieces are settled down.

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


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

ALSA: hda - Make snd_hda_bus_type public

Define the common hd-audio driver and device types to bind over
snd_hda_bus_type publicly. This allows to implement other type of
device and driver code over hd-audio bus.

Now both struct hda_codec and struct hda_codec_driver inherit these
new struct hdac_device and struct hdac_driver, respectively.

The bus registration is done in subsys_initcall() to assure it
before any other driver registrations.

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>


# b2a0bafa 05-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use shutdown driver ops instead of reboot notifier

The driver shutdown ops is simpler than registering reboot notifier
manually. There should be no functional change by this -- the codec
driver calls its own callback while the bus driver just calls
azx_stop() like before.

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


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

ALSA: hda - Release resources in device release callback

Move the destructor code to device release callback for the codec
object instead. This is a safer place to release the resources than
dev_free callback in general.

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


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

ALSA: hda - Use standard workqueue for unsol and jack events

The events that are handled by HD-audio drivers are no frequent and
urgent ones, so we can use the standard workqueue without any problem
nowadays.

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


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

ALSA: hda - Build PCMs and controls at codec driver probe

This makes the code flow easier -- instead of the controller driver
calling snd_hda_build_pcms() and snd_hda_build_controls() explicitly,
the codec driver itself builds PCMs and controls at probe time. Then
the controller driver only needs to call snd_card_register().

Also, this allows us the full bind/unbind control, too. Even when a
codec driver is bound later, it automatically registers the new PCM
and controls by itself.

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


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

ALSA: hda - Implement unbind more safely

Now we have all pieces ready, and put them into places:
- add the hda_pcm refcount to azx_pcm_open() and azx_pcm_close(),
- call the most of cleanup code in hda_codec_reset() from the codec
driver remove,
- call the same code also from the hda_codec object free.

Then the codec driver can be unbound more safely now.

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


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

ALSA: hda - Don't assume non-NULL PCM ops

The PCM ops might be set NULL, or cleared to NULL when the driver is
unbound. Give a proper NULL check at each place to be more robust.

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>


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

ALSA: hda - Remove superfluous memory allocation error messages

The memory allocators should have already given the kernel warning
messages, thus we don't have to annoy again.

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


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

ALSA: hda - Add card field to hda_codec struct

Allow the codec object to have an individual card pointer. Not only
this simplifies the redirections in many places, also this will allow
us to make each codec assigned to a different card object.

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


# 1a4ba30c 24-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Split snd_hda_build_pcms()

snd_hda_build_pcms() does actually three things: let the codec driver
build up hda_pcm list, set the PCM default values, and call the
attach_pcm bus ops for each hda_pcm instance. The former two are
basically independent from the bus implementation, so it'd make the
code a bit more readable.

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


# 7e40b80d 26-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove channel mode helper functions

They are no longer used, let's kill them.

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


# 709949fb 20-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Power down codec automatically at registration

So far, we let the controller driver power down the all codecs at the
end of probe. But this can be done better in the codec's dev_register
callback. This results in the reduction of duplicated codes in each
control driver.

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


# 55ed9cd1 19-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Replace bus pm_notify with the standard runtime PM framework

Now the final bit of runtime PM cleanup: instead of manual
notification of the power up/down of the codec via hda_bus pm_notify
ops, use the standard runtime PM feature.

The child codec device will kick off the runtime PM of the parent
(PCI) device upon suspend/resume automatically. For managing whether
the link can be really turned off, we use the bit flags
bus->codec_powered instead of the earlier bus->power_keep_link_on.
flag. Each codec driver is responsible to set/clear the bit flag, and
the controller device can be turned off only when all these bits are
cleared.

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


# bb573928 20-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Drop power_save value indirection in hda_bus

We used to pass the power_save option value to hda_bus via a given
pointer. This was needed to refer to the value from the HD-audio core
side. However, after the transition to the runtime PM, this is no
longer needed.

This patch drops the power_save value indirection in hda_bus above,
and let the controller driver reprograms the autosuspend value
explicitly by a new helper, snd_hda_set_power_save(). Without this
call, the HD-audio core doesn't set up the autosuspend and flip the
runtime PM. (User may still be able to set up via sysfs, though.)

Along with this change, the pointer argument of azx_bus_create() is
dropped as well.

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


# cc72da7d 19-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use standard runtime PM for codec power-save control

Like the previous transition of suspend/resume, now move the
power-save code to the standard runtime PM. As usual for runtime PM,
it's a bit tricky, but this simplified codes a lot in the end.

For keeping the usage compatibility, power_save module option still
controls the whole power-saving behavior on all codecs. The value is
translated to pm_runtime_*_autosuspend() and pm_runtime_allow() /
pm_runtime_forbid() calls.

snd_hda_power_up() and snd_hda_power_down() are translated to
pm_runtime_get_sync() and pm_runtime_put_autosuspend(), respectively.
Since we can do call pm_runtime_get_sync() more reliably, the sync
version is used always and snd_hda_power_up_d3wait() is dropped.
Another slight difference is that snd_hda_power_up()/down() don't call
runtime_pm code during the suspend/resume transition phase. Calling
them there isn't safe unlike our own code, resulted in unexpected
behavior (endless wakeups).

The hda_power_count tracepoint was removed, as it doesn't match well
with the new code.

Last but not least, we need to set ignore_children flag in the parent
dev.power field so that the runtime PM of the controller chip won't
get confused. The notification is still done in the bus pm_notify
callback. We'll get rid of this hack in the later patch.

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


# 59ed1ead 18-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move codec suspend/resume to codec driver

This patch moves the suspend/resume mechanisms down to each codec
driver level, as we have a proper codec driver bound on the bus now.
Then we get the asynchronous PM gratis without fiddling much in the
driver level.

As a soft-landing transition, implement the common suspend/resume pm
ops for hda_codec_driver and keep the each codec driver intact. Only
the callers of suspend/resume in the controller side (azx_suspend()
and azx_resume()) are removed.

Another involved place is azx_bus_reset() calling the temporary
suspend and resume as a hackish method of bus reset. The HD-audio
core provide a helper function snd_hda_bus_reset() instead.

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>


# 781c7b96 20-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid unnecessary power-up at mixer amp changes

When the mixer amp is touched by control elements, we don't have to
power up always; if the codec was suspended at the time, we can just
update the amp cache and it's reflected to the hardware upon resume.

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


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

ALSA: hda - Embed struct hda_bus_unsolicited into struct hda_bus

There is no big merit to handle hda_bus_unsolicited object
individually, as it's tightly coupled with the hda_bus object itself.
Embedding it makes the code simpler in the end.

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


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

ALSA: hda - Drop hda_bus_template for snd_hda_bus_new()

Instead of copying from the given template, let the caller fills the
fields after creation. This simplifies the code after all.

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


# 69eba10e 26-Nov-2014 Dan Carpenter <dan.carpenter@oracle.com>

ALSA: hda - using uninitialized data

In olden times the snd_hda_param_read() function always set "*start_id"
but in 2007 we introduced a new return and it causes uninitialized data
bugs in a couple of the callers: print_codec_info() and
hdmi_parse_codec().

Fixes: e8a7f136f5ed ('[ALSA] hda-intel - Improve HD-audio codec probing robustness')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f0acd28c 17-Nov-2014 Markus Elfring <elfring@users.sourceforge.net>

ALSA: hda: Deletion of unnecessary checks before two function calls

The functions kfree() and release_firmware() test whether their argument
is NULL and then return immediately. Thus the test around the call
is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda - More kerneldoc comments

Put more kerneldoc comments to the exported functions.
Still the generic parser code and the HD-audio controller code aren't
covered yet, though.

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


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

ALSA: hda - Correct kerneldoc comments

Complete the missing parameters and fix anything wrong there.
Just comment changes.

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


# 66797f36 27-Oct-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Pass printf argument directly to request_module()

request_module() handles the printf style arguments, so we don't have
to render strings in the caller side. Not only it reduces the
unnecessary temporary string buffer, it's even safer from the security
POV.

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


# 3ff72219 20-Oct-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Use snd_ctl_enum_info()

... and reduce the open codes.

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>


# e9bd0224 12-Aug-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove obsoleted snd_hda_check_board_config() & co

The helper functions snd_hda_check_board_config() and
snd_hda_check_board_codec_sid_config() are no longer used since the
transition to the generic parser and all quirks have been replaced
with fixups. Let's kill these dead codes.

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


# f5662e1c 22-Jul-2014 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Refactor quirk picking and change quirk priority

Previously, calling one quirk function first and another later
would make the latter one take priority, this is now changed
to make the former take priority.

By adding two special values for fixup_id we can also get rid of the
fixup_forced flag.

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


# e8750940 30-Jun-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix invalid function call in snd_hda_add_vmaster()

The recent commit [6194b99d: ALSA: hda - Kill the rest of snd_print*()
usages] changed the callback map_slaves(), but one call was forgotten
to be replaced due to the cast, which leads to kernel Oops due to
invalid function. This patch replaces it with a proper function.

Fixes: 6194b99de9f5 ('ALSA: hda - Kill the rest of snd_print*() usages')
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>


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


# 648a8d27 25-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add sysfs to codec object, too

We have currently sysfs attributes for each hwdep, but basically these
should belong to the codec itself, per se. Let's add them to the
codec object while keeping them for hwdep as is for compatibility.

While we are at it, split the sysfs-related stuff into a separate
source file, hda_sysfs.c, and keep only the stuff necessary for hwdep
in hda_hwdep.c.

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


# 13aeaf68 24-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Create own device struct for each codec

As the HD-audio is treated individually in each codec driver, it's
more convenient to assign an own struct device to each codec object.
Then we'll be able to use dev_err() more easily for each codec, for
example.

For achieving it, this patch just creates an object "hdaudioCxDy".
It belongs to sound class instead of creating a new bus, just for
simplicity, at this stage. No pm ops is implemented in the device
struct level but currently it's merely a container. The PCM and hwdep
devices are now children of this codec device.

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


# 2565c899 19-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Manage each codec instance individually

Now each snd_hda_codec instance is managed via the device chain, the
registration and release are done by its callback instead of calling
from bus.

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


# caa751ba 25-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: Create sysfs attribute files via groups

Instead of calling each time device_create_file(), create the groups
of sysfs attribute files at once in a normal way. Add a new helper
function, snd_get_device(), to return the associated device object,
so that we can handle the sysfs addition locally.

Since the sysfs file addition is done differently now,
snd_add_device_sysfs_file() helper function is removed.

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


# dff86f86 19-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add QEMU codec vendor ID

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


# 1f85a0f0 15-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove superfluous inclusion of linux/pci.h

Some codec drivers still have it since using PCI_VENDOR_ID_*.

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


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

ALSA: hda - Fix undefined symbol due to builtin/module mixup

Even after the fix for leftover kconfig handling (commit f8f1becf),
the current code still doesn't handle properly the builtin/module
mixup case between the core snd-hda-codec and other codec drivers.
For example, when CONFIG_SND_HDA_INTEL=y and
CONFIG_SND_HDA_CODEC_HDMI=m, it'll end up with an unresolved symbol
snd_hda_parse_hdmi_codec. This patch fixes the issue.

Now codec->parser points to the parser object *only* when a module
(either generic or HDMI parser) is loaded and bound. When a builtin
symbol is used, codec->parser still points to NULL. This is the
difference from the previous versions.

Fixes: f8f1becfa4ac ('ALSA: hda - Fix leftover ifdef checks after modularization')
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f8f1becf 06-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix leftover ifdef checks after modularization

Since the commit [595fe1b702c3: ALSA: hda - Make
CONFIG_SND_HDA_CODEC_* tristate], the kconfig variables for the
generic parser and codec drivers can be "m" instead of boolean, but
some codes are left unchanged to check only #ifdef
CONFIG_SND_HDA_CODEC_XXX, which is no longer true for modules.
This patch fixes them by replacing with IS_ENABLED() macros.

Fixes: 595fe1b702c3 ('ALSA: hda - Make CONFIG_SND_HDA_CODEC_* tristate')
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=70161
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>


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


# f4d6a55d 05-Dec-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Clean up async codec PM using standard async infrastructure

This simplifies lots of codes indeed.

Tested-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7f132927 28-Nov-2013 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - allow a codec to define its own depop delay time

This patch adds 'depop_delay' to struct hda_codec, to indicate a depop delay
time in ms when power-down, in function set_power_state() to D3.

Default value is -1, for a default delay time.
Machine fixup can set a suitable value according to the codec chip and HW audio
design.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 12edb893 26-Nov-2013 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - resume codecs in parallel

To reduce driver resume time, this patch resumes the codecs in parallel
if there are multiple codecs on the bus.

- The PM workqueue of bus is also used to parallel resuming multiple codecs.
- The work item 'pm_work' is renamed to 'suspend_work' to parallel suspending
codecs.
- Add a work item 'resume_work' to parallel resuming codecs.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0e24dbb7 26-Nov-2013 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - suspend codecs in parallel

The time to suspend a single codec may be several hundreds of ms. When runtime
power saving is disabled, driver suspend time can be long especially when there
are more than one codec on the bus.

To reduce driver suspend time, this patch creates a work queue for the bus, and
suspends the codecs in parallel if there are multiple codecs on the bus.

[fixed cosmetic issues by tiwai]

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda - Disable runtime PM when EPSS is unavailable

According to Mengdong, we shouldn't enable runtime PM when a codec
doesn't support EPSS, based on the experiences on Windows.
We have already this check in HDMI codec drivers, but now apply it in
general in hda_codec.c.

Credit goes to Mengdong Lin <mengdong.lin@intel.com>

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


# a40e0a88 19-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Refactor pm notification in hda_codec.c

No functional change.

- codec->pm_down_notified flag is renamed to codec->pm_up_notified
flag (and takes the reversed meaning), which is managed solely in
hda_call_pm_notify() now.

- The explicit call of hda_call_pm_notify() is moved into
hda_keep_power_on().

- Removed a redundant call of hda_call_pm_notify() in
snd_hda_power_up(), as it's called in hda_call_codec_resume()
anyway.

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


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

ALSA: hda - Bind with HDMI codec parser automatically

If a codec contains only the digital outputs, it's very likely a
HDMI/DP codec, which isn't supported by the generic parser but via
HDMI codec parser code. Detect such a case and bind with the proper
parser object if available.

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>


# 0fc28fc0 19-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix unbalanced runtime PM notification at resume

When a codec is resumed, it keeps the power on while the resuming
phase via hda_keep_power_on(), then turns down via
snd_hda_power_down(). At that point, snd_hda_power_down() notifies
the power down to the controller, and this may confuse the refcount if
the codec was already powered up before the resume.

In the end result, the controller goes to runtime suspend even before
the codec is kicked off to the power save, and the communication
stalls happens.

The fix is to add the power-up notification together with
hda_keep_power_on(), and clears the flag appropriately.

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


# d183b4fc 13-Nov-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't clear the power state at snd_hda_codec_reset()

snd_hda_codec_reset() is called either in resetting the whole setup at
error paths or hwdep clear/reconfig sysfs triggers. But all of these
don't assume that the power has to be off, rather they want to keep
the power state unchanged (e.g. reconfig_codec() calls the power
up/down by itself). Thus, unconditionally clearing the power state in
snd_hda_codec_reset() leads to the inconsistency, confuses the further
operation. This patch gets rid of the lines doing that bad thing.

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


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

ALSA: hda - Add sanity check of vmaster slave dB steps

Check whether all vmaster slaves have the same dB steps. Otherwise
the behavior would become inconsistent.

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


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

ALSA: hda - Fix possible zero-division

Check the TLV db scale result before actually dividing in vmaster
slave init code. Also mask TLV_DB_SCALE_MUTE bit so that the right
value is obtained even if this bit is set by the codec driver.

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


# ca16ec02 27-Oct-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove locally dead codes

Reported by coverity.

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


# e6bbe666 23-Oct-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix unbalanced runtime PM refcount after S3/S4

When a machine goes to S3/S4 after power-save is enabled, the runtime
PM refcount might be incorrectly decreased because the power-down
triggered soon after resume assumes that the controller was already
powered up, and issues the pm_notify down.

This patch fixes the incorrect pm_notify call simply by checking the
current value properly.

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


# 4758fed9 17-Oct-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Treat zero connection as non-error

The zero-length connection list happens so often on Haswell HDMI, and
it results in warning messages like
ALSA: hda_codec: invalid CONNECT_LIST verb 5[1]:0
at each time the codec resumes from the power-save, which is fairly
annoying.

Since this is no real error, make it shown only in the verbose debug
mode.

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


# cd4035e8 10-Oct-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Enable surround speakers (when line out is also present)

In the case where we have both line out and more than stereo speakers,
the speaker DACs will end up in extra_out_nid.
In fact, AFAIU, speakers are the only ones that can end up in extra_out_nid,
and if we have several of those, they should be surround outputs
rather than copy front.

BugLink: https://bugs.launchpad.net/bugs/1236965
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f1aa0684 26-Aug-2013 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - add flags and routines to get devices selection info for DP1.2 MST

This patch adds flags and routines to get device list & selection info on
a pin.

To support Display Port 1.2 multi-stream transport (MST) over single DP port,
a pin can support multiple devices. Please refer to HD-A spec Document Change
Notificaton HDA040-A.

A display audio codec can set flag "dp_mst" in its patch, indicating its pins
can support MST. But at runtime, a pin may not be multi-streaming capable and
report the device list is empty, depending on Gfx driver configuration.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 18e60627 25-Jul-2013 Wang Xingchao <xingchao.wang@linux.intel.com>

ALSA: hda - jack poll once if jackpoll_interval==0

With jackpoll_interval != 0, it's used to poll jack event periodically
in a delayed work. if it's 0, give the caller chance to probe jack status
but will not restart the delayed work.

In the next patch which enable WAKEEN feature, HDA controller was able to wake
up system when it's in D3, it's useful to detect Jack hotplug event and notify
userspace. By default the jackpoll_interval=0, this patch let jack poll once
without starting the delayed work.

Signed-off-by: Wang Xingchao <xingchao.wang@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 83a35e36 28-Jun-2013 Geert Uytterhoeven <geert@linux-m68k.org>

treewide: relase -> release

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 63e51fd7 06-Jun-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't take unresponsive D3 transition too serious

When a codec is powered off, some systems don't respond properly after
D3 FG transition, while the driver still expects the response and
tries to fall back to different modes (polling and single-cmd). When
the fallback happens, the driver stays in that mode, and falling back
to the single-cmd mode means it'll loose the unsol event handling,
too.

The unresponsiveness at D3 isn't too serious, thus this fallback is
mostly superfluous. We can gracefully ignore the error there so that
the driver keeps the normal operation mode.

This patch adds a new bit flag for codec read/write, set in the power
transition stage, which is notified to the controller driver via a new
bus->no_response_fallback flag.

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


# e7ecc27e 06-Jun-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce bit flags to snd_hda_codec_read/write()

snd_hda_codec_read(), snd_hda_codec_write() & co take the argument
"direct" that indicates whether the given NID is a direct reference or
an indirect reference. However, the indirect reference is practically
unimplemented and never exists. And moreover, we don't need the
indication of indirect reference at this high level, as NID can be
represented in 16bit values at this point.

Meanwhile, there are some cases where it'd be nice to give some
operational options to these functions. So, we can reuse this
argument as a new bit flag! Pretty frugal, eh?

All callers so far pass zero to this argument, thus there is no
behavior change by this replacement.

The real usage of this new bit option will be added in the following
patches.

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


# 36bb00d4 05-Jun-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Drop hard dependency on CONFIG_SND_DYNAMIC_MINORS

Currently HDMI codec driver sets the hard dependency (reverse
selection) on CONFIG_SND_DYNAMIC_MINORS because the recent codecs may
support more than two PCMs. But, this doesn't mean that we need
always this option, since there can be a single PCM stream even with
the modern codecs.

This patch drops the hard dependency again but give more sensible
error message when no enough PCMs are available due to the lack of
this option.

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


# 6c35ae3c 10-May-2013 Takashi Iwai <tiwai@suse.de>

Revert "ALSA: hda - Don't set up active streams twice"

This reverts commit affdb62b815b38261f09f9d4ec210a35c7ffb1f3.

The commit introduced a regression with AD codecs where the stream is
always clean up. Since the patch is just a minor optimization and
reverting the commit fixes the issue, let's just revert it.

Reported-and-tested-by: Michael Burian <michael.burian@sbg.at>
Cc: <stable@vger.kernel.org> [v3.9+]
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2195b063 06-May-2013 Wang YanQing <udknight@gmail.com>

ALSA: HDA: Fix Oops caused by dereference NULL pointer

The interrupt handler azx_interrupt will call azx_update_rirb,
which may call snd_hda_queue_unsol_event, snd_hda_queue_unsol_event
will dereference chip->bus pointer.

The problem is we alloc chip->bus in azx_codec_create
which will be called after we enable IRQ and enable unsolicited
event in azx_probe.

This will cause Oops due dereference NULL pointer. I meet it, good luck:)

[Rearranged the NULL check before the tracepoint and added another
NULL check of bus->workq -- tiwai]

Signed-off-by: Wang YanQing <udknight@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d5657ec9 18-Apr-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Disable the sanity check in snd_hda_add_pincfg()

When pin default configs are overridden via patch option, these are
evaluated before fixups are applied. Since some fixups change the
whole codec trees and/or add pins dynamically, this sanity check might
not pass when pins aren't present at the time the function is called.

We may reorder the execution, but an easier fix is simply to disable
this sanity check.

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


# 594813ff 17-Apr-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't call vmaster hook when bus->shutdown is set

The flag bus->shutdown implies that the control elements might have
been already destroyed. When a codec is resumed at this state and
tries to call vmaster hook (e.g. in snd_hda_gen_init()), it would
refer to a non-existing object, resulting in Oops in the end.

This patch just adds a check of the flag in the caller side for
avoiding such a crash.

Though, the best would be to clear hook->sw_kctl by the destructor of
the corresponding ctl element, but vmaster uses its own private_free,
it can't be done easily. So let it be for a while.

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


# aeb3a972 04-Apr-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - fix typo in proc output

Rename "Digitial In" to "Digital In". This function is only used for
proc output, so should not cause any problems to change.

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


# a686fd14 20-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix typo in checking IEC958 emphasis bit

There is a typo in convert_to_spdif_status() about checking the
emphasis IEC958 status bit. It should check the given value instead
of the resultant value.

Reported-by: Martin Weishart <martin.weishart@telosalliance.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ba615b86 13-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't apply EAPD power filter as default

So far, the driver doesn't power down the widget at going down to D3
when the widget node has an EAPD capability and EAPD is actually set
on all codecs unless codec->power_filter is set explicitly.
This caused a problem on some Conexant codecs, leading to click
noises, and we set it as NULL there. But it is very unlikely that the
problem hits only these codecs.

Looking back at the development history, this workaround for EAPD was
introduced just for some laptops with STAC9200 codec, then we applied
it blindly for all. Now, since it's revealed to have an ill effect,
we should disable this workaround per default and apply only for the
known requiring systems.

The EAPD workaround is implemented now as snd_hda_codec_eapd_power_filter(),
and this has to be set explicitly by the codec driver when needed.
As of now, only patch_stac9200() sets this one.

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


# 5265fd9a 12-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Drop explicit memset() by reallocation with __GFP_ZERO

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


# b5f82b10 12-Mar-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix snd_hda_get_num_raw_conns() to return a correct value

In the connection list expansion in hda_codec.c and hda_proc.c, the
value returned from snd_hda_get_num_raw_conns() is used as the array
size to store the connection list. However, the function returns
simply a raw value of the AC_PAR_CONNLIST_LEN parameter, and the
widget list with ranges isn't considered there. Thus it may return a
smaller size than the actual list, which results in -ENOSPC in
snd_hda_get_raw_conections().

This patch fixes the bug by parsing the connection list correctly also
for snd_hda_get_num_raw_conns().

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


# 4c7a548a 07-Mar-2013 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - check NULL pointer when creating SPDIF PCM switch

If the new control cannot be created, this function will return to avoid
snd_hda_ctl_add dereferencing a NULL control pointer.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 25336e8a 07-Mar-2013 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - check NULL pointer when creating SPDIF controls

If the SPDIF control array cannot be reallocated, the function
will return to avoid dereferencing a NULL pointer.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ea9b43ad 12-Feb-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix broken workaround for HDMI/SPDIF conflicts

The commit [dcda58061: ALSA: hda - Add workaround for conflicting
IEC958 controls] introduced a workaround for cards that have both
SPDIF and HDMI devices for giving device=1 to SPDIF control elements.
It turned out, however, that this workaround doesn't work well -

- The workaround checks only conflicts in a single codec, but SPDIF
and HDMI are provided by multiple codecs in many cases, and

- ALSA mixer abstraction doesn't care about the device number in ctl
elements, thus you'll get errors from amixer such as
% amixer scontrols -c 0
ALSA lib simple_none.c:1551:(simple_add1) helem (MIXER,'IEC958
Playback Switch',0,1,0) appears twice or more
amixer: Mixer hw:0 load error: Invalid argument

This patch fixes the previous broken workaround. Instead of changing
the device number of SPDIF ctl elements, shift the element indices of
such controls up to 16. Also, the conflict check is performed over
all codecs found on the bus.

HDMI devices will be put to dev=0,index=0 as before. Only the
conflicting SPDIF device is moved to a different place. The new place
of SPDIF device is supposed by the updated alsa-lib HDA-Intel.conf,
respectively.

Reported-by: Stephan Raue <stephan@openelec.tv>
Reported-by: Anssi Hannula <anssi.hannula@iki.fi>
Cc: <stable@vger.kernel.org> [v3.8]
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a15d05db 08-Feb-2013 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - Support rereading widgets under the function group

A codec may allow software to hide some unused pin/cvt widgets.

Sometimes BIOS does not enable the hidden widgets properly although they are
needed for the board. Thus the driver need to enable them as a board-specific
fixup and the whole tree will change.

This patch implements a common code for rereading codec widgets. So the fixup
code can call it after enabling the hidden widgets.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4eea3091 07-Feb-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove limit of widget connections

Currently we set the max number of connections to be 32, but there
seems codec that gives longer connection lists like AD1988, and we see
errors in proc output and else. (Though, in the case of AD1988, it's
a list of all codecs connected to a single vendor widget, so this must
be something fishy, but it's still valid from the h/w design POV.)

This patch tries to remove this restriction. For efficiency, we still
use the fixed size array in the parser, but takes a dynamic array when
the size is reported to be greater than that.

Now the fixed array size is found only in patch_hdmi.c, but it should
be fine, as the codec itself can't support so many pins.

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


# 9040d102 24-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_check_power_state() helper function

... for small refactoring.

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


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

ALSA: hda - Synchronize the power state at the end of codec init

Put the power state synchronization at the end of the parsing of
codec. This is necessary when the power filter is changed during the
codec probe. Since the first power-up sequence is performed without
the special filter, all widgets are supposed to be ON at this point.

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


# 9419ab6b 24-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add power state filtering

Add a hook to struct hda_codec for filtering the target power state of
each widget when powering up/down. The current hackish EAPD check is
implemented as the default hook pointer, too.

This allows codec drivers to implement own power filter. In the
upcoming changes, the generic parser will have the better power filter
based on the active paths.

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


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

ALSA: hda - Fix inconsistent pin states after resume

The commit [26a6cb6c: ALSA: hda - Implement a poll loop for jacks as a
module parameter] introduced the polling jack detection code, but it
also moved the call of snd_hda_jack_set_dirty_all() in the resume path
after resume/init ops call. This caused a regression when the jack
state has been changed during power-down (e.g. in the power save
mode). Since the driver doesn't probe the new jack state but keeps
using the cached value due to no dirty flag, the pin state remains
also as if the jack is still plugged.

The fix is simply moving snd_hda_jack_set_dirty_all() to the original
position.

Reported-by: Manolo Díaz <diaz.manolo@gmail.com>
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>


# f038fcac 15-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - fix OOPS in hda_mark_cmd_cache_dirty

Obvious copy-paste error.

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


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

ALSA: hda - Protect user-defined arrays via mutex

The pincfgs, init_verbs and hints set by sysfs or patch might be
changed dynamically on the fly, thus we need to protect it.
Add a simple protection via a mutex.

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


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

ALSA: hda - More strict correction of invalid pinctl bits

Check more strictly about the validity of pinctl values in
snd_hda_set_pin_ctl() and correct the wrong bits automatically.
Also provide the helper function to correct pinctl bits to codec
drivers.

This automatically fixes the invalid pinctl writes that are found in
a few Realtek fixups for NID 0x0f amp like ASUS A6Rp.

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


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

ALSA: hda - Add helper functions to cache the current pinctl target

We already have the list of whole pin widgets and there is an unused
space in the list; let's use it for caching the current pinctl value.

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


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

ALSA: hda - Don't set up active streams twice

We don't have to set up a stream that has been already set up
previously.

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>


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

ALSA: hda - Increase the max depth of widget connections

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

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


# 2ce4886a 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid access of amp cache element outside mutex

The access to a cache array element could be invalid outside the
mutex, so copy locally for the later references.

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


# 8565f052 19-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix wrong dirty check in snd_hda_codec_resume_amp()

The dirty entry has to be checked at the beginning in the loop, not in
the inner loop for channels. This caused a regression that the right
channel isn't properly written.

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


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

ALSA: hda - Check CORB overflow

Add an overflow check of CORB in HD-audio controller and codec drivers
so that flood of sequential writes would work properly.
In the controller side, add a check of CORB read-pointer to make
returning -EAGAIN when it's full. Meanwhile in the codec side, when
-EAGAIN error is received, it retries the write after flushing the
pending verbs (calling get_response() essentially does it).

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


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

ALSA: hda - Clear cached_write flag in snd_hda_codec_resume_*()

These functions are supposed to be called at finishing the cached
sequential writes, so clear the flag properly for lazy developers who
often forget details.

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


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

ALSA: hda - Clear dirty flag upon cache write

When verbs or amps are actually written to the hardware, we can clear
dirty flag so that the later snd_hda_codec_resume_*() calls can skip
these verbs / amps.

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


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

ALSA: hda - Allow one chance for zero NID in connection list

The commit [2e9bf24: ALSA: hda_codec: Check for invalid zero
connections] trims the whole connection list when an invalid value is
reported by the hardware. But some codecs (at least AD1986A) may give
a zero NID in the middle of the connection list, so dropping the whole
list isn't good for such cases.

In this patch, as a workaround, allow a single zero NID in the read
connection list. If it hits zero twice, it's handled as an error, so
that we can avoid "too many connections" errors.

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


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

ALSA: hda - Move fixup code into struct hda_codec

Since the fixup code is used commonly, it's worth to move it to the
common place, struct hda_codec, instead of keeping in hda_gen_spec.

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


# 280e57d5 14-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce snd_hda_codec_amp_init*()

The new function snd_hda_codec_amp_init() (and the stereo variant)
initializes the amp value only once at the first access. If the amp
was already initialized or updated, this won't do anything more.

It's useful for initializing the input amps that are in the part of
the path but never used.

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


# c370dd6e 13-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce cache & flush cmd / amp writes

For optimizing the verb executions, a new mechanism to cache the verbs
and amp update commands is introduced. With the new "write to cache
and flush" way, you can reduce the same verbs that have been written
multiple times.

When codec->cached_write flag is set, the further
snd_hda_codec_write_cache() and snd_hda_codec_amp_stereo() calls will
be performed only on the command or amp cache table, but not sent to
the hardware yet. Once after you call all commands and update amps,
call snd_hda_codec_resume_amp() and snd_hda_codec_resume_cache().
Then all cached writes and amp updates will be written to the
hardware, and the dirty flags are cleared.

In this implementation, the existing cache table is reused, so
actually no big code change is seen here. Each cache entry has a new
dirty flag now (so the cache key is now reduced to 31bit).

As a good side-effect by this change, snd_hda_codec_resume_*() will no
longer execute verbs that have been already issued during the resume
phase by checking the dirty flags.

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


# c86c2d44 03-Jan-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Switch "On" and "Off" for "Mute-LED Mode" kcontrol

The vmaster hook sends 1 for enabled/unmuted and 0 for disabled/muted,
but "Mute-LED Mode" being "On" refers to the LED being on, not the
volume being on.
Therefore "On" and "Off" should be switched.

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


# 6a0f56a7 06-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: Remove the rest of __devinit* in comments

Remove the leftover __devinit* in comments.
They have been commented out because they couldn't fit with __dev*
although they should have matched.

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


# dda415d4 30-Nov-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add a helper function for simple enum kcontrols

The same type of code is being used in multiple places in various
codec drivers, so put it as a core library.

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


# 361dab3e 09-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Call snd_array_init() early and only once

This is a preliminary patch for introducing a protection to access
races of snd_array instances. Call snd_array_init() appropriately
at the initialization time and don't call it twice.

Also the allocations of codec-spec structs are cleaned up by helper
functions in patch_sigmatel.c and patch_analog.c.

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


# d846b174 24-Nov-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix build without CONFIG_PM

I forgot this again... codec->in_pm is in #ifdef CONFIG_PM

Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3fdf1469 22-Nov-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't overwrite the pin default configs

Since we keep the pin default config values anyway internally, we
don't have to set the values in the codec. This patch removes the
code writing the pincfg values.

As a gratis bonus, we can remove also the code restoring the original
pincfg values at PM resume or module free. This will give us more
benefit, as it can reduce the unnecessary power-up of codecs.

This won't change the driver functionality. The only difference would
be that the codec proc file will show the original pincfg values
instead of the actually referred values. The actually referred values
can be determined from sysfs *_pin_configs files.
(Also hda-emu was updated to follow this change.)

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


# 989c3187 19-Nov-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix recursive suspend/resume call

When the bus reset is performed during the suspend/resume (including
the power-saving too), it calls snd_hda_suspend() and
snd_hda_resume() again, and deadlocks eventually.

For avoiding the recursive call, add a new flag indicating that the PM
is being performed, and don't go to the bus reset mode when it's on.

Reported-and-tested-by: Julian Wollrath <jwollrath@web.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ee81abb6 08-Nov-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Apply a proper chmap for built-in 2.1 speakers

When 2.1 speakers are detected, use the corresponding channel map
instead of the standard map with front+rear surrounds.

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


# 3bef1c37 03-Nov-2012 Laurence Darby <ldarby@tuffmail.com>

ALSA: hda - stop setup_dig_out_stream() causing clicks

Starting audio or seeking in various music players causes
setup_dig_out_stream() to be called, which resets the SPDIF stream,
which caused one DAC (but not another) to make a clicking noise every
time.

This patch ensures the reset only happens when it needs to, which is
when the format changes, and makes the code a little more readable.

Signed-off-by: Laurence Darby <ldarby@tuffmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# dcda5806 12-Oct-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add workaround for conflicting IEC958 controls

When both an SPDIF and an HDMI device are created on the same card
instance, multiple IEC958 controls are created with indices=0, 1, ...
But the alsa-lib configuration can't know which index corresponds
actually to which PCM device, and both the SPDIF and the HDMI
configurations point to the first IEC958 control wrongly.

This patch introduces a (hackish and ugly) workaround: the IEC958
controls for the SPDIF device are re-labeled with device=1 when HDMI
coexists. The device=1 corresponds to the actual PCM device for
SPDIF, so it's anyway a better representation. In future, HDMI
controls should be moved with the corresponding PCM device number,
too.

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


# 26a6cb6c 09-Oct-2012 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Implement a poll loop for jacks as a module parameter

Now that we have a generic unsol mechanism, we can implement a generic
poll loop, which can be used for debugging, or if a codec's unsol
mechanism is broken.

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


# 12f17717 10-Oct-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Warn an allocation for an uninitialized array

Better to add a sanity check as I tend to forget something (especially
during crazy midsummer nights).

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


# d17344b3 28-Sep-2012 Dylan Reid <dgreid@chromium.org>

ALSA: hda - Fix hang caused by race during suspend.

There was a race condition when the system suspends while hda_power_work
is running in the work queue. If system suspend (snd_hda_suspend)
happens after the work queue releases power_lock but before it calls
hda_call_codec_suspend, codec_suspend runs with power_on=0, causing the
codec to power up for register reads, and hanging when it calls
cancel_delayed_work_sync from the running work queue.

The call chain from the work queue will look like this:
hda_power_work <<- power_on = 1, unlock, then power_on cleard by suspend
hda_call_codec_suspend
hda_set_power_state
snd_hda_codec_read
codec_exec_verb
snd_hda_power_up
snd_hda_power_save
__snd_hda_power_up
cancel_delayed_work_sync <<-- cancelling executing wq

Fix this by waiting for the work queue to finish before starting suspend
if suspend is not happening on the work queue.

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


# 07dc59f0 10-Sep-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix Oops at codec reset/reconfig

snd_hda_codec_reset() calls restore_pincfgs() where the codec is
powered up again, which eventually tries to resume and initialize via
the callbacks of the codec. However, it's the place just after codec
free callback, thus no codec callbacks should be called after that.
On a codec like CS4206, it results in Oops due to the access in init
callback.

This patch fixes the issue by clearing the codec callbacks properly
after freeing codec.

Reported-by: Daniel J Blueman <daniel@quora.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9c9a5175 31-Jul-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add standard channel maps

Although HD-audio allows pair-wise channel configurations, only the
fixed channel positions are used in this version. In future, this can
be changed and allow user to modify the channel positions.

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


# d819387e 31-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Clean up redundant FG checks

Just refactoring, no functional changes.

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


# 08fa20ae 31-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Yet another fix for D3 stop-clock refcounting

The call of pm_notify callback in snd_hda_codec_free() should be with
the check of the current state whether pm_notify(false) is called or
not, instead of codec->power_on check.

For improving the code readability and fixing this inconsistency,
codec->d3_stop_clk_ok is renamed to codec->pm_down_notified, and this
flag is set only when runtime PM down is called. The new name reflects
to a more direct purpose of the flag.

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>


# 432c641e 28-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix D3 clock stop check for codecs with own set_power_state op

When a codec provides its own set_power_state op, the D3-clock-stop
isn't checked correctly. And the recent changes for repeating the
state-setting operation isn't applied to such a codec, too.

This patch fixes these issues by moving the call of codec's own op to
the place where the generic power-set operation is done, and move the
power-state synchronization code out of
snd_hda_set_power_state_to_all() so that it can be called always at
the end of power-up/down sequence, and updates the D3 clock-stop flag
properly.

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


# 68467f51 28-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix runtime PM leftover refcounts

When the HD-audio is removed, it leaves the refcounts when codecs are
powered up (usually yes) in the destructor. For fixing the unbalance,
and cleaning up the code mess, this patch changes the following:
- change pm_notify callback to take the explicit power on/off state,
- check of D3 stop-clock and keep_link_on flags is moved to the caller
side,
- call pm_notify callback in snd_hda_codec_new() and snd_hda_codec_free()
so that the refcounts are proprely updated.

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


# 983f6b93 28-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid unnecessary parameter read for EPSS

EPSS parameter should be static, so we can read it once and remember.
This also allows more easily to override the wrong EPSS capability
reported from a codec by changing the flag in the codec
initialization step.

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


# 5d908ab9 24-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make clear built-in driver optimization

Use unsigned int to make clear that the codes required only for
modules will be reduced by the compiler optimization.

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


# 5d6147f1 23-Aug-2012 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - bug fix on references without checking CONFIG_SND_HDA_POWER_SAVE

The patch to support runtime PM introduced a bug:
Module parameter 'power_save_controller', and the codec flag 'd3_stop_clk'
'd3_stop_clk_ok' are defined only when HDA power save is enabled in config. But
there are references to them without checking macro CONFIG_SND_HDA_POWER_SAVE.

This patch is to fix the bug.

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b8dfc462 23-Aug-2012 Mengdong Lin <mengdong.lin@intel.com>

ALSA: hda - add runtime PM support

Runtime PM can bring more power saving:
- When the controller is suspended, its parent device will also have a chance
to suspend.
- PCI subsystem can choose the lowest power state the controller can signal
wake up from. This state can be D3cold on platforms with ACPI PM support.
And runtime PM can provide a gerneral sysfs interface for a system policy
manager.

Runtime PM support is based on current HDA power saving implementation. The user
can enable runtime PM on platfroms that provide acceptable latency on transition
from D3 to D0.

Details:
- When both power saving and runtime PM are enabled:
-- If a codec supports 'stop-clock' in D3, it will request suspending the
controller after it enters D3 and request resuming the controller before
back to D0. Thus the controller will be suspended only when all codecs are
suspended and support stop-clock in D3.
-- User IO operations and HW wakeup signal can resume the controller back to
D0.
- If runtime PM is disabled, power saving just works as before.
- If power saving is disabled, the controller won't be suspended because the
power usage counter can never be 0.

More about 'stop-clock' feature:
If a codec can support targeted pass-through operations in D3 state when there
is no BCLK present on the link, it will set CLKSTOP flag in the supported power
states and report PS-ClkStopOk when entering D3 state. Please refer to HDA spec
section 7.3.3.10 Power state and 7.3.4.12 Supported Power State.

[Fixed CONFIG_PM_RUNTIME dependency in hda_intel.c by tiwai]

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 8a535414 22-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Call snd_hda_jack_report_sync() generically in hda_codec.c

Instead of calling the jack sync in the init callback of each codec,
call it generically at initialization and resume. By calling it at
the last of resume sequence, a possible race between the jack sync and
the unsol event enablement in the current code will be closed, too.

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


# 535b6c51 20-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix leftover codec->power_transition

When the codec turn-on operation is canceled by the immediate
power-on, the driver left the power_transition flag as is.
This caused the persistent avoidance of power-save behavior.

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


# c376e2c7 14-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Implement snd_hda_power_sync() helper function

Added a new helper function snd_hda_power_sync() to trigger the
power-saving manually. It's an inline function call to
snd_hda_power_save() helper function.

Together with this addition, snd_hda_power_up*() and
snd_hda_power_down() functions are inlined to a call of the same
snd_hda_power_save() helper function.

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


# b244d335 20-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add tracepoints at snd_hda_power_up/down entrances.

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


# e037cb4a 10-Aug-2012 Mengdong Lin <mengdong.lin@intel.com>

ALSA : hda - bug fix on checking the supported power states of a codec

The return value of snd_hda_param_read() is -1 for an error, otherwise
it's the supported power states of a codec.

The supported power states is a 32-bit value. Bit 31 will be set to 1
if the codec supports EPSS, thus making "sup" negative. And the bit
28:5 is reserved as "0".
So a negative value other than -1 shall be further checked.

Please refer to High-Definition spec 7.3.4.12 "Supported Power
States", thanks!

Signed-off-by: Mengdong Lin <mengdong.lin@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5cb543db 09-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Deferred probing with request_firmware_nowait()

For processing the firmware handling properly for built-in kernels,
implement an asynchronous firmware loading with
request_firmware_nowait(). This means that the codec probing is
deferred when the patch option is specified.

Tested-by: Thierry Reding <thierry.reding@avionic-design.de>
Reviewed-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ed360813 08-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add codec->pcm_format_first flag

Introduced a new flag to set up the PCM stream format at first before
the stream_id and channel tag. Some codecs (e.g. CA0132) seem
preferring this over stream_id -> format order.

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


# 0401e854 03-Jul-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move beep helper functions to hda_beep.c

Move snd_hda_mixer_amp_switch_put_beep() to hda_beep.c as a clean up
to remove one more ifdef.

Also add the corresponding get callback to return consistently the
digital beep state independently from the mixer amp value.

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


# 68cb2b55 02-Jul-2012 Takashi Iwai <tiwai@suse.de>

ALSA: Convert to new pm_ops for PCI drivers

Straightforward conversion to the new pm_ops from the legacy
suspend/resume ops.

Since we change vx222, vx_core and vxpocket have to be converted,
too.

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


# 09a6071b 26-Jun-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Initialize caches at codec reconfiguration

Better to clean up the caches for avoiding inconsistent codec state
after the reconfiguration.

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


# 59cad16b 26-Jun-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix memory leaks at module unload

Some caches aren't released properly at module unloading time.

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


# b43d2247 21-Jun-2012 Dylan Reid <dgreid@chromium.org>

ALSA: hda - Don't power up when not powered down.

After cancel_delayed_work_sync returns, the power down work either never
started (power_on == 1) or finished (power_on == 0). In the former case
there is no need to power up again.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b4a91cf0 15-Jun-2012 Dylan Reid <dgreid@chromium.org>

ALSA: hda - Handle open while transitioning to D3.

This addresses an issue encountered when a pcm is opened while
transitioning to low power state (codec->power_on == 1 &&
codec->power_transition == -1). Add snd_pcm_power_up_d3wait to
hda_codec. This function is used to power up from azx_open as opposed
to snd_hda_power_up used from codec_exec_verb. When powering up from
azx_open, wait for pending power downs to complete, avoiding the power
up continuing in parallel with the power down on the work queue.

The specific issue seen was with the CS4210 codec, it powers off the ADC
and DAC nid in its suspend handler. If it is re-opened before the
~100ms power down process completes, the ADC and DAC nid are initialized
while powered down and audio is lost until another suspend/resume cycle.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 09617ce4 07-Jun-2012 Wang Xingchao <xingchao.wang@intel.com>

ALSA: hda - power setting error check

codec may reject power state transition requests(reporting PS-ERROR set),
in that case we re-issue a power state setting and check error bit again.

Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0f4ccbb0 07-Jun-2012 Wang Xingchao <xingchao.wang@intel.com>

ALSA: hda - reduce msleep time if EPSS power states supported

if EPSS supported, transition from D3 state to D0 state in less
than 10ms

Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0c7f46ad 06-Jun-2012 Wang Xingchao <xingchao.wang@intel.com>

ALSA: hda - check supported power states

Add function to check whether power states supported by specific
codec node.

Signed-off-by: Wang Xingchao <xingchao.wang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 09cf03b8 19-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix possible races of accesses to connection list array

Like the previous fixes for cache hash accesses, a protection over
accesses to the widget connection list array must be provided.
Together with this action, remove snd_hda_get_conn_list() which can be
always race, and replace it with either snd_hda_get_num_conns() or
snd_hda_get_connections() calls.

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


# d3d020bd 25-Apr-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Export snd_hda_lock_devices()

It's a preliminary work for the vga-switcher support.
Export the function to do pseudo-lock for the sound card to be used
in other places.

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


# 8c7dd890 12-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Disable FLOAT format support

It turned out that the FLOAT format on CS4206 results in simple
noises, which implies that this is no right format as is.
Since CS4206 is the only codec supporting the float, let's disable it
until we find the correct format.

Reported-and-tested-by: Adrian Knoth <adi@drcomp.erfurt.thur.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c3b6bcc2 10-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix concurrent hash accesses

The amp and caps hashes aren't protected properly for concurrent
accesses. Protect them via a new mutex now.

But it can't be so simple as originally thought: since the update of a
hash table entry itself might trigger the power-up sequence which
again accesses the hash table, we can't cover the whole function
simply via mutex. Thus the update part has to be split from the mutex
and revalidated.

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


# e3245cdd 10-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Protect SPDIF-related stuff via spdif_mutex

Add the missing mutex protection or move into the protected part for
SPDIF access codes for codecs.

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


# a2d96e77 08-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - More robustify the power-up/down sequence

Check the power_transition up/down state instead of boolean bit, so
that the power-up sequence can cancel the pending power-down work
properly. Also, by moving cancel_delayed_work_sync() before the
actual power-up sequence, make sure that the delayed power-down is
completed.

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


# 607d4f7f 09-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove pre_resume and post_suspend ops

Since the recent commit, the resume procedure is always performed at
the resume time. This makes the pre_resume hack for VREF mute LED on
some HP laptops superfluous. As this is the only user of pre_resume
(and there is no user of post_suspend) ops, let's kill them again.

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


# 128bc4ba 07-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move BIOS pin-parser code to hda_auto_parser.c

Just code shuffles.

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


# 5536c6d6 08-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Protect the power-saving count with spinlock

To avoid some races. Still not perfect, but now a bit safer.

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


# 339876d7 08-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Clear the power-saving states properly at reset

Some power-saving states have been left unchanged in
snd_hda_codec_reset(), and this is a potential danger because the
function may be called in various situations including the continuous
operation after that call.

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


# 7f30830b 08-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Always resume the codec immediately

This is a fix for the problem in commit 785f857d1c, the pop noise
issue on some machines with ALC269. The problem was the uninitialized
state after the resume due to the delayed resume of the codec chips.
In that commit, we tried to fix by forcibly putting the codec to D3 at
suspend. But, this still also leaves the uninitialized state after
resume, and it _might_ be still problematic with some BIOS. Since the
commit turned out to regress another issues, we reverted it in the
end.

Now, in this fix, try to fix by turning on the codec immediately at
the resume path. We need to take care of the power-saving in this
case. When the device is woken up at the power-saved state, it should
go power-saving again after the resume.

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


# c382a9f0 07-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix possible access to uninitialized work struct

The work struct must be initialized before the possible call in the
destructor.

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


# 619a341b 08-May-2012 Takashi Iwai <tiwai@suse.de>

Revert "ALSA: hda - Set codec to D3 forcibly even if not used"

This reverts commit 785f857d1cb0856b612b46a0545b74aa2596e44a.

The commit causes a problem with the wrong D3 state after suspend
because the call of hda_set_power_state() involves with the power-up
sequence, which changes the power_count, and this confuses the resume
sequence that checks the power_count as well.

Originally, this go-to-D3 sequence should be a simple task without the
power-up sequence. But, it'd need some proper sanity checks in the
case of power-saved state, so it's not too easy to write now in the
3.4-rc cycle.

In short, the safest option now is to revert this affecting commit.

Of course, we need to clean up and robustify the power-saving code
better for 3.5 kernel.

Reported-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6942c103 20-Apr-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Skip pin capability sanity check for bogus values

Some old codecs like ALC880 seem to give a bogus pin capability value 0
occasionally. This breaks the new sanity check in snd_hda_set_pin_ctl().
Skip the sanity checks in such a case.

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


# 4740860b 20-Apr-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_get_default_vref() helper function

Add a new helper function to guess the default VREF pin control bits
for mic in. This can be used to set the pin control value safely
matching with the actual pin capabilities.

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


# cdd03ced 19-Apr-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce snd_hda_set_pin_ctl*() helper functions

For setting the pin-control values more safely to match with the
actual pin capability bits, a copule of new helper functions,
snd_hda_set_pin_ctl() and snd_hda_set_pin_ctl_cache(), are
introduced. These are simple replacement of the codec verb write with
AC_VERB_SET_PIN_WIDGET but do more sanity checks and filter out
superfluous pin-control bits if they don't fit with the corresponding
pin capabilities.

Some codecs are screwed up or ignore the command when such a wrong bit
is set. These helpers will avoid such secret errors.

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


# f29735cb 13-Mar-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add expose_enum_ctl flag to snd_hda_add_vmaster_hook()

Since it's not always safe to assume that the vmaster hook is purely the
mute-LED control, add the flag indicating whether to expose the mute-LED
enum control or not. Currently, conexant codec sets this off for non-HP
laptops where EAPD may be used really as EAPD.

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


# d2f344b5 12-Mar-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add "Mute-LED Mode" enum control

Create snd_hda_add_vmaster_hook() and snd_hda_sync_vmaster_hook()
helper functions to handle the mute-LED in vmaster hook more
commonly. In the former function, a new enum control "Mute-LED Mode"
is added. This provides user to choose whether the mute-LED should be
turned on/off explicitly or to follow the master-mute status.

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


# 29e5853d 11-Mar-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Return the created kcontrol in __snd_hda_add_vmaster()

It'll be used for adding hooks in later patches.

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


# 18478e8b 09-Mar-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Initialize vmaster slave volumes

When the driver is changed to use vmaster or a new slave element is
added by the improvement of the parser code, user may face often the
silent output because of the muted slave mixer although Master volume
is properly set. And they complain. And I get upset.

Although such a mixer element should be initialized via "alsactl init",
it'd be more user-friendly if the known output slaves are unmuted and
set to 0dB so that user can control the volume only with Master as
default. Since Master is still set muted as default even with this
change, no risk of the speaker blow up, too.

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


# 785f857d 07-Mar-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Set codec to D3 forcibly even if not used

We've seen a problem with a pop-noise at suspend/resume on a HP
machine with ALC269, and it turned out to be an issue that the
controller going to D3 while the codec is unused.

When the device is once suspended and resumed and kept unused, the
driver doesn't initialize the codecs. Instead, the codec chips are
set up dynamically at the first usage. Now, suppose the device going
to suspend again before the codec is set up. The controller is turned
off to D3 while the codec chips are untouched. This caused a pop
noise because the codec chip might have been turned on implicitly by
the hardware.

As a workaround, the codec chip needs to be set to D3 when going to
suspend no matter whether it was used or not. Also, for making it
happening, the controller has to be always set up in the resume path.

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


# e49a3434 01-Mar-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Kill hyphenated names

Kill hyphens from "Line-Out" name strings, as suggested by Mark Brown.

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


# 3868137e 27-Feb-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add a fake mute feature

Some codecs don't supply the mute amp-capabilities although the lowest
volume gives the mute. It'd be handy if the parser provides the mute
mixers in such a case.

This patch adds an extension amp-cap bit (which is used only in the
driver) to represent the min volume = mute state. Also modified the
amp cache code to support the fake mute feature when this bit is set
but the real mute bit is unset.

In addition, conexant cx5051 parser uses this new feature to implement
the missing mute controls.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=42825

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


# fc9e5c6f 06-Feb-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove a debug print in vmaster code

Wrongly slipped in from the commit 9322ca54.

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


# 9322ca54 03-Feb-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add suffix argument to snd_hda_add_vmaster()

In most cases, the slave strings for vmaster are identical between
volumes and switches except for "xxx Volume" and "xxx Switch" suffix.
Now snd_hda_add_vmaster() takes the optional suffix argument so that
each string can be composed with the given suffix, and we can share the
slave name strings in both volume and switch calls nicely.

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


# 54c2a89f 31-Jan-2012 David Henningsson <david.henningsson@canonical.com>

ALSA: HDA: Fix duplicated output to more than one codec

This typo caused the wrong codec's nid to be checked for wcaps type.
As a result, sometimes speakers would duplicate the output sent to
HDMI output.

Cc: stable@kernel.org
BugLink: https://bugs.launchpad.net/bugs/924320
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 01b65bfb 24-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Supports more audio streams

So far, the driver supports up to 10 streams. This is a restriction in
hda_intel.c and hda_codec.c: in the former, the fixed array size limits
the amount, and in the latter, the fixed device-number assignment table
(in get_empty_pcm_device()) limits the possibility.

This patch reduces the restriction by
- using linked list for managing PCM instances in hda_intel.c, and
- assigning non-fixed device numbers for the extra devices

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


# e2301a4d 22-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check subdevice mask in snd_hda_check_board_codec_sid_config()

In snd_hda_check_board_codec_sid_config(), not only comparing with the
exact value but allow the bit-mask comparison for vendor-only, etc.

Tested-by: Linus Torvalds <torvalds@linux-foundation.org>
Tested-by: Dirk Hohndel <hohndel@infradead.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 358b6e62 21-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't add channel suffix for headphone pin labels

The multiple headphone pins are usually handled as copied from the same
source, not as individual channels like front and surround. Thus it'd
be more correct to avoid the channel suffix for "Headphone" pin labels
in snd_hda_get_pin_label() but give an index number instead.

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


# d6018bb5 21-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix a typo

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


# 201e06ff 16-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Give more unique names by snd_hda_get_pin_label()

The function now gives more unique names for the output pins by adding
some prefix and suffix for the location and the channels. Otherwise, it
can pass the index number.

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


# aad37dbd 02-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Merge input-jack helpers to hda_jack.c

We can use the very same table in hda_jack.c for managing the list for
input-jack elements, too.

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


# 1835a0f9 27-Oct-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Cache the jack-detection value

Introduce a table containing the pins and their jack-detection states
for avoiding the unnecessary verbs to check the pin status at each time.

When the unsol event is enabled via snd_hda_jack_detect_enable(), it
automatically adds the given NID to the table. Then the driver supposes
that the codec driver will set the dirty flag appropariately when an
unsolicited event is invoked for that pin.

The behavior for reading other pins that aren't registered in the table
doesn't change. Only the pins assigned to the table are cached, so far.

In near futre, this table can be extended to use the central place for
the unsolicited events of all pins, etc, and eventually include the
jack-detect kcontrols that replace the current input-jack stuff.

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


# 04f5ade6 27-Oct-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce snd_hda_get_pin_label()

Create a new helper function snd_hda_get_pin_label() for getting a label
string for both input and output pins. hda_get_input_pin_label() is
obsoleted by this function, and the callers are replaced appropriately
now by this patch.

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


# 2f451d2a 09-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Re-enable the check NO_PRESENCE misc bit

We disabled the check of NO_PRESENCE bit of the default pin-config
in commit f4419172 temporarily. One problem was that the first
implementation was wrong -- the bit after the shift must be checked.
However, this would still give many regressions on machines with broken
BIOS. They set this bit wrongly even on active pins.

A workaround is to check whether all pins contain this bit. As far as
I've checked, broken BIOSen set this bit on all pins, no matter whether
active or not. In such a case, the driver should ignore this bit check.

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


# aeb4b88e 09-Nov-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't add elements of other codecs to vmaster slave

When a virtual mater control is created, the driver looks for slave
elements from the assigned card instance. But this may include the
elements of other codecs when multiple codecs are on the same HD-audio
bus. This works at the first time, but it'll give Oops when it's once
freed and re-created via reconfig sysfs.

This patch changes the element-look-up strategy to limit only to the
mixer elements of the same codec.

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


# da155d5b 14-Jul-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

sound: Add module.h to the previously silent sound users

Lots of sound drivers were getting module.h via the implicit presence
of it in <linux/device.h> but we are going to clean that up. So
fix up those users now.

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


# 8fa7ab48 26-Oct-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix surround/CLFE headphone and speaker pins order

When 5.1 or more headphone or speaker pins are provided, the parser still
takes as is without fixing the order of channel mapping, which leads in
the unexpected strange channel order by surround outputs.

This patch fixes the issue by applying the same fix-up not only to
line_out_pins[] but also hp_pins[] and speaker_pins[].

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


# f71ff0d7 06-Oct-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Moved snd_print_pcm_rates() back into hda_proc.c

Since hda_proc.c is now the only user of snd_print_pcm_rates(), better to
put it back locally to hda_proc.c and revert to the old style.

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


# af65cbf2 05-Oct-2011 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hdmi: fix printout of SAD sampling rates

SAD sampling rate information reported in
/proc/asound/cardX/eldX is incorrect due to a mismatch
between HDA and HDMI frequencies. Add new routine to provide
relevant values.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7c2f8e40 05-Oct-2011 David Henningsson <david.henningsson@canonical.com>

ALSA: jack - Add "Line In" input jack constants

Similar to Line Out, these constants form the base for future
patches enabling input jack reporting for Line in jacks.

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


# 218264ae 27-Sep-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid unnecessary verbs to clear PCM formats

Since really_cleanup_stream() is called from both purity_inactive_streams()
and hda_cleanup_all_streams(), the verbs to clear the PCM channel and
format may be called multiple times unnecessarily.

This patch adds checks to skip these unneeded verbs.

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


# 99e14c9d 13-Sep-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Terminate the recursive connection search properly

The recursive search of widget connections in snd_hda_get_conn_index()
must be terminated at the pin and the audio-out widgets. Otherwise
you'll get "too deep connection" warnings unnecessarily.

Reported-by: Francis Moreau <francis.moro@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a06dbfc2 23-Aug-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add multi-headphone NIDs in multiout struct

For supporting both the multiple headphones and the multiple speakers,
add the new field in struct hda_multi_out, and evaluate in the standard
setup functions.

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


# d025febc 23-Aug-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Rename to snd_hda_parse_pin_defcfg()

... and add a new bit-flags argument to specify the behavior of the
function. The older function is kept as is (as a wrapper).

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


# 965f1b2e 19-Aug-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow different assoc numbers for multiple speakers

In snd_hda_parse_pin_def_config(), we checked the associated number
of speaker pins and accepts only one number exclusively. But many BIOS
seem to give different assoc number for surround speakers, thus we'd
better to accept all speaker pins no matter which assoc number, and sort
like done for the headphone pins.

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


# f57c2565 14-Aug-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_override_pin_caps() helper function

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


# ecf726f5 09-Aug-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add tracepoint for unsolicited events

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


# d66fee5d 02-Aug-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add basic tracepoints

Add a few tracepoints to HD-audio driver.

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


# 4d7fbdbc 26-Jul-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow codec-specific set_power_state ops

The procedure for codec D-state change may have exceptional cases
depending on the codec chip, such as a longer delay or suppressing D3.

This patch adds a new codec ops, set_power_state() to override the system
default function. For ease of porting, snd_hda_codec_set_power_to_all()
helper function is extracted from the default set_power_state() function.

As an example, the Conexant codec-specific delay is removed from the
default routine but moved to patch_conexant.c.

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


# e581f3db 26-Jul-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add post_suspend patch ops

Add a new ops, post_suspend(), which is called after suspend() ops is
performed. This is called only in the case of the real PM suspend, and
the codec driver can use this for further changing of D-state or
clearing the LED, etc.

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


# 2a43952a 26-Jul-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make CONFIG_SND_HDA_POWER_SAVE depending on CONFIG_PM

It makes little sense to enable power-saving without PM.
This removes SND_HDA_NEEDS_RESUME define so that we can use CONFIG_PM
in all places.

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


# d02667e6 22-Jul-2011 Vitaliy Kulikov <Vitaliy.Kulikov@idt.com>

ALSA: hda - Fix invalid mute led state on resume of IDT codecs

Codec state is not restored immediately on resume but on the first
access when power-save is enabled. That leads to an invalid mute led
state after resume until either sound is played or some control is
changed. This patch adds a possibility for a vendor specific patch to
restore codec state immediately after resume if required. And it adds
code to restore IDT codecs state immediately on resume on HP systems
with mute led support.

Signed-off-by: Vitaliy Kulikov <Vitaliy.Kulikov@idt.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 00ef9610 14-Jul-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix krealloc() replacement in hda_codec.c

It was obviously wrong, grr....

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


# 3101ba03 12-Jul-2011 Takashi Iwai <tiwai@suse.de>

ALSA: Use krealloc() in possible places

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


# 9e7717c9 11-Jul-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Always read raw connections for proc output

In the codec proc outputs, read the raw connections instead of the
cached connection list, i.e. proc files contain only raw values.

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


# b2f934a0 04-Jul-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_override_conn_list() helper function

Add a function to add/modify the connection-list cache entry.
It'll be useful to fix a buggy hardware result.

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


# 8d087c76 27-Jun-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Create snd_hda_get_conn_index() helper function

Create snd_hda_get_conn_index() helper function for obtaining the
connection index of the widget. Replaced the similar codes used in
several codec-drivers with this common helper.

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


# dce2079b 24-Jun-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_get_conn_list() helper function

Add a new helper function snd_hda_get_conn_list().
Unlike snd_hda_get_connections(), this function doesn't copy the
connection-list but gives the raw pointer for the cached list.

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


# 1af7c5f0 24-Jun-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add a workaround for invalid line-out setups

Some BIOS set up the pin config wrongly as line-out although it's
supposed to be a speaker out. In most cases, though, we can judge
the validity by checking the connection type -- when it's FIXED,
mostly it's an invalid line-out but a speaker.

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


# 9857edfd 13-Jun-2011 Greg Thelen <gthelen@google.com>

ALSA: hda: check make_exec_verb() return value

If given a -1 cmd parameter then make_exec_verb() returns -1 without
setting the res output value.

Prior to this change snd_hda_codec_read() assumed that make_exec_verb()
unconditionally set res regardless of the cmd value.

This change explicitly checks the make_exec_verb() return value before
consuming the potentially unset res value.

Signed-off-by: Greg Thelen <gthelen@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 384a48d7 01-Jun-2011 Stephen Warren <swarren@nvidia.com>

ALSA: hda: HDMI: Support codecs with fewer cvts than pins

The general concept of this change is to create a PCM device for each
pin widget instead of each converter widget. Whenever a PCM is opened,
a converter is dynamically selected to drive that pin based on those
available for muxing into the pin.

The one thing this model doesn't support is a single PCM/converter
sending audio to multiple pin widgets at once.

Note that this means that a struct hda_pcm_stream's nid variable is
set to 0 except between a stream's open and cleanup calls. The dynamic
de-assignment of converters to PCMs occurs within cleanup, not close,
in order for it to co-incide with when controller stream IDs are
cleaned up from converters.

While the PCM for a pin is not open, the pin is disabled (its widget
control's PIN_OUT bit is cleared) so that if the currently routed
converter is used to drive a different PCM/pin, that audio does not
leak out over a disabled pin.

We use the recently added SPDIF virtualization feature in order to
create SPDIF controls for each pin widget instead of each converter
widget, so that state is specific to a PCM.

In order to support this, a number of more mechanical changes are made:

* s/nid/pin_nid/ or s/nid/cvt_nid/ in many places in order to make it
clear exactly what the code is dealing with.

* We now have per_pin and per_cvt arrays in hdmi_spec to store relevant
data. In particular, we store a converter's capabilities in the per_cvt
entry, rather than relying on a combination of codec_pcm_pars and
the struct hda_pcm_stream.

* ELD-related workarounds were removed from hdmi_channel_allocation
into hdmi_instrinsic in order to simplifiy infoframe calculations and
remove HW dependencies.

* Various functions only apply to a single pin, since there is now
only 1 pin per PCM. For example, hdmi_setup_infoframe,
hdmi_setup_stream.

* hdmi_add_pin and hdmi_add_cvt are more oriented at pure codec parsing
and data retrieval, rather than determining which pins/converters
are to be used for creating PCMs.

This is quite a large change; it may be appropriate to simply read the
result of the patch rather than the diffs. Some small parts of the change
might be separable into different patches, but I think the bulk of the
change will probably always be one large patch. Hopefully the change
isn't too opaque!

This has been tested on:

* NVIDIA GeForce 400 series discrete graphics card. This model has the
classical 1:1:1 codec:converter:pcm widget model. Tested stereo PCM
audio to a PC monitor that supports audio.

* NVIDIA GeForce 520 discrete graphics card. This model is the new
1 codec n converters m pins m>n model. Tested stereo PCM audio to a
PC monitor that supports audio.

* NVIDIA GeForce 400 series laptop graphics chip. This model has the
classical 1:1:1 codec:converter:pcm widget model. Tested stereo PCM,
multi-channel PCM, and AC3 pass-through to an AV receiver.

* Intel Ibex Peak laptop. This model is the new 1 codec n converters m
pins m>n model. Tested stereo PCM, multi-channel PCM, and AC3 pass-
through to an AV receiver.

Note that I'm not familiar at all with AC3 pass-through. Hence, I may
not have covered all possible mechanisms that are applicable here. I do
know that my receiver definitely received AC3, not decoded PCM. I tested
with mplayer's "-afm hwac3" and/or "-af lavcac3enc" options, and alsa a
WAV file that I believe has AC3 content rather than PCM.

I also tested:
* Play a stream
* Mute while playing
* Stop stream
* Play some other streams to re-assign the converter to a different
pin, PCM, set of SPDIF controls, ... hence hopefully triggering
cleanup for the original PCM.
* Unmute original stream while not playing
* Play a stream on the original pin/PCM.

This was to test SPDIF control virtualization.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 74b654c9 01-Jun-2011 Stephen Warren <swarren@nvidia.com>

ALSA: hda: Virtualize SPDIF out controls

The SPDIF output controls apply to converter widgets. A future change
will create a PCM device per pin widget, and hence a set of SPDIF output
controls per pin widget, for certain HDMI codecs. To support this, we
need the ability to virtualize the SPDIF output controls. Specifically:

* Controls can be "unassigned" from real hardware when a converter is
not used for the PCM the control was created for.
* Control puts only write to hardware when they are assigned.
* Controls can be "assigned" to real hardware when a converter is picked
to support output for a particular PCM.
* When a converter is assigned, the hardware is updated to the cached
configuration.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7c935976 01-Jun-2011 Stephen Warren <swarren@nvidia.com>

ALSA: hda: Allow multple SPDIF controls per codec

Currently, the data that backs the kcontrols created by
snd_hda_create_spdif_out_ctls is stored directly in struct hda_codec. When
multiple sets of these controls are stored, they will all manipulate the
same data, causing confusion. Instead, store an array of this data, one
copy per converter, to isolate the controls.

This patch would cause a behavioural change in the case where
snd_hda_create_spdif_out_ctls was called multiple times for a single codec.
As best I can tell, this is never the case for any codec.

This will be relevant at least for some HDMI audio codecs, such as the
NVIDIA GeForce 520 and Intel Ibex Peak. A future change will modify the
driver's handling of those codecs to create multiple PCMs per codec. Note
that this issue isn't affected by whether one creates a PCM-per-converter
or PCM-per-pin; there are multiple of both within a single codec in both
of those codecs.

Note that those codecs don't currently create multiple PCMs for the codec
due to the default HW mux state of all pins being to point at the same
converter, hence there is only a single converter routed to any pin, and
hence only a single PCM.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 0b626737 26-May-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use snd_printd() in snd_hda_parse_pin_def_config()

Fixed the wrong usage of snd_printdd() for debug prints of input
entries. It should be snd_printd() like others.

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


# 07acecc1 19-May-2011 David Henningsson <david.henningsson@canonical.com>

ALSA: HDA: Add jack detection for HDMI

Just as for headphones and microphone jacks, this patch adds reporting
of HDMI jack status through the input layer.

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


# dda14410 02-May-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Constify some API function arguments

Also fixed the assignment of multiout.dac_nids to satisfy const.

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


# 031024ee 02-May-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Constify some API function arguments

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


# c2de187e 29-Apr-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Show the line-out type in snd_hda_parse_pin_def_config()

Helpful for debugging.

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


# 1c7276cf 20-Apr-2011 Mike Waychison <mikew@google.com>

ALSA: hda - Fix unused warnings when !SND_HDA_NEEDS_RESUME

When SND_HDA_NEEDS_RESUME is not defined, the compiler identifies that
the following symbols are static but not used:

restore_shutup_pins
hda_cleanup_all_streams

Fix warnings by adding SND_HDA_NEEDS_RESUME guards.

Signed-off-by: Mike Waychison <mikew@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5b17b077 14-Apr-2011 Andrew Morton <akpm@linux-foundation.org>

ALSA: hda - sound/pci/hda/hda_codec.c: fix warning

sound/pci/hda/hda_codec.c: In function 'snd_hda_get_connections':
sound/pci/hda/hda_codec.c:332: warning: unused variable 'j'

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a12d3e1e 07-Apr-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remember connection lists

The connection lists are static and we can reuse the previous results
instead of querying via verb at each time. This will reduce the I/O
in the runtime especially for some codec auto-parsers.

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


# 25985edc 30-Mar-2011 Lucas De Marchi <lucas.demarchi@profusion.mobi>

Fix common misspellings

Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>


# cd372fb3 03-Mar-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make common input-jack helper functions

Since multiple codec drivers already use the input-jack stuff, let's
make common helper functions to reduce the duplicated codes.

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


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

ALSA: hda - consitify string arrays

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


# b2d05760 10-Jan-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix multi-headphone handling for Realtek codecs

When multiple headphone pins are defined without line-out pins, the
driver takes them as primary outputs. But it forgot to set line_out_type
to HP by assuming there is some rest of HP pins. This results in some
mis-handling of these pins for Realtek codec parser. It takes as if
these are pure line-out jacks.

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


# 1afe206a 23-Dec-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Try to find an empty control index when it's occupied

When a mixer control element was already created with the given name,
try to find another index for avoiding conflicts, instead of breaking
with an error. This makes the driver more robust.

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


# 0e7adbe2 25-Oct-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Disable sticky PCM stream assignment for AD codecs

The sticky PCM stream assignment introduced in 2.6.36 kernel seems
causing problems on AD codecs. At some time later, the streaming no
longer works by unknown reason. A simple workaround is to disable
sticky-assignment for these codecs.

Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 62b7e5e0 22-Oct-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add workarounds for CT-IBG controllers

Creative IBG controllers require the playback stream-tags to be started
from 1, instead of capture+1. Otherwise the stream stalls.

Reported-by: Wai Yew CHAY <wychay@ctl.creative.com>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c08d9169 17-Oct-2010 Takashi Iwai <tiwai@suse.de>

ALSA: tlv - Define numbers in sound/tlv.h

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


# de8c85f7 15-Oct-2010 Clemens Ladisch <clemens@ladisch.de>

ALSA: HDA: Sigmatel: work around incorrect master muting

The HDA specification does not allow for a codec to mute itself just
because the volume is reduced, so _of course_ somebody had to go and do
it. This wouldn'\''t hurt too much when the volume is adjusted by hand,
but programs like PA that try to set the volume automatically could
inadvertently mute the output.

To work around this, change the TLV dB information for the Master volume
on all Sigmatel HDA codecs to indicate the the minimal volume setting
actually mutes.

Reported-by: Colin Guthrie <gmane@colin.guthr.ie>
Reported-by: "Alexander E. Patrakov" <patrakov@gmail.com>
Tested-by: Colin Guthrie <cguthrie@mandriva.org>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9e5341b9 21-Sep-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Introduce hda_call_check_power_status() helper

Replace the explicit ifdef check and call of check_power_status ops with
a new helper function, hda_call_check_power_status().

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


# 99ae28be 17-Sep-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make snd_hda_get_input_pin_attr() helper

Make the helper function to give the input-pin attribute for jack
connectivity and location. This simplifies checks of input-pin jacks
a bit in some places.

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


# 41c89ef3 17-Sep-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix mic attribute check for internal mics

Now Windows claims that the BIOS sets pins for internal mics to be
BOTH connection instead of FIXED.

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


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

ALSA: hda - Sort input pins in snd_hda_parse_pin_def_config()

Sort inputs[] array in autocfg so that the codec parsers can filter out
easily per input pin types.

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


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

ALSA: hda - Add comments to new helper functions

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


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

ALSA: hda - Reduce redundant mic location prefix in input source labels

When the mic pins are assigned to the same location, we can omit the
redundant location prefix like "Front" or "Rear".

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>


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

ALSA: hda - Remove AUTO_PIN_FRONT_{MIC|LINE}

We can assign multiple pins to a single role now, let's reduce the
redundant FRONT_MIC and FRONT_LINE. Also, autocfg->input_pins[] is
no longer used, so this is removed as well.

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>


# 03642c9a 08-Sep-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Clear left-over hp_pins in snd_hda_parse_pin_def_config()

In snd_hda_parse_def_config(), some unused values may remain in hp_pins[]
array during the headphone-reassignment workaround. This patch clears
the unused array members.

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


# 122661b6 08-Sep-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix wrong HP pin detection in snd_hda_parse_pin_def_config()

snd_hda_parse_pin_def_config() has some workaround for re-assigning
some pins declared as headphones to line-outs. This didn't work properly
for some cases because it used memmove() stupidly wrongly.

Reference: Novell bnc#637263
https://bugzilla.novell.com/show_bug.cgi?id=637263

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


# d7b1ae9d 30-Aug-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_get_input_pin_label() helper function

Added snd_hda_get_input_pin_label() helper function to return the
string that can be used for control or capture-source ids.

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


# 75e0eb24 29-Aug-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add inputs[] to auto_pin_cfg struct

Added the new fields to contain all input-pins to struct auto_pin_cfg.
Unlike the existing input_pins[], this array contains all input pins
even if the multiple pins are assigned for a single role (i.e. two
front mics). The former input_pins[] still remains for a while, but
will be removed in near future.

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


# 3f50ac6a 20-Aug-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix stream and channel-ids codec-bus wide

The new sticky PCM parameter introduced the delayed clean-ups of
stream- and channel-id tags. In the current implementation, this check
(adding dirty flag) and actual clean-ups are done only for the codec
chip. However, with HD-audio architecture, multiple codecs can be
on a single bus, and the controller assign stream- and channel-ids in
the bus-wide.

In this patch, the stream-id and channel-id are checked over all codecs
connected to the corresponding bus. Together with it, the mutex is
moved to struct hda_bus, as this becomes also bus-wide.

Reported-and-tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f0cea797 13-Aug-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix dynamic ADC change working again

The commit eb541337b7a43822fce7d0c9d967ee149b2d9a96
ALSA: hda - Make converter setups sticky
changes the semantics of snd_hda_codec_cleanup_stream() not to clean up
the stream at that moment but delay the action. This broke the codes
expecting that the clean-up is done immediately, such as dynamic ADC
changes in some codec drivers.

This patch fixes the issue by introducing a lower helper,
__snd_hda_codec_cleanup_stream(), to allow the immediate clean up.
The original snd_hda_codec_cleanup_stream() is kept as is now.

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


# eb541337 06-Aug-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make converter setups sticky

So far, we reset the converter setups like the stream-tag, the
channel-id and format-id in prepare callbacks, and clear them in
cleanup callbacks. This often causes a silence of the digital
receiver for a couple of seconds.

This patch tries to delay the converter setup changes as much as
possible. The converter setups are cached and aren't reset as long
as the same values are used. At suspend/resume, they are cleared
to be recovered properly, too.

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


# 92f10b3f 03-Aug-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Define AC_FMT_* constants

Define constants for the HD-audio stream format bits, and replace the
magic numbers in codes.

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


# 32c168c8 03-Aug-2010 Anssi Hannula <anssi.hannula@iki.fi>

ALSA: hda - Set Stream Type in Stream Format according to AES0

Set bit 15 (Stream Type) of HDA Stream Format to 1 (Non-PCM) when IEC958
channel status bit 1 (AES0 & 0x02) is set to 1 (non-audio).

This is a prequisite for HDMI HBR passthrough.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5aacc218 30-Jul-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make error messages more verbose

Add a prefix and more information for error messages regarding the
connection-list in hda_codec.c.

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


# 7ccc3efa 26-Jul-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix max amp cap calculation for IDT/STAC codecs

The commit afbd9b8448f4b7d15673c6858012f384f18d28b8
ALSA: hda - Limit the amp value to write
introduced a regression for codec setups with amp offsets like IDT/STAC
codecs. The limit value should be a raw value without offset calculation.

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


# cd7643bf 19-Jul-2010 Jaroslav Kysela <perex@perex.cz>

ALSA: hda-intel - fix function_id rework (add missing bitmask)

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


# 79c944ad 19-Jul-2010 Jaroslav Kysela <perex@perex.cz>

ALSA: hda-intel - do not mix audio and modem function IDs

The function IDs are different for audio and modem. Do not mix them.
Also, show the unsolicited bit in the function_id register.

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


# afbd9b84 08-Jul-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Limit the amp value to write

Check the amp max value at put callbacks and set the upper limit
so that the driver won't write any invalid value over the defined
range.

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


# ac0547dc 05-Jul-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Restore cleared pin controls on resume

Many codecs now clear the pin controls at suspend via snd_hda_shutup_pins()
for reducing the click noise at power-off. But this leaves some pins
uninitialized, and they'll be never recovered after resume.

This patch adds the proper recovery of cleared pin controls on resume.
Also it adds a check of bus->shutdown so that pins won't be cleared at
module unloading.

Reference: Kernel bug 16339
http://bugzilla.kernel.org/show_bug.cgi?id=16339

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


# a68d5a54 30-Mar-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - introduce snd_hda_codec_update_cache()

Add a new helper, snd_hda_codec_update_cache(), for reducing the unneeded
verbs. This function checks the cached value and skips if it's identical
with the given one. Otherwise it works like snd_hda_codec_write_cache().

The alc269 code uses this function as an example.

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


# 46712646 29-Mar-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Report errors when invalid values are passed to snd_hda_amp_*()

The values should be in 8 bits.

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


# 10e77dda 26-Mar-2010 Jaroslav Kysela <perex@perex.cz>

ALSA: hda-intel - remove model=hwio , use probe_only=3 instead

The probe_only module parameter skips the codec initialization, too.
Remove the model=hwio code and use second bit in probe_only to
skip the HDA codec reset procedure.

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


# cd508fe5 26-Mar-2010 Jaroslav Kysela <perex@perex.cz>

ALSA: hda-intel - add special 'hwio' model to bypass initialization

Using the 'model=hwio' option, the driver bypasses any codec
initialization and the reset procedure for codecs is also
bypassed. This mode is usefull to enable direct access using
hwdep interface (using hdaverb or hda-analyzer tools) and
retain codec setup from BIOS.

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


# 6ff86a3f 19-Mar-2010 Kailang Yang <kailang@realtek.com>

ALSA: hda - Take internal mic as Front Mic

Add new check for MIC. Do the internal DMIC as the Front MIC.
It could solve the default record source index issue.

[Fix the check properly using the bitmask by tiwai]

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


# 28d1a85e 15-Mar-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add an error message for invalid mapping NID

Add an error message to snd_hda_add_nid() for invalid mapping NID to make
easier to hunt the buggy code.

Also added a missing space to the error message in snd_hda_build_controls()

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


# 28aedaf7 28-Feb-2010 Norberto Lopes <nlopes.ml@gmail.com>

ALSA: sound/pci/hda/hda_codec.c: various coding style fixes

Signed-off-by: Norberto Lopes <nlopes.ml@gmail.com>
Acked-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# dd2b4a7a 23-Feb-2010 Zhang, Rui <rui.zhang@intel.com>

ALSA: hda - remove unnecessary msleep on power state transitions

This will save ~15ms boot time.

The first 10ms sleep was introduced in commit d2595d86e5 for (buggy)
Cxt codecs, so better to limit the sleep to the problem hardware.

For the second 10ms sleep, the HDA spec says:

Power State[1:0]:
00: Node Power state (D0) is fully on.
01: Node Power state (D1) allows for (does not require) the lowest possible power consuming state from which it
can return to the "fully on" state (D0) within 10 ms, excepting analog pass through circuits (e.g., CD analog
playback) which must remain fully on.
10: Node Power state (D2) allows for (does not require) the lowest possible power consuming state from which it
can return to the "fully on" state (D0) within 10 ms. For modems, this is the "wake on ring" power state.
11: Node Power state (D3) allows for (does not require) lowest possible power consuming state under software
control. Note that any low power state set by software must retain sufficient operational capability to properly
respond to subsequent software Power State command.

So 10ms is actually the max wait time. It should be safe to
remove/reduce it and rely on the loop of 1ms-sleeps.

CC: Marc Boucher <marc@linuxant.com>
CC: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c8936222 28-Jan-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Define max number of PCM devices in hda_codec.h

Define the constant rather in the common header file.

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


# b82855a0 27-Dec-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add sanity check for storing the user-defined pin configs

Check whether the given NID is a pin widget before storing the
user-defined pin configs.

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


# 92ee6162 27-Dec-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_shutup_pins() helper function

Add a common helper function for clearing pin controls before suspend.
Use the pincfg array instead of looking through all widget tree.

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


# 729d55ba 25-Dec-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Disable tigger at pin-sensing on AD codecs

Analog Device codecs seem to have problems with the triggering of
pin-sensing although their pincaps give the trigger requirements.
Some reported that constant CPU load on HP laptops with AD codecs.

For avoiding this regression, add a flag to codec struct to notify
explicitly that the codec doesn't suppot the trigger at pin-sensing.

Tested-by: Maciej Rutecki <maciej.rutecki@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f62faedb 23-Dec-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Set mixer name after codec patch

Postpone the mixer name setup after the codec patch since the codec
patch may change the codec name string in itself.

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


# 21949f00 23-Dec-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix NID association for capture mixers

Fix the wrong implementation of NID <-> kctl mapping for capture mixers
introduced by the ocmmit 5b0cb1d850c26893b1468b3a519433a1b7a176be.
So far, the driver returns an error at probe.

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


# 5e26dfd0 10-Dec-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - simplify usage of HDA_SUBDEV_AMP_FLAG

The HDA_SUBDEV_NID_FLAG is duplicate for amplifier control elements. Move
get_amp_nid_() call to the snd_hda_ctl_add() function.

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


# 9e3fd871 08-Dec-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - introduce HDA_SUBDEV_AMP_FLAG (ControlAmp in proc)

The purpose of this changeset is to show information about amplifier
setting in the codec proc file. Something like:

Control: name="Front Playback Volume", index=0, device=0
ControlAmp: chs=3, dir=Out, idx=0, ofs=0
Control: name="Front Playback Switch", index=0, device=0
ControlAmp: chs=3, dir=In, idx=2, ofs=0

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


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


# 864f92be 17-Nov-2009 Wu Fengguang <fengguang.wu@intel.com>

ALSA: hda - introduce snd_hda_jack_detect() and snd_hda_pin_sense()

This helps merge duplicate code.

v2: add snd_hda_jack_detect() and comments recommended by Takashi.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 67d634c0 16-Nov-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix build errors with CONFIG_SND_HDA_INPUT_BEEP=n

Disable beep-related codes when CONFIG_SND_HDA_INPUT_BEEP isn't set.

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


# d5191e50 16-Nov-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Update / add kerneldoc comments to exported functions

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


# 9c96fa59 16-Nov-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Get rid of magic digits for subdev hack

Define a proper const for a magic 31bit flag for subdev / NID setup
with a brief comment.

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


# 4d02d1b6 12-Nov-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - proc - add support for dynamic controls to mixer<->NID mapping

This patch adds support for dynamically created controls to proc codec file
(Control: lines).

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


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


# 123c07ae 21-Oct-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda_intel: Digital PC Beep - change behaviour for input layer

Original implementation was keeping registered input device for SND_BEEP
and SND_TONE events all time. This patch changes this behaviour:
If digital PC Beep is turned off using universal control switch,
the input device is unregistered.

Explanation: The kd_mksound() send SND_BEEP and SND_TONE only to last
registered device acceping those events. It means that the HDA Intel
audio driver blocks also the internal PC Speaker device (pcspkr.c
driver) even if the HDA Beep is muted. The user can easy disable
all beeps using 'setterm -blength 0' or 'xset b off' command.

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


# a2f6309e 11-Nov-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add power on/off counter

Added the power on/off counter and expose via sysfs files.
The sysfs files, power_on_acct and power_off_acct, are created under
each codec hwdep sysfs directory (e.g. /sys/class/sound/hwC0D0).
The files show the msec length of the codec power-on and power-off,
respectively.

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


# 8f217a22 10-Nov-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing export for snd_hda_bus_reboot_notify

... forgot to add for modules.

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


# e3303235 10-Nov-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - proc - show which I/O NID is associated to PCM device

Output something like:

Node 0x02 [Audio Output] wcaps 0x11: Stereo
Device: name="ALC888 Analog", type="Audio", device=0, substream=0
Converter: stream=0, channel=0
...

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


# fb8d1a34 10-Nov-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add reboot notifier to each codec

Add reboot notifier to each codec so that it can do some workarounds
needed for reboot.

So far, patch_sigmatel.c calls its shutup routine for avoiding noises
at reboot on some HP machines.

References: Novell bnc#544779
http://bugzilla.novell.com/show_bug.cgi?id=544779

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


# 92608bad 30-Oct-2009 Wu Fengguang <fengguang.wu@intel.com>

ALSA: hda - allow up to 4 HDMI devices

The new Intel HDMI codec supports 2 independant HDMI/DisplayPort pipes.
We'll be exporting them as 2 pcm devices. So bump up the allowed number
of HDMI devices.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# f5d6def5 30-Oct-2009 Wu Fengguang <fengguang.wu@intel.com>

ALSA: hda - vectorize get_empty_pcm_device()

This unifies the code and data structure,
and makes it easy to add more HDMI devices.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d94ff6b7 01-Sep-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix obsolete CONFIG_SND_DEBUG_DETECT

Fix the old dead CONFIG_SND_DEBUG_DETECT to CONFIG_SND_DEBUG_VERBOSE.

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


# deadff16 01-Aug-2009 Wu Fengguang <fengguang.wu@intel.com>

ALSA: hda: track CIRB/CORB command/response states for each codec

Recently we hit a bug in our dev board, whose HDMI codec#3 may emit
redundant/spurious responses, which were then taken as responses to
command for another onboard Realtek codec#2, and mess up both codecs.

Extend the azx_rb.cmds and azx_rb.res to array and track each codec's
commands/responses separately. This helps keep good codec safe from
broken ones.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda - Add exception for volume-knob in snd_hda_get_connections()

Volume-knob widgets may have connections even if they have no CONN_LIST
cap bit. Allow the query exceptionally in snd_hda_get_connections().

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>


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

ALSA: hda-intel: Cleanups for widget connection list handling

This patch adds a check to snd_hda_get_connections() routine for
presence of AC_WCAP_CONN_LIST. Also, make sure that negative error
codes from noted route are handled on all places as errors.

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


# 05ff7e11 21-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Reduce click noise at power-saving

Add some tricks to reduce the click noise at powering down to D3
in the power saving mode on STAC/IDT codecs.
The key seems to be to reset PINs before the power-down, and some
delay before entering D3. The needed delay is significantly long,
but I don't know why.

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


# 2e9bf247 18-Jul-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: hda_codec: Check for invalid zero connections

To prevent "Too many connections" message and the error path for some HDMI
codecs (which makes onboard audio unusable), check for invalid zero
connections for CONNECT_LIST verb.

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


# 82e1b804 16-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix the previous sanity check in make_codec_cmd()

The newly added sanity-check for a codec verb can be better written
with logical ORs. Also, the parameter can be more than 8bit.

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


# 6430aeeb 17-Jul-2009 Wu Fengguang <fengguang.wu@intel.com>

ALSA: hda - add bounds checking for the codec command fields

A recent bug involves passing auto detected >0x7f NID to codec command,
creating an invalid codec addr field, and finally lead to cmd timeout
and fall back into single command mode. Jaroslav fixed that bug in
alc880_parse_auto_config().

It would be safer to further check the bounds of all cmd fields.

Cc: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 3c6aae44 09-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check codec errors in snd_hda_get_connections()

The codec read errors in snd_hda_get_connections() are ignored so far,
and it causes a problem like the bug in the commit
9d30937accf2c01e8b0bd59787409a7348cbbcb7
ALSA: hda_intel: more strict alc880_parse_auto_config dig_nid checking

Better to check errors in the function and returns a proper error code
rather than passing bogus NID values.

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


# b0bb3aa6 03-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't override maxbps for FLOAT sharing with linear formats

When FLOAT PCM format is available but together with other linear
PCM formats, don't override maxbps value. For FLOAT format, it's always
32, thus it can be better checked in snd_hda_calc_stream_format().
Otherwise the maxbps 32 might be used wrongly even if the linear PCM
doesn't support it.

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


# 022b466f 03-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Avoid invalid formats and rates with shared SPDIF

Check whether formats and rates don't result in zero due to the
restriction of SPDIF sharing. If any of them can be zero, disable
the SPDIF sharing mode instead. Otherwise it will lead to a PCM
configuration error.

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


# e5f14248 01-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add Cirrus Logic CS420x support

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


# b5025c50 01-Jul-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow FLOAT PCM format

So far, the FLOAT PCM format is used only exclusivley set. But
this can be a combination with other formats.

This patch changes the parser to allow the FLOAT format in addition
to other PCM formats.

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


# a1e21c90 17-Jun-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't call snd_hda_codec_configure in snd_hda_codec_new()

The codec setup call via snd_hda_codec_configure() isn't necessarily
called in snd_hda_codec_new(). For the later added feature, it's better
to change the code flow like:
- create all codec instances
- configure each codec

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


# f75dcc87 17-Jun-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix memory leak at codec creation

The codec->modelname field is allocated twice in snd_hda_codec_new().

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


# b20f3b83 01-Jun-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Limit codec-verb retry to limited hardwares

The reset of a BUS controller during operations is somehow risky and
shouldn't be done inevitably for devices that have apparently no such
codec-communication problems.

This patch adds the check of the hardware and limits the bus-reset
capability.

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


# 8dd78330 01-Jun-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add codec bus reset and verb-retry at critical errors

Some machines machine cause a severe CORB/RIRB stall in certain
weird conditions, such as PA access at the start up together with
fglrx driver. This seems unable to be recovered without the controller
reset.

This patch allows the bus controller reset at critical errors so
that the communication gets recovered again.

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


# aa2936f5 26-May-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Support sync after writing a verb

This patch adds a debug mode to make the codec communication
synchronous. Define SND_HDA_SUPPORT_SYNC_WRITE in hda_codec.c,
and the call of snd_hda_codec_write*() will become synchronous,
i.e. wait for the reply from the codec at each time issuing a verb.

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


# 812a2cca 16-May-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Split codec->name to vendor and chip name strings

Split the name string in hda_codec struct to vendor_name and chip_name
strings to be stored directly from the preset name.
Since mostly only the chip name is referred in many patch_*.c, this
results in the reduction of many codes in the end.

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


# a3b48c88 21-Apr-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - minor optimization in hda_set_power_state()

Check the target power-state before checking EAPD exception to reduce
unneeded verb executions.

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


# b613291f 24-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Retry codec-verbs at errors

The current error-recovery scheme for the codec communication errors
doesn't work always well. Especially falling back to the
single-command mode causes the fatal problem on many systems.

In this patch, the problematic verb is re-issued again after the error
(even with polling mode) instead of the single-cmd mode. The
single-cmd mode will be used only when specified via the command
option explicitly, mainly just for testing.

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


# 92c7c8a7 24-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Cache PCM and STREAM parameters queries

Cache quries for PCM and STREAM parameters as well as ampcap and
pincap sharing the hash table. This will reduce the superfluous
access of the same codec verbs.

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


# 93e82ae7 17-Apr-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Set function_id only on FG nodes

(Re)set function_id only from the value on FG nodes.
The current code overrides the value with the last widget.

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


# 18cb7109 16-Apr-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check strcpy length

Check the length to copy via strlen() beforehand to avoid the stack
corruption, or use strlcpy() to be safe in HD-audio codes.

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


# 4e01f54b 16-Apr-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add Creative CA0110-IBG support

Added the support for Creative SB X-Fi boards with UAA (HD-audio) mode.
In the HD-audio mode, no multiple streams are supported by just it
behaves like a normal HD-audio device.

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


# fcad94a4 15-Apr-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix the cmd cache keys for amp verbs

Fix the key value generation for get/set amp verbs. The upper bits of
the parameter have to be combined with the verb value to be unique for
each direction/index of amp access.

This fixes the resume problem on some hardwares like Macbook after
the channel mode is changed.

Tested-by: Johannes Berg <johannes@sipsolutions.net>
Cc: <stable@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 14bafe32 23-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use cached calls to get widget caps and pin caps

Replace with the standard function calls to use caches for reading
the widget caps and pin caps.

hda_proc.c is still using the direct verbs to get raw values as
much as possible.

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>


# 234b4346 23-Mar-2009 Pascal de Bruijn <pascal@unilogicnetworks.net>

ALSA: hda - Add function id to proc output

This patch does two things:
Output Intel HDA Function Id in /proc/asound/cardX/codec#X
Align Vendor/Subsystem/Revision Ids to 8 characters, front-padded with zeros

Before:
Vendor Id: 0x11d41884
Subsystem Id: 0x103c281a
Revision Id: 0x100100

After:
Function Id: 0x1
Vendor Id: 0x11d41884
Subsystem Id: 0x103c281a
Revision Id: 0x0100100

As report on the Kernel Bugzilla #12888

Signed-off-by: Pascal de Bruijn <pascal@unilogicnetworks.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ee504710 17-Mar-2009 Jaroslav Kysela <perex@perex.cz>

ALSA: snd-hda-intel - add checks for invalid values to *query_supported_pcm()

If ratesp or formatsp values are zero, wrong values are passed to ALSA's
the PCM midlevel code. The bug is showed more later than expected.

Also, clean a bit the code.

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


# bb6ac72f 13-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - power up before codec initialization

Change the power state of each widget before starting the initialization
work so that all verbs are executed properly.

Also, keep power-up during hwdep reconfiguration.

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


# 7a411ee0 06-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow slave controls with non-zero indices

Fix snd_hda_add_vmaster() to check the non-zero indices of slave controls.

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


# 82ad39f9 03-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix gcc compile warning

It's false positive, but annoying.
sound/pci/hda/hda_codec.c: In function ‘get_empty_pcm_device’:
sound/pci/hda/hda_codec.c:2772: warning: ‘dev’ may be used uninitialized in this function

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


# 6e655bf2 02-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't return a fatal error at PCM-creation errors

Don't return a fatal error to the driver but continue to probe when
any error occurs at creating PCM streams for each codec.
It's often non-fatal and keeping it would help debugging.

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


# f93d461b 02-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Revert the codec probe at control-creation errors

Revert the codec probe instead of returning the error to the driver
when any error occurs at creating the control elements.
The control element conflict can be non-fatal in many cases,
especially if it comes from the digital-only codec.

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


# d1f1af2d 02-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Intialize more codec fields in snd_hda_codec_reset()

Initiailize forgotten fields in snd_hda_codec_reset().

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


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

ALSA: hda - Add pseudo device-locking for clear/reconfig

Added the pseudo device-locking using card->shutdown flag to avoid
the crash via clear/reconfig during operations.

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


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

ALSA: hda - Make user_pin overriding the driver setup

Make user_pin overriding even the driver pincfg, e.g. the static / fixed
pin config table in patch_sigmatel.c.

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


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

ALSA: hda - Rename {override,cur}_pin with {user,driver}_pin

Rename from override_pin and cur_pin with user_pin and driver_pin,
respectively, to be a bit more intuitive.

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>


# 3be14149 20-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add generic pincfg initialization

Added the generic pincfg cache and save/restore functions.
Also introduced the pin-overriding via hwdep sysfs.

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


# 9411e21c 13-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_multi_out_dig_cleanup()

Added the helper function snd_hda_multi_out_dig_cleanup() to clean up
the digital outputs with multi setup. This call is needed in cases
the codec supports multiple digital outputs as slaves. Otherwise the
slave widgets aren't properly cleaned up.

For a single digital output (e.g. in patch_conexant.c), this call isn't
needed.

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


# 0852d7a6 11-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Detect multiple digital-out pins

Detect multiple digital-out pins in snd_hda_parse_pin_defconfig().
The dig_out_pin and dig_out_type fields become arrays.

The codec parser still doesn't use this multiple pins detection, though.

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


# 32d2c7fa 11-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix a wrong pin check in snd_hda_parse_pin_def_config()

Fixed a wrong pin check (a typo) for debug print of digital input pin.

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


# c8dcdf82 06-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing NULL check in snd_hda_create_spdif_in_ctls()

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


# e8c0ee5d 04-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix misc workqueue issues

Some fixes regarding snd-hda-intel workqueue:
- Use create_singlethread_workqueue() instead of create_workqueue()
as per-CPU work isn't required.
- Allocate workq name string properly
- Renamed the workq name to "hd-audio*" to be more obvious.

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


# 2297bd6e 20-Jan-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check HDMI jack types in the auto configuration

Add dig_out_type and dig_in_type fields to autocfg struct.
A proper HDA_PCM_TYPE_* value is assigned to these fields according
to the pin-jack location type value.

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


# 41b5b01a 20-Jan-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't break the PCM creation loop

Don't break the loop in snd_hda_codec_build_pcms() even if the item
has no substreams.

It's possible that it's an empty item and the next item containing
the valid substreams (e.g. realtek codecs may create the analog
and alt-analog but no digitl streams).

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


# 1b52ae70 20-Jan-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Detect non-SPDIF digital I/O

Accept non-SPDIF digital I/O pins as the digital pins.
These are usually corresponding to HDMI I/O.

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


# 89ce9e87 20-Jan-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add debug prints for digital I/O pin detections

Add the debug prints for digital I/O pin detections in
snd_hda_parse_pin_def_config() function.

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


# 29fdbec2 20-Jan-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add extra volume offset to standard volume amp macros

Added the volume offset to base for the standard volume controls
to handle elements with too big volume scales like -96dB..0dB.
For such elements, you can set the base volume to reduce the range.

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


# c107b41c 13-Jan-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use queue_delayed_work()

Replaced the old schedule_work() with queue_delayed_work() where
overlooked in the previous patches.

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


# 6acaed38 12-Jan-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use own workqueue

snd-hda-intel driver used schedule_work() fot the delayed DMA pointer
updates, but this has several potential problems:
- it may block other eventsd works longer
- it may deadlock when probing fails and flush_scheduled_work() is
called during probe callback (as probe callback itself could be
invoked from eventd)

This patch adds an own workq for each driver instance to solve these
problems.

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


# 5a9e02e9 09-Jan-2009 Wu Fengguang <wfg@linux.intel.com>

ALSA: hda - create hda_codec.control_mutex for kcontrol->private_value

Fix the following lockdep warning by not reusing the hda_codec.spdif_mutex.

ALSA sound/pci/hda/hda_codec.c:882: hda_codec_cleanup_stream: NID=0x2

=======================================================
[ INFO: possible circular locking dependency detected ]
2.6.28-next-20090102 #33
-------------------------------------------------------
mplayer/3151 is trying to acquire lock:
(&pcm->open_mutex){--..}, at: [<ffffffffa004ced3>] snd_pcm_release+0x43/0xd0 [snd_pcm]

but task is already holding lock:
(&mm->mmap_sem){----}, at: [<ffffffff810c0252>] sys_munmap+0x42/0x80

which lock already depends on the new lock.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d4d9cd03 19-Dec-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add probe_only option

Added probe_only module option to hd-audio driver.
This option specifies whether the driver creates and initializes the
codec-parser after probing. When this option is set, the driver skips
the codec parsing and initialization but gives you proc and other
accesses. It's useful to see the initial codec state for debugging.

The default of this value is off, so the default behavior is as same
as before.

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


# 827057f5 19-Dec-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing initializations of amp and verb caches

The re-initializations of codec amp and verb caches are missing
at reconfig, which may cause Oops occasionally.

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


# 74c61133 18-Dec-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add Intel vendor id string

Added Intel codec vendor id string (0x8086).
Also fixed Intel-HDMI codec name strings, too.

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


# 31117b78 16-Dec-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add Nvidia vendor id string

Added Nvidia (0x10de) to the vendor id list.
Cleaned up the codec name strings accordingly.

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


# 2eda3445 11-Aug-2008 Mauro Carvalho Chehab <mchehab@kernel.org>

ALSA: hda - Add a new function to seek for a codec ID

Gateway notebooks have their ID inside codec vendor ID, not at PCI ID. Due to
that, model auto-detection were not possible with the standard seek method.

This is what is found at lspci -vnn:

00:14.2 Audio device [0403]: ATI Technologies Inc SB450 HDA Audio [1002:437b] (rev 01)
Subsystem: ATI Technologies Inc SB450 HDA Audio [1002:437b]

Yet, autodetection is possible, since the codec properly reflects the vendor at
the Subsystem ID:

$ cat /proc/asound/card0/codec#0 |head -4

Codec: SigmaTel STAC9250
Address: 0
Vendor Id: 0x83847634
Subsystem Id: 0x107b0367

This patch adds a new autodetection function that seeks for codec subsystem ID.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ff7a3267 28-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't export symbols when built-in kernel

The global functions in hda_codec.c and other core parts are only
for HD-audio codec and controller drivers. When the HD-audio driver
is built in kernel, all stuff have to be statically linked, thus
we don't need any exports.

This patch introduces a conditional macro to do export only
when needed.

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


# 645f10c1 28-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check MODULE instead of CONFIG_SND_HDA_INTEL_MODULE

Checking MODULE is more generic.
Also a cosmetic comment change.

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


# 56d17712 28-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Clear codec->proc_widget_hook at reset

Clear the remaining pointer at snd_hda_codec_reset() to avoid Oops.

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>


# 529bd6c4 27-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix PCM reconfigure

The reconfiguration of PCM affected all PCM streams on the bus, but
this this should be done rather only for the target codec.

This patch does the following:
- introduce bitmap indicating the PCM device usages on a hda_bus
- refactor the PCM build functions
- fix __devinit prefix in some fucntions
- add a proper ifdef around HDA-reconfig-specific functions

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


# fee2fba3 26-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move power_save option to hda_intel.c

Move power_save option into hda_intel.c, and make a field in hda_bus,
instead of keeping module parameters in separate files.

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


# 986862bd 26-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - make some functions static

Minor clean ups: move snd_hda_codecs_inuse() into hda_intel.c and
make static. Also, make snd_hda_query_supported_pcm() static
as it's used only in hda_codec.c.

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


# 4f199629 25-Nov-2008 Qinghuang Feng <qhfeng.kernel@gmail.com>

ALSA: sound/pci/hda/hda_codec.c: cleanup kernel-doc

There is no argument named @state in snd_hda_resume,
remove its' comment.

Signed-off-by: Qinghuang Feng <qhfeng.kernel@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 9e976976 25-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix caching of SPDIF status bits

SPDIF status bits controls are written via snd_hda_codec_write()
without caching. This causes a regression at resume that the bits
are lost.

Simply replacing it with the cached version fixes the problem.

Reference:
http://lkml.org/lkml/2008/11/24/324

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


# b2022266 21-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix build without CONFIG_PROC_FS

snd_print_pcm_rates() and snd_print_pcm_bits() are used by both
hda_proc.c and hda_eld.c, thus they have to be defined in the common
place.

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


# b94d3539 21-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix double free of jack instances

The jack instances created in patch_sigmatel.c may be double-freed.
The device management code checks the invalid element, and thus there
is no real breakage, but it spews annoying warning messages.
But, we can't simply remove the release calls of these jack instances
because they have to be freed when the codec is re-configured.

Now, a new flag, bus->shutdown is introduced to indicate that the bus
is really being unloaded, i.e. the objects managed by the device
manager will be automatically deleted. We release these objects only
when this flag isn't set.

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


# f43aa025 10-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix another cache list management

Fix another silly bug in the amp cache list management.

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


# ea2da6e8 06-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix broken hash chain allocation

The chaining for amp hash got broken due to the rewrite with
snd_array. Fixed now.

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


# b910d9ae 06-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add max allocation check in array allocator

Added a check for max allocation size in snd_array_new() for a
debugging purpose.

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


# c217429b 06-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add missing NULL check in amp hash allocation

Added the missing NULL check from allocator in get_alloc_hash().

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


# 33fa35ed 06-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - simplify hda_bus ops callbacks

The hda_bus ops callback take struct hda_bus pointer.
Also, the command callback takes the composed command word, instead of
each small bits in arguments.

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


# 91504877 04-Nov-2008 Wu, Fengguang <fengguang.wu@intel.com>

ALSA: hda - Intel HDMI audio support

Add support for Intel G45 integrated HDMI audio codecs.

This initial release supports:
- 2 channel stereo sound output
- report monitor's ELD information

Signed-off-by: Wu Fengguang <wfg@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bfc5c26f 04-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't create empty PCM streams

Due to the hda-reconfiguration patches, the check of empty stream
is gone, and this results in an error with the codec setup with empty
streams.

This patch adds the check again to avoid the error at probing.

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


# b91f080f 04-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix possible NULL dereference

Add NULL-check of the return value of snd_kctl_new1() before
accessing it. Also, make a sanity NULL check to snd_BUG_ON()
for debugging only.

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


# 8199de3b 28-Oct-2008 Mark Brown <broonie@opensource.wolfsonmicro.com>

ALSA: hda: Add HDA vendor ID for Wolfson Microelectronics

Add Wolfson Microelectronics to the HDA vendor ID table.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 50a9f790 24-Oct-2008 Matt Ranostay <mranostay@gmail.com>

ALSA: hda: add snd_hda_get_jack* functions

This patch adds snd_hda_get_jack* functions for reporting jack location,
device, and connectivity type.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

ALSA: hda - Add init_verbs entries

This patch enables the additional init verbs for each codec. The verbs
can be entered via hwdep sysfs file. These verbs are executed at
reconfiguring the codec for non-standard setups like overriding
the pin-defcfg.

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


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

ALSA: hda - Add sysfs entries to hwdep devices

Added the sysfs entries to hwdep devices so that the new features
like reconfiguration can be done via sysfs.

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


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

ALSA: hda - Add codec reconfiguration feature

Added the reconfiguration feature of any individual codec.
Via the reconfiguration, the old resources are released and
the patch is called again to recreate the PCM and mixers in
addition to the re-initialization.

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>


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

ALSA: hda - Allocate name string of each codec

Allocate dynamically the name string of each codec instead of
pointing to a static string.

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


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

ALSA: hda - Use generic array helpers

Use generic array helpers to simplify array handling in snd-hda-intel.

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


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

ALSA: hda - Add generic arrays

Added helper functions to handle generic arrays.

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


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

ALSA: hda - Add infrastructure for dynamic stream allocation

Added the infrastructure for dynamic stream allocation on HD-audio.

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


# 6b34500c 07-Oct-2008 Wu Fengguang <wfg@linux.intel.com>

ALSA: hda: comment typo fix

fix a typo in comment for is_in_nid_list().

Signed-off-by: Wu Fengguang <wfg@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 5c1d1a98 07-Oct-2008 Wu Fengguang <wfg@linux.intel.com>

ALSA: hda: comment typo fix

fix a typo in comment for process_unsol_events().

Signed-off-by: Wu Fengguang<wfg@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 9a10eb21 25-Sep-2008 Wei Ni <wni@nvidia.com>

ALSA: Support NVIDIA MCP78/7A HDMI audio

Add NVIDIA HDMI HD-audio codec support in snd-hda-intel driver,
include NVIDIA MCP78/7A HDMI.

Signed-off-by: Wei Ni <wni@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 2f72853c 25-Sep-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix / clean-up slave digital out codes

The recent slave_dig_out addition has some rooms to clean up.
Also it doesn't call snd_hda_cleanup_stream() properly for slaves
at closing. The patch fixes both issues.

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


# ddc0f38a 25-Sep-2008 Matt Ranostay <mranostay@gmail.com>

ALSA: hda: slave_dig_outs code block in wrong location

Removed invalid references to slave_dig_outs inside the S/PDIF IN capture switch
control. Beforehand this was basically a mute switch for the S/PDIF outs as well.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 89385035 11-Sep-2008 Matt Ranostay <mranostay@gmail.com>

ALSA: hda: Input port AMP controls

Added support for controlling hardware gain amps on input ports
using a volume control mixer with a mux selecting the port being controlled.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 9932fbb0 13-Sep-2008 Herton Ronaldo Krzesinski <herton@mandriva.com.br>

ALSA: hda: fix oopses in snd-hda-intel after digital slave support additions

Many places fail to check if codec has slave_dig_outs entries (the most common
case is not having any entry), leading to various possible oopses in hda_codec
code.

Signed-off-by: Herton Ronaldo Krzesinski <herton@mandriva.com.br>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# de51ca12 07-Sep-2008 Matt Ranostay <mranostay@gmail.com>

ALSA: hda: slave digital out support

Added support for playing a stream on multiple digital outs. This is done
by defining codec->slave_dig_outs as array of hda_nid_t with a null-terminated entry to set the
slave SPDIF outs, in which the slave outs have cloned settings of the master out (e.g. dig_out_nid).

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# ba443687 13-Aug-2008 Jaroslav Kysela <perex@perex.cz>

ALSA: hda - put all HDA codec IDs to components for precise hw detection

Export HDA codec subvendor ID and revision ID to user space via the
components variable. Our alsactl utility requires these values for
the perfect hardware identification.

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


# 963f803f 11-Aug-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't reset SPDIF in each status change

The SPDIF output is toggled at each time any SPDIF status bits are changed
because of the known problems on some codecs. But, this also results in
loosing the sync, and the problem is more obvious on HDMI output over
SPDIF. Since the toggle is necessary only for some codecs, we should
check whether this workaround is needed and skip if unnecessary.

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


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


# 62cf872a 19-May-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] Replace CONFIG_SND_DEBUG_DETECT with CONFIG_SND_DEBUG_VERBOSE

Replace CONFIG_SND_DEBUG_DETECT with CONFIG_SND_DEBUG_VERBOSE to
represent its meaning more better. This config isn't provided only
for the detection but for more verbose debug prints in general.

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


# eaa9985b 14-Apr-2008 Frederik Deweerdt <deweerdt@free.fr>

[ALSA] hda-codec - Fix unbalanced mutex

On Wed, Apr 02, 2008 at 08:19:29AM -0400, Miles Lane wrote:
> [ 48.765906] [ BUG: bad unlock balance detected! ]
> [ 48.765912] -------------------------------------
> [ 48.765918] pulseaudio/4277 is trying to release lock
> (&codec->spdif_mutex) at:
> [ 48.765930] [<c03031b7>] mutex_unlock+0x8/0xa
> [ 48.765945] but there are no more locks to release!
> [ 48.765950]
> [ 48.765952] other info that might help us debug this:
> [ 48.765959] 2 locks held by pulseaudio/4277:
> [ 48.765965] #0: (&pcm->open_mutex){--..}, at: [<f89f134b>]
> snd_pcm_open+0xc1/0x1ba [snd_pcm]
> [ 48.766003] #1: (&chip->open_mutex){--..}, at: [<f8b4f13d>]
> azx_pcm_open+0x36/0x184 [snd_hda_intel]
> [ 48.766057]
> [ 48.766059] stack backtrace:
> [ 48.766066] Pid: 4277, comm: pulseaudio Not tainted 2.6.25-rc8-mm1 #12
> [ 48.766086] [<c013afc6>] print_unlock_inbalance_bug+0xce/0xd8
> [ 48.766107] [<c0109e1c>] ? save_stack_trace+0x1d/0x3b
> [ 48.766130] [<c012f54e>] ? __kernel_text_address+0x1b/0x27
> [ 48.766146] [<c0104533>] ? dump_trace+0xcd/0xd9
> [ 48.766160] [<c0109d9e>] ? save_stack_address+0x0/0x2c
> [ 48.766176] [<c013b80a>] ? find_usage_backwards+0xa4/0xc3
> [ 48.766193] [<c013cfb5>] lock_release_non_nested+0x84/0x120
> [ 48.766209] [<c03031b7>] ? mutex_unlock+0x8/0xa
> [ 48.766222] [<c013d1bb>] lock_release+0x16a/0x199
> [ 48.766238] [<c0303137>] __mutex_unlock_slowpath+0xa9/0x121
> [ 48.766252] [<c03031b7>] mutex_unlock+0x8/0xa
> [ 48.766263] [<f8b4ffd8>] snd_hda_multi_out_analog_open+0xd3/0xef
> [snd_hda_intel]

The following patch should fix it.

Cc: "Miles Lane" <miles.lane@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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


# 3c9a3203 29-Feb-2008 Harvey Harrison <harvey.harrison@gmail.com>

[ALSA] sound: hda: missing includes of hda_patch.h

Move the array declaration to hda_codec.c where it is used and add includes
where the individual presets are declared.

Fixes the following sparse warnings:
sound/pci/hda/patch_realtek.c:13744:25: warning: symbol 'snd_hda_preset_realtek' was not declared. Should it be static?
sound/pci/hda/patch_cmedia.c:729:25: warning: symbol 'snd_hda_preset_cmedia' was not declared. Should it be static?
sound/pci/hda/patch_analog.c:3656:25: warning: symbol 'snd_hda_preset_analog' was not declared. Should it be static?
sound/pci/hda/patch_sigmatel.c:3995:25: warning: symbol 'snd_hda_preset_sigmatel' was not declared. Should it be static?
sound/pci/hda/patch_si3054.c:286:25: warning: symbol 'snd_hda_preset_si3054' was not declared. Should it be static?
sound/pci/hda/patch_atihdmi.c:156:25: warning: symbol 'snd_hda_preset_atihdmi' was not declared. Should it be static?
sound/pci/hda/patch_conexant.c:1721:25: warning: symbol 'snd_hda_preset_conexant' was not declared. Should it be static?
sound/pci/hda/patch_via.c:1962:25: warning: symbol 'snd_hda_preset_via' was not declared. Should it be static?

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# c8cd1281 13-Feb-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add more names to vendor list

Added more known names to the vendor id list.

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


# 9a08160b 12-Feb-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add "IEC958 Default PCM" switch

Added a new mixer switch to enable/disable the sharing of the default
PCM stream with analog and SPDIF outputs. When "IEC958 Default PCM"
switch is on, the PCM stream is routed both to analog and SPDIF outputs.
This is the behavior in the earlier version.

Turning this switch off has a merit for some codecs, though. Some codec
chips don't support 24bit formats for SPDIF but only for analog outputs.
In this case, you can use 24bit format by disabling this switch.

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


# 5832fcf8 12-Feb-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - More fix-up for auto-configuration

In some cases, the BIOS sets up only the HP pins with different assoc
and sequence numbers, e.g. on FSC Esprimo with ALC262.

This patch adds a fix-up for such a case. When multiple HPs are defined
and no line-outs is found, the configurator tries to re-assign some pins
from HP list to line-out, judging from the sequence number.

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


# 09f99701 03-Feb-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Allow multiple SPDIF devices

The current code doesn't allow multiple SPDIF devices, and causes
errors when multiple SPDIF devices are found (e.g. SPDIF out and HDMI).
This patch allows multiple SPDIF devices by incrementing the index
automatically.

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


# 2f085549 22-Feb-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Don't create vmaster if no slaves found

Don't create vmaster controls if no slaves are found in the given list.
This prevents the error due to an empty vmaster control.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 14c65f98 22-Feb-2008 Serge A. Suchkov <Serge.A.S@tochka.ru>

[ALSA] hda-codec - Fix race condition in generic bound volume/swtich controls

Attached patch fix race condition in hd_codec generic bound volume/swtich
controls

oops on this bug can be easy reproduced by two mixer apps on SMP system with
PREEMPT kernel

dmesg:

ALSA /home/ss/ALSA/alsa-driver-1.0.16/pci/hda/../../alsa-kernel/pci/hda/hda_intel.c:596:
hda_intel: azx_get_response timeout, switching to polling mode: las
t cmd=0x014f0900
BUG: unable to handle kernel paging request at virtual address 00070006
printing eip: f8f43e95 *pde = 00000000
Oops: 0000 [#1] PREEMPT SMP
Modules linked in: i915 drm snd_seq_dummy snd_seq_oss snd_seq_midi_event
snd_seq snd_seq_device snd_pcm_oss snd_mixer_oss bnep rfcomm hidp l2cap
bluetooth w
lan_wep acpi_cpufreq coretemp hwmon mmc_block pcspkr psmouse wlan_scan_sta
ath_rate_sample snd_hda_intel ath_pci serio_raw wlan tg3 sdhci snd_pcm
firewire_o
hci mmc_core i2c_i801 snd_timer firewire_core snd_page_alloc ath_hal(P)
snd_hwdep snd iTCO_wdt crc_itu_t iTCO_vendor_support shpchp video output
acer_acpi b
acklight led_class wmi_acer

Pid: 3969, comm: gkrellm Tainted: P (2.6.24-jm #4)
EIP: 0060:[<f8f43e95>] EFLAGS: 00010292 CPU: 0
EIP is at snd_hda_mixer_bind_ctls_info+0x20/0x43 [snd_hda_intel]
EAX: 00000000 EBX: f7478e00 ECX: f763e000 EDX: f764f788
ESI: 00070002 EDI: edce5e00 EBP: edc3fe64 ESP: edc3fe54
DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
Process gkrellm (pid: 3969, ti=edc3e000 task=f1e4e000 task.ti=edc3e000)
Stack: f764f77c f7478e00 edce5e00 f6dd6000 edc3fe84 f8e590e8 edc7a239 f6d14034
f764f34c f6c0f7e0 edc3ff30 f6d14034 edc3fea8 f8e591b7 edc3ff30 edc3ff2c
00000000 f70aa668 f6d14034 f8e59165 bfbfadb0 edc3ff40 f8e587aa edc3ff2c
Call Trace:
[<c0104fbb>] show_trace_log_lvl+0x1a/0x2f
[<c010506d>] show_stack_log_lvl+0x9d/0xa5
[<c0105119>] show_registers+0xa4/0x1bd
[<c0105354>] die+0x122/0x206
[<c03daccc>] do_page_fault+0x535/0x623
[<c03d940a>] error_code+0x72/0x78
[<f8e590e8>] snd_mixer_oss_get_volume1_vol+0x74/0xf1 [snd_mixer_oss]
[<f8e591b7>] snd_mixer_oss_get_volume1+0x52/0xa5 [snd_mixer_oss]
[<f8e587aa>] snd_mixer_oss_ioctl1+0x673/0x71e [snd_mixer_oss]
[<f8e588af>] snd_mixer_oss_ioctl+0xb/0xd [snd_mixer_oss]
[<c017af0a>] do_ioctl+0x22/0x67
[<c017b186>] vfs_ioctl+0x237/0x24a
[<c017b1ca>] sys_ioctl+0x31/0x4b
[<c010402e>] syscall_call+0x7/0xb
=======================
Code: 3f 49 c7 89 f8 59 5b 5e 5f 5d c3 55 89 e5 57 89 d7 56 53 89 c3 83 ec 04
8b 70 5c 8b 40 60 05 7c 01 00 00 89 45 f0 e8 c0 3f 49 c7 <8b> 46 04 89 fa 89
4
3 5c 89 d8 8b 0e ff 11 89 73 5c 89 c7 8b 45
EIP: [<f8f43e95>] snd_hda_mixer_bind_ctls_info+0x20/0x43 [snd_hda_intel]
SS:ESP 0068:edc3fe54
---[ end trace 0a20bc209e9397cc ]---

similar issue report present in ALSA bugtracking system
https://bugtrack.alsa-project.org/alsa-bug/view.php?id=3652

Signed-off-by: Serge A. Suchkov <Serge.A.S@tochka.ru>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 09a99959 24-Jan-2008 Matt Ranostay <mranostay@gmail.com>

[ALSA] hda: Add dynamic mono mixer support for STAC92xx codecs

Allows for dynamically creating mono out mixer controls and well
as mono mux controls.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 90da78bf 24-Jan-2008 Matt Ranostay <mranostay@gmail.com>

[ALSA] hda: Added mono_out_pin to autoconfig

Added a mono_out_pin field to autocfg struct, and code to parse
for the mono_out_line.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 0ef6ce7b 22-Jan-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Optimize snd_hda_pser_pin_def_config()

Don't read the widget list again as we already have it at the beginning.

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


# ca7cfae9 22-Jan-2008 Marc Boucher <marc@linuxant.com>

[ALSA] hda-codec - Add afg and mfg preset mask

Added afg and mfg preset masks for more finer codec-preset selection.

Signed-off-by: Marc Boucher <marc@linuxant.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# d2595d86 22-Jan-2008 Marc Boucher <marc@linuxant.com>

[ALSA] hda-codec - Add a delay after power state change

Added a delay after the power state change as a partial workaround
for 'hda_intel: azx_get_response timeout' problem on Cxt codecs.

Signed-off-by: Marc Boucher <marc@linuxant.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 9c8f2abd 11-Jan-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - print control name in error messages

Print the name of the defect controls in error messages in amp info
callback. This will make debugging easier.

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


# 2134ea4f 10-Jan-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add virtual master controls

Add master controls using vmaster to codecs that have no real hardware
master volume registers.

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


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


# 3982d17e 18-Dec-2007 Andrew Paprocki <andrew@ishiboo.com>

[ALSA] hda-codec - Add missing #defines (and 1 rename) in hda_codec.h

Added AC_VERB_GET_DIGI_CONVERT_2 and renamed AC_VERB_GET_DIGI_CONVERT to
AC_VERB_GET_DIGI_CONVERT_1 to stay consistent with the SET variants. Added
AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK, AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK,
and AC_PINCAP_LR_SWAP. The missing fields were listed in the ALC883 datasheet
rev 1.3.

Signed-off-by: Andrew Paprocki <andrew@ishiboo.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 68ea7b2f 15-Nov-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Check value range in ctl callbacks

Check the value ranges in ctl put callbacks properly so that
invalid values won't be stored or written to registers.

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


# f889fa91 31-Oct-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Improve the auto-configuration

Some small improvements on autocfg stuff:
- sort HP pins by sequence number, too
- move sole mic pin to AUTO_PIN_MIC instead of AUTO_PIN_FRONT_MIC
- ditto for line-in pin

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


# 7f16859a 18-Oct-2007 Matt Ranostay <mranostay@gmail.com>

[ALSA] hda-codec - Add STAC9228 DMIC support

Added the missing STAC9228 DMIC support.
Also added a new vendor id tag for IDT.

Signed-off-by: Matthew Ranostay <mranostay@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 7eba5c9d 14-Nov-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Check PINCAP only for PIN widgets

The recent addition of checking PINCAP for EAPD seems to break some
systems due to unexpected response from the codec chip. We shouldn't
issue GET_PINCAP verb to non-PIN widgets. Now checks the widget type
before checking EAPD bit.

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


# d29240ce 25-Oct-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Disable shared stream on AD1986A

AD1986A has a hardware problem that it cannot share a stream with
multiple pins properly. The problem occurs e.g. when a volume is changed
during playback.
So far, hda-intel driver unconditionally assigns the stream to multiple
output pins in copy-front mode, and this should be avoided for AD1986A
codec.
The original fix patch was by zhejiang <zhe.jiang@intel.com>.

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


# 35a1e0cc 19-Oct-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix build without CONFIG_SND_HDA_GENERIC

Fixed the build error from patch_sigmatel.c when built without
CONFIG_SND_HDA_GENERIC by defining a dummy function to return error.
Also, clean up hda_codec.c by removing unneeded ifdefs (the compiler
will optimize out).

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


# 1194b5b7 10-Oct-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix Gateway laptops with STAC9200

Fix the output of Gateway laptops with STAC9200 codec chip.
They require the EAPD control for some pins. These pins shouldn't be
powered down.
To enable EAPD control, a new model 'gateway' was added to STAC9200.
The known PCI SSIDs are included in the quirk list.
The fix was originally suggested by Brian Hinz, in ALSA bug#2948.

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


# 5513b0c5 09-Oct-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add zero checks in input-mux helper functions

Added zero checks in input-mux helper functions to avoid Oops.
Some devices may have no input pins while the driver registers
control elements calling these functions.

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


# 7a5a27cf 17-Sep-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] Add default values for power-saving as Kconfig options

Added CONFIG_SND_AC97_POWER_SAVE_DEFAULT and CONFIG_SND_HDA_POWER_SAVE_DEFAULT
Kconfig options as the default values for power-saving mode of AC97 and
HD-audio drivers, respectively.

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


# e8a7f136 11-Sep-2007 Danny Tholen <obiwan@mailmij.org>

[ALSA] hda-intel - Improve HD-audio codec probing robustness

When modem is disabled in the BIOS, detection of the number of codecs
always fails after booting if STATESTS is not cleared first.
This patch fixes this problem and also adds an error check in a place
where a read error would lead to a very large number of pointless loops.

Signed-off-by: Danny Tholen <obiwan@mailmij.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# d804ad92 03-Sep-2007 Maxim Levitsky <maximlevitsky@gmail.com>

[ALSA] hda-intel - Fix resume logic, when dynamic power managment is on

Comment in hda_intel.c states that 'the explicit resume is needed only
when POWER_SAVE isn't set', but this is not true.
There is no code that will automaticly power up the codec on resume,
but only code that powers it up when user accesses it. So if user
leaves a sound playing, codec will not be powered
To fix that I check if there are any codecs that should be powered
codec->power_count, and if so I power them up together with main
controller.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 2e492462 03-Sep-2007 Maxim Levitsky <maximlevitsky@gmail.com>

[ALSA] hda-intel - fix a race in dynamic power managment

codec->power_transition is supposed to be true while codec is going
to be shut off if in the mean time somebody calls snd_hda_power_up,
hda_power_work will not shut down the codec, but nether will clear
codec->power_transition, thus it stays on forever. Fix this.

Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 1fcaee6e 22-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Fix compile with gcc-3.x

gcc-3.x doesn't like forward inlining:
CC [M] sound/pci/hda/hda_codec.o
sound/pci/hda/hda_codec.c: In function 'snd_hda_codec_free':
sound/pci/hda/hda_codec.c:517: sorry, unimplemented: inlining failed in call to 'free_hda_cache': function body not available
sound/pci/hda/hda_codec.c:534: sorry, unimplemented: called from here
sound/pci/hda/hda_codec.c:517: sorry, unimplemented: inlining failed in call to 'free_hda_cache': function body not available
sound/pci/hda/hda_codec.c:535: sorry, unimplemented: called from here

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


# a221e287 16-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Avoid unnecessary work scheduling

Avoid unnecessary work scheduling for power-off.

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


# 2525fdc4 15-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Add flush_scheduled_work() in snd_hda_codec_free()

Added flush_scheduled_work() in snd_hda_codec_free() to make sure that
the all work is gone. Also, optimized the condition to schedule the
delayed work in snd_hda_power_down().

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


# 0b7a2e9c 14-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Don't do suspend if already powered down

In the power-saving mode, the suspend is done dynamically at power-down.
So we don't have to call suspend stuff explicitly if it's already
powered down.

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


# 9d99f312 14-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Fix NULL dereference in resume

codec->patch_ops.init can be NULL. Check before calling it.

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


# 95e99fda 13-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Fix resume with power save

The controller power wasn't turned on properly at resume due to the
power-saving patch. Now fixed.

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>


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

[ALSA] hda-codec - introduce command register cache

This patch adds the cache for codec command registers.
snd_hda_codec_write_cache() and snd_hda_sequence_write_cache() do
the write operations with caching, which values can be resumed via
snd_hda_codec_resume_cache().
The patch introduces only the framework, and no codec code is using
this cache yet. It'll be implemented in the following patch.

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


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

[ALSA] hda-codec - rewrite amp cache more generic

Rewrite the code to handle amp cache and hash tables to be more
generic. This routine will be used by the register caches in the
next patch.

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


# 12f288bf 02-Aug-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Remove invalid __devinit

Some functions in hda_codec.c are called from patch ops, which are
kept in the codec instance even after initialization. Thus they
shouldn't be marked as __devinit.

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


# 82467611 27-Jul-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - kernel config for each codec

Create kernel configs to choose the codec support codes to build.

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


# 532d5381 27-Jul-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add a generic bind-control helper

Added callbacks for a generic bind-control of mixer elements.
This can be used for creating a mixer element controlling multiple
widgets at the same time. Two macros, HDA_BIND_VOL() and HDA_BIND_SW(),
are introduced for creating bind-volume and bind-switch, respectively.
It taks the mixer element name and struct hda_bind_ctls pointer, which
contains the real control callbacks in ops field and long array for
private_value of each bound widget.
All widgets have to be the same type (i.e. the same amp capability).

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


# 2807314d 27-Jul-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Add hwdep interface

Added a hwdep interface for each codec (enabled per kconfig).
This interface can be used for reading/writing HD-audio verbs
and other purposes as future extensions.

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


# a5ce8890 23-Jul-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] Clean up with common snd_ctl_boolean_*_info callbacks

Clean up codes using the new common snd_ctl_boolean_*_info() callbacks.

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


# 897cc188 29-May-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix STAC922x capture boost level

STAC922x provides the capture boost level up to 4, but actually it
works only up to 2. Since the range of the mixer is automatically
defined from amp-capability bits, we need to override the value
beforehand. snd_hda_override_amp_caps() is introduced for this
purpose.
The function patch_stac922x() calls this for NID 0x12 (Mux Capture
Volume). This should fix another recording problem on Intel Macs.

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


# b75e53f0 10-May-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Make the mixer capability check more robust

In some cases, mixer elements return -EINVAL because it couldn't
obtain proper amp_cap bits. The patch improves the robustness,
trying the amp_cap query again in such a case.

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


# 81937d3b 08-May-2007 Steve Longerbeam <stevel@embeddedalley.com>

[ALSA] Add speaker pin sequencing to hda_codec.c:snd_hda_parse_pin_def_config()

Some verb tables (such as an Asus VT sent by IDT) contain only speaker
outs in the default pin configs, and no line-outs. In such a case the
speaker sequence numbers have to be used to order the speaker out
pins, just as is being done for line-out pins. Then, when speaker-outs
are copied to line-outs, the line-outs will be ordered properly.

Signed-off-by: Steve Longerbeam <stevel@embeddedalley.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 43ea1d47 26-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Prefer audio codec name as the mixer name

Prefer the name of audio codecs as the mixer name even if
modem codecs are probed before the audio codecs.

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


# d258e24a 23-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add line_out_type to auto_pin_cfg struct

Added line_out_type field to auto_pin_cfg struct to provide the
pin type of default line_outs.

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


# 9422db40 20-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix 8-channel auto-configuration

Fix the auto-configuration of 8-channel devices. The sequence numbers
of usual 7.1 outputs are: 0/1/2/4 = Front/CLFE/Rear/Side

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


# 0ba21762 16-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Code clean up

Trivial code clean-ups to follow the standard coding styles.

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


# 756e2b01 16-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Merge hda-codec module to a single module

Merge hda-codec module to a single hda-intel module since this is the
only user right now. Although hda-codec stuff is designed to be used
universally from different controller drivers, currently only one
controller interface (and compatibles) are used. So, let's merge them
to a single module to save memory.

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


# 5930ca41 16-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Allow opening SPDIF while analog dup mode

Allow opening the dedicated SPDIF stream while running on analog dup
mode. Then the SPDIF stream is once reset and assigned for the new
stream. It's useful for exclusive SPDIF output like AC3/DTS.
(In the former version, you had to close once the analog stream to
play the exclusive digital stream.)

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


# a961f9fe 12-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add support of 96kHz back

Added the support of 96kHz sample rate back. Although the rate isn't
listed in the ACC_PAR_PCM bits but si3054 codecs do support this rate
explicitly. Now fixed the deteciton code not to check this extra bit.

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


# 6b97eb45 05-Apr-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix SPDIF output

Fix SPDIF output (at least on Realtek codecs). The DIGI_CONVERT verbs
have to be reset before the PCM stream is set up. Otherwise the digital
setup is screwed up.
Also, check the AMP capability before setting AMP of the digital out
widget.

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


# d5ad630b 07-Mar-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] Fix NULL dereference with null modelname

Fix the NULL dereference of modelname option. The check is moved to
find_codec_preset() now, too.

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


# 6d7b1d7d 26-Feb-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Allow model=generic always for generic parser

Accept model=generic option to specify the generic parser regardless
of codec chips. This is helpful for testing and debugging.

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


# e250af29 19-Dec-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Use global workqueue

Use global workqueue for simplicity.
The unsolicited event frequency isn't so high to have own queue.

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


# c577b8a1 29-Nov-2006 Joseph Chan <josephchan@via.com.tw>

[ALSA] hda-codec - Add support for VIA VT1708(A) HD audio codec

This patch is VIA first release for HD audio codec, VT1708(A) and
it provides geneneral HD audio driver features.

Signed-off-by: Joseph Chan <josephchan@via.com.tw>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# f5fcc13c 24-Nov-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Use snd_pci_quirk_lookup() for board config lookup

Use snd_pci_quirk_lookup() for looking up a board config table.
The config table is sorted in numerical order of PCI SSIDs.

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


# ee3527b0 07-Nov-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix detection of supported sample rates

Don't include 9.6kHz in the list of supported sample rates.
Since this rate isn't indicated in AC_PAR_PCM parameter,
the driver might guess wrongly as if it's available.

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


# c4028958 22-Nov-2006 David Howells <dhowells@redhat.com>

WorkStruct: make allyesconfig

Fix up for make allyesconfig.

Signed-Off-By: David Howells <dhowells@redhat.com>


# 314634bc 21-Sep-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix mic input with STAC92xx codecs

Fixed mic input with STAC92xx codecs. The mic pin was sometimes set to
OUTPUT by the headphone jack detection.
Also, try to assign a secondary mic as front-mic (or vice versa)
in the auto-detection if possible.

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


# eb06ed8f 20-Sep-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Support multiple headphone pins

Some machines have multiple headpohne pins (usually on the lpatop
and on the docking station) while the current hda-codec driver
assumes a single headphone pin. Now it supports multiple hp pins
(at least for detection).
The sigmatel 92xx code supports this new multiple hp pins.
It detects all hp pins for auto-muting, too.
Also, the driver checks speaker pins in addition. In some cases,
all line-out, speaker and hp-pins coexist.

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


# 33ef7651 19-Sep-2006 Nicolas Graziano <nicolas.graziano@wanadoo.fr>

[ALSA] hda_intel prefer 24bit instead of 20bit

If I understand the hda_intel code, for format > 20bit it only advertise
the SNDRV_PCM_FMTBIT_S32_LE format and play it at 32 bit, 20 bit or 24 bit.
But if the 20bit and 24bit are available, actually it prefer the 20bit
format. This path is to prefer the 24bit format instead of 20bit.

Signed-off-by: Nicolas Graziano <nicolas.graziano@wanadoo.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# a9226251 17-Sep-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Add vendor ids for Motorola and Conexant

Added string entries for Motorola and Conexant vendor ids.

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


# 35aec4e2 28-Jul-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] Don't set up the same PID twice in snd_hda_multi_out_analog_prepare

Check the hp_nid whether it's identical with front pin to avoid
the setup of the same widget node twice.

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


# bc6c531e 27-Jul-2006 Jaroslav Kysela <perex@suse.cz>

[ALSA] HDA driver - do not set mute flag for dB scale (follow HDA specification)


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


# 302e9c5a 05-Jul-2006 Jaroslav Kysela <perex@suse.cz>

[ALSA] HDA codec & CA0106 - add/fix TLV support


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


# 9c7f852e 28-Jun-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] Fix/add support of Realtek ALC883 / ALC888 and ALC861 codecs

Patch from Realtek:
- Fix ALC883 support code
- Add support of ALC888 codec
- Add ALC660 support (ALC861-compatible)
- Add HP xw4400/6400/8400/9400 support (model=hp-bpc)
- Code clean-up: fix spaces and indentation

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


# e5e8a1d4 28-Apr-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Move EXPORT_SYMBOL() to adjacent to each function

Move EXPORT_SYMBOL() to adjacent to each exported function/variable.

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


# ce7415f4 30-Mar-2006 OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

[ALSA] sound/pci/hda: use create_singlethread_workqueue()

process_unsol_events() seems to assume a singlethread one (IOW, racey).
So, this patch uses create_singlethread_workqueue() instead of
create_workqueue().

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 82bc955f 21-Mar-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix BIOS auto-configuration

Modules: HDA Codec driver,HDA generic driver

- Fix autoconfig speaker/hp detection
Now it allows multiple speaker pins (e.g. Dell laptops have such config)

- Use speaker or hp pins if no line-outs are available
This fixes the silence output on recent Dell laptops with STAC9200
(ALSA bug#1843)

- Fix analog/realtek/sigmatel autoconfig parser

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


# 834be88d 01-Mar-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix ALC262 for Fujitsu laptop

Modules: HDA Codec driver,HDA generic driver

Add 'fujitsu' model for ALC262 patch to support a FSC laptop.
The internal speaker is turned on/off with jack sensing.

Also fixed alc262 'basic' model.

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


# 111d3af5 16-Feb-2006 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Automatic correction to single_cmd mode

Modules: HDA Codec driver,HDA Intel driver

Switch to single_cmd mode automatically as a fallback when CORB/RIRB
communication doesn't work well. It may make the driver working on
some devices with broken BIOS/ACPI support.

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


# 62932df8 16-Jan-2006 Ingo Molnar <mingo@elte.hu>

[ALSA] semaphore -> mutex (PCI part)

Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 4a471b7d 07-Dec-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Small clean up and fixes

Modules: HDA Codec driver,HDA generic driver

- Common labels for input pins
- Fix and clean up of Realtek codec parsers

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


# df694daa 05-Dec-2005 Kailang Yang <kailang@realtek.com.tw>

[ALSA] hda-codec - Add the support of ALC262,ALC883,ALC885,ALC861

Modules: HDA Codec driver,HDA generic driver

This patch adds the support of ALC262,ALC883,ALC885,ALC861 to driver
More models and improvements for ALC880, ALC260 and ALC882 codecs, too.

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


# b2ec6423 24-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix channel mode helper

Modules: HDA Codec driver

Fix the channel mode helper (for put callback).

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


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

[ALSA] hda-codec - Fix connection list parsing

Modules: HDA Codec driver,HDA generic driver

- Fix connection list parsing (with ranged flag).
- Increase the max number of connections
- Introduce widget capabilities cache
- Power up/down widgets at init, suspend and resume

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>


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

[ALSA] hda-codec - Fix assignment of speaker pin

Modules: HDA Codec driver,HDA generic driver

Fix the auto-assignment of speaker pin. Handle it independently from
line-out pins.

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


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

[ALSA] hda-codec - Prepare unsol workqueue on demand

Modules: HDA Codec driver

Prepare unsol workqueue only when a codec really supports.

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


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

[ALSA] hda-codec - Add channel-mode helper

Modules: HDA Codec driver,HDA generic driver

Add common channel-mode helper functions for all codec patches.

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


# d031166f 07-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Allocate amp hash array dynamically

Modules: HDA Codec driver

Allocate amp hash array dynamically instead of static array.

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


# 985be54b 02-Nov-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Minor rewrites

Modules: HDA Codec driver,HDA generic driver

- Make bound controls global to all patches
- Clean up analog patches (for the upcoming extension to AD1988)

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


# 86284e45 11-Oct-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Get subsystem ID from AFG/MFG

Modules: HDA Codec driver

Get subsytem ID from AFG/MFG if not obtained from the root node.

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>


# befdf316 22-Aug-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Code clean up

HDA Codec driver
Use struct instead of array to improve the readability of hda_codec.c.

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


# 9d8f53f2 22-Aug-2005 Nicolas Graziano <nicolas.graziano@wanadoo.fr>

[ALSA] hda-intel - correct a bug in detection of rate supported

HDA Codec driver
The insertion of the rate 9600 make a shift in detection of supported
rate, put this rate at the end of the list.

Signed-off-by: Nicolas Graziano <nicolas.graziano@wanadoo.fr>
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>


# b9f5a89c 28-Jul-2005 Nicolas Graziano <nicolas.graziano@wanadoo.fr>

[ALSA] hda-codec - Fix LFE volume/switch

HDA Codec driver
Fixed LFE volume/switch control.

Signed-off-by: Nicolas Graziano <nicolas.graziano@wanadoo.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# cb8e2f83 29-Jul-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Fix reordering of surround channels

HDA Codec driver
- Fixed the reordering of surround channels.
Originally reported by Nicolas GRAZIANO <nicolas.graziano@wanadoo.fr>.

- Show the selected ssid when debug option is set.

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>


# 5ecd7022 10-Jun-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Allow sub_device=0 in board config check

HDA Codec driver
Allow sub_device=0 in board config check. This means that every device
with the given sub vendor ID will match.

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


# 4b3acaf5 10-Jun-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-codec - Feed front signals to all surrounds

HDA Codec driver
Feed front signals to all surround channels if no data is given
for surround channels.

It seems that CLFE works as expected (only center outputs) even if
connected from the front line - at least on my test system.
If this change causes problems on other system (e.g. only the left
channel is transferred to the center channel), please let me know...

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


# 4a19faee 08-Jun-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Fix the handling of amp cache in hda-codec

HDA Codec driver
Fixed the handling of amp cache in hda-codec driver.
The confliction of cache values with different indices should be fixed now.

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


# 54b903ec 15-May-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Add Analog Devices vendor name

HDA Codec driver
Added the missing vendor name entry for Analog Devices.

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


# 680ff0ac 13-May-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Suppress error message

HDA Codec driver
Suppressing the error message regarding no AFG.
This is often harmless (e.g. probing a modem codec).

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


# 89c87bf8 13-May-2005 Adrian Bunk <bunk@stusta.de>

[ALSA] make code static

CA0106 driver,HDA Codec driver
This patch makes needlessly global code static.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 7291548d 12-May-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Rename pci_vendor/pci_device to pci_subvendor/pci_subdevice

HDA Codec driver,HDA generic driver
Renamed pci_vendor/pci_device fields to pci_subvendor/pci_subdevice.
They are really PCI subsystem IDs.

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


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

[ALSA] Fix and cleanup of CM9880 auto-configuration

HDA Codec driver
Fix and cleanup of CM9880 automatic PIN configuration.
snd_hda_codec_setup_stream() doesn't do anything when NID is 0.

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


# 01f66d2c 14-Apr-2005 Takashi Iwai <tiwai@suse.de>

[ALSA] Remove dead code

HDA Codec driver
Removed the dead (duplicated) code.

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


# 2f2f4251 13-Apr-2005 Matt <matt@embeddedalley.com>

[ALSA] add sigmatel codec support

HDA generic driver,HDA Codec driver
Add initial SigmaTel codec support for 9200 and 922x. Note that
this hda patch relies on the configuration default registers to
be set correctly (normally by BIOS/firmware) in order for it to
set up pin widgets properly. There's a test switch in the patch
so it will work with the SigmaTel reference boards that are usually
plugged into a system that doesn't set the configuration default
registers. It supports 2 channel analog out and line/mic in. I
plan to add >2 channel support and spdif support shortly.
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!