... 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.
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.
There is no much merit to keep the HD-audio codec and controller
helper codes in separate modules any longer. Let's merge them into a
single helper module.
This patch just changes Makefile entries to merge two individual
modules to one. The only code change is the removal of superfluous
MODULE_*() macros in one side.
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.
Mengdong Lin [Tue, 14 Apr 2015 03:25:36 +0000 (11:25 +0800)]
ALSA: hda - set GET bit when adding a vendor verb to the codec regmap
Some HD-A codecs may add their own vendor 'set' verb to the regmap, thru func
snd_hdac_add_vendor_verb(). This patch sets the GET bit (bit 11) when adding
the verb so that its peer vendor 'get' verb is actually added. This can avoid
I/O error when writing the 'set' verb thru remap, since HD-A regmap internally
looks up a writable vendor verb with GET bit set at first.
Signed-off-by: Mengdong Lin <mengdong.lin@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Merge tag 'asoc-v4.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Updates for v4.1
More updates for v4.1, pretty much all drivers:
- Lots of cleanups from Lars, mainly moving things from the CODEC level
to the card level.
- Continuing improvements to rcar from Morimoto-san, pcm512x from
Howard and Peter, the Intel platforms from Vinod, Jie, Jin and Han,
and to rt5670 from Bard.
- Support for some non-DSP Qualcomm platforms, Google's Storm
platform, Maxmim MAX98925 CODECs and the Ingenic JZ4780 SoC.
ALSA: hda - Fix another race in runtime PM refcounting
Although some races in runtime PM refcount was fixed by the commit
[664c715573c2: ALSA: hda - Work around races of power up/down with
runtime PM], there is still a race in the following case:
For avoiding this situation, increment in_pm flag atomically when it's
non-zero, and decrement accordingly, to ensure that in_pm is set
consistently for the whole concurrent operations.
Also, since atomic_inc_not_zero() and atomic_dec_if_positive() are
lengthy inline functions, move snd_hdac_power_up_pm() and _down_pm()
to sound/hda/hdac_device.c as no inline functions.
ALSA: ctl: fix to handle several elements added by one operation for userspace element
An element instance can have several elements with the same feature.
Some userspace applications can add such an element instance by add
operation with the number of elements. Then, the element instance
gets a memory object to keep states of these elements.
But the element instance has just one memory object for the elements.
This causes the same result to each read/write operations to the
different elements.
This commit fixes this bug by allocating enough memory objects to the
element instance for each of elements.
Mark Brown [Sun, 12 Apr 2015 18:48:29 +0000 (19:48 +0100)]
Merge tag 'asoc-v4.1' into asoc-next
ASoC: Changes for v4.1
A selection of changes for v4.1 so far. The main things are:
- Move of jack registration to the card where it belongs.
- Support for DAPM routes specified by both the machine driver and DT.
# gpg: Signature made Thu 05 Mar 2015 01:10:27 GMT using RSA key ID 5D5487D0
# gpg: WARNING: digest algorithm MD5 is deprecated
# gpg: please see https://gnupg.org/faq/weak-digest-algos.html for more information
# gpg: Oops: keyid_from_fingerprint: no pubkey
# gpg: Good signature from "Mark Brown <broonie@sirena.org.uk>"
# gpg: aka "Mark Brown <broonie@debian.org>"
# gpg: aka "Mark Brown <broonie@kernel.org>"
# gpg: aka "Mark Brown <broonie@tardis.ed.ac.uk>"
# gpg: aka "Mark Brown <broonie@linaro.org>"
# gpg: aka "Mark Brown <Mark.Brown@linaro.org>"
Mark Brown [Sun, 12 Apr 2015 18:48:19 +0000 (19:48 +0100)]
Merge tag 'asoc-fix-v4.0-rc7' into asoc-linus
ASoC: Last minute fix for v4.0
This patch backs out a change that came in during the merge window which
selects a configuration for GPIO4 on pcm512x CODECs that may not be
suitable for all systems using the device. Changes for v4.1 will make
this properly configurable but for now it's safest to revert to the
v3.19 behaviour and leave the pin configuration alone.
Sorry for sending this direct at the last minute but due to the GPIO
misuse it'd be really good to get it in the release and I'd not realised
it hadn't been sent yet - between some travel, a job change and other
non-urgent fixes coming in I'd lost track of the urgency. It's been in
-next for several weeks now, is isolated to the driver and fairly clear
to inspection.
# gpg: Signature made Sat 11 Apr 2015 22:14:17 BST using RSA key ID 5D5487D0
# gpg: WARNING: digest algorithm MD5 is deprecated
# gpg: please see https://gnupg.org/faq/weak-digest-algos.html for more information
# gpg: Oops: keyid_from_fingerprint: no pubkey
# gpg: Good signature from "Mark Brown <broonie@sirena.org.uk>"
# gpg: aka "Mark Brown <broonie@debian.org>"
# gpg: aka "Mark Brown <broonie@kernel.org>"
# gpg: aka "Mark Brown <broonie@tardis.ed.ac.uk>"
# gpg: aka "Mark Brown <broonie@linaro.org>"
# gpg: aka "Mark Brown <Mark.Brown@linaro.org>"
sound/soc/intel/haswell/sst-haswell-ipc.c:646:28-29: WARNING: Use ARRAY_SIZE
Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element
Semantic patch information:
This makes an effort to find cases where ARRAY_SIZE can be used such as
where there is a division of sizeof the array by the sizeof its first
element or by any indexed element or the element type. It replaces the
division of the two sizeofs by ARRAY_SIZE.
All CODEC input and output widgets are either in the DAPM routing table or
manually marked as non-connected. This means the card is fully routed and we
can let the core take care of disconnecting non-connected pins.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: n810: Consistently pass the card DAPM context to n810_ext_control()
Some callers of n810_ext_control() pass the card DAPM context and some pass
the CODEC DAPM context. Given that some of the widgets that are accessed in
the function are in the card's context, always passing it is the obvious
choice.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: davinci-evm: Use card DAPM context to access widgets
The dapm field of the snd_soc_codec struct will eventually be removed
(replaced with the DAPM context from the component embedded inside the
CODEC). Replace its usage with the card's DAPM context. The idea is that
DAPM is hierarchical and with the card at the root it is possible to access
widgets from other contexts through the card context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: mop500_ab8500: Use card DAPM context to access widgets
The dapm field of the snd_soc_codec struct will eventually be removed
(replaced with the DAPM context from the component embedded inside the
CODEC). Replace its usage with the card's DAPM context. The idea is that
DAPM is hierarchical and with the card at the root it is possible to access
widgets from other contexts through the card context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: wm1133-ev1: Use card DAPM context to access widgets
The dapm field of the snd_soc_codec struct will eventually be removed
(replaced with the DAPM context from the component embedded inside the
CODEC). Replace its usage with the card's DAPM context. The idea is that
DAPM is hierarchical and with the card at the root it is possible to access
widgets from other contexts through the card context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: atmel: Improve machine driver compile test coverage
The Atmel ASoC machine drivers don't have any compile time arch dependencies
anymore. Make it possible to select them when COMPILE_TEST is enabled to get
better compile test coverage.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: atmel: Add dependency to SND_SOC_I2C_AND_SPI where necessary
The SND_AT91_SOC_SAM9G20_WM8731 and SND_AT91_SOC_SAM9X5_WM8731 machine
driver symbols select SND_SOC_WM8731 which depends on SND_SOC_I2C_AND_SPI.
So the machine driver symbols need to depend on SND_SOC_I2C_AND_SPI as well,
otherwise we might end up with a invalid configuration, which will sooner or
later upset the randconfig auto-builders.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ALSA: control: Fix a typo of SNDRV_CTL_ELEM_ACCESS_TLV_* with SNDRV_CTL_TLV_OP_*
The commit [39d118677baa: ALSA: ctl: evaluate macro instead of
numerical value] replaced the numbers with constants, but one place
was replaced wrongly with a different type. Fixed now.
Adam Honse [Sun, 12 Apr 2015 06:03:07 +0000 (01:03 -0500)]
ALSA: usb-audio: Don't attempt to get Microsoft Lifecam Cinema sample rate
Adds Microsoft LifeCam Cinema USB ID to the snd_usb_get_sample_rate_quirk list as the Lifecam Cinema does not appear to support getting the sample rate.
Fixes the issue where the LifeCam Cinema would wait for USB timeout and log the message "cannot get freq at ep 0x82" when accessed.
ASoC: rnsd: fix build regression without CONFIG_OF
The r-car sound driver only works when CONFIG_OF is set, and
after a recent change has a compile-time dependency as well:
sound/built-in.o: In function `rsnd_dma_request_channel':
:(.text+0x9fb84): undefined reference to `of_dma_request_slave_channel'
This could be fixed either by adding a static inline wrapper
for the function, or by adding a Kconfig dependency. This
implements the second approach, which seems appropriate
because the driver in fact has a hard dependency.
Signed-off-by: Arnd Bergmann <arnd@arndb.de> Fixes: 72adc61f4637aa3 ("ASoC: rsnd: 1st DMAC dma-names cares subnode") Signed-off-by: Mark Brown <broonie@kernel.org>
Howard Mitchell [Mon, 23 Mar 2015 21:17:01 +0000 (21:17 +0000)]
ASoC: pcm512x: Remove hardcoding of pll-lock to GPIO4
Currently GPIO4 is hardcoded to output the pll-lock signal.
Unfortunately this is after the pll-out GPIO is configured which
is selectable in the device tree. Therefore it is not possible to
use GPIO4 for pll-out. Therefore this patch removes the
configuration of GPIO4.
Signed-off-by: Howard Mitchell <hm@hmbedded.co.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
Michael Gernoth [Sat, 11 Apr 2015 16:00:19 +0000 (18:00 +0200)]
ALSA: emu10k1: add toggles for E-mu 1010 optical ports
The optical ports on the E-mu 1010 (and dock) can be configured
for ADAT- or S/PDIF-mode, which is currently hardcoded to ADAT.
Add two mixer elements to expose this setting.
Tested on an E-mu 1010 PCIe with connected Micro Dock.
Signed-off-by: Michael Gernoth <michael@gernoth.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: ctl: fill identical information to return value when adding userspace elements
currently some members related identical information are not fiiled
in returned parameter of SNDRV_CTL_IOCTL_ELEM_ADD. This is not better
for userspace application.
This commit copies information to returned value. When failing to copy
into userspace, the added elements are going to be removed. Then, no
applications can lock these elements between adding and removing because
these are already locked.
ALSA: ctl: confirm to return all identical information in 'activate' event
When event originator doesn't set numerical ID in identical information,
the event data includes no numerical ID, thus userspace applications
cannot identify the control just by unique ID in event data.
This commit fix this bug so as the event data includes all of identical
information.
Jin Yao [Tue, 7 Apr 2015 01:33:30 +0000 (09:33 +0800)]
ASoC: Intel: Refactor common IPC/mailbox code into generic APIs
Currently in Intel SST driver, some similar IPC/mailbox processing
code are used in different platforms (e.g. in baytrail/broadwell).
This patch extracts the common code and creates new files
(sst-ipc.c/sst-ipc.h) to contain the common code and provide the generic
APIs for IPC/mailbox processing.
Signed-off-by: Jin Yao <yao.jin@linux.intel.com> Acked-by: Jie Yang <yang.jie@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: core: call snd_soc_runtime_set_dai_fmt() before soc_new_pcm()
Current snd_soc_runtime_set_dai_fmt() is called after
soc_probe_link_dais(). this means snd_soc_dai_set_fmt() will be
called after soc_new_pcm().
Before appling 1efb53a220b78fdfdbb97b726a2156713e75bdab
(ASoC: simple-card: Remove support for setting differing DAI formats)
simple-card user had (1) snd_soc_dai_set_fmt() -> soc_new_pcm(),
but, after that it is (2) soc_new_pcm() -> snd_soc_dai_set_fmt().
At least rsnd driver is assuming (1) pattern.
This patch move snd_soc_dai_set_fmt() into soc_probe_link_dais()
after the dai_link->init section to solve this issue.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Michael Gernoth [Thu, 9 Apr 2015 21:42:15 +0000 (23:42 +0200)]
ALSA: emu10k1: don't deadlock in proc-functions
The functions snd_emu10k1_proc_spdif_read and snd_emu1010_fpga_read
acquire the emu_lock before accessing the FPGA. The function used
to access the FPGA (snd_emu1010_fpga_read) also tries to take
the emu_lock which causes a deadlock.
Remove the outer locking in the proc-functions (guarding only the
already safe fpga read) to prevent this deadlock.
[removed superfluous flags variables too -- tiwai]
Signed-off-by: Michael Gernoth <michael@gernoth.net> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: usb - Creative USB X-Fi Pro SB1095 volume knob support
Adds an entry for Creative USB X-Fi to the rc_config array in
mixer_quirks.c to allow use of volume knob on the device.
Adds support for newer X-Fi Pro card, known as "Model No. SB1095"
with USB ID "041e:3237"
ASoC: Don't try to register debugfs entries if the parent does not exist
If the registration of a debugfs directory fails this is treated as a
non-fatal error in ASoC and operation continues as normal. This means we
need to be careful and check if the parent debugfs directory exists if we
try to register a debugfs file or sub-directory. Otherwise we might end up
passing NULL for the parent and the file or directory will be registered in
the top-level debugfs directory.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Failing to register the debugfs entries is not fatal and will not affect
normal operation of the sound card. Don't abort the card registration if
soc_dpcm_debugfs_add() fails.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
RT286 can't do register reset. If the hardware power is still existing
in power off, rt286 will keep the register settings. So, we need to
restore the default register value in probe to make sure the cache value
is the same as the real register value.
Signed-off-by: Bard Liao <bardliao@realtek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Create the card debugfs directory at the begining of the initilization
rather then the end as various steps in the initilization sequence will try
to register files and sub-directories in the card directory.
Fixes: 4e2576bd36a1 ("ASoC: soc-core: initialize debugfs in snd_soc_instantiate_card()") Reported-by: Fabio Estevam <festevam@gmail.com> Reported-by: Nicolin Chen <nicoleotsuka@gmail.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ALSA: hda/realtek - Fix the regression by widget power-saving
While enabling the widget power-saving for ALC269 & co, the important
setup was forgotten -- stream_pm ops. Without this setup, the paths
for PCM won't be powered up at all.
Also, the power_filter callbacks used in ALC269 & co need to chain to
the default snd_hda_gen_path_power_filter().
Tested-by: Hui Wang <hui.wang@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Dan Carpenter [Thu, 9 Apr 2015 09:02:39 +0000 (12:02 +0300)]
ASoC: Intel: do cast earlier in sst_cdev_tstamp()
My static checker complains about these because it looks like the
multiply can overflow and then we cast to a larger data type. I don't
think this is a problem, but it's also harmless to do the cast earlier
so let's silence the static checker warning.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mark Brown <broonie@kernel.org>
ALSA: hda/generic - Don't override power_filter when power_save_node is set
Currently the generic parser sets codec->power_filter when
power_save_node flag is set. But this overrides the existing filter
that has been already set by the codec driver, thus it looses some
features. Instead, set the default power_filter only when it's not
set yet.
ALSA: hda/generic - Make snd_hda_gen_path_power_filter() always applicable
Add the check of power_save_node flag at the beginning of the function
so that it skips the rest if the flag isn't set. In this way, we can
call this function safely no matter whether the widget power-saving is
really used or not.
ALSA: hda/generic - Fix wrong initial power state for fixed pins
When the widget power-saving is enabled, the first automute hook
invocation checks through the whole pins and it also tries to
synchronize the power state. However, this results in a wrong state
because it calls unconditionally snd_hda_jack_detect_state().
This patch adds a check of jack detectability before the actual jack
detection call.
ALSA: hda/generic - Check power state cap at updating the widget power
The new widget power-saving tries to apply the power change no matter
whether the node has a power cap or not. It's bad (although most of
codecs chip just ignore it). Check the capability properly
beforehand.
ASoC: tegra_wm9712: Use card DAPM context to access widgets
The dapm field of the snd_soc_codec struct will eventually be removed
(replaced with the DAPM context from the component embedded inside the
CODEC). Replace its usage with the card's DAPM context. The idea is that
DAPM is hierarchical and with the card at the root it is possible to access
widgets from other contexts through the card context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: tegra_wm8903: Use card DAPM context to access widgets
The dapm field of the snd_soc_codec struct will eventually be removed
(replaced with the DAPM context from the component embedded inside the
CODEC). Replace its usage with the card's DAPM context. The idea is that
DAPM is hierarchical and with the card at the root it is possible to access
widgets from other contexts through the card context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: tegra_rt5677: Use card DAPM context to access widgets
The dapm field of the snd_soc_codec struct will eventually be removed
(replaced with the DAPM context from the component embedded inside the
CODEC). Replace its usage with the card's DAPM context. The idea is that
DAPM is hierarchical and with the card at the root it is possible to access
widgets from other contexts through the card context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ASoC: tegra_alc5632: Use card DAPM context to access widgets
The dapm field of the snd_soc_codec struct will eventually be removed
(replaced with the DAPM context from the component embedded inside the
CODEC). Replace its usage with the card's DAPM context. The idea is that
DAPM is hierarchical and with the card at the root it is possible to access
widgets from other contexts through the card context.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
ALSA: hda - Fix headphone pin config for Lifebook T731
Some BIOS version of Fujitsu Lifebook T731 seems to set up the
headphone pin (0x21) without the assoc number 0x0f while it's set only
to the output on the docking port (0x1a). With the recent commit
[03ad6a8c93b6: ALSA: hda - Fix "PCM" name being used on one DAC when
there are two DACs], this resulted in the weird mixer element
mapping where the headphone on the laptop is assigned as a shared
volume with the speaker and the docking port is assigned as an
individual headphone.
This patch improves the situation by correcting the headphone pin
config to the more appropriate value.
Reported-and-tested-by: Taylor Smock <smocktaylor@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Charles Keepax [Tue, 7 Apr 2015 11:55:10 +0000 (12:55 +0100)]
ASoC: wm8804: Enable runtime PM
Currently both the oscillator and the PLL are powered up in
set_bias_level. This can be problematic when using output clocks from
the wm8804 for other devices. The snd_soc_codec_set_pll API defines that
a clock should be available once the call returns, however, with all the
clocking controlled in set_bias_level this is not currently the case.
This patch enables pm_runtime for the wm8804, enabling both the
regulators and the oscillator when the chip resumes, and enabling the
PLL in the snd_soc_codec_set_pll call. Naturally the enabling the PLL
will also cause the chip to resume.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This change converts the driver to use DAPM to control the power for the
various blocks on the chip. As part of this change the existing controls
"TX Playback Switch" (controlled power for the SPDIF TX block) and "AIF
Playback Switch" (controlled power for the AIF block) are both removed,
as they are now redundant since the power state of those blocks is
controlled automatically by DAPM.
There are several benefits of this change, the most important of which
is this change adds support for powering down the SPDIF RX block. The RX
block will automatically assume control of the PLL on the chip when it
is receiving a signal, so leaving this enabled all the time as was
currently done in the driver can be problematic. An incoming SPDIF signal
that is not being used can completely destroy the clocking for an in use
TX signal. But this change ensures that the RX block will only be
powered when the user intends to be receiving data, thus avoiding this
issue.
Additional benefits include the chip being simpler to operate as the
power no longer needs to be manually controlled between use-cases and a
small power saving (although it is acknowledged that this is likely
unimportant in the typical use-cases for this chip).
Signed-off-by: Sapthagiri Baratam <sapthagiri.baratam@incubesol.com> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Caesar Wang [Wed, 8 Apr 2015 11:05:56 +0000 (19:05 +0800)]
ASoC: max98090: add shutdown callback for max98090
To fix pop noise when shutdown,the pop noise during shutdown
is the pmic cutoff power of codec without any notice.
Signed-off-by: jay.xu <xjq@rock-chips.com> Signed-off-by: zhengxing <zhengxing@rock-chips.com> Signed-off-by: Caesar Wang <wxt@rock-chips.com> Signed-off-by: Mark Brown <broonie@kernel.org>
ALSA: bebob: fix to processing in big-endian machine for sending cue
Some M-Audio devices require to receive bootup command just after
powering on, while codes in BeBoB driver doesn't work properly in
big-endian machine because the command should be aligned by
little-endian.
This commit fixes this bug. This fix should go to stable kernel.
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...
... so that user-space can know that the whole nodes have been
created. Unfortunately, this can't be implemented easily in race-free
way, so it's a kind of compromise.