diff options
author | Takashi Iwai <tiwai@suse.de> | 2009-02-23 08:15:47 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-02-23 08:15:47 -0500 |
commit | 209b14033652f0509912da97fb4a5c8001e64ec0 (patch) | |
tree | 4b9f6e00815932c65dacd1e0148fe0538bb2323d /sound | |
parent | 13c989beba166b470b1e6b0fa117148bcbfa3dd1 (diff) | |
parent | 39c2871eeaeeddcbecee29ec905ec528a057ca52 (diff) |
Merge branch 'test/hda-pincfg' into topic/hda
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 162 | ||||
-rw-r--r-- | sound/pci/hda/hda_codec.h | 15 | ||||
-rw-r--r-- | sound/pci/hda/hda_generic.c | 2 | ||||
-rw-r--r-- | sound/pci/hda/hda_hwdep.c | 66 | ||||
-rw-r--r-- | sound/pci/hda/patch_analog.c | 3 | ||||
-rw-r--r-- | sound/pci/hda/patch_cmedia.c | 12 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 78 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 255 | ||||
-rw-r--r-- | sound/pci/hda/patch_via.c | 7 |
9 files changed, 310 insertions, 290 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 98884bc8f35f..a13480fa8e74 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -682,11 +682,140 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node) | |||
682 | return 0; | 682 | return 0; |
683 | } | 683 | } |
684 | 684 | ||
685 | /* read all pin default configurations and save codec->init_pins */ | ||
686 | static int read_pin_defaults(struct hda_codec *codec) | ||
687 | { | ||
688 | int i; | ||
689 | hda_nid_t nid = codec->start_nid; | ||
690 | |||
691 | for (i = 0; i < codec->num_nodes; i++, nid++) { | ||
692 | struct hda_pincfg *pin; | ||
693 | unsigned int wcaps = get_wcaps(codec, nid); | ||
694 | unsigned int wid_type = (wcaps & AC_WCAP_TYPE) >> | ||
695 | AC_WCAP_TYPE_SHIFT; | ||
696 | if (wid_type != AC_WID_PIN) | ||
697 | continue; | ||
698 | pin = snd_array_new(&codec->init_pins); | ||
699 | if (!pin) | ||
700 | return -ENOMEM; | ||
701 | pin->nid = nid; | ||
702 | pin->cfg = snd_hda_codec_read(codec, nid, 0, | ||
703 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
704 | } | ||
705 | return 0; | ||
706 | } | ||
707 | |||
708 | /* look up the given pin config list and return the item matching with NID */ | ||
709 | static struct hda_pincfg *look_up_pincfg(struct hda_codec *codec, | ||
710 | struct snd_array *array, | ||
711 | hda_nid_t nid) | ||
712 | { | ||
713 | int i; | ||
714 | for (i = 0; i < array->used; i++) { | ||
715 | struct hda_pincfg *pin = snd_array_elem(array, i); | ||
716 | if (pin->nid == nid) | ||
717 | return pin; | ||
718 | } | ||
719 | return NULL; | ||
720 | } | ||
721 | |||
722 | /* write a config value for the given NID */ | ||
723 | static void set_pincfg(struct hda_codec *codec, hda_nid_t nid, | ||
724 | unsigned int cfg) | ||
725 | { | ||
726 | int i; | ||
727 | for (i = 0; i < 4; i++) { | ||
728 | snd_hda_codec_write(codec, nid, 0, | ||
729 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | ||
730 | cfg & 0xff); | ||
731 | cfg >>= 8; | ||
732 | } | ||
733 | } | ||
734 | |||
735 | /* set the current pin config value for the given NID. | ||
736 | * the value is cached, and read via snd_hda_codec_get_pincfg() | ||
737 | */ | ||
738 | int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, | ||
739 | hda_nid_t nid, unsigned int cfg) | ||
740 | { | ||
741 | struct hda_pincfg *pin; | ||
742 | unsigned int oldcfg; | ||
743 | |||
744 | oldcfg = snd_hda_codec_get_pincfg(codec, nid); | ||
745 | pin = look_up_pincfg(codec, list, nid); | ||
746 | if (!pin) { | ||
747 | pin = snd_array_new(list); | ||
748 | if (!pin) | ||
749 | return -ENOMEM; | ||
750 | pin->nid = nid; | ||
751 | } | ||
752 | pin->cfg = cfg; | ||
753 | |||
754 | /* change only when needed; e.g. if the pincfg is already present | ||
755 | * in user_pins[], don't write it | ||
756 | */ | ||
757 | cfg = snd_hda_codec_get_pincfg(codec, nid); | ||
758 | if (oldcfg != cfg) | ||
759 | set_pincfg(codec, nid, cfg); | ||
760 | return 0; | ||
761 | } | ||
762 | |||
763 | int snd_hda_codec_set_pincfg(struct hda_codec *codec, | ||
764 | hda_nid_t nid, unsigned int cfg) | ||
765 | { | ||
766 | return snd_hda_add_pincfg(codec, &codec->driver_pins, nid, cfg); | ||
767 | } | ||
768 | EXPORT_SYMBOL_HDA(snd_hda_codec_set_pincfg); | ||
769 | |||
770 | /* get the current pin config value of the given pin NID */ | ||
771 | unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid) | ||
772 | { | ||
773 | struct hda_pincfg *pin; | ||
774 | |||
775 | #ifdef CONFIG_SND_HDA_HWDEP | ||
776 | pin = look_up_pincfg(codec, &codec->user_pins, nid); | ||
777 | if (pin) | ||
778 | return pin->cfg; | ||
779 | #endif | ||
780 | pin = look_up_pincfg(codec, &codec->driver_pins, nid); | ||
781 | if (pin) | ||
782 | return pin->cfg; | ||
783 | pin = look_up_pincfg(codec, &codec->init_pins, nid); | ||
784 | if (pin) | ||
785 | return pin->cfg; | ||
786 | return 0; | ||
787 | } | ||
788 | EXPORT_SYMBOL_HDA(snd_hda_codec_get_pincfg); | ||
789 | |||
790 | /* restore all current pin configs */ | ||
791 | static void restore_pincfgs(struct hda_codec *codec) | ||
792 | { | ||
793 | int i; | ||
794 | for (i = 0; i < codec->init_pins.used; i++) { | ||
795 | struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i); | ||
796 | set_pincfg(codec, pin->nid, | ||
797 | snd_hda_codec_get_pincfg(codec, pin->nid)); | ||
798 | } | ||
799 | } | ||
685 | 800 | ||
686 | static void init_hda_cache(struct hda_cache_rec *cache, | 801 | static void init_hda_cache(struct hda_cache_rec *cache, |
687 | unsigned int record_size); | 802 | unsigned int record_size); |
688 | static void free_hda_cache(struct hda_cache_rec *cache); | 803 | static void free_hda_cache(struct hda_cache_rec *cache); |
689 | 804 | ||
805 | /* restore the initial pin cfgs and release all pincfg lists */ | ||
806 | static void restore_init_pincfgs(struct hda_codec *codec) | ||
807 | { | ||
808 | /* first free driver_pins and user_pins, then call restore_pincfg | ||
809 | * so that only the values in init_pins are restored | ||
810 | */ | ||
811 | snd_array_free(&codec->driver_pins); | ||
812 | #ifdef CONFIG_SND_HDA_HWDEP | ||
813 | snd_array_free(&codec->user_pins); | ||
814 | #endif | ||
815 | restore_pincfgs(codec); | ||
816 | snd_array_free(&codec->init_pins); | ||
817 | } | ||
818 | |||
690 | /* | 819 | /* |
691 | * codec destructor | 820 | * codec destructor |
692 | */ | 821 | */ |
@@ -694,6 +823,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) | |||
694 | { | 823 | { |
695 | if (!codec) | 824 | if (!codec) |
696 | return; | 825 | return; |
826 | restore_init_pincfgs(codec); | ||
697 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 827 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
698 | cancel_delayed_work(&codec->power_work); | 828 | cancel_delayed_work(&codec->power_work); |
699 | flush_workqueue(codec->bus->workq); | 829 | flush_workqueue(codec->bus->workq); |
@@ -751,6 +881,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
751 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); | 881 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); |
752 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); | 882 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); |
753 | snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); | 883 | snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); |
884 | snd_array_init(&codec->init_pins, sizeof(struct hda_pincfg), 16); | ||
885 | snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); | ||
754 | if (codec->bus->modelname) { | 886 | if (codec->bus->modelname) { |
755 | codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); | 887 | codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); |
756 | if (!codec->modelname) { | 888 | if (!codec->modelname) { |
@@ -787,15 +919,18 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
787 | setup_fg_nodes(codec); | 919 | setup_fg_nodes(codec); |
788 | if (!codec->afg && !codec->mfg) { | 920 | if (!codec->afg && !codec->mfg) { |
789 | snd_printdd("hda_codec: no AFG or MFG node found\n"); | 921 | snd_printdd("hda_codec: no AFG or MFG node found\n"); |
790 | snd_hda_codec_free(codec); | 922 | err = -ENODEV; |
791 | return -ENODEV; | 923 | goto error; |
792 | } | 924 | } |
793 | 925 | ||
794 | if (read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg) < 0) { | 926 | err = read_widget_caps(codec, codec->afg ? codec->afg : codec->mfg); |
927 | if (err < 0) { | ||
795 | snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); | 928 | snd_printk(KERN_ERR "hda_codec: cannot malloc\n"); |
796 | snd_hda_codec_free(codec); | 929 | goto error; |
797 | return -ENOMEM; | ||
798 | } | 930 | } |
931 | err = read_pin_defaults(codec); | ||
932 | if (err < 0) | ||
933 | goto error; | ||
799 | 934 | ||
800 | if (!codec->subsystem_id) { | 935 | if (!codec->subsystem_id) { |
801 | hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; | 936 | hda_nid_t nid = codec->afg ? codec->afg : codec->mfg; |
@@ -808,10 +943,8 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
808 | 943 | ||
809 | if (do_init) { | 944 | if (do_init) { |
810 | err = snd_hda_codec_configure(codec); | 945 | err = snd_hda_codec_configure(codec); |
811 | if (err < 0) { | 946 | if (err < 0) |
812 | snd_hda_codec_free(codec); | 947 | goto error; |
813 | return err; | ||
814 | } | ||
815 | } | 948 | } |
816 | snd_hda_codec_proc_new(codec); | 949 | snd_hda_codec_proc_new(codec); |
817 | 950 | ||
@@ -824,6 +957,10 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
824 | if (codecp) | 957 | if (codecp) |
825 | *codecp = codec; | 958 | *codecp = codec; |
826 | return 0; | 959 | return 0; |
960 | |||
961 | error: | ||
962 | snd_hda_codec_free(codec); | ||
963 | return err; | ||
827 | } | 964 | } |
828 | EXPORT_SYMBOL_HDA(snd_hda_codec_new); | 965 | EXPORT_SYMBOL_HDA(snd_hda_codec_new); |
829 | 966 | ||
@@ -1334,6 +1471,9 @@ void snd_hda_codec_reset(struct hda_codec *codec) | |||
1334 | free_hda_cache(&codec->cmd_cache); | 1471 | free_hda_cache(&codec->cmd_cache); |
1335 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); | 1472 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); |
1336 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); | 1473 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); |
1474 | /* free only driver_pins so that init_pins + user_pins are restored */ | ||
1475 | snd_array_free(&codec->driver_pins); | ||
1476 | restore_pincfgs(codec); | ||
1337 | codec->num_pcms = 0; | 1477 | codec->num_pcms = 0; |
1338 | codec->pcm_info = NULL; | 1478 | codec->pcm_info = NULL; |
1339 | codec->preset = NULL; | 1479 | codec->preset = NULL; |
@@ -2175,6 +2315,7 @@ static void hda_call_codec_resume(struct hda_codec *codec) | |||
2175 | hda_set_power_state(codec, | 2315 | hda_set_power_state(codec, |
2176 | codec->afg ? codec->afg : codec->mfg, | 2316 | codec->afg ? codec->afg : codec->mfg, |
2177 | AC_PWRST_D0); | 2317 | AC_PWRST_D0); |
2318 | restore_pincfgs(codec); /* restore all current pin configs */ | ||
2178 | hda_exec_init_verbs(codec); | 2319 | hda_exec_init_verbs(codec); |
2179 | if (codec->patch_ops.resume) | 2320 | if (codec->patch_ops.resume) |
2180 | codec->patch_ops.resume(codec); | 2321 | codec->patch_ops.resume(codec); |
@@ -3355,8 +3496,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec, | |||
3355 | if (ignore_nids && is_in_nid_list(nid, ignore_nids)) | 3496 | if (ignore_nids && is_in_nid_list(nid, ignore_nids)) |
3356 | continue; | 3497 | continue; |
3357 | 3498 | ||
3358 | def_conf = snd_hda_codec_read(codec, nid, 0, | 3499 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
3359 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
3360 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | 3500 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
3361 | continue; | 3501 | continue; |
3362 | loc = get_defcfg_location(def_conf); | 3502 | loc = get_defcfg_location(def_conf); |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 09a332ada0c6..2ea628478a91 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -778,11 +778,14 @@ struct hda_codec { | |||
778 | unsigned short spdif_ctls; /* SPDIF control bits */ | 778 | unsigned short spdif_ctls; /* SPDIF control bits */ |
779 | unsigned int spdif_in_enable; /* SPDIF input enable? */ | 779 | unsigned int spdif_in_enable; /* SPDIF input enable? */ |
780 | hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ | 780 | hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ |
781 | struct snd_array init_pins; /* initial (BIOS) pin configurations */ | ||
782 | struct snd_array driver_pins; /* pin configs set by codec parser */ | ||
781 | 783 | ||
782 | #ifdef CONFIG_SND_HDA_HWDEP | 784 | #ifdef CONFIG_SND_HDA_HWDEP |
783 | struct snd_hwdep *hwdep; /* assigned hwdep device */ | 785 | struct snd_hwdep *hwdep; /* assigned hwdep device */ |
784 | struct snd_array init_verbs; /* additional init verbs */ | 786 | struct snd_array init_verbs; /* additional init verbs */ |
785 | struct snd_array hints; /* additional hints */ | 787 | struct snd_array hints; /* additional hints */ |
788 | struct snd_array user_pins; /* default pin configs to override */ | ||
786 | #endif | 789 | #endif |
787 | 790 | ||
788 | /* misc flags */ | 791 | /* misc flags */ |
@@ -855,6 +858,18 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec); | |||
855 | #define snd_hda_sequence_write_cache snd_hda_sequence_write | 858 | #define snd_hda_sequence_write_cache snd_hda_sequence_write |
856 | #endif | 859 | #endif |
857 | 860 | ||
861 | /* the struct for codec->pin_configs */ | ||
862 | struct hda_pincfg { | ||
863 | hda_nid_t nid; | ||
864 | unsigned int cfg; | ||
865 | }; | ||
866 | |||
867 | unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid); | ||
868 | int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid, | ||
869 | unsigned int cfg); | ||
870 | int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, | ||
871 | hda_nid_t nid, unsigned int cfg); /* for hwdep */ | ||
872 | |||
858 | /* | 873 | /* |
859 | * Mixer | 874 | * Mixer |
860 | */ | 875 | */ |
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index 65745e96dc70..2c81a683e8f8 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -146,7 +146,7 @@ static int add_new_node(struct hda_codec *codec, struct hda_gspec *spec, hda_nid | |||
146 | if (node->type == AC_WID_PIN) { | 146 | if (node->type == AC_WID_PIN) { |
147 | node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP); | 147 | node->pin_caps = snd_hda_param_read(codec, node->nid, AC_PAR_PIN_CAP); |
148 | node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 148 | node->pin_ctl = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
149 | node->def_cfg = snd_hda_codec_read(codec, node->nid, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 149 | node->def_cfg = snd_hda_codec_get_pincfg(codec, node->nid); |
150 | } | 150 | } |
151 | 151 | ||
152 | if (node->wid_caps & AC_WCAP_OUT_AMP) { | 152 | if (node->wid_caps & AC_WCAP_OUT_AMP) { |
diff --git a/sound/pci/hda/hda_hwdep.c b/sound/pci/hda/hda_hwdep.c index 4ae51dcb81af..c660383ef381 100644 --- a/sound/pci/hda/hda_hwdep.c +++ b/sound/pci/hda/hda_hwdep.c | |||
@@ -109,6 +109,7 @@ static void clear_hwdep_elements(struct hda_codec *codec) | |||
109 | for (i = 0; i < codec->hints.used; i++, head++) | 109 | for (i = 0; i < codec->hints.used; i++, head++) |
110 | kfree(*head); | 110 | kfree(*head); |
111 | snd_array_free(&codec->hints); | 111 | snd_array_free(&codec->hints); |
112 | snd_array_free(&codec->user_pins); | ||
112 | } | 113 | } |
113 | 114 | ||
114 | static void hwdep_free(struct snd_hwdep *hwdep) | 115 | static void hwdep_free(struct snd_hwdep *hwdep) |
@@ -141,6 +142,7 @@ int /*__devinit*/ snd_hda_create_hwdep(struct hda_codec *codec) | |||
141 | 142 | ||
142 | snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32); | 143 | snd_array_init(&codec->init_verbs, sizeof(struct hda_verb), 32); |
143 | snd_array_init(&codec->hints, sizeof(char *), 32); | 144 | snd_array_init(&codec->hints, sizeof(char *), 32); |
145 | snd_array_init(&codec->user_pins, sizeof(struct hda_pincfg), 16); | ||
144 | 146 | ||
145 | return 0; | 147 | return 0; |
146 | } | 148 | } |
@@ -316,6 +318,67 @@ static ssize_t hints_store(struct device *dev, | |||
316 | return count; | 318 | return count; |
317 | } | 319 | } |
318 | 320 | ||
321 | static ssize_t pin_configs_show(struct hda_codec *codec, | ||
322 | struct snd_array *list, | ||
323 | char *buf) | ||
324 | { | ||
325 | int i, len = 0; | ||
326 | for (i = 0; i < list->used; i++) { | ||
327 | struct hda_pincfg *pin = snd_array_elem(list, i); | ||
328 | len += sprintf(buf + len, "0x%02x 0x%08x\n", | ||
329 | pin->nid, pin->cfg); | ||
330 | } | ||
331 | return len; | ||
332 | } | ||
333 | |||
334 | static ssize_t init_pin_configs_show(struct device *dev, | ||
335 | struct device_attribute *attr, | ||
336 | char *buf) | ||
337 | { | ||
338 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
339 | struct hda_codec *codec = hwdep->private_data; | ||
340 | return pin_configs_show(codec, &codec->init_pins, buf); | ||
341 | } | ||
342 | |||
343 | static ssize_t user_pin_configs_show(struct device *dev, | ||
344 | struct device_attribute *attr, | ||
345 | char *buf) | ||
346 | { | ||
347 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
348 | struct hda_codec *codec = hwdep->private_data; | ||
349 | return pin_configs_show(codec, &codec->user_pins, buf); | ||
350 | } | ||
351 | |||
352 | static ssize_t driver_pin_configs_show(struct device *dev, | ||
353 | struct device_attribute *attr, | ||
354 | char *buf) | ||
355 | { | ||
356 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
357 | struct hda_codec *codec = hwdep->private_data; | ||
358 | return pin_configs_show(codec, &codec->driver_pins, buf); | ||
359 | } | ||
360 | |||
361 | #define MAX_PIN_CONFIGS 32 | ||
362 | |||
363 | static ssize_t user_pin_configs_store(struct device *dev, | ||
364 | struct device_attribute *attr, | ||
365 | const char *buf, size_t count) | ||
366 | { | ||
367 | struct snd_hwdep *hwdep = dev_get_drvdata(dev); | ||
368 | struct hda_codec *codec = hwdep->private_data; | ||
369 | int nid, cfg; | ||
370 | int err; | ||
371 | |||
372 | if (sscanf(buf, "%i %i", &nid, &cfg) != 2) | ||
373 | return -EINVAL; | ||
374 | if (!nid) | ||
375 | return -EINVAL; | ||
376 | err = snd_hda_add_pincfg(codec, &codec->user_pins, nid, cfg); | ||
377 | if (err < 0) | ||
378 | return err; | ||
379 | return count; | ||
380 | } | ||
381 | |||
319 | #define CODEC_ATTR_RW(type) \ | 382 | #define CODEC_ATTR_RW(type) \ |
320 | __ATTR(type, 0644, type##_show, type##_store) | 383 | __ATTR(type, 0644, type##_show, type##_store) |
321 | #define CODEC_ATTR_RO(type) \ | 384 | #define CODEC_ATTR_RO(type) \ |
@@ -333,6 +396,9 @@ static struct device_attribute codec_attrs[] = { | |||
333 | CODEC_ATTR_RW(modelname), | 396 | CODEC_ATTR_RW(modelname), |
334 | CODEC_ATTR_WO(init_verbs), | 397 | CODEC_ATTR_WO(init_verbs), |
335 | CODEC_ATTR_WO(hints), | 398 | CODEC_ATTR_WO(hints), |
399 | CODEC_ATTR_RO(init_pin_configs), | ||
400 | CODEC_ATTR_RW(user_pin_configs), | ||
401 | CODEC_ATTR_RO(driver_pin_configs), | ||
336 | CODEC_ATTR_WO(reconfig), | 402 | CODEC_ATTR_WO(reconfig), |
337 | CODEC_ATTR_WO(clear), | 403 | CODEC_ATTR_WO(clear), |
338 | }; | 404 | }; |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index b16802841468..0253cb93aa7f 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -1047,8 +1047,7 @@ static struct hda_amp_list ad1986a_loopbacks[] = { | |||
1047 | 1047 | ||
1048 | static int is_jack_available(struct hda_codec *codec, hda_nid_t nid) | 1048 | static int is_jack_available(struct hda_codec *codec, hda_nid_t nid) |
1049 | { | 1049 | { |
1050 | unsigned int conf = snd_hda_codec_read(codec, nid, 0, | 1050 | unsigned int conf = snd_hda_codec_get_pincfg(codec, nid); |
1051 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
1052 | return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; | 1051 | return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; |
1053 | } | 1052 | } |
1054 | 1053 | ||
diff --git a/sound/pci/hda/patch_cmedia.c b/sound/pci/hda/patch_cmedia.c index f3ebe837f2d5..c921264bbd71 100644 --- a/sound/pci/hda/patch_cmedia.c +++ b/sound/pci/hda/patch_cmedia.c | |||
@@ -680,13 +680,13 @@ static int patch_cmi9880(struct hda_codec *codec) | |||
680 | struct auto_pin_cfg cfg; | 680 | struct auto_pin_cfg cfg; |
681 | 681 | ||
682 | /* collect pin default configuration */ | 682 | /* collect pin default configuration */ |
683 | port_e = snd_hda_codec_read(codec, 0x0f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 683 | port_e = snd_hda_codec_get_pincfg(codec, 0x0f); |
684 | port_f = snd_hda_codec_read(codec, 0x10, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 684 | port_f = snd_hda_codec_get_pincfg(codec, 0x10); |
685 | spec->front_panel = 1; | 685 | spec->front_panel = 1; |
686 | if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE || | 686 | if (get_defcfg_connect(port_e) == AC_JACK_PORT_NONE || |
687 | get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) { | 687 | get_defcfg_connect(port_f) == AC_JACK_PORT_NONE) { |
688 | port_g = snd_hda_codec_read(codec, 0x1f, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 688 | port_g = snd_hda_codec_get_pincfg(codec, 0x1f); |
689 | port_h = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 689 | port_h = snd_hda_codec_get_pincfg(codec, 0x20); |
690 | spec->channel_modes = cmi9880_channel_modes; | 690 | spec->channel_modes = cmi9880_channel_modes; |
691 | /* no front panel */ | 691 | /* no front panel */ |
692 | if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || | 692 | if (get_defcfg_connect(port_g) == AC_JACK_PORT_NONE || |
@@ -703,8 +703,8 @@ static int patch_cmi9880(struct hda_codec *codec) | |||
703 | spec->multiout.max_channels = cmi9880_channel_modes[0].channels; | 703 | spec->multiout.max_channels = cmi9880_channel_modes[0].channels; |
704 | } else { | 704 | } else { |
705 | spec->input_mux = &cmi9880_basic_mux; | 705 | spec->input_mux = &cmi9880_basic_mux; |
706 | port_spdifi = snd_hda_codec_read(codec, 0x13, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 706 | port_spdifi = snd_hda_codec_get_pincfg(codec, 0x13); |
707 | port_spdifo = snd_hda_codec_read(codec, 0x12, 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | 707 | port_spdifo = snd_hda_codec_get_pincfg(codec, 0x12); |
708 | if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE) | 708 | if (get_defcfg_connect(port_spdifo) != AC_JACK_PORT_NONE) |
709 | spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; | 709 | spec->multiout.dig_out_nid = CMI_DIG_OUT_NID; |
710 | if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE) | 710 | if (get_defcfg_connect(port_spdifi) != AC_JACK_PORT_NONE) |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 5c9bb066a764..50ae8f33af5f 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -330,13 +330,6 @@ struct alc_spec { | |||
330 | /* for PLL fix */ | 330 | /* for PLL fix */ |
331 | hda_nid_t pll_nid; | 331 | hda_nid_t pll_nid; |
332 | unsigned int pll_coef_idx, pll_coef_bit; | 332 | unsigned int pll_coef_idx, pll_coef_bit; |
333 | |||
334 | #ifdef SND_HDA_NEEDS_RESUME | ||
335 | #define ALC_MAX_PINS 16 | ||
336 | unsigned int num_pins; | ||
337 | hda_nid_t pin_nids[ALC_MAX_PINS]; | ||
338 | unsigned int pin_cfgs[ALC_MAX_PINS]; | ||
339 | #endif | ||
340 | }; | 333 | }; |
341 | 334 | ||
342 | /* | 335 | /* |
@@ -1010,8 +1003,7 @@ static void alc_subsystem_id(struct hda_codec *codec, | |||
1010 | nid = 0x1d; | 1003 | nid = 0x1d; |
1011 | if (codec->vendor_id == 0x10ec0260) | 1004 | if (codec->vendor_id == 0x10ec0260) |
1012 | nid = 0x17; | 1005 | nid = 0x17; |
1013 | ass = snd_hda_codec_read(codec, nid, 0, | 1006 | ass = snd_hda_codec_get_pincfg(codec, nid); |
1014 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
1015 | if (!(ass & 1) && !(ass & 0x100000)) | 1007 | if (!(ass & 1) && !(ass & 0x100000)) |
1016 | return; | 1008 | return; |
1017 | if ((ass >> 30) != 1) /* no physical connection */ | 1009 | if ((ass >> 30) != 1) /* no physical connection */ |
@@ -1185,16 +1177,8 @@ static void alc_fix_pincfg(struct hda_codec *codec, | |||
1185 | return; | 1177 | return; |
1186 | 1178 | ||
1187 | cfg = pinfix[quirk->value]; | 1179 | cfg = pinfix[quirk->value]; |
1188 | for (; cfg->nid; cfg++) { | 1180 | for (; cfg->nid; cfg++) |
1189 | int i; | 1181 | snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val); |
1190 | u32 val = cfg->val; | ||
1191 | for (i = 0; i < 4; i++) { | ||
1192 | snd_hda_codec_write(codec, cfg->nid, 0, | ||
1193 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i, | ||
1194 | val & 0xff); | ||
1195 | val >>= 8; | ||
1196 | } | ||
1197 | } | ||
1198 | } | 1182 | } |
1199 | 1183 | ||
1200 | /* | 1184 | /* |
@@ -3216,61 +3200,13 @@ static void alc_free(struct hda_codec *codec) | |||
3216 | } | 3200 | } |
3217 | 3201 | ||
3218 | #ifdef SND_HDA_NEEDS_RESUME | 3202 | #ifdef SND_HDA_NEEDS_RESUME |
3219 | static void store_pin_configs(struct hda_codec *codec) | ||
3220 | { | ||
3221 | struct alc_spec *spec = codec->spec; | ||
3222 | hda_nid_t nid, end_nid; | ||
3223 | |||
3224 | end_nid = codec->start_nid + codec->num_nodes; | ||
3225 | for (nid = codec->start_nid; nid < end_nid; nid++) { | ||
3226 | unsigned int wid_caps = get_wcaps(codec, nid); | ||
3227 | unsigned int wid_type = | ||
3228 | (wid_caps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
3229 | if (wid_type != AC_WID_PIN) | ||
3230 | continue; | ||
3231 | if (spec->num_pins >= ARRAY_SIZE(spec->pin_nids)) | ||
3232 | break; | ||
3233 | spec->pin_nids[spec->num_pins] = nid; | ||
3234 | spec->pin_cfgs[spec->num_pins] = | ||
3235 | snd_hda_codec_read(codec, nid, 0, | ||
3236 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
3237 | spec->num_pins++; | ||
3238 | } | ||
3239 | } | ||
3240 | |||
3241 | static void resume_pin_configs(struct hda_codec *codec) | ||
3242 | { | ||
3243 | struct alc_spec *spec = codec->spec; | ||
3244 | int i; | ||
3245 | |||
3246 | for (i = 0; i < spec->num_pins; i++) { | ||
3247 | hda_nid_t pin_nid = spec->pin_nids[i]; | ||
3248 | unsigned int pin_config = spec->pin_cfgs[i]; | ||
3249 | snd_hda_codec_write(codec, pin_nid, 0, | ||
3250 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | ||
3251 | pin_config & 0x000000ff); | ||
3252 | snd_hda_codec_write(codec, pin_nid, 0, | ||
3253 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | ||
3254 | (pin_config & 0x0000ff00) >> 8); | ||
3255 | snd_hda_codec_write(codec, pin_nid, 0, | ||
3256 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | ||
3257 | (pin_config & 0x00ff0000) >> 16); | ||
3258 | snd_hda_codec_write(codec, pin_nid, 0, | ||
3259 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | ||
3260 | pin_config >> 24); | ||
3261 | } | ||
3262 | } | ||
3263 | |||
3264 | static int alc_resume(struct hda_codec *codec) | 3203 | static int alc_resume(struct hda_codec *codec) |
3265 | { | 3204 | { |
3266 | resume_pin_configs(codec); | ||
3267 | codec->patch_ops.init(codec); | 3205 | codec->patch_ops.init(codec); |
3268 | snd_hda_codec_resume_amp(codec); | 3206 | snd_hda_codec_resume_amp(codec); |
3269 | snd_hda_codec_resume_cache(codec); | 3207 | snd_hda_codec_resume_cache(codec); |
3270 | return 0; | 3208 | return 0; |
3271 | } | 3209 | } |
3272 | #else | ||
3273 | #define store_pin_configs(codec) | ||
3274 | #endif | 3210 | #endif |
3275 | 3211 | ||
3276 | /* | 3212 | /* |
@@ -4330,7 +4266,6 @@ static int alc880_parse_auto_config(struct hda_codec *codec) | |||
4330 | spec->num_mux_defs = 1; | 4266 | spec->num_mux_defs = 1; |
4331 | spec->input_mux = &spec->private_imux[0]; | 4267 | spec->input_mux = &spec->private_imux[0]; |
4332 | 4268 | ||
4333 | store_pin_configs(codec); | ||
4334 | return 1; | 4269 | return 1; |
4335 | } | 4270 | } |
4336 | 4271 | ||
@@ -5809,7 +5744,6 @@ static int alc260_parse_auto_config(struct hda_codec *codec) | |||
5809 | spec->num_mux_defs = 1; | 5744 | spec->num_mux_defs = 1; |
5810 | spec->input_mux = &spec->private_imux[0]; | 5745 | spec->input_mux = &spec->private_imux[0]; |
5811 | 5746 | ||
5812 | store_pin_configs(codec); | ||
5813 | return 1; | 5747 | return 1; |
5814 | } | 5748 | } |
5815 | 5749 | ||
@@ -10821,7 +10755,6 @@ static int alc262_parse_auto_config(struct hda_codec *codec) | |||
10821 | if (err < 0) | 10755 | if (err < 0) |
10822 | return err; | 10756 | return err; |
10823 | 10757 | ||
10824 | store_pin_configs(codec); | ||
10825 | return 1; | 10758 | return 1; |
10826 | } | 10759 | } |
10827 | 10760 | ||
@@ -11994,7 +11927,6 @@ static int alc268_parse_auto_config(struct hda_codec *codec) | |||
11994 | if (err < 0) | 11927 | if (err < 0) |
11995 | return err; | 11928 | return err; |
11996 | 11929 | ||
11997 | store_pin_configs(codec); | ||
11998 | return 1; | 11930 | return 1; |
11999 | } | 11931 | } |
12000 | 11932 | ||
@@ -12907,7 +12839,6 @@ static int alc269_parse_auto_config(struct hda_codec *codec) | |||
12907 | if (!spec->cap_mixer && !spec->no_analog) | 12839 | if (!spec->cap_mixer && !spec->no_analog) |
12908 | set_capture_mixer(spec); | 12840 | set_capture_mixer(spec); |
12909 | 12841 | ||
12910 | store_pin_configs(codec); | ||
12911 | return 1; | 12842 | return 1; |
12912 | } | 12843 | } |
12913 | 12844 | ||
@@ -13958,7 +13889,6 @@ static int alc861_parse_auto_config(struct hda_codec *codec) | |||
13958 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); | 13889 | spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids); |
13959 | set_capture_mixer(spec); | 13890 | set_capture_mixer(spec); |
13960 | 13891 | ||
13961 | store_pin_configs(codec); | ||
13962 | return 1; | 13892 | return 1; |
13963 | } | 13893 | } |
13964 | 13894 | ||
@@ -15060,7 +14990,6 @@ static int alc861vd_parse_auto_config(struct hda_codec *codec) | |||
15060 | if (err < 0) | 14990 | if (err < 0) |
15061 | return err; | 14991 | return err; |
15062 | 14992 | ||
15063 | store_pin_configs(codec); | ||
15064 | return 1; | 14993 | return 1; |
15065 | } | 14994 | } |
15066 | 14995 | ||
@@ -16870,7 +16799,6 @@ static int alc662_parse_auto_config(struct hda_codec *codec) | |||
16870 | if (err < 0) | 16799 | if (err < 0) |
16871 | return err; | 16800 | return err; |
16872 | 16801 | ||
16873 | store_pin_configs(codec); | ||
16874 | return 1; | 16802 | return 1; |
16875 | } | 16803 | } |
16876 | 16804 | ||
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index d00a211a813b..da48d8c0b295 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -229,7 +229,6 @@ struct sigmatel_spec { | |||
229 | /* pin widgets */ | 229 | /* pin widgets */ |
230 | hda_nid_t *pin_nids; | 230 | hda_nid_t *pin_nids; |
231 | unsigned int num_pins; | 231 | unsigned int num_pins; |
232 | unsigned int *pin_configs; | ||
233 | 232 | ||
234 | /* codec specific stuff */ | 233 | /* codec specific stuff */ |
235 | struct hda_verb *init; | 234 | struct hda_verb *init; |
@@ -2272,101 +2271,19 @@ static struct snd_pci_quirk stac9205_cfg_tbl[] = { | |||
2272 | {} /* terminator */ | 2271 | {} /* terminator */ |
2273 | }; | 2272 | }; |
2274 | 2273 | ||
2275 | static int stac92xx_save_bios_config_regs(struct hda_codec *codec) | 2274 | static void stac92xx_set_config_regs(struct hda_codec *codec, |
2275 | unsigned int *pincfgs) | ||
2276 | { | 2276 | { |
2277 | int i; | 2277 | int i; |
2278 | struct sigmatel_spec *spec = codec->spec; | 2278 | struct sigmatel_spec *spec = codec->spec; |
2279 | |||
2280 | kfree(spec->pin_configs); | ||
2281 | spec->pin_configs = kcalloc(spec->num_pins, sizeof(*spec->pin_configs), | ||
2282 | GFP_KERNEL); | ||
2283 | if (!spec->pin_configs) | ||
2284 | return -ENOMEM; | ||
2285 | |||
2286 | for (i = 0; i < spec->num_pins; i++) { | ||
2287 | hda_nid_t nid = spec->pin_nids[i]; | ||
2288 | unsigned int pin_cfg; | ||
2289 | |||
2290 | if (!nid) | ||
2291 | continue; | ||
2292 | pin_cfg = snd_hda_codec_read(codec, nid, 0, | ||
2293 | AC_VERB_GET_CONFIG_DEFAULT, 0x00); | ||
2294 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n", | ||
2295 | nid, pin_cfg); | ||
2296 | spec->pin_configs[i] = pin_cfg; | ||
2297 | } | ||
2298 | |||
2299 | return 0; | ||
2300 | } | ||
2301 | 2279 | ||
2302 | static void stac92xx_set_config_reg(struct hda_codec *codec, | 2280 | if (!pincfgs) |
2303 | hda_nid_t pin_nid, unsigned int pin_config) | 2281 | return; |
2304 | { | ||
2305 | int i; | ||
2306 | snd_hda_codec_write(codec, pin_nid, 0, | ||
2307 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_0, | ||
2308 | pin_config & 0x000000ff); | ||
2309 | snd_hda_codec_write(codec, pin_nid, 0, | ||
2310 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_1, | ||
2311 | (pin_config & 0x0000ff00) >> 8); | ||
2312 | snd_hda_codec_write(codec, pin_nid, 0, | ||
2313 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_2, | ||
2314 | (pin_config & 0x00ff0000) >> 16); | ||
2315 | snd_hda_codec_write(codec, pin_nid, 0, | ||
2316 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | ||
2317 | pin_config >> 24); | ||
2318 | i = snd_hda_codec_read(codec, pin_nid, 0, | ||
2319 | AC_VERB_GET_CONFIG_DEFAULT, | ||
2320 | 0x00); | ||
2321 | snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", | ||
2322 | pin_nid, i); | ||
2323 | } | ||
2324 | |||
2325 | static void stac92xx_set_config_regs(struct hda_codec *codec) | ||
2326 | { | ||
2327 | int i; | ||
2328 | struct sigmatel_spec *spec = codec->spec; | ||
2329 | |||
2330 | if (!spec->pin_configs) | ||
2331 | return; | ||
2332 | 2282 | ||
2333 | for (i = 0; i < spec->num_pins; i++) | 2283 | for (i = 0; i < spec->num_pins; i++) |
2334 | if (spec->pin_nids[i] && spec->pin_configs[i]) | 2284 | if (spec->pin_nids[i] && pincfgs[i]) |
2335 | stac92xx_set_config_reg(codec, spec->pin_nids[i], | 2285 | snd_hda_codec_set_pincfg(codec, spec->pin_nids[i], |
2336 | spec->pin_configs[i]); | 2286 | pincfgs[i]); |
2337 | } | ||
2338 | |||
2339 | static int stac_save_pin_cfgs(struct hda_codec *codec, unsigned int *pins) | ||
2340 | { | ||
2341 | struct sigmatel_spec *spec = codec->spec; | ||
2342 | |||
2343 | if (!pins) | ||
2344 | return stac92xx_save_bios_config_regs(codec); | ||
2345 | |||
2346 | kfree(spec->pin_configs); | ||
2347 | spec->pin_configs = kmemdup(pins, | ||
2348 | spec->num_pins * sizeof(*pins), | ||
2349 | GFP_KERNEL); | ||
2350 | if (!spec->pin_configs) | ||
2351 | return -ENOMEM; | ||
2352 | |||
2353 | stac92xx_set_config_regs(codec); | ||
2354 | return 0; | ||
2355 | } | ||
2356 | |||
2357 | static void stac_change_pin_config(struct hda_codec *codec, hda_nid_t nid, | ||
2358 | unsigned int cfg) | ||
2359 | { | ||
2360 | struct sigmatel_spec *spec = codec->spec; | ||
2361 | int i; | ||
2362 | |||
2363 | for (i = 0; i < spec->num_pins; i++) { | ||
2364 | if (spec->pin_nids[i] == nid) { | ||
2365 | spec->pin_configs[i] = cfg; | ||
2366 | stac92xx_set_config_reg(codec, nid, cfg); | ||
2367 | break; | ||
2368 | } | ||
2369 | } | ||
2370 | } | 2287 | } |
2371 | 2288 | ||
2372 | /* | 2289 | /* |
@@ -2853,8 +2770,7 @@ static hda_nid_t check_mic_out_switch(struct hda_codec *codec) | |||
2853 | mic_pin = AUTO_PIN_MIC; | 2770 | mic_pin = AUTO_PIN_MIC; |
2854 | for (;;) { | 2771 | for (;;) { |
2855 | hda_nid_t nid = cfg->input_pins[mic_pin]; | 2772 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
2856 | def_conf = snd_hda_codec_read(codec, nid, 0, | 2773 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
2857 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
2858 | /* some laptops have an internal analog microphone | 2774 | /* some laptops have an internal analog microphone |
2859 | * which can't be used as a output */ | 2775 | * which can't be used as a output */ |
2860 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { | 2776 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
@@ -3426,11 +3342,7 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, | |||
3426 | unsigned int wcaps; | 3342 | unsigned int wcaps; |
3427 | unsigned int def_conf; | 3343 | unsigned int def_conf; |
3428 | 3344 | ||
3429 | def_conf = snd_hda_codec_read(codec, | 3345 | def_conf = snd_hda_codec_get_pincfg(codec, spec->dmic_nids[i]); |
3430 | spec->dmic_nids[i], | ||
3431 | 0, | ||
3432 | AC_VERB_GET_CONFIG_DEFAULT, | ||
3433 | 0); | ||
3434 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) | 3346 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) |
3435 | continue; | 3347 | continue; |
3436 | 3348 | ||
@@ -3779,9 +3691,7 @@ static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec, | |||
3779 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { | 3691 | for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) { |
3780 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; | 3692 | hda_nid_t pin = spec->autocfg.line_out_pins[i]; |
3781 | unsigned int defcfg; | 3693 | unsigned int defcfg; |
3782 | defcfg = snd_hda_codec_read(codec, pin, 0, | 3694 | defcfg = snd_hda_codec_get_pincfg(codec, pin); |
3783 | AC_VERB_GET_CONFIG_DEFAULT, | ||
3784 | 0x00); | ||
3785 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { | 3695 | if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) { |
3786 | unsigned int wcaps = get_wcaps(codec, pin); | 3696 | unsigned int wcaps = get_wcaps(codec, pin); |
3787 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); | 3697 | wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP); |
@@ -3885,8 +3795,7 @@ static int stac92xx_add_jack(struct hda_codec *codec, | |||
3885 | #ifdef CONFIG_SND_JACK | 3795 | #ifdef CONFIG_SND_JACK |
3886 | struct sigmatel_spec *spec = codec->spec; | 3796 | struct sigmatel_spec *spec = codec->spec; |
3887 | struct sigmatel_jack *jack; | 3797 | struct sigmatel_jack *jack; |
3888 | int def_conf = snd_hda_codec_read(codec, nid, | 3798 | int def_conf = snd_hda_codec_get_pincfg(codec, nid); |
3889 | 0, AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
3890 | int connectivity = get_defcfg_connect(def_conf); | 3799 | int connectivity = get_defcfg_connect(def_conf); |
3891 | char name[32]; | 3800 | char name[32]; |
3892 | 3801 | ||
@@ -4066,8 +3975,7 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4066 | pinctl); | 3975 | pinctl); |
4067 | } | 3976 | } |
4068 | } | 3977 | } |
4069 | conf = snd_hda_codec_read(codec, nid, 0, | 3978 | conf = snd_hda_codec_get_pincfg(codec, nid); |
4070 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
4071 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { | 3979 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { |
4072 | enable_pin_detect(codec, nid, | 3980 | enable_pin_detect(codec, nid, |
4073 | STAC_INSERT_EVENT); | 3981 | STAC_INSERT_EVENT); |
@@ -4108,8 +4016,7 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4108 | stac_toggle_power_map(codec, nid, 1); | 4016 | stac_toggle_power_map(codec, nid, 1); |
4109 | continue; | 4017 | continue; |
4110 | } | 4018 | } |
4111 | def_conf = snd_hda_codec_read(codec, nid, 0, | 4019 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
4112 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
4113 | def_conf = get_defcfg_connect(def_conf); | 4020 | def_conf = get_defcfg_connect(def_conf); |
4114 | /* skip any ports that don't have jacks since presence | 4021 | /* skip any ports that don't have jacks since presence |
4115 | * detection is useless */ | 4022 | * detection is useless */ |
@@ -4163,7 +4070,6 @@ static void stac92xx_free(struct hda_codec *codec) | |||
4163 | if (! spec) | 4070 | if (! spec) |
4164 | return; | 4071 | return; |
4165 | 4072 | ||
4166 | kfree(spec->pin_configs); | ||
4167 | stac92xx_free_jacks(codec); | 4073 | stac92xx_free_jacks(codec); |
4168 | snd_array_free(&spec->events); | 4074 | snd_array_free(&spec->events); |
4169 | 4075 | ||
@@ -4474,7 +4380,6 @@ static int stac92xx_resume(struct hda_codec *codec) | |||
4474 | { | 4380 | { |
4475 | struct sigmatel_spec *spec = codec->spec; | 4381 | struct sigmatel_spec *spec = codec->spec; |
4476 | 4382 | ||
4477 | stac92xx_set_config_regs(codec); | ||
4478 | stac92xx_init(codec); | 4383 | stac92xx_init(codec); |
4479 | snd_hda_codec_resume_amp(codec); | 4384 | snd_hda_codec_resume_amp(codec); |
4480 | snd_hda_codec_resume_cache(codec); | 4385 | snd_hda_codec_resume_cache(codec); |
@@ -4523,16 +4428,11 @@ static int patch_stac9200(struct hda_codec *codec) | |||
4523 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, | 4428 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
4524 | stac9200_models, | 4429 | stac9200_models, |
4525 | stac9200_cfg_tbl); | 4430 | stac9200_cfg_tbl); |
4526 | if (spec->board_config < 0) { | 4431 | if (spec->board_config < 0) |
4527 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); | 4432 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n"); |
4528 | err = stac92xx_save_bios_config_regs(codec); | 4433 | else |
4529 | } else | 4434 | stac92xx_set_config_regs(codec, |
4530 | err = stac_save_pin_cfgs(codec, | ||
4531 | stac9200_brd_tbl[spec->board_config]); | 4435 | stac9200_brd_tbl[spec->board_config]); |
4532 | if (err < 0) { | ||
4533 | stac92xx_free(codec); | ||
4534 | return err; | ||
4535 | } | ||
4536 | 4436 | ||
4537 | spec->multiout.max_channels = 2; | 4437 | spec->multiout.max_channels = 2; |
4538 | spec->multiout.num_dacs = 1; | 4438 | spec->multiout.num_dacs = 1; |
@@ -4600,17 +4500,12 @@ static int patch_stac925x(struct hda_codec *codec) | |||
4600 | stac925x_models, | 4500 | stac925x_models, |
4601 | stac925x_cfg_tbl); | 4501 | stac925x_cfg_tbl); |
4602 | again: | 4502 | again: |
4603 | if (spec->board_config < 0) { | 4503 | if (spec->board_config < 0) |
4604 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," | 4504 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x," |
4605 | "using BIOS defaults\n"); | 4505 | "using BIOS defaults\n"); |
4606 | err = stac92xx_save_bios_config_regs(codec); | 4506 | else |
4607 | } else | 4507 | stac92xx_set_config_regs(codec, |
4608 | err = stac_save_pin_cfgs(codec, | ||
4609 | stac925x_brd_tbl[spec->board_config]); | 4508 | stac925x_brd_tbl[spec->board_config]); |
4610 | if (err < 0) { | ||
4611 | stac92xx_free(codec); | ||
4612 | return err; | ||
4613 | } | ||
4614 | 4509 | ||
4615 | spec->multiout.max_channels = 2; | 4510 | spec->multiout.max_channels = 2; |
4616 | spec->multiout.num_dacs = 1; | 4511 | spec->multiout.num_dacs = 1; |
@@ -4688,17 +4583,12 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
4688 | stac92hd73xx_models, | 4583 | stac92hd73xx_models, |
4689 | stac92hd73xx_cfg_tbl); | 4584 | stac92hd73xx_cfg_tbl); |
4690 | again: | 4585 | again: |
4691 | if (spec->board_config < 0) { | 4586 | if (spec->board_config < 0) |
4692 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 4587 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
4693 | " STAC92HD73XX, using BIOS defaults\n"); | 4588 | " STAC92HD73XX, using BIOS defaults\n"); |
4694 | err = stac92xx_save_bios_config_regs(codec); | 4589 | else |
4695 | } else | 4590 | stac92xx_set_config_regs(codec, |
4696 | err = stac_save_pin_cfgs(codec, | ||
4697 | stac92hd73xx_brd_tbl[spec->board_config]); | 4591 | stac92hd73xx_brd_tbl[spec->board_config]); |
4698 | if (err < 0) { | ||
4699 | stac92xx_free(codec); | ||
4700 | return err; | ||
4701 | } | ||
4702 | 4592 | ||
4703 | num_dacs = snd_hda_get_connections(codec, 0x0a, | 4593 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
4704 | conn, STAC92HD73_DAC_COUNT + 2) - 1; | 4594 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
@@ -4758,18 +4648,18 @@ again: | |||
4758 | spec->init = dell_m6_core_init; | 4648 | spec->init = dell_m6_core_init; |
4759 | switch (spec->board_config) { | 4649 | switch (spec->board_config) { |
4760 | case STAC_DELL_M6_AMIC: /* Analog Mics */ | 4650 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
4761 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); | 4651 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
4762 | spec->num_dmics = 0; | 4652 | spec->num_dmics = 0; |
4763 | spec->private_dimux.num_items = 1; | 4653 | spec->private_dimux.num_items = 1; |
4764 | break; | 4654 | break; |
4765 | case STAC_DELL_M6_DMIC: /* Digital Mics */ | 4655 | case STAC_DELL_M6_DMIC: /* Digital Mics */ |
4766 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); | 4656 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
4767 | spec->num_dmics = 1; | 4657 | spec->num_dmics = 1; |
4768 | spec->private_dimux.num_items = 2; | 4658 | spec->private_dimux.num_items = 2; |
4769 | break; | 4659 | break; |
4770 | case STAC_DELL_M6_BOTH: /* Both */ | 4660 | case STAC_DELL_M6_BOTH: /* Both */ |
4771 | stac92xx_set_config_reg(codec, 0x0b, 0x90A70170); | 4661 | snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170); |
4772 | stac92xx_set_config_reg(codec, 0x13, 0x90A60160); | 4662 | snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160); |
4773 | spec->num_dmics = 1; | 4663 | spec->num_dmics = 1; |
4774 | spec->private_dimux.num_items = 2; | 4664 | spec->private_dimux.num_items = 2; |
4775 | break; | 4665 | break; |
@@ -4865,17 +4755,12 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
4865 | stac92hd83xxx_models, | 4755 | stac92hd83xxx_models, |
4866 | stac92hd83xxx_cfg_tbl); | 4756 | stac92hd83xxx_cfg_tbl); |
4867 | again: | 4757 | again: |
4868 | if (spec->board_config < 0) { | 4758 | if (spec->board_config < 0) |
4869 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 4759 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
4870 | " STAC92HD83XXX, using BIOS defaults\n"); | 4760 | " STAC92HD83XXX, using BIOS defaults\n"); |
4871 | err = stac92xx_save_bios_config_regs(codec); | 4761 | else |
4872 | } else | 4762 | stac92xx_set_config_regs(codec, |
4873 | err = stac_save_pin_cfgs(codec, | ||
4874 | stac92hd83xxx_brd_tbl[spec->board_config]); | 4763 | stac92hd83xxx_brd_tbl[spec->board_config]); |
4875 | if (err < 0) { | ||
4876 | stac92xx_free(codec); | ||
4877 | return err; | ||
4878 | } | ||
4879 | 4764 | ||
4880 | switch (codec->vendor_id) { | 4765 | switch (codec->vendor_id) { |
4881 | case 0x111d7604: | 4766 | case 0x111d7604: |
@@ -4945,6 +4830,16 @@ static struct hda_input_mux stac92hd71bxx_dmux_amixer = { | |||
4945 | } | 4830 | } |
4946 | }; | 4831 | }; |
4947 | 4832 | ||
4833 | /* get the pin connection (fixed, none, etc) */ | ||
4834 | static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx) | ||
4835 | { | ||
4836 | struct sigmatel_spec *spec = codec->spec; | ||
4837 | unsigned int cfg; | ||
4838 | |||
4839 | cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]); | ||
4840 | return get_defcfg_connect(cfg); | ||
4841 | } | ||
4842 | |||
4948 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, | 4843 | static int stac92hd71bxx_connected_ports(struct hda_codec *codec, |
4949 | hda_nid_t *nids, int num_nids) | 4844 | hda_nid_t *nids, int num_nids) |
4950 | { | 4845 | { |
@@ -4958,7 +4853,7 @@ static int stac92hd71bxx_connected_ports(struct hda_codec *codec, | |||
4958 | break; | 4853 | break; |
4959 | if (idx >= spec->num_pins) | 4854 | if (idx >= spec->num_pins) |
4960 | break; | 4855 | break; |
4961 | def_conf = get_defcfg_connect(spec->pin_configs[idx]); | 4856 | def_conf = stac_get_defcfg_connect(codec, idx); |
4962 | if (def_conf == AC_JACK_PORT_NONE) | 4857 | if (def_conf == AC_JACK_PORT_NONE) |
4963 | break; | 4858 | break; |
4964 | } | 4859 | } |
@@ -4978,13 +4873,13 @@ static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec, | |||
4978 | return 0; | 4873 | return 0; |
4979 | 4874 | ||
4980 | /* dig1pin case */ | 4875 | /* dig1pin case */ |
4981 | if (get_defcfg_connect(spec->pin_configs[idx+1]) != AC_JACK_PORT_NONE) | 4876 | if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE) |
4982 | return 2; | 4877 | return 2; |
4983 | 4878 | ||
4984 | /* dig0pin + dig2pin case */ | 4879 | /* dig0pin + dig2pin case */ |
4985 | if (get_defcfg_connect(spec->pin_configs[idx+2]) != AC_JACK_PORT_NONE) | 4880 | if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE) |
4986 | return 2; | 4881 | return 2; |
4987 | if (get_defcfg_connect(spec->pin_configs[idx]) != AC_JACK_PORT_NONE) | 4882 | if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE) |
4988 | return 1; | 4883 | return 1; |
4989 | else | 4884 | else |
4990 | return 0; | 4885 | return 0; |
@@ -5023,17 +4918,12 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
5023 | stac92hd71bxx_models, | 4918 | stac92hd71bxx_models, |
5024 | stac92hd71bxx_cfg_tbl); | 4919 | stac92hd71bxx_cfg_tbl); |
5025 | again: | 4920 | again: |
5026 | if (spec->board_config < 0) { | 4921 | if (spec->board_config < 0) |
5027 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 4922 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
5028 | " STAC92HD71BXX, using BIOS defaults\n"); | 4923 | " STAC92HD71BXX, using BIOS defaults\n"); |
5029 | err = stac92xx_save_bios_config_regs(codec); | 4924 | else |
5030 | } else | 4925 | stac92xx_set_config_regs(codec, |
5031 | err = stac_save_pin_cfgs(codec, | ||
5032 | stac92hd71bxx_brd_tbl[spec->board_config]); | 4926 | stac92hd71bxx_brd_tbl[spec->board_config]); |
5033 | if (err < 0) { | ||
5034 | stac92xx_free(codec); | ||
5035 | return err; | ||
5036 | } | ||
5037 | 4927 | ||
5038 | if (spec->board_config > STAC_92HD71BXX_REF) { | 4928 | if (spec->board_config > STAC_92HD71BXX_REF) { |
5039 | /* GPIO0 = EAPD */ | 4929 | /* GPIO0 = EAPD */ |
@@ -5097,8 +4987,8 @@ again: | |||
5097 | /* disable VSW */ | 4987 | /* disable VSW */ |
5098 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; | 4988 | spec->init = &stac92hd71bxx_analog_core_init[HD_DISABLE_PORTF]; |
5099 | unmute_init++; | 4989 | unmute_init++; |
5100 | stac_change_pin_config(codec, 0x0f, 0x40f000f0); | 4990 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0); |
5101 | stac_change_pin_config(codec, 0x19, 0x40f000f3); | 4991 | snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3); |
5102 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; | 4992 | stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS - 1] = 0; |
5103 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, | 4993 | spec->num_dmics = stac92hd71bxx_connected_ports(codec, |
5104 | stac92hd71bxx_dmic_nids, | 4994 | stac92hd71bxx_dmic_nids, |
@@ -5147,7 +5037,7 @@ again: | |||
5147 | switch (spec->board_config) { | 5037 | switch (spec->board_config) { |
5148 | case STAC_HP_M4: | 5038 | case STAC_HP_M4: |
5149 | /* enable internal microphone */ | 5039 | /* enable internal microphone */ |
5150 | stac_change_pin_config(codec, 0x0e, 0x01813040); | 5040 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040); |
5151 | stac92xx_auto_set_pinctl(codec, 0x0e, | 5041 | stac92xx_auto_set_pinctl(codec, 0x0e, |
5152 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); | 5042 | AC_PINCTL_IN_EN | AC_PINCTL_VREF_80); |
5153 | /* fallthru */ | 5043 | /* fallthru */ |
@@ -5163,7 +5053,7 @@ again: | |||
5163 | spec->num_dmuxes = 0; | 5053 | spec->num_dmuxes = 0; |
5164 | break; | 5054 | break; |
5165 | case STAC_HP_DV5: | 5055 | case STAC_HP_DV5: |
5166 | stac_change_pin_config(codec, 0x0d, 0x90170010); | 5056 | snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010); |
5167 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); | 5057 | stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN); |
5168 | break; | 5058 | break; |
5169 | }; | 5059 | }; |
@@ -5247,17 +5137,12 @@ static int patch_stac922x(struct hda_codec *codec) | |||
5247 | } | 5137 | } |
5248 | 5138 | ||
5249 | again: | 5139 | again: |
5250 | if (spec->board_config < 0) { | 5140 | if (spec->board_config < 0) |
5251 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " | 5141 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, " |
5252 | "using BIOS defaults\n"); | 5142 | "using BIOS defaults\n"); |
5253 | err = stac92xx_save_bios_config_regs(codec); | 5143 | else |
5254 | } else | 5144 | stac92xx_set_config_regs(codec, |
5255 | err = stac_save_pin_cfgs(codec, | ||
5256 | stac922x_brd_tbl[spec->board_config]); | 5145 | stac922x_brd_tbl[spec->board_config]); |
5257 | if (err < 0) { | ||
5258 | stac92xx_free(codec); | ||
5259 | return err; | ||
5260 | } | ||
5261 | 5146 | ||
5262 | spec->adc_nids = stac922x_adc_nids; | 5147 | spec->adc_nids = stac922x_adc_nids; |
5263 | spec->mux_nids = stac922x_mux_nids; | 5148 | spec->mux_nids = stac922x_mux_nids; |
@@ -5315,17 +5200,12 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5315 | stac927x_models, | 5200 | stac927x_models, |
5316 | stac927x_cfg_tbl); | 5201 | stac927x_cfg_tbl); |
5317 | again: | 5202 | again: |
5318 | if (spec->board_config < 0) { | 5203 | if (spec->board_config < 0) |
5319 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" | 5204 | snd_printdd(KERN_INFO "hda_codec: Unknown model for" |
5320 | "STAC927x, using BIOS defaults\n"); | 5205 | "STAC927x, using BIOS defaults\n"); |
5321 | err = stac92xx_save_bios_config_regs(codec); | 5206 | else |
5322 | } else | 5207 | stac92xx_set_config_regs(codec, |
5323 | err = stac_save_pin_cfgs(codec, | ||
5324 | stac927x_brd_tbl[spec->board_config]); | 5208 | stac927x_brd_tbl[spec->board_config]); |
5325 | if (err < 0) { | ||
5326 | stac92xx_free(codec); | ||
5327 | return err; | ||
5328 | } | ||
5329 | 5209 | ||
5330 | spec->digbeep_nid = 0x23; | 5210 | spec->digbeep_nid = 0x23; |
5331 | spec->adc_nids = stac927x_adc_nids; | 5211 | spec->adc_nids = stac927x_adc_nids; |
@@ -5354,15 +5234,15 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5354 | case 0x10280209: | 5234 | case 0x10280209: |
5355 | case 0x1028022e: | 5235 | case 0x1028022e: |
5356 | /* correct the device field to SPDIF out */ | 5236 | /* correct the device field to SPDIF out */ |
5357 | stac_change_pin_config(codec, 0x21, 0x01442070); | 5237 | snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070); |
5358 | break; | 5238 | break; |
5359 | }; | 5239 | }; |
5360 | /* configure the analog microphone on some laptops */ | 5240 | /* configure the analog microphone on some laptops */ |
5361 | stac_change_pin_config(codec, 0x0c, 0x90a79130); | 5241 | snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130); |
5362 | /* correct the front output jack as a hp out */ | 5242 | /* correct the front output jack as a hp out */ |
5363 | stac_change_pin_config(codec, 0x0f, 0x0227011f); | 5243 | snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f); |
5364 | /* correct the front input jack as a mic */ | 5244 | /* correct the front input jack as a mic */ |
5365 | stac_change_pin_config(codec, 0x0e, 0x02a79130); | 5245 | snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130); |
5366 | /* fallthru */ | 5246 | /* fallthru */ |
5367 | case STAC_DELL_3ST: | 5247 | case STAC_DELL_3ST: |
5368 | /* GPIO2 High = Enable EAPD */ | 5248 | /* GPIO2 High = Enable EAPD */ |
@@ -5447,16 +5327,11 @@ static int patch_stac9205(struct hda_codec *codec) | |||
5447 | stac9205_models, | 5327 | stac9205_models, |
5448 | stac9205_cfg_tbl); | 5328 | stac9205_cfg_tbl); |
5449 | again: | 5329 | again: |
5450 | if (spec->board_config < 0) { | 5330 | if (spec->board_config < 0) |
5451 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); | 5331 | snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n"); |
5452 | err = stac92xx_save_bios_config_regs(codec); | 5332 | else |
5453 | } else | 5333 | stac92xx_set_config_regs(codec, |
5454 | err = stac_save_pin_cfgs(codec, | ||
5455 | stac9205_brd_tbl[spec->board_config]); | 5334 | stac9205_brd_tbl[spec->board_config]); |
5456 | if (err < 0) { | ||
5457 | stac92xx_free(codec); | ||
5458 | return err; | ||
5459 | } | ||
5460 | 5335 | ||
5461 | spec->digbeep_nid = 0x23; | 5336 | spec->digbeep_nid = 0x23; |
5462 | spec->adc_nids = stac9205_adc_nids; | 5337 | spec->adc_nids = stac9205_adc_nids; |
@@ -5484,8 +5359,8 @@ static int patch_stac9205(struct hda_codec *codec) | |||
5484 | switch (spec->board_config){ | 5359 | switch (spec->board_config){ |
5485 | case STAC_9205_DELL_M43: | 5360 | case STAC_9205_DELL_M43: |
5486 | /* Enable SPDIF in/out */ | 5361 | /* Enable SPDIF in/out */ |
5487 | stac_change_pin_config(codec, 0x1f, 0x01441030); | 5362 | snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030); |
5488 | stac_change_pin_config(codec, 0x20, 0x1c410030); | 5363 | snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030); |
5489 | 5364 | ||
5490 | /* Enable unsol response for GPIO4/Dock HP connection */ | 5365 | /* Enable unsol response for GPIO4/Dock HP connection */ |
5491 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); | 5366 | err = stac_add_event(spec, codec->afg, STAC_VREF_EVENT, 0x01); |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 639b2ff510a6..b25a5cc637d6 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -1308,16 +1308,13 @@ static void vt1708_set_pinconfig_connect(struct hda_codec *codec, hda_nid_t nid) | |||
1308 | unsigned int def_conf; | 1308 | unsigned int def_conf; |
1309 | unsigned char seqassoc; | 1309 | unsigned char seqassoc; |
1310 | 1310 | ||
1311 | def_conf = snd_hda_codec_read(codec, nid, 0, | 1311 | def_conf = snd_hda_codec_get_pincfg(codec, nid); |
1312 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
1313 | seqassoc = (unsigned char) get_defcfg_association(def_conf); | 1312 | seqassoc = (unsigned char) get_defcfg_association(def_conf); |
1314 | seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf); | 1313 | seqassoc = (seqassoc << 4) | get_defcfg_sequence(def_conf); |
1315 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) { | 1314 | if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE) { |
1316 | if (seqassoc == 0xff) { | 1315 | if (seqassoc == 0xff) { |
1317 | def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30)); | 1316 | def_conf = def_conf & (~(AC_JACK_PORT_BOTH << 30)); |
1318 | snd_hda_codec_write(codec, nid, 0, | 1317 | snd_hda_codec_set_pincfg(codec, nid, def_conf); |
1319 | AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, | ||
1320 | def_conf >> 24); | ||
1321 | } | 1318 | } |
1322 | } | 1319 | } |
1323 | 1320 | ||