History log of /linux-master/sound/hda/hdac_regmap.c
Revision Date Author Comments
# 99aae705 17-Jul-2023 Mark Brown <broonie@kernel.org>

ALSA: hda: Use regcache_reg_cached() rather than open coding

The HDA driver intentionally drops repeated writes to registers in some
circumstances, beyond the suppression of noop writes that regmap does in
regmap_update_bits(). It does this by checking if the register is cached
before doing a regmap_update_bits(), now we have an API for querying this
directly use it directly rather than trying a read in cache only mode
making the code a little clearer.

Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230717-regmap-cache-check-v1-3-73ef688afae3@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>


# 1f4a08fe 02-Jul-2023 Tuo Li <islituo@gmail.com>

ALSA: hda: fix a possible null-pointer dereference due to data race in snd_hdac_regmap_sync()

The variable codec->regmap is often protected by the lock
codec->regmap_lock when is accessed. However, it is accessed without
holding the lock when is accessed in snd_hdac_regmap_sync():

if (codec->regmap)

In my opinion, this may be a harmful race, because if codec->regmap is
set to NULL right after the condition is checked, a null-pointer
dereference can occur in the called function regcache_sync():

map->lock(map->lock_arg); --> Line 360 in drivers/base/regmap/regcache.c

To fix this possible null-pointer dereference caused by data race, the
mutex_lock coverage is extended to protect the if statement as well as the
function call to regcache_sync().

[ Note: the lack of the regmap_lock itself is harmless for the current
codec driver implementations, as snd_hdac_regmap_sync() is only for
PM runtime resume that is prohibited during the codec probe.
But the change makes the whole code more consistent, so it's merged
as is -- tiwai ]

Reported-by: BassCheck <bass@buaa.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
Link: https://lore.kernel.org/r/20230703031016.1184711-1-islituo@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 15253079 10-Jun-2023 Mark Brown <broonie@kernel.org>

ALSA: hda: Use maple tree register cache

HDA can only support single register read and write operations so does not
benefit from block writes. This means it gets no benefit from using the
rbtree register cache over the maple tree register cache so convert it to
use maple trees instead, it is more modern.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230609-alsa-hda-maple-v1-1-a2b725c8b8f5@kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 2f3092e7 16-May-2023 Claudiu Beznea <claudiu.beznea@microchip.com>

ASoC: do not include pm_runtime.h if not used

Do not include pm_runtime.h header in files where APIs exported by
pm_runtime.h are not used.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Acked-by: Jarkko Nikula <jarkko.nikula@bitmer.com> # for omap-mcbsp-st.c
Link: https://lore.kernel.org/r/20230517094903.2895238-2-claudiu.beznea@microchip.com
Signed-off-by: Mark Brown <broonie@kernel.org>


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


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


# 8e85def5 08-Jan-2020 Kai Vehmanen <kai.vehmanen@linux.intel.com>

ALSA: hda: enable regmap internal locking

