[PATCH 24/25] UBUNTU hardy-lum lpia branch sync
Steve Conklin
sconklin at canonical.com
Tue Mar 10 19:37:48 UTC 2009
>From 964b9e7316c7d96dcd9050f96bac6749bb2e34f7 Mon Sep 17 00:00:00 2001
From: Michael Frey (Senior Manager, MID) <michael.frey at canonical.com>
Date: Tue, 10 Mar 2009 10:13:07 -0400
Subject: [PATCH] Added functions to save / restore codec pin configuration over suspend / resume
(LP# 250627)
Signed-off-by: Michael Frey (Senior Manager, MID) <michael.frey at canonical.com>
---
ubuntu/sound/alsa-kernel/pci/hda/patch_realtek.c | 69 ++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/ubuntu/sound/alsa-kernel/pci/hda/patch_realtek.c b/ubuntu/sound/alsa-kernel/pci/hda/patch_realtek.c
index 77e5479..69747d5 100644
--- a/ubuntu/sound/alsa-kernel/pci/hda/patch_realtek.c
+++ b/ubuntu/sound/alsa-kernel/pci/hda/patch_realtek.c
@@ -286,6 +286,13 @@ struct alc_spec {
hda_nid_t pll_nid;
unsigned int pll_coef_idx, pll_coef_bit;
+#ifdef SND_HDA_NEEDS_RESUME
+#define ALC_MAX_PINS 16
+ unsigned int num_pins;
+ hda_nid_t pin_nids[ALC_MAX_PINS];
+ unsigned int pin_cfgs[ALC_MAX_PINS];
+#endif
+
};
/*
@@ -2638,6 +2645,64 @@ static void alc_free(struct hda_codec *codec)
kfree(spec);
}
+#ifdef SND_HDA_NEEDS_RESUME
+static void store_pin_configs(struct hda_codec *codec)
+{
+ struct alc_spec *spec = codec->spec;
+ hda_nid_t nid, end_nid;
+
+ end_nid = codec->start_nid + codec->num_nodes;
+ for (nid = codec->start_nid; nid < end_nid; nid++) {
+ unsigned int wid_caps = get_wcaps(codec, nid);
+ unsigned int wid_type =
+ (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
+ if (wid_type != AC_WID_PIN)
+ continue;
+ if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids))
+ break;
+ spec->pin_nids[spec->num_pins] = nid;
+ spec->pin_cfgs[spec->num_pins] =
+ snd_hda_codec_read(codec, nid, 0,
+ AC_VERB_GET_CONFIG_DEFAULT, 0);
+ spec->num_pins++;
+ }
+}
+
+static void resume_pin_configs(struct hda_codec *codec)
+{
+ struct alc_spec *spec = codec->spec;
+ int i;
+
+ for (i = 0; i < spec->num_pins; i++) {
+ hda_nid_t pin_nid = spec->pin_nids[i];
+ unsigned int pin_config = spec->pin_cfgs[i];
+ snd_hda_codec_write(codec, pin_nid, 0,
+ AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
+ pin_config & 0x000000ff);
+ snd_hda_codec_write(codec, pin_nid, 0,
+ AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
+ (pin_config & 0x0000ff00) >> 8);
+ snd_hda_codec_write(codec, pin_nid, 0,
+ AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
+ (pin_config & 0x00ff0000) >> 16);
+ snd_hda_codec_write(codec, pin_nid, 0,
+ AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
+ pin_config >> 24);
+ }
+}
+
+static int alc_resume(struct hda_codec *codec)
+{
+ resume_pin_configs(codec);
+ codec->patch_ops.init(codec);
+ snd_hda_codec_resume_amp(codec);
+ snd_hda_codec_resume_cache(codec);
+ return 0;
+}
+#else
+#define store_pin_configs(codec)
+#endif
+
/*
*/
static struct hda_codec_ops alc_patch_ops = {
@@ -2646,6 +2711,9 @@ static struct hda_codec_ops alc_patch_ops = {
.init = alc_init,
.free = alc_free,
.unsol_event = alc_unsol_event,
+#ifdef SND_HDA_NEEDS_RESUME
+ .resume = alc_resume,
+#endif
#ifdef CONFIG_SND_HDA_POWER_SAVE
.check_power_status = alc_check_power_status,
#endif
@@ -10853,6 +10921,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
if (err < 0)
return err;
+ store_pin_configs(codec);
return 1;
}
--
1.5.6.3
More information about the kernel-team
mailing list