summaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-25 14:42:38 +0100
committerTakashi Iwai <tiwai@suse.de>2015-03-23 13:19:36 +0100
commit4d75faa0448a6bb2fd6d56051a3675a3937cbada (patch)
tree3cb2a3fbf131cf7d8eb8eba866490548d9ea6c1a /sound/pci
parent71fc4c7ef5ef2d0ddd22f0545ede4c135b554b84 (diff)
downloadlinux-4d75faa0448a6bb2fd6d56051a3675a3937cbada.tar.bz2
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>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_bind.c4
-rw-r--r--sound/pci/hda/hda_codec.c1
-rw-r--r--sound/pci/hda/hda_codec.h1
3 files changed, 6 insertions, 0 deletions
diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c
index 7b269c3237e3..00aa31c5f08e 100644
--- a/sound/pci/hda/hda_bind.c
+++ b/sound/pci/hda/hda_bind.c
@@ -75,6 +75,9 @@ static int hda_codec_driver_probe(struct device *dev)
err = codec_refresh_name(codec, codec->preset->name);
if (err < 0)
goto error;
+ err = snd_hdac_regmap_init(&codec->core);
+ if (err < 0)
+ goto error;
if (!try_module_get(owner)) {
err = -EINVAL;
@@ -98,6 +101,7 @@ static int hda_codec_driver_probe(struct device *dev)
snd_hda_codec_register(codec);
}
+ codec->core.lazy_cache = true;
return 0;
error_module:
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 10e257ff9084..8eb42f4226ff 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -945,6 +945,7 @@ void snd_hda_codec_cleanup_for_unbind(struct hda_codec *codec)
snd_array_free(&codec->mixers);
snd_array_free(&codec->nids);
remove_conn_list(codec);
+ snd_hdac_regmap_exit(&codec->core);
}
static unsigned int hda_set_power_state(struct hda_codec *codec,
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 3068163b3db2..0f5749ca1600 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -28,6 +28,7 @@
#include <sound/hwdep.h>
#include <sound/hdaudio.h>
#include <sound/hda_verbs.h>
+#include <sound/hda_regmap.h>
/*
* Structures