This reverts commit 42ec336f1f9d ("ALSA: hda: Disable regmap
internal locking").

Without regmap locking, there is a race between snd_hda_codec_amp_init()
and PM callbacks issuing regcache_sync(). This was caught by
following kernel warning trace:

<4> [358.080081] WARNING: CPU: 2 PID: 4157 at drivers/base/regmap/regcache.c:498 regcache_cache_only+0xf5/0x130
[...]
<4> [358.080148] Call Trace:
<4> [358.080158] snd_hda_codec_amp_init+0x4e/0x100 [snd_hda_codec]
<4> [358.080169] snd_hda_codec_amp_init_stereo+0x40/0x80 [snd_hda_codec]

Suggested-by: Takashi Iwai <tiwai@suse.de>
BugLink: https://gitlab.freedesktop.org/drm/intel/issues/592
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/20200108180856.5194-1-kai.vehmanen@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1a0986c1 08-Jan-2020 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Fix a typo in comments

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


# 42ec336f 05-Nov-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Disable regmap internal locking

Since we apply the own mutex (bus->cmd_mutex) in HDA core side, the
internal locking in regmap is superfluous. This patch adds the flag
to indicate that.

Also, an infamous side-effect by this change is that it disables the
regmap debugfs, too, and this is seen rather good; the regmap debugfs
isn't quite useful for HD-audio as it provides the very sparse
registers and its debugfs access tends to lead to the way too high
resource usages or sometimes hang up. So it'd be rather safe to
disable it altogether.

Link: https://lore.kernel.org/r/2029139028.10333037.1572874551626.JavaMail.zimbra@redhat.com
Link: https://lore.kernel.org/r/20191105081806.4896-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# ddf7cb83 14-Aug-2019 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Unexport a few more stuff

Drop EXPORT_SYMBOL*() from a few more stuff in HD-audio core that
aren't used outside. Particular the unsol event handler can be
staticized now because the recent change removed all external
callers.

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


# 457c8996 19-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Add SPDX license identifier for missed files

Add SPDX license identifiers to all files which:

- Have no license information of any form

- Have EXPORT_.*_SYMBOL_GPL inside which was used in the
initial scan/conversion to ignore the file

These files fall under the project license, GPL v2 only. The resulting SPDX
license identifier is:

GPL-2.0-only

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 1c96a2f6 01-Sep-2018 David Frey <dpfrey@gmail.com>

regmap: split up regmap_config.use_single_rw

Split regmap_config.use_single_rw into use_single_read and
use_single_write. This change enables drivers of devices which only
support bulk operations in one direction to use the regmap_bulk_*()
functions for both directions and have their bulk operation split into
single operations only when necessary.

Update all struct regmap_config instances where use_single_rw==true to
instead set both use_single_read and use_single_write. No attempt was
made to evaluate whether it is possible to set only one of
use_single_read or use_single_write.

Signed-off-by: David Frey <dpfrey@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>


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


# 8198868f 17-Jun-2016 Jaroslav Kysela <perex@perex.cz>

ALSA: hdac_regmap - fix the register access for runtime PM

Call path:

1) snd_hdac_power_up_pm()
2) snd_hdac_power_up()
3) pm_runtime_get_sync()
4) __pm_runtime_resume()
5) rpm_resume()

The rpm_resume() returns 1 when the device is already active.
Because the return value is unmodified, the hdac regmap read/write
functions should allow this value for the retry I/O operation, too.

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


# 3194ed49 21-Apr-2016 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix possible race on regmap bypass flip

HD-audio driver uses regmap cache bypass feature for reading a raw
value without the cache. But this is racy since both the cached and
the uncached reads may occur concurrently. The former is done via the
normal control API access while the latter comes from the proc file
read.

Even though the regmap itself has the protection against the
concurrent accesses, the flag set/reset is done without the
protection, so it may lead to inconsistent state of bypass flag that
doesn't match with the current read and occasionally result in a
kernel WARNING like:
WARNING: CPU: 3 PID: 2731 at drivers/base/regmap/regcache.c:499 regcache_cache_only+0x78/0x93

One way to work around such a problem is to wrap with a mutex. But in
this case, the solution is simpler: for the uncached read, we just
skip the regmap and directly calls its accessor. The verb execution
there is protected by itself, so basically it's safe to call
individually.

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


# fc4f000b 04-Mar-2016 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix unexpected resume through regmap code path

HD-audio driver has a mechanism to trigger the runtime resume
automatically at accessing the verbs. This auto-resume, however,
causes the mutex deadlock when invoked from the regmap handler since
the regmap keeps the mutex while auto-resuming. For avoiding that,
there is some tricky check in the HDA regmap handler to return -EAGAIN
error to back-off when the codec is powered down. Then the caller of
regmap r/w will retry after properly turning on the codec power.

This works in most cases, but there seems a slight race between the
codec power check and the actual on-demand auto-resume trigger. This
resulted in the lockdep splat, eventually leading to a real deadlock.

This patch tries to address the race window by getting the runtime PM
refcount at the check time using pm_runtime_get_if_in_use(). With
this call, we can keep the power on only when the codec has been
already turned on, and back off if not.

For keeping the code consistency, the code touching the runtime PM is
stored in hdac_device.c although it's used only locally in
hdac_regmap.c.

