diff options
author | Takashi Iwai <tiwai@suse.de> | 2007-08-10 11:09:26 -0400 |
---|---|---|
committer | Jaroslav Kysela <perex@perex.cz> | 2007-10-16 09:58:43 -0400 |
commit | 82beb8fd365afe3891b277c46425083f13e23c56 (patch) | |
tree | a564d7228b59170aa490d4fc9284b5fa4442adb0 /sound/pci/hda/patch_sigmatel.c | |
parent | b3ac56364126f78cae94eb2a75b72d9ea85aca9d (diff) |
[ALSA] hda-codec - optimize resume using caches
So far, the driver looked the table of snd_kcontrol_new used for creating
mixer elements and forces to call each of its put callbacks in PM resume
code. This is too ugly and hackish.
Now, the resume is simplified using the codec amp and command register
caches. The driver simply restores the values that have been written
in the cache table. With this simplification, most codec support codes
don't require any special resume callback.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/hda/patch_sigmatel.c')
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 87a36e9d6546..145a5f3c0632 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -874,16 +874,16 @@ static void stac92xx_enable_gpio_mask(struct hda_codec *codec) | |||
874 | { | 874 | { |
875 | struct sigmatel_spec *spec = codec->spec; | 875 | struct sigmatel_spec *spec = codec->spec; |
876 | /* Configure GPIOx as output */ | 876 | /* Configure GPIOx as output */ |
877 | snd_hda_codec_write(codec, codec->afg, 0, | 877 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
878 | AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask); | 878 | AC_VERB_SET_GPIO_DIRECTION, spec->gpio_mask); |
879 | /* Configure GPIOx as CMOS */ | 879 | /* Configure GPIOx as CMOS */ |
880 | snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000); | 880 | snd_hda_codec_write_cache(codec, codec->afg, 0, 0x7e7, 0x00000000); |
881 | /* Assert GPIOx */ | 881 | /* Assert GPIOx */ |
882 | snd_hda_codec_write(codec, codec->afg, 0, | 882 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
883 | AC_VERB_SET_GPIO_DATA, spec->gpio_data); | 883 | AC_VERB_SET_GPIO_DATA, spec->gpio_data); |
884 | /* Enable GPIOx */ | 884 | /* Enable GPIOx */ |
885 | snd_hda_codec_write(codec, codec->afg, 0, | 885 | snd_hda_codec_write_cache(codec, codec->afg, 0, |
886 | AC_VERB_SET_GPIO_MASK, spec->gpio_mask); | 886 | AC_VERB_SET_GPIO_MASK, spec->gpio_mask); |
887 | } | 887 | } |
888 | 888 | ||
889 | /* | 889 | /* |
@@ -1082,7 +1082,8 @@ static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid) | |||
1082 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) | 1082 | static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type) |
1083 | 1083 | ||
1084 | { | 1084 | { |
1085 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | 1085 | snd_hda_codec_write_cache(codec, nid, 0, |
1086 | AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type); | ||
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info | 1089 | #define stac92xx_io_switch_info snd_ctl_boolean_mono_info |
@@ -1291,8 +1292,8 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, | |||
1291 | spec->multiout.num_dacs++; | 1292 | spec->multiout.num_dacs++; |
1292 | if (conn_len > 1) { | 1293 | if (conn_len > 1) { |
1293 | /* select this DAC in the pin's input mux */ | 1294 | /* select this DAC in the pin's input mux */ |
1294 | snd_hda_codec_write(codec, nid, 0, | 1295 | snd_hda_codec_write_cache(codec, nid, 0, |
1295 | AC_VERB_SET_CONNECT_SEL, j); | 1296 | AC_VERB_SET_CONNECT_SEL, j); |
1296 | 1297 | ||
1297 | } | 1298 | } |
1298 | } | 1299 | } |
@@ -1545,9 +1546,9 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const | |||
1545 | * NID lists. Hopefully this won't get confused. | 1546 | * NID lists. Hopefully this won't get confused. |
1546 | */ | 1547 | */ |
1547 | for (i = 0; i < spec->num_muxes; i++) { | 1548 | for (i = 0; i < spec->num_muxes; i++) { |
1548 | snd_hda_codec_write(codec, spec->mux_nids[i], 0, | 1549 | snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0, |
1549 | AC_VERB_SET_CONNECT_SEL, | 1550 | AC_VERB_SET_CONNECT_SEL, |
1550 | imux->items[0].index); | 1551 | imux->items[0].index); |
1551 | } | 1552 | } |
1552 | } | 1553 | } |
1553 | 1554 | ||
@@ -1879,7 +1880,7 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
1879 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) | 1880 | if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)) |
1880 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); | 1881 | pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN); |
1881 | 1882 | ||
1882 | snd_hda_codec_write(codec, nid, 0, | 1883 | snd_hda_codec_write_cache(codec, nid, 0, |
1883 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 1884 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
1884 | pin_ctl | flag); | 1885 | pin_ctl | flag); |
1885 | } | 1886 | } |
@@ -1889,7 +1890,7 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
1889 | { | 1890 | { |
1890 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, | 1891 | unsigned int pin_ctl = snd_hda_codec_read(codec, nid, |
1891 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); | 1892 | 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00); |
1892 | snd_hda_codec_write(codec, nid, 0, | 1893 | snd_hda_codec_write_cache(codec, nid, 0, |
1893 | AC_VERB_SET_PIN_WIDGET_CONTROL, | 1894 | AC_VERB_SET_PIN_WIDGET_CONTROL, |
1894 | pin_ctl & ~flag); | 1895 | pin_ctl & ~flag); |
1895 | } | 1896 | } |
@@ -1948,21 +1949,10 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | |||
1948 | #ifdef CONFIG_PM | 1949 | #ifdef CONFIG_PM |
1949 | static int stac92xx_resume(struct hda_codec *codec) | 1950 | static int stac92xx_resume(struct hda_codec *codec) |
1950 | { | 1951 | { |
1951 | struct sigmatel_spec *spec = codec->spec; | ||
1952 | int i; | ||
1953 | |||
1954 | stac92xx_set_config_regs(codec); | 1952 | stac92xx_set_config_regs(codec); |
1955 | if (spec->gpio_mask && spec->gpio_data) | ||
1956 | stac92xx_enable_gpio_mask(codec); | ||
1957 | stac92xx_init(codec); | 1953 | stac92xx_init(codec); |
1958 | snd_hda_resume_ctls(codec, spec->mixer); | 1954 | snd_hda_codec_resume_amp(codec); |
1959 | for (i = 0; i < spec->num_mixers; i++) | 1955 | snd_hda_codec_resume_cache(codec); |
1960 | snd_hda_resume_ctls(codec, spec->mixers[i]); | ||
1961 | if (spec->multiout.dig_out_nid) | ||
1962 | snd_hda_resume_spdif_out(codec); | ||
1963 | if (spec->dig_in_nid) | ||
1964 | snd_hda_resume_spdif_in(codec); | ||
1965 | |||
1966 | return 0; | 1956 | return 0; |
1967 | } | 1957 | } |
1968 | #endif | 1958 | #endif |