aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_codec.c76
-rw-r--r--sound/pci/hda/hda_codec.h3
-rw-r--r--sound/pci/hda/hda_intel.c24
-rw-r--r--sound/pci/hda/patch_analog.c21
-rw-r--r--sound/pci/hda/patch_realtek.c233
5 files changed, 280 insertions, 77 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 0e76ac2b2ac..a3d638c8c1f 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -1209,8 +1209,7 @@ static void free_hda_cache(struct hda_cache_rec *cache)
1209} 1209}
1210 1210
1211/* query the hash. allocate an entry if not found. */ 1211/* query the hash. allocate an entry if not found. */
1212static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache, 1212static struct hda_cache_head *get_hash(struct hda_cache_rec *cache, u32 key)
1213 u32 key)
1214{ 1213{
1215 u16 idx = key % (u16)ARRAY_SIZE(cache->hash); 1214 u16 idx = key % (u16)ARRAY_SIZE(cache->hash);
1216 u16 cur = cache->hash[idx]; 1215 u16 cur = cache->hash[idx];
@@ -1222,17 +1221,27 @@ static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache,
1222 return info; 1221 return info;
1223 cur = info->next; 1222 cur = info->next;
1224 } 1223 }
1224 return NULL;
1225}
1225 1226
1226 /* add a new hash entry */ 1227/* query the hash. allocate an entry if not found. */
1227 info = snd_array_new(&cache->buf); 1228static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache,
1228 if (!info) 1229 u32 key)
1229 return NULL; 1230{
1230 cur = snd_array_index(&cache->buf, info); 1231 struct hda_cache_head *info = get_hash(cache, key);
1231 info->key = key; 1232 if (!info) {
1232 info->val = 0; 1233 u16 idx, cur;
1233 info->next = cache->hash[idx]; 1234 /* add a new hash entry */
1234 cache->hash[idx] = cur; 1235 info = snd_array_new(&cache->buf);
1235 1236 if (!info)
1237 return NULL;
1238 cur = snd_array_index(&cache->buf, info);
1239 info->key = key;
1240 info->val = 0;
1241 idx = key % (u16)ARRAY_SIZE(cache->hash);
1242 info->next = cache->hash[idx];
1243 cache->hash[idx] = cur;
1244 }
1236 return info; 1245 return info;
1237} 1246}
1238 1247
@@ -1461,6 +1470,8 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
1461 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx)); 1470 info = get_alloc_amp_hash(codec, HDA_HASH_KEY(nid, direction, idx));
1462 if (!info) 1471 if (!info)
1463 return 0; 1472 return 0;
1473 if (snd_BUG_ON(mask & ~0xff))
1474 mask &= 0xff;
1464 val &= mask; 1475 val &= mask;
1465 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; 1476 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
1466 if (info->vol[ch] == val) 1477 if (info->vol[ch] == val)
@@ -1486,6 +1497,9 @@ int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
1486 int direction, int idx, int mask, int val) 1497 int direction, int idx, int mask, int val)
1487{ 1498{
1488 int ch, ret = 0; 1499 int ch, ret = 0;
1500
1501 if (snd_BUG_ON(mask & ~0xff))
1502 mask &= 0xff;
1489 for (ch = 0; ch < 2; ch++) 1503 for (ch = 0; ch < 2; ch++)
1490 ret |= snd_hda_codec_amp_update(codec, nid, ch, direction, 1504 ret |= snd_hda_codec_amp_update(codec, nid, ch, direction,
1491 idx, mask, val); 1505 idx, mask, val);
@@ -2717,6 +2731,41 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
2717EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); 2731EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache);
2718 2732
2719/** 2733/**
2734 * snd_hda_codec_update_cache - check cache and write the cmd only when needed
2735 * @codec: the HDA codec
2736 * @nid: NID to send the command
2737 * @direct: direct flag
2738 * @verb: the verb to send
2739 * @parm: the parameter for the verb
2740 *
2741 * This function works like snd_hda_codec_write_cache(), but it doesn't send
2742 * command if the parameter is already identical with the cached value.
2743 * If not, it sends the command and refreshes the cache.
2744 *
2745 * Returns 0 if successful, or a negative error code.
2746 */
2747int snd_hda_codec_update_cache(struct hda_codec *codec, hda_nid_t nid,
2748 int direct, unsigned int verb, unsigned int parm)
2749{
2750 struct hda_cache_head *c;
2751 u32 key;
2752
2753 /* parm may contain the verb stuff for get/set amp */
2754 verb = verb | (parm >> 8);
2755 parm &= 0xff;
2756 key = build_cmd_cache_key(nid, verb);
2757 mutex_lock(&codec->bus->cmd_mutex);
2758 c = get_hash(&codec->cmd_cache, key);
2759 if (c && c->val == parm) {
2760 mutex_unlock(&codec->bus->cmd_mutex);
2761 return 0;
2762 }
2763 mutex_unlock(&codec->bus->cmd_mutex);
2764 return snd_hda_codec_write_cache(codec, nid, direct, verb, parm);
2765}
2766EXPORT_SYMBOL_HDA(snd_hda_codec_update_cache);
2767
2768/**
2720 * snd_hda_codec_resume_cache - Resume the all commands from the cache 2769 * snd_hda_codec_resume_cache - Resume the all commands from the cache
2721 * @codec: HD-audio codec 2770 * @codec: HD-audio codec
2722 * 2771 *
@@ -4218,7 +4267,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4218 break; 4267 break;
4219 case AC_JACK_MIC_IN: { 4268 case AC_JACK_MIC_IN: {
4220 int preferred, alt; 4269 int preferred, alt;
4221 if (loc == AC_JACK_LOC_FRONT) { 4270 if (loc == AC_JACK_LOC_FRONT ||
4271 (loc & 0x30) == AC_JACK_LOC_INTERNAL) {
4222 preferred = AUTO_PIN_FRONT_MIC; 4272 preferred = AUTO_PIN_FRONT_MIC;
4223 alt = AUTO_PIN_MIC; 4273 alt = AUTO_PIN_MIC;
4224 } else { 4274 } else {
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index b75da47571e..49e939e7e5c 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -885,9 +885,12 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
885 int direct, unsigned int verb, unsigned int parm); 885 int direct, unsigned int verb, unsigned int parm);
886void snd_hda_sequence_write_cache(struct hda_codec *codec, 886void snd_hda_sequence_write_cache(struct hda_codec *codec,
887 const struct hda_verb *seq); 887 const struct hda_verb *seq);
888int snd_hda_codec_update_cache(struct hda_codec *codec, hda_nid_t nid,
889 int direct, unsigned int verb, unsigned int parm);
888void snd_hda_codec_resume_cache(struct hda_codec *codec); 890void snd_hda_codec_resume_cache(struct hda_codec *codec);
889#else 891#else
890#define snd_hda_codec_write_cache snd_hda_codec_write 892#define snd_hda_codec_write_cache snd_hda_codec_write
893#define snd_hda_codec_update_cache snd_hda_codec_write
891#define snd_hda_sequence_write_cache snd_hda_sequence_write 894#define snd_hda_sequence_write_cache snd_hda_sequence_write
892#endif 895#endif
893 896
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index f8fd586ae02..6fe07d1c9de 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -84,7 +84,7 @@ module_param_array(bdl_pos_adj, int, NULL, 0644);
84MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset."); 84MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset.");
85module_param_array(probe_mask, int, NULL, 0444); 85module_param_array(probe_mask, int, NULL, 0444);
86MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); 86MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1).");
87module_param_array(probe_only, bool, NULL, 0444); 87module_param_array(probe_only, int, NULL, 0444);
88MODULE_PARM_DESC(probe_only, "Only probing and no codec initialization."); 88MODULE_PARM_DESC(probe_only, "Only probing and no codec initialization.");
89module_param(single_cmd, bool, 0444); 89module_param(single_cmd, bool, 0444);
90MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " 90MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs "
@@ -858,10 +858,13 @@ static void azx_power_notify(struct hda_bus *bus);
858#endif 858#endif
859 859
860/* reset codec link */ 860/* reset codec link */
861static int azx_reset(struct azx *chip) 861static int azx_reset(struct azx *chip, int full_reset)
862{ 862{
863 int count; 863 int count;
864 864
865 if (!full_reset)
866 goto __skip;
867
865 /* clear STATESTS */ 868 /* clear STATESTS */
866 azx_writeb(chip, STATESTS, STATESTS_INT_MASK); 869 azx_writeb(chip, STATESTS, STATESTS_INT_MASK);
867 870
@@ -887,6 +890,7 @@ static int azx_reset(struct azx *chip)
887 /* Brent Chartrand said to wait >= 540us for codecs to initialize */ 890 /* Brent Chartrand said to wait >= 540us for codecs to initialize */
888 msleep(1); 891 msleep(1);
889 892
893 __skip:
890 /* check to see if controller is ready */ 894 /* check to see if controller is ready */
891 if (!azx_readb(chip, GCTL)) { 895 if (!azx_readb(chip, GCTL)) {
892 snd_printd(SFX "azx_reset: controller not ready!\n"); 896 snd_printd(SFX "azx_reset: controller not ready!\n");
@@ -998,13 +1002,13 @@ static void azx_stream_stop(struct azx *chip, struct azx_dev *azx_dev)
998/* 1002/*
999 * reset and start the controller registers 1003 * reset and start the controller registers
1000 */ 1004 */
1001static void azx_init_chip(struct azx *chip) 1005static void azx_init_chip(struct azx *chip, int full_reset)
1002{ 1006{
1003 if (chip->initialized) 1007 if (chip->initialized)
1004 return; 1008 return;
1005 1009
1006 /* reset controller */ 1010 /* reset controller */
1007 azx_reset(chip); 1011 azx_reset(chip, full_reset);
1008 1012
1009 /* initialize interrupts */ 1013 /* initialize interrupts */
1010 azx_int_clear(chip); 1014 azx_int_clear(chip);
@@ -1348,7 +1352,7 @@ static void azx_bus_reset(struct hda_bus *bus)
1348 1352
1349 bus->in_reset = 1; 1353 bus->in_reset = 1;
1350 azx_stop_chip(chip); 1354 azx_stop_chip(chip);
1351 azx_init_chip(chip); 1355 azx_init_chip(chip, 1);
1352#ifdef CONFIG_PM 1356#ifdef CONFIG_PM
1353 if (chip->initialized) { 1357 if (chip->initialized) {
1354 int i; 1358 int i;
@@ -1422,7 +1426,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model)
1422 * get back to the sanity state. 1426 * get back to the sanity state.
1423 */ 1427 */
1424 azx_stop_chip(chip); 1428 azx_stop_chip(chip);
1425 azx_init_chip(chip); 1429 azx_init_chip(chip, 1);
1426 } 1430 }
1427 } 1431 }
1428 } 1432 }
@@ -2112,7 +2116,7 @@ static void azx_power_notify(struct hda_bus *bus)
2112 } 2116 }
2113 } 2117 }
2114 if (power_on) 2118 if (power_on)
2115 azx_init_chip(chip); 2119 azx_init_chip(chip, 1);
2116 else if (chip->running && power_save_controller && 2120 else if (chip->running && power_save_controller &&
2117 !bus->power_keep_link_on) 2121 !bus->power_keep_link_on)
2118 azx_stop_chip(chip); 2122 azx_stop_chip(chip);
@@ -2182,7 +2186,7 @@ static int azx_resume(struct pci_dev *pci)
2182 azx_init_pci(chip); 2186 azx_init_pci(chip);
2183 2187
2184 if (snd_hda_codecs_inuse(chip->bus)) 2188 if (snd_hda_codecs_inuse(chip->bus))
2185 azx_init_chip(chip); 2189 azx_init_chip(chip, 1);
2186 2190
2187 snd_hda_resume(chip->bus); 2191 snd_hda_resume(chip->bus);
2188 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 2192 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
@@ -2575,7 +2579,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
2575 2579
2576 /* initialize chip */ 2580 /* initialize chip */
2577 azx_init_pci(chip); 2581 azx_init_pci(chip);
2578 azx_init_chip(chip); 2582 azx_init_chip(chip, (probe_only[dev] & 2) == 0);
2579 2583
2580 /* codec detection */ 2584 /* codec detection */
2581 if (!chip->codec_mask) { 2585 if (!chip->codec_mask) {
@@ -2664,7 +2668,7 @@ static int __devinit azx_probe(struct pci_dev *pci,
2664 goto out_free; 2668 goto out_free;
2665 } 2669 }
2666#endif 2670#endif
2667 if (!probe_only[dev]) { 2671 if ((probe_only[dev] & 1) == 0) {
2668 err = azx_codec_configure(chip); 2672 err = azx_codec_configure(chip);
2669 if (err < 0) 2673 if (err < 0)
2670 goto out_free; 2674 goto out_free;
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index af34606c30c..9cbd80cba12 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -71,9 +71,10 @@ struct ad198x_spec {
71 struct hda_input_mux private_imux; 71 struct hda_input_mux private_imux;
72 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 72 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
73 73
74 unsigned int jack_present :1; 74 unsigned int jack_present: 1;
75 unsigned int inv_jack_detect:1; /* inverted jack-detection */ 75 unsigned int inv_jack_detect: 1;/* inverted jack-detection */
76 unsigned int inv_eapd:1; /* inverted EAPD implementation */ 76 unsigned int inv_eapd: 1; /* inverted EAPD implementation */
77 unsigned int analog_beep: 1; /* analog beep input present */
77 78
78#ifdef CONFIG_SND_HDA_POWER_SAVE 79#ifdef CONFIG_SND_HDA_POWER_SAVE
79 struct hda_loopback_check loopback; 80 struct hda_loopback_check loopback;
@@ -165,6 +166,12 @@ static struct snd_kcontrol_new ad_beep_mixer[] = {
165 { } /* end */ 166 { } /* end */
166}; 167};
167 168
169static struct snd_kcontrol_new ad_beep2_mixer[] = {
170 HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0, 0, HDA_OUTPUT),
171 HDA_CODEC_MUTE_BEEP("Digital Beep Playback Switch", 0, 0, HDA_OUTPUT),
172 { } /* end */
173};
174
168#define set_beep_amp(spec, nid, idx, dir) \ 175#define set_beep_amp(spec, nid, idx, dir) \
169 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */ 176 ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
170#else 177#else
@@ -203,7 +210,8 @@ static int ad198x_build_controls(struct hda_codec *codec)
203#ifdef CONFIG_SND_HDA_INPUT_BEEP 210#ifdef CONFIG_SND_HDA_INPUT_BEEP
204 if (spec->beep_amp) { 211 if (spec->beep_amp) {
205 struct snd_kcontrol_new *knew; 212 struct snd_kcontrol_new *knew;
206 for (knew = ad_beep_mixer; knew->name; knew++) { 213 knew = spec->analog_beep ? ad_beep2_mixer : ad_beep_mixer;
214 for ( ; knew->name; knew++) {
207 struct snd_kcontrol *kctl; 215 struct snd_kcontrol *kctl;
208 kctl = snd_ctl_new1(knew, codec); 216 kctl = snd_ctl_new1(knew, codec);
209 if (!kctl) 217 if (!kctl)
@@ -3490,6 +3498,8 @@ static struct snd_kcontrol_new ad1984_thinkpad_mixers[] = {
3490 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT), 3498 HDA_CODEC_MUTE("Mic Playback Switch", 0x20, 0x00, HDA_INPUT),
3491 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT), 3499 HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x20, 0x01, HDA_INPUT),
3492 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT), 3500 HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x20, 0x01, HDA_INPUT),
3501 HDA_CODEC_VOLUME("Beep Playback Volume", 0x20, 0x03, HDA_INPUT),
3502 HDA_CODEC_MUTE("Beep Playback Switch", 0x20, 0x03, HDA_INPUT),
3493 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT), 3503 HDA_CODEC_VOLUME("Docking Mic Playback Volume", 0x20, 0x04, HDA_INPUT),
3494 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT), 3504 HDA_CODEC_MUTE("Docking Mic Playback Switch", 0x20, 0x04, HDA_INPUT),
3495 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT), 3505 HDA_CODEC_VOLUME("Mic Boost", 0x14, 0x0, HDA_INPUT),
@@ -3531,6 +3541,8 @@ static struct hda_verb ad1984_thinkpad_init_verbs[] = {
3531 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3541 {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3532 /* docking mic boost */ 3542 /* docking mic boost */
3533 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 3543 {0x25, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
3544 /* Analog PC Beeper - allow firmware/ACPI beeps */
3545 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3) | 0x1a},
3534 /* Analog mixer - docking mic; mute as default */ 3546 /* Analog mixer - docking mic; mute as default */
3535 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, 3547 {0x20, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
3536 /* enable EAPD bit */ 3548 /* enable EAPD bit */
@@ -3663,6 +3675,7 @@ static int patch_ad1984(struct hda_codec *codec)
3663 spec->input_mux = &ad1984_thinkpad_capture_source; 3675 spec->input_mux = &ad1984_thinkpad_capture_source;
3664 spec->mixers[0] = ad1984_thinkpad_mixers; 3676 spec->mixers[0] = ad1984_thinkpad_mixers;
3665 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs; 3677 spec->init_verbs[spec->num_init_verbs++] = ad1984_thinkpad_init_verbs;
3678 spec->analog_beep = 1;
3666 break; 3679 break;
3667 case AD1984_DELL_DESKTOP: 3680 case AD1984_DELL_DESKTOP:
3668 spec->multiout.dig_out_nid = 0; 3681 spec->multiout.dig_out_nid = 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 8d60b1f25ce..98cc465992f 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -276,6 +276,18 @@ struct alc_mic_route {
276 276
277#define MUX_IDX_UNDEF ((unsigned char)-1) 277#define MUX_IDX_UNDEF ((unsigned char)-1)
278 278
279struct alc_customize_define {
280 unsigned int sku_cfg;
281 unsigned char port_connectivity;
282 unsigned char check_sum;
283 unsigned char customization;
284 unsigned char external_amp;
285 unsigned int enable_pcbeep:1;
286 unsigned int platform_type:1;
287 unsigned int swap:1;
288 unsigned int override:1;
289};
290
279struct alc_spec { 291struct alc_spec {
280 /* codec parameterization */ 292 /* codec parameterization */
281 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ 293 struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
@@ -333,6 +345,7 @@ struct alc_spec {
333 345
334 /* dynamic controls, init_verbs and input_mux */ 346 /* dynamic controls, init_verbs and input_mux */
335 struct auto_pin_cfg autocfg; 347 struct auto_pin_cfg autocfg;
348 struct alc_customize_define cdefine;
336 struct snd_array kctls; 349 struct snd_array kctls;
337 struct hda_input_mux private_imux[3]; 350 struct hda_input_mux private_imux[3];
338 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; 351 hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
@@ -1248,6 +1261,62 @@ static void alc_init_auto_mic(struct hda_codec *codec)
1248 spec->unsol_event = alc_sku_unsol_event; 1261 spec->unsol_event = alc_sku_unsol_event;
1249} 1262}
1250 1263
1264static int alc_auto_parse_customize_define(struct hda_codec *codec)
1265{
1266 unsigned int ass, tmp, i;
1267 unsigned nid = 0;
1268 struct alc_spec *spec = codec->spec;
1269
1270 ass = codec->subsystem_id & 0xffff;
1271 if (ass != codec->bus->pci->subsystem_device && (ass & 1))
1272 goto do_sku;
1273
1274 nid = 0x1d;
1275 if (codec->vendor_id == 0x10ec0260)
1276 nid = 0x17;
1277 ass = snd_hda_codec_get_pincfg(codec, nid);
1278
1279 if (!(ass & 1)) {
1280 printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
1281 codec->chip_name, ass);
1282 return -1;
1283 }
1284
1285 /* check sum */
1286 tmp = 0;
1287 for (i = 1; i < 16; i++) {
1288 if ((ass >> i) & 1)
1289 tmp++;
1290 }
1291 if (((ass >> 16) & 0xf) != tmp)
1292 return -1;
1293
1294 spec->cdefine.port_connectivity = ass >> 30;
1295 spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
1296 spec->cdefine.check_sum = (ass >> 16) & 0xf;
1297 spec->cdefine.customization = ass >> 8;
1298do_sku:
1299 spec->cdefine.sku_cfg = ass;
1300 spec->cdefine.external_amp = (ass & 0x38) >> 3;
1301 spec->cdefine.platform_type = (ass & 0x4) >> 2;
1302 spec->cdefine.swap = (ass & 0x2) >> 1;
1303 spec->cdefine.override = ass & 0x1;
1304
1305 snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
1306 nid, spec->cdefine.sku_cfg);
1307 snd_printd("SKU: port_connectivity=0x%x\n",
1308 spec->cdefine.port_connectivity);
1309 snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
1310 snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
1311 snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
1312 snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
1313 snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
1314 snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
1315 snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
1316
1317 return 0;
1318}
1319
1251/* check subsystem ID and set up device-specific initialization; 1320/* check subsystem ID and set up device-specific initialization;
1252 * return 1 if initialized, 0 if invalid SSID 1321 * return 1 if initialized, 0 if invalid SSID
1253 */ 1322 */
@@ -3406,6 +3475,10 @@ static int alc_init(struct hda_codec *codec)
3406 if (spec->init_hook) 3475 if (spec->init_hook)
3407 spec->init_hook(codec); 3476 spec->init_hook(codec);
3408 3477
3478#ifdef CONFIG_SND_HDA_POWER_SAVE
3479 if (codec->patch_ops.check_power_status)
3480 codec->patch_ops.check_power_status(codec, 0x01);
3481#endif
3409 return 0; 3482 return 0;
3410} 3483}
3411 3484
@@ -3766,6 +3839,10 @@ static int alc_resume(struct hda_codec *codec)
3766 codec->patch_ops.init(codec); 3839 codec->patch_ops.init(codec);
3767 snd_hda_codec_resume_amp(codec); 3840 snd_hda_codec_resume_amp(codec);
3768 snd_hda_codec_resume_cache(codec); 3841 snd_hda_codec_resume_cache(codec);
3842#ifdef CONFIG_SND_HDA_POWER_SAVE
3843 if (codec->patch_ops.check_power_status)
3844 codec->patch_ops.check_power_status(codec, 0x01);
3845#endif
3769 return 0; 3846 return 0;
3770} 3847}
3771#endif 3848#endif
@@ -3788,6 +3865,17 @@ static struct hda_codec_ops alc_patch_ops = {
3788 .reboot_notify = alc_shutup, 3865 .reboot_notify = alc_shutup,
3789}; 3866};
3790 3867
3868/* replace the codec chip_name with the given string */
3869static int alc_codec_rename(struct hda_codec *codec, const char *name)
3870{
3871 kfree(codec->chip_name);
3872 codec->chip_name = kstrdup(name, GFP_KERNEL);
3873 if (!codec->chip_name) {
3874 alc_free(codec);
3875 return -ENOMEM;
3876 }
3877 return 0;
3878}
3791 3879
3792/* 3880/*
3793 * Test configuration for debugging 3881 * Test configuration for debugging
@@ -10179,21 +10267,20 @@ static int alc882_auto_create_input_ctls(struct hda_codec *codec,
10179 10267
10180static void alc882_auto_set_output_and_unmute(struct hda_codec *codec, 10268static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
10181 hda_nid_t nid, int pin_type, 10269 hda_nid_t nid, int pin_type,
10182 int dac_idx) 10270 hda_nid_t dac)
10183{ 10271{
10184 /* set as output */
10185 struct alc_spec *spec = codec->spec;
10186 int idx; 10272 int idx;
10187 10273
10274 /* set as output */
10188 alc_set_pin_output(codec, nid, pin_type); 10275 alc_set_pin_output(codec, nid, pin_type);
10189 if (dac_idx >= spec->multiout.num_dacs) 10276
10190 return; 10277 if (dac == 0x25)
10191 if (spec->multiout.dac_nids[dac_idx] == 0x25)
10192 idx = 4; 10278 idx = 4;
10279 else if (dac >= 0x02 && dac <= 0x05)
10280 idx = dac - 2;
10193 else 10281 else
10194 idx = spec->multiout.dac_nids[dac_idx] - 2; 10282 return;
10195 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx); 10283 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
10196
10197} 10284}
10198 10285
10199static void alc882_auto_init_multi_out(struct hda_codec *codec) 10286static void alc882_auto_init_multi_out(struct hda_codec *codec)
@@ -10206,22 +10293,29 @@ static void alc882_auto_init_multi_out(struct hda_codec *codec)
10206 int pin_type = get_pin_type(spec->autocfg.line_out_type); 10293 int pin_type = get_pin_type(spec->autocfg.line_out_type);
10207 if (nid) 10294 if (nid)
10208 alc882_auto_set_output_and_unmute(codec, nid, pin_type, 10295 alc882_auto_set_output_and_unmute(codec, nid, pin_type,
10209 i); 10296 spec->multiout.dac_nids[i]);
10210 } 10297 }
10211} 10298}
10212 10299
10213static void alc882_auto_init_hp_out(struct hda_codec *codec) 10300static void alc882_auto_init_hp_out(struct hda_codec *codec)
10214{ 10301{
10215 struct alc_spec *spec = codec->spec; 10302 struct alc_spec *spec = codec->spec;
10216 hda_nid_t pin; 10303 hda_nid_t pin, dac;
10217 10304
10218 pin = spec->autocfg.hp_pins[0]; 10305 pin = spec->autocfg.hp_pins[0];
10219 if (pin) /* connect to front */ 10306 if (pin) {
10220 /* use dac 0 */ 10307 dac = spec->multiout.hp_nid;
10221 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); 10308 if (!dac)
10309 dac = spec->multiout.dac_nids[0]; /* to front */
10310 alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, dac);
10311 }
10222 pin = spec->autocfg.speaker_pins[0]; 10312 pin = spec->autocfg.speaker_pins[0];
10223 if (pin) 10313 if (pin) {
10224 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); 10314 dac = spec->multiout.extra_out_nid[0];
10315 if (!dac)
10316 dac = spec->multiout.dac_nids[0]; /* to front */
10317 alc882_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac);
10318 }
10225} 10319}
10226 10320
10227static void alc882_auto_init_analog_input(struct hda_codec *codec) 10321static void alc882_auto_init_analog_input(struct hda_codec *codec)
@@ -10337,15 +10431,15 @@ static int alc882_parse_auto_config(struct hda_codec *codec)
10337 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg); 10431 err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
10338 if (err < 0) 10432 if (err < 0)
10339 return err; 10433 return err;
10434 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10435 "Headphone");
10436 if (err < 0)
10437 return err;
10340 err = alc880_auto_create_extra_out(spec, 10438 err = alc880_auto_create_extra_out(spec,
10341 spec->autocfg.speaker_pins[0], 10439 spec->autocfg.speaker_pins[0],
10342 "Speaker"); 10440 "Speaker");
10343 if (err < 0) 10441 if (err < 0)
10344 return err; 10442 return err;
10345 err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
10346 "Headphone");
10347 if (err < 0)
10348 return err;
10349 err = alc882_auto_create_input_ctls(codec, &spec->autocfg); 10443 err = alc882_auto_create_input_ctls(codec, &spec->autocfg);
10350 if (err < 0) 10444 if (err < 0)
10351 return err; 10445 return err;
@@ -10415,6 +10509,8 @@ static int patch_alc882(struct hda_codec *codec)
10415 10509
10416 codec->spec = spec; 10510 codec->spec = spec;
10417 10511
10512 alc_auto_parse_customize_define(codec);
10513
10418 switch (codec->vendor_id) { 10514 switch (codec->vendor_id) {
10419 case 0x10ec0882: 10515 case 0x10ec0882:
10420 case 0x10ec0885: 10516 case 0x10ec0885:
@@ -10510,7 +10606,9 @@ static int patch_alc882(struct hda_codec *codec)
10510 } 10606 }
10511 10607
10512 set_capture_mixer(codec); 10608 set_capture_mixer(codec);
10513 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 10609
10610 if (spec->cdefine.enable_pcbeep)
10611 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
10514 10612
10515 spec->vmaster_nid = 0x0c; 10613 spec->vmaster_nid = 0x0c;
10516 10614
@@ -12294,6 +12392,7 @@ static int patch_alc262(struct hda_codec *codec)
12294 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); 12392 snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
12295 } 12393 }
12296#endif 12394#endif
12395 alc_auto_parse_customize_define(codec);
12297 12396
12298 alc_fix_pll_init(codec, 0x20, 0x0a, 10); 12397 alc_fix_pll_init(codec, 0x20, 0x0a, 10);
12299 12398
@@ -12372,7 +12471,7 @@ static int patch_alc262(struct hda_codec *codec)
12372 } 12471 }
12373 if (!spec->cap_mixer && !spec->no_analog) 12472 if (!spec->cap_mixer && !spec->no_analog)
12374 set_capture_mixer(codec); 12473 set_capture_mixer(codec);
12375 if (!spec->no_analog) 12474 if (!spec->no_analog && spec->cdefine.enable_pcbeep)
12376 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 12475 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
12377 12476
12378 spec->vmaster_nid = 0x0c; 12477 spec->vmaster_nid = 0x0c;
@@ -13991,6 +14090,35 @@ static struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
13991 /* NID is set in alc_build_pcms */ 14090 /* NID is set in alc_build_pcms */
13992}; 14091};
13993 14092
14093#ifdef CONFIG_SND_HDA_POWER_SAVE
14094static int alc269_mic2_for_mute_led(struct hda_codec *codec)
14095{
14096 switch (codec->subsystem_id) {
14097 case 0x103c1586:
14098 return 1;
14099 }
14100 return 0;
14101}
14102
14103static int alc269_mic2_mute_check_ps(struct hda_codec *codec, hda_nid_t nid)
14104{
14105 /* update mute-LED according to the speaker mute state */
14106 if (nid == 0x01 || nid == 0x14) {
14107 int pinval;
14108 if (snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0) &
14109 HDA_AMP_MUTE)
14110 pinval = 0x24;
14111 else
14112 pinval = 0x20;
14113 /* mic2 vref pin is used for mute LED control */
14114 snd_hda_codec_update_cache(codec, 0x19, 0,
14115 AC_VERB_SET_PIN_WIDGET_CONTROL,
14116 pinval);
14117 }
14118 return alc_check_power_status(codec, nid);
14119}
14120#endif /* CONFIG_SND_HDA_POWER_SAVE */
14121
13994/* 14122/*
13995 * BIOS auto configuration 14123 * BIOS auto configuration
13996 */ 14124 */
@@ -14255,17 +14383,17 @@ static int patch_alc269(struct hda_codec *codec)
14255 14383
14256 codec->spec = spec; 14384 codec->spec = spec;
14257 14385
14258 alc_fix_pll_init(codec, 0x20, 0x04, 15); 14386 alc_auto_parse_customize_define(codec);
14259 14387
14260 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){ 14388 if ((alc_read_coef_idx(codec, 0) & 0x00f0) == 0x0010){
14261 kfree(codec->chip_name); 14389 if (codec->bus->pci->subsystem_vendor == 0x1025 &&
14262 codec->chip_name = kstrdup("ALC259", GFP_KERNEL); 14390 spec->cdefine.platform_type == 1)
14263 if (!codec->chip_name) { 14391 alc_codec_rename(codec, "ALC271X");
14264 alc_free(codec); 14392 else
14265 return -ENOMEM; 14393 alc_codec_rename(codec, "ALC259");
14266 }
14267 is_alc269vb = 1; 14394 is_alc269vb = 1;
14268 } 14395 } else
14396 alc_fix_pll_init(codec, 0x20, 0x04, 15);
14269 14397
14270 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST, 14398 board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
14271 alc269_models, 14399 alc269_models,
@@ -14327,7 +14455,8 @@ static int patch_alc269(struct hda_codec *codec)
14327 14455
14328 if (!spec->cap_mixer) 14456 if (!spec->cap_mixer)
14329 set_capture_mixer(codec); 14457 set_capture_mixer(codec);
14330 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 14458 if (spec->cdefine.enable_pcbeep)
14459 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
14331 14460
14332 spec->vmaster_nid = 0x02; 14461 spec->vmaster_nid = 0x02;
14333 14462
@@ -14337,6 +14466,8 @@ static int patch_alc269(struct hda_codec *codec)
14337#ifdef CONFIG_SND_HDA_POWER_SAVE 14466#ifdef CONFIG_SND_HDA_POWER_SAVE
14338 if (!spec->loopback.amplist) 14467 if (!spec->loopback.amplist)
14339 spec->loopback.amplist = alc269_loopbacks; 14468 spec->loopback.amplist = alc269_loopbacks;
14469 if (alc269_mic2_for_mute_led(codec))
14470 codec->patch_ops.check_power_status = alc269_mic2_mute_check_ps;
14340#endif 14471#endif
14341 14472
14342 return 0; 14473 return 0;
@@ -18477,16 +18608,16 @@ static int patch_alc662(struct hda_codec *codec)
18477 18608
18478 codec->spec = spec; 18609 codec->spec = spec;
18479 18610
18611 alc_auto_parse_customize_define(codec);
18612
18480 alc_fix_pll_init(codec, 0x20, 0x04, 15); 18613 alc_fix_pll_init(codec, 0x20, 0x04, 15);
18481 18614
18482 if (alc_read_coef_idx(codec, 0)==0x8020){ 18615 if (alc_read_coef_idx(codec, 0) == 0x8020)
18483 kfree(codec->chip_name); 18616 alc_codec_rename(codec, "ALC661");
18484 codec->chip_name = kstrdup("ALC661", GFP_KERNEL); 18617 else if ((alc_read_coef_idx(codec, 0) & (1 << 14)) &&
18485 if (!codec->chip_name) { 18618 codec->bus->pci->subsystem_vendor == 0x1025 &&
18486 alc_free(codec); 18619 spec->cdefine.platform_type == 1)
18487 return -ENOMEM; 18620 alc_codec_rename(codec, "ALC272X");
18488 }
18489 }
18490 18621
18491 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST, 18622 board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
18492 alc662_models, 18623 alc662_models,
@@ -18536,18 +18667,20 @@ static int patch_alc662(struct hda_codec *codec)
18536 if (!spec->cap_mixer) 18667 if (!spec->cap_mixer)
18537 set_capture_mixer(codec); 18668 set_capture_mixer(codec);
18538 18669
18539 switch (codec->vendor_id) { 18670 if (spec->cdefine.enable_pcbeep) {
18540 case 0x10ec0662: 18671 switch (codec->vendor_id) {
18541 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 18672 case 0x10ec0662:
18542 break; 18673 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
18543 case 0x10ec0272: 18674 break;
18544 case 0x10ec0663: 18675 case 0x10ec0272:
18545 case 0x10ec0665: 18676 case 0x10ec0663:
18546 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 18677 case 0x10ec0665:
18547 break; 18678 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
18548 case 0x10ec0273: 18679 break;
18549 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); 18680 case 0x10ec0273:
18550 break; 18681 set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
18682 break;
18683 }
18551 } 18684 }
18552 spec->vmaster_nid = 0x02; 18685 spec->vmaster_nid = 0x02;
18553 18686