Reported-by: Jiri Slaby <jslaby@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 78dd5e21 27-Oct-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add / fix kernel doc comments

Give some readable comment in kernel doc style for each exported
function, as I promised in the previous meetings. While we're at it,
fix the wrong comments, too.

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


# fbce23a0 17-Jul-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Check the return value from pm_runtime_get/put*()

This patch changes the return type of snd_hdac_power_up/down() and
variants to pass the error code from the underlying
pm_runtime_get/put() calls. Currently they are ignored, but in most
places, these should be handled properly.

As an example, the regmap handler is updated to check the return value
and accesses the register only when the wakeup succeeds.

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>


# 98a226ed 10-Jun-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Don't actually write registers for caps overwrites

Along with the transition to regmap for managing the cached parameter
reads, the caps overwrite was also moved to regmap cache. The cache
change itself works, but it still tries to write the non-existing verb
(the HDA parameter is read-only) wrongly. It's harmless in most
cases, but some chips are picky and may result in the codec
communication stall.

This patch avoids it just by adding the missing flag check in
reg_write ops.

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


# d6eb9e3e 13-Apr-2015 Mengdong Lin <mengdong.lin@intel.com>

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>


# 9efe2731 08-Apr-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Always allow access for POWER_STATE verbs via regmap

The hdac regmap code checks whether the codec is powered on while
accessing, but there must be an exception -- the verbs to control the
power state.

Currently HD-audio driver doesn't access them via regmap, so this
patch doesn't fix any current behavior, but it's just for future.

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>


# 9d82f927 27-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Set use_single_rw flag for regmap

HD-audio doesn't support the bulk access. Currently it works even
without this flag as implicitly assumed, but it's safer to set
explicitly.

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


# 8bc174e9 26-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Handle a few verbs as read-only

Although they can be written, handle a few verbs as read-only in
regmap interface: CONFIG_DEFAULT, CONV and CVT_CHAN_COUNT. These are
either updated in PCM or HDMI management code in a volatile manner, or
just needed only as parameter, thus they don't need to be written at
resume sync.

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


# 40ba66a7 13-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add cache support for COEF read/write

The 16bit COEF read/write is pretty standard for many codecs, and they
can be cached in most cases -- more importantly, they need to be
restored at resume. For making this easier, add the cache support to
regmap. If the codec driver wants to cache the COEF access, set
codec->cache_coef flag and issue AC_VERB_GET_PROC_COEF with the coef
index in LSB 8 bits.

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


# 33f81940 09-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Handle get/set power verb symmetrically via regmap

HD-audio has quite a few asymmetrical ways of accessing verbs, and one
of typical ones is GET/SET_POWER_STATE verbs. While it takes only the
power state for setting, it returns a combination of states for
getting. For making the state handling simpler, this patch adds a
code to translate the value returned from GET_POWER_STATE to return
only the actual state or -1 for error. In that way, the driver can
simplify the power state management.

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


# d313e0a8 04-Mar-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add a fake stereo amp register support

HD-audio spec is inconvenient regarding the handling of stereo volume
controls. It can set and get only single channel at once (although
there is a special option to set the same value to both channels).
This patch provides a fake pseudo-register via the regmap access so
that the stereo channels can be read and written by a single call.
It'd be useful, for example, for implementing DAPM widgets.

A stereo amp pseudo register consists of the encoding like the normal
amp verbs but it has both SET_LEFT (bit 13) and SET_RIGHT (bit 12)
bits set. The regmap reads and writes a 16bit value for this pseudo
register where the upper 8bit is for the right chanel and the lower
8bit for the left channel.

Note that the driver doesn't recognize conflicts when both stereo and
mono channel registers are mixed. Mixing them would certainly confuse
the operation. So, use carefully.

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


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

ALSA: hda - Allow driver to add vendor-specific verbs for regmap

Codecs may have own vendor-specific verbs, and we need to allow each
driver to give such verbs for cached accesses. Here a verb can be put
into a single array and looked through it at readable and writeable
callbacks.

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>


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