Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Universal Interface for Intel High Definition Audio Codec |
| 3 | * |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4 | * HD audio interface patch for Realtek ALC codecs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 6 | * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw> |
| 7 | * PeiSen Hou <pshou@realtek.com.tw> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * Takashi Iwai <tiwai@suse.de> |
Jonathan Woithe | 409a3e9 | 2012-03-27 13:01:01 +1030 | [diff] [blame] | 9 | * Jonathan Woithe <jwoithe@just42.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
| 11 | * This driver is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This driver is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | */ |
| 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
| 28 | #include <linux/slab.h> |
| 29 | #include <linux/pci.h> |
Paul Gortmaker | da155d5 | 2011-07-15 12:38:28 -0400 | [diff] [blame] | 30 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <sound/core.h> |
Kailang Yang | 9ad0e49 | 2010-09-14 23:22:00 +0200 | [diff] [blame] | 32 | #include <sound/jack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include "hda_codec.h" |
| 34 | #include "hda_local.h" |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 35 | #include "hda_auto_parser.h" |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 36 | #include "hda_beep.h" |
Takashi Iwai | 1835a0f | 2011-10-27 22:12:46 +0200 | [diff] [blame] | 37 | #include "hda_jack.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 39 | /* unsol event tags */ |
| 40 | #define ALC_FRONT_EVENT 0x01 |
| 41 | #define ALC_DCVOL_EVENT 0x02 |
| 42 | #define ALC_HP_EVENT 0x04 |
| 43 | #define ALC_MIC_EVENT 0x08 |
Takashi Iwai | d4a86d8 | 2010-06-23 17:51:26 +0200 | [diff] [blame] | 44 | |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 45 | /* for GPIO Poll */ |
| 46 | #define GPIO_MASK 0x03 |
| 47 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 48 | /* extra amp-initialization sequence types */ |
| 49 | enum { |
| 50 | ALC_INIT_NONE, |
| 51 | ALC_INIT_DEFAULT, |
| 52 | ALC_INIT_GPIO1, |
| 53 | ALC_INIT_GPIO2, |
| 54 | ALC_INIT_GPIO3, |
| 55 | }; |
| 56 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 57 | struct alc_customize_define { |
| 58 | unsigned int sku_cfg; |
| 59 | unsigned char port_connectivity; |
| 60 | unsigned char check_sum; |
| 61 | unsigned char customization; |
| 62 | unsigned char external_amp; |
| 63 | unsigned int enable_pcbeep:1; |
| 64 | unsigned int platform_type:1; |
| 65 | unsigned int swap:1; |
| 66 | unsigned int override:1; |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 67 | unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */ |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 70 | struct alc_multi_io { |
| 71 | hda_nid_t pin; /* multi-io widget pin NID */ |
| 72 | hda_nid_t dac; /* DAC to be connected */ |
| 73 | unsigned int ctl_in; /* cached input-pin control value */ |
| 74 | }; |
| 75 | |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 76 | enum { |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 77 | ALC_AUTOMUTE_PIN, /* change the pin control */ |
| 78 | ALC_AUTOMUTE_AMP, /* mute/unmute the pin AMP */ |
| 79 | ALC_AUTOMUTE_MIXER, /* mute/unmute mixer widget AMP */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 80 | }; |
| 81 | |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 82 | #define MAX_VOL_NIDS 0x40 |
| 83 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 84 | /* make compatible with old code */ |
| 85 | #define alc_apply_pincfgs snd_hda_apply_pincfgs |
| 86 | #define alc_apply_fixup snd_hda_apply_fixup |
| 87 | #define alc_pick_fixup snd_hda_pick_fixup |
| 88 | #define alc_fixup hda_fixup |
| 89 | #define alc_pincfg hda_pintbl |
| 90 | #define alc_model_fixup hda_model_fixup |
| 91 | |
| 92 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS |
| 93 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS |
| 94 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC |
| 95 | |
| 96 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE |
| 97 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE |
| 98 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT |
| 99 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD |
| 100 | |
| 101 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | struct alc_spec { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 103 | struct hda_gen_spec gen; |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 106 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | unsigned int num_mixers; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 108 | const struct snd_kcontrol_new *cap_mixer; /* capture mixer */ |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 109 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 111 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 112 | const struct hda_pcm_stream *stream_analog_playback; |
| 113 | const struct hda_pcm_stream *stream_analog_capture; |
| 114 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 115 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 117 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 118 | const struct hda_pcm_stream *stream_digital_playback; |
| 119 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 122 | struct hda_multi_out multiout; /* playback set-up |
| 123 | * max_channels, dacs must be set |
| 124 | * dig_out_nid and hp_nid are optional |
| 125 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 126 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 127 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 128 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
| 130 | /* capture */ |
| 131 | unsigned int num_adc_nids; |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 132 | const hda_nid_t *adc_nids; |
| 133 | const hda_nid_t *capsrc_nids; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 134 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 135 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Takashi Iwai | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 136 | DECLARE_BITMAP(vol_ctls, MAX_VOL_NIDS << 1); |
| 137 | DECLARE_BITMAP(sw_ctls, MAX_VOL_NIDS << 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 139 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 140 | hda_nid_t cur_adc; |
| 141 | unsigned int cur_adc_stream_tag; |
| 142 | unsigned int cur_adc_format; |
| 143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 145 | unsigned int num_mux_defs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | const struct hda_input_mux *input_mux; |
| 147 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 148 | hda_nid_t ext_mic_pin; |
| 149 | hda_nid_t dock_mic_pin; |
| 150 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 153 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 155 | int need_dac_fix; |
Hector Martin | 3b315d7 | 2009-06-02 10:54:19 +0200 | [diff] [blame] | 156 | int const_channel_count; |
| 157 | int ext_channel_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | |
| 159 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 160 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 161 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 162 | /* dynamic controls, init_verbs and input_mux */ |
| 163 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 164 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 165 | struct snd_array kctls; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 166 | struct hda_input_mux private_imux[3]; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 167 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 168 | hda_nid_t private_adc_nids[AUTO_CFG_MAX_OUTS]; |
| 169 | hda_nid_t private_capsrc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 170 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 171 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 172 | int int_mic_idx, ext_mic_idx, dock_mic_idx; /* for auto-mic */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 173 | hda_nid_t inv_dmic_pin; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 174 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 175 | /* hooks */ |
| 176 | void (*init_hook)(struct hda_codec *codec); |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 177 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 178 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 179 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 180 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 181 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 182 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 183 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 184 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 185 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 186 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 187 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 188 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 189 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 190 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 191 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 192 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 193 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 194 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 195 | unsigned int keep_vref_in_automute:1; /* Don't clear VREF in automute */ |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 196 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 197 | /* other flags */ |
| 198 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 199 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 200 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 201 | unsigned int vol_in_capsrc:1; /* use capsrc volume (ADC has no vol) */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 202 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 203 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 204 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ |
| 205 | unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */ |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 206 | unsigned int no_primary_hp:1; /* Don't prefer HP pins to speaker pins */ |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 207 | |
| 208 | /* auto-mute control */ |
| 209 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 210 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 211 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 212 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 213 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 214 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 215 | /* for virtual master */ |
| 216 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 217 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 218 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 219 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 220 | int num_loopbacks; |
| 221 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 222 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 223 | |
| 224 | /* for PLL fix */ |
| 225 | hda_nid_t pll_nid; |
| 226 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 227 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 228 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 229 | /* multi-io */ |
| 230 | int multi_ios; |
| 231 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 232 | |
| 233 | /* bind volumes */ |
| 234 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 235 | }; |
| 236 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 237 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 238 | int dir, unsigned int bits) |
| 239 | { |
| 240 | if (!nid) |
| 241 | return false; |
| 242 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 243 | if (query_amp_caps(codec, nid, dir) & bits) |
| 244 | return true; |
| 245 | return false; |
| 246 | } |
| 247 | |
| 248 | #define nid_has_mute(codec, nid, dir) \ |
| 249 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 250 | #define nid_has_volume(codec, nid, dir) \ |
| 251 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 252 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | /* |
| 254 | * input MUX handling |
| 255 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 256 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 257 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | { |
| 259 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 260 | struct alc_spec *spec = codec->spec; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 261 | unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id); |
| 262 | if (mux_idx >= spec->num_mux_defs) |
| 263 | mux_idx = 0; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 264 | if (!spec->input_mux[mux_idx].num_items && mux_idx > 0) |
| 265 | mux_idx = 0; |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 266 | return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 269 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 270 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | { |
| 272 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 273 | struct alc_spec *spec = codec->spec; |
| 274 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 275 | |
| 276 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 277 | return 0; |
| 278 | } |
| 279 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 280 | static bool alc_dyn_adc_pcm_resetup(struct hda_codec *codec, int cur) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 282 | struct alc_spec *spec = codec->spec; |
| 283 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 284 | |
| 285 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 286 | /* stream is running, let's swap the current ADC */ |
| 287 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 288 | spec->cur_adc = new_adc; |
| 289 | snd_hda_codec_setup_stream(codec, new_adc, |
| 290 | spec->cur_adc_stream_tag, 0, |
| 291 | spec->cur_adc_format); |
| 292 | return true; |
| 293 | } |
| 294 | return false; |
| 295 | } |
| 296 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 297 | static inline hda_nid_t get_capsrc(struct alc_spec *spec, int idx) |
| 298 | { |
| 299 | return spec->capsrc_nids ? |
| 300 | spec->capsrc_nids[idx] : spec->adc_nids[idx]; |
| 301 | } |
| 302 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 303 | static void call_update_outputs(struct hda_codec *codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 304 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 305 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 306 | /* for shared I/O, change the pin-control accordingly */ |
| 307 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) |
| 308 | { |
| 309 | struct alc_spec *spec = codec->spec; |
| 310 | unsigned int val; |
| 311 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
| 312 | /* NOTE: this assumes that there are only two inputs, the |
| 313 | * first is the real internal mic and the second is HP/mic jack. |
| 314 | */ |
| 315 | |
| 316 | val = snd_hda_get_default_vref(codec, pin); |
| 317 | |
| 318 | /* This pin does not have vref caps - let's enable vref on pin 0x18 |
| 319 | instead, as suggested by Realtek */ |
| 320 | if (val == AC_PINCTL_VREF_HIZ) { |
| 321 | const hda_nid_t vref_pin = 0x18; |
| 322 | /* Sanity check pin 0x18 */ |
| 323 | if (get_wcaps_type(get_wcaps(codec, vref_pin)) == AC_WID_PIN && |
| 324 | get_defcfg_connect(snd_hda_codec_get_pincfg(codec, vref_pin)) == AC_JACK_PORT_NONE) { |
| 325 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
| 326 | if (vref_val != AC_PINCTL_VREF_HIZ) |
| 327 | snd_hda_set_pin_ctl(codec, vref_pin, PIN_IN | (set_as_mic ? vref_val : 0)); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | val = set_as_mic ? val | PIN_IN : PIN_HP; |
| 332 | snd_hda_set_pin_ctl(codec, pin, val); |
| 333 | |
| 334 | spec->automute_speaker = !set_as_mic; |
| 335 | call_update_outputs(codec); |
| 336 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 337 | |
| 338 | /* select the given imux item; either unmute exclusively or select the route */ |
| 339 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 340 | unsigned int idx, bool force) |
| 341 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 343 | const struct hda_input_mux *imux; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 344 | unsigned int mux_idx; |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 345 | int i, type, num_conns; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 346 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | |
Takashi Iwai | 5803a32 | 2012-02-21 11:59:45 +0100 | [diff] [blame] | 348 | if (!spec->input_mux) |
| 349 | return 0; |
| 350 | |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 351 | mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx; |
| 352 | imux = &spec->input_mux[mux_idx]; |
Takashi Iwai | 5311114 | 2010-03-08 12:13:07 +0100 | [diff] [blame] | 353 | if (!imux->num_items && mux_idx > 0) |
| 354 | imux = &spec->input_mux[0]; |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 355 | if (!imux->num_items) |
| 356 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 357 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 358 | if (idx >= imux->num_items) |
| 359 | idx = imux->num_items - 1; |
| 360 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 361 | return 0; |
| 362 | spec->cur_mux[adc_idx] = idx; |
| 363 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 364 | if (spec->shared_mic_hp) |
| 365 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 366 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 367 | if (spec->dyn_adc_switch) { |
| 368 | alc_dyn_adc_pcm_resetup(codec, idx); |
| 369 | adc_idx = spec->dyn_adc_idx[idx]; |
| 370 | } |
| 371 | |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 372 | nid = get_capsrc(spec, adc_idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 373 | |
| 374 | /* no selection? */ |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 375 | num_conns = snd_hda_get_num_conns(codec, nid); |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 376 | if (num_conns <= 1) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 377 | return 1; |
| 378 | |
Takashi Iwai | a22d543 | 2009-07-27 12:54:26 +0200 | [diff] [blame] | 379 | type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 0169b6b | 2009-06-22 10:50:19 +0200 | [diff] [blame] | 380 | if (type == AC_WID_AUD_MIX) { |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 381 | /* Matrix-mixer style (e.g. ALC882) */ |
Takashi Iwai | dccc181 | 2011-11-08 07:52:19 +0100 | [diff] [blame] | 382 | int active = imux->items[idx].index; |
| 383 | for (i = 0; i < num_conns; i++) { |
| 384 | unsigned int v = (i == active) ? 0 : HDA_AMP_MUTE; |
| 385 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, i, |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 386 | HDA_AMP_MUTE, v); |
| 387 | } |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 388 | } else { |
| 389 | /* MUX style (e.g. ALC880) */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 390 | snd_hda_codec_write_cache(codec, nid, 0, |
| 391 | AC_VERB_SET_CONNECT_SEL, |
| 392 | imux->items[idx].index); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 393 | } |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 394 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 395 | return 1; |
| 396 | } |
| 397 | |
| 398 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 399 | struct snd_ctl_elem_value *ucontrol) |
| 400 | { |
| 401 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 402 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 403 | return alc_mux_select(codec, adc_idx, |
| 404 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 405 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 406 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 407 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 408 | * set up the input pin config (depending on the given auto-pin type) |
| 409 | */ |
| 410 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 411 | int auto_pin_type) |
| 412 | { |
| 413 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 414 | if (auto_pin_type == AUTO_PIN_MIC) |
| 415 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 416 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 420 | * Append the given mixer and verb elements for the later use |
| 421 | * The mixer array is referred in build_controls(), and init_verbs are |
| 422 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 423 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 424 | static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix) |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 425 | { |
| 426 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 427 | return; |
| 428 | spec->mixers[spec->num_mixers++] = mix; |
| 429 | } |
| 430 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 431 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 432 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 433 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 434 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 435 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 436 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 437 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 438 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 439 | { } |
| 440 | }; |
| 441 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 442 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 443 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 444 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 445 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 446 | { } |
| 447 | }; |
| 448 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 449 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 450 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 451 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 452 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 453 | { } |
| 454 | }; |
| 455 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 456 | /* |
| 457 | * Fix hardware PLL issue |
| 458 | * On some codecs, the analog PLL gating control must be off while |
| 459 | * the default value is 1. |
| 460 | */ |
| 461 | static void alc_fix_pll(struct hda_codec *codec) |
| 462 | { |
| 463 | struct alc_spec *spec = codec->spec; |
| 464 | unsigned int val; |
| 465 | |
| 466 | if (!spec->pll_nid) |
| 467 | return; |
| 468 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 469 | spec->pll_coef_idx); |
| 470 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 471 | AC_VERB_GET_PROC_COEF, 0); |
| 472 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 473 | spec->pll_coef_idx); |
| 474 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 475 | val & ~(1 << spec->pll_coef_bit)); |
| 476 | } |
| 477 | |
| 478 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 479 | unsigned int coef_idx, unsigned int coef_bit) |
| 480 | { |
| 481 | struct alc_spec *spec = codec->spec; |
| 482 | spec->pll_nid = nid; |
| 483 | spec->pll_coef_idx = coef_idx; |
| 484 | spec->pll_coef_bit = coef_bit; |
| 485 | alc_fix_pll(codec); |
| 486 | } |
| 487 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 488 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 489 | * Jack detections for HP auto-mute and mic-switch |
| 490 | */ |
| 491 | |
| 492 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 493 | static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins) |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 494 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 495 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 496 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 497 | for (i = 0; i < num_pins; i++) { |
| 498 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 499 | if (!nid) |
| 500 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 501 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 502 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 503 | return present; |
| 504 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 505 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 506 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 507 | static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins, |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 508 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 509 | { |
| 510 | struct alc_spec *spec = codec->spec; |
| 511 | unsigned int mute_bits = mute ? HDA_AMP_MUTE : 0; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 512 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 513 | int i; |
| 514 | |
| 515 | for (i = 0; i < num_pins; i++) { |
| 516 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 517 | unsigned int val; |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 518 | if (!nid) |
| 519 | break; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 520 | switch (spec->automute_mode) { |
| 521 | case ALC_AUTOMUTE_PIN: |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 522 | /* don't reset VREF value in case it's controlling |
| 523 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 524 | */ |
| 525 | if (spec->keep_vref_in_automute) { |
| 526 | val = snd_hda_codec_read(codec, nid, 0, |
| 527 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 528 | val &= ~PIN_HP; |
| 529 | } else |
| 530 | val = 0; |
| 531 | val |= pin_bits; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 532 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 533 | break; |
| 534 | case ALC_AUTOMUTE_AMP: |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 535 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 536 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 537 | break; |
| 538 | case ALC_AUTOMUTE_MIXER: |
| 539 | nid = spec->automute_mixer_nid[i]; |
| 540 | if (!nid) |
| 541 | break; |
| 542 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 543 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 544 | snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 1, |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 545 | HDA_AMP_MUTE, mute_bits); |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 546 | break; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 547 | } |
Takashi Iwai | a9fd4f3 | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 548 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 549 | } |
| 550 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 551 | /* Toggle outputs muting */ |
| 552 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 553 | { |
| 554 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 555 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 556 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 557 | /* Control HP pins/amps depending on master_mute state; |
| 558 | * in general, HP pins/amps control should be enabled in all cases, |
| 559 | * but currently set only for master_mute, just to be safe |
| 560 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 561 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 562 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 563 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 564 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 565 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 566 | on = 0; |
| 567 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 568 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 569 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 570 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 571 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 572 | |
| 573 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 574 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 575 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 576 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 577 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 578 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 579 | on = 0; |
| 580 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 581 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 582 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 583 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 584 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 585 | } |
| 586 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 587 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 588 | { |
| 589 | struct alc_spec *spec = codec->spec; |
| 590 | if (spec->automute_hook) |
| 591 | spec->automute_hook(codec); |
| 592 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 593 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 594 | } |
| 595 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 596 | /* standard HP-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 597 | static void alc_hp_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 598 | { |
| 599 | struct alc_spec *spec = codec->spec; |
| 600 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 601 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 602 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 603 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 604 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 605 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 606 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 607 | } |
| 608 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 609 | /* standard line-out-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 610 | static void alc_line_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 611 | { |
| 612 | struct alc_spec *spec = codec->spec; |
| 613 | |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 614 | /* check LO jack only when it's different from HP */ |
| 615 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 616 | return; |
| 617 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 618 | spec->line_jack_present = |
| 619 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 620 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 621 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 622 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 623 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 624 | } |
| 625 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 626 | #define get_connection_index(codec, mux, nid) \ |
| 627 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 628 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 629 | /* standard mic auto-switch helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 630 | static void alc_mic_automute(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 631 | { |
| 632 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 633 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 634 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 635 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 636 | return; |
| 637 | if (snd_BUG_ON(!spec->adc_nids)) |
| 638 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 639 | if (snd_BUG_ON(spec->int_mic_idx < 0 || spec->ext_mic_idx < 0)) |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 640 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 641 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 642 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 643 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 644 | else if (spec->dock_mic_idx >= 0 && |
| 645 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 646 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 647 | else |
| 648 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 649 | } |
| 650 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 651 | /* update the master volume per volume-knob's unsol event */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 652 | static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack) |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 653 | { |
| 654 | unsigned int val; |
| 655 | struct snd_kcontrol *kctl; |
| 656 | struct snd_ctl_elem_value *uctl; |
| 657 | |
| 658 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 659 | if (!kctl) |
| 660 | return; |
| 661 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 662 | if (!uctl) |
| 663 | return; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 664 | val = snd_hda_codec_read(codec, jack->nid, 0, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 665 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 666 | val &= HDA_AMP_VOLMASK; |
| 667 | uctl->value.integer.value[0] = val; |
| 668 | uctl->value.integer.value[1] = val; |
| 669 | kctl->put(kctl, uctl); |
| 670 | kfree(uctl); |
| 671 | } |
| 672 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 673 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 674 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 675 | /* For some reason, the res given from ALC880 is broken. |
| 676 | Here we adjust it properly. */ |
| 677 | snd_hda_jack_unsol_event(codec, res >> 2); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 678 | } |
| 679 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 680 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 681 | static void alc_inithook(struct hda_codec *codec) |
| 682 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 683 | alc_hp_automute(codec, NULL); |
| 684 | alc_line_automute(codec, NULL); |
| 685 | alc_mic_automute(codec, NULL); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 686 | } |
| 687 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 688 | /* additional initialization for ALC888 variants */ |
| 689 | static void alc888_coef_init(struct hda_codec *codec) |
| 690 | { |
| 691 | unsigned int tmp; |
| 692 | |
| 693 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 694 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 695 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
Takashi Iwai | 37db623 | 2009-03-05 09:40:16 +0100 | [diff] [blame] | 696 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 697 | /* alc888S-VC */ |
| 698 | snd_hda_codec_read(codec, 0x20, 0, |
| 699 | AC_VERB_SET_PROC_COEF, 0x830); |
| 700 | else |
| 701 | /* alc888-VB */ |
| 702 | snd_hda_codec_read(codec, 0x20, 0, |
| 703 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 704 | } |
| 705 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 706 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 707 | static void alc889_coef_init(struct hda_codec *codec) |
| 708 | { |
| 709 | unsigned int tmp; |
| 710 | |
| 711 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 712 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 713 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 714 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 715 | } |
| 716 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 717 | /* turn on/off EAPD control (only if available) */ |
| 718 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 719 | { |
| 720 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 721 | return; |
| 722 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 723 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 724 | on ? 2 : 0); |
| 725 | } |
| 726 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 727 | /* turn on/off EAPD controls of the codec */ |
| 728 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 729 | { |
| 730 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 731 | static hda_nid_t pins[] = { |
| 732 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 733 | }; |
| 734 | hda_nid_t *p; |
| 735 | for (p = pins; *p; p++) |
| 736 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 737 | } |
| 738 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 739 | /* generic shutup callback; |
| 740 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 741 | */ |
| 742 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 743 | { |
| 744 | alc_auto_setup_eapd(codec, false); |
| 745 | msleep(200); |
| 746 | } |
| 747 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 748 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 749 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 750 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 751 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 752 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 753 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 754 | switch (type) { |
| 755 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 756 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 757 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 758 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 759 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 760 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 761 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 762 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 763 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 764 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 765 | switch (codec->vendor_id) { |
| 766 | case 0x10ec0260: |
| 767 | snd_hda_codec_write(codec, 0x1a, 0, |
| 768 | AC_VERB_SET_COEF_INDEX, 7); |
| 769 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 770 | AC_VERB_GET_PROC_COEF, 0); |
| 771 | snd_hda_codec_write(codec, 0x1a, 0, |
| 772 | AC_VERB_SET_COEF_INDEX, 7); |
| 773 | snd_hda_codec_write(codec, 0x1a, 0, |
| 774 | AC_VERB_SET_PROC_COEF, |
| 775 | tmp | 0x2010); |
| 776 | break; |
| 777 | case 0x10ec0262: |
| 778 | case 0x10ec0880: |
| 779 | case 0x10ec0882: |
| 780 | case 0x10ec0883: |
| 781 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 782 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 783 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 784 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 785 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 786 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 787 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 788 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 789 | #if 0 /* XXX: This may cause the silent output on speaker on some machines */ |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 790 | case 0x10ec0267: |
| 791 | case 0x10ec0268: |
| 792 | snd_hda_codec_write(codec, 0x20, 0, |
| 793 | AC_VERB_SET_COEF_INDEX, 7); |
| 794 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 795 | AC_VERB_GET_PROC_COEF, 0); |
| 796 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 797 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 798 | snd_hda_codec_write(codec, 0x20, 0, |
| 799 | AC_VERB_SET_PROC_COEF, |
| 800 | tmp | 0x3000); |
| 801 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 802 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 803 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 804 | break; |
| 805 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 806 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 807 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 808 | /* |
| 809 | * Auto-Mute mode mixer enum support |
| 810 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 811 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 812 | struct snd_ctl_elem_info *uinfo) |
| 813 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 814 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 815 | struct alc_spec *spec = codec->spec; |
| 816 | static const char * const texts2[] = { |
| 817 | "Disabled", "Enabled" |
| 818 | }; |
| 819 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 820 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 821 | }; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 822 | const char * const *texts; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 823 | |
| 824 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 825 | uinfo->count = 1; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 826 | if (spec->automute_speaker_possible && spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 827 | uinfo->value.enumerated.items = 3; |
| 828 | texts = texts3; |
| 829 | } else { |
| 830 | uinfo->value.enumerated.items = 2; |
| 831 | texts = texts2; |
| 832 | } |
| 833 | if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) |
| 834 | uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 835 | strcpy(uinfo->value.enumerated.name, |
| 836 | texts[uinfo->value.enumerated.item]); |
| 837 | return 0; |
| 838 | } |
| 839 | |
| 840 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 841 | struct snd_ctl_elem_value *ucontrol) |
| 842 | { |
| 843 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 844 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 845 | unsigned int val = 0; |
| 846 | if (spec->automute_speaker) |
| 847 | val++; |
| 848 | if (spec->automute_lo) |
| 849 | val++; |
| 850 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 851 | ucontrol->value.enumerated.item[0] = val; |
| 852 | return 0; |
| 853 | } |
| 854 | |
| 855 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 856 | struct snd_ctl_elem_value *ucontrol) |
| 857 | { |
| 858 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 859 | struct alc_spec *spec = codec->spec; |
| 860 | |
| 861 | switch (ucontrol->value.enumerated.item[0]) { |
| 862 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 863 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 864 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 865 | spec->automute_speaker = 0; |
| 866 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 867 | break; |
| 868 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 869 | if (spec->automute_speaker_possible) { |
| 870 | if (!spec->automute_lo && spec->automute_speaker) |
| 871 | return 0; |
| 872 | spec->automute_speaker = 1; |
| 873 | spec->automute_lo = 0; |
| 874 | } else if (spec->automute_lo_possible) { |
| 875 | if (spec->automute_lo) |
| 876 | return 0; |
| 877 | spec->automute_lo = 1; |
| 878 | } else |
| 879 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 880 | break; |
| 881 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 882 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 883 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 884 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 885 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 886 | spec->automute_speaker = 1; |
| 887 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 888 | break; |
| 889 | default: |
| 890 | return -EINVAL; |
| 891 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 892 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 893 | return 1; |
| 894 | } |
| 895 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 896 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 897 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 898 | .name = "Auto-Mute Mode", |
| 899 | .info = alc_automute_mode_info, |
| 900 | .get = alc_automute_mode_get, |
| 901 | .put = alc_automute_mode_put, |
| 902 | }; |
| 903 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 904 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) |
| 905 | { |
| 906 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 907 | return snd_array_new(&spec->kctls); |
| 908 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 909 | |
| 910 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 911 | { |
| 912 | struct alc_spec *spec = codec->spec; |
| 913 | struct snd_kcontrol_new *knew; |
| 914 | |
| 915 | knew = alc_kcontrol_new(spec); |
| 916 | if (!knew) |
| 917 | return -ENOMEM; |
| 918 | *knew = alc_automute_mode_enum; |
| 919 | knew->name = kstrdup("Auto-Mute Mode", GFP_KERNEL); |
| 920 | if (!knew->name) |
| 921 | return -ENOMEM; |
| 922 | return 0; |
| 923 | } |
| 924 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 925 | /* |
| 926 | * Check the availability of HP/line-out auto-mute; |
| 927 | * Set up appropriately if really supported |
| 928 | */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 929 | static void alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 930 | { |
| 931 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 932 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 933 | int present = 0; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 934 | int i; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 935 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 936 | if (cfg->hp_pins[0]) |
| 937 | present++; |
| 938 | if (cfg->line_out_pins[0]) |
| 939 | present++; |
| 940 | if (cfg->speaker_pins[0]) |
| 941 | present++; |
| 942 | if (present < 2) /* need two different output types */ |
| 943 | return; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 944 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 945 | if (!cfg->speaker_pins[0] && |
| 946 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 947 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 948 | sizeof(cfg->speaker_pins)); |
| 949 | cfg->speaker_outs = cfg->line_outs; |
| 950 | } |
| 951 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 952 | if (!cfg->hp_pins[0] && |
| 953 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 954 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 955 | sizeof(cfg->hp_pins)); |
| 956 | cfg->hp_outs = cfg->line_outs; |
| 957 | } |
| 958 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 959 | spec->automute_mode = ALC_AUTOMUTE_PIN; |
| 960 | |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 961 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 962 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 963 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 964 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 965 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 966 | nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 967 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, |
| 968 | alc_hp_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 969 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 970 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 971 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 972 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 973 | if (cfg->speaker_outs) |
| 974 | for (i = 0; i < cfg->line_outs; i++) { |
| 975 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 976 | if (!is_jack_detectable(codec, nid)) |
| 977 | continue; |
| 978 | snd_printdd("realtek: Enable Line-Out " |
| 979 | "auto-muting on NID 0x%x\n", nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 980 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, |
| 981 | alc_line_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 982 | spec->detect_lo = 1; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 983 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 984 | spec->automute_lo_possible = spec->detect_hp; |
| 985 | } |
| 986 | |
| 987 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 988 | (spec->detect_hp || spec->detect_lo); |
| 989 | |
| 990 | spec->automute_lo = spec->automute_lo_possible; |
| 991 | spec->automute_speaker = spec->automute_speaker_possible; |
| 992 | |
David Henningsson | a7a0a64 | 2012-07-05 12:00:12 +0200 | [diff] [blame] | 993 | if (spec->automute_speaker_possible || spec->automute_lo_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 994 | /* create a control for automute mode */ |
| 995 | alc_add_automute_mode_enum(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 996 | } |
| 997 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 998 | /* return the position of NID in the list, or -1 if not found */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 999 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1000 | { |
| 1001 | int i; |
| 1002 | for (i = 0; i < nums; i++) |
| 1003 | if (list[i] == nid) |
| 1004 | return i; |
| 1005 | return -1; |
| 1006 | } |
| 1007 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1008 | /* check whether dynamic ADC-switching is available */ |
| 1009 | static bool alc_check_dyn_adc_switch(struct hda_codec *codec) |
| 1010 | { |
| 1011 | struct alc_spec *spec = codec->spec; |
| 1012 | struct hda_input_mux *imux = &spec->private_imux[0]; |
| 1013 | int i, n, idx; |
| 1014 | hda_nid_t cap, pin; |
| 1015 | |
| 1016 | if (imux != spec->input_mux) /* no dynamic imux? */ |
| 1017 | return false; |
| 1018 | |
| 1019 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1020 | cap = spec->private_capsrc_nids[n]; |
| 1021 | for (i = 0; i < imux->num_items; i++) { |
| 1022 | pin = spec->imux_pins[i]; |
| 1023 | if (!pin) |
| 1024 | return false; |
| 1025 | if (get_connection_index(codec, cap, pin) < 0) |
| 1026 | break; |
| 1027 | } |
| 1028 | if (i >= imux->num_items) |
Takashi Iwai | 268ff6f | 2011-07-08 14:37:35 +0200 | [diff] [blame] | 1029 | return true; /* no ADC-switch is needed */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | for (i = 0; i < imux->num_items; i++) { |
| 1033 | pin = spec->imux_pins[i]; |
| 1034 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 1035 | cap = spec->private_capsrc_nids[n]; |
| 1036 | idx = get_connection_index(codec, cap, pin); |
| 1037 | if (idx >= 0) { |
| 1038 | imux->items[i].index = idx; |
| 1039 | spec->dyn_adc_idx[i] = n; |
| 1040 | break; |
| 1041 | } |
| 1042 | } |
| 1043 | } |
| 1044 | |
| 1045 | snd_printdd("realtek: enabling ADC switching\n"); |
| 1046 | spec->dyn_adc_switch = 1; |
| 1047 | return true; |
| 1048 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1049 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1050 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 1051 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 1052 | { |
| 1053 | struct alc_spec *spec = codec->spec; |
| 1054 | const struct hda_input_mux *imux; |
| 1055 | |
| 1056 | if (!spec->auto_mic) |
| 1057 | return false; |
| 1058 | if (spec->auto_mic_valid_imux) |
| 1059 | return true; /* already checked */ |
| 1060 | |
| 1061 | /* fill up imux indices */ |
| 1062 | if (!alc_check_dyn_adc_switch(codec)) { |
| 1063 | spec->auto_mic = 0; |
| 1064 | return false; |
| 1065 | } |
| 1066 | |
| 1067 | imux = spec->input_mux; |
| 1068 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 1069 | spec->imux_pins, imux->num_items); |
| 1070 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 1071 | spec->imux_pins, imux->num_items); |
| 1072 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 1073 | spec->imux_pins, imux->num_items); |
| 1074 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) { |
| 1075 | spec->auto_mic = 0; |
| 1076 | return false; /* no corresponding imux */ |
| 1077 | } |
| 1078 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1079 | snd_hda_jack_detect_enable_callback(codec, spec->ext_mic_pin, |
| 1080 | ALC_MIC_EVENT, alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1081 | if (spec->dock_mic_pin) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1082 | snd_hda_jack_detect_enable_callback(codec, spec->dock_mic_pin, |
| 1083 | ALC_MIC_EVENT, |
| 1084 | alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1085 | |
| 1086 | spec->auto_mic_valid_imux = 1; |
| 1087 | spec->auto_mic = 1; |
| 1088 | return true; |
| 1089 | } |
| 1090 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1091 | /* |
| 1092 | * Check the availability of auto-mic switch; |
| 1093 | * Set up if really supported |
| 1094 | */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1095 | static void alc_init_auto_mic(struct hda_codec *codec) |
| 1096 | { |
| 1097 | struct alc_spec *spec = codec->spec; |
| 1098 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1099 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1100 | int i; |
| 1101 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 1102 | if (spec->shared_mic_hp) |
| 1103 | return; /* no auto-mic for the shared I/O */ |
| 1104 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1105 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1106 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1107 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1108 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1109 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1110 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1111 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1112 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1113 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1114 | if (fixed) |
| 1115 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1116 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1117 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1118 | fixed = nid; |
| 1119 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1120 | case INPUT_PIN_ATTR_UNUSED: |
| 1121 | return; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1122 | case INPUT_PIN_ATTR_DOCK: |
| 1123 | if (dock) |
| 1124 | return; /* already occupied */ |
| 1125 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
| 1126 | return; /* invalid type */ |
| 1127 | dock = nid; |
| 1128 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1129 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1130 | if (ext) |
| 1131 | return; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1132 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
| 1133 | return; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1134 | ext = nid; |
| 1135 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1136 | } |
| 1137 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1138 | if (!ext && dock) { |
| 1139 | ext = dock; |
| 1140 | dock = 0; |
| 1141 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1142 | if (!ext || !fixed) |
| 1143 | return; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1144 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1145 | return; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1146 | if (dock && !is_jack_detectable(codec, dock)) |
| 1147 | return; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1148 | |
| 1149 | /* check imux indices */ |
| 1150 | spec->ext_mic_pin = ext; |
| 1151 | spec->int_mic_pin = fixed; |
| 1152 | spec->dock_mic_pin = dock; |
| 1153 | |
| 1154 | spec->auto_mic = 1; |
| 1155 | if (!alc_auto_mic_check_imux(codec)) |
| 1156 | return; |
| 1157 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1158 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1159 | ext, fixed, dock); |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1160 | } |
| 1161 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1162 | /* check the availabilities of auto-mute and auto-mic switches */ |
| 1163 | static void alc_auto_check_switches(struct hda_codec *codec) |
| 1164 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 1165 | alc_init_automute(codec); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1166 | alc_init_auto_mic(codec); |
| 1167 | } |
| 1168 | |
| 1169 | /* |
| 1170 | * Realtek SSID verification |
| 1171 | */ |
| 1172 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1173 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1174 | * the driver to ignore any present sku defines. |
| 1175 | */ |
| 1176 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1177 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1178 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1179 | const struct hda_fixup *fix, int action) |
| 1180 | { |
| 1181 | struct alc_spec *spec = codec->spec; |
| 1182 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1183 | spec->cdefine.fixup = 1; |
| 1184 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1185 | } |
| 1186 | } |
| 1187 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1188 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1189 | { |
| 1190 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1191 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1192 | struct alc_spec *spec = codec->spec; |
| 1193 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1194 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1195 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1196 | if (spec->cdefine.fixup) { |
| 1197 | ass = spec->cdefine.sku_cfg; |
| 1198 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1199 | return -1; |
| 1200 | goto do_sku; |
| 1201 | } |
| 1202 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1203 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1204 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1205 | goto do_sku; |
| 1206 | |
| 1207 | nid = 0x1d; |
| 1208 | if (codec->vendor_id == 0x10ec0260) |
| 1209 | nid = 0x17; |
| 1210 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1211 | |
| 1212 | if (!(ass & 1)) { |
| 1213 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1214 | codec->chip_name, ass); |
| 1215 | return -1; |
| 1216 | } |
| 1217 | |
| 1218 | /* check sum */ |
| 1219 | tmp = 0; |
| 1220 | for (i = 1; i < 16; i++) { |
| 1221 | if ((ass >> i) & 1) |
| 1222 | tmp++; |
| 1223 | } |
| 1224 | if (((ass >> 16) & 0xf) != tmp) |
| 1225 | return -1; |
| 1226 | |
| 1227 | spec->cdefine.port_connectivity = ass >> 30; |
| 1228 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1229 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1230 | spec->cdefine.customization = ass >> 8; |
| 1231 | do_sku: |
| 1232 | spec->cdefine.sku_cfg = ass; |
| 1233 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1234 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1235 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1236 | spec->cdefine.override = ass & 0x1; |
| 1237 | |
| 1238 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1239 | nid, spec->cdefine.sku_cfg); |
| 1240 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1241 | spec->cdefine.port_connectivity); |
| 1242 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1243 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1244 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1245 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1246 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1247 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1248 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1249 | |
| 1250 | return 0; |
| 1251 | } |
| 1252 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1253 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1254 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1255 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1256 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1257 | } |
| 1258 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1259 | /* check subsystem ID and set up device-specific initialization; |
| 1260 | * return 1 if initialized, 0 if invalid SSID |
| 1261 | */ |
| 1262 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1263 | * 31 ~ 16 : Manufacture ID |
| 1264 | * 15 ~ 8 : SKU ID |
| 1265 | * 7 ~ 0 : Assembly ID |
| 1266 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1267 | */ |
| 1268 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1269 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1270 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1271 | { |
| 1272 | unsigned int ass, tmp, i; |
| 1273 | unsigned nid; |
| 1274 | struct alc_spec *spec = codec->spec; |
| 1275 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1276 | if (spec->cdefine.fixup) { |
| 1277 | ass = spec->cdefine.sku_cfg; |
| 1278 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1279 | return 0; |
| 1280 | goto do_sku; |
| 1281 | } |
| 1282 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1283 | ass = codec->subsystem_id & 0xffff; |
| 1284 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1285 | goto do_sku; |
| 1286 | |
| 1287 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1288 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1289 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1290 | * 29~21 : reserve |
| 1291 | * 20 : PCBEEP input |
| 1292 | * 19~16 : Check sum (15:1) |
| 1293 | * 15~1 : Custom |
| 1294 | * 0 : override |
| 1295 | */ |
| 1296 | nid = 0x1d; |
| 1297 | if (codec->vendor_id == 0x10ec0260) |
| 1298 | nid = 0x17; |
| 1299 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1300 | snd_printd("realtek: No valid SSID, " |
| 1301 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1302 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1303 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1304 | return 0; |
| 1305 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1306 | return 0; |
| 1307 | |
| 1308 | /* check sum */ |
| 1309 | tmp = 0; |
| 1310 | for (i = 1; i < 16; i++) { |
| 1311 | if ((ass >> i) & 1) |
| 1312 | tmp++; |
| 1313 | } |
| 1314 | if (((ass >> 16) & 0xf) != tmp) |
| 1315 | return 0; |
| 1316 | do_sku: |
| 1317 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1318 | ass & 0xffff, codec->vendor_id); |
| 1319 | /* |
| 1320 | * 0 : override |
| 1321 | * 1 : Swap Jack |
| 1322 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1323 | * 3~5 : External Amplifier control |
| 1324 | * 7~6 : Reserved |
| 1325 | */ |
| 1326 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1327 | switch (tmp) { |
| 1328 | case 1: |
| 1329 | spec->init_amp = ALC_INIT_GPIO1; |
| 1330 | break; |
| 1331 | case 3: |
| 1332 | spec->init_amp = ALC_INIT_GPIO2; |
| 1333 | break; |
| 1334 | case 7: |
| 1335 | spec->init_amp = ALC_INIT_GPIO3; |
| 1336 | break; |
| 1337 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1338 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1339 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1340 | break; |
| 1341 | } |
| 1342 | |
| 1343 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1344 | * when the external headphone out jack is plugged" |
| 1345 | */ |
| 1346 | if (!(ass & 0x8000)) |
| 1347 | return 1; |
| 1348 | /* |
| 1349 | * 10~8 : Jack location |
| 1350 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1351 | * 14~13: Resvered |
| 1352 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1353 | * when the external headphone out jack is plugged" |
| 1354 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1355 | if (!spec->autocfg.hp_pins[0] && |
| 1356 | !(spec->autocfg.line_out_pins[0] && |
| 1357 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1358 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1359 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1360 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1361 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1362 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1363 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1364 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1365 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1366 | else if (tmp == 3) |
| 1367 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1368 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1369 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1370 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1371 | spec->autocfg.line_outs)) |
| 1372 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1373 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1374 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1375 | return 1; |
| 1376 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1377 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1378 | /* Check the validity of ALC subsystem-id |
| 1379 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1380 | static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1381 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1382 | if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1383 | struct alc_spec *spec = codec->spec; |
| 1384 | snd_printd("realtek: " |
| 1385 | "Enable default setup for auto mode as fallback\n"); |
| 1386 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1387 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1388 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1389 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1390 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1391 | * COEF access helper functions |
| 1392 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1393 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1394 | unsigned int coef_idx) |
| 1395 | { |
| 1396 | unsigned int val; |
| 1397 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1398 | coef_idx); |
| 1399 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1400 | AC_VERB_GET_PROC_COEF, 0); |
| 1401 | return val; |
| 1402 | } |
| 1403 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1404 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1405 | unsigned int coef_val) |
| 1406 | { |
| 1407 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1408 | coef_idx); |
| 1409 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1410 | coef_val); |
| 1411 | } |
| 1412 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1413 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1414 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1415 | { |
| 1416 | struct alc_spec *spec = codec->spec; |
| 1417 | if (!spec->coef0) |
| 1418 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1419 | return spec->coef0; |
| 1420 | } |
| 1421 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1422 | /* |
| 1423 | * Digital I/O handling |
| 1424 | */ |
| 1425 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1426 | /* set right pin controls for digital I/O */ |
| 1427 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1428 | { |
| 1429 | struct alc_spec *spec = codec->spec; |
| 1430 | int i; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1431 | hda_nid_t pin, dac; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1432 | |
| 1433 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1434 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1435 | if (!pin) |
| 1436 | continue; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1437 | snd_hda_set_pin_ctl(codec, pin, PIN_OUT); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1438 | if (!i) |
| 1439 | dac = spec->multiout.dig_out_nid; |
| 1440 | else |
| 1441 | dac = spec->slave_dig_outs[i - 1]; |
| 1442 | if (!dac || !(get_wcaps(codec, dac) & AC_WCAP_OUT_AMP)) |
| 1443 | continue; |
| 1444 | snd_hda_codec_write(codec, dac, 0, |
| 1445 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 1446 | AMP_OUT_UNMUTE); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1447 | } |
| 1448 | pin = spec->autocfg.dig_in_pin; |
| 1449 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1450 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1451 | } |
| 1452 | |
| 1453 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1454 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1455 | { |
| 1456 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1457 | int i, err, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1458 | hda_nid_t dig_nid; |
| 1459 | |
| 1460 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1461 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1462 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1463 | hda_nid_t conn[4]; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1464 | err = snd_hda_get_connections(codec, |
| 1465 | spec->autocfg.dig_out_pins[i], |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1466 | conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1467 | if (err <= 0) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1468 | continue; |
Takashi Iwai | a926757 | 2011-07-07 15:12:55 +0200 | [diff] [blame] | 1469 | dig_nid = conn[0]; /* assume the first element is audio-out */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1470 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1471 | spec->multiout.dig_out_nid = dig_nid; |
| 1472 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1473 | } else { |
| 1474 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1475 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1476 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1477 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1478 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1479 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1480 | } |
| 1481 | |
| 1482 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1483 | dig_nid = codec->start_nid; |
| 1484 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
| 1485 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1486 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1487 | continue; |
| 1488 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1489 | continue; |
| 1490 | if (!(wcaps & AC_WCAP_CONN_LIST)) |
| 1491 | continue; |
| 1492 | err = get_connection_index(codec, dig_nid, |
| 1493 | spec->autocfg.dig_in_pin); |
| 1494 | if (err >= 0) { |
| 1495 | spec->dig_in_nid = dig_nid; |
| 1496 | break; |
| 1497 | } |
| 1498 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1499 | } |
| 1500 | } |
| 1501 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1502 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1503 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1504 | */ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1505 | static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, |
| 1506 | struct snd_ctl_elem_info *uinfo) |
| 1507 | { |
| 1508 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1509 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1510 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1511 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1512 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1513 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1514 | if (spec->vol_in_capsrc) |
| 1515 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1516 | else |
| 1517 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1518 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1519 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1520 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1521 | return err; |
| 1522 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1523 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1524 | static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, |
| 1525 | unsigned int size, unsigned int __user *tlv) |
| 1526 | { |
| 1527 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1528 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1529 | unsigned long val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1530 | int err; |
| 1531 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1532 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1533 | if (spec->vol_in_capsrc) |
| 1534 | val = HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[0], 3, 0, HDA_OUTPUT); |
| 1535 | else |
| 1536 | val = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, HDA_INPUT); |
| 1537 | kcontrol->private_value = val; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1538 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1539 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1540 | return err; |
| 1541 | } |
| 1542 | |
| 1543 | typedef int (*getput_call_t)(struct snd_kcontrol *kcontrol, |
| 1544 | struct snd_ctl_elem_value *ucontrol); |
| 1545 | |
| 1546 | static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, |
| 1547 | struct snd_ctl_elem_value *ucontrol, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1548 | getput_call_t func, bool is_put) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1549 | { |
| 1550 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1551 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1552 | int i, err = 0; |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1553 | |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1554 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1555 | if (is_put && spec->dyn_adc_switch) { |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1556 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1557 | kcontrol->private_value = |
| 1558 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1559 | 3, 0, HDA_INPUT); |
| 1560 | err = func(kcontrol, ucontrol); |
| 1561 | if (err < 0) |
| 1562 | goto error; |
| 1563 | } |
| 1564 | } else { |
| 1565 | i = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 1566 | if (spec->vol_in_capsrc) |
| 1567 | kcontrol->private_value = |
| 1568 | HDA_COMPOSE_AMP_VAL(spec->capsrc_nids[i], |
| 1569 | 3, 0, HDA_OUTPUT); |
| 1570 | else |
| 1571 | kcontrol->private_value = |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1572 | HDA_COMPOSE_AMP_VAL(spec->adc_nids[i], |
| 1573 | 3, 0, HDA_INPUT); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1574 | err = func(kcontrol, ucontrol); |
| 1575 | } |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1576 | if (err >= 0 && is_put) |
| 1577 | alc_inv_dmic_sync(codec, false); |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1578 | error: |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1579 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1580 | return err; |
| 1581 | } |
| 1582 | |
| 1583 | static int alc_cap_vol_get(struct snd_kcontrol *kcontrol, |
| 1584 | struct snd_ctl_elem_value *ucontrol) |
| 1585 | { |
| 1586 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1587 | snd_hda_mixer_amp_volume_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1588 | } |
| 1589 | |
| 1590 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1591 | struct snd_ctl_elem_value *ucontrol) |
| 1592 | { |
| 1593 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1594 | snd_hda_mixer_amp_volume_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1595 | } |
| 1596 | |
| 1597 | /* capture mixer elements */ |
| 1598 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
| 1599 | |
| 1600 | static int alc_cap_sw_get(struct snd_kcontrol *kcontrol, |
| 1601 | struct snd_ctl_elem_value *ucontrol) |
| 1602 | { |
| 1603 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1604 | snd_hda_mixer_amp_switch_get, false); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1608 | struct snd_ctl_elem_value *ucontrol) |
| 1609 | { |
| 1610 | return alc_cap_getput_caller(kcontrol, ucontrol, |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1611 | snd_hda_mixer_amp_switch_put, true); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1612 | } |
| 1613 | |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1614 | #define _DEFINE_CAPMIX(num) \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1615 | { \ |
| 1616 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1617 | .name = "Capture Switch", \ |
| 1618 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ |
| 1619 | .count = num, \ |
| 1620 | .info = alc_cap_sw_info, \ |
| 1621 | .get = alc_cap_sw_get, \ |
| 1622 | .put = alc_cap_sw_put, \ |
| 1623 | }, \ |
| 1624 | { \ |
| 1625 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1626 | .name = "Capture Volume", \ |
| 1627 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | \ |
| 1628 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ |
| 1629 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), \ |
| 1630 | .count = num, \ |
| 1631 | .info = alc_cap_vol_info, \ |
| 1632 | .get = alc_cap_vol_get, \ |
| 1633 | .put = alc_cap_vol_put, \ |
| 1634 | .tlv = { .c = alc_cap_vol_tlv }, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1635 | } |
| 1636 | |
| 1637 | #define _DEFINE_CAPSRC(num) \ |
Takashi Iwai | 3c3e989 | 2008-10-31 17:48:56 +0100 | [diff] [blame] | 1638 | { \ |
| 1639 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ |
| 1640 | /* .name = "Capture Source", */ \ |
| 1641 | .name = "Input Source", \ |
| 1642 | .count = num, \ |
| 1643 | .info = alc_mux_enum_info, \ |
| 1644 | .get = alc_mux_enum_get, \ |
| 1645 | .put = alc_mux_enum_put, \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | #define DEFINE_CAPMIX(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1649 | static const struct snd_kcontrol_new alc_capture_mixer ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1650 | _DEFINE_CAPMIX(num), \ |
| 1651 | _DEFINE_CAPSRC(num), \ |
| 1652 | { } /* end */ \ |
| 1653 | } |
| 1654 | |
| 1655 | #define DEFINE_CAPMIX_NOSRC(num) \ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1656 | static const struct snd_kcontrol_new alc_capture_mixer_nosrc ## num[] = { \ |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1657 | _DEFINE_CAPMIX(num), \ |
| 1658 | { } /* end */ \ |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1659 | } |
| 1660 | |
| 1661 | /* up to three ADCs */ |
| 1662 | DEFINE_CAPMIX(1); |
| 1663 | DEFINE_CAPMIX(2); |
| 1664 | DEFINE_CAPMIX(3); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1665 | DEFINE_CAPMIX_NOSRC(1); |
| 1666 | DEFINE_CAPMIX_NOSRC(2); |
| 1667 | DEFINE_CAPMIX_NOSRC(3); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1668 | |
| 1669 | /* |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1670 | * Inverted digital-mic handling |
| 1671 | * |
| 1672 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" |
| 1673 | * gives the additional mute only to the right channel of the digital mic |
| 1674 | * capture stream. This is a workaround for avoiding the almost silence |
| 1675 | * by summing the stereo stream from some (known to be ForteMedia) |
| 1676 | * digital mic unit. |
| 1677 | * |
| 1678 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) |
| 1679 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel |
| 1680 | * without caching so that the cache can still keep the original value. |
| 1681 | * The cached value is then restored when the flag is set off or any other |
| 1682 | * than d-mic is used as the current input source. |
| 1683 | */ |
| 1684 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) |
| 1685 | { |
| 1686 | struct alc_spec *spec = codec->spec; |
| 1687 | int i; |
| 1688 | |
| 1689 | if (!spec->inv_dmic_fixup) |
| 1690 | return; |
| 1691 | if (!spec->inv_dmic_muted && !force) |
| 1692 | return; |
| 1693 | for (i = 0; i < spec->num_adc_nids; i++) { |
| 1694 | int src = spec->dyn_adc_switch ? 0 : i; |
| 1695 | bool dmic_fixup = false; |
| 1696 | hda_nid_t nid; |
| 1697 | int parm, dir, v; |
| 1698 | |
| 1699 | if (spec->inv_dmic_muted && |
| 1700 | spec->imux_pins[spec->cur_mux[src]] == spec->inv_dmic_pin) |
| 1701 | dmic_fixup = true; |
| 1702 | if (!dmic_fixup && !force) |
| 1703 | continue; |
| 1704 | if (spec->vol_in_capsrc) { |
| 1705 | nid = spec->capsrc_nids[i]; |
| 1706 | parm = AC_AMP_SET_RIGHT | AC_AMP_SET_OUTPUT; |
| 1707 | dir = HDA_OUTPUT; |
| 1708 | } else { |
| 1709 | nid = spec->adc_nids[i]; |
| 1710 | parm = AC_AMP_SET_RIGHT | AC_AMP_SET_INPUT; |
| 1711 | dir = HDA_INPUT; |
| 1712 | } |
| 1713 | /* we care only right channel */ |
| 1714 | v = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); |
| 1715 | if (v & 0x80) /* if already muted, we don't need to touch */ |
| 1716 | continue; |
| 1717 | if (dmic_fixup) /* add mute for d-mic */ |
| 1718 | v |= 0x80; |
| 1719 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1720 | parm | v); |
| 1721 | } |
| 1722 | } |
| 1723 | |
| 1724 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
| 1725 | struct snd_ctl_elem_value *ucontrol) |
| 1726 | { |
| 1727 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1728 | struct alc_spec *spec = codec->spec; |
| 1729 | |
| 1730 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; |
| 1731 | return 0; |
| 1732 | } |
| 1733 | |
| 1734 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, |
| 1735 | struct snd_ctl_elem_value *ucontrol) |
| 1736 | { |
| 1737 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1738 | struct alc_spec *spec = codec->spec; |
| 1739 | unsigned int val = !ucontrol->value.integer.value[0]; |
| 1740 | |
| 1741 | if (val == spec->inv_dmic_muted) |
| 1742 | return 0; |
| 1743 | spec->inv_dmic_muted = val; |
| 1744 | alc_inv_dmic_sync(codec, true); |
| 1745 | return 0; |
| 1746 | } |
| 1747 | |
| 1748 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { |
| 1749 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1750 | .info = snd_ctl_boolean_mono_info, |
| 1751 | .get = alc_inv_dmic_sw_get, |
| 1752 | .put = alc_inv_dmic_sw_put, |
| 1753 | }; |
| 1754 | |
| 1755 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) |
| 1756 | { |
| 1757 | struct alc_spec *spec = codec->spec; |
| 1758 | struct snd_kcontrol_new *knew = alc_kcontrol_new(spec); |
| 1759 | if (!knew) |
| 1760 | return -ENOMEM; |
| 1761 | *knew = alc_inv_dmic_sw; |
| 1762 | knew->name = kstrdup("Inverted Internal Mic Capture Switch", GFP_KERNEL); |
| 1763 | if (!knew->name) |
| 1764 | return -ENOMEM; |
| 1765 | spec->inv_dmic_fixup = 1; |
| 1766 | spec->inv_dmic_muted = 0; |
| 1767 | spec->inv_dmic_pin = nid; |
| 1768 | return 0; |
| 1769 | } |
| 1770 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 1771 | /* typically the digital mic is put at node 0x12 */ |
| 1772 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, |
| 1773 | const struct alc_fixup *fix, int action) |
| 1774 | { |
| 1775 | if (action == ALC_FIXUP_ACT_PROBE) |
| 1776 | alc_add_inv_dmic_mixer(codec, 0x12); |
| 1777 | } |
| 1778 | |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1779 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1780 | * virtual master controls |
| 1781 | */ |
| 1782 | |
| 1783 | /* |
| 1784 | * slave controls for virtual master |
| 1785 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1786 | static const char * const alc_slave_pfxs[] = { |
| 1787 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1788 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1789 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1790 | NULL, |
| 1791 | }; |
| 1792 | |
| 1793 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1794 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1795 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1796 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1797 | #define NID_MAPPING (-1) |
| 1798 | |
| 1799 | #define SUBDEV_SPEAKER_ (0 << 6) |
| 1800 | #define SUBDEV_HP_ (1 << 6) |
| 1801 | #define SUBDEV_LINE_ (2 << 6) |
| 1802 | #define SUBDEV_SPEAKER(x) (SUBDEV_SPEAKER_ | ((x) & 0x3f)) |
| 1803 | #define SUBDEV_HP(x) (SUBDEV_HP_ | ((x) & 0x3f)) |
| 1804 | #define SUBDEV_LINE(x) (SUBDEV_LINE_ | ((x) & 0x3f)) |
| 1805 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1806 | static void alc_free_kctls(struct hda_codec *codec); |
| 1807 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1808 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1809 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1810 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1811 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1812 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1813 | { } /* end */ |
| 1814 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1815 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1816 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1817 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | { |
| 1819 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2f44f84 | 2010-06-22 11:12:32 +0200 | [diff] [blame] | 1820 | struct snd_kcontrol *kctl = NULL; |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1821 | const struct snd_kcontrol_new *knew; |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1822 | int i, j, err; |
| 1823 | unsigned int u; |
| 1824 | hda_nid_t nid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1825 | |
| 1826 | for (i = 0; i < spec->num_mixers; i++) { |
| 1827 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1828 | if (err < 0) |
| 1829 | return err; |
| 1830 | } |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1831 | if (spec->cap_mixer) { |
| 1832 | err = snd_hda_add_new_ctls(codec, spec->cap_mixer); |
| 1833 | if (err < 0) |
| 1834 | return err; |
| 1835 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1836 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1837 | err = snd_hda_create_spdif_out_ctls(codec, |
Stephen Warren | 74b654c | 2011-06-01 11:14:18 -0600 | [diff] [blame] | 1838 | spec->multiout.dig_out_nid, |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1839 | spec->multiout.dig_out_nid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | if (err < 0) |
| 1841 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1842 | if (!spec->no_analog) { |
| 1843 | err = snd_hda_create_spdif_share_sw(codec, |
| 1844 | &spec->multiout); |
| 1845 | if (err < 0) |
| 1846 | return err; |
| 1847 | spec->multiout.share_spdif = 1; |
| 1848 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1849 | } |
| 1850 | if (spec->dig_in_nid) { |
| 1851 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1852 | if (err < 0) |
| 1853 | return err; |
| 1854 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1855 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1856 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1857 | /* create beep controls if needed */ |
| 1858 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1859 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1860 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1861 | struct snd_kcontrol *kctl; |
| 1862 | kctl = snd_ctl_new1(knew, codec); |
| 1863 | if (!kctl) |
| 1864 | return -ENOMEM; |
| 1865 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1866 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1867 | if (err < 0) |
| 1868 | return err; |
| 1869 | } |
| 1870 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1871 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1872 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1873 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1874 | if (!spec->no_analog && |
| 1875 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1876 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1877 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1878 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1879 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1880 | vmaster_tlv, alc_slave_pfxs, |
| 1881 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1882 | if (err < 0) |
| 1883 | return err; |
| 1884 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1885 | if (!spec->no_analog && |
| 1886 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1887 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1888 | NULL, alc_slave_pfxs, |
| 1889 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1890 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1891 | if (err < 0) |
| 1892 | return err; |
| 1893 | } |
| 1894 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1895 | /* assign Capture Source enums to NID */ |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1896 | if (spec->capsrc_nids || spec->adc_nids) { |
| 1897 | kctl = snd_hda_find_mixer_ctl(codec, "Capture Source"); |
| 1898 | if (!kctl) |
| 1899 | kctl = snd_hda_find_mixer_ctl(codec, "Input Source"); |
| 1900 | for (i = 0; kctl && i < kctl->count; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 1901 | err = snd_hda_add_nid(codec, kctl, i, |
| 1902 | get_capsrc(spec, i)); |
Takashi Iwai | fbe618f | 2010-06-11 11:24:58 +0200 | [diff] [blame] | 1903 | if (err < 0) |
| 1904 | return err; |
| 1905 | } |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1906 | } |
Takashi Iwai | 60a6a84 | 2011-07-27 14:01:24 +0200 | [diff] [blame] | 1907 | if (spec->cap_mixer && spec->adc_nids) { |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1908 | const char *kname = kctl ? kctl->id.name : NULL; |
| 1909 | for (knew = spec->cap_mixer; knew->name; knew++) { |
| 1910 | if (kname && strcmp(knew->name, kname) == 0) |
| 1911 | continue; |
| 1912 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1913 | for (i = 0; kctl && i < kctl->count; i++) { |
| 1914 | err = snd_hda_add_nid(codec, kctl, i, |
| 1915 | spec->adc_nids[i]); |
| 1916 | if (err < 0) |
| 1917 | return err; |
| 1918 | } |
| 1919 | } |
| 1920 | } |
| 1921 | |
| 1922 | /* other nid->control mapping */ |
| 1923 | for (i = 0; i < spec->num_mixers; i++) { |
| 1924 | for (knew = spec->mixers[i]; knew->name; knew++) { |
| 1925 | if (knew->iface != NID_MAPPING) |
| 1926 | continue; |
| 1927 | kctl = snd_hda_find_mixer_ctl(codec, knew->name); |
| 1928 | if (kctl == NULL) |
| 1929 | continue; |
| 1930 | u = knew->subdevice; |
| 1931 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1932 | nid = u & 0x3f; |
| 1933 | if (nid == 0) |
| 1934 | continue; |
| 1935 | switch (u & 0xc0) { |
| 1936 | case SUBDEV_SPEAKER_: |
| 1937 | nid = spec->autocfg.speaker_pins[nid]; |
| 1938 | break; |
| 1939 | case SUBDEV_LINE_: |
| 1940 | nid = spec->autocfg.line_out_pins[nid]; |
| 1941 | break; |
| 1942 | case SUBDEV_HP_: |
| 1943 | nid = spec->autocfg.hp_pins[nid]; |
| 1944 | break; |
| 1945 | default: |
| 1946 | continue; |
| 1947 | } |
| 1948 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1949 | if (err < 0) |
| 1950 | return err; |
| 1951 | } |
| 1952 | u = knew->private_value; |
| 1953 | for (j = 0; j < 4; j++, u >>= 8) { |
| 1954 | nid = u & 0xff; |
| 1955 | if (nid == 0) |
| 1956 | continue; |
| 1957 | err = snd_hda_add_nid(codec, kctl, 0, nid); |
| 1958 | if (err < 0) |
| 1959 | return err; |
| 1960 | } |
| 1961 | } |
| 1962 | } |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1963 | |
| 1964 | alc_free_kctls(codec); /* no longer needed */ |
| 1965 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1966 | return 0; |
| 1967 | } |
| 1968 | |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1969 | static int alc_build_jacks(struct hda_codec *codec) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1970 | { |
| 1971 | struct alc_spec *spec = codec->spec; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1972 | |
| 1973 | if (spec->shared_mic_hp) { |
| 1974 | int err; |
| 1975 | int nid = spec->autocfg.inputs[1].pin; |
| 1976 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); |
| 1977 | if (err < 0) |
| 1978 | return err; |
| 1979 | err = snd_hda_jack_detect_enable(codec, nid, 0); |
| 1980 | if (err < 0) |
| 1981 | return err; |
| 1982 | } |
| 1983 | |
| 1984 | return snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1985 | } |
| 1986 | |
| 1987 | static int alc_build_controls(struct hda_codec *codec) |
| 1988 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1989 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1990 | if (err < 0) |
| 1991 | return err; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1992 | |
| 1993 | err = alc_build_jacks(codec); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1994 | if (err < 0) |
| 1995 | return err; |
| 1996 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 1997 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1998 | } |
| 1999 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2000 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2001 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2002 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2003 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 2004 | |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2005 | static void alc_init_special_input_src(struct hda_codec *codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2006 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2007 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2008 | static int alc_init(struct hda_codec *codec) |
| 2009 | { |
| 2010 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2011 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 2012 | if (spec->init_hook) |
| 2013 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 2014 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2015 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 2016 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 2017 | |
Takashi Iwai | 2e8b2b2 | 2012-06-13 16:47:32 +0200 | [diff] [blame] | 2018 | snd_hda_gen_apply_verbs(codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 2019 | alc_init_special_input_src(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 2020 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 2021 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 2022 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 2023 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2024 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | return 0; |
| 2026 | } |
| 2027 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2028 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2029 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 2030 | { |
| 2031 | struct alc_spec *spec = codec->spec; |
| 2032 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 2033 | } |
| 2034 | #endif |
| 2035 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2036 | /* |
| 2037 | * Analog playback callbacks |
| 2038 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2039 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2041 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | { |
| 2043 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 2044 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 2045 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2046 | } |
| 2047 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2048 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2049 | struct hda_codec *codec, |
| 2050 | unsigned int stream_tag, |
| 2051 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2052 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2053 | { |
| 2054 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 2055 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 2056 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | } |
| 2058 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2059 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2060 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2061 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | { |
| 2063 | struct alc_spec *spec = codec->spec; |
| 2064 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 2065 | } |
| 2066 | |
| 2067 | /* |
| 2068 | * Digital out |
| 2069 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2070 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2072 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2073 | { |
| 2074 | struct alc_spec *spec = codec->spec; |
| 2075 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 2076 | } |
| 2077 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2078 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 2079 | struct hda_codec *codec, |
| 2080 | unsigned int stream_tag, |
| 2081 | unsigned int format, |
| 2082 | struct snd_pcm_substream *substream) |
| 2083 | { |
| 2084 | struct alc_spec *spec = codec->spec; |
| 2085 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 2086 | stream_tag, format, substream); |
| 2087 | } |
| 2088 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2089 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 2090 | struct hda_codec *codec, |
| 2091 | struct snd_pcm_substream *substream) |
| 2092 | { |
| 2093 | struct alc_spec *spec = codec->spec; |
| 2094 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 2095 | } |
| 2096 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2097 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2098 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2099 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | { |
| 2101 | struct alc_spec *spec = codec->spec; |
| 2102 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 2103 | } |
| 2104 | |
| 2105 | /* |
| 2106 | * Analog capture |
| 2107 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2108 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2109 | struct hda_codec *codec, |
| 2110 | unsigned int stream_tag, |
| 2111 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2112 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2113 | { |
| 2114 | struct alc_spec *spec = codec->spec; |
| 2115 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2116 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2117 | stream_tag, 0, format); |
| 2118 | return 0; |
| 2119 | } |
| 2120 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2121 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2122 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2123 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2124 | { |
| 2125 | struct alc_spec *spec = codec->spec; |
| 2126 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 2127 | snd_hda_codec_cleanup_stream(codec, |
| 2128 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | return 0; |
| 2130 | } |
| 2131 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2132 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2133 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2134 | struct hda_codec *codec, |
| 2135 | unsigned int stream_tag, |
| 2136 | unsigned int format, |
| 2137 | struct snd_pcm_substream *substream) |
| 2138 | { |
| 2139 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2140 | spec->cur_adc = spec->adc_nids[spec->dyn_adc_idx[spec->cur_mux[0]]]; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2141 | spec->cur_adc_stream_tag = stream_tag; |
| 2142 | spec->cur_adc_format = format; |
| 2143 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 2144 | return 0; |
| 2145 | } |
| 2146 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2147 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2148 | struct hda_codec *codec, |
| 2149 | struct snd_pcm_substream *substream) |
| 2150 | { |
| 2151 | struct alc_spec *spec = codec->spec; |
| 2152 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 2153 | spec->cur_adc = 0; |
| 2154 | return 0; |
| 2155 | } |
| 2156 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2157 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2158 | .substreams = 1, |
| 2159 | .channels_min = 2, |
| 2160 | .channels_max = 2, |
| 2161 | .nid = 0, /* fill later */ |
| 2162 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2163 | .prepare = dyn_adc_capture_pcm_prepare, |
| 2164 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 2165 | }, |
| 2166 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2167 | |
| 2168 | /* |
| 2169 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2170 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | .substreams = 1, |
| 2172 | .channels_min = 2, |
| 2173 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2174 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2175 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2176 | .open = alc_playback_pcm_open, |
| 2177 | .prepare = alc_playback_pcm_prepare, |
| 2178 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2179 | }, |
| 2180 | }; |
| 2181 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2182 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2183 | .substreams = 1, |
| 2184 | .channels_min = 2, |
| 2185 | .channels_max = 2, |
| 2186 | /* NID is set in alc_build_pcms */ |
| 2187 | }; |
| 2188 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2189 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2190 | .substreams = 1, |
| 2191 | .channels_min = 2, |
| 2192 | .channels_max = 2, |
| 2193 | /* NID is set in alc_build_pcms */ |
| 2194 | }; |
| 2195 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2196 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2197 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | .channels_min = 2, |
| 2199 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2200 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2201 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2202 | .prepare = alc_alt_capture_pcm_prepare, |
| 2203 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2204 | }, |
| 2205 | }; |
| 2206 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2207 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | .substreams = 1, |
| 2209 | .channels_min = 2, |
| 2210 | .channels_max = 2, |
| 2211 | /* NID is set in alc_build_pcms */ |
| 2212 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2213 | .open = alc_dig_playback_pcm_open, |
| 2214 | .close = alc_dig_playback_pcm_close, |
| 2215 | .prepare = alc_dig_playback_pcm_prepare, |
| 2216 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2217 | }, |
| 2218 | }; |
| 2219 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2220 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2221 | .substreams = 1, |
| 2222 | .channels_min = 2, |
| 2223 | .channels_max = 2, |
| 2224 | /* NID is set in alc_build_pcms */ |
| 2225 | }; |
| 2226 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2227 | /* Used by alc_build_pcms to flag that a PCM has no playback stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2228 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 2229 | .substreams = 0, |
| 2230 | .channels_min = 0, |
| 2231 | .channels_max = 0, |
| 2232 | }; |
| 2233 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | static int alc_build_pcms(struct hda_codec *codec) |
| 2235 | { |
| 2236 | struct alc_spec *spec = codec->spec; |
| 2237 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2238 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2239 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2240 | int i; |
| 2241 | |
| 2242 | codec->num_pcms = 1; |
| 2243 | codec->pcm_info = info; |
| 2244 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2245 | if (spec->no_analog) |
| 2246 | goto skip_analog; |
| 2247 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2248 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 2249 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 2251 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 2252 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2253 | p = spec->stream_analog_playback; |
| 2254 | if (!p) |
| 2255 | p = &alc_pcm_analog_playback; |
| 2256 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2257 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 9c9a517 | 2012-07-31 11:35:35 +0200 | [diff] [blame] | 2258 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 2259 | spec->multiout.max_channels; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2260 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2261 | if (spec->adc_nids) { |
| 2262 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2263 | if (!p) { |
| 2264 | if (spec->dyn_adc_switch) |
| 2265 | p = &dyn_adc_pcm_analog_capture; |
| 2266 | else |
| 2267 | p = &alc_pcm_analog_capture; |
| 2268 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2269 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2270 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2271 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2273 | if (spec->channel_mode) { |
| 2274 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2275 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2276 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2277 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2278 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | } |
| 2280 | } |
| 2281 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2282 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2283 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2284 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2285 | snprintf(spec->stream_name_digital, |
| 2286 | sizeof(spec->stream_name_digital), |
| 2287 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2288 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2289 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2290 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2291 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2292 | if (spec->dig_out_type) |
| 2293 | info->pcm_type = spec->dig_out_type; |
| 2294 | else |
| 2295 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2296 | if (spec->multiout.dig_out_nid) { |
| 2297 | p = spec->stream_digital_playback; |
| 2298 | if (!p) |
| 2299 | p = &alc_pcm_digital_playback; |
| 2300 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2301 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2302 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2303 | if (spec->dig_in_nid) { |
| 2304 | p = spec->stream_digital_capture; |
| 2305 | if (!p) |
| 2306 | p = &alc_pcm_digital_capture; |
| 2307 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2309 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2310 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2311 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2312 | } |
| 2313 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2314 | if (spec->no_analog) |
| 2315 | return 0; |
| 2316 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2317 | /* If the use of more than one ADC is requested for the current |
| 2318 | * model, configure a second analog capture-only PCM. |
| 2319 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2320 | have_multi_adcs = (spec->num_adc_nids > 1) && |
| 2321 | !spec->dyn_adc_switch && !spec->auto_mic && |
| 2322 | (!spec->input_mux || spec->input_mux->num_items > 1); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2323 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2324 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2325 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2326 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2327 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2328 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2329 | p = spec->stream_analog_alt_playback; |
| 2330 | if (!p) |
| 2331 | p = &alc_pcm_analog_alt_playback; |
| 2332 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2333 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2334 | spec->alt_dac_nid; |
| 2335 | } else { |
| 2336 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2337 | alc_pcm_null_stream; |
| 2338 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2339 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2340 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2341 | p = spec->stream_analog_alt_capture; |
| 2342 | if (!p) |
| 2343 | p = &alc_pcm_analog_alt_capture; |
| 2344 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2345 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2346 | spec->adc_nids[1]; |
| 2347 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2348 | spec->num_adc_nids - 1; |
| 2349 | } else { |
| 2350 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2351 | alc_pcm_null_stream; |
| 2352 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2353 | } |
| 2354 | } |
| 2355 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | return 0; |
| 2357 | } |
| 2358 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2359 | static inline void alc_shutup(struct hda_codec *codec) |
| 2360 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2361 | struct alc_spec *spec = codec->spec; |
| 2362 | |
| 2363 | if (spec && spec->shutup) |
| 2364 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2365 | snd_hda_shutup_pins(codec); |
| 2366 | } |
| 2367 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2368 | static void alc_free_kctls(struct hda_codec *codec) |
| 2369 | { |
| 2370 | struct alc_spec *spec = codec->spec; |
| 2371 | |
| 2372 | if (spec->kctls.list) { |
| 2373 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2374 | int i; |
| 2375 | for (i = 0; i < spec->kctls.used; i++) |
| 2376 | kfree(kctl[i].name); |
| 2377 | } |
| 2378 | snd_array_free(&spec->kctls); |
| 2379 | } |
| 2380 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2381 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2382 | { |
| 2383 | struct alc_spec *spec = codec->spec; |
| 2384 | if (spec->bind_ctls.list) { |
| 2385 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2386 | int i; |
| 2387 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2388 | kfree(ctl[i]); |
| 2389 | } |
| 2390 | snd_array_free(&spec->bind_ctls); |
| 2391 | } |
| 2392 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2393 | static void alc_free(struct hda_codec *codec) |
| 2394 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2395 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2396 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2397 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2398 | return; |
| 2399 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2400 | alc_shutup(codec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2401 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2402 | alc_free_bind_ctls(codec); |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 2403 | snd_hda_gen_free(&spec->gen); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2404 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2405 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2406 | } |
| 2407 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2408 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2409 | static void alc_power_eapd(struct hda_codec *codec) |
| 2410 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2411 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2412 | } |
| 2413 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 2414 | static int alc_suspend(struct hda_codec *codec) |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2415 | { |
| 2416 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2417 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2418 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2419 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2420 | return 0; |
| 2421 | } |
| 2422 | #endif |
| 2423 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2424 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2425 | static int alc_resume(struct hda_codec *codec) |
| 2426 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2427 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2428 | codec->patch_ops.init(codec); |
| 2429 | snd_hda_codec_resume_amp(codec); |
| 2430 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 2431 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2432 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2433 | return 0; |
| 2434 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2435 | #endif |
| 2436 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2437 | /* |
| 2438 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2439 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2440 | .build_controls = alc_build_controls, |
| 2441 | .build_pcms = alc_build_pcms, |
| 2442 | .init = alc_init, |
| 2443 | .free = alc_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2444 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2445 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2446 | .resume = alc_resume, |
| 2447 | #endif |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2448 | #ifdef CONFIG_PM |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2449 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2450 | .check_power_status = alc_check_power_status, |
| 2451 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2452 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2453 | }; |
| 2454 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2455 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2456 | /* replace the codec chip_name with the given string */ |
| 2457 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2458 | { |
| 2459 | kfree(codec->chip_name); |
| 2460 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2461 | if (!codec->chip_name) { |
| 2462 | alc_free(codec); |
| 2463 | return -ENOMEM; |
| 2464 | } |
| 2465 | return 0; |
| 2466 | } |
| 2467 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2468 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2469 | * Rename codecs appropriately from COEF value |
| 2470 | */ |
| 2471 | struct alc_codec_rename_table { |
| 2472 | unsigned int vendor_id; |
| 2473 | unsigned short coef_mask; |
| 2474 | unsigned short coef_bits; |
| 2475 | const char *name; |
| 2476 | }; |
| 2477 | |
| 2478 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2479 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2480 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2481 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2482 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2483 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2484 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2485 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 2486 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2487 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2488 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2489 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2490 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2491 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2492 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2493 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2494 | { } /* terminator */ |
| 2495 | }; |
| 2496 | |
| 2497 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2498 | { |
| 2499 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2500 | |
| 2501 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2502 | if (p->vendor_id != codec->vendor_id) |
| 2503 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2504 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2505 | return alc_codec_rename(codec, p->name); |
| 2506 | } |
| 2507 | return 0; |
| 2508 | } |
| 2509 | |
| 2510 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2511 | * Automatic parse of I/O pins from the BIOS configuration |
| 2512 | */ |
| 2513 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2514 | enum { |
| 2515 | ALC_CTL_WIDGET_VOL, |
| 2516 | ALC_CTL_WIDGET_MUTE, |
| 2517 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2518 | ALC_CTL_BIND_VOL, |
| 2519 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2520 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2521 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2522 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2523 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2524 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2525 | HDA_BIND_VOL(NULL, 0), |
| 2526 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2527 | }; |
| 2528 | |
| 2529 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2530 | static int add_control(struct alc_spec *spec, int type, const char *name, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2531 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2532 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2533 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2534 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2535 | knew = alc_kcontrol_new(spec); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2536 | if (!knew) |
| 2537 | return -ENOMEM; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2538 | *knew = alc_control_templates[type]; |
Paulo Marques | 543537b | 2005-06-23 00:09:02 -0700 | [diff] [blame] | 2539 | knew->name = kstrdup(name, GFP_KERNEL); |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2540 | if (!knew->name) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2541 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2542 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2543 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2544 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2545 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2546 | return 0; |
| 2547 | } |
| 2548 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2549 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2550 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2551 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2552 | { |
| 2553 | char name[32]; |
| 2554 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2555 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2556 | } |
| 2557 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2558 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2559 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2560 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2561 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2562 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2563 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2564 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2565 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2566 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2567 | static const char * const channel_name[4] = { |
| 2568 | "Front", "Surround", "CLFE", "Side" |
| 2569 | }; |
| 2570 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2571 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2572 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2573 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2574 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2575 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2576 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2577 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2578 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2579 | return "Master"; |
| 2580 | |
| 2581 | switch (cfg->line_out_type) { |
| 2582 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2583 | if (cfg->line_outs == 1) |
| 2584 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2585 | if (cfg->line_outs == 2) |
| 2586 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2587 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2588 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2589 | /* for multi-io case, only the primary out */ |
| 2590 | if (ch && spec->multi_ios) |
| 2591 | break; |
| 2592 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2593 | return "Headphone"; |
| 2594 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2595 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2596 | return "PCM"; |
| 2597 | break; |
| 2598 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2599 | if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) |
| 2600 | return "PCM"; |
| 2601 | |
| 2602 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2603 | } |
| 2604 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2605 | #ifdef CONFIG_PM |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2606 | /* add the powersave loopback-list entry */ |
| 2607 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2608 | { |
| 2609 | struct hda_amp_list *list; |
| 2610 | |
| 2611 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2612 | return; |
| 2613 | list = spec->loopback_list + spec->num_loopbacks; |
| 2614 | list->nid = mix; |
| 2615 | list->dir = HDA_INPUT; |
| 2616 | list->idx = idx; |
| 2617 | spec->num_loopbacks++; |
| 2618 | spec->loopback.amplist = spec->loopback_list; |
| 2619 | } |
| 2620 | #else |
| 2621 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2622 | #endif |
| 2623 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2624 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2625 | static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2626 | const char *ctlname, int ctlidx, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2627 | int idx, hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2628 | { |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 2629 | int err; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2630 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2631 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2632 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2633 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2634 | return err; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2635 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2636 | HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT)); |
| 2637 | if (err < 0) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2638 | return err; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2639 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2640 | return 0; |
| 2641 | } |
| 2642 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2643 | static int alc_is_input_pin(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2644 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2645 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2646 | return (pincap & AC_PINCAP_IN) != 0; |
| 2647 | } |
| 2648 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2649 | /* Parse the codec tree and retrieve ADCs and corresponding capsrc MUXs */ |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2650 | static int alc_auto_fill_adc_caps(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2651 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2652 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2653 | hda_nid_t nid; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2654 | hda_nid_t *adc_nids = spec->private_adc_nids; |
| 2655 | hda_nid_t *cap_nids = spec->private_capsrc_nids; |
| 2656 | int max_nums = ARRAY_SIZE(spec->private_adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2657 | int i, nums = 0; |
| 2658 | |
| 2659 | nid = codec->start_nid; |
| 2660 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 2661 | hda_nid_t src; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2662 | unsigned int caps = get_wcaps(codec, nid); |
| 2663 | int type = get_wcaps_type(caps); |
| 2664 | |
| 2665 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2666 | continue; |
| 2667 | adc_nids[nums] = nid; |
| 2668 | cap_nids[nums] = nid; |
| 2669 | src = nid; |
| 2670 | for (;;) { |
| 2671 | int n; |
| 2672 | type = get_wcaps_type(get_wcaps(codec, src)); |
| 2673 | if (type == AC_WID_PIN) |
| 2674 | break; |
| 2675 | if (type == AC_WID_AUD_SEL) { |
| 2676 | cap_nids[nums] = src; |
| 2677 | break; |
| 2678 | } |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2679 | n = snd_hda_get_num_conns(codec, src); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2680 | if (n > 1) { |
| 2681 | cap_nids[nums] = src; |
| 2682 | break; |
| 2683 | } else if (n != 1) |
| 2684 | break; |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2685 | if (snd_hda_get_connections(codec, src, &src, 1) != 1) |
| 2686 | break; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2687 | } |
| 2688 | if (++nums >= max_nums) |
| 2689 | break; |
| 2690 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2691 | spec->adc_nids = spec->private_adc_nids; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2692 | spec->capsrc_nids = spec->private_capsrc_nids; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2693 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2694 | return nums; |
| 2695 | } |
| 2696 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2697 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2698 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2699 | { |
| 2700 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2701 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2702 | hda_nid_t mixer = spec->mixer_nid; |
Herton Ronaldo Krzesinski | 61b9b9b | 2009-01-28 09:16:33 -0200 | [diff] [blame] | 2703 | struct hda_input_mux *imux = &spec->private_imux[0]; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2704 | int num_adcs; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2705 | int i, c, err, idx, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2706 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2707 | |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2708 | num_adcs = alc_auto_fill_adc_caps(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2709 | if (num_adcs < 0) |
| 2710 | return 0; |
| 2711 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2712 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2713 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2714 | const char *label; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2715 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2716 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2717 | if (!alc_is_input_pin(codec, pin)) |
| 2718 | continue; |
| 2719 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2720 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2721 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2722 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2723 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2724 | type_idx++; |
| 2725 | else |
| 2726 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2727 | prev_label = label; |
| 2728 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2729 | if (mixer) { |
| 2730 | idx = get_connection_index(codec, mixer, pin); |
| 2731 | if (idx >= 0) { |
| 2732 | err = new_analog_input(spec, pin, |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2733 | label, type_idx, |
| 2734 | idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2735 | if (err < 0) |
| 2736 | return err; |
| 2737 | } |
| 2738 | } |
| 2739 | |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2740 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 2741 | hda_nid_t cap = get_capsrc(spec, c); |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2742 | idx = get_connection_index(codec, cap, pin); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2743 | if (idx >= 0) { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2744 | spec->imux_pins[imux->num_items] = pin; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2745 | snd_hda_add_imux_item(imux, label, idx, NULL); |
| 2746 | break; |
| 2747 | } |
| 2748 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2749 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2750 | |
| 2751 | spec->num_mux_defs = 1; |
| 2752 | spec->input_mux = imux; |
| 2753 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2754 | return 0; |
| 2755 | } |
| 2756 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2757 | /* create a shared input with the headphone out */ |
| 2758 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2759 | { |
| 2760 | struct alc_spec *spec = codec->spec; |
| 2761 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2762 | unsigned int defcfg; |
| 2763 | hda_nid_t nid; |
| 2764 | |
| 2765 | /* only one internal input pin? */ |
| 2766 | if (cfg->num_inputs != 1) |
| 2767 | return 0; |
| 2768 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2769 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2770 | return 0; |
| 2771 | |
| 2772 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2773 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2774 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2775 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2776 | else |
| 2777 | return 0; /* both not available */ |
| 2778 | |
| 2779 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2780 | return 0; /* no input */ |
| 2781 | |
| 2782 | cfg->inputs[1].pin = nid; |
| 2783 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2784 | cfg->num_inputs = 2; |
| 2785 | spec->shared_mic_hp = 1; |
| 2786 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2787 | return 0; |
| 2788 | } |
| 2789 | |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2790 | static void alc_set_pin_output(struct hda_codec *codec, hda_nid_t nid, |
| 2791 | unsigned int pin_type) |
| 2792 | { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 2793 | snd_hda_set_pin_ctl(codec, nid, pin_type); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2794 | /* unmute pin */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 2795 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2796 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | d260cdf | 2008-02-13 17:19:35 +0100 | [diff] [blame] | 2797 | AMP_OUT_UNMUTE); |
Takashi Iwai | f6c7e54 | 2008-02-12 18:32:23 +0100 | [diff] [blame] | 2798 | } |
| 2799 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2800 | static int get_pin_type(int line_out_type) |
| 2801 | { |
| 2802 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2803 | return PIN_HP; |
| 2804 | else |
| 2805 | return PIN_OUT; |
| 2806 | } |
| 2807 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2808 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2809 | { |
| 2810 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2811 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2812 | int i; |
| 2813 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2814 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2815 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2816 | if (alc_is_input_pin(codec, nid)) { |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2817 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2818 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2819 | snd_hda_codec_write(codec, nid, 0, |
| 2820 | AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2821 | AMP_OUT_MUTE); |
| 2822 | } |
| 2823 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2824 | |
| 2825 | /* mute all loopback inputs */ |
| 2826 | if (spec->mixer_nid) { |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 2827 | int nums = snd_hda_get_num_conns(codec, spec->mixer_nid); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2828 | for (i = 0; i < nums; i++) |
| 2829 | snd_hda_codec_write(codec, spec->mixer_nid, 0, |
| 2830 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 2831 | AMP_IN_MUTE(i)); |
| 2832 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2833 | } |
| 2834 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2835 | /* convert from MIX nid to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2836 | static hda_nid_t alc_auto_mix_to_dac(struct hda_codec *codec, hda_nid_t nid) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2837 | { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2838 | hda_nid_t list[5]; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2839 | int i, num; |
| 2840 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 2841 | if (get_wcaps_type(get_wcaps(codec, nid)) == AC_WID_AUD_OUT) |
| 2842 | return nid; |
Takashi Iwai | 1304ac8 | 2011-04-06 15:16:21 +0200 | [diff] [blame] | 2843 | num = snd_hda_get_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 2844 | for (i = 0; i < num; i++) { |
| 2845 | if (get_wcaps_type(get_wcaps(codec, list[i])) == AC_WID_AUD_OUT) |
| 2846 | return list[i]; |
| 2847 | } |
| 2848 | return 0; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2849 | } |
| 2850 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2851 | /* go down to the selector widget before the mixer */ |
| 2852 | static hda_nid_t alc_go_down_to_selector(struct hda_codec *codec, hda_nid_t pin) |
| 2853 | { |
| 2854 | hda_nid_t srcs[5]; |
| 2855 | int num = snd_hda_get_connections(codec, pin, srcs, |
| 2856 | ARRAY_SIZE(srcs)); |
| 2857 | if (num != 1 || |
| 2858 | get_wcaps_type(get_wcaps(codec, srcs[0])) != AC_WID_AUD_SEL) |
| 2859 | return pin; |
| 2860 | return srcs[0]; |
| 2861 | } |
| 2862 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2863 | /* get MIX nid connected to the given pin targeted to DAC */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2864 | static hda_nid_t alc_auto_dac_to_mix(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2865 | hda_nid_t dac) |
| 2866 | { |
David Henningsson | cc1c452 | 2010-11-24 14:17:47 +0100 | [diff] [blame] | 2867 | hda_nid_t mix[5]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2868 | int i, num; |
| 2869 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2870 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2871 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2872 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2873 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2874 | return mix[i]; |
| 2875 | } |
| 2876 | return 0; |
| 2877 | } |
| 2878 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2879 | /* select the connection from pin to DAC if needed */ |
| 2880 | static int alc_auto_select_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2881 | hda_nid_t dac) |
| 2882 | { |
| 2883 | hda_nid_t mix[5]; |
| 2884 | int i, num; |
| 2885 | |
| 2886 | pin = alc_go_down_to_selector(codec, pin); |
| 2887 | num = snd_hda_get_connections(codec, pin, mix, ARRAY_SIZE(mix)); |
| 2888 | if (num < 2) |
| 2889 | return 0; |
| 2890 | for (i = 0; i < num; i++) { |
| 2891 | if (alc_auto_mix_to_dac(codec, mix[i]) == dac) { |
| 2892 | snd_hda_codec_update_cache(codec, pin, 0, |
| 2893 | AC_VERB_SET_CONNECT_SEL, i); |
| 2894 | return 0; |
| 2895 | } |
| 2896 | } |
| 2897 | return 0; |
| 2898 | } |
| 2899 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2900 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2901 | { |
| 2902 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2903 | int i; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2904 | if (found_in_nid_list(nid, spec->multiout.dac_nids, |
| 2905 | ARRAY_SIZE(spec->private_dac_nids)) || |
| 2906 | found_in_nid_list(nid, spec->multiout.hp_out_nid, |
| 2907 | ARRAY_SIZE(spec->multiout.hp_out_nid)) || |
| 2908 | found_in_nid_list(nid, spec->multiout.extra_out_nid, |
| 2909 | ARRAY_SIZE(spec->multiout.extra_out_nid))) |
| 2910 | return true; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2911 | for (i = 0; i < spec->multi_ios; i++) { |
| 2912 | if (spec->multi_io[i].dac == nid) |
| 2913 | return true; |
| 2914 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2915 | return false; |
| 2916 | } |
| 2917 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2918 | /* look for an empty DAC slot */ |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2919 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2920 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2921 | hda_nid_t srcs[5]; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2922 | int i, num; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2923 | |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2924 | pin = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2925 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2926 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 2927 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2928 | if (!nid) |
| 2929 | continue; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2930 | if (!alc_is_dac_already_used(codec, nid)) |
| 2931 | return nid; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 2932 | } |
| 2933 | return 0; |
| 2934 | } |
| 2935 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2936 | /* check whether the DAC is reachable from the pin */ |
| 2937 | static bool alc_auto_is_dac_reachable(struct hda_codec *codec, |
| 2938 | hda_nid_t pin, hda_nid_t dac) |
| 2939 | { |
| 2940 | hda_nid_t srcs[5]; |
| 2941 | int i, num; |
| 2942 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 2943 | if (!pin || !dac) |
| 2944 | return false; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 2945 | pin = alc_go_down_to_selector(codec, pin); |
| 2946 | num = snd_hda_get_connections(codec, pin, srcs, ARRAY_SIZE(srcs)); |
| 2947 | for (i = 0; i < num; i++) { |
| 2948 | hda_nid_t nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 2949 | if (nid == dac) |
| 2950 | return true; |
| 2951 | } |
| 2952 | return false; |
| 2953 | } |
| 2954 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2955 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2956 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2957 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2958 | hda_nid_t sel = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2959 | hda_nid_t nid, nid_found, srcs[5]; |
| 2960 | int i, num = snd_hda_get_connections(codec, sel, srcs, |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2961 | ARRAY_SIZE(srcs)); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2962 | if (num == 1) |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2963 | return alc_auto_look_for_dac(codec, pin); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2964 | nid_found = 0; |
| 2965 | for (i = 0; i < num; i++) { |
| 2966 | if (srcs[i] == spec->mixer_nid) |
| 2967 | continue; |
| 2968 | nid = alc_auto_mix_to_dac(codec, srcs[i]); |
| 2969 | if (nid && !alc_is_dac_already_used(codec, nid)) { |
| 2970 | if (nid_found) |
| 2971 | return 0; |
| 2972 | nid_found = nid; |
| 2973 | } |
| 2974 | } |
| 2975 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2976 | } |
| 2977 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2978 | /* mark up volume and mute control NIDs: used during badness parsing and |
| 2979 | * at creating actual controls |
| 2980 | */ |
| 2981 | static inline unsigned int get_ctl_pos(unsigned int data) |
| 2982 | { |
| 2983 | hda_nid_t nid = get_amp_nid_(data); |
| 2984 | unsigned int dir; |
| 2985 | if (snd_BUG_ON(nid >= MAX_VOL_NIDS)) |
| 2986 | return 0; |
| 2987 | dir = get_amp_direction_(data); |
| 2988 | return (nid << 1) | dir; |
| 2989 | } |
| 2990 | |
| 2991 | #define is_ctl_used(bits, data) \ |
| 2992 | test_bit(get_ctl_pos(data), bits) |
| 2993 | #define mark_ctl_usage(bits, data) \ |
| 2994 | set_bit(get_ctl_pos(data), bits) |
| 2995 | |
| 2996 | static void clear_vol_marks(struct hda_codec *codec) |
| 2997 | { |
| 2998 | struct alc_spec *spec = codec->spec; |
| 2999 | memset(spec->vol_ctls, 0, sizeof(spec->vol_ctls)); |
| 3000 | memset(spec->sw_ctls, 0, sizeof(spec->sw_ctls)); |
| 3001 | } |
| 3002 | |
| 3003 | /* badness definition */ |
| 3004 | enum { |
| 3005 | /* No primary DAC is found for the main output */ |
| 3006 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 3007 | /* No DAC is found for the extra output */ |
| 3008 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3009 | /* No possible multi-ios */ |
| 3010 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3011 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3012 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3013 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3014 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3015 | /* Primary DAC shared with main surrounds */ |
| 3016 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3017 | /* Primary DAC shared with main CLFE */ |
| 3018 | BAD_SHARED_CLFE = 0x10, |
| 3019 | /* Primary DAC shared with extra surrounds */ |
| 3020 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3021 | /* Volume widget is shared */ |
| 3022 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3023 | }; |
| 3024 | |
| 3025 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3026 | hda_nid_t pin, hda_nid_t dac); |
| 3027 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3028 | hda_nid_t pin, hda_nid_t dac); |
| 3029 | |
| 3030 | static int eval_shared_vol_badness(struct hda_codec *codec, hda_nid_t pin, |
| 3031 | hda_nid_t dac) |
| 3032 | { |
| 3033 | struct alc_spec *spec = codec->spec; |
| 3034 | hda_nid_t nid; |
| 3035 | unsigned int val; |
| 3036 | int badness = 0; |
| 3037 | |
| 3038 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3039 | if (nid) { |
| 3040 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3041 | if (is_ctl_used(spec->vol_ctls, nid)) |
| 3042 | badness += BAD_SHARED_VOL; |
| 3043 | else |
| 3044 | mark_ctl_usage(spec->vol_ctls, val); |
| 3045 | } else |
| 3046 | badness += BAD_SHARED_VOL; |
| 3047 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3048 | if (nid) { |
| 3049 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3050 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) |
| 3051 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3052 | else |
| 3053 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
| 3054 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3055 | badness += BAD_SHARED_VOL; |
| 3056 | else |
| 3057 | mark_ctl_usage(spec->sw_ctls, val); |
| 3058 | } else |
| 3059 | badness += BAD_SHARED_VOL; |
| 3060 | return badness; |
| 3061 | } |
| 3062 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3063 | struct badness_table { |
| 3064 | int no_primary_dac; /* no primary DAC */ |
| 3065 | int no_dac; /* no secondary DACs */ |
| 3066 | int shared_primary; /* primary DAC is shared with main output */ |
| 3067 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3068 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3069 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3070 | }; |
| 3071 | |
| 3072 | static struct badness_table main_out_badness = { |
| 3073 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3074 | .no_dac = BAD_NO_DAC, |
| 3075 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3076 | .shared_surr = BAD_SHARED_SURROUND, |
| 3077 | .shared_clfe = BAD_SHARED_CLFE, |
| 3078 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3079 | }; |
| 3080 | |
| 3081 | static struct badness_table extra_out_badness = { |
| 3082 | .no_primary_dac = BAD_NO_DAC, |
| 3083 | .no_dac = BAD_NO_DAC, |
| 3084 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3085 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3086 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3087 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3088 | }; |
| 3089 | |
| 3090 | /* try to assign DACs to pins and return the resultant badness */ |
| 3091 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3092 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3093 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3094 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3095 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3096 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3097 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3098 | int badness = 0; |
| 3099 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3100 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3101 | if (!num_outs) |
| 3102 | return 0; |
| 3103 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3104 | for (i = 0; i < num_outs; i++) { |
| 3105 | hda_nid_t pin = pins[i]; |
| 3106 | if (!dacs[i]) |
| 3107 | dacs[i] = alc_auto_look_for_dac(codec, pin); |
| 3108 | if (!dacs[i] && !i) { |
| 3109 | for (j = 1; j < num_outs; j++) { |
| 3110 | if (alc_auto_is_dac_reachable(codec, pin, dacs[j])) { |
| 3111 | dacs[0] = dacs[j]; |
| 3112 | dacs[j] = 0; |
| 3113 | break; |
| 3114 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3115 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3116 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3117 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3118 | if (!dac) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3119 | if (alc_auto_is_dac_reachable(codec, pin, dacs[0])) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3120 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3121 | else if (cfg->line_outs > i && |
| 3122 | alc_auto_is_dac_reachable(codec, pin, |
| 3123 | spec->private_dac_nids[i])) |
| 3124 | dac = spec->private_dac_nids[i]; |
| 3125 | if (dac) { |
| 3126 | if (!i) |
| 3127 | badness += bad->shared_primary; |
| 3128 | else if (i == 1) |
| 3129 | badness += bad->shared_surr; |
| 3130 | else |
| 3131 | badness += bad->shared_clfe; |
| 3132 | } else if (alc_auto_is_dac_reachable(codec, pin, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3133 | spec->private_dac_nids[0])) { |
| 3134 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3135 | badness += bad->shared_surr_main; |
| 3136 | } else if (!i) |
| 3137 | badness += bad->no_primary_dac; |
| 3138 | else |
| 3139 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3140 | } |
| 3141 | if (dac) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3142 | badness += eval_shared_vol_badness(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3143 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3144 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3145 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3146 | } |
| 3147 | |
| 3148 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3149 | hda_nid_t reference_pin, |
| 3150 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3151 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3152 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3153 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3154 | { |
| 3155 | int i; |
| 3156 | bool found = false; |
| 3157 | for (i = 0; i < outs; i++) { |
| 3158 | if (dacs[i]) |
| 3159 | continue; |
| 3160 | dacs[i] = get_dac_if_single(codec, pins[i]); |
| 3161 | if (dacs[i]) |
| 3162 | found = true; |
| 3163 | } |
| 3164 | return found; |
| 3165 | } |
| 3166 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3167 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3168 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3169 | bool fill_hardwired, |
| 3170 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3171 | { |
| 3172 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3173 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3174 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3175 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3176 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3177 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3178 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3179 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3180 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3181 | memset(spec->multiout.extra_out_nid, 0, sizeof(spec->multiout.extra_out_nid)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3182 | spec->multi_ios = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3183 | clear_vol_marks(codec); |
| 3184 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3185 | |
| 3186 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3187 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3188 | bool mapped; |
| 3189 | do { |
| 3190 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3191 | cfg->line_out_pins, |
| 3192 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3193 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3194 | cfg->hp_pins, |
| 3195 | spec->multiout.hp_out_nid); |
| 3196 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3197 | cfg->speaker_pins, |
| 3198 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3199 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3200 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3201 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3202 | if (!err) |
| 3203 | mapped = true; |
| 3204 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3205 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3206 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3207 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3208 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3209 | spec->private_dac_nids, |
| 3210 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3211 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3212 | /* re-count num_dacs and squash invalid entries */ |
| 3213 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3214 | for (i = 0; i < cfg->line_outs; i++) { |
| 3215 | if (spec->private_dac_nids[i]) |
| 3216 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3217 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3218 | memmove(spec->private_dac_nids + i, |
| 3219 | spec->private_dac_nids + i + 1, |
| 3220 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3221 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3222 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3223 | } |
| 3224 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3225 | if (fill_mio_first && |
| 3226 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3227 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3228 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3229 | if (err < 0) |
| 3230 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3231 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3232 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3233 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3234 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3235 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3236 | spec->multiout.hp_out_nid, |
| 3237 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3238 | if (err < 0) |
| 3239 | return err; |
| 3240 | badness += err; |
| 3241 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3242 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3243 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3244 | cfg->speaker_pins, |
| 3245 | spec->multiout.extra_out_nid, |
| 3246 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3247 | if (err < 0) |
| 3248 | return err; |
| 3249 | badness += err; |
| 3250 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3251 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3252 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], false, 0); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3253 | if (err < 0) |
| 3254 | return err; |
| 3255 | badness += err; |
| 3256 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3257 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3258 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3259 | int offset = 0; |
| 3260 | if (cfg->line_outs >= 3) |
| 3261 | offset = 1; |
| 3262 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3263 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3264 | if (err < 0) |
| 3265 | return err; |
| 3266 | badness += err; |
| 3267 | } |
| 3268 | |
| 3269 | if (spec->multi_ios == 2) { |
| 3270 | for (i = 0; i < 2; i++) |
| 3271 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3272 | spec->multi_io[i].dac; |
| 3273 | spec->ext_channel_count = 2; |
| 3274 | } else if (spec->multi_ios) { |
| 3275 | spec->multi_ios = 0; |
| 3276 | badness += BAD_MULTI_IO; |
| 3277 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3278 | |
| 3279 | return badness; |
| 3280 | } |
| 3281 | |
| 3282 | #define DEBUG_BADNESS |
| 3283 | |
| 3284 | #ifdef DEBUG_BADNESS |
| 3285 | #define debug_badness snd_printdd |
| 3286 | #else |
| 3287 | #define debug_badness(...) |
| 3288 | #endif |
| 3289 | |
| 3290 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3291 | { |
| 3292 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3293 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3294 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3295 | spec->multiout.dac_nids[0], |
| 3296 | spec->multiout.dac_nids[1], |
| 3297 | spec->multiout.dac_nids[2], |
| 3298 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3299 | if (spec->multi_ios > 0) |
| 3300 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3301 | spec->multi_ios, |
| 3302 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3303 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3304 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3305 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3306 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3307 | spec->multiout.hp_out_nid[0], |
| 3308 | spec->multiout.hp_out_nid[1], |
| 3309 | spec->multiout.hp_out_nid[2], |
| 3310 | spec->multiout.hp_out_nid[3]); |
| 3311 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3312 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3313 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3314 | spec->multiout.extra_out_nid[0], |
| 3315 | spec->multiout.extra_out_nid[1], |
| 3316 | spec->multiout.extra_out_nid[2], |
| 3317 | spec->multiout.extra_out_nid[3]); |
| 3318 | } |
| 3319 | |
| 3320 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3321 | { |
| 3322 | struct alc_spec *spec = codec->spec; |
| 3323 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3324 | struct auto_pin_cfg *best_cfg; |
| 3325 | int best_badness = INT_MAX; |
| 3326 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3327 | bool fill_hardwired = true, fill_mio_first = true; |
| 3328 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3329 | bool hp_spk_swapped = false; |
| 3330 | |
| 3331 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3332 | if (!best_cfg) |
| 3333 | return -ENOMEM; |
| 3334 | *best_cfg = *cfg; |
| 3335 | |
| 3336 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3337 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3338 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3339 | if (badness < 0) { |
| 3340 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3341 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3342 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3343 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3344 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3345 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3346 | debug_show_configs(spec, cfg); |
| 3347 | if (badness < best_badness) { |
| 3348 | best_badness = badness; |
| 3349 | *best_cfg = *cfg; |
| 3350 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3351 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3352 | } |
| 3353 | if (!badness) |
| 3354 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3355 | fill_mio_first = !fill_mio_first; |
| 3356 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3357 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3358 | fill_hardwired = !fill_hardwired; |
| 3359 | if (!fill_hardwired) |
| 3360 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3361 | if (hp_spk_swapped) |
| 3362 | break; |
| 3363 | hp_spk_swapped = true; |
| 3364 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3365 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3366 | cfg->hp_outs = cfg->line_outs; |
| 3367 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3368 | sizeof(cfg->hp_pins)); |
| 3369 | cfg->line_outs = cfg->speaker_outs; |
| 3370 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3371 | sizeof(cfg->speaker_pins)); |
| 3372 | cfg->speaker_outs = 0; |
| 3373 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3374 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3375 | fill_hardwired = true; |
| 3376 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3377 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3378 | if (cfg->hp_outs > 0 && |
| 3379 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3380 | cfg->speaker_outs = cfg->line_outs; |
| 3381 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3382 | sizeof(cfg->speaker_pins)); |
| 3383 | cfg->line_outs = cfg->hp_outs; |
| 3384 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3385 | sizeof(cfg->hp_pins)); |
| 3386 | cfg->hp_outs = 0; |
| 3387 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3388 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3389 | fill_hardwired = true; |
| 3390 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3391 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3392 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3393 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3394 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3395 | if (badness) { |
| 3396 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3397 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3398 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3399 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3400 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3401 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3402 | |
David Henningsson | fde48a1 | 2011-12-09 18:27:42 +0800 | [diff] [blame] | 3403 | if (cfg->line_out_pins[0]) |
| 3404 | spec->vmaster_nid = |
| 3405 | alc_look_for_out_vol_nid(codec, cfg->line_out_pins[0], |
| 3406 | spec->multiout.dac_nids[0]); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3407 | |
| 3408 | /* clear the bitmap flags for creating controls */ |
| 3409 | clear_vol_marks(codec); |
| 3410 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3411 | return 0; |
| 3412 | } |
| 3413 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3414 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3415 | const char *pfx, int cidx, |
| 3416 | hda_nid_t nid, unsigned int chs) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3417 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3418 | struct alc_spec *spec = codec->spec; |
| 3419 | unsigned int val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3420 | if (!nid) |
| 3421 | return 0; |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3422 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
| 3423 | if (is_ctl_used(spec->vol_ctls, val) && chs != 2) /* exclude LFE */ |
| 3424 | return 0; |
| 3425 | mark_ctl_usage(spec->vol_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3426 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3427 | val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3428 | } |
| 3429 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3430 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3431 | const char *pfx, int cidx, |
| 3432 | hda_nid_t nid) |
| 3433 | { |
| 3434 | int chs = 1; |
| 3435 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3436 | chs = 3; |
| 3437 | return alc_auto_add_vol_ctl(codec, pfx, cidx, nid, chs); |
| 3438 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3439 | |
| 3440 | /* create a mute-switch for the given mixer widget; |
| 3441 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3442 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3443 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3444 | const char *pfx, int cidx, |
| 3445 | hda_nid_t nid, unsigned int chs) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3446 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3447 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3448 | int wid_type; |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3449 | int type; |
| 3450 | unsigned long val; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3451 | if (!nid) |
| 3452 | return 0; |
| 3453 | wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3454 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT) { |
| 3455 | type = ALC_CTL_WIDGET_MUTE; |
| 3456 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT); |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 3457 | } else if (snd_hda_get_num_conns(codec, nid) == 1) { |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3458 | type = ALC_CTL_WIDGET_MUTE; |
| 3459 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_INPUT); |
| 3460 | } else { |
| 3461 | type = ALC_CTL_BIND_MUTE; |
| 3462 | val = HDA_COMPOSE_AMP_VAL(nid, chs, 2, HDA_INPUT); |
| 3463 | } |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3464 | if (is_ctl_used(spec->sw_ctls, val) && chs != 2) /* exclude LFE */ |
| 3465 | return 0; |
| 3466 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3467 | return __add_pb_sw_ctrl(codec->spec, type, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3468 | } |
| 3469 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3470 | static int alc_auto_add_stereo_sw(struct hda_codec *codec, const char *pfx, |
| 3471 | int cidx, hda_nid_t nid) |
| 3472 | { |
| 3473 | int chs = 1; |
| 3474 | if (get_wcaps(codec, nid) & AC_WCAP_STEREO) |
| 3475 | chs = 3; |
| 3476 | return alc_auto_add_sw_ctl(codec, pfx, cidx, nid, chs); |
| 3477 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3478 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3479 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
| 3480 | hda_nid_t pin, hda_nid_t dac) |
| 3481 | { |
| 3482 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3483 | if (nid_has_mute(codec, pin, HDA_OUTPUT)) |
| 3484 | return pin; |
| 3485 | else if (mix && nid_has_mute(codec, mix, HDA_INPUT)) |
| 3486 | return mix; |
| 3487 | else if (nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3488 | return dac; |
| 3489 | return 0; |
| 3490 | } |
| 3491 | |
| 3492 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
| 3493 | hda_nid_t pin, hda_nid_t dac) |
| 3494 | { |
| 3495 | hda_nid_t mix = alc_auto_dac_to_mix(codec, pin, dac); |
| 3496 | if (nid_has_volume(codec, dac, HDA_OUTPUT)) |
| 3497 | return dac; |
| 3498 | else if (nid_has_volume(codec, mix, HDA_OUTPUT)) |
| 3499 | return mix; |
| 3500 | else if (nid_has_volume(codec, pin, HDA_OUTPUT)) |
| 3501 | return pin; |
| 3502 | return 0; |
| 3503 | } |
| 3504 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3505 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3506 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3507 | const struct auto_pin_cfg *cfg) |
| 3508 | { |
| 3509 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3510 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3511 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3512 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3513 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3514 | noutputs += spec->multi_ios; |
| 3515 | |
| 3516 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3517 | const char *name; |
| 3518 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3519 | hda_nid_t dac, pin; |
| 3520 | hda_nid_t sw, vol; |
| 3521 | |
| 3522 | dac = spec->multiout.dac_nids[i]; |
| 3523 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3524 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3525 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3526 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3527 | index = 0; |
| 3528 | name = channel_name[i]; |
| 3529 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3530 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3531 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3532 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3533 | |
| 3534 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3535 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 9c4e84d | 2011-08-24 17:27:52 +0200 | [diff] [blame] | 3536 | if (!name || !strcmp(name, "CLFE")) { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3537 | /* Center/LFE */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3538 | err = alc_auto_add_vol_ctl(codec, "Center", 0, vol, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3539 | if (err < 0) |
| 3540 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3541 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, vol, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3542 | if (err < 0) |
| 3543 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3544 | err = alc_auto_add_sw_ctl(codec, "Center", 0, sw, 1); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3545 | if (err < 0) |
| 3546 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3547 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, sw, 2); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3548 | if (err < 0) |
| 3549 | return err; |
| 3550 | } else { |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3551 | err = alc_auto_add_stereo_vol(codec, name, index, vol); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3552 | if (err < 0) |
| 3553 | return err; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3554 | err = alc_auto_add_stereo_sw(codec, name, index, sw); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3555 | if (err < 0) |
| 3556 | return err; |
| 3557 | } |
| 3558 | } |
| 3559 | return 0; |
| 3560 | } |
| 3561 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3562 | static int alc_auto_create_extra_out(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3563 | hda_nid_t dac, const char *pfx, |
| 3564 | int cidx) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3565 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3566 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3567 | hda_nid_t sw, vol; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3568 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3569 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3570 | if (!dac) { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3571 | unsigned int val; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3572 | /* the corresponding DAC is already occupied */ |
| 3573 | if (!(get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)) |
| 3574 | return 0; /* no way */ |
| 3575 | /* create a switch only */ |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3576 | val = HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT); |
| 3577 | if (is_ctl_used(spec->sw_ctls, val)) |
| 3578 | return 0; /* already created */ |
| 3579 | mark_ctl_usage(spec->sw_ctls, val); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3580 | return __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, pfx, cidx, val); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3581 | } |
| 3582 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3583 | sw = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3584 | vol = alc_look_for_out_vol_nid(codec, pin, dac); |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3585 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, vol); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3586 | if (err < 0) |
Takashi Iwai | 24fb917 | 2008-09-02 14:48:20 +0200 | [diff] [blame] | 3587 | return err; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3588 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, sw); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3589 | if (err < 0) |
| 3590 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3591 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3592 | } |
| 3593 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3594 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3595 | unsigned int nums, |
| 3596 | struct hda_ctl_ops *ops) |
| 3597 | { |
| 3598 | struct alc_spec *spec = codec->spec; |
| 3599 | struct hda_bind_ctls **ctlp, *ctl; |
| 3600 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); |
| 3601 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3602 | if (!ctlp) |
| 3603 | return NULL; |
| 3604 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3605 | *ctlp = ctl; |
| 3606 | if (ctl) |
| 3607 | ctl->ops = ops; |
| 3608 | return ctl; |
| 3609 | } |
| 3610 | |
| 3611 | /* add playback controls for speaker and HP outputs */ |
| 3612 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3613 | const hda_nid_t *pins, |
| 3614 | const hda_nid_t *dacs, |
| 3615 | const char *pfx) |
| 3616 | { |
| 3617 | struct alc_spec *spec = codec->spec; |
| 3618 | struct hda_bind_ctls *ctl; |
| 3619 | char name[32]; |
| 3620 | int i, n, err; |
| 3621 | |
| 3622 | if (!num_pins || !pins[0]) |
| 3623 | return 0; |
| 3624 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3625 | if (num_pins == 1) { |
| 3626 | hda_nid_t dac = *dacs; |
| 3627 | if (!dac) |
| 3628 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3629 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3630 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3631 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3632 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3633 | hda_nid_t dac; |
| 3634 | if (dacs[num_pins - 1]) |
| 3635 | dac = dacs[i]; /* with individual volumes */ |
| 3636 | else |
| 3637 | dac = 0; |
| 3638 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3639 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3640 | "Bass Speaker", 0); |
| 3641 | } else if (num_pins >= 3) { |
| 3642 | snprintf(name, sizeof(name), "%s %s", |
| 3643 | pfx, channel_name[i]); |
| 3644 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3645 | name, 0); |
| 3646 | } else { |
| 3647 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3648 | pfx, i); |
| 3649 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3650 | if (err < 0) |
| 3651 | return err; |
| 3652 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3653 | if (dacs[num_pins - 1]) |
| 3654 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3655 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3656 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3657 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3658 | if (!ctl) |
| 3659 | return -ENOMEM; |
| 3660 | n = 0; |
| 3661 | for (i = 0; i < num_pins; i++) { |
| 3662 | hda_nid_t vol; |
| 3663 | if (!pins[i] || !dacs[i]) |
| 3664 | continue; |
| 3665 | vol = alc_look_for_out_vol_nid(codec, pins[i], dacs[i]); |
| 3666 | if (vol) |
| 3667 | ctl->values[n++] = |
| 3668 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3669 | } |
| 3670 | if (n) { |
| 3671 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3672 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3673 | if (err < 0) |
| 3674 | return err; |
| 3675 | } |
| 3676 | return 0; |
| 3677 | } |
| 3678 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3679 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3680 | { |
| 3681 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3682 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3683 | spec->autocfg.hp_pins, |
| 3684 | spec->multiout.hp_out_nid, |
| 3685 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3686 | } |
| 3687 | |
| 3688 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3689 | { |
| 3690 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3691 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3692 | spec->autocfg.speaker_pins, |
| 3693 | spec->multiout.extra_out_nid, |
| 3694 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3695 | } |
| 3696 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3697 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3698 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3699 | hda_nid_t dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3700 | { |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3701 | int i, num; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3702 | hda_nid_t nid, mix = 0; |
Takashi Iwai | ce503f3 | 2010-07-30 10:37:29 +0200 | [diff] [blame] | 3703 | hda_nid_t srcs[HDA_MAX_CONNECTIONS]; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3704 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3705 | alc_set_pin_output(codec, pin, pin_type); |
| 3706 | nid = alc_go_down_to_selector(codec, pin); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3707 | num = snd_hda_get_connections(codec, nid, srcs, ARRAY_SIZE(srcs)); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3708 | for (i = 0; i < num; i++) { |
Takashi Iwai | 604401a | 2011-04-27 15:14:23 +0200 | [diff] [blame] | 3709 | if (alc_auto_mix_to_dac(codec, srcs[i]) != dac) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3710 | continue; |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3711 | mix = srcs[i]; |
| 3712 | break; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3713 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3714 | if (!mix) |
| 3715 | return; |
| 3716 | |
| 3717 | /* need the manual connection? */ |
| 3718 | if (num > 1) |
| 3719 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, i); |
| 3720 | /* unmute mixer widget inputs */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3721 | if (nid_has_mute(codec, mix, HDA_INPUT)) { |
| 3722 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3723 | AMP_IN_UNMUTE(0)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3724 | snd_hda_codec_write(codec, mix, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3725 | AMP_IN_UNMUTE(1)); |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3726 | } |
Takashi Iwai | cd51155 | 2011-07-06 13:10:42 +0200 | [diff] [blame] | 3727 | /* initialize volume */ |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3728 | nid = alc_look_for_out_vol_nid(codec, pin, dac); |
| 3729 | if (nid) |
| 3730 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3731 | AMP_OUT_ZERO); |
Takashi Iwai | 43dea22 | 2011-11-06 11:25:34 +0100 | [diff] [blame] | 3732 | |
| 3733 | /* unmute DAC if it's not assigned to a mixer */ |
| 3734 | nid = alc_look_for_out_mute_nid(codec, pin, dac); |
| 3735 | if (nid == mix && nid_has_mute(codec, dac, HDA_OUTPUT)) |
| 3736 | snd_hda_codec_write(codec, dac, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 3737 | AMP_OUT_ZERO); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3738 | } |
| 3739 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3740 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3741 | { |
| 3742 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3743 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3744 | int i; |
| 3745 | |
| 3746 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3747 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3748 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3749 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3750 | spec->multiout.dac_nids[i]); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3751 | } |
| 3752 | } |
| 3753 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3754 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3755 | { |
| 3756 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3757 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3758 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3759 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3760 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3761 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3762 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3763 | pin = spec->autocfg.hp_pins[i]; |
| 3764 | if (!pin) |
| 3765 | break; |
| 3766 | dac = spec->multiout.hp_out_nid[i]; |
| 3767 | if (!dac) { |
| 3768 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3769 | dac = spec->multiout.hp_out_nid[0]; |
| 3770 | else |
| 3771 | dac = spec->multiout.dac_nids[0]; |
| 3772 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3773 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
| 3774 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3775 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3776 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3777 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3778 | pin = spec->autocfg.speaker_pins[i]; |
| 3779 | if (!pin) |
| 3780 | break; |
| 3781 | dac = spec->multiout.extra_out_nid[i]; |
| 3782 | if (!dac) { |
| 3783 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3784 | dac = spec->multiout.extra_out_nid[0]; |
| 3785 | else |
| 3786 | dac = spec->multiout.dac_nids[0]; |
| 3787 | } |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3788 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
| 3789 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3790 | } |
| 3791 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3792 | /* check whether the given pin can be a multi-io pin */ |
| 3793 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 3794 | unsigned int location, hda_nid_t nid) |
| 3795 | { |
| 3796 | unsigned int defcfg, caps; |
| 3797 | |
| 3798 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3799 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3800 | return false; |
| 3801 | if (location && get_defcfg_location(defcfg) != location) |
| 3802 | return false; |
| 3803 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3804 | if (!(caps & AC_PINCAP_OUT)) |
| 3805 | return false; |
| 3806 | return true; |
| 3807 | } |
| 3808 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3809 | /* |
| 3810 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3811 | * |
| 3812 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 3813 | * zero if any pins are filled, non-zero if nothing found. |
| 3814 | * When hardwired is off, try to fill possible input pins, and returns |
| 3815 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3816 | */ |
| 3817 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3818 | hda_nid_t reference_pin, |
| 3819 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3820 | { |
| 3821 | struct alc_spec *spec = codec->spec; |
| 3822 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3823 | int type, i, j, dacs, num_pins, old_pins; |
| 3824 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 3825 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3826 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3827 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3828 | old_pins = spec->multi_ios; |
| 3829 | if (old_pins >= 2) |
| 3830 | goto end_fill; |
| 3831 | |
| 3832 | num_pins = 0; |
| 3833 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3834 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3835 | if (cfg->inputs[i].type != type) |
| 3836 | continue; |
| 3837 | if (can_be_multiio_pin(codec, location, |
| 3838 | cfg->inputs[i].pin)) |
| 3839 | num_pins++; |
| 3840 | } |
| 3841 | } |
| 3842 | if (num_pins < 2) |
| 3843 | goto end_fill; |
| 3844 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3845 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3846 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3847 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3848 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3849 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3850 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3851 | if (cfg->inputs[i].type != type) |
| 3852 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3853 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3854 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3855 | for (j = 0; j < spec->multi_ios; j++) { |
| 3856 | if (nid == spec->multi_io[j].pin) |
| 3857 | break; |
| 3858 | } |
| 3859 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3860 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3861 | |
| 3862 | if (offset && offset + spec->multi_ios < dacs) { |
| 3863 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3864 | if (!alc_auto_is_dac_reachable(codec, nid, dac)) |
| 3865 | dac = 0; |
| 3866 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3867 | if (hardwired) |
| 3868 | dac = get_dac_if_single(codec, nid); |
| 3869 | else if (!dac) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3870 | dac = alc_auto_look_for_dac(codec, nid); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3871 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3872 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3873 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3874 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3875 | spec->multi_io[spec->multi_ios].pin = nid; |
| 3876 | spec->multi_io[spec->multi_ios].dac = dac; |
| 3877 | spec->multi_ios++; |
| 3878 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3879 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3880 | } |
| 3881 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3882 | end_fill: |
| 3883 | if (badness) |
| 3884 | badness = BAD_MULTI_IO; |
| 3885 | if (old_pins == spec->multi_ios) { |
| 3886 | if (hardwired) |
| 3887 | return 1; /* nothing found */ |
| 3888 | else |
| 3889 | return badness; /* no badness if nothing found */ |
| 3890 | } |
| 3891 | if (!hardwired && spec->multi_ios < 2) { |
| 3892 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3893 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3894 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3895 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3896 | return 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3897 | } |
| 3898 | |
| 3899 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 3900 | struct snd_ctl_elem_info *uinfo) |
| 3901 | { |
| 3902 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3903 | struct alc_spec *spec = codec->spec; |
| 3904 | |
| 3905 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 3906 | uinfo->count = 1; |
| 3907 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 3908 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 3909 | uinfo->value.enumerated.item = spec->multi_ios; |
| 3910 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 3911 | (uinfo->value.enumerated.item + 1) * 2); |
| 3912 | return 0; |
| 3913 | } |
| 3914 | |
| 3915 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 3916 | struct snd_ctl_elem_value *ucontrol) |
| 3917 | { |
| 3918 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3919 | struct alc_spec *spec = codec->spec; |
| 3920 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 3921 | return 0; |
| 3922 | } |
| 3923 | |
| 3924 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 3925 | { |
| 3926 | struct alc_spec *spec = codec->spec; |
| 3927 | hda_nid_t nid = spec->multi_io[idx].pin; |
| 3928 | |
| 3929 | if (!spec->multi_io[idx].ctl_in) |
| 3930 | spec->multi_io[idx].ctl_in = |
| 3931 | snd_hda_codec_read(codec, nid, 0, |
| 3932 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 3933 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3934 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3935 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3936 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3937 | HDA_AMP_MUTE, 0); |
| 3938 | alc_auto_select_dac(codec, nid, spec->multi_io[idx].dac); |
| 3939 | } else { |
| 3940 | if (get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) |
| 3941 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
| 3942 | HDA_AMP_MUTE, HDA_AMP_MUTE); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 3943 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 3944 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3945 | } |
| 3946 | return 0; |
| 3947 | } |
| 3948 | |
| 3949 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 3950 | struct snd_ctl_elem_value *ucontrol) |
| 3951 | { |
| 3952 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 3953 | struct alc_spec *spec = codec->spec; |
| 3954 | int i, ch; |
| 3955 | |
| 3956 | ch = ucontrol->value.enumerated.item[0]; |
| 3957 | if (ch < 0 || ch > spec->multi_ios) |
| 3958 | return -EINVAL; |
| 3959 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 3960 | return 0; |
| 3961 | spec->ext_channel_count = (ch + 1) * 2; |
| 3962 | for (i = 0; i < spec->multi_ios; i++) |
| 3963 | alc_set_multi_io(codec, i, i < ch); |
| 3964 | spec->multiout.max_channels = spec->ext_channel_count; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 3965 | if (spec->need_dac_fix && !spec->const_channel_count) |
| 3966 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3967 | return 1; |
| 3968 | } |
| 3969 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 3970 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3971 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 3972 | .name = "Channel Mode", |
| 3973 | .info = alc_auto_ch_mode_info, |
| 3974 | .get = alc_auto_ch_mode_get, |
| 3975 | .put = alc_auto_ch_mode_put, |
| 3976 | }; |
| 3977 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3978 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3979 | { |
| 3980 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3981 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3982 | if (spec->multi_ios > 0) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3983 | struct snd_kcontrol_new *knew; |
| 3984 | |
| 3985 | knew = alc_kcontrol_new(spec); |
| 3986 | if (!knew) |
| 3987 | return -ENOMEM; |
| 3988 | *knew = alc_auto_channel_mode_enum; |
| 3989 | knew->name = kstrdup("Channel Mode", GFP_KERNEL); |
| 3990 | if (!knew->name) |
| 3991 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3992 | } |
| 3993 | return 0; |
| 3994 | } |
| 3995 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 3996 | /* filter out invalid adc_nids (and capsrc_nids) that don't give all |
| 3997 | * active input pins |
| 3998 | */ |
| 3999 | static void alc_remove_invalid_adc_nids(struct hda_codec *codec) |
| 4000 | { |
| 4001 | struct alc_spec *spec = codec->spec; |
| 4002 | const struct hda_input_mux *imux; |
| 4003 | hda_nid_t adc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4004 | hda_nid_t capsrc_nids[ARRAY_SIZE(spec->private_adc_nids)]; |
| 4005 | int i, n, nums; |
| 4006 | |
| 4007 | imux = spec->input_mux; |
| 4008 | if (!imux) |
| 4009 | return; |
| 4010 | if (spec->dyn_adc_switch) |
| 4011 | return; |
| 4012 | |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4013 | again: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4014 | nums = 0; |
| 4015 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 4016 | hda_nid_t cap = spec->private_capsrc_nids[n]; |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 4017 | int num_conns = snd_hda_get_num_conns(codec, cap); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4018 | for (i = 0; i < imux->num_items; i++) { |
| 4019 | hda_nid_t pin = spec->imux_pins[i]; |
| 4020 | if (pin) { |
| 4021 | if (get_connection_index(codec, cap, pin) < 0) |
| 4022 | break; |
| 4023 | } else if (num_conns <= imux->items[i].index) |
| 4024 | break; |
| 4025 | } |
| 4026 | if (i >= imux->num_items) { |
| 4027 | adc_nids[nums] = spec->private_adc_nids[n]; |
| 4028 | capsrc_nids[nums++] = cap; |
| 4029 | } |
| 4030 | } |
| 4031 | if (!nums) { |
| 4032 | /* check whether ADC-switch is possible */ |
| 4033 | if (!alc_check_dyn_adc_switch(codec)) { |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4034 | if (spec->shared_mic_hp) { |
| 4035 | spec->shared_mic_hp = 0; |
| 4036 | spec->private_imux[0].num_items = 1; |
| 4037 | goto again; |
| 4038 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4039 | printk(KERN_WARNING "hda_codec: %s: no valid ADC found;" |
| 4040 | " using fallback 0x%x\n", |
| 4041 | codec->chip_name, spec->private_adc_nids[0]); |
| 4042 | spec->num_adc_nids = 1; |
| 4043 | spec->auto_mic = 0; |
| 4044 | return; |
| 4045 | } |
| 4046 | } else if (nums != spec->num_adc_nids) { |
| 4047 | memcpy(spec->private_adc_nids, adc_nids, |
| 4048 | nums * sizeof(hda_nid_t)); |
| 4049 | memcpy(spec->private_capsrc_nids, capsrc_nids, |
| 4050 | nums * sizeof(hda_nid_t)); |
| 4051 | spec->num_adc_nids = nums; |
| 4052 | } |
| 4053 | |
| 4054 | if (spec->auto_mic) |
| 4055 | alc_auto_mic_check_imux(codec); /* check auto-mic setups */ |
Takashi Iwai | 26acaf0 | 2012-03-22 14:36:50 +0100 | [diff] [blame] | 4056 | else if (spec->input_mux->num_items == 1 || spec->shared_mic_hp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4057 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 4058 | } |
| 4059 | |
| 4060 | /* |
| 4061 | * initialize ADC paths |
| 4062 | */ |
| 4063 | static void alc_auto_init_adc(struct hda_codec *codec, int adc_idx) |
| 4064 | { |
| 4065 | struct alc_spec *spec = codec->spec; |
| 4066 | hda_nid_t nid; |
| 4067 | |
| 4068 | nid = spec->adc_nids[adc_idx]; |
| 4069 | /* mute ADC */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4070 | if (nid_has_mute(codec, nid, HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4071 | snd_hda_codec_write(codec, nid, 0, |
| 4072 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4073 | AMP_IN_MUTE(0)); |
| 4074 | return; |
| 4075 | } |
| 4076 | if (!spec->capsrc_nids) |
| 4077 | return; |
| 4078 | nid = spec->capsrc_nids[adc_idx]; |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4079 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4080 | snd_hda_codec_write(codec, nid, 0, |
| 4081 | AC_VERB_SET_AMP_GAIN_MUTE, |
| 4082 | AMP_OUT_MUTE); |
| 4083 | } |
| 4084 | |
| 4085 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4086 | { |
| 4087 | struct alc_spec *spec = codec->spec; |
| 4088 | int c, nums; |
| 4089 | |
| 4090 | for (c = 0; c < spec->num_adc_nids; c++) |
| 4091 | alc_auto_init_adc(codec, c); |
| 4092 | if (spec->dyn_adc_switch) |
| 4093 | nums = 1; |
| 4094 | else |
| 4095 | nums = spec->num_adc_nids; |
| 4096 | for (c = 0; c < nums; c++) |
Takashi Iwai | 068b939 | 2012-02-25 11:13:16 +0100 | [diff] [blame] | 4097 | alc_mux_select(codec, c, spec->cur_mux[c], true); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4098 | } |
| 4099 | |
| 4100 | /* add mic boosts if needed */ |
| 4101 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4102 | { |
| 4103 | struct alc_spec *spec = codec->spec; |
| 4104 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4105 | int i, err; |
| 4106 | int type_idx = 0; |
| 4107 | hda_nid_t nid; |
| 4108 | const char *prev_label = NULL; |
| 4109 | |
| 4110 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4111 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4112 | break; |
| 4113 | nid = cfg->inputs[i].pin; |
| 4114 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4115 | const char *label; |
| 4116 | char boost_label[32]; |
| 4117 | |
| 4118 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4119 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4120 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4121 | if (prev_label && !strcmp(label, prev_label)) |
| 4122 | type_idx++; |
| 4123 | else |
| 4124 | type_idx = 0; |
| 4125 | prev_label = label; |
| 4126 | |
| 4127 | snprintf(boost_label, sizeof(boost_label), |
| 4128 | "%s Boost Volume", label); |
| 4129 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
| 4130 | boost_label, type_idx, |
| 4131 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); |
| 4132 | if (err < 0) |
| 4133 | return err; |
| 4134 | } |
| 4135 | } |
| 4136 | return 0; |
| 4137 | } |
| 4138 | |
| 4139 | /* select or unmute the given capsrc route */ |
| 4140 | static void select_or_unmute_capsrc(struct hda_codec *codec, hda_nid_t cap, |
| 4141 | int idx) |
| 4142 | { |
| 4143 | if (get_wcaps_type(get_wcaps(codec, cap)) == AC_WID_AUD_MIX) { |
| 4144 | snd_hda_codec_amp_stereo(codec, cap, HDA_INPUT, idx, |
| 4145 | HDA_AMP_MUTE, 0); |
Takashi Iwai | 09cf03b | 2012-05-19 17:21:25 +0200 | [diff] [blame] | 4146 | } else if (snd_hda_get_num_conns(codec, cap) > 1) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4147 | snd_hda_codec_write_cache(codec, cap, 0, |
| 4148 | AC_VERB_SET_CONNECT_SEL, idx); |
| 4149 | } |
| 4150 | } |
| 4151 | |
| 4152 | /* set the default connection to that pin */ |
| 4153 | static int init_capsrc_for_pin(struct hda_codec *codec, hda_nid_t pin) |
| 4154 | { |
| 4155 | struct alc_spec *spec = codec->spec; |
| 4156 | int i; |
| 4157 | |
| 4158 | if (!pin) |
| 4159 | return 0; |
| 4160 | for (i = 0; i < spec->num_adc_nids; i++) { |
Takashi Iwai | 6107159 | 2011-11-23 07:52:15 +0100 | [diff] [blame] | 4161 | hda_nid_t cap = get_capsrc(spec, i); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4162 | int idx; |
| 4163 | |
| 4164 | idx = get_connection_index(codec, cap, pin); |
| 4165 | if (idx < 0) |
| 4166 | continue; |
| 4167 | select_or_unmute_capsrc(codec, cap, idx); |
| 4168 | return i; /* return the found index */ |
| 4169 | } |
| 4170 | return -1; /* not found */ |
| 4171 | } |
| 4172 | |
| 4173 | /* initialize some special cases for input sources */ |
| 4174 | static void alc_init_special_input_src(struct hda_codec *codec) |
| 4175 | { |
| 4176 | struct alc_spec *spec = codec->spec; |
| 4177 | int i; |
| 4178 | |
| 4179 | for (i = 0; i < spec->autocfg.num_inputs; i++) |
| 4180 | init_capsrc_for_pin(codec, spec->autocfg.inputs[i].pin); |
| 4181 | } |
| 4182 | |
| 4183 | /* assign appropriate capture mixers */ |
| 4184 | static void set_capture_mixer(struct hda_codec *codec) |
| 4185 | { |
| 4186 | struct alc_spec *spec = codec->spec; |
| 4187 | static const struct snd_kcontrol_new *caps[2][3] = { |
| 4188 | { alc_capture_mixer_nosrc1, |
| 4189 | alc_capture_mixer_nosrc2, |
| 4190 | alc_capture_mixer_nosrc3 }, |
| 4191 | { alc_capture_mixer1, |
| 4192 | alc_capture_mixer2, |
| 4193 | alc_capture_mixer3 }, |
| 4194 | }; |
| 4195 | |
| 4196 | /* check whether either of ADC or MUX has a volume control */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4197 | if (!nid_has_volume(codec, spec->adc_nids[0], HDA_INPUT)) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4198 | if (!spec->capsrc_nids) |
| 4199 | return; /* no volume */ |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 4200 | if (!nid_has_volume(codec, spec->capsrc_nids[0], HDA_OUTPUT)) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4201 | return; /* no volume in capsrc, too */ |
| 4202 | spec->vol_in_capsrc = 1; |
| 4203 | } |
| 4204 | |
| 4205 | if (spec->num_adc_nids > 0) { |
| 4206 | int mux = 0; |
| 4207 | int num_adcs = 0; |
| 4208 | |
| 4209 | if (spec->input_mux && spec->input_mux->num_items > 1) |
| 4210 | mux = 1; |
| 4211 | if (spec->auto_mic) { |
| 4212 | num_adcs = 1; |
| 4213 | mux = 0; |
| 4214 | } else if (spec->dyn_adc_switch) |
| 4215 | num_adcs = 1; |
| 4216 | if (!num_adcs) { |
| 4217 | if (spec->num_adc_nids > 3) |
| 4218 | spec->num_adc_nids = 3; |
| 4219 | else if (!spec->num_adc_nids) |
| 4220 | return; |
| 4221 | num_adcs = spec->num_adc_nids; |
| 4222 | } |
| 4223 | spec->cap_mixer = caps[mux][num_adcs - 1]; |
| 4224 | } |
| 4225 | } |
| 4226 | |
| 4227 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4228 | * standard auto-parser initializations |
| 4229 | */ |
| 4230 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4231 | { |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4232 | alc_auto_init_multi_out(codec); |
| 4233 | alc_auto_init_extra_out(codec); |
| 4234 | alc_auto_init_analog_input(codec); |
| 4235 | alc_auto_init_input_src(codec); |
| 4236 | alc_auto_init_digital(codec); |
David Henningsson | a7a0a64 | 2012-07-05 12:00:12 +0200 | [diff] [blame] | 4237 | alc_inithook(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4238 | } |
| 4239 | |
| 4240 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4241 | * Digital-beep handlers |
| 4242 | */ |
| 4243 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4244 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4245 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4246 | |
| 4247 | static const struct snd_pci_quirk beep_white_list[] = { |
| 4248 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4249 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4250 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4251 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4252 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4253 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4254 | {} |
| 4255 | }; |
| 4256 | |
| 4257 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4258 | { |
| 4259 | struct alc_spec *spec = codec->spec; |
| 4260 | const struct snd_pci_quirk *q; |
| 4261 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4262 | if (q) |
| 4263 | return q->value; |
| 4264 | return spec->cdefine.enable_pcbeep; |
| 4265 | } |
| 4266 | #else |
| 4267 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4268 | #define has_cdefine_beep(codec) 0 |
| 4269 | #endif |
| 4270 | |
| 4271 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4272 | /* return 1 if successful, 0 if the proper config is not found, |
| 4273 | * or a negative error code |
| 4274 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4275 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4276 | const hda_nid_t *ignore_nids, |
| 4277 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4278 | { |
| 4279 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4280 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4281 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4282 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4283 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4284 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4285 | if (err < 0) |
| 4286 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4287 | if (!cfg->line_outs) { |
| 4288 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4289 | spec->multiout.max_channels = 2; |
| 4290 | spec->no_analog = 1; |
| 4291 | goto dig_only; |
| 4292 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4293 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4294 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4295 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 4296 | if (!spec->no_primary_hp && |
| 4297 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4298 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4299 | /* use HP as primary out */ |
| 4300 | cfg->speaker_outs = cfg->line_outs; |
| 4301 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4302 | sizeof(cfg->speaker_pins)); |
| 4303 | cfg->line_outs = cfg->hp_outs; |
| 4304 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4305 | cfg->hp_outs = 0; |
| 4306 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4307 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4308 | } |
| 4309 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4310 | err = alc_auto_fill_dac_nids(codec); |
| 4311 | if (err < 0) |
| 4312 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4313 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4314 | if (err < 0) |
| 4315 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4316 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4317 | if (err < 0) |
| 4318 | return err; |
| 4319 | err = alc_auto_create_hp_out(codec); |
| 4320 | if (err < 0) |
| 4321 | return err; |
| 4322 | err = alc_auto_create_speaker_out(codec); |
| 4323 | if (err < 0) |
| 4324 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4325 | err = alc_auto_create_shared_input(codec); |
| 4326 | if (err < 0) |
| 4327 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4328 | err = alc_auto_create_input_ctls(codec); |
| 4329 | if (err < 0) |
| 4330 | return err; |
| 4331 | |
| 4332 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
| 4333 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4334 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4335 | alc_auto_parse_digital(codec); |
| 4336 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4337 | if (!spec->no_analog) |
| 4338 | alc_remove_invalid_adc_nids(codec); |
| 4339 | |
| 4340 | if (ssid_nids) |
| 4341 | alc_ssid_check(codec, ssid_nids); |
| 4342 | |
| 4343 | if (!spec->no_analog) { |
| 4344 | alc_auto_check_switches(codec); |
| 4345 | err = alc_auto_add_mic_boost(codec); |
| 4346 | if (err < 0) |
| 4347 | return err; |
| 4348 | } |
| 4349 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4350 | if (spec->kctls.list) |
| 4351 | add_mixer(spec, spec->kctls.list); |
| 4352 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 4353 | if (!spec->no_analog && !spec->cap_mixer) |
| 4354 | set_capture_mixer(codec); |
| 4355 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4356 | return 1; |
| 4357 | } |
| 4358 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4359 | /* common preparation job for alc_spec */ |
| 4360 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4361 | { |
| 4362 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4363 | int err; |
| 4364 | |
| 4365 | if (!spec) |
| 4366 | return -ENOMEM; |
| 4367 | codec->spec = spec; |
| 4368 | spec->mixer_nid = mixer_nid; |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 4369 | snd_hda_gen_init(&spec->gen); |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4370 | |
| 4371 | err = alc_codec_rename_from_preset(codec); |
| 4372 | if (err < 0) { |
| 4373 | kfree(spec); |
| 4374 | return err; |
| 4375 | } |
| 4376 | return 0; |
| 4377 | } |
| 4378 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4379 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4380 | { |
| 4381 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4382 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4383 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4384 | } |
| 4385 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4386 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4387 | * ALC880 fix-ups |
| 4388 | */ |
| 4389 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4390 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4391 | ALC880_FIXUP_GPIO2, |
| 4392 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4393 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4394 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4395 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4396 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4397 | ALC880_FIXUP_VOL_KNOB, |
| 4398 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4399 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4400 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4401 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4402 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4403 | ALC880_FIXUP_3ST_BASE, |
| 4404 | ALC880_FIXUP_3ST, |
| 4405 | ALC880_FIXUP_3ST_DIG, |
| 4406 | ALC880_FIXUP_5ST_BASE, |
| 4407 | ALC880_FIXUP_5ST, |
| 4408 | ALC880_FIXUP_5ST_DIG, |
| 4409 | ALC880_FIXUP_6ST_BASE, |
| 4410 | ALC880_FIXUP_6ST, |
| 4411 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4412 | }; |
| 4413 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4414 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4415 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4416 | const struct alc_fixup *fix, int action) |
| 4417 | { |
| 4418 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4419 | snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master); |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4420 | } |
| 4421 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4422 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4423 | [ALC880_FIXUP_GPIO1] = { |
| 4424 | .type = ALC_FIXUP_VERBS, |
| 4425 | .v.verbs = alc_gpio1_init_verbs, |
| 4426 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4427 | [ALC880_FIXUP_GPIO2] = { |
| 4428 | .type = ALC_FIXUP_VERBS, |
| 4429 | .v.verbs = alc_gpio2_init_verbs, |
| 4430 | }, |
| 4431 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4432 | .type = ALC_FIXUP_VERBS, |
| 4433 | .v.verbs = (const struct hda_verb[]) { |
| 4434 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4435 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4436 | { } |
| 4437 | }, |
| 4438 | .chained = true, |
| 4439 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4440 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4441 | [ALC880_FIXUP_LG] = { |
| 4442 | .type = ALC_FIXUP_PINS, |
| 4443 | .v.pins = (const struct alc_pincfg[]) { |
| 4444 | /* disable bogus unused pins */ |
| 4445 | { 0x16, 0x411111f0 }, |
| 4446 | { 0x18, 0x411111f0 }, |
| 4447 | { 0x1a, 0x411111f0 }, |
| 4448 | { } |
| 4449 | } |
| 4450 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4451 | [ALC880_FIXUP_W810] = { |
| 4452 | .type = ALC_FIXUP_PINS, |
| 4453 | .v.pins = (const struct alc_pincfg[]) { |
| 4454 | /* disable bogus unused pins */ |
| 4455 | { 0x17, 0x411111f0 }, |
| 4456 | { } |
| 4457 | }, |
| 4458 | .chained = true, |
| 4459 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4460 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4461 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4462 | .type = ALC_FIXUP_VERBS, |
| 4463 | .v.verbs = (const struct hda_verb[]) { |
| 4464 | /* change to EAPD mode */ |
| 4465 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4466 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4467 | {} |
| 4468 | }, |
| 4469 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4470 | [ALC880_FIXUP_TCL_S700] = { |
| 4471 | .type = ALC_FIXUP_VERBS, |
| 4472 | .v.verbs = (const struct hda_verb[]) { |
| 4473 | /* change to EAPD mode */ |
| 4474 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4475 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4476 | {} |
| 4477 | }, |
| 4478 | .chained = true, |
| 4479 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4480 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4481 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4482 | .type = ALC_FIXUP_FUNC, |
| 4483 | .v.func = alc880_fixup_vol_knob, |
| 4484 | }, |
| 4485 | [ALC880_FIXUP_FUJITSU] = { |
| 4486 | /* override all pins as BIOS on old Amilo is broken */ |
| 4487 | .type = ALC_FIXUP_PINS, |
| 4488 | .v.pins = (const struct alc_pincfg[]) { |
| 4489 | { 0x14, 0x0121411f }, /* HP */ |
| 4490 | { 0x15, 0x99030120 }, /* speaker */ |
| 4491 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4492 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4493 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4494 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4495 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4496 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4497 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4498 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4499 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4500 | { } |
| 4501 | }, |
| 4502 | .chained = true, |
| 4503 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4504 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4505 | [ALC880_FIXUP_F1734] = { |
| 4506 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4507 | .type = ALC_FIXUP_PINS, |
| 4508 | .v.pins = (const struct alc_pincfg[]) { |
| 4509 | { 0x14, 0x0121411f }, /* HP */ |
| 4510 | { 0x15, 0x99030120 }, /* speaker */ |
| 4511 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4512 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4513 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4514 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4515 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4516 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4517 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4518 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4519 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4520 | { } |
| 4521 | }, |
| 4522 | .chained = true, |
| 4523 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4524 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4525 | [ALC880_FIXUP_UNIWILL] = { |
| 4526 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4527 | .type = ALC_FIXUP_PINS, |
| 4528 | .v.pins = (const struct alc_pincfg[]) { |
| 4529 | { 0x14, 0x0121411f }, /* HP */ |
| 4530 | { 0x15, 0x99030120 }, /* speaker */ |
| 4531 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4532 | { } |
| 4533 | }, |
| 4534 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4535 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4536 | .type = ALC_FIXUP_PINS, |
| 4537 | .v.pins = (const struct alc_pincfg[]) { |
| 4538 | /* disable bogus unused pins */ |
| 4539 | { 0x17, 0x411111f0 }, |
| 4540 | { 0x19, 0x411111f0 }, |
| 4541 | { 0x1b, 0x411111f0 }, |
| 4542 | { 0x1f, 0x411111f0 }, |
| 4543 | { } |
| 4544 | } |
| 4545 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4546 | [ALC880_FIXUP_Z71V] = { |
| 4547 | .type = ALC_FIXUP_PINS, |
| 4548 | .v.pins = (const struct alc_pincfg[]) { |
| 4549 | /* set up the whole pins as BIOS is utterly broken */ |
| 4550 | { 0x14, 0x99030120 }, /* speaker */ |
| 4551 | { 0x15, 0x0121411f }, /* HP */ |
| 4552 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4553 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4554 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4555 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4556 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4557 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4558 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4559 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4560 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4561 | { } |
| 4562 | } |
| 4563 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4564 | [ALC880_FIXUP_3ST_BASE] = { |
| 4565 | .type = ALC_FIXUP_PINS, |
| 4566 | .v.pins = (const struct alc_pincfg[]) { |
| 4567 | { 0x14, 0x01014010 }, /* line-out */ |
| 4568 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4569 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4570 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4571 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4572 | { 0x19, 0x0121411f }, /* HP */ |
| 4573 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4574 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4575 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4576 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4577 | /* 0x1e is filled in below */ |
| 4578 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4579 | { } |
| 4580 | } |
| 4581 | }, |
| 4582 | [ALC880_FIXUP_3ST] = { |
| 4583 | .type = ALC_FIXUP_PINS, |
| 4584 | .v.pins = (const struct alc_pincfg[]) { |
| 4585 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4586 | { } |
| 4587 | }, |
| 4588 | .chained = true, |
| 4589 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4590 | }, |
| 4591 | [ALC880_FIXUP_3ST_DIG] = { |
| 4592 | .type = ALC_FIXUP_PINS, |
| 4593 | .v.pins = (const struct alc_pincfg[]) { |
| 4594 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4595 | { } |
| 4596 | }, |
| 4597 | .chained = true, |
| 4598 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4599 | }, |
| 4600 | [ALC880_FIXUP_5ST_BASE] = { |
| 4601 | .type = ALC_FIXUP_PINS, |
| 4602 | .v.pins = (const struct alc_pincfg[]) { |
| 4603 | { 0x14, 0x01014010 }, /* front */ |
| 4604 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4605 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4606 | { 0x17, 0x01016412 }, /* surr */ |
| 4607 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4608 | { 0x19, 0x0121411f }, /* HP */ |
| 4609 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4610 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4611 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4612 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4613 | /* 0x1e is filled in below */ |
| 4614 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4615 | { } |
| 4616 | } |
| 4617 | }, |
| 4618 | [ALC880_FIXUP_5ST] = { |
| 4619 | .type = ALC_FIXUP_PINS, |
| 4620 | .v.pins = (const struct alc_pincfg[]) { |
| 4621 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4622 | { } |
| 4623 | }, |
| 4624 | .chained = true, |
| 4625 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4626 | }, |
| 4627 | [ALC880_FIXUP_5ST_DIG] = { |
| 4628 | .type = ALC_FIXUP_PINS, |
| 4629 | .v.pins = (const struct alc_pincfg[]) { |
| 4630 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4631 | { } |
| 4632 | }, |
| 4633 | .chained = true, |
| 4634 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4635 | }, |
| 4636 | [ALC880_FIXUP_6ST_BASE] = { |
| 4637 | .type = ALC_FIXUP_PINS, |
| 4638 | .v.pins = (const struct alc_pincfg[]) { |
| 4639 | { 0x14, 0x01014010 }, /* front */ |
| 4640 | { 0x15, 0x01016412 }, /* surr */ |
| 4641 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4642 | { 0x17, 0x01012414 }, /* side */ |
| 4643 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4644 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4645 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4646 | { 0x1b, 0x0121411f }, /* HP */ |
| 4647 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4648 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4649 | /* 0x1e is filled in below */ |
| 4650 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4651 | { } |
| 4652 | } |
| 4653 | }, |
| 4654 | [ALC880_FIXUP_6ST] = { |
| 4655 | .type = ALC_FIXUP_PINS, |
| 4656 | .v.pins = (const struct alc_pincfg[]) { |
| 4657 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4658 | { } |
| 4659 | }, |
| 4660 | .chained = true, |
| 4661 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4662 | }, |
| 4663 | [ALC880_FIXUP_6ST_DIG] = { |
| 4664 | .type = ALC_FIXUP_PINS, |
| 4665 | .v.pins = (const struct alc_pincfg[]) { |
| 4666 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4667 | { } |
| 4668 | }, |
| 4669 | .chained = true, |
| 4670 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4671 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4672 | }; |
| 4673 | |
| 4674 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4675 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4676 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4677 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4678 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4679 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4680 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4681 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4682 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4683 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4684 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4685 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4686 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4687 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4688 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4689 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4690 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4691 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4692 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4693 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4694 | |
| 4695 | /* Below is the copied entries from alc880_quirks.c. |
| 4696 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4697 | * on these machines, thus they are kept to be compatible with |
| 4698 | * the old static quirks. Once when it's confirmed to work without |
| 4699 | * these overrides, it'd be better to remove. |
| 4700 | */ |
| 4701 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4702 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4703 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4704 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4705 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4706 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4707 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4708 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4709 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4710 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4711 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4712 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4713 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4714 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4715 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4716 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4717 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4718 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4719 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4720 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4721 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4722 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4723 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4724 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4725 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4726 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4727 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4728 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4729 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4730 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4731 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4732 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4733 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4734 | /* default Intel */ |
| 4735 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4736 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4737 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4738 | {} |
| 4739 | }; |
| 4740 | |
| 4741 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4742 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4743 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4744 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4745 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4746 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4747 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4748 | {} |
| 4749 | }; |
| 4750 | |
| 4751 | |
| 4752 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4753 | * OK, here we have finally the patch for ALC880 |
| 4754 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4755 | static int patch_alc880(struct hda_codec *codec) |
| 4756 | { |
| 4757 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4758 | int err; |
| 4759 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4760 | err = alc_alloc_spec(codec, 0x0b); |
| 4761 | if (err < 0) |
| 4762 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4763 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4764 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4765 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4766 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4767 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4768 | alc880_fixups); |
| 4769 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4770 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4771 | /* automatic parse from the BIOS config */ |
| 4772 | err = alc880_parse_auto_config(codec); |
| 4773 | if (err < 0) |
| 4774 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4775 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4776 | if (!spec->no_analog) { |
| 4777 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4778 | if (err < 0) |
| 4779 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4780 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4781 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4782 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4783 | codec->patch_ops = alc_patch_ops; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4784 | codec->patch_ops.unsol_event = alc880_unsol_event; |
| 4785 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4786 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4787 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4788 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4789 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4790 | |
| 4791 | error: |
| 4792 | alc_free(codec); |
| 4793 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4794 | } |
| 4795 | |
| 4796 | |
| 4797 | /* |
| 4798 | * ALC260 support |
| 4799 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4800 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4801 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4802 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4803 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4804 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4805 | } |
| 4806 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4807 | /* |
| 4808 | * Pin config fixes |
| 4809 | */ |
| 4810 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4811 | ALC260_FIXUP_HP_DC5750, |
| 4812 | ALC260_FIXUP_HP_PIN_0F, |
| 4813 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4814 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4815 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4816 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4817 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4818 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4819 | }; |
| 4820 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4821 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4822 | { |
| 4823 | struct alc_spec *spec = codec->spec; |
| 4824 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4825 | spec->hp_jack_present); |
| 4826 | } |
| 4827 | |
| 4828 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4829 | const struct alc_fixup *fix, int action) |
| 4830 | { |
| 4831 | struct alc_spec *spec = codec->spec; |
| 4832 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4833 | /* although the machine has only one output pin, we need to |
| 4834 | * toggle GPIO1 according to the jack state |
| 4835 | */ |
| 4836 | spec->automute_hook = alc260_gpio1_automute; |
| 4837 | spec->detect_hp = 1; |
| 4838 | spec->automute_speaker = 1; |
| 4839 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4840 | snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, |
| 4841 | alc_hp_automute); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4842 | snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4843 | } |
| 4844 | } |
| 4845 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4846 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 4847 | const struct alc_fixup *fix, int action) |
| 4848 | { |
| 4849 | struct alc_spec *spec = codec->spec; |
| 4850 | static const struct alc_pincfg pincfgs[] = { |
| 4851 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 4852 | { 0x12, 0x90a60160 }, /* int mic */ |
| 4853 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 4854 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 4855 | /* disable bogus I/O pins */ |
| 4856 | { 0x10, 0x411111f0 }, |
| 4857 | { 0x11, 0x411111f0 }, |
| 4858 | { 0x14, 0x411111f0 }, |
| 4859 | { 0x15, 0x411111f0 }, |
| 4860 | { 0x16, 0x411111f0 }, |
| 4861 | { 0x17, 0x411111f0 }, |
| 4862 | { 0x19, 0x411111f0 }, |
| 4863 | { } |
| 4864 | }; |
| 4865 | |
| 4866 | switch (action) { |
| 4867 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 4868 | alc_apply_pincfgs(codec, pincfgs); |
| 4869 | break; |
| 4870 | case ALC_FIXUP_ACT_PROBE: |
| 4871 | spec->init_amp = ALC_INIT_NONE; |
| 4872 | break; |
| 4873 | } |
| 4874 | } |
| 4875 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4876 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4877 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4878 | .type = ALC_FIXUP_PINS, |
| 4879 | .v.pins = (const struct alc_pincfg[]) { |
| 4880 | { 0x11, 0x90130110 }, /* speaker */ |
| 4881 | { } |
| 4882 | } |
| 4883 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4884 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 4885 | .type = ALC_FIXUP_PINS, |
| 4886 | .v.pins = (const struct alc_pincfg[]) { |
| 4887 | { 0x0f, 0x01214000 }, /* HP */ |
| 4888 | { } |
| 4889 | } |
| 4890 | }, |
| 4891 | [ALC260_FIXUP_COEF] = { |
| 4892 | .type = ALC_FIXUP_VERBS, |
| 4893 | .v.verbs = (const struct hda_verb[]) { |
| 4894 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4895 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 4896 | { } |
| 4897 | }, |
| 4898 | .chained = true, |
| 4899 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4900 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4901 | [ALC260_FIXUP_GPIO1] = { |
| 4902 | .type = ALC_FIXUP_VERBS, |
| 4903 | .v.verbs = alc_gpio1_init_verbs, |
| 4904 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4905 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 4906 | .type = ALC_FIXUP_FUNC, |
| 4907 | .v.func = alc260_fixup_gpio1_toggle, |
| 4908 | .chained = true, |
| 4909 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4910 | }, |
| 4911 | [ALC260_FIXUP_REPLACER] = { |
| 4912 | .type = ALC_FIXUP_VERBS, |
| 4913 | .v.verbs = (const struct hda_verb[]) { |
| 4914 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4915 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4916 | { } |
| 4917 | }, |
| 4918 | .chained = true, |
| 4919 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 4920 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4921 | [ALC260_FIXUP_HP_B1900] = { |
| 4922 | .type = ALC_FIXUP_FUNC, |
| 4923 | .v.func = alc260_fixup_gpio1_toggle, |
| 4924 | .chained = true, |
| 4925 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4926 | }, |
| 4927 | [ALC260_FIXUP_KN1] = { |
| 4928 | .type = ALC_FIXUP_FUNC, |
| 4929 | .v.func = alc260_fixup_kn1, |
| 4930 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4931 | }; |
| 4932 | |
| 4933 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4934 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4935 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4936 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4937 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4938 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 4939 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4940 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4941 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4942 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4943 | {} |
| 4944 | }; |
| 4945 | |
| 4946 | /* |
| 4947 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4948 | static int patch_alc260(struct hda_codec *codec) |
| 4949 | { |
| 4950 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4951 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4952 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4953 | err = alc_alloc_spec(codec, 0x07); |
| 4954 | if (err < 0) |
| 4955 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4956 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4957 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4958 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4959 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 4960 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4961 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4962 | /* automatic parse from the BIOS config */ |
| 4963 | err = alc260_parse_auto_config(codec); |
| 4964 | if (err < 0) |
| 4965 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4966 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4967 | if (!spec->no_analog) { |
| 4968 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4969 | if (err < 0) |
| 4970 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4971 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 4972 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4973 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4974 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4975 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4976 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4977 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4978 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4979 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4980 | |
| 4981 | error: |
| 4982 | alc_free(codec); |
| 4983 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4984 | } |
| 4985 | |
| 4986 | |
| 4987 | /* |
| 4988 | * ALC882/883/885/888/889 support |
| 4989 | * |
| 4990 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 4991 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 4992 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 4993 | * 6-channel independent captures. |
| 4994 | * |
| 4995 | * In addition, an independent DAC for the multi-playback (not used in this |
| 4996 | * driver yet). |
| 4997 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4998 | |
| 4999 | /* |
| 5000 | * Pin config fixes |
| 5001 | */ |
| 5002 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5003 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5004 | ALC882_FIXUP_LENOVO_Y530, |
| 5005 | ALC882_FIXUP_PB_M5210, |
| 5006 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5007 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5008 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5009 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5010 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5011 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5012 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5013 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5014 | ALC882_FIXUP_GPIO1, |
| 5015 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5016 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5017 | ALC889_FIXUP_COEF, |
| 5018 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5019 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5020 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5021 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5022 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5023 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5024 | ALC889_FIXUP_MBP_VREF, |
| 5025 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5026 | ALC882_FIXUP_INV_DMIC, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5027 | ALC882_FIXUP_NO_PRIMARY_HP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5028 | }; |
| 5029 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5030 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5031 | const struct alc_fixup *fix, int action) |
| 5032 | { |
| 5033 | if (action != ALC_FIXUP_ACT_INIT) |
| 5034 | return; |
| 5035 | alc889_coef_init(codec); |
| 5036 | } |
| 5037 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5038 | /* toggle speaker-output according to the hp-jack state */ |
| 5039 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5040 | { |
| 5041 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5042 | |
| 5043 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5044 | AC_VERB_GET_GPIO_DATA, 0); |
| 5045 | |
| 5046 | if (!muted) |
| 5047 | gpiostate |= (1 << pin); |
| 5048 | else |
| 5049 | gpiostate &= ~(1 << pin); |
| 5050 | |
| 5051 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5052 | AC_VERB_GET_GPIO_MASK, 0); |
| 5053 | gpiomask |= (1 << pin); |
| 5054 | |
| 5055 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5056 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5057 | gpiodir |= (1 << pin); |
| 5058 | |
| 5059 | |
| 5060 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5061 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5062 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5063 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5064 | |
| 5065 | msleep(1); |
| 5066 | |
| 5067 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5068 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5069 | } |
| 5070 | |
| 5071 | /* set up GPIO at initialization */ |
| 5072 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5073 | const struct alc_fixup *fix, int action) |
| 5074 | { |
| 5075 | if (action != ALC_FIXUP_ACT_INIT) |
| 5076 | return; |
| 5077 | alc882_gpio_mute(codec, 0, 0); |
| 5078 | alc882_gpio_mute(codec, 1, 0); |
| 5079 | } |
| 5080 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5081 | /* Fix the connection of some pins for ALC889: |
| 5082 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5083 | * work correctly (bko#42740) |
| 5084 | */ |
| 5085 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5086 | const struct alc_fixup *fix, int action) |
| 5087 | { |
| 5088 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5089 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5090 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5091 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5092 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5093 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5094 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5095 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5096 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5097 | /* restore the connections */ |
| 5098 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5099 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5100 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5101 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5102 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5103 | } |
| 5104 | } |
| 5105 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5106 | /* Set VREF on HP pin */ |
| 5107 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5108 | const struct alc_fixup *fix, int action) |
| 5109 | { |
| 5110 | struct alc_spec *spec = codec->spec; |
| 5111 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5112 | int i; |
| 5113 | |
| 5114 | if (action != ALC_FIXUP_ACT_INIT) |
| 5115 | return; |
| 5116 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5117 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5118 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5119 | continue; |
| 5120 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5121 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5122 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5123 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5124 | spec->keep_vref_in_automute = 1; |
| 5125 | break; |
| 5126 | } |
| 5127 | } |
| 5128 | |
| 5129 | /* Set VREF on speaker pins on imac91 */ |
| 5130 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5131 | const struct alc_fixup *fix, int action) |
| 5132 | { |
| 5133 | struct alc_spec *spec = codec->spec; |
| 5134 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5135 | int i; |
| 5136 | |
| 5137 | if (action != ALC_FIXUP_ACT_INIT) |
| 5138 | return; |
| 5139 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5140 | unsigned int val; |
| 5141 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5142 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5143 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5144 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5145 | } |
| 5146 | spec->keep_vref_in_automute = 1; |
| 5147 | } |
| 5148 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5149 | /* Don't take HP output as primary |
| 5150 | * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05 |
| 5151 | */ |
| 5152 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, |
| 5153 | const struct alc_fixup *fix, int action) |
| 5154 | { |
| 5155 | struct alc_spec *spec = codec->spec; |
| 5156 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5157 | spec->no_primary_hp = 1; |
| 5158 | } |
| 5159 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5160 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5161 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5162 | .type = ALC_FIXUP_PINS, |
| 5163 | .v.pins = (const struct alc_pincfg[]) { |
| 5164 | { 0x15, 0x01080104 }, /* side */ |
| 5165 | { 0x16, 0x01011012 }, /* rear */ |
| 5166 | { 0x17, 0x01016011 }, /* clfe */ |
| 5167 | { } |
| 5168 | } |
| 5169 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5170 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5171 | .type = ALC_FIXUP_PINS, |
| 5172 | .v.pins = (const struct alc_pincfg[]) { |
| 5173 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5174 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5175 | { } |
| 5176 | } |
| 5177 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5178 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5179 | .type = ALC_FIXUP_VERBS, |
| 5180 | .v.verbs = (const struct hda_verb[]) { |
| 5181 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5182 | {} |
| 5183 | } |
| 5184 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5185 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5186 | .type = ALC_FIXUP_FUNC, |
| 5187 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5188 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5189 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5190 | .type = ALC_FIXUP_PINS, |
| 5191 | .v.pins = (const struct alc_pincfg[]) { |
| 5192 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5193 | { } |
| 5194 | } |
| 5195 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5196 | [ALC889_FIXUP_CD] = { |
| 5197 | .type = ALC_FIXUP_PINS, |
| 5198 | .v.pins = (const struct alc_pincfg[]) { |
| 5199 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5200 | { } |
| 5201 | } |
| 5202 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5203 | [ALC889_FIXUP_VAIO_TT] = { |
| 5204 | .type = ALC_FIXUP_PINS, |
| 5205 | .v.pins = (const struct alc_pincfg[]) { |
| 5206 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5207 | { } |
| 5208 | } |
| 5209 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5210 | [ALC888_FIXUP_EEE1601] = { |
| 5211 | .type = ALC_FIXUP_VERBS, |
| 5212 | .v.verbs = (const struct hda_verb[]) { |
| 5213 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5214 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5215 | { } |
| 5216 | } |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5217 | }, |
| 5218 | [ALC882_FIXUP_EAPD] = { |
| 5219 | .type = ALC_FIXUP_VERBS, |
| 5220 | .v.verbs = (const struct hda_verb[]) { |
| 5221 | /* change to EAPD mode */ |
| 5222 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5223 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5224 | { } |
| 5225 | } |
| 5226 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5227 | [ALC883_FIXUP_EAPD] = { |
| 5228 | .type = ALC_FIXUP_VERBS, |
| 5229 | .v.verbs = (const struct hda_verb[]) { |
| 5230 | /* change to EAPD mode */ |
| 5231 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5232 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5233 | { } |
| 5234 | } |
| 5235 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5236 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5237 | .type = ALC_FIXUP_VERBS, |
| 5238 | .v.verbs = (const struct hda_verb[]) { |
| 5239 | /* eanable EAPD on Acer laptops */ |
| 5240 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5241 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5242 | { } |
| 5243 | } |
| 5244 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5245 | [ALC882_FIXUP_GPIO1] = { |
| 5246 | .type = ALC_FIXUP_VERBS, |
| 5247 | .v.verbs = alc_gpio1_init_verbs, |
| 5248 | }, |
| 5249 | [ALC882_FIXUP_GPIO2] = { |
| 5250 | .type = ALC_FIXUP_VERBS, |
| 5251 | .v.verbs = alc_gpio2_init_verbs, |
| 5252 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5253 | [ALC882_FIXUP_GPIO3] = { |
| 5254 | .type = ALC_FIXUP_VERBS, |
| 5255 | .v.verbs = alc_gpio3_init_verbs, |
| 5256 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5257 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5258 | .type = ALC_FIXUP_VERBS, |
| 5259 | .v.verbs = alc_gpio1_init_verbs, |
| 5260 | .chained = true, |
| 5261 | .chain_id = ALC882_FIXUP_EAPD, |
| 5262 | }, |
| 5263 | [ALC889_FIXUP_COEF] = { |
| 5264 | .type = ALC_FIXUP_FUNC, |
| 5265 | .v.func = alc889_fixup_coef, |
| 5266 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5267 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5268 | .type = ALC_FIXUP_PINS, |
| 5269 | .v.pins = (const struct alc_pincfg[]) { |
| 5270 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5271 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5272 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5273 | }, |
| 5274 | .chained = true, |
| 5275 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5276 | }, |
| 5277 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5278 | .type = ALC_FIXUP_PINS, |
| 5279 | .v.pins = (const struct alc_pincfg[]) { |
| 5280 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5281 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5282 | { } |
| 5283 | }, |
| 5284 | .chained = true, |
| 5285 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5286 | }, |
| 5287 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5288 | /* additional init verbs for Acer Aspire 8930G */ |
| 5289 | .type = ALC_FIXUP_VERBS, |
| 5290 | .v.verbs = (const struct hda_verb[]) { |
| 5291 | /* Enable all DACs */ |
| 5292 | /* DAC DISABLE/MUTE 1? */ |
| 5293 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5294 | * apparently. Init=0x38 */ |
| 5295 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5296 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5297 | /* DAC DISABLE/MUTE 2? */ |
| 5298 | /* some bit here disables the other DACs. |
| 5299 | * Init=0x4900 */ |
| 5300 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5301 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5302 | /* DMIC fix |
| 5303 | * This laptop has a stereo digital microphone. |
| 5304 | * The mics are only 1cm apart which makes the stereo |
| 5305 | * useless. However, either the mic or the ALC889 |
| 5306 | * makes the signal become a difference/sum signal |
| 5307 | * instead of standard stereo, which is annoying. |
| 5308 | * So instead we flip this bit which makes the |
| 5309 | * codec replicate the sum signal to both channels, |
| 5310 | * turning it into a normal mono mic. |
| 5311 | */ |
| 5312 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5313 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5314 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5315 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5316 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5317 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5318 | }, |
| 5319 | .chained = true, |
| 5320 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5321 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5322 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5323 | .type = ALC_FIXUP_FUNC, |
| 5324 | .v.func = alc885_fixup_macpro_gpio, |
| 5325 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5326 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5327 | .type = ALC_FIXUP_FUNC, |
| 5328 | .v.func = alc889_fixup_dac_route, |
| 5329 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5330 | [ALC889_FIXUP_MBP_VREF] = { |
| 5331 | .type = ALC_FIXUP_FUNC, |
| 5332 | .v.func = alc889_fixup_mbp_vref, |
| 5333 | .chained = true, |
| 5334 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5335 | }, |
| 5336 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5337 | .type = ALC_FIXUP_FUNC, |
| 5338 | .v.func = alc889_fixup_imac91_vref, |
| 5339 | .chained = true, |
| 5340 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5341 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5342 | [ALC882_FIXUP_INV_DMIC] = { |
| 5343 | .type = ALC_FIXUP_FUNC, |
| 5344 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5345 | }, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5346 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
| 5347 | .type = ALC_FIXUP_FUNC, |
| 5348 | .v.func = alc882_fixup_no_primary_hp, |
| 5349 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5350 | }; |
| 5351 | |
| 5352 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5353 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5354 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5355 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5356 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5357 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5358 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5359 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5360 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5361 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5362 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5363 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5364 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5365 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5366 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5367 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5368 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5369 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5370 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5371 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5372 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5373 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5374 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5375 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5376 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5377 | SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5378 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a3 | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5379 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5380 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5381 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5382 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5383 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5384 | SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5385 | |
| 5386 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5387 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5388 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5389 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5390 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5391 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5392 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5393 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5394 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5395 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5396 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5397 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5398 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5399 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5400 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5401 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5402 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5403 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5404 | SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5405 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5406 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5407 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5408 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5409 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5410 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5411 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5412 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5413 | SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5414 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5415 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5416 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5417 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5418 | {} |
| 5419 | }; |
| 5420 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5421 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5422 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5423 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5424 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5425 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5426 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5427 | {} |
| 5428 | }; |
| 5429 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5430 | /* |
| 5431 | * BIOS auto configuration |
| 5432 | */ |
| 5433 | /* almost identical with ALC880 parser... */ |
| 5434 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5435 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5436 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5437 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5438 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5439 | } |
| 5440 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5441 | /* |
| 5442 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5443 | static int patch_alc882(struct hda_codec *codec) |
| 5444 | { |
| 5445 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5446 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5447 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5448 | err = alc_alloc_spec(codec, 0x0b); |
| 5449 | if (err < 0) |
| 5450 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5451 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5452 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5453 | |
| 5454 | switch (codec->vendor_id) { |
| 5455 | case 0x10ec0882: |
| 5456 | case 0x10ec0885: |
| 5457 | break; |
| 5458 | default: |
| 5459 | /* ALC883 and variants */ |
| 5460 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5461 | break; |
| 5462 | } |
| 5463 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5464 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5465 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5466 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5467 | |
| 5468 | alc_auto_parse_customize_define(codec); |
| 5469 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5470 | /* automatic parse from the BIOS config */ |
| 5471 | err = alc882_parse_auto_config(codec); |
| 5472 | if (err < 0) |
| 5473 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5474 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5475 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5476 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5477 | if (err < 0) |
| 5478 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5479 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5480 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5481 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5482 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5483 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5484 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5485 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5486 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5487 | |
| 5488 | error: |
| 5489 | alc_free(codec); |
| 5490 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5491 | } |
| 5492 | |
| 5493 | |
| 5494 | /* |
| 5495 | * ALC262 support |
| 5496 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5497 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5498 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5499 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5500 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5501 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5502 | } |
| 5503 | |
| 5504 | /* |
| 5505 | * Pin config fixes |
| 5506 | */ |
| 5507 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5508 | ALC262_FIXUP_FSC_H270, |
| 5509 | ALC262_FIXUP_HP_Z200, |
| 5510 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5511 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5512 | ALC262_FIXUP_BENQ, |
| 5513 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5514 | ALC262_FIXUP_INV_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5515 | }; |
| 5516 | |
| 5517 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5518 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5519 | .type = ALC_FIXUP_PINS, |
| 5520 | .v.pins = (const struct alc_pincfg[]) { |
| 5521 | { 0x14, 0x99130110 }, /* speaker */ |
| 5522 | { 0x15, 0x0221142f }, /* front HP */ |
| 5523 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5524 | { } |
| 5525 | } |
| 5526 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5527 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5528 | .type = ALC_FIXUP_PINS, |
| 5529 | .v.pins = (const struct alc_pincfg[]) { |
| 5530 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5531 | { } |
| 5532 | } |
| 5533 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5534 | [ALC262_FIXUP_TYAN] = { |
| 5535 | .type = ALC_FIXUP_PINS, |
| 5536 | .v.pins = (const struct alc_pincfg[]) { |
| 5537 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5538 | { } |
| 5539 | } |
| 5540 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5541 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5542 | .type = ALC_FIXUP_VERBS, |
| 5543 | .v.verbs = (const struct hda_verb[]) { |
| 5544 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5545 | {} |
| 5546 | }, |
| 5547 | .chained = true, |
| 5548 | .chain_id = ALC262_FIXUP_BENQ, |
| 5549 | }, |
| 5550 | [ALC262_FIXUP_BENQ] = { |
| 5551 | .type = ALC_FIXUP_VERBS, |
| 5552 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5553 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5554 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5555 | {} |
| 5556 | } |
| 5557 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5558 | [ALC262_FIXUP_BENQ_T31] = { |
| 5559 | .type = ALC_FIXUP_VERBS, |
| 5560 | .v.verbs = (const struct hda_verb[]) { |
| 5561 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5562 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5563 | {} |
| 5564 | } |
| 5565 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5566 | [ALC262_FIXUP_INV_DMIC] = { |
| 5567 | .type = ALC_FIXUP_FUNC, |
| 5568 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5569 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5570 | }; |
| 5571 | |
| 5572 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5573 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5574 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5575 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5576 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5577 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5578 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5579 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5580 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5581 | {} |
| 5582 | }; |
| 5583 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5584 | static const struct alc_model_fixup alc262_fixup_models[] = { |
| 5585 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5586 | {} |
| 5587 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5588 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5589 | /* |
| 5590 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5591 | static int patch_alc262(struct hda_codec *codec) |
| 5592 | { |
| 5593 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5594 | int err; |
| 5595 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5596 | err = alc_alloc_spec(codec, 0x0b); |
| 5597 | if (err < 0) |
| 5598 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5599 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5600 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5601 | |
| 5602 | #if 0 |
| 5603 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5604 | * under-run |
| 5605 | */ |
| 5606 | { |
| 5607 | int tmp; |
| 5608 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5609 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5610 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5611 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5612 | } |
| 5613 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5614 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5615 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5616 | alc_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
| 5617 | alc262_fixups); |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5618 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5619 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5620 | alc_auto_parse_customize_define(codec); |
| 5621 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5622 | /* automatic parse from the BIOS config */ |
| 5623 | err = alc262_parse_auto_config(codec); |
| 5624 | if (err < 0) |
| 5625 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5626 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5627 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5628 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5629 | if (err < 0) |
| 5630 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5631 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5632 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5633 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5634 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5635 | spec->shutup = alc_eapd_shutup; |
| 5636 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5637 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5638 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5639 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5640 | |
| 5641 | error: |
| 5642 | alc_free(codec); |
| 5643 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5644 | } |
| 5645 | |
| 5646 | /* |
| 5647 | * ALC268 |
| 5648 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5649 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5650 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5651 | .ops = &snd_hda_bind_sw, |
| 5652 | .values = { |
| 5653 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5654 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5655 | 0 |
| 5656 | }, |
| 5657 | }; |
| 5658 | |
| 5659 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5660 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5661 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5662 | { } |
| 5663 | }; |
| 5664 | |
| 5665 | /* set PCBEEP vol = 0, mute connections */ |
| 5666 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5667 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5668 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5669 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5670 | { } |
| 5671 | }; |
| 5672 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5673 | enum { |
| 5674 | ALC268_FIXUP_INV_DMIC, |
| 5675 | }; |
| 5676 | |
| 5677 | static const struct alc_fixup alc268_fixups[] = { |
| 5678 | [ALC268_FIXUP_INV_DMIC] = { |
| 5679 | .type = ALC_FIXUP_FUNC, |
| 5680 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5681 | }, |
| 5682 | }; |
| 5683 | |
| 5684 | static const struct alc_model_fixup alc268_fixup_models[] = { |
| 5685 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5686 | {} |
| 5687 | }; |
| 5688 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5689 | /* |
| 5690 | * BIOS auto configuration |
| 5691 | */ |
| 5692 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5693 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5694 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5695 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5696 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5697 | if (err > 0) { |
| 5698 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5699 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5700 | snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5701 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5702 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5703 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5704 | } |
| 5705 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5706 | /* |
| 5707 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5708 | static int patch_alc268(struct hda_codec *codec) |
| 5709 | { |
| 5710 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5711 | int i, has_beep, err; |
| 5712 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5713 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5714 | err = alc_alloc_spec(codec, 0); |
| 5715 | if (err < 0) |
| 5716 | return err; |
| 5717 | |
| 5718 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5719 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5720 | alc_pick_fixup(codec, alc268_fixup_models, NULL, alc268_fixups); |
| 5721 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 5722 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5723 | /* automatic parse from the BIOS config */ |
| 5724 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5725 | if (err < 0) |
| 5726 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5727 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5728 | has_beep = 0; |
| 5729 | for (i = 0; i < spec->num_mixers; i++) { |
| 5730 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5731 | has_beep = 1; |
| 5732 | break; |
| 5733 | } |
| 5734 | } |
| 5735 | |
| 5736 | if (has_beep) { |
| 5737 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5738 | if (err < 0) |
| 5739 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5740 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5741 | /* override the amp caps for beep generator */ |
| 5742 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5743 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5744 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5745 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5746 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5747 | } |
| 5748 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5749 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5750 | spec->shutup = alc_eapd_shutup; |
| 5751 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5752 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5753 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5754 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5755 | |
| 5756 | error: |
| 5757 | alc_free(codec); |
| 5758 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5759 | } |
| 5760 | |
| 5761 | /* |
| 5762 | * ALC269 |
| 5763 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5764 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5765 | .substreams = 1, |
| 5766 | .channels_min = 2, |
| 5767 | .channels_max = 8, |
| 5768 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5769 | /* NID is set in alc_build_pcms */ |
| 5770 | .ops = { |
| 5771 | .open = alc_playback_pcm_open, |
| 5772 | .prepare = alc_playback_pcm_prepare, |
| 5773 | .cleanup = alc_playback_pcm_cleanup |
| 5774 | }, |
| 5775 | }; |
| 5776 | |
| 5777 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5778 | .substreams = 1, |
| 5779 | .channels_min = 2, |
| 5780 | .channels_max = 2, |
| 5781 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5782 | /* NID is set in alc_build_pcms */ |
| 5783 | }; |
| 5784 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5785 | /* different alc269-variants */ |
| 5786 | enum { |
| 5787 | ALC269_TYPE_ALC269VA, |
| 5788 | ALC269_TYPE_ALC269VB, |
| 5789 | ALC269_TYPE_ALC269VC, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5790 | ALC269_TYPE_ALC269VD, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5791 | }; |
| 5792 | |
| 5793 | /* |
| 5794 | * BIOS auto configuration |
| 5795 | */ |
| 5796 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5797 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5798 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5799 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5800 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5801 | struct alc_spec *spec = codec->spec; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5802 | const hda_nid_t *ssids; |
| 5803 | |
| 5804 | switch (spec->codec_variant) { |
| 5805 | case ALC269_TYPE_ALC269VA: |
| 5806 | case ALC269_TYPE_ALC269VC: |
| 5807 | ssids = alc269va_ssids; |
| 5808 | break; |
| 5809 | case ALC269_TYPE_ALC269VB: |
| 5810 | case ALC269_TYPE_ALC269VD: |
| 5811 | ssids = alc269_ssids; |
| 5812 | break; |
| 5813 | default: |
| 5814 | ssids = alc269_ssids; |
| 5815 | break; |
| 5816 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5817 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5818 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5819 | } |
| 5820 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5821 | static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) |
| 5822 | { |
| 5823 | int val = alc_read_coef_idx(codec, 0x04); |
| 5824 | if (power_up) |
| 5825 | val |= 1 << 11; |
| 5826 | else |
| 5827 | val &= ~(1 << 11); |
| 5828 | alc_write_coef_idx(codec, 0x04, val); |
| 5829 | } |
| 5830 | |
| 5831 | static void alc269_shutup(struct hda_codec *codec) |
| 5832 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5833 | struct alc_spec *spec = codec->spec; |
| 5834 | |
| 5835 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
| 5836 | return; |
| 5837 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5838 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5839 | alc269_toggle_power_output(codec, 0); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 5840 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5841 | alc269_toggle_power_output(codec, 0); |
| 5842 | msleep(150); |
| 5843 | } |
| 5844 | } |
| 5845 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5846 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5847 | static int alc269_resume(struct hda_codec *codec) |
| 5848 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5849 | struct alc_spec *spec = codec->spec; |
| 5850 | |
| 5851 | if (spec->codec_variant == ALC269_TYPE_ALC269VB || |
| 5852 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5853 | alc269_toggle_power_output(codec, 0); |
| 5854 | msleep(150); |
| 5855 | } |
| 5856 | |
| 5857 | codec->patch_ops.init(codec); |
| 5858 | |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5859 | if (spec->codec_variant == ALC269_TYPE_ALC269VB || |
| 5860 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5861 | alc269_toggle_power_output(codec, 1); |
| 5862 | msleep(200); |
| 5863 | } |
| 5864 | |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5865 | if (spec->codec_variant == ALC269_TYPE_ALC269VB || |
| 5866 | (alc_get_coef0(codec) & 0x00ff) == 0x018) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5867 | alc269_toggle_power_output(codec, 1); |
| 5868 | |
| 5869 | snd_hda_codec_resume_amp(codec); |
| 5870 | snd_hda_codec_resume_cache(codec); |
| 5871 | hda_call_check_power_status(codec, 0x01); |
| 5872 | return 0; |
| 5873 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5874 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5875 | |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 5876 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
| 5877 | const struct alc_fixup *fix, int action) |
| 5878 | { |
| 5879 | struct alc_spec *spec = codec->spec; |
| 5880 | |
| 5881 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5882 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 5883 | } |
| 5884 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5885 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 5886 | const struct alc_fixup *fix, int action) |
| 5887 | { |
| 5888 | int coef; |
| 5889 | |
| 5890 | if (action != ALC_FIXUP_ACT_INIT) |
| 5891 | return; |
| 5892 | coef = alc_read_coef_idx(codec, 0x1e); |
| 5893 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 5894 | } |
| 5895 | |
| 5896 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 5897 | const struct alc_fixup *fix, int action) |
| 5898 | { |
| 5899 | static const struct hda_verb verbs[] = { |
| 5900 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 5901 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 5902 | {} |
| 5903 | }; |
| 5904 | unsigned int cfg; |
| 5905 | |
| 5906 | if (strcmp(codec->chip_name, "ALC271X")) |
| 5907 | return; |
| 5908 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 5909 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 5910 | snd_hda_sequence_write(codec, verbs); |
| 5911 | } |
| 5912 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5913 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 5914 | const struct alc_fixup *fix, int action) |
| 5915 | { |
| 5916 | struct alc_spec *spec = codec->spec; |
| 5917 | |
| 5918 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5919 | return; |
| 5920 | |
| 5921 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 5922 | * fix the sample rate of analog I/O to 44.1kHz |
| 5923 | */ |
| 5924 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 5925 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 5926 | } |
| 5927 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5928 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 5929 | const struct alc_fixup *fix, int action) |
| 5930 | { |
| 5931 | int coef; |
| 5932 | |
| 5933 | if (action != ALC_FIXUP_ACT_INIT) |
| 5934 | return; |
| 5935 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 5936 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 5937 | * Below is a workaround specific to ALC269 to control the dmic |
| 5938 | * signal source as mono. |
| 5939 | */ |
| 5940 | coef = alc_read_coef_idx(codec, 0x07); |
| 5941 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 5942 | } |
| 5943 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5944 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 5945 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 5946 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 5947 | |
| 5948 | snd_hda_codec_write(codec, 0x20, 0, |
| 5949 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5950 | snd_hda_codec_write(codec, 0x20, 0, |
| 5951 | AC_VERB_SET_PROC_COEF, 0x680); |
| 5952 | |
| 5953 | snd_hda_codec_write(codec, 0x20, 0, |
| 5954 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 5955 | snd_hda_codec_write(codec, 0x20, 0, |
| 5956 | AC_VERB_SET_PROC_COEF, 0x480); |
| 5957 | } |
| 5958 | |
| 5959 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 5960 | const struct alc_fixup *fix, int action) |
| 5961 | { |
| 5962 | struct alc_spec *spec = codec->spec; |
| 5963 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5964 | return; |
| 5965 | spec->automute_hook = alc269_quanta_automute; |
| 5966 | } |
| 5967 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5968 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 5969 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 5970 | { |
| 5971 | struct hda_codec *codec = private_data; |
| 5972 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5973 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5974 | } |
| 5975 | |
| 5976 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 5977 | const struct alc_fixup *fix, int action) |
| 5978 | { |
| 5979 | struct alc_spec *spec = codec->spec; |
| 5980 | switch (action) { |
| 5981 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5982 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735cb | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 5983 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5984 | /* fallthru */ |
| 5985 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 5986 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 5987 | break; |
| 5988 | } |
| 5989 | } |
| 5990 | |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 5991 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5992 | enum { |
| 5993 | ALC269_FIXUP_SONY_VAIO, |
| 5994 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 5995 | ALC269_FIXUP_DELL_M101Z, |
| 5996 | ALC269_FIXUP_SKU_IGNORE, |
| 5997 | ALC269_FIXUP_ASUS_G73JW, |
| 5998 | ALC269_FIXUP_LENOVO_EAPD, |
| 5999 | ALC275_FIXUP_SONY_HWEQ, |
| 6000 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6001 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6002 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6003 | ALC269_FIXUP_QUANTA_MUTE, |
| 6004 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6005 | ALC269_FIXUP_AMIC, |
| 6006 | ALC269_FIXUP_DMIC, |
| 6007 | ALC269VB_FIXUP_AMIC, |
| 6008 | ALC269VB_FIXUP_DMIC, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6009 | ALC269_FIXUP_MIC2_MUTE_LED, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6010 | ALC269_FIXUP_INV_DMIC, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6011 | ALC269_FIXUP_LENOVO_DOCK, |
| 6012 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6013 | }; |
| 6014 | |
| 6015 | static const struct alc_fixup alc269_fixups[] = { |
| 6016 | [ALC269_FIXUP_SONY_VAIO] = { |
| 6017 | .type = ALC_FIXUP_VERBS, |
| 6018 | .v.verbs = (const struct hda_verb[]) { |
| 6019 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 6020 | {} |
| 6021 | } |
| 6022 | }, |
| 6023 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 6024 | .type = ALC_FIXUP_VERBS, |
| 6025 | .v.verbs = (const struct hda_verb[]) { |
| 6026 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6027 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6028 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6029 | { } |
| 6030 | }, |
| 6031 | .chained = true, |
| 6032 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6033 | }, |
| 6034 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6035 | .type = ALC_FIXUP_VERBS, |
| 6036 | .v.verbs = (const struct hda_verb[]) { |
| 6037 | /* Enables internal speaker */ |
| 6038 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6039 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6040 | {} |
| 6041 | } |
| 6042 | }, |
| 6043 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6044 | .type = ALC_FIXUP_FUNC, |
| 6045 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6046 | }, |
| 6047 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6048 | .type = ALC_FIXUP_PINS, |
| 6049 | .v.pins = (const struct alc_pincfg[]) { |
| 6050 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6051 | { } |
| 6052 | } |
| 6053 | }, |
| 6054 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6055 | .type = ALC_FIXUP_VERBS, |
| 6056 | .v.verbs = (const struct hda_verb[]) { |
| 6057 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6058 | {} |
| 6059 | } |
| 6060 | }, |
| 6061 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6062 | .type = ALC_FIXUP_FUNC, |
| 6063 | .v.func = alc269_fixup_hweq, |
| 6064 | .chained = true, |
| 6065 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6066 | }, |
| 6067 | [ALC271_FIXUP_DMIC] = { |
| 6068 | .type = ALC_FIXUP_FUNC, |
| 6069 | .v.func = alc271_fixup_dmic, |
| 6070 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6071 | [ALC269_FIXUP_PCM_44K] = { |
| 6072 | .type = ALC_FIXUP_FUNC, |
| 6073 | .v.func = alc269_fixup_pcm_44k, |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6074 | .chained = true, |
| 6075 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6076 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6077 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6078 | .type = ALC_FIXUP_FUNC, |
| 6079 | .v.func = alc269_fixup_stereo_dmic, |
| 6080 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6081 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6082 | .type = ALC_FIXUP_FUNC, |
| 6083 | .v.func = alc269_fixup_quanta_mute, |
| 6084 | }, |
| 6085 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6086 | .type = ALC_FIXUP_PINS, |
| 6087 | .v.pins = (const struct alc_pincfg[]) { |
| 6088 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6089 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6090 | { } |
| 6091 | }, |
| 6092 | .chained = true, |
| 6093 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6094 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6095 | [ALC269_FIXUP_AMIC] = { |
| 6096 | .type = ALC_FIXUP_PINS, |
| 6097 | .v.pins = (const struct alc_pincfg[]) { |
| 6098 | { 0x14, 0x99130110 }, /* speaker */ |
| 6099 | { 0x15, 0x0121401f }, /* HP out */ |
| 6100 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6101 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6102 | { } |
| 6103 | }, |
| 6104 | }, |
| 6105 | [ALC269_FIXUP_DMIC] = { |
| 6106 | .type = ALC_FIXUP_PINS, |
| 6107 | .v.pins = (const struct alc_pincfg[]) { |
| 6108 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6109 | { 0x14, 0x99130110 }, /* speaker */ |
| 6110 | { 0x15, 0x0121401f }, /* HP out */ |
| 6111 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6112 | { } |
| 6113 | }, |
| 6114 | }, |
| 6115 | [ALC269VB_FIXUP_AMIC] = { |
| 6116 | .type = ALC_FIXUP_PINS, |
| 6117 | .v.pins = (const struct alc_pincfg[]) { |
| 6118 | { 0x14, 0x99130110 }, /* speaker */ |
| 6119 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6120 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6121 | { 0x21, 0x0121401f }, /* HP out */ |
| 6122 | { } |
| 6123 | }, |
| 6124 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6125 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6126 | .type = ALC_FIXUP_PINS, |
| 6127 | .v.pins = (const struct alc_pincfg[]) { |
| 6128 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6129 | { 0x14, 0x99130110 }, /* speaker */ |
| 6130 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6131 | { 0x21, 0x0121401f }, /* HP out */ |
| 6132 | { } |
| 6133 | }, |
| 6134 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6135 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6136 | .type = ALC_FIXUP_FUNC, |
| 6137 | .v.func = alc269_fixup_mic2_mute, |
| 6138 | }, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6139 | [ALC269_FIXUP_INV_DMIC] = { |
| 6140 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6141 | .v.func = alc_fixup_inv_dmic_0x12, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6142 | }, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6143 | [ALC269_FIXUP_LENOVO_DOCK] = { |
| 6144 | .type = ALC_FIXUP_PINS, |
| 6145 | .v.pins = (const struct alc_pincfg[]) { |
| 6146 | { 0x19, 0x23a11040 }, /* dock mic */ |
| 6147 | { 0x1b, 0x2121103f }, /* dock headphone */ |
| 6148 | { } |
| 6149 | }, |
| 6150 | .chained = true, |
| 6151 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT |
| 6152 | }, |
| 6153 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 6154 | .type = ALC_FIXUP_FUNC, |
| 6155 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 6156 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6157 | }; |
| 6158 | |
| 6159 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6160 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
| 6161 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6162 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 5ac5755 | 2012-04-20 10:01:46 +0200 | [diff] [blame] | 6163 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Oleksij Rempel | 148728f | 2012-09-21 17:44:58 +0200 | [diff] [blame] | 6164 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6165 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6166 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6167 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6168 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6169 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6170 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6171 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6172 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6173 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6174 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6175 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6176 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
| 6177 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6178 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6179 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6180 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6181 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6182 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6183 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 707fba3 | 2012-08-02 09:04:39 +0200 | [diff] [blame] | 6184 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
Felix Kaechele | c8415a4 | 2012-08-06 23:02:01 +0200 | [diff] [blame] | 6185 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
Philipp A. Mohrenweiser | 4407be6 | 2012-08-06 13:14:18 +0200 | [diff] [blame] | 6186 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6187 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6188 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6189 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6190 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6191 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6192 | /* Below is a quirk table taken from the old code. |
| 6193 | * Basically the device should work as is without the fixup table. |
| 6194 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6195 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6196 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6197 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6198 | ALC269_FIXUP_AMIC), |
| 6199 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6200 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6201 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6202 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6203 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6204 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6205 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6206 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6207 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6208 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6209 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6210 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6211 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6212 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6213 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6214 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6215 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6216 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6217 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6218 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6219 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6220 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6221 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6222 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6223 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6224 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6225 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6226 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6227 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6228 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6229 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6230 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6231 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6232 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6233 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6234 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6235 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6236 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6237 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6238 | #endif |
| 6239 | {} |
| 6240 | }; |
| 6241 | |
| 6242 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6243 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6244 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6245 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
| 6246 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
| 6247 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6248 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6249 | {} |
| 6250 | }; |
| 6251 | |
| 6252 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6253 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6254 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6255 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6256 | int val; |
| 6257 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6258 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6259 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6260 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6261 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6262 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6263 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6264 | } |
| 6265 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6266 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6267 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6268 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6269 | } |
| 6270 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6271 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6272 | val = alc_read_coef_idx(codec, 0x04); |
| 6273 | /* Power up output pin */ |
| 6274 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6275 | } |
| 6276 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6277 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6278 | val = alc_read_coef_idx(codec, 0xd); |
| 6279 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6280 | /* Capless ramp up clock control */ |
| 6281 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6282 | } |
| 6283 | val = alc_read_coef_idx(codec, 0x17); |
| 6284 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6285 | /* Class D power on reset */ |
| 6286 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6287 | } |
| 6288 | } |
| 6289 | |
| 6290 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6291 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6292 | |
| 6293 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6294 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6295 | } |
| 6296 | |
| 6297 | /* |
| 6298 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6299 | static int patch_alc269(struct hda_codec *codec) |
| 6300 | { |
| 6301 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6302 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6303 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6304 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6305 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6306 | return err; |
| 6307 | |
| 6308 | spec = codec->spec; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6309 | |
Herton Ronaldo Krzesinski | 9f720bb9 | 2012-09-27 10:38:14 -0300 | [diff] [blame^] | 6310 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6311 | alc269_fixup_tbl, alc269_fixups); |
| 6312 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6313 | |
| 6314 | alc_auto_parse_customize_define(codec); |
| 6315 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6316 | if (codec->vendor_id == 0x10ec0269) { |
| 6317 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6318 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6319 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6320 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6321 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6322 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6323 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6324 | break; |
| 6325 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6326 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6327 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6328 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6329 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6330 | break; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6331 | case 0x0030: |
| 6332 | spec->codec_variant = ALC269_TYPE_ALC269VD; |
| 6333 | break; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6334 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6335 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6336 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6337 | if (err < 0) |
| 6338 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6339 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6340 | alc269_fill_coef(codec); |
| 6341 | } |
| 6342 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6343 | /* automatic parse from the BIOS config */ |
| 6344 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6345 | if (err < 0) |
| 6346 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6347 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6348 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6349 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6350 | if (err < 0) |
| 6351 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6352 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6353 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6354 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6355 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6356 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6357 | codec->patch_ops.resume = alc269_resume; |
| 6358 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6359 | spec->shutup = alc269_shutup; |
| 6360 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6361 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6362 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6363 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6364 | |
| 6365 | error: |
| 6366 | alc_free(codec); |
| 6367 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6368 | } |
| 6369 | |
| 6370 | /* |
| 6371 | * ALC861 |
| 6372 | */ |
| 6373 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6374 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6375 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6376 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6377 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6378 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6379 | } |
| 6380 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6381 | /* Pin config fixes */ |
| 6382 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6383 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6384 | ALC861_FIXUP_AMP_VREF_0F, |
| 6385 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6386 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6387 | }; |
| 6388 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6389 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6390 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6391 | const struct alc_fixup *fix, int action) |
| 6392 | { |
| 6393 | struct alc_spec *spec = codec->spec; |
| 6394 | unsigned int val; |
| 6395 | |
| 6396 | if (action != ALC_FIXUP_ACT_INIT) |
| 6397 | return; |
| 6398 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6399 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6400 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6401 | val |= AC_PINCTL_IN_EN; |
| 6402 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6403 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6404 | spec->keep_vref_in_automute = 1; |
| 6405 | } |
| 6406 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6407 | /* suppress the jack-detection */ |
| 6408 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6409 | const struct alc_fixup *fix, int action) |
| 6410 | { |
| 6411 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6412 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6413 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6414 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6415 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6416 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6417 | .type = ALC_FIXUP_PINS, |
| 6418 | .v.pins = (const struct alc_pincfg[]) { |
| 6419 | { 0x0b, 0x0221101f }, /* HP */ |
| 6420 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6421 | { } |
| 6422 | } |
| 6423 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6424 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6425 | .type = ALC_FIXUP_FUNC, |
| 6426 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6427 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6428 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6429 | .type = ALC_FIXUP_FUNC, |
| 6430 | .v.func = alc_fixup_no_jack_detect, |
| 6431 | }, |
| 6432 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6433 | .type = ALC_FIXUP_FUNC, |
| 6434 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6435 | .chained = true, |
| 6436 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6437 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6438 | }; |
| 6439 | |
| 6440 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6441 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6442 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6443 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6444 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6445 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6446 | SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6447 | {} |
| 6448 | }; |
| 6449 | |
| 6450 | /* |
| 6451 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6452 | static int patch_alc861(struct hda_codec *codec) |
| 6453 | { |
| 6454 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6455 | int err; |
| 6456 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6457 | err = alc_alloc_spec(codec, 0x15); |
| 6458 | if (err < 0) |
| 6459 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6460 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6461 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6462 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6463 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6464 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6465 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6466 | /* automatic parse from the BIOS config */ |
| 6467 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6468 | if (err < 0) |
| 6469 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6470 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6471 | if (!spec->no_analog) { |
| 6472 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6473 | if (err < 0) |
| 6474 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6475 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6476 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6477 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6478 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 6479 | #ifdef CONFIG_PM |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6480 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6481 | #endif |
| 6482 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6483 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6484 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6485 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6486 | |
| 6487 | error: |
| 6488 | alc_free(codec); |
| 6489 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6490 | } |
| 6491 | |
| 6492 | /* |
| 6493 | * ALC861-VD support |
| 6494 | * |
| 6495 | * Based on ALC882 |
| 6496 | * |
| 6497 | * In addition, an independent DAC |
| 6498 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6499 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6500 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6501 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6502 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6503 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6504 | } |
| 6505 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6506 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6507 | ALC660VD_FIX_ASUS_GPIO1, |
| 6508 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6509 | }; |
| 6510 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6511 | /* exclude VREF80 */ |
| 6512 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6513 | const struct alc_fixup *fix, int action) |
| 6514 | { |
| 6515 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
| 6516 | snd_hda_override_pin_caps(codec, 0x18, 0x00001714); |
| 6517 | snd_hda_override_pin_caps(codec, 0x19, 0x0000171c); |
| 6518 | } |
| 6519 | } |
| 6520 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6521 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6522 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6523 | .type = ALC_FIXUP_VERBS, |
| 6524 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6525 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6526 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6527 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6528 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6529 | { } |
| 6530 | } |
| 6531 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6532 | [ALC861VD_FIX_DALLAS] = { |
| 6533 | .type = ALC_FIXUP_FUNC, |
| 6534 | .v.func = alc861vd_fixup_dallas, |
| 6535 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6536 | }; |
| 6537 | |
| 6538 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6539 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6540 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6541 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6542 | {} |
| 6543 | }; |
| 6544 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6545 | /* |
| 6546 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6547 | static int patch_alc861vd(struct hda_codec *codec) |
| 6548 | { |
| 6549 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6550 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6551 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6552 | err = alc_alloc_spec(codec, 0x0b); |
| 6553 | if (err < 0) |
| 6554 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6555 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6556 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6557 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6558 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6559 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6560 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6561 | /* automatic parse from the BIOS config */ |
| 6562 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6563 | if (err < 0) |
| 6564 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6565 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6566 | if (!spec->no_analog) { |
| 6567 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6568 | if (err < 0) |
| 6569 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6570 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6571 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6572 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6573 | codec->patch_ops = alc_patch_ops; |
| 6574 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6575 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6576 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6577 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6578 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6579 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6580 | |
| 6581 | error: |
| 6582 | alc_free(codec); |
| 6583 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6584 | } |
| 6585 | |
| 6586 | /* |
| 6587 | * ALC662 support |
| 6588 | * |
| 6589 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6590 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6591 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6592 | * 6-channel independent captures. |
| 6593 | * |
| 6594 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6595 | * driver yet). |
| 6596 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6597 | |
| 6598 | /* |
| 6599 | * BIOS auto configuration |
| 6600 | */ |
| 6601 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6602 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6603 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6604 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6605 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6606 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6607 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6608 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6609 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6610 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6611 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6612 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6613 | ssids = alc662_ssids; |
| 6614 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6615 | } |
| 6616 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6617 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6618 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6619 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6620 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6621 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6622 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6623 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6624 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6625 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6626 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6627 | printk(KERN_WARNING |
| 6628 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6629 | } |
| 6630 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6631 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6632 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6633 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6634 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6635 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6636 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6637 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6638 | ALC662_FIXUP_ASUS_MODE1, |
| 6639 | ALC662_FIXUP_ASUS_MODE2, |
| 6640 | ALC662_FIXUP_ASUS_MODE3, |
| 6641 | ALC662_FIXUP_ASUS_MODE4, |
| 6642 | ALC662_FIXUP_ASUS_MODE5, |
| 6643 | ALC662_FIXUP_ASUS_MODE6, |
| 6644 | ALC662_FIXUP_ASUS_MODE7, |
| 6645 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6646 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6647 | ALC662_FIXUP_ZOTAC_Z68, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6648 | ALC662_FIXUP_INV_DMIC, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6649 | }; |
| 6650 | |
| 6651 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6652 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6653 | .type = ALC_FIXUP_PINS, |
| 6654 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6655 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6656 | { } |
| 6657 | } |
| 6658 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6659 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6660 | .type = ALC_FIXUP_PINS, |
| 6661 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6662 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6663 | { } |
| 6664 | } |
| 6665 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6666 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6667 | .type = ALC_FIXUP_FUNC, |
| 6668 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6669 | }, |
| 6670 | [ALC662_FIXUP_CZC_P10T] = { |
| 6671 | .type = ALC_FIXUP_VERBS, |
| 6672 | .v.verbs = (const struct hda_verb[]) { |
| 6673 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6674 | {} |
| 6675 | } |
| 6676 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6677 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6678 | .type = ALC_FIXUP_FUNC, |
| 6679 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6680 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6681 | [ALC662_FIXUP_HP_RP5800] = { |
| 6682 | .type = ALC_FIXUP_PINS, |
| 6683 | .v.pins = (const struct alc_pincfg[]) { |
| 6684 | { 0x14, 0x0221201f }, /* HP out */ |
| 6685 | { } |
| 6686 | }, |
| 6687 | .chained = true, |
| 6688 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6689 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6690 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6691 | .type = ALC_FIXUP_PINS, |
| 6692 | .v.pins = (const struct alc_pincfg[]) { |
| 6693 | { 0x14, 0x99130110 }, /* speaker */ |
| 6694 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6695 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6696 | { 0x21, 0x0121401f }, /* HP out */ |
| 6697 | { } |
| 6698 | }, |
| 6699 | .chained = true, |
| 6700 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6701 | }, |
| 6702 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6703 | .type = ALC_FIXUP_PINS, |
| 6704 | .v.pins = (const struct alc_pincfg[]) { |
| 6705 | { 0x14, 0x99130110 }, /* speaker */ |
| 6706 | { 0x18, 0x01a19820 }, /* mic */ |
| 6707 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6708 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6709 | { } |
| 6710 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6711 | .chained = true, |
| 6712 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6713 | }, |
| 6714 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6715 | .type = ALC_FIXUP_PINS, |
| 6716 | .v.pins = (const struct alc_pincfg[]) { |
| 6717 | { 0x14, 0x99130110 }, /* speaker */ |
| 6718 | { 0x15, 0x0121441f }, /* HP */ |
| 6719 | { 0x18, 0x01a19840 }, /* mic */ |
| 6720 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6721 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6722 | { } |
| 6723 | }, |
| 6724 | .chained = true, |
| 6725 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6726 | }, |
| 6727 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6728 | .type = ALC_FIXUP_PINS, |
| 6729 | .v.pins = (const struct alc_pincfg[]) { |
| 6730 | { 0x14, 0x99130110 }, /* speaker */ |
| 6731 | { 0x16, 0x99130111 }, /* speaker */ |
| 6732 | { 0x18, 0x01a19840 }, /* mic */ |
| 6733 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6734 | { 0x21, 0x0121441f }, /* HP */ |
| 6735 | { } |
| 6736 | }, |
| 6737 | .chained = true, |
| 6738 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6739 | }, |
| 6740 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6741 | .type = ALC_FIXUP_PINS, |
| 6742 | .v.pins = (const struct alc_pincfg[]) { |
| 6743 | { 0x14, 0x99130110 }, /* speaker */ |
| 6744 | { 0x15, 0x0121441f }, /* HP */ |
| 6745 | { 0x16, 0x99130111 }, /* speaker */ |
| 6746 | { 0x18, 0x01a19840 }, /* mic */ |
| 6747 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6748 | { } |
| 6749 | }, |
| 6750 | .chained = true, |
| 6751 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6752 | }, |
| 6753 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 6754 | .type = ALC_FIXUP_PINS, |
| 6755 | .v.pins = (const struct alc_pincfg[]) { |
| 6756 | { 0x14, 0x99130110 }, /* speaker */ |
| 6757 | { 0x15, 0x01211420 }, /* HP2 */ |
| 6758 | { 0x18, 0x01a19840 }, /* mic */ |
| 6759 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6760 | { 0x1b, 0x0121441f }, /* HP */ |
| 6761 | { } |
| 6762 | }, |
| 6763 | .chained = true, |
| 6764 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6765 | }, |
| 6766 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 6767 | .type = ALC_FIXUP_PINS, |
| 6768 | .v.pins = (const struct alc_pincfg[]) { |
| 6769 | { 0x14, 0x99130110 }, /* speaker */ |
| 6770 | { 0x17, 0x99130111 }, /* speaker */ |
| 6771 | { 0x18, 0x01a19840 }, /* mic */ |
| 6772 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6773 | { 0x1b, 0x01214020 }, /* HP */ |
| 6774 | { 0x21, 0x0121401f }, /* HP */ |
| 6775 | { } |
| 6776 | }, |
| 6777 | .chained = true, |
| 6778 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6779 | }, |
| 6780 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 6781 | .type = ALC_FIXUP_PINS, |
| 6782 | .v.pins = (const struct alc_pincfg[]) { |
| 6783 | { 0x14, 0x99130110 }, /* speaker */ |
| 6784 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 6785 | { 0x15, 0x01214020 }, /* HP */ |
| 6786 | { 0x17, 0x99130111 }, /* speaker */ |
| 6787 | { 0x18, 0x01a19840 }, /* mic */ |
| 6788 | { 0x21, 0x0121401f }, /* HP */ |
| 6789 | { } |
| 6790 | }, |
| 6791 | .chained = true, |
| 6792 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6793 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6794 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 6795 | .type = ALC_FIXUP_FUNC, |
| 6796 | .v.func = alc_fixup_no_jack_detect, |
| 6797 | }, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6798 | [ALC662_FIXUP_ZOTAC_Z68] = { |
| 6799 | .type = ALC_FIXUP_PINS, |
| 6800 | .v.pins = (const struct alc_pincfg[]) { |
| 6801 | { 0x1b, 0x02214020 }, /* Front HP */ |
| 6802 | { } |
| 6803 | } |
| 6804 | }, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6805 | [ALC662_FIXUP_INV_DMIC] = { |
| 6806 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6807 | .v.func = alc_fixup_inv_dmic_0x12, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6808 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6809 | }; |
| 6810 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6811 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6812 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 6813 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6814 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6815 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6816 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6817 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6818 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6819 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 6820 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 6821 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6822 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6823 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6824 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6825 | |
| 6826 | #if 0 |
| 6827 | /* Below is a quirk table taken from the old code. |
| 6828 | * Basically the device should work as is without the fixup table. |
| 6829 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6830 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6831 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6832 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 6833 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 6834 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 6835 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 6836 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6837 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6838 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6839 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 6840 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 6841 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6842 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 6843 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 6844 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 6845 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 6846 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 6847 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6848 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 6849 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 6850 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6851 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6852 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6853 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6854 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 6855 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 6856 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 6857 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6858 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 6859 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6860 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6861 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 6862 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6863 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6864 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 6865 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 6866 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 6867 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 6868 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 6869 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 6870 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 6871 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6872 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 6873 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 6874 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6875 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 6876 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 6877 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 6878 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 6879 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 6880 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6881 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 6882 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6883 | {} |
| 6884 | }; |
| 6885 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6886 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 6887 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6888 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 6889 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 6890 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 6891 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 6892 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 6893 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 6894 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 6895 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6896 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6897 | {} |
| 6898 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6899 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 6900 | static void alc662_fill_coef(struct hda_codec *codec) |
| 6901 | { |
| 6902 | int val, coef; |
| 6903 | |
| 6904 | coef = alc_get_coef0(codec); |
| 6905 | |
| 6906 | switch (codec->vendor_id) { |
| 6907 | case 0x10ec0662: |
| 6908 | if ((coef & 0x00f0) == 0x0030) { |
| 6909 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ |
| 6910 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); |
| 6911 | } |
| 6912 | break; |
| 6913 | case 0x10ec0272: |
| 6914 | case 0x10ec0273: |
| 6915 | case 0x10ec0663: |
| 6916 | case 0x10ec0665: |
| 6917 | case 0x10ec0670: |
| 6918 | case 0x10ec0671: |
| 6919 | case 0x10ec0672: |
| 6920 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ |
| 6921 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6922 | break; |
| 6923 | } |
| 6924 | } |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6925 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6926 | /* |
| 6927 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6928 | static int patch_alc662(struct hda_codec *codec) |
| 6929 | { |
| 6930 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6931 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6932 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6933 | err = alc_alloc_spec(codec, 0x0b); |
| 6934 | if (err < 0) |
| 6935 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6936 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6937 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 6938 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6939 | /* handle multiple HPs as is */ |
| 6940 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 6941 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 6942 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 6943 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 6944 | spec->init_hook = alc662_fill_coef; |
| 6945 | alc662_fill_coef(codec); |
| 6946 | |
Takashi Iwai | 8e5a050 | 2012-06-21 15:49:33 +0200 | [diff] [blame] | 6947 | alc_pick_fixup(codec, alc662_fixup_models, |
| 6948 | alc662_fixup_tbl, alc662_fixups); |
| 6949 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6950 | |
| 6951 | alc_auto_parse_customize_define(codec); |
| 6952 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6953 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6954 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 6955 | spec->cdefine.platform_type == 1) { |
| 6956 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 6957 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6958 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 6959 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 6960 | /* automatic parse from the BIOS config */ |
| 6961 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6962 | if (err < 0) |
| 6963 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6964 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6965 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6966 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6967 | if (err < 0) |
| 6968 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 6969 | switch (codec->vendor_id) { |
| 6970 | case 0x10ec0662: |
| 6971 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6972 | break; |
| 6973 | case 0x10ec0272: |
| 6974 | case 0x10ec0663: |
| 6975 | case 0x10ec0665: |
| 6976 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 6977 | break; |
| 6978 | case 0x10ec0273: |
| 6979 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 6980 | break; |
| 6981 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 6982 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 6983 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6984 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 6985 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6986 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6987 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6988 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6989 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6990 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6991 | error: |
| 6992 | alc_free(codec); |
| 6993 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 6994 | } |
| 6995 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6996 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6997 | * ALC680 support |
| 6998 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 6999 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7000 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 7001 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7002 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7003 | } |
| 7004 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7005 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7006 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7007 | static int patch_alc680(struct hda_codec *codec) |
| 7008 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7009 | int err; |
| 7010 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7011 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7012 | err = alc_alloc_spec(codec, 0); |
| 7013 | if (err < 0) |
| 7014 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7015 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 7016 | /* automatic parse from the BIOS config */ |
| 7017 | err = alc680_parse_auto_config(codec); |
| 7018 | if (err < 0) { |
| 7019 | alc_free(codec); |
| 7020 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7021 | } |
| 7022 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7023 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7024 | |
| 7025 | return 0; |
| 7026 | } |
| 7027 | |
| 7028 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7029 | * patch entries |
| 7030 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7031 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7032 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7033 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7034 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7035 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 7036 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7037 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7038 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 7039 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7040 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7041 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
David Henningsson | befae82 | 2012-06-25 19:49:28 +0200 | [diff] [blame] | 7042 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
David Henningsson | 4e01ec6 | 2012-07-18 07:38:46 +0200 | [diff] [blame] | 7043 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7044 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7045 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7046 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 7047 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 7048 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7049 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7050 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7051 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 7052 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 7053 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 7054 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 7055 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7056 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7057 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7058 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7059 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7060 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7061 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 7062 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7063 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 7064 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7065 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7066 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7067 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 7068 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7069 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7070 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7071 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7072 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7073 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7074 | {} /* terminator */ |
| 7075 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7076 | |
| 7077 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7078 | |
| 7079 | MODULE_LICENSE("GPL"); |
| 7080 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7081 | |
| 7082 | static struct hda_codec_preset_list realtek_list = { |
| 7083 | .preset = snd_hda_preset_realtek, |
| 7084 | .owner = THIS_MODULE, |
| 7085 | }; |
| 7086 | |
| 7087 | static int __init patch_realtek_init(void) |
| 7088 | { |
| 7089 | return snd_hda_add_codec_preset(&realtek_list); |
| 7090 | } |
| 7091 | |
| 7092 | static void __exit patch_realtek_exit(void) |
| 7093 | { |
| 7094 | snd_hda_delete_codec_preset(&realtek_list); |
| 7095 | } |
| 7096 | |
| 7097 | module_init(patch_realtek_init) |
| 7098 | module_exit(patch_realtek_exit) |