aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_via.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/patch_via.c')
-rw-r--r--sound/pci/hda/patch_via.c274
1 files changed, 166 insertions, 108 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index b70e26ad263f..9ddc37300f6b 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -54,6 +54,8 @@
54#include "hda_codec.h" 54#include "hda_codec.h"
55#include "hda_local.h" 55#include "hda_local.h"
56 56
57#define NID_MAPPING (-1)
58
57/* amp values */ 59/* amp values */
58#define AMP_VAL_IDX_SHIFT 19 60#define AMP_VAL_IDX_SHIFT 19
59#define AMP_VAL_IDX_MASK (0x0f<<19) 61#define AMP_VAL_IDX_MASK (0x0f<<19)
@@ -157,6 +159,19 @@ struct via_spec {
157#endif 159#endif
158}; 160};
159 161
162static struct via_spec * via_new_spec(struct hda_codec *codec)
163{
164 struct via_spec *spec;
165
166 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
167 if (spec == NULL)
168 return NULL;
169
170 codec->spec = spec;
171 spec->codec = codec;
172 return spec;
173}
174
160static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec) 175static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
161{ 176{
162 u32 vendor_id = codec->vendor_id; 177 u32 vendor_id = codec->vendor_id;
@@ -443,11 +458,27 @@ static int via_add_control(struct via_spec *spec, int type, const char *name,
443 if (!knew->name) 458 if (!knew->name)
444 return -ENOMEM; 459 return -ENOMEM;
445 if (get_amp_nid_(val)) 460 if (get_amp_nid_(val))
446 knew->subdevice = HDA_SUBDEV_NID_FLAG | get_amp_nid_(val); 461 knew->subdevice = HDA_SUBDEV_AMP_FLAG;
447 knew->private_value = val; 462 knew->private_value = val;
448 return 0; 463 return 0;
449} 464}
450 465
466static struct snd_kcontrol_new *via_clone_control(struct via_spec *spec,
467 struct snd_kcontrol_new *tmpl)
468{
469 struct snd_kcontrol_new *knew;
470
471 snd_array_init(&spec->kctls, sizeof(*knew), 32);
472 knew = snd_array_new(&spec->kctls);
473 if (!knew)
474 return NULL;
475 *knew = *tmpl;
476 knew->name = kstrdup(tmpl->name, GFP_KERNEL);
477 if (!knew->name)
478 return NULL;
479 return 0;
480}
481
451static void via_free_kctls(struct hda_codec *codec) 482static void via_free_kctls(struct hda_codec *codec)
452{ 483{
453 struct via_spec *spec = codec->spec; 484 struct via_spec *spec = codec->spec;
@@ -1088,24 +1119,9 @@ static int via_independent_hp_get(struct snd_kcontrol *kcontrol,
1088 struct snd_ctl_elem_value *ucontrol) 1119 struct snd_ctl_elem_value *ucontrol)
1089{ 1120{
1090 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1121 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1091 struct via_spec *spec = codec->spec; 1122 hda_nid_t nid = kcontrol->private_value;
1092 hda_nid_t nid;
1093 unsigned int pinsel; 1123 unsigned int pinsel;
1094 1124
1095 switch (spec->codec_type) {
1096 case VT1718S:
1097 nid = 0x34;
1098 break;
1099 case VT2002P:
1100 nid = 0x35;
1101 break;
1102 case VT1812:
1103 nid = 0x3d;
1104 break;
1105 default:
1106 nid = spec->autocfg.hp_pins[0];
1107 break;
1108 }
1109 /* use !! to translate conn sel 2 for VT1718S */ 1125 /* use !! to translate conn sel 2 for VT1718S */
1110 pinsel = !!snd_hda_codec_read(codec, nid, 0, 1126 pinsel = !!snd_hda_codec_read(codec, nid, 0,
1111 AC_VERB_GET_CONNECT_SEL, 1127 AC_VERB_GET_CONNECT_SEL,
@@ -1127,29 +1143,24 @@ static void activate_ctl(struct hda_codec *codec, const char *name, int active)
1127 } 1143 }
1128} 1144}
1129 1145
1146static hda_nid_t side_mute_channel(struct via_spec *spec)
1147{
1148 switch (spec->codec_type) {
1149 case VT1708: return 0x1b;
1150 case VT1709_10CH: return 0x29;
1151 case VT1708B_8CH: /* fall thru */
1152 case VT1708S: return 0x27;
1153 default: return 0;
1154 }
1155}
1156
1130static int update_side_mute_status(struct hda_codec *codec) 1157static int update_side_mute_status(struct hda_codec *codec)
1131{ 1158{
1132 /* mute side channel */ 1159 /* mute side channel */
1133 struct via_spec *spec = codec->spec; 1160 struct via_spec *spec = codec->spec;
1134 unsigned int parm = spec->hp_independent_mode 1161 unsigned int parm = spec->hp_independent_mode
1135 ? AMP_OUT_MUTE : AMP_OUT_UNMUTE; 1162 ? AMP_OUT_MUTE : AMP_OUT_UNMUTE;
1136 hda_nid_t sw3; 1163 hda_nid_t sw3 = side_mute_channel(spec);
1137
1138 switch (spec->codec_type) {
1139 case VT1708:
1140 sw3 = 0x1b;
1141 break;
1142 case VT1709_10CH:
1143 sw3 = 0x29;
1144 break;
1145 case VT1708B_8CH:
1146 case VT1708S:
1147 sw3 = 0x27;
1148 break;
1149 default:
1150 sw3 = 0;
1151 break;
1152 }
1153 1164
1154 if (sw3) 1165 if (sw3)
1155 snd_hda_codec_write(codec, sw3, 0, AC_VERB_SET_AMP_GAIN_MUTE, 1166 snd_hda_codec_write(codec, sw3, 0, AC_VERB_SET_AMP_GAIN_MUTE,
@@ -1162,28 +1173,11 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol,
1162{ 1173{
1163 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1174 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
1164 struct via_spec *spec = codec->spec; 1175 struct via_spec *spec = codec->spec;
1165 hda_nid_t nid = spec->autocfg.hp_pins[0]; 1176 hda_nid_t nid = kcontrol->private_value;
1166 unsigned int pinsel = ucontrol->value.enumerated.item[0]; 1177 unsigned int pinsel = ucontrol->value.enumerated.item[0];
1167 /* Get Independent Mode index of headphone pin widget */ 1178 /* Get Independent Mode index of headphone pin widget */
1168 spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel 1179 spec->hp_independent_mode = spec->hp_independent_mode_index == pinsel
1169 ? 1 : 0; 1180 ? 1 : 0;
1170
1171 switch (spec->codec_type) {
1172 case VT1718S:
1173 nid = 0x34;
1174 pinsel = pinsel ? 2 : 0; /* indep HP use AOW4 (index 2) */
1175 spec->multiout.num_dacs = 4;
1176 break;
1177 case VT2002P:
1178 nid = 0x35;
1179 break;
1180 case VT1812:
1181 nid = 0x3d;
1182 break;
1183 default:
1184 nid = spec->autocfg.hp_pins[0];
1185 break;
1186 }
1187 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel); 1181 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, pinsel);
1188 1182
1189 if (spec->multiout.hp_nid && spec->multiout.hp_nid 1183 if (spec->multiout.hp_nid && spec->multiout.hp_nid
@@ -1207,18 +1201,55 @@ static int via_independent_hp_put(struct snd_kcontrol *kcontrol,
1207 return 0; 1201 return 0;
1208} 1202}
1209 1203
1210static struct snd_kcontrol_new via_hp_mixer[] = { 1204static struct snd_kcontrol_new via_hp_mixer[2] = {
1211 { 1205 {
1212 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1206 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1213 .name = "Independent HP", 1207 .name = "Independent HP",
1214 .count = 1,
1215 .info = via_independent_hp_info, 1208 .info = via_independent_hp_info,
1216 .get = via_independent_hp_get, 1209 .get = via_independent_hp_get,
1217 .put = via_independent_hp_put, 1210 .put = via_independent_hp_put,
1218 }, 1211 },
1219 { } /* end */ 1212 {
1213 .iface = NID_MAPPING,
1214 .name = "Independent HP",
1215 },
1220}; 1216};
1221 1217
1218static int via_hp_build(struct via_spec *spec)
1219{
1220 struct snd_kcontrol_new *knew;
1221 hda_nid_t nid;
1222
1223 knew = via_clone_control(spec, &via_hp_mixer[0]);
1224 if (knew == NULL)
1225 return -ENOMEM;
1226
1227 switch (spec->codec_type) {
1228 case VT1718S:
1229 nid = 0x34;
1230 break;
1231 case VT2002P:
1232 nid = 0x35;
1233 break;
1234 case VT1812:
1235 nid = 0x3d;
1236 break;
1237 default:
1238 nid = spec->autocfg.hp_pins[0];
1239 break;
1240 }
1241
1242 knew->subdevice = HDA_SUBDEV_NID_FLAG | nid;
1243 knew->private_value = nid;
1244
1245 knew = via_clone_control(spec, &via_hp_mixer[1]);
1246 if (knew == NULL)
1247 return -ENOMEM;
1248 knew->subdevice = side_mute_channel(spec);
1249
1250 return 0;
1251}
1252
1222static void notify_aa_path_ctls(struct hda_codec *codec) 1253static void notify_aa_path_ctls(struct hda_codec *codec)
1223{ 1254{
1224 int i; 1255 int i;
@@ -1376,7 +1407,7 @@ static int via_smart51_put(struct snd_kcontrol *kcontrol,
1376 return 1; 1407 return 1;
1377} 1408}
1378 1409
1379static struct snd_kcontrol_new via_smart51_mixer[] = { 1410static struct snd_kcontrol_new via_smart51_mixer[2] = {
1380 { 1411 {
1381 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1412 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1382 .name = "Smart 5.1", 1413 .name = "Smart 5.1",
@@ -1385,9 +1416,36 @@ static struct snd_kcontrol_new via_smart51_mixer[] = {
1385 .get = via_smart51_get, 1416 .get = via_smart51_get,
1386 .put = via_smart51_put, 1417 .put = via_smart51_put,
1387 }, 1418 },
1388 {} /* end */ 1419 {
1420 .iface = NID_MAPPING,
1421 .name = "Smart 5.1",
1422 }
1389}; 1423};
1390 1424
1425static int via_smart51_build(struct via_spec *spec)
1426{
1427 struct snd_kcontrol_new *knew;
1428 int index[] = { AUTO_PIN_MIC, AUTO_PIN_FRONT_MIC, AUTO_PIN_LINE };
1429 hda_nid_t nid;
1430 int i;
1431
1432 knew = via_clone_control(spec, &via_smart51_mixer[0]);
1433 if (knew == NULL)
1434 return -ENOMEM;
1435
1436 for (i = 0; i < ARRAY_SIZE(index); i++) {
1437 nid = spec->autocfg.input_pins[index[i]];
1438 if (nid) {
1439 knew = via_clone_control(spec, &via_smart51_mixer[1]);
1440 if (knew == NULL)
1441 return -ENOMEM;
1442 knew->subdevice = nid;
1443 }
1444 }
1445
1446 return 0;
1447}
1448
1391/* capture mixer elements */ 1449/* capture mixer elements */
1392static struct snd_kcontrol_new vt1708_capture_mixer[] = { 1450static struct snd_kcontrol_new vt1708_capture_mixer[] = {
1393 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT), 1451 HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_INPUT),
@@ -1819,8 +1877,9 @@ static struct hda_pcm_stream vt1708_pcm_digital_capture = {
1819static int via_build_controls(struct hda_codec *codec) 1877static int via_build_controls(struct hda_codec *codec)
1820{ 1878{
1821 struct via_spec *spec = codec->spec; 1879 struct via_spec *spec = codec->spec;
1822 int err; 1880 struct snd_kcontrol *kctl;
1823 int i; 1881 struct snd_kcontrol_new *knew;
1882 int err, i;
1824 1883
1825 for (i = 0; i < spec->num_mixers; i++) { 1884 for (i = 0; i < spec->num_mixers; i++) {
1826 err = snd_hda_add_new_ctls(codec, spec->mixers[i]); 1885 err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
@@ -1845,6 +1904,27 @@ static int via_build_controls(struct hda_codec *codec)
1845 return err; 1904 return err;
1846 } 1905 }
1847 1906
1907 /* assign Capture Source enums to NID */
1908 kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
1909 for (i = 0; kctl && i < kctl->count; i++) {
1910 err = snd_hda_add_nid(codec, kctl, i, spec->mux_nids[i]);
1911 if (err < 0)
1912 return err;
1913 }
1914
1915 /* other nid->control mapping */
1916 for (i = 0; i < spec->num_mixers; i++) {
1917 for (knew = spec->mixers[i]; knew->name; knew++) {
1918 if (knew->iface != NID_MAPPING)
1919 continue;
1920 kctl = snd_hda_find_mixer_ctl(codec, knew->name);
1921 if (kctl == NULL)
1922 continue;
1923 err = snd_hda_add_nid(codec, kctl, 0,
1924 knew->subdevice);
1925 }
1926 }
1927
1848 /* init power states */ 1928 /* init power states */
1849 set_jack_power_state(codec); 1929 set_jack_power_state(codec);
1850 analog_low_current_mode(codec, 1); 1930 analog_low_current_mode(codec, 1);
@@ -2481,9 +2561,9 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
2481 spec->input_mux = &spec->private_imux[0]; 2561 spec->input_mux = &spec->private_imux[0];
2482 2562
2483 if (spec->hp_mux) 2563 if (spec->hp_mux)
2484 spec->mixers[spec->num_mixers++] = via_hp_mixer; 2564 via_hp_build(spec);
2485 2565
2486 spec->mixers[spec->num_mixers++] = via_smart51_mixer; 2566 via_smart51_build(spec);
2487 return 1; 2567 return 1;
2488} 2568}
2489 2569
@@ -2554,12 +2634,10 @@ static int patch_vt1708(struct hda_codec *codec)
2554 int err; 2634 int err;
2555 2635
2556 /* create a codec specific record */ 2636 /* create a codec specific record */
2557 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 2637 spec = via_new_spec(codec);
2558 if (spec == NULL) 2638 if (spec == NULL)
2559 return -ENOMEM; 2639 return -ENOMEM;
2560 2640
2561 codec->spec = spec;
2562
2563 /* automatic parse from the BIOS config */ 2641 /* automatic parse from the BIOS config */
2564 err = vt1708_parse_auto_config(codec); 2642 err = vt1708_parse_auto_config(codec);
2565 if (err < 0) { 2643 if (err < 0) {
@@ -2597,7 +2675,6 @@ static int patch_vt1708(struct hda_codec *codec)
2597#ifdef CONFIG_SND_HDA_POWER_SAVE 2675#ifdef CONFIG_SND_HDA_POWER_SAVE
2598 spec->loopback.amplist = vt1708_loopbacks; 2676 spec->loopback.amplist = vt1708_loopbacks;
2599#endif 2677#endif
2600 spec->codec = codec;
2601 INIT_DELAYED_WORK(&spec->vt1708_hp_work, vt1708_update_hp_jack_state); 2678 INIT_DELAYED_WORK(&spec->vt1708_hp_work, vt1708_update_hp_jack_state);
2602 return 0; 2679 return 0;
2603} 2680}
@@ -3010,9 +3087,9 @@ static int vt1709_parse_auto_config(struct hda_codec *codec)
3010 spec->input_mux = &spec->private_imux[0]; 3087 spec->input_mux = &spec->private_imux[0];
3011 3088
3012 if (spec->hp_mux) 3089 if (spec->hp_mux)
3013 spec->mixers[spec->num_mixers++] = via_hp_mixer; 3090 via_hp_build(spec);
3014 3091
3015 spec->mixers[spec->num_mixers++] = via_smart51_mixer; 3092 via_smart51_build(spec);
3016 return 1; 3093 return 1;
3017} 3094}
3018 3095
@@ -3032,12 +3109,10 @@ static int patch_vt1709_10ch(struct hda_codec *codec)
3032 int err; 3109 int err;
3033 3110
3034 /* create a codec specific record */ 3111 /* create a codec specific record */
3035 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3112 spec = via_new_spec(codec);
3036 if (spec == NULL) 3113 if (spec == NULL)
3037 return -ENOMEM; 3114 return -ENOMEM;
3038 3115
3039 codec->spec = spec;
3040
3041 err = vt1709_parse_auto_config(codec); 3116 err = vt1709_parse_auto_config(codec);
3042 if (err < 0) { 3117 if (err < 0) {
3043 via_free(codec); 3118 via_free(codec);
@@ -3126,12 +3201,10 @@ static int patch_vt1709_6ch(struct hda_codec *codec)
3126 int err; 3201 int err;
3127 3202
3128 /* create a codec specific record */ 3203 /* create a codec specific record */
3129 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3204 spec = via_new_spec(codec);
3130 if (spec == NULL) 3205 if (spec == NULL)
3131 return -ENOMEM; 3206 return -ENOMEM;
3132 3207
3133 codec->spec = spec;
3134
3135 err = vt1709_parse_auto_config(codec); 3208 err = vt1709_parse_auto_config(codec);
3136 if (err < 0) { 3209 if (err < 0) {
3137 via_free(codec); 3210 via_free(codec);
@@ -3581,9 +3654,9 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec)
3581 spec->input_mux = &spec->private_imux[0]; 3654 spec->input_mux = &spec->private_imux[0];
3582 3655
3583 if (spec->hp_mux) 3656 if (spec->hp_mux)
3584 spec->mixers[spec->num_mixers++] = via_hp_mixer; 3657 via_hp_build(spec);
3585 3658
3586 spec->mixers[spec->num_mixers++] = via_smart51_mixer; 3659 via_smart51_build(spec);
3587 return 1; 3660 return 1;
3588} 3661}
3589 3662
@@ -3605,12 +3678,10 @@ static int patch_vt1708B_8ch(struct hda_codec *codec)
3605 if (get_codec_type(codec) == VT1708BCE) 3678 if (get_codec_type(codec) == VT1708BCE)
3606 return patch_vt1708S(codec); 3679 return patch_vt1708S(codec);
3607 /* create a codec specific record */ 3680 /* create a codec specific record */
3608 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3681 spec = via_new_spec(codec);
3609 if (spec == NULL) 3682 if (spec == NULL)
3610 return -ENOMEM; 3683 return -ENOMEM;
3611 3684
3612 codec->spec = spec;
3613
3614 /* automatic parse from the BIOS config */ 3685 /* automatic parse from the BIOS config */
3615 err = vt1708B_parse_auto_config(codec); 3686 err = vt1708B_parse_auto_config(codec);
3616 if (err < 0) { 3687 if (err < 0) {
@@ -3657,12 +3728,10 @@ static int patch_vt1708B_4ch(struct hda_codec *codec)
3657 int err; 3728 int err;
3658 3729
3659 /* create a codec specific record */ 3730 /* create a codec specific record */
3660 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 3731 spec = via_new_spec(codec);
3661 if (spec == NULL) 3732 if (spec == NULL)
3662 return -ENOMEM; 3733 return -ENOMEM;
3663 3734
3664 codec->spec = spec;
3665
3666 /* automatic parse from the BIOS config */ 3735 /* automatic parse from the BIOS config */
3667 err = vt1708B_parse_auto_config(codec); 3736 err = vt1708B_parse_auto_config(codec);
3668 if (err < 0) { 3737 if (err < 0) {
@@ -4071,9 +4140,9 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec)
4071 spec->input_mux = &spec->private_imux[0]; 4140 spec->input_mux = &spec->private_imux[0];
4072 4141
4073 if (spec->hp_mux) 4142 if (spec->hp_mux)
4074 spec->mixers[spec->num_mixers++] = via_hp_mixer; 4143 via_hp_build(spec);
4075 4144
4076 spec->mixers[spec->num_mixers++] = via_smart51_mixer; 4145 via_smart51_build(spec);
4077 return 1; 4146 return 1;
4078} 4147}
4079 4148
@@ -4103,12 +4172,10 @@ static int patch_vt1708S(struct hda_codec *codec)
4103 int err; 4172 int err;
4104 4173
4105 /* create a codec specific record */ 4174 /* create a codec specific record */
4106 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4175 spec = via_new_spec(codec);
4107 if (spec == NULL) 4176 if (spec == NULL)
4108 return -ENOMEM; 4177 return -ENOMEM;
4109 4178
4110 codec->spec = spec;
4111
4112 /* automatic parse from the BIOS config */ 4179 /* automatic parse from the BIOS config */
4113 err = vt1708S_parse_auto_config(codec); 4180 err = vt1708S_parse_auto_config(codec);
4114 if (err < 0) { 4181 if (err < 0) {
@@ -4443,7 +4510,7 @@ static int vt1702_parse_auto_config(struct hda_codec *codec)
4443 spec->input_mux = &spec->private_imux[0]; 4510 spec->input_mux = &spec->private_imux[0];
4444 4511
4445 if (spec->hp_mux) 4512 if (spec->hp_mux)
4446 spec->mixers[spec->num_mixers++] = via_hp_mixer; 4513 via_hp_build(spec);
4447 4514
4448 return 1; 4515 return 1;
4449} 4516}
@@ -4464,12 +4531,10 @@ static int patch_vt1702(struct hda_codec *codec)
4464 int err; 4531 int err;
4465 4532
4466 /* create a codec specific record */ 4533 /* create a codec specific record */
4467 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4534 spec = via_new_spec(codec);
4468 if (spec == NULL) 4535 if (spec == NULL)
4469 return -ENOMEM; 4536 return -ENOMEM;
4470 4537
4471 codec->spec = spec;
4472
4473 /* automatic parse from the BIOS config */ 4538 /* automatic parse from the BIOS config */
4474 err = vt1702_parse_auto_config(codec); 4539 err = vt1702_parse_auto_config(codec);
4475 if (err < 0) { 4540 if (err < 0) {
@@ -4865,9 +4930,9 @@ static int vt1718S_parse_auto_config(struct hda_codec *codec)
4865 spec->input_mux = &spec->private_imux[0]; 4930 spec->input_mux = &spec->private_imux[0];
4866 4931
4867 if (spec->hp_mux) 4932 if (spec->hp_mux)
4868 spec->mixers[spec->num_mixers++] = via_hp_mixer; 4933 via_hp_build(spec);
4869 4934
4870 spec->mixers[spec->num_mixers++] = via_smart51_mixer; 4935 via_smart51_build(spec);
4871 4936
4872 return 1; 4937 return 1;
4873} 4938}
@@ -4888,12 +4953,10 @@ static int patch_vt1718S(struct hda_codec *codec)
4888 int err; 4953 int err;
4889 4954
4890 /* create a codec specific record */ 4955 /* create a codec specific record */
4891 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 4956 spec = via_new_spec(codec);
4892 if (spec == NULL) 4957 if (spec == NULL)
4893 return -ENOMEM; 4958 return -ENOMEM;
4894 4959
4895 codec->spec = spec;
4896
4897 /* automatic parse from the BIOS config */ 4960 /* automatic parse from the BIOS config */
4898 err = vt1718S_parse_auto_config(codec); 4961 err = vt1718S_parse_auto_config(codec);
4899 if (err < 0) { 4962 if (err < 0) {
@@ -5014,6 +5077,7 @@ static struct snd_kcontrol_new vt1716s_dmic_mixer[] = {
5014 { 5077 {
5015 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 5078 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
5016 .name = "Digital Mic Capture Switch", 5079 .name = "Digital Mic Capture Switch",
5080 .subdevice = HDA_SUBDEV_NID_FLAG | 0x26,
5017 .count = 1, 5081 .count = 1,
5018 .info = vt1716s_dmic_info, 5082 .info = vt1716s_dmic_info,
5019 .get = vt1716s_dmic_get, 5083 .get = vt1716s_dmic_get,
@@ -5361,9 +5425,9 @@ static int vt1716S_parse_auto_config(struct hda_codec *codec)
5361 spec->input_mux = &spec->private_imux[0]; 5425 spec->input_mux = &spec->private_imux[0];
5362 5426
5363 if (spec->hp_mux) 5427 if (spec->hp_mux)
5364 spec->mixers[spec->num_mixers++] = via_hp_mixer; 5428 via_hp_build(spec);
5365 5429
5366 spec->mixers[spec->num_mixers++] = via_smart51_mixer; 5430 via_smart51_build(spec);
5367 5431
5368 return 1; 5432 return 1;
5369} 5433}
@@ -5384,12 +5448,10 @@ static int patch_vt1716S(struct hda_codec *codec)
5384 int err; 5448 int err;
5385 5449
5386 /* create a codec specific record */ 5450 /* create a codec specific record */
5387 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5451 spec = via_new_spec(codec);
5388 if (spec == NULL) 5452 if (spec == NULL)
5389 return -ENOMEM; 5453 return -ENOMEM;
5390 5454
5391 codec->spec = spec;
5392
5393 /* automatic parse from the BIOS config */ 5455 /* automatic parse from the BIOS config */
5394 err = vt1716S_parse_auto_config(codec); 5456 err = vt1716S_parse_auto_config(codec);
5395 if (err < 0) { 5457 if (err < 0) {
@@ -5719,7 +5781,7 @@ static int vt2002P_parse_auto_config(struct hda_codec *codec)
5719 spec->input_mux = &spec->private_imux[0]; 5781 spec->input_mux = &spec->private_imux[0];
5720 5782
5721 if (spec->hp_mux) 5783 if (spec->hp_mux)
5722 spec->mixers[spec->num_mixers++] = via_hp_mixer; 5784 via_hp_build(spec);
5723 5785
5724 return 1; 5786 return 1;
5725} 5787}
@@ -5741,12 +5803,10 @@ static int patch_vt2002P(struct hda_codec *codec)
5741 int err; 5803 int err;
5742 5804
5743 /* create a codec specific record */ 5805 /* create a codec specific record */
5744 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 5806 spec = via_new_spec(codec);
5745 if (spec == NULL) 5807 if (spec == NULL)
5746 return -ENOMEM; 5808 return -ENOMEM;
5747 5809
5748 codec->spec = spec;
5749
5750 /* automatic parse from the BIOS config */ 5810 /* automatic parse from the BIOS config */
5751 err = vt2002P_parse_auto_config(codec); 5811 err = vt2002P_parse_auto_config(codec);
5752 if (err < 0) { 5812 if (err < 0) {
@@ -6070,7 +6130,7 @@ static int vt1812_parse_auto_config(struct hda_codec *codec)
6070 spec->input_mux = &spec->private_imux[0]; 6130 spec->input_mux = &spec->private_imux[0];
6071 6131
6072 if (spec->hp_mux) 6132 if (spec->hp_mux)
6073 spec->mixers[spec->num_mixers++] = via_hp_mixer; 6133 via_hp_build(spec);
6074 6134
6075 return 1; 6135 return 1;
6076} 6136}
@@ -6092,12 +6152,10 @@ static int patch_vt1812(struct hda_codec *codec)
6092 int err; 6152 int err;
6093 6153
6094 /* create a codec specific record */ 6154 /* create a codec specific record */
6095 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 6155 spec = via_new_spec(codec);
6096 if (spec == NULL) 6156 if (spec == NULL)
6097 return -ENOMEM; 6157 return -ENOMEM;
6098 6158
6099 codec->spec = spec;
6100
6101 /* automatic parse from the BIOS config */ 6159 /* automatic parse from the BIOS config */
6102 err = vt1812_parse_auto_config(codec); 6160 err = vt1812_parse_auto_config(codec);
6103 if (err < 0) { 6161 if (err < 0) {