aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r--sound/pci/hda/hda_codec.c149
1 files changed, 104 insertions, 45 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 76d3c4c049db..a3d638c8c1fd 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -978,8 +978,9 @@ static void hda_set_power_state(struct hda_codec *codec, hda_nid_t fg,
978 * 978 *
979 * Returns 0 if successful, or a negative error code. 979 * Returns 0 if successful, or a negative error code.
980 */ 980 */
981int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 981int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
982 struct hda_codec **codecp) 982 unsigned int codec_addr,
983 struct hda_codec **codecp)
983{ 984{
984 struct hda_codec *codec; 985 struct hda_codec *codec;
985 char component[31]; 986 char component[31];
@@ -1186,7 +1187,7 @@ EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream);
1186 */ 1187 */
1187 1188
1188/* FIXME: more better hash key? */ 1189/* FIXME: more better hash key? */
1189#define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) 1190#define HDA_HASH_KEY(nid, dir, idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24))
1190#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) 1191#define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24))
1191#define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24)) 1192#define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24))
1192#define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24)) 1193#define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24))
@@ -1208,8 +1209,7 @@ static void free_hda_cache(struct hda_cache_rec *cache)
1208} 1209}
1209 1210
1210/* query the hash. allocate an entry if not found. */ 1211/* query the hash. allocate an entry if not found. */
1211static 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)
1212 u32 key)
1213{ 1213{
1214 u16 idx = key % (u16)ARRAY_SIZE(cache->hash); 1214 u16 idx = key % (u16)ARRAY_SIZE(cache->hash);
1215 u16 cur = cache->hash[idx]; 1215 u16 cur = cache->hash[idx];
@@ -1221,17 +1221,27 @@ static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache,
1221 return info; 1221 return info;
1222 cur = info->next; 1222 cur = info->next;
1223 } 1223 }
1224 return NULL;
1225}
1224 1226
1225 /* add a new hash entry */ 1227/* query the hash. allocate an entry if not found. */
1226 info = snd_array_new(&cache->buf); 1228static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache,
1227 if (!info) 1229 u32 key)
1228 return NULL; 1230{
1229 cur = snd_array_index(&cache->buf, info); 1231 struct hda_cache_head *info = get_hash(cache, key);
1230 info->key = key; 1232 if (!info) {
1231 info->val = 0; 1233 u16 idx, cur;
1232 info->next = cache->hash[idx]; 1234 /* add a new hash entry */
1233 cache->hash[idx] = cur; 1235 info = snd_array_new(&cache->buf);
1234 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 }
1235 return info; 1245 return info;
1236} 1246}
1237 1247
@@ -1356,7 +1366,8 @@ u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid)
1356 if (!codec->no_trigger_sense) { 1366 if (!codec->no_trigger_sense) {
1357 pincap = snd_hda_query_pin_caps(codec, nid); 1367 pincap = snd_hda_query_pin_caps(codec, nid);
1358 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ 1368 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */
1359 snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); 1369 snd_hda_codec_read(codec, nid, 0,
1370 AC_VERB_SET_PIN_SENSE, 0);
1360 } 1371 }
1361 return snd_hda_codec_read(codec, nid, 0, 1372 return snd_hda_codec_read(codec, nid, 0,
1362 AC_VERB_GET_PIN_SENSE, 0); 1373 AC_VERB_GET_PIN_SENSE, 0);
@@ -1372,8 +1383,8 @@ EXPORT_SYMBOL_HDA(snd_hda_pin_sense);
1372 */ 1383 */
1373int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) 1384int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
1374{ 1385{
1375 u32 sense = snd_hda_pin_sense(codec, nid); 1386 u32 sense = snd_hda_pin_sense(codec, nid);
1376 return !!(sense & AC_PINSENSE_PRESENCE); 1387 return !!(sense & AC_PINSENSE_PRESENCE);
1377} 1388}
1378EXPORT_SYMBOL_HDA(snd_hda_jack_detect); 1389EXPORT_SYMBOL_HDA(snd_hda_jack_detect);
1379 1390
@@ -1459,6 +1470,8 @@ int snd_hda_codec_amp_update(struct hda_codec *codec, hda_nid_t nid, int ch,
1459 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));
1460 if (!info) 1471 if (!info)
1461 return 0; 1472 return 0;
1473 if (snd_BUG_ON(mask & ~0xff))
1474 mask &= 0xff;
1462 val &= mask; 1475 val &= mask;
1463 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask; 1476 val |= get_vol_mute(codec, info, nid, ch, direction, idx) & ~mask;
1464 if (info->vol[ch] == val) 1477 if (info->vol[ch] == val)
@@ -1484,6 +1497,9 @@ int snd_hda_codec_amp_stereo(struct hda_codec *codec, hda_nid_t nid,
1484 int direction, int idx, int mask, int val) 1497 int direction, int idx, int mask, int val)
1485{ 1498{
1486 int ch, ret = 0; 1499 int ch, ret = 0;
1500
1501 if (snd_BUG_ON(mask & ~0xff))
1502 mask &= 0xff;
1487 for (ch = 0; ch < 2; ch++) 1503 for (ch = 0; ch < 2; ch++)
1488 ret |= snd_hda_codec_amp_update(codec, nid, ch, direction, 1504 ret |= snd_hda_codec_amp_update(codec, nid, ch, direction,
1489 idx, mask, val); 1505 idx, mask, val);
@@ -1804,6 +1820,8 @@ int snd_hda_add_nid(struct hda_codec *codec, struct snd_kcontrol *kctl,
1804 item->nid = nid; 1820 item->nid = nid;
1805 return 0; 1821 return 0;
1806 } 1822 }
1823 printk(KERN_ERR "hda-codec: no NID for mapping control %s:%d:%d\n",
1824 kctl->id.name, kctl->id.index, index);
1807 return -EINVAL; 1825 return -EINVAL;
1808} 1826}
1809EXPORT_SYMBOL_HDA(snd_hda_add_nid); 1827EXPORT_SYMBOL_HDA(snd_hda_add_nid);
@@ -1952,7 +1970,7 @@ int snd_hda_add_vmaster(struct hda_codec *codec, char *name,
1952 err = snd_hda_ctl_add(codec, 0, kctl); 1970 err = snd_hda_ctl_add(codec, 0, kctl);
1953 if (err < 0) 1971 if (err < 0)
1954 return err; 1972 return err;
1955 1973
1956 for (s = slaves; *s; s++) { 1974 for (s = slaves; *s; s++) {
1957 struct snd_kcontrol *sctl; 1975 struct snd_kcontrol *sctl;
1958 int i = 0; 1976 int i = 0;
@@ -2439,27 +2457,27 @@ static struct snd_kcontrol_new dig_mixes[] = {
2439 { 2457 {
2440 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2458 .access = SNDRV_CTL_ELEM_ACCESS_READ,
2441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2459 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2442 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), 2460 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK),
2443 .info = snd_hda_spdif_mask_info, 2461 .info = snd_hda_spdif_mask_info,
2444 .get = snd_hda_spdif_cmask_get, 2462 .get = snd_hda_spdif_cmask_get,
2445 }, 2463 },
2446 { 2464 {
2447 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2465 .access = SNDRV_CTL_ELEM_ACCESS_READ,
2448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2466 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2449 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), 2467 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK),
2450 .info = snd_hda_spdif_mask_info, 2468 .info = snd_hda_spdif_mask_info,
2451 .get = snd_hda_spdif_pmask_get, 2469 .get = snd_hda_spdif_pmask_get,
2452 }, 2470 },
2453 { 2471 {
2454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2472 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2455 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 2473 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
2456 .info = snd_hda_spdif_mask_info, 2474 .info = snd_hda_spdif_mask_info,
2457 .get = snd_hda_spdif_default_get, 2475 .get = snd_hda_spdif_default_get,
2458 .put = snd_hda_spdif_default_put, 2476 .put = snd_hda_spdif_default_put,
2459 }, 2477 },
2460 { 2478 {
2461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2479 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2462 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), 2480 .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH),
2463 .info = snd_hda_spdif_out_switch_info, 2481 .info = snd_hda_spdif_out_switch_info,
2464 .get = snd_hda_spdif_out_switch_get, 2482 .get = snd_hda_spdif_out_switch_get,
2465 .put = snd_hda_spdif_out_switch_put, 2483 .put = snd_hda_spdif_out_switch_put,
@@ -2610,7 +2628,7 @@ static int snd_hda_spdif_in_status_get(struct snd_kcontrol *kcontrol,
2610static struct snd_kcontrol_new dig_in_ctls[] = { 2628static struct snd_kcontrol_new dig_in_ctls[] = {
2611 { 2629 {
2612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2630 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2613 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 2631 .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH),
2614 .info = snd_hda_spdif_in_switch_info, 2632 .info = snd_hda_spdif_in_switch_info,
2615 .get = snd_hda_spdif_in_switch_get, 2633 .get = snd_hda_spdif_in_switch_get,
2616 .put = snd_hda_spdif_in_switch_put, 2634 .put = snd_hda_spdif_in_switch_put,
@@ -2618,7 +2636,7 @@ static struct snd_kcontrol_new dig_in_ctls[] = {
2618 { 2636 {
2619 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2637 .access = SNDRV_CTL_ELEM_ACCESS_READ,
2620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2638 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
2621 .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT), 2639 .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT),
2622 .info = snd_hda_spdif_mask_info, 2640 .info = snd_hda_spdif_mask_info,
2623 .get = snd_hda_spdif_in_status_get, 2641 .get = snd_hda_spdif_in_status_get,
2624 }, 2642 },
@@ -2713,6 +2731,41 @@ int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
2713EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache); 2731EXPORT_SYMBOL_HDA(snd_hda_codec_write_cache);
2714 2732
2715/** 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/**
2716 * 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
2717 * @codec: HD-audio codec 2770 * @codec: HD-audio codec
2718 * 2771 *
@@ -2882,8 +2935,8 @@ int /*__devinit*/ snd_hda_build_controls(struct hda_bus *bus)
2882 list_for_each_entry(codec, &bus->codec_list, list) { 2935 list_for_each_entry(codec, &bus->codec_list, list) {
2883 int err = snd_hda_codec_build_controls(codec); 2936 int err = snd_hda_codec_build_controls(codec);
2884 if (err < 0) { 2937 if (err < 0) {
2885 printk(KERN_ERR "hda_codec: cannot build controls" 2938 printk(KERN_ERR "hda_codec: cannot build controls "
2886 "for #%d (error %d)\n", codec->addr, err); 2939 "for #%d (error %d)\n", codec->addr, err);
2887 err = snd_hda_codec_reset(codec); 2940 err = snd_hda_codec_reset(codec);
2888 if (err < 0) { 2941 if (err < 0) {
2889 printk(KERN_ERR 2942 printk(KERN_ERR
@@ -2979,8 +3032,12 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
2979 val |= channels - 1; 3032 val |= channels - 1;
2980 3033
2981 switch (snd_pcm_format_width(format)) { 3034 switch (snd_pcm_format_width(format)) {
2982 case 8: val |= 0x00; break; 3035 case 8:
2983 case 16: val |= 0x10; break; 3036 val |= 0x00;
3037 break;
3038 case 16:
3039 val |= 0x10;
3040 break;
2984 case 20: 3041 case 20:
2985 case 24: 3042 case 24:
2986 case 32: 3043 case 32:
@@ -3298,7 +3355,8 @@ static int get_empty_pcm_device(struct hda_bus *bus, int type)
3298 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) 3355 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits))
3299 return audio_idx[type][i]; 3356 return audio_idx[type][i];
3300 3357
3301 snd_printk(KERN_WARNING "Too many %s devices\n", snd_hda_pcm_type_name[type]); 3358 snd_printk(KERN_WARNING "Too many %s devices\n",
3359 snd_hda_pcm_type_name[type]);
3302 return -EAGAIN; 3360 return -EAGAIN;
3303} 3361}
3304 3362
@@ -3336,7 +3394,7 @@ int snd_hda_codec_build_pcms(struct hda_codec *codec)
3336 err = codec->patch_ops.build_pcms(codec); 3394 err = codec->patch_ops.build_pcms(codec);
3337 if (err < 0) { 3395 if (err < 0) {
3338 printk(KERN_ERR "hda_codec: cannot build PCMs" 3396 printk(KERN_ERR "hda_codec: cannot build PCMs"
3339 "for #%d (error %d)\n", codec->addr, err); 3397 "for #%d (error %d)\n", codec->addr, err);
3340 err = snd_hda_codec_reset(codec); 3398 err = snd_hda_codec_reset(codec);
3341 if (err < 0) { 3399 if (err < 0) {
3342 printk(KERN_ERR 3400 printk(KERN_ERR
@@ -3466,8 +3524,8 @@ EXPORT_SYMBOL_HDA(snd_hda_check_board_config);
3466 3524
3467/** 3525/**
3468 * snd_hda_check_board_codec_sid_config - compare the current codec 3526 * snd_hda_check_board_codec_sid_config - compare the current codec
3469 subsystem ID with the 3527 subsystem ID with the
3470 config table 3528 config table
3471 3529
3472 This is important for Gateway notebooks with SB450 HDA Audio 3530 This is important for Gateway notebooks with SB450 HDA Audio
3473 where the vendor ID of the PCI device is: 3531 where the vendor ID of the PCI device is:
@@ -3607,7 +3665,7 @@ void snd_hda_update_power_acct(struct hda_codec *codec)
3607 * 3665 *
3608 * Increment the power-up counter and power up the hardware really when 3666 * Increment the power-up counter and power up the hardware really when
3609 * not turned on yet. 3667 * not turned on yet.
3610 */ 3668 */
3611void snd_hda_power_up(struct hda_codec *codec) 3669void snd_hda_power_up(struct hda_codec *codec)
3612{ 3670{
3613 struct hda_bus *bus = codec->bus; 3671 struct hda_bus *bus = codec->bus;
@@ -3636,7 +3694,7 @@ EXPORT_SYMBOL_HDA(snd_hda_power_up);
3636 * 3694 *
3637 * Decrement the power-up counter and schedules the power-off work if 3695 * Decrement the power-up counter and schedules the power-off work if
3638 * the counter rearches to zero. 3696 * the counter rearches to zero.
3639 */ 3697 */
3640void snd_hda_power_down(struct hda_codec *codec) 3698void snd_hda_power_down(struct hda_codec *codec)
3641{ 3699{
3642 --codec->power_count; 3700 --codec->power_count;
@@ -3662,7 +3720,7 @@ EXPORT_SYMBOL_HDA(snd_hda_power_down);
3662 * 3720 *
3663 * This function is supposed to be set or called from the check_power_status 3721 * This function is supposed to be set or called from the check_power_status
3664 * patch ops. 3722 * patch ops.
3665 */ 3723 */
3666int snd_hda_check_amp_list_power(struct hda_codec *codec, 3724int snd_hda_check_amp_list_power(struct hda_codec *codec,
3667 struct hda_loopback_check *check, 3725 struct hda_loopback_check *check,
3668 hda_nid_t nid) 3726 hda_nid_t nid)
@@ -3830,7 +3888,7 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
3830{ 3888{
3831 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ 3889 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
3832 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) 3890 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))
3833 set_dig_out_convert(codec, nid, 3891 set_dig_out_convert(codec, nid,
3834 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff, 3892 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff,
3835 -1); 3893 -1);
3836 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); 3894 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
@@ -4089,13 +4147,13 @@ static int is_in_nid_list(hda_nid_t nid, hda_nid_t *list)
4089/* 4147/*
4090 * Sort an associated group of pins according to their sequence numbers. 4148 * Sort an associated group of pins according to their sequence numbers.
4091 */ 4149 */
4092static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences, 4150static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences,
4093 int num_pins) 4151 int num_pins)
4094{ 4152{
4095 int i, j; 4153 int i, j;
4096 short seq; 4154 short seq;
4097 hda_nid_t nid; 4155 hda_nid_t nid;
4098 4156
4099 for (i = 0; i < num_pins; i++) { 4157 for (i = 0; i < num_pins; i++) {
4100 for (j = i + 1; j < num_pins; j++) { 4158 for (j = i + 1; j < num_pins; j++) {
4101 if (sequences[i] > sequences[j]) { 4159 if (sequences[i] > sequences[j]) {
@@ -4123,7 +4181,7 @@ static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences,
4123 * is detected, one of speaker of HP pins is assigned as the primary 4181 * is detected, one of speaker of HP pins is assigned as the primary
4124 * output, i.e. to line_out_pins[0]. So, line_outs is always positive 4182 * output, i.e. to line_out_pins[0]. So, line_outs is always positive
4125 * if any analog output exists. 4183 * if any analog output exists.
4126 * 4184 *
4127 * The analog input pins are assigned to input_pins array. 4185 * The analog input pins are assigned to input_pins array.
4128 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 4186 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin,
4129 * respectively. 4187 * respectively.
@@ -4186,9 +4244,9 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4186 case AC_JACK_SPEAKER: 4244 case AC_JACK_SPEAKER:
4187 seq = get_defcfg_sequence(def_conf); 4245 seq = get_defcfg_sequence(def_conf);
4188 assoc = get_defcfg_association(def_conf); 4246 assoc = get_defcfg_association(def_conf);
4189 if (! assoc) 4247 if (!assoc)
4190 continue; 4248 continue;
4191 if (! assoc_speaker) 4249 if (!assoc_speaker)
4192 assoc_speaker = assoc; 4250 assoc_speaker = assoc;
4193 else if (assoc_speaker != assoc) 4251 else if (assoc_speaker != assoc)
4194 continue; 4252 continue;
@@ -4209,7 +4267,8 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4209 break; 4267 break;
4210 case AC_JACK_MIC_IN: { 4268 case AC_JACK_MIC_IN: {
4211 int preferred, alt; 4269 int preferred, alt;
4212 if (loc == AC_JACK_LOC_FRONT) { 4270 if (loc == AC_JACK_LOC_FRONT ||
4271 (loc & 0x30) == AC_JACK_LOC_INTERNAL) {
4213 preferred = AUTO_PIN_FRONT_MIC; 4272 preferred = AUTO_PIN_FRONT_MIC;
4214 alt = AUTO_PIN_MIC; 4273 alt = AUTO_PIN_MIC;
4215 } else { 4274 } else {
@@ -4286,7 +4345,7 @@ int snd_hda_parse_pin_def_config(struct hda_codec *codec,
4286 cfg->speaker_outs); 4345 cfg->speaker_outs);
4287 sort_pins_by_sequence(cfg->hp_pins, sequences_hp, 4346 sort_pins_by_sequence(cfg->hp_pins, sequences_hp,
4288 cfg->hp_outs); 4347 cfg->hp_outs);
4289 4348
4290 /* if we have only one mic, make it AUTO_PIN_MIC */ 4349 /* if we have only one mic, make it AUTO_PIN_MIC */
4291 if (!cfg->input_pins[AUTO_PIN_MIC] && 4350 if (!cfg->input_pins[AUTO_PIN_MIC] &&
4292 cfg->input_pins[AUTO_PIN_FRONT_MIC]) { 4351 cfg->input_pins[AUTO_PIN_FRONT_MIC]) {
@@ -4436,7 +4495,7 @@ EXPORT_SYMBOL_HDA(snd_hda_resume);
4436/** 4495/**
4437 * snd_array_new - get a new element from the given array 4496 * snd_array_new - get a new element from the given array
4438 * @array: the array object 4497 * @array: the array object
4439 * 4498 *
4440 * Get a new element from the given array. If it exceeds the 4499 * Get a new element from the given array. If it exceeds the
4441 * pre-allocated array size, re-allocate the array. 4500 * pre-allocated array size, re-allocate the array.
4442 * 4501 *