2019-05-19 20:08:55 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
/*
|
|
|
|
* Regmap support for HD-audio verbs
|
|
|
|
*
|
|
|
|
* A virtual register is translated to one or more hda verbs for write,
|
|
|
|
* vice versa for read.
|
|
|
|
*
|
|
|
|
* A few limitations:
|
|
|
|
* - Provided for not all verbs but only subset standard non-volatile verbs.
|
|
|
|
* - For reading, only AC_VERB_GET_* variants can be used.
|
|
|
|
* - For writing, mapped to the *corresponding* AC_VERB_SET_* variants,
|
|
|
|
* so can't handle asymmetric verbs for read and write
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <linux/export.h>
|
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/pm_runtime.h>
|
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/hdaudio.h>
|
|
|
|
#include <sound/hda_regmap.h>
|
2019-08-15 01:59:44 +08:00
|
|
|
#include "local.h"
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
|
2016-03-04 18:34:18 +08:00
|
|
|
static int codec_pm_lock(struct hdac_device *codec)
|
|
|
|
{
|
|
|
|
return snd_hdac_keep_power_up(codec);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void codec_pm_unlock(struct hdac_device *codec, int lock)
|
|
|
|
{
|
|
|
|
if (lock == 1)
|
|
|
|
snd_hdac_power_down_pm(codec);
|
|
|
|
}
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
|
|
|
|
#define get_verb(reg) (((reg) >> 8) & 0xfff)
|
|
|
|
|
|
|
|
static bool hda_volatile_reg(struct device *dev, unsigned int reg)
|
|
|
|
{
|
2015-03-13 22:56:25 +08:00
|
|
|
struct hdac_device *codec = dev_to_hdac_dev(dev);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
unsigned int verb = get_verb(reg);
|
|
|
|
|
|
|
|
switch (verb) {
|
|
|
|
case AC_VERB_GET_PROC_COEF:
|
2015-03-13 22:56:25 +08:00
|
|
|
return !codec->cache_coef;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
case AC_VERB_GET_COEF_INDEX:
|
|
|
|
case AC_VERB_GET_PROC_STATE:
|
|
|
|
case AC_VERB_GET_POWER_STATE:
|
|
|
|
case AC_VERB_GET_PIN_SENSE:
|
|
|
|
case AC_VERB_GET_HDMI_DIP_SIZE:
|
|
|
|
case AC_VERB_GET_HDMI_ELDD:
|
|
|
|
case AC_VERB_GET_HDMI_DIP_INDEX:
|
|
|
|
case AC_VERB_GET_HDMI_DIP_DATA:
|
|
|
|
case AC_VERB_GET_HDMI_DIP_XMIT:
|
|
|
|
case AC_VERB_GET_HDMI_CP_CTRL:
|
|
|
|
case AC_VERB_GET_HDMI_CHAN_SLOT:
|
|
|
|
case AC_VERB_GET_DEVICE_SEL:
|
|
|
|
case AC_VERB_GET_DEVICE_LIST: /* read-only volatile */
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool hda_writeable_reg(struct device *dev, unsigned int reg)
|
|
|
|
{
|
2015-02-26 15:54:56 +08:00
|
|
|
struct hdac_device *codec = dev_to_hdac_dev(dev);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
unsigned int verb = get_verb(reg);
|
2018-04-23 23:24:56 +08:00
|
|
|
const unsigned int *v;
|
2015-02-26 19:29:03 +08:00
|
|
|
int i;
|
|
|
|
|
2018-04-23 23:24:56 +08:00
|
|
|
snd_array_for_each(&codec->vendor_verbs, i, v) {
|
2015-02-26 19:29:03 +08:00
|
|
|
if (verb == *v)
|
|
|
|
return true;
|
|
|
|
}
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
|
2015-02-26 15:54:56 +08:00
|
|
|
if (codec->caps_overwriting)
|
|
|
|
return true;
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
switch (verb & 0xf00) {
|
|
|
|
case AC_VERB_GET_STREAM_FORMAT:
|
|
|
|
case AC_VERB_GET_AMP_GAIN_MUTE:
|
|
|
|
return true;
|
2015-03-13 22:56:25 +08:00
|
|
|
case AC_VERB_GET_PROC_COEF:
|
|
|
|
return codec->cache_coef;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
case 0xf00:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (verb) {
|
|
|
|
case AC_VERB_GET_CONNECT_SEL:
|
|
|
|
case AC_VERB_GET_SDI_SELECT:
|
|
|
|
case AC_VERB_GET_PIN_WIDGET_CONTROL:
|
|
|
|
case AC_VERB_GET_UNSOLICITED_RESPONSE: /* only as SET_UNSOLICITED_ENABLE */
|
|
|
|
case AC_VERB_GET_BEEP_CONTROL:
|
|
|
|
case AC_VERB_GET_EAPD_BTLENABLE:
|
|
|
|
case AC_VERB_GET_DIGI_CONVERT_1:
|
|
|
|
case AC_VERB_GET_DIGI_CONVERT_2: /* only for beep control */
|
|
|
|
case AC_VERB_GET_VOLUME_KNOB_CONTROL:
|
|
|
|
case AC_VERB_GET_GPIO_MASK:
|
|
|
|
case AC_VERB_GET_GPIO_DIRECTION:
|
|
|
|
case AC_VERB_GET_GPIO_DATA: /* not for volatile read */
|
|
|
|
case AC_VERB_GET_GPIO_WAKE_MASK:
|
|
|
|
case AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK:
|
|
|
|
case AC_VERB_GET_GPIO_STICKY_MASK:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool hda_readable_reg(struct device *dev, unsigned int reg)
|
|
|
|
{
|
2015-02-26 15:54:56 +08:00
|
|
|
struct hdac_device *codec = dev_to_hdac_dev(dev);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
unsigned int verb = get_verb(reg);
|
|
|
|
|
2015-02-26 15:54:56 +08:00
|
|
|
if (codec->caps_overwriting)
|
|
|
|
return true;
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
switch (verb) {
|
|
|
|
case AC_VERB_PARAMETERS:
|
|
|
|
case AC_VERB_GET_CONNECT_LIST:
|
|
|
|
case AC_VERB_GET_SUBSYSTEM_ID:
|
|
|
|
return true;
|
2015-03-26 21:18:34 +08:00
|
|
|
/* below are basically writable, but disabled for reducing unnecessary
|
|
|
|
* writes at sync
|
|
|
|
*/
|
|
|
|
case AC_VERB_GET_CONFIG_DEFAULT: /* usually just read */
|
|
|
|
case AC_VERB_GET_CONV: /* managed in PCM code */
|
|
|
|
case AC_VERB_GET_CVT_CHAN_COUNT: /* managed in HDMI CA code */
|
|
|
|
return true;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return hda_writeable_reg(dev, reg);
|
|
|
|
}
|
|
|
|
|
2015-03-05 03:43:20 +08:00
|
|
|
/*
|
|
|
|
* Stereo amp pseudo register:
|
|
|
|
* for making easier to handle the stereo volume control, we provide a
|
|
|
|
* fake register to deal both left and right channels by a single
|
|
|
|
* (pseudo) register access. A verb consisting of SET_AMP_GAIN with
|
|
|
|
* *both* SET_LEFT and SET_RIGHT bits takes a 16bit value, the lower 8bit
|
|
|
|
* for the left and the upper 8bit for the right channel.
|
|
|
|
*/
|
|
|
|
static bool is_stereo_amp_verb(unsigned int reg)
|
|
|
|
{
|
|
|
|
if (((reg >> 8) & 0x700) != AC_VERB_SET_AMP_GAIN_MUTE)
|
|
|
|
return false;
|
|
|
|
return (reg & (AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT)) ==
|
|
|
|
(AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read a pseudo stereo amp register (16bit left+right) */
|
|
|
|
static int hda_reg_read_stereo_amp(struct hdac_device *codec,
|
|
|
|
unsigned int reg, unsigned int *val)
|
|
|
|
{
|
|
|
|
unsigned int left, right;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
reg &= ~(AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT);
|
|
|
|
err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_LEFT, 0, &left);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
err = snd_hdac_exec_verb(codec, reg | AC_AMP_GET_RIGHT, 0, &right);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
*val = left | (right << 8);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write a pseudo stereo amp register (16bit left+right) */
|
|
|
|
static int hda_reg_write_stereo_amp(struct hdac_device *codec,
|
|
|
|
unsigned int reg, unsigned int val)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
unsigned int verb, left, right;
|
|
|
|
|
|
|
|
verb = AC_VERB_SET_AMP_GAIN_MUTE << 8;
|
|
|
|
if (reg & AC_AMP_GET_OUTPUT)
|
|
|
|
verb |= AC_AMP_SET_OUTPUT;
|
|
|
|
else
|
|
|
|
verb |= AC_AMP_SET_INPUT | ((reg & 0xf) << 8);
|
|
|
|
reg = (reg & ~0xfffff) | verb;
|
|
|
|
|
|
|
|
left = val & 0xff;
|
|
|
|
right = (val >> 8) & 0xff;
|
|
|
|
if (left == right) {
|
|
|
|
reg |= AC_AMP_SET_LEFT | AC_AMP_SET_RIGHT;
|
|
|
|
return snd_hdac_exec_verb(codec, reg | left, 0, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_LEFT | left, 0, NULL);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
err = snd_hdac_exec_verb(codec, reg | AC_AMP_SET_RIGHT | right, 0, NULL);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-13 22:56:25 +08:00
|
|
|
/* read a pseudo coef register (16bit) */
|
|
|
|
static int hda_reg_read_coef(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int *val)
|
|
|
|
{
|
|
|
|
unsigned int verb;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!codec->cache_coef)
|
|
|
|
return -EINVAL;
|
|
|
|
/* LSB 8bit = coef index */
|
|
|
|
verb = (reg & ~0xfff00) | (AC_VERB_SET_COEF_INDEX << 8);
|
|
|
|
err = snd_hdac_exec_verb(codec, verb, 0, NULL);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
verb = (reg & ~0xfffff) | (AC_VERB_GET_COEF_INDEX << 8);
|
|
|
|
return snd_hdac_exec_verb(codec, verb, 0, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write a pseudo coef register (16bit) */
|
|
|
|
static int hda_reg_write_coef(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int val)
|
|
|
|
{
|
|
|
|
unsigned int verb;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!codec->cache_coef)
|
|
|
|
return -EINVAL;
|
|
|
|
/* LSB 8bit = coef index */
|
|
|
|
verb = (reg & ~0xfff00) | (AC_VERB_SET_COEF_INDEX << 8);
|
|
|
|
err = snd_hdac_exec_verb(codec, verb, 0, NULL);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
verb = (reg & ~0xfffff) | (AC_VERB_GET_COEF_INDEX << 8) |
|
|
|
|
(val & 0xffff);
|
|
|
|
return snd_hdac_exec_verb(codec, verb, 0, NULL);
|
|
|
|
}
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
static int hda_reg_read(void *context, unsigned int reg, unsigned int *val)
|
|
|
|
{
|
|
|
|
struct hdac_device *codec = context;
|
2015-03-13 22:56:25 +08:00
|
|
|
int verb = get_verb(reg);
|
2015-03-10 05:19:47 +08:00
|
|
|
int err;
|
2016-03-04 18:34:18 +08:00
|
|
|
int pm_lock = 0;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
|
2016-03-04 18:34:18 +08:00
|
|
|
if (verb != AC_VERB_GET_POWER_STATE) {
|
|
|
|
pm_lock = codec_pm_lock(codec);
|
|
|
|
if (pm_lock < 0)
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
reg |= (codec->addr << 28);
|
2016-03-04 18:34:18 +08:00
|
|
|
if (is_stereo_amp_verb(reg)) {
|
|
|
|
err = hda_reg_read_stereo_amp(codec, reg, val);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (verb == AC_VERB_GET_PROC_COEF) {
|
|
|
|
err = hda_reg_read_coef(codec, reg, val);
|
|
|
|
goto out;
|
|
|
|
}
|
2015-06-11 16:51:28 +08:00
|
|
|
if ((verb & 0x700) == AC_VERB_SET_AMP_GAIN_MUTE)
|
|
|
|
reg &= ~AC_AMP_FAKE_MUTE;
|
|
|
|
|
2015-03-10 05:19:47 +08:00
|
|
|
err = snd_hdac_exec_verb(codec, reg, 0, val);
|
|
|
|
if (err < 0)
|
2016-03-04 18:34:18 +08:00
|
|
|
goto out;
|
2015-03-10 05:19:47 +08:00
|
|
|
/* special handling for asymmetric reads */
|
2015-03-13 22:56:25 +08:00
|
|
|
if (verb == AC_VERB_GET_POWER_STATE) {
|
2015-03-10 05:19:47 +08:00
|
|
|
if (*val & AC_PWRST_ERROR)
|
|
|
|
*val = -1;
|
|
|
|
else /* take only the actual state */
|
|
|
|
*val = (*val >> 4) & 0x0f;
|
|
|
|
}
|
2016-03-04 18:34:18 +08:00
|
|
|
out:
|
|
|
|
codec_pm_unlock(codec, pm_lock);
|
|
|
|
return err;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int hda_reg_write(void *context, unsigned int reg, unsigned int val)
|
|
|
|
{
|
|
|
|
struct hdac_device *codec = context;
|
|
|
|
unsigned int verb;
|
|
|
|
int i, bytes, err;
|
2016-03-04 18:34:18 +08:00
|
|
|
int pm_lock = 0;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
|
2015-06-10 16:27:00 +08:00
|
|
|
if (codec->caps_overwriting)
|
|
|
|
return 0;
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
reg &= ~0x00080000U; /* drop GET bit */
|
|
|
|
reg |= (codec->addr << 28);
|
2015-04-09 13:58:46 +08:00
|
|
|
verb = get_verb(reg);
|
|
|
|
|
2016-03-04 18:34:18 +08:00
|
|
|
if (verb != AC_VERB_SET_POWER_STATE) {
|
|
|
|
pm_lock = codec_pm_lock(codec);
|
|
|
|
if (pm_lock < 0)
|
|
|
|
return codec->lazy_cache ? 0 : -EAGAIN;
|
|
|
|
}
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
|
2016-03-04 18:34:18 +08:00
|
|
|
if (is_stereo_amp_verb(reg)) {
|
|
|
|
err = hda_reg_write_stereo_amp(codec, reg, val);
|
|
|
|
goto out;
|
|
|
|
}
|
2015-03-05 03:43:20 +08:00
|
|
|
|
2016-03-04 18:34:18 +08:00
|
|
|
if (verb == AC_VERB_SET_PROC_COEF) {
|
|
|
|
err = hda_reg_write_coef(codec, reg, val);
|
|
|
|
goto out;
|
|
|
|
}
|
2015-03-13 22:56:25 +08:00
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
switch (verb & 0xf00) {
|
|
|
|
case AC_VERB_SET_AMP_GAIN_MUTE:
|
2015-06-11 16:51:28 +08:00
|
|
|
if ((reg & AC_AMP_FAKE_MUTE) && (val & AC_AMP_MUTE))
|
|
|
|
val = 0;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
verb = AC_VERB_SET_AMP_GAIN_MUTE;
|
|
|
|
if (reg & AC_AMP_GET_LEFT)
|
|
|
|
verb |= AC_AMP_SET_LEFT >> 8;
|
|
|
|
else
|
|
|
|
verb |= AC_AMP_SET_RIGHT >> 8;
|
|
|
|
if (reg & AC_AMP_GET_OUTPUT) {
|
|
|
|
verb |= AC_AMP_SET_OUTPUT >> 8;
|
|
|
|
} else {
|
|
|
|
verb |= AC_AMP_SET_INPUT >> 8;
|
|
|
|
verb |= reg & 0xf;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (verb) {
|
|
|
|
case AC_VERB_SET_DIGI_CONVERT_1:
|
|
|
|
bytes = 2;
|
|
|
|
break;
|
|
|
|
case AC_VERB_SET_CONFIG_DEFAULT_BYTES_0:
|
|
|
|
bytes = 4;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bytes = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < bytes; i++) {
|
|
|
|
reg &= ~0xfffff;
|
|
|
|
reg |= (verb + i) << 8 | ((val >> (8 * i)) & 0xff);
|
|
|
|
err = snd_hdac_exec_verb(codec, reg, 0, NULL);
|
|
|
|
if (err < 0)
|
2016-03-04 18:34:18 +08:00
|
|
|
goto out;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
2016-03-04 18:34:18 +08:00
|
|
|
out:
|
|
|
|
codec_pm_unlock(codec, pm_lock);
|
|
|
|
return err;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct regmap_config hda_regmap_cfg = {
|
|
|
|
.name = "hdaudio",
|
|
|
|
.reg_bits = 32,
|
|
|
|
.val_bits = 32,
|
|
|
|
.max_register = 0xfffffff,
|
|
|
|
.writeable_reg = hda_writeable_reg,
|
|
|
|
.readable_reg = hda_readable_reg,
|
|
|
|
.volatile_reg = hda_volatile_reg,
|
|
|
|
.cache_type = REGCACHE_RBTREE,
|
|
|
|
.reg_read = hda_reg_read,
|
|
|
|
.reg_write = hda_reg_write,
|
2018-09-02 00:50:41 +08:00
|
|
|
.use_single_read = true,
|
|
|
|
.use_single_write = true,
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
};
|
|
|
|
|
2015-10-28 19:26:48 +08:00
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_init - Initialize regmap for HDA register accesses
|
|
|
|
* @codec: the codec object
|
|
|
|
*
|
|
|
|
* Returns zero for success or a negative error code.
|
|
|
|
*/
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
int snd_hdac_regmap_init(struct hdac_device *codec)
|
|
|
|
{
|
|
|
|
struct regmap *regmap;
|
|
|
|
|
|
|
|
regmap = regmap_init(&codec->dev, NULL, codec, &hda_regmap_cfg);
|
|
|
|
if (IS_ERR(regmap))
|
|
|
|
return PTR_ERR(regmap);
|
|
|
|
codec->regmap = regmap;
|
2015-02-26 19:29:03 +08:00
|
|
|
snd_array_init(&codec->vendor_verbs, sizeof(unsigned int), 8);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_init);
|
|
|
|
|
2015-10-28 19:26:48 +08:00
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_init - Release the regmap from HDA codec
|
|
|
|
* @codec: the codec object
|
|
|
|
*/
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
void snd_hdac_regmap_exit(struct hdac_device *codec)
|
|
|
|
{
|
|
|
|
if (codec->regmap) {
|
|
|
|
regmap_exit(codec->regmap);
|
|
|
|
codec->regmap = NULL;
|
2015-02-26 19:29:03 +08:00
|
|
|
snd_array_free(&codec->vendor_verbs);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_exit);
|
|
|
|
|
2015-02-26 19:29:03 +08:00
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_add_vendor_verb - add a vendor-specific verb to regmap
|
|
|
|
* @codec: the codec object
|
|
|
|
* @verb: verb to allow accessing via regmap
|
|
|
|
*
|
|
|
|
* Returns zero for success or a negative error code.
|
|
|
|
*/
|
|
|
|
int snd_hdac_regmap_add_vendor_verb(struct hdac_device *codec,
|
|
|
|
unsigned int verb)
|
|
|
|
{
|
|
|
|
unsigned int *p = snd_array_new(&codec->vendor_verbs);
|
|
|
|
|
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
2015-04-14 11:25:36 +08:00
|
|
|
*p = verb | 0x800; /* set GET bit */
|
2015-02-26 19:29:03 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_add_vendor_verb);
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
/*
|
|
|
|
* helper functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* write a pseudo-register value (w/o power sequence) */
|
|
|
|
static int reg_raw_write(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int val)
|
|
|
|
{
|
2024-06-11 20:26:44 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&codec->regmap_lock);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
if (!codec->regmap)
|
2024-06-11 20:26:44 +08:00
|
|
|
err = hda_reg_write(codec, reg, val);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
else
|
2024-06-11 20:26:44 +08:00
|
|
|
err = regmap_write(codec->regmap, reg, val);
|
|
|
|
mutex_unlock(&codec->regmap_lock);
|
|
|
|
return err;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
2024-06-11 20:26:44 +08:00
|
|
|
/* a helper macro to call @func_call; retry with power-up if failed */
|
|
|
|
#define CALL_RAW_FUNC(codec, func_call) \
|
|
|
|
({ \
|
|
|
|
int _err = func_call; \
|
|
|
|
if (_err == -EAGAIN) { \
|
|
|
|
_err = snd_hdac_power_up_pm(codec); \
|
|
|
|
if (_err >= 0) \
|
|
|
|
_err = func_call; \
|
|
|
|
snd_hdac_power_down_pm(codec); \
|
|
|
|
} \
|
|
|
|
_err;})
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_write_raw - write a pseudo register with power mgmt
|
|
|
|
* @codec: the codec object
|
|
|
|
* @reg: pseudo register
|
|
|
|
* @val: value to write
|
|
|
|
*
|
|
|
|
* Returns zero if successful or a negative error code.
|
|
|
|
*/
|
|
|
|
int snd_hdac_regmap_write_raw(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int val)
|
|
|
|
{
|
2024-06-11 20:26:44 +08:00
|
|
|
return CALL_RAW_FUNC(codec, reg_raw_write(codec, reg, val));
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_write_raw);
|
|
|
|
|
|
|
|
static int reg_raw_read(struct hdac_device *codec, unsigned int reg,
|
2016-04-21 23:49:11 +08:00
|
|
|
unsigned int *val, bool uncached)
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
{
|
2024-06-11 20:26:44 +08:00
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&codec->regmap_lock);
|
2016-04-21 23:49:11 +08:00
|
|
|
if (uncached || !codec->regmap)
|
2024-06-11 20:26:44 +08:00
|
|
|
err = hda_reg_read(codec, reg, val);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
else
|
2024-06-11 20:26:44 +08:00
|
|
|
err = regmap_read(codec->regmap, reg, val);
|
|
|
|
mutex_unlock(&codec->regmap_lock);
|
|
|
|
return err;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
|
2016-04-21 23:49:11 +08:00
|
|
|
static int __snd_hdac_regmap_read_raw(struct hdac_device *codec,
|
|
|
|
unsigned int reg, unsigned int *val,
|
|
|
|
bool uncached)
|
|
|
|
{
|
2024-06-11 20:26:44 +08:00
|
|
|
return CALL_RAW_FUNC(codec, reg_raw_read(codec, reg, val, uncached));
|
2016-04-21 23:49:11 +08:00
|
|
|
}
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_read_raw - read a pseudo register with power mgmt
|
|
|
|
* @codec: the codec object
|
|
|
|
* @reg: pseudo register
|
|
|
|
* @val: pointer to store the read value
|
|
|
|
*
|
|
|
|
* Returns zero if successful or a negative error code.
|
|
|
|
*/
|
|
|
|
int snd_hdac_regmap_read_raw(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int *val)
|
|
|
|
{
|
2016-04-21 23:49:11 +08:00
|
|
|
return __snd_hdac_regmap_read_raw(codec, reg, val, false);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_read_raw);
|
|
|
|
|
2016-04-21 23:49:11 +08:00
|
|
|
/* Works like snd_hdac_regmap_read_raw(), but this doesn't read from the
|
|
|
|
* cache but always via hda verbs.
|
|
|
|
*/
|
|
|
|
int snd_hdac_regmap_read_raw_uncached(struct hdac_device *codec,
|
|
|
|
unsigned int reg, unsigned int *val)
|
|
|
|
{
|
|
|
|
return __snd_hdac_regmap_read_raw(codec, reg, val, true);
|
|
|
|
}
|
|
|
|
|
2024-06-11 20:26:44 +08:00
|
|
|
static int reg_raw_update(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int mask, unsigned int val)
|
|
|
|
{
|
|
|
|
unsigned int orig;
|
|
|
|
bool change;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
mutex_lock(&codec->regmap_lock);
|
|
|
|
if (codec->regmap) {
|
|
|
|
err = regmap_update_bits_check(codec->regmap, reg, mask, val,
|
|
|
|
&change);
|
|
|
|
if (!err)
|
|
|
|
err = change ? 1 : 0;
|
|
|
|
} else {
|
|
|
|
err = hda_reg_read(codec, reg, &orig);
|
|
|
|
if (!err) {
|
|
|
|
val &= mask;
|
|
|
|
val |= orig & ~mask;
|
|
|
|
if (val != orig) {
|
|
|
|
err = hda_reg_write(codec, reg, val);
|
|
|
|
if (!err)
|
|
|
|
err = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_unlock(&codec->regmap_lock);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_update_raw - update a pseudo register with power mgmt
|
|
|
|
* @codec: the codec object
|
|
|
|
* @reg: pseudo register
|
|
|
|
* @mask: bit mask to udpate
|
|
|
|
* @val: value to update
|
|
|
|
*
|
|
|
|
* Returns zero if successful or a negative error code.
|
|
|
|
*/
|
|
|
|
int snd_hdac_regmap_update_raw(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int mask, unsigned int val)
|
2024-06-11 20:26:44 +08:00
|
|
|
{
|
|
|
|
return CALL_RAW_FUNC(codec, reg_raw_update(codec, reg, mask, val));
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw);
|
|
|
|
|
|
|
|
static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int mask, unsigned int val)
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
{
|
|
|
|
unsigned int orig;
|
|
|
|
int err;
|
|
|
|
|
2024-06-11 20:26:44 +08:00
|
|
|
if (!codec->regmap)
|
|
|
|
return reg_raw_update(codec, reg, mask, val);
|
|
|
|
|
|
|
|
mutex_lock(&codec->regmap_lock);
|
|
|
|
regcache_cache_only(codec->regmap, true);
|
|
|
|
err = regmap_read(codec->regmap, reg, &orig);
|
|
|
|
regcache_cache_only(codec->regmap, false);
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
if (err < 0)
|
2024-06-11 20:26:44 +08:00
|
|
|
err = regmap_update_bits(codec->regmap, reg, mask, val);
|
|
|
|
mutex_unlock(&codec->regmap_lock);
|
|
|
|
return err;
|
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>
2015-02-25 21:42:38 +08:00
|
|
|
}
|
2024-06-11 20:26:44 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_update_raw_once - initialize the register value only once
|
|
|
|
* @codec: the codec object
|
|
|
|
* @reg: pseudo register
|
|
|
|
* @mask: bit mask to update
|
|
|
|
* @val: value to update
|
|
|
|
*
|
|
|
|
* Performs the update of the register bits only once when the register
|
|
|
|
* hasn't been initialized yet. Used in HD-audio legacy driver.
|
|
|
|
* Returns zero if successful or a negative error code
|
|
|
|
*/
|
|
|
|
int snd_hdac_regmap_update_raw_once(struct hdac_device *codec, unsigned int reg,
|
|
|
|
unsigned int mask, unsigned int val)
|
|
|
|
{
|
|
|
|
return CALL_RAW_FUNC(codec, reg_raw_update_once(codec, reg, mask, val));
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw_once);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* snd_hdac_regmap_sync - sync out the cached values for PM resume
|
|
|
|
* @codec: the codec object
|
|
|
|
*/
|
|
|
|
void snd_hdac_regmap_sync(struct hdac_device *codec)
|
|
|
|
{
|
|
|
|
if (codec->regmap) {
|
|
|
|
mutex_lock(&codec->regmap_lock);
|
|
|
|
regcache_sync(codec->regmap);
|
|
|
|
mutex_unlock(&codec->regmap_lock);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(snd_hdac_regmap_sync);
|