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 | c14c95f | 2012-02-16 16:38:07 +0100 | [diff] [blame] | 76 | #define MAX_VOL_NIDS 0x40 |
| 77 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 78 | /* make compatible with old code */ |
| 79 | #define alc_apply_pincfgs snd_hda_apply_pincfgs |
| 80 | #define alc_apply_fixup snd_hda_apply_fixup |
| 81 | #define alc_pick_fixup snd_hda_pick_fixup |
| 82 | #define alc_fixup hda_fixup |
| 83 | #define alc_pincfg hda_pintbl |
| 84 | #define alc_model_fixup hda_model_fixup |
| 85 | |
| 86 | #define ALC_FIXUP_PINS HDA_FIXUP_PINS |
| 87 | #define ALC_FIXUP_VERBS HDA_FIXUP_VERBS |
| 88 | #define ALC_FIXUP_FUNC HDA_FIXUP_FUNC |
| 89 | |
| 90 | #define ALC_FIXUP_ACT_PRE_PROBE HDA_FIXUP_ACT_PRE_PROBE |
| 91 | #define ALC_FIXUP_ACT_PROBE HDA_FIXUP_ACT_PROBE |
| 92 | #define ALC_FIXUP_ACT_INIT HDA_FIXUP_ACT_INIT |
| 93 | #define ALC_FIXUP_ACT_BUILD HDA_FIXUP_ACT_BUILD |
| 94 | |
| 95 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 96 | #define MAX_NID_PATH_DEPTH 5 |
| 97 | |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 98 | enum { |
| 99 | NID_PATH_VOL_CTL, |
| 100 | NID_PATH_MUTE_CTL, |
| 101 | NID_PATH_BOOST_CTL, |
| 102 | NID_PATH_NUM_CTLS |
| 103 | }; |
| 104 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 105 | /* Widget connection path |
| 106 | * |
| 107 | * For output, stored in the order of DAC -> ... -> pin, |
| 108 | * for input, pin -> ... -> ADC. |
| 109 | * |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 110 | * idx[i] contains the source index number to select on of the widget path[i]; |
| 111 | * e.g. idx[1] is the index of the DAC (path[0]) selected by path[1] widget |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 112 | * multi[] indicates whether it's a selector widget with multi-connectors |
| 113 | * (i.e. the connection selection is mandatory) |
| 114 | * vol_ctl and mute_ctl contains the NIDs for the assigned mixers |
| 115 | */ |
| 116 | struct nid_path { |
| 117 | int depth; |
| 118 | hda_nid_t path[MAX_NID_PATH_DEPTH]; |
| 119 | unsigned char idx[MAX_NID_PATH_DEPTH]; |
| 120 | unsigned char multi[MAX_NID_PATH_DEPTH]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 121 | unsigned int ctls[NID_PATH_NUM_CTLS]; /* NID_PATH_XXX_CTL */ |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 122 | bool active; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 123 | }; |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | struct alc_spec { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 126 | struct hda_gen_spec gen; |
| 127 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | /* codec parameterization */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 129 | const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | unsigned int num_mixers; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 131 | unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 133 | char stream_name_analog[32]; /* analog PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 134 | const struct hda_pcm_stream *stream_analog_playback; |
| 135 | const struct hda_pcm_stream *stream_analog_capture; |
| 136 | const struct hda_pcm_stream *stream_analog_alt_playback; |
| 137 | const struct hda_pcm_stream *stream_analog_alt_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
Takashi Iwai | aa563af | 2009-07-31 10:05:11 +0200 | [diff] [blame] | 139 | char stream_name_digital[32]; /* digital PCM stream */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 140 | const struct hda_pcm_stream *stream_digital_playback; |
| 141 | const struct hda_pcm_stream *stream_digital_capture; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | /* playback */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 144 | struct hda_multi_out multiout; /* playback set-up |
| 145 | * max_channels, dacs must be set |
| 146 | * dig_out_nid and hp_nid are optional |
| 147 | */ |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 148 | hda_nid_t alt_dac_nid; |
Takashi Iwai | 6a05ac4 | 2009-02-13 11:19:09 +0100 | [diff] [blame] | 149 | hda_nid_t slave_dig_outs[3]; /* optional - for auto-parsing */ |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 150 | int dig_out_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | |
| 152 | /* capture */ |
| 153 | unsigned int num_adc_nids; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 154 | hda_nid_t adc_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 155 | hda_nid_t dig_in_nid; /* digital-in NID; optional */ |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 156 | hda_nid_t mixer_nid; /* analog-mixer NID */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 158 | /* capture setup for dynamic dual-adc switch */ |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 159 | hda_nid_t cur_adc; |
| 160 | unsigned int cur_adc_stream_tag; |
| 161 | unsigned int cur_adc_format; |
| 162 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | /* capture source */ |
Jonathan Woithe | a1e8d2d | 2006-03-28 12:47:09 +0200 | [diff] [blame] | 164 | unsigned int num_mux_defs; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 165 | struct hda_input_mux input_mux; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | unsigned int cur_mux[3]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 167 | hda_nid_t ext_mic_pin; |
| 168 | hda_nid_t dock_mic_pin; |
| 169 | hda_nid_t int_mic_pin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
| 171 | /* channel model */ |
Takashi Iwai | d2a6d7d | 2005-11-17 11:06:29 +0100 | [diff] [blame] | 172 | const struct hda_channel_mode *channel_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | int num_channel_mode; |
Takashi Iwai | 4e195a7 | 2006-07-28 14:47:34 +0200 | [diff] [blame] | 174 | int need_dac_fix; |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 175 | int const_channel_count; /* min. channel count (for speakers) */ |
| 176 | int ext_channel_count; /* current channel count for multi-io */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | |
| 178 | /* PCM information */ |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 179 | struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */ |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 180 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 181 | /* dynamic controls, init_verbs and input_mux */ |
| 182 | struct auto_pin_cfg autocfg; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 183 | struct alc_customize_define cdefine; |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 184 | struct snd_array kctls; |
Takashi Iwai | 41923e4 | 2007-10-22 17:20:10 +0200 | [diff] [blame] | 185 | hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 186 | hda_nid_t imux_pins[HDA_MAX_NUM_INPUTS]; |
| 187 | unsigned int dyn_adc_idx[HDA_MAX_NUM_INPUTS]; |
| 188 | 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] | 189 | hda_nid_t inv_dmic_pin; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame^] | 190 | hda_nid_t shared_mic_vref_pin; |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 191 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 192 | /* DAC list */ |
| 193 | int num_all_dacs; |
| 194 | hda_nid_t all_dacs[16]; |
| 195 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 196 | /* path list */ |
| 197 | struct snd_array paths; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 198 | |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 199 | /* hooks */ |
| 200 | void (*init_hook)(struct hda_codec *codec); |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 201 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 202 | void (*power_hook)(struct hda_codec *codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 203 | #endif |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 204 | void (*shutup)(struct hda_codec *codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 205 | void (*automute_hook)(struct hda_codec *codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 206 | |
Takashi Iwai | 834be88 | 2006-03-01 14:16:17 +0100 | [diff] [blame] | 207 | /* for pin sensing */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 208 | unsigned int hp_jack_present:1; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 209 | unsigned int line_jack_present:1; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 210 | unsigned int master_mute:1; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 211 | unsigned int auto_mic:1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 212 | unsigned int auto_mic_valid_imux:1; /* valid imux for auto-mic */ |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 213 | unsigned int automute_speaker:1; /* automute speaker outputs */ |
| 214 | unsigned int automute_lo:1; /* automute LO outputs */ |
| 215 | unsigned int detect_hp:1; /* Headphone detection enabled */ |
| 216 | unsigned int detect_lo:1; /* Line-out detection enabled */ |
| 217 | unsigned int automute_speaker_possible:1; /* there are speakers and either LO or HP */ |
| 218 | unsigned int automute_lo_possible:1; /* there are line outs and HP */ |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 219 | 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] | 220 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 221 | /* other flags */ |
| 222 | unsigned int no_analog :1; /* digital I/O only */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 223 | unsigned int dyn_adc_switch:1; /* switch ADCs (for ALC275) */ |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 224 | unsigned int single_input_src:1; |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 225 | 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] | 226 | unsigned int parse_flags; /* passed to snd_hda_parse_pin_defcfg() */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 227 | unsigned int shared_mic_hp:1; /* HP/Mic-in sharing */ |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 228 | unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */ |
| 229 | 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] | 230 | 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] | 231 | |
| 232 | /* auto-mute control */ |
| 233 | int automute_mode; |
Takashi Iwai | 3b8510c | 2011-04-28 14:03:24 +0200 | [diff] [blame] | 234 | hda_nid_t automute_mixer_nid[AUTO_CFG_MAX_OUTS]; |
Takashi Iwai | d922b51 | 2011-04-28 12:18:53 +0200 | [diff] [blame] | 235 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 236 | int init_amp; |
Takashi Iwai | d433a67 | 2010-09-20 15:11:54 +0200 | [diff] [blame] | 237 | int codec_variant; /* flag for other variants */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 238 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 239 | /* for virtual master */ |
| 240 | hda_nid_t vmaster_nid; |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 241 | struct hda_vmaster_mute_hook vmaster_mute; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 242 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 243 | struct hda_loopback_check loopback; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 244 | int num_loopbacks; |
| 245 | struct hda_amp_list loopback_list[8]; |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 246 | #endif |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 247 | |
| 248 | /* for PLL fix */ |
| 249 | hda_nid_t pll_nid; |
| 250 | unsigned int pll_coef_idx, pll_coef_bit; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 251 | unsigned int coef0; |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 252 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 253 | /* multi-io */ |
| 254 | int multi_ios; |
| 255 | struct alc_multi_io multi_io[4]; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 256 | |
| 257 | /* bind volumes */ |
| 258 | struct snd_array bind_ctls; |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 259 | }; |
| 260 | |
Takashi Iwai | 44c0240 | 2011-07-08 15:14:19 +0200 | [diff] [blame] | 261 | static bool check_amp_caps(struct hda_codec *codec, hda_nid_t nid, |
| 262 | int dir, unsigned int bits) |
| 263 | { |
| 264 | if (!nid) |
| 265 | return false; |
| 266 | if (get_wcaps(codec, nid) & (1 << (dir + 1))) |
| 267 | if (query_amp_caps(codec, nid, dir) & bits) |
| 268 | return true; |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | #define nid_has_mute(codec, nid, dir) \ |
| 273 | check_amp_caps(codec, nid, dir, AC_AMPCAP_MUTE) |
| 274 | #define nid_has_volume(codec, nid, dir) \ |
| 275 | check_amp_caps(codec, nid, dir, AC_AMPCAP_NUM_STEPS) |
| 276 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 277 | static struct nid_path * |
| 278 | get_nid_path(struct hda_codec *codec, hda_nid_t from_nid, hda_nid_t to_nid); |
| 279 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
| 280 | bool enable, bool add_aamix); |
| 281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | /* |
| 283 | * input MUX handling |
| 284 | */ |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 285 | static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, |
| 286 | struct snd_ctl_elem_info *uinfo) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | { |
| 288 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 289 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 290 | return snd_hda_input_mux_info(&spec->input_mux, uinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | } |
| 292 | |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 293 | static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, |
| 294 | struct snd_ctl_elem_value *ucontrol) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | { |
| 296 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 297 | struct alc_spec *spec = codec->spec; |
| 298 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 299 | |
| 300 | ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx]; |
| 301 | return 0; |
| 302 | } |
| 303 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 304 | static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx) |
| 305 | { |
| 306 | struct alc_spec *spec = codec->spec; |
| 307 | if (spec->dyn_adc_switch) |
| 308 | adc_idx = spec->dyn_adc_idx[imux_idx]; |
| 309 | return spec->adc_nids[adc_idx]; |
| 310 | } |
| 311 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 312 | 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] | 313 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 314 | struct alc_spec *spec = codec->spec; |
| 315 | hda_nid_t new_adc = spec->adc_nids[spec->dyn_adc_idx[cur]]; |
| 316 | |
| 317 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
| 318 | /* stream is running, let's swap the current ADC */ |
| 319 | __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); |
| 320 | spec->cur_adc = new_adc; |
| 321 | snd_hda_codec_setup_stream(codec, new_adc, |
| 322 | spec->cur_adc_stream_tag, 0, |
| 323 | spec->cur_adc_format); |
| 324 | return true; |
| 325 | } |
| 326 | return false; |
| 327 | } |
| 328 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 329 | static void call_update_outputs(struct hda_codec *codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 330 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 331 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 332 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 333 | /* for shared I/O, change the pin-control accordingly */ |
| 334 | static void update_shared_mic_hp(struct hda_codec *codec, bool set_as_mic) |
| 335 | { |
| 336 | struct alc_spec *spec = codec->spec; |
| 337 | unsigned int val; |
| 338 | hda_nid_t pin = spec->autocfg.inputs[1].pin; |
| 339 | /* NOTE: this assumes that there are only two inputs, the |
| 340 | * first is the real internal mic and the second is HP/mic jack. |
| 341 | */ |
| 342 | |
| 343 | val = snd_hda_get_default_vref(codec, pin); |
| 344 | |
| 345 | /* This pin does not have vref caps - let's enable vref on pin 0x18 |
| 346 | instead, as suggested by Realtek */ |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame^] | 347 | if (val == AC_PINCTL_VREF_HIZ && spec->shared_mic_vref_pin) { |
| 348 | const hda_nid_t vref_pin = spec->shared_mic_vref_pin; |
| 349 | unsigned int vref_val = snd_hda_get_default_vref(codec, vref_pin); |
| 350 | if (vref_val != AC_PINCTL_VREF_HIZ) |
| 351 | snd_hda_set_pin_ctl(codec, vref_pin, PIN_IN | (set_as_mic ? vref_val : 0)); |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | val = set_as_mic ? val | PIN_IN : PIN_HP; |
| 355 | snd_hda_set_pin_ctl(codec, pin, val); |
| 356 | |
| 357 | spec->automute_speaker = !set_as_mic; |
| 358 | call_update_outputs(codec); |
| 359 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 360 | |
| 361 | /* select the given imux item; either unmute exclusively or select the route */ |
| 362 | static int alc_mux_select(struct hda_codec *codec, unsigned int adc_idx, |
| 363 | unsigned int idx, bool force) |
| 364 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 366 | const struct hda_input_mux *imux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 367 | struct nid_path *path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 369 | imux = &spec->input_mux; |
| 370 | if (!imux->num_items) |
Takashi Iwai | cce4aa3 | 2011-12-02 15:29:12 +0100 | [diff] [blame] | 371 | return 0; |
Takashi Iwai | cd896c3 | 2008-11-18 12:36:33 +0100 | [diff] [blame] | 372 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 373 | if (idx >= imux->num_items) |
| 374 | idx = imux->num_items - 1; |
| 375 | if (spec->cur_mux[adc_idx] == idx && !force) |
| 376 | return 0; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 377 | |
| 378 | path = get_nid_path(codec, spec->imux_pins[spec->cur_mux[adc_idx]], |
| 379 | spec->adc_nids[adc_idx]); |
| 380 | if (!path) |
| 381 | return 0; |
| 382 | if (path->active) |
| 383 | activate_path(codec, path, false, false); |
| 384 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 385 | spec->cur_mux[adc_idx] = idx; |
| 386 | |
David Henningsson | 00227f1 | 2012-06-27 18:45:44 +0200 | [diff] [blame] | 387 | if (spec->shared_mic_hp) |
| 388 | update_shared_mic_hp(codec, spec->cur_mux[adc_idx]); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 389 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 390 | if (spec->dyn_adc_switch) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 391 | alc_dyn_adc_pcm_resetup(codec, idx); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 392 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 393 | path = get_nid_path(codec, spec->imux_pins[idx], |
| 394 | get_adc_nid(codec, adc_idx, idx)); |
| 395 | if (!path) |
| 396 | return 0; |
| 397 | if (path->active) |
| 398 | return 0; |
| 399 | activate_path(codec, path, true, false); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 400 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 401 | return 1; |
| 402 | } |
| 403 | |
| 404 | static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, |
| 405 | struct snd_ctl_elem_value *ucontrol) |
| 406 | { |
| 407 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 408 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
| 409 | return alc_mux_select(codec, adc_idx, |
| 410 | ucontrol->value.enumerated.item[0], false); |
Takashi Iwai | 54cbc9a | 2008-10-31 15:24:04 +0100 | [diff] [blame] | 411 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 412 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | /* |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 414 | * set up the input pin config (depending on the given auto-pin type) |
| 415 | */ |
| 416 | static void alc_set_input_pin(struct hda_codec *codec, hda_nid_t nid, |
| 417 | int auto_pin_type) |
| 418 | { |
| 419 | unsigned int val = PIN_IN; |
Takashi Iwai | 4740860 | 2012-04-20 13:06:53 +0200 | [diff] [blame] | 420 | if (auto_pin_type == AUTO_PIN_MIC) |
| 421 | val |= snd_hda_get_default_vref(codec, nid); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 422 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | 23f0c04 | 2009-02-26 13:03:58 +0100 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 426 | * Append the given mixer and verb elements for the later use |
| 427 | * The mixer array is referred in build_controls(), and init_verbs are |
| 428 | * called in init(). |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 429 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 430 | 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] | 431 | { |
| 432 | if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers))) |
| 433 | return; |
| 434 | spec->mixers[spec->num_mixers++] = mix; |
| 435 | } |
| 436 | |
Takashi Iwai | d88897e | 2008-10-31 15:01:37 +0100 | [diff] [blame] | 437 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 438 | * GPIO setup tables, used in initialization |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 439 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 440 | /* Enable GPIO mask and set output */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 441 | static const struct hda_verb alc_gpio1_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 442 | {0x01, AC_VERB_SET_GPIO_MASK, 0x01}, |
| 443 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 444 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 445 | { } |
| 446 | }; |
| 447 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 448 | static const struct hda_verb alc_gpio2_init_verbs[] = { |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 449 | {0x01, AC_VERB_SET_GPIO_MASK, 0x02}, |
| 450 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02}, |
| 451 | {0x01, AC_VERB_SET_GPIO_DATA, 0x02}, |
| 452 | { } |
| 453 | }; |
| 454 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 455 | static const struct hda_verb alc_gpio3_init_verbs[] = { |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 456 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 457 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03}, |
| 458 | {0x01, AC_VERB_SET_GPIO_DATA, 0x03}, |
| 459 | { } |
| 460 | }; |
| 461 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 462 | /* |
| 463 | * Fix hardware PLL issue |
| 464 | * On some codecs, the analog PLL gating control must be off while |
| 465 | * the default value is 1. |
| 466 | */ |
| 467 | static void alc_fix_pll(struct hda_codec *codec) |
| 468 | { |
| 469 | struct alc_spec *spec = codec->spec; |
| 470 | unsigned int val; |
| 471 | |
| 472 | if (!spec->pll_nid) |
| 473 | return; |
| 474 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 475 | spec->pll_coef_idx); |
| 476 | val = snd_hda_codec_read(codec, spec->pll_nid, 0, |
| 477 | AC_VERB_GET_PROC_COEF, 0); |
| 478 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX, |
| 479 | spec->pll_coef_idx); |
| 480 | snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF, |
| 481 | val & ~(1 << spec->pll_coef_bit)); |
| 482 | } |
| 483 | |
| 484 | static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid, |
| 485 | unsigned int coef_idx, unsigned int coef_bit) |
| 486 | { |
| 487 | struct alc_spec *spec = codec->spec; |
| 488 | spec->pll_nid = nid; |
| 489 | spec->pll_coef_idx = coef_idx; |
| 490 | spec->pll_coef_bit = coef_bit; |
| 491 | alc_fix_pll(codec); |
| 492 | } |
| 493 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 494 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 495 | * Jack detections for HP auto-mute and mic-switch |
| 496 | */ |
| 497 | |
| 498 | /* check each pin in the given array; returns true if any of them is plugged */ |
| 499 | 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] | 500 | { |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 501 | int i, present = 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 502 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 503 | for (i = 0; i < num_pins; i++) { |
| 504 | hda_nid_t nid = pins[i]; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 505 | if (!nid) |
| 506 | break; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 507 | present |= snd_hda_jack_detect(codec, nid); |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 508 | } |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 509 | return present; |
| 510 | } |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 511 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 512 | /* standard HP/line-out auto-mute helper */ |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 513 | 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] | 514 | bool mute, bool hp_out) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 515 | { |
| 516 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e942796 | 2011-04-28 15:46:07 +0200 | [diff] [blame] | 517 | unsigned int pin_bits = mute ? 0 : (hp_out ? PIN_HP : PIN_OUT); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 518 | int i; |
| 519 | |
| 520 | for (i = 0; i < num_pins; i++) { |
| 521 | hda_nid_t nid = pins[i]; |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 522 | unsigned int val; |
Takashi Iwai | a9fd4f3f | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 523 | if (!nid) |
| 524 | break; |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 525 | /* don't reset VREF value in case it's controlling |
| 526 | * the amp (see alc861_fixup_asus_amp_vref_0f()) |
| 527 | */ |
| 528 | if (spec->keep_vref_in_automute) { |
| 529 | val = snd_hda_codec_read(codec, nid, 0, |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 530 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | b8a47c7 | 2012-12-14 14:20:34 +0100 | [diff] [blame] | 531 | val &= ~PIN_HP; |
| 532 | } else |
| 533 | val = 0; |
| 534 | val |= pin_bits; |
| 535 | snd_hda_set_pin_ctl(codec, nid, val); |
Takashi Iwai | a9fd4f3f | 2009-05-08 15:57:59 +0200 | [diff] [blame] | 536 | } |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 537 | } |
| 538 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 539 | /* Toggle outputs muting */ |
| 540 | static void update_outputs(struct hda_codec *codec) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 541 | { |
| 542 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 543 | int on; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 544 | |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 545 | /* Control HP pins/amps depending on master_mute state; |
| 546 | * in general, HP pins/amps control should be enabled in all cases, |
| 547 | * but currently set only for master_mute, just to be safe |
| 548 | */ |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 549 | if (!spec->shared_mic_hp) /* don't change HP-pin when shared with mic */ |
| 550 | do_automute(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
Takashi Iwai | c0a2026 | 2011-06-10 15:28:15 +0200 | [diff] [blame] | 551 | spec->autocfg.hp_pins, spec->master_mute, true); |
| 552 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 553 | if (!spec->automute_speaker) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 554 | on = 0; |
| 555 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 556 | on = spec->hp_jack_present | spec->line_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 557 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 558 | do_automute(codec, ARRAY_SIZE(spec->autocfg.speaker_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 559 | spec->autocfg.speaker_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 560 | |
| 561 | /* toggle line-out mutes if needed, too */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 562 | /* if LO is a copy of either HP or Speaker, don't need to handle it */ |
| 563 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0] || |
| 564 | spec->autocfg.line_out_pins[0] == spec->autocfg.speaker_pins[0]) |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 565 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 566 | if (!spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 567 | on = 0; |
| 568 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 569 | on = spec->hp_jack_present; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 570 | on |= spec->master_mute; |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 571 | do_automute(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 572 | spec->autocfg.line_out_pins, on, false); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 573 | } |
| 574 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 575 | static void call_update_outputs(struct hda_codec *codec) |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 576 | { |
| 577 | struct alc_spec *spec = codec->spec; |
| 578 | if (spec->automute_hook) |
| 579 | spec->automute_hook(codec); |
| 580 | else |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 581 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 582 | } |
| 583 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 584 | /* standard HP-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 585 | 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] | 586 | { |
| 587 | struct alc_spec *spec = codec->spec; |
| 588 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 589 | spec->hp_jack_present = |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 590 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.hp_pins), |
| 591 | spec->autocfg.hp_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 592 | if (!spec->detect_hp || (!spec->automute_speaker && !spec->automute_lo)) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 593 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 594 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 595 | } |
| 596 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 597 | /* standard line-out-automute helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 598 | 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] | 599 | { |
| 600 | struct alc_spec *spec = codec->spec; |
| 601 | |
David Henningsson | f7f4b232 | 2012-10-10 16:32:09 +0200 | [diff] [blame] | 602 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 603 | return; |
Takashi Iwai | e0d32e3 | 2011-09-26 15:19:55 +0200 | [diff] [blame] | 604 | /* check LO jack only when it's different from HP */ |
| 605 | if (spec->autocfg.line_out_pins[0] == spec->autocfg.hp_pins[0]) |
| 606 | return; |
| 607 | |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 608 | spec->line_jack_present = |
| 609 | detect_jacks(codec, ARRAY_SIZE(spec->autocfg.line_out_pins), |
| 610 | spec->autocfg.line_out_pins); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 611 | if (!spec->automute_speaker || !spec->detect_lo) |
Takashi Iwai | 3c715a9 | 2011-08-23 12:41:09 +0200 | [diff] [blame] | 612 | return; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 613 | call_update_outputs(codec); |
Takashi Iwai | e6a5e1b | 2011-04-28 14:41:52 +0200 | [diff] [blame] | 614 | } |
| 615 | |
Takashi Iwai | 8d087c7 | 2011-06-28 12:45:47 +0200 | [diff] [blame] | 616 | #define get_connection_index(codec, mux, nid) \ |
| 617 | snd_hda_get_conn_index(codec, mux, nid, 0) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 618 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 619 | /* standard mic auto-switch helper */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 620 | 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] | 621 | { |
| 622 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 623 | hda_nid_t *pins = spec->imux_pins; |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 624 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 625 | if (!spec->auto_mic || !spec->auto_mic_valid_imux) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 626 | return; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 627 | 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] | 628 | return; |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 629 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 630 | if (snd_hda_jack_detect(codec, pins[spec->ext_mic_idx])) |
| 631 | alc_mux_select(codec, 0, spec->ext_mic_idx, false); |
| 632 | else if (spec->dock_mic_idx >= 0 && |
| 633 | snd_hda_jack_detect(codec, pins[spec->dock_mic_idx])) |
| 634 | alc_mux_select(codec, 0, spec->dock_mic_idx, false); |
| 635 | else |
| 636 | alc_mux_select(codec, 0, spec->int_mic_idx, false); |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 637 | } |
| 638 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 639 | /* update the master volume per volume-knob's unsol event */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 640 | 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] | 641 | { |
| 642 | unsigned int val; |
| 643 | struct snd_kcontrol *kctl; |
| 644 | struct snd_ctl_elem_value *uctl; |
| 645 | |
| 646 | kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume"); |
| 647 | if (!kctl) |
| 648 | return; |
| 649 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
| 650 | if (!uctl) |
| 651 | return; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 652 | val = snd_hda_codec_read(codec, jack->nid, 0, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 653 | AC_VERB_GET_VOLUME_KNOB_CONTROL, 0); |
| 654 | val &= HDA_AMP_VOLMASK; |
| 655 | uctl->value.integer.value[0] = val; |
| 656 | uctl->value.integer.value[1] = val; |
| 657 | kctl->put(kctl, uctl); |
| 658 | kfree(uctl); |
| 659 | } |
| 660 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 661 | static void alc880_unsol_event(struct hda_codec *codec, unsigned int res) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 662 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 663 | /* For some reason, the res given from ALC880 is broken. |
| 664 | Here we adjust it properly. */ |
| 665 | snd_hda_jack_unsol_event(codec, res >> 2); |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 666 | } |
| 667 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 668 | /* call init functions of standard auto-mute helpers */ |
Kailang Yang | 7fb0d78 | 2008-10-15 11:12:35 +0200 | [diff] [blame] | 669 | static void alc_inithook(struct hda_codec *codec) |
| 670 | { |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 671 | alc_hp_automute(codec, NULL); |
| 672 | alc_line_automute(codec, NULL); |
| 673 | alc_mic_automute(codec, NULL); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 674 | } |
| 675 | |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 676 | /* additional initialization for ALC888 variants */ |
| 677 | static void alc888_coef_init(struct hda_codec *codec) |
| 678 | { |
| 679 | unsigned int tmp; |
| 680 | |
| 681 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0); |
| 682 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 683 | 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] | 684 | if ((tmp & 0xf0) == 0x20) |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 685 | /* alc888S-VC */ |
| 686 | snd_hda_codec_read(codec, 0x20, 0, |
| 687 | AC_VERB_SET_PROC_COEF, 0x830); |
| 688 | else |
| 689 | /* alc888-VB */ |
| 690 | snd_hda_codec_read(codec, 0x20, 0, |
| 691 | AC_VERB_SET_PROC_COEF, 0x3030); |
| 692 | } |
| 693 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 694 | /* additional initialization for ALC889 variants */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 695 | static void alc889_coef_init(struct hda_codec *codec) |
| 696 | { |
| 697 | unsigned int tmp; |
| 698 | |
| 699 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 700 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 701 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 702 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010); |
| 703 | } |
| 704 | |
Takashi Iwai | 3fb4a50 | 2010-01-19 15:46:37 +0100 | [diff] [blame] | 705 | /* turn on/off EAPD control (only if available) */ |
| 706 | static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on) |
| 707 | { |
| 708 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN) |
| 709 | return; |
| 710 | if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD) |
| 711 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE, |
| 712 | on ? 2 : 0); |
| 713 | } |
| 714 | |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 715 | /* turn on/off EAPD controls of the codec */ |
| 716 | static void alc_auto_setup_eapd(struct hda_codec *codec, bool on) |
| 717 | { |
| 718 | /* We currently only handle front, HP */ |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 719 | static hda_nid_t pins[] = { |
| 720 | 0x0f, 0x10, 0x14, 0x15, 0 |
| 721 | }; |
| 722 | hda_nid_t *p; |
| 723 | for (p = pins; *p; p++) |
| 724 | set_eapd(codec, *p, on); |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 725 | } |
| 726 | |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 727 | /* generic shutup callback; |
| 728 | * just turning off EPAD and a little pause for avoiding pop-noise |
| 729 | */ |
| 730 | static void alc_eapd_shutup(struct hda_codec *codec) |
| 731 | { |
| 732 | alc_auto_setup_eapd(codec, false); |
| 733 | msleep(200); |
| 734 | } |
| 735 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 736 | /* generic EAPD initialization */ |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 737 | static void alc_auto_init_amp(struct hda_codec *codec, int type) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 738 | { |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 739 | unsigned int tmp; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 740 | |
Takashi Iwai | 39fa84e | 2011-06-27 15:28:57 +0200 | [diff] [blame] | 741 | alc_auto_setup_eapd(codec, true); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 742 | switch (type) { |
| 743 | case ALC_INIT_GPIO1: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 744 | snd_hda_sequence_write(codec, alc_gpio1_init_verbs); |
| 745 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 746 | case ALC_INIT_GPIO2: |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 747 | snd_hda_sequence_write(codec, alc_gpio2_init_verbs); |
| 748 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 749 | case ALC_INIT_GPIO3: |
Kailang Yang | bdd148a | 2007-05-08 15:19:08 +0200 | [diff] [blame] | 750 | snd_hda_sequence_write(codec, alc_gpio3_init_verbs); |
| 751 | break; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 752 | case ALC_INIT_DEFAULT: |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 753 | switch (codec->vendor_id) { |
| 754 | case 0x10ec0260: |
| 755 | snd_hda_codec_write(codec, 0x1a, 0, |
| 756 | AC_VERB_SET_COEF_INDEX, 7); |
| 757 | tmp = snd_hda_codec_read(codec, 0x1a, 0, |
| 758 | AC_VERB_GET_PROC_COEF, 0); |
| 759 | snd_hda_codec_write(codec, 0x1a, 0, |
| 760 | AC_VERB_SET_COEF_INDEX, 7); |
| 761 | snd_hda_codec_write(codec, 0x1a, 0, |
| 762 | AC_VERB_SET_PROC_COEF, |
| 763 | tmp | 0x2010); |
| 764 | break; |
| 765 | case 0x10ec0262: |
| 766 | case 0x10ec0880: |
| 767 | case 0x10ec0882: |
| 768 | case 0x10ec0883: |
| 769 | case 0x10ec0885: |
Takashi Iwai | 4a5a4c5 | 2009-02-06 12:46:59 +0100 | [diff] [blame] | 770 | case 0x10ec0887: |
Takashi Iwai | 20b67dd | 2011-03-23 22:54:32 +0100 | [diff] [blame] | 771 | /*case 0x10ec0889:*/ /* this causes an SPDIF problem */ |
Jaroslav Kysela | 87a8c37 | 2009-07-23 10:58:29 +0200 | [diff] [blame] | 772 | alc889_coef_init(codec); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 773 | break; |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 774 | case 0x10ec0888: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 775 | alc888_coef_init(codec); |
Kailang Yang | f9423e7 | 2008-05-27 12:32:25 +0200 | [diff] [blame] | 776 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 777 | #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] | 778 | case 0x10ec0267: |
| 779 | case 0x10ec0268: |
| 780 | snd_hda_codec_write(codec, 0x20, 0, |
| 781 | AC_VERB_SET_COEF_INDEX, 7); |
| 782 | tmp = snd_hda_codec_read(codec, 0x20, 0, |
| 783 | AC_VERB_GET_PROC_COEF, 0); |
| 784 | snd_hda_codec_write(codec, 0x20, 0, |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 785 | AC_VERB_SET_COEF_INDEX, 7); |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 786 | snd_hda_codec_write(codec, 0x20, 0, |
| 787 | AC_VERB_SET_PROC_COEF, |
| 788 | tmp | 0x3000); |
| 789 | break; |
Takashi Iwai | 0aea778 | 2010-01-25 15:44:11 +0100 | [diff] [blame] | 790 | #endif /* XXX */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 791 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 792 | break; |
| 793 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 794 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 795 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 796 | /* |
| 797 | * Auto-Mute mode mixer enum support |
| 798 | */ |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 799 | static int alc_automute_mode_info(struct snd_kcontrol *kcontrol, |
| 800 | struct snd_ctl_elem_info *uinfo) |
| 801 | { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 802 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 803 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 804 | static const char * const texts3[] = { |
Takashi Iwai | e49a343 | 2012-03-01 18:14:41 +0100 | [diff] [blame] | 805 | "Disabled", "Speaker Only", "Line Out+Speaker" |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 806 | }; |
| 807 | |
Takashi Iwai | dda415d | 2012-11-30 18:34:38 +0100 | [diff] [blame] | 808 | if (spec->automute_speaker_possible && spec->automute_lo_possible) |
| 809 | return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3); |
| 810 | return snd_hda_enum_bool_helper_info(kcontrol, uinfo); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 811 | } |
| 812 | |
| 813 | static int alc_automute_mode_get(struct snd_kcontrol *kcontrol, |
| 814 | struct snd_ctl_elem_value *ucontrol) |
| 815 | { |
| 816 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 817 | struct alc_spec *spec = codec->spec; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 818 | unsigned int val = 0; |
| 819 | if (spec->automute_speaker) |
| 820 | val++; |
| 821 | if (spec->automute_lo) |
| 822 | val++; |
| 823 | |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 824 | ucontrol->value.enumerated.item[0] = val; |
| 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | static int alc_automute_mode_put(struct snd_kcontrol *kcontrol, |
| 829 | struct snd_ctl_elem_value *ucontrol) |
| 830 | { |
| 831 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 832 | struct alc_spec *spec = codec->spec; |
| 833 | |
| 834 | switch (ucontrol->value.enumerated.item[0]) { |
| 835 | case 0: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 836 | if (!spec->automute_speaker && !spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 837 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 838 | spec->automute_speaker = 0; |
| 839 | spec->automute_lo = 0; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 840 | break; |
| 841 | case 1: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 842 | if (spec->automute_speaker_possible) { |
| 843 | if (!spec->automute_lo && spec->automute_speaker) |
| 844 | return 0; |
| 845 | spec->automute_speaker = 1; |
| 846 | spec->automute_lo = 0; |
| 847 | } else if (spec->automute_lo_possible) { |
| 848 | if (spec->automute_lo) |
| 849 | return 0; |
| 850 | spec->automute_lo = 1; |
| 851 | } else |
| 852 | return -EINVAL; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 853 | break; |
| 854 | case 2: |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 855 | if (!spec->automute_lo_possible || !spec->automute_speaker_possible) |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 856 | return -EINVAL; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 857 | if (spec->automute_speaker && spec->automute_lo) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 858 | return 0; |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 859 | spec->automute_speaker = 1; |
| 860 | spec->automute_lo = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 861 | break; |
| 862 | default: |
| 863 | return -EINVAL; |
| 864 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 865 | call_update_outputs(codec); |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 866 | return 1; |
| 867 | } |
| 868 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 869 | static const struct snd_kcontrol_new alc_automute_mode_enum = { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 870 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 871 | .name = "Auto-Mute Mode", |
| 872 | .info = alc_automute_mode_info, |
| 873 | .get = alc_automute_mode_get, |
| 874 | .put = alc_automute_mode_put, |
| 875 | }; |
| 876 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 877 | static struct snd_kcontrol_new * |
| 878 | alc_kcontrol_new(struct alc_spec *spec, const char *name, |
| 879 | const struct snd_kcontrol_new *temp) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 880 | { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 881 | struct snd_kcontrol_new *knew = snd_array_new(&spec->kctls); |
| 882 | if (!knew) |
| 883 | return NULL; |
| 884 | *knew = *temp; |
| 885 | knew->name = kstrdup(name, GFP_KERNEL); |
| 886 | if (!knew->name) |
| 887 | return NULL; |
| 888 | return knew; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 889 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 890 | |
| 891 | static int alc_add_automute_mode_enum(struct hda_codec *codec) |
| 892 | { |
| 893 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 894 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 895 | if (!alc_kcontrol_new(spec, "Auto-Mute Mode", &alc_automute_mode_enum)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 896 | return -ENOMEM; |
| 897 | return 0; |
| 898 | } |
| 899 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 900 | /* |
| 901 | * Check the availability of HP/line-out auto-mute; |
| 902 | * Set up appropriately if really supported |
| 903 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 904 | static int alc_init_automute(struct hda_codec *codec) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 905 | { |
| 906 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 907 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 908 | int present = 0; |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 909 | int i, err; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 910 | |
Takashi Iwai | 1daf5f4 | 2011-04-28 17:57:46 +0200 | [diff] [blame] | 911 | if (cfg->hp_pins[0]) |
| 912 | present++; |
| 913 | if (cfg->line_out_pins[0]) |
| 914 | present++; |
| 915 | if (cfg->speaker_pins[0]) |
| 916 | present++; |
| 917 | if (present < 2) /* need two different output types */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 918 | return 0; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 919 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 920 | if (!cfg->speaker_pins[0] && |
| 921 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 922 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 923 | sizeof(cfg->speaker_pins)); |
| 924 | cfg->speaker_outs = cfg->line_outs; |
| 925 | } |
| 926 | |
Takashi Iwai | c48a8fb | 2011-07-27 16:41:57 +0200 | [diff] [blame] | 927 | if (!cfg->hp_pins[0] && |
| 928 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 929 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 930 | sizeof(cfg->hp_pins)); |
| 931 | cfg->hp_outs = cfg->line_outs; |
| 932 | } |
| 933 | |
| 934 | for (i = 0; i < cfg->hp_outs; i++) { |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 935 | hda_nid_t nid = cfg->hp_pins[i]; |
Takashi Iwai | 06dec22 | 2011-05-17 10:00:16 +0200 | [diff] [blame] | 936 | if (!is_jack_detectable(codec, nid)) |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 937 | continue; |
Takashi Iwai | bb35feb | 2010-09-08 15:30:49 +0200 | [diff] [blame] | 938 | snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 939 | nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 940 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_HP_EVENT, |
| 941 | alc_hp_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 942 | spec->detect_hp = 1; |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 943 | } |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 944 | |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 945 | if (cfg->line_out_type == AUTO_PIN_LINE_OUT && cfg->line_outs) { |
| 946 | if (cfg->speaker_outs) |
| 947 | for (i = 0; i < cfg->line_outs; i++) { |
| 948 | hda_nid_t nid = cfg->line_out_pins[i]; |
| 949 | if (!is_jack_detectable(codec, nid)) |
| 950 | continue; |
| 951 | snd_printdd("realtek: Enable Line-Out " |
| 952 | "auto-muting on NID 0x%x\n", nid); |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 953 | snd_hda_jack_detect_enable_callback(codec, nid, ALC_FRONT_EVENT, |
| 954 | alc_line_automute); |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 955 | spec->detect_lo = 1; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 956 | } |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 957 | spec->automute_lo_possible = spec->detect_hp; |
| 958 | } |
| 959 | |
| 960 | spec->automute_speaker_possible = cfg->speaker_outs && |
| 961 | (spec->detect_hp || spec->detect_lo); |
| 962 | |
| 963 | spec->automute_lo = spec->automute_lo_possible; |
| 964 | spec->automute_speaker = spec->automute_speaker_possible; |
| 965 | |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 966 | if (spec->automute_speaker_possible || spec->automute_lo_possible) { |
Takashi Iwai | ae8a60a | 2011-04-28 18:09:52 +0200 | [diff] [blame] | 967 | /* create a control for automute mode */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 968 | err = alc_add_automute_mode_enum(codec); |
| 969 | if (err < 0) |
| 970 | return err; |
| 971 | } |
| 972 | return 0; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 973 | } |
| 974 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 975 | /* 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] | 976 | static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 977 | { |
| 978 | int i; |
| 979 | for (i = 0; i < nums; i++) |
| 980 | if (list[i] == nid) |
| 981 | return i; |
| 982 | return -1; |
| 983 | } |
| 984 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 985 | /* check whether all auto-mic pins are valid; setup indices if OK */ |
| 986 | static bool alc_auto_mic_check_imux(struct hda_codec *codec) |
| 987 | { |
| 988 | struct alc_spec *spec = codec->spec; |
| 989 | const struct hda_input_mux *imux; |
| 990 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 991 | imux = &spec->input_mux; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 992 | spec->ext_mic_idx = find_idx_in_nid_list(spec->ext_mic_pin, |
| 993 | spec->imux_pins, imux->num_items); |
| 994 | spec->int_mic_idx = find_idx_in_nid_list(spec->int_mic_pin, |
| 995 | spec->imux_pins, imux->num_items); |
| 996 | spec->dock_mic_idx = find_idx_in_nid_list(spec->dock_mic_pin, |
| 997 | spec->imux_pins, imux->num_items); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 998 | if (spec->ext_mic_idx < 0 || spec->int_mic_idx < 0) |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 999 | return false; /* no corresponding imux */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1000 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1001 | snd_hda_jack_detect_enable_callback(codec, spec->ext_mic_pin, |
| 1002 | ALC_MIC_EVENT, alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1003 | if (spec->dock_mic_pin) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 1004 | snd_hda_jack_detect_enable_callback(codec, spec->dock_mic_pin, |
| 1005 | ALC_MIC_EVENT, |
| 1006 | alc_mic_automute); |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1007 | |
| 1008 | spec->auto_mic_valid_imux = 1; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1009 | return true; |
| 1010 | } |
| 1011 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1012 | /* |
| 1013 | * Check the availability of auto-mic switch; |
| 1014 | * Set up if really supported |
| 1015 | */ |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1016 | static int alc_init_auto_mic(struct hda_codec *codec) |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1017 | { |
| 1018 | struct alc_spec *spec = codec->spec; |
| 1019 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1020 | hda_nid_t fixed, ext, dock; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1021 | int i; |
| 1022 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1023 | spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; |
| 1024 | |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1025 | fixed = ext = dock = 0; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 1026 | for (i = 0; i < cfg->num_inputs; i++) { |
| 1027 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1028 | unsigned int defcfg; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1029 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1030 | switch (snd_hda_get_input_pin_attr(defcfg)) { |
| 1031 | case INPUT_PIN_ATTR_INT: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1032 | if (fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1033 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1034 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1035 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1036 | fixed = nid; |
| 1037 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1038 | case INPUT_PIN_ATTR_UNUSED: |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1039 | return 0; /* invalid entry */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1040 | case INPUT_PIN_ATTR_DOCK: |
| 1041 | if (dock) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1042 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1043 | if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1044 | return 0; /* invalid type */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1045 | dock = nid; |
| 1046 | break; |
Takashi Iwai | 99ae28b | 2010-09-17 14:42:34 +0200 | [diff] [blame] | 1047 | default: |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1048 | if (ext) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1049 | return 0; /* already occupied */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1050 | if (cfg->inputs[i].type != AUTO_PIN_MIC) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1051 | return 0; /* invalid type */ |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1052 | ext = nid; |
| 1053 | break; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1054 | } |
| 1055 | } |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1056 | if (!ext && dock) { |
| 1057 | ext = dock; |
| 1058 | dock = 0; |
| 1059 | } |
Takashi Iwai | eaa9b3a | 2010-01-17 13:09:33 +0100 | [diff] [blame] | 1060 | if (!ext || !fixed) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1061 | return 0; |
Takashi Iwai | e35d9d6 | 2011-05-17 11:28:16 +0200 | [diff] [blame] | 1062 | if (!is_jack_detectable(codec, ext)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1063 | return 0; /* no unsol support */ |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1064 | if (dock && !is_jack_detectable(codec, dock)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1065 | return 0; /* no unsol support */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1066 | |
| 1067 | /* check imux indices */ |
| 1068 | spec->ext_mic_pin = ext; |
| 1069 | spec->int_mic_pin = fixed; |
| 1070 | spec->dock_mic_pin = dock; |
| 1071 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1072 | if (!alc_auto_mic_check_imux(codec)) |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1073 | return 0; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1074 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1075 | spec->auto_mic = 1; |
| 1076 | spec->num_adc_nids = 1; |
| 1077 | spec->cur_mux[0] = spec->int_mic_idx; |
Takashi Iwai | 8ed99d9 | 2011-05-17 12:05:02 +0200 | [diff] [blame] | 1078 | snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", |
| 1079 | ext, fixed, dock); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 1080 | |
| 1081 | return 0; |
Takashi Iwai | 6c81949 | 2009-08-10 18:47:44 +0200 | [diff] [blame] | 1082 | } |
| 1083 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1084 | /* |
| 1085 | * Realtek SSID verification |
| 1086 | */ |
| 1087 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1088 | /* Could be any non-zero and even value. When used as fixup, tells |
| 1089 | * the driver to ignore any present sku defines. |
| 1090 | */ |
| 1091 | #define ALC_FIXUP_SKU_IGNORE (2) |
| 1092 | |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 1093 | static void alc_fixup_sku_ignore(struct hda_codec *codec, |
| 1094 | const struct hda_fixup *fix, int action) |
| 1095 | { |
| 1096 | struct alc_spec *spec = codec->spec; |
| 1097 | if (action == HDA_FIXUP_ACT_PRE_PROBE) { |
| 1098 | spec->cdefine.fixup = 1; |
| 1099 | spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE; |
| 1100 | } |
| 1101 | } |
| 1102 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1103 | static int alc_auto_parse_customize_define(struct hda_codec *codec) |
| 1104 | { |
| 1105 | unsigned int ass, tmp, i; |
Takashi Iwai | 7fb5622 | 2010-03-22 17:09:47 +0100 | [diff] [blame] | 1106 | unsigned nid = 0; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1107 | struct alc_spec *spec = codec->spec; |
| 1108 | |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1109 | spec->cdefine.enable_pcbeep = 1; /* assume always enabled */ |
| 1110 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1111 | if (spec->cdefine.fixup) { |
| 1112 | ass = spec->cdefine.sku_cfg; |
| 1113 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1114 | return -1; |
| 1115 | goto do_sku; |
| 1116 | } |
| 1117 | |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1118 | ass = codec->subsystem_id & 0xffff; |
Takashi Iwai | b6cbe51 | 2010-07-28 17:43:36 +0200 | [diff] [blame] | 1119 | if (ass != codec->bus->pci->subsystem_device && (ass & 1)) |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 1120 | goto do_sku; |
| 1121 | |
| 1122 | nid = 0x1d; |
| 1123 | if (codec->vendor_id == 0x10ec0260) |
| 1124 | nid = 0x17; |
| 1125 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1126 | |
| 1127 | if (!(ass & 1)) { |
| 1128 | printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n", |
| 1129 | codec->chip_name, ass); |
| 1130 | return -1; |
| 1131 | } |
| 1132 | |
| 1133 | /* check sum */ |
| 1134 | tmp = 0; |
| 1135 | for (i = 1; i < 16; i++) { |
| 1136 | if ((ass >> i) & 1) |
| 1137 | tmp++; |
| 1138 | } |
| 1139 | if (((ass >> 16) & 0xf) != tmp) |
| 1140 | return -1; |
| 1141 | |
| 1142 | spec->cdefine.port_connectivity = ass >> 30; |
| 1143 | spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20; |
| 1144 | spec->cdefine.check_sum = (ass >> 16) & 0xf; |
| 1145 | spec->cdefine.customization = ass >> 8; |
| 1146 | do_sku: |
| 1147 | spec->cdefine.sku_cfg = ass; |
| 1148 | spec->cdefine.external_amp = (ass & 0x38) >> 3; |
| 1149 | spec->cdefine.platform_type = (ass & 0x4) >> 2; |
| 1150 | spec->cdefine.swap = (ass & 0x2) >> 1; |
| 1151 | spec->cdefine.override = ass & 0x1; |
| 1152 | |
| 1153 | snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n", |
| 1154 | nid, spec->cdefine.sku_cfg); |
| 1155 | snd_printd("SKU: port_connectivity=0x%x\n", |
| 1156 | spec->cdefine.port_connectivity); |
| 1157 | snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep); |
| 1158 | snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum); |
| 1159 | snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization); |
| 1160 | snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp); |
| 1161 | snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type); |
| 1162 | snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap); |
| 1163 | snd_printd("SKU: override=0x%x\n", spec->cdefine.override); |
| 1164 | |
| 1165 | return 0; |
| 1166 | } |
| 1167 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1168 | /* return true if the given NID is found in the list */ |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1169 | static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums) |
| 1170 | { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1171 | return find_idx_in_nid_list(nid, list, nums) >= 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1172 | } |
| 1173 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1174 | /* check subsystem ID and set up device-specific initialization; |
| 1175 | * return 1 if initialized, 0 if invalid SSID |
| 1176 | */ |
| 1177 | /* 32-bit subsystem ID for BIOS loading in HD Audio codec. |
| 1178 | * 31 ~ 16 : Manufacture ID |
| 1179 | * 15 ~ 8 : SKU ID |
| 1180 | * 7 ~ 0 : Assembly ID |
| 1181 | * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36 |
| 1182 | */ |
| 1183 | static int alc_subsystem_id(struct hda_codec *codec, |
| 1184 | hda_nid_t porta, hda_nid_t porte, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1185 | hda_nid_t portd, hda_nid_t porti) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1186 | { |
| 1187 | unsigned int ass, tmp, i; |
| 1188 | unsigned nid; |
| 1189 | struct alc_spec *spec = codec->spec; |
| 1190 | |
David Henningsson | 9062291 | 2010-10-14 14:50:18 +0200 | [diff] [blame] | 1191 | if (spec->cdefine.fixup) { |
| 1192 | ass = spec->cdefine.sku_cfg; |
| 1193 | if (ass == ALC_FIXUP_SKU_IGNORE) |
| 1194 | return 0; |
| 1195 | goto do_sku; |
| 1196 | } |
| 1197 | |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1198 | ass = codec->subsystem_id & 0xffff; |
| 1199 | if ((ass != codec->bus->pci->subsystem_device) && (ass & 1)) |
| 1200 | goto do_sku; |
| 1201 | |
| 1202 | /* invalid SSID, check the special NID pin defcfg instead */ |
| 1203 | /* |
Sasha Alexandr | def319f | 2009-06-16 16:00:15 -0400 | [diff] [blame] | 1204 | * 31~30 : port connectivity |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1205 | * 29~21 : reserve |
| 1206 | * 20 : PCBEEP input |
| 1207 | * 19~16 : Check sum (15:1) |
| 1208 | * 15~1 : Custom |
| 1209 | * 0 : override |
| 1210 | */ |
| 1211 | nid = 0x1d; |
| 1212 | if (codec->vendor_id == 0x10ec0260) |
| 1213 | nid = 0x17; |
| 1214 | ass = snd_hda_codec_get_pincfg(codec, nid); |
| 1215 | snd_printd("realtek: No valid SSID, " |
| 1216 | "checking pincfg 0x%08x for NID 0x%x\n", |
Takashi Iwai | cb6605c | 2009-04-28 13:03:19 +0200 | [diff] [blame] | 1217 | ass, nid); |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1218 | if (!(ass & 1)) |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1219 | return 0; |
| 1220 | if ((ass >> 30) != 1) /* no physical connection */ |
| 1221 | return 0; |
| 1222 | |
| 1223 | /* check sum */ |
| 1224 | tmp = 0; |
| 1225 | for (i = 1; i < 16; i++) { |
| 1226 | if ((ass >> i) & 1) |
| 1227 | tmp++; |
| 1228 | } |
| 1229 | if (((ass >> 16) & 0xf) != tmp) |
| 1230 | return 0; |
| 1231 | do_sku: |
| 1232 | snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n", |
| 1233 | ass & 0xffff, codec->vendor_id); |
| 1234 | /* |
| 1235 | * 0 : override |
| 1236 | * 1 : Swap Jack |
| 1237 | * 2 : 0 --> Desktop, 1 --> Laptop |
| 1238 | * 3~5 : External Amplifier control |
| 1239 | * 7~6 : Reserved |
| 1240 | */ |
| 1241 | tmp = (ass & 0x38) >> 3; /* external Amp control */ |
| 1242 | switch (tmp) { |
| 1243 | case 1: |
| 1244 | spec->init_amp = ALC_INIT_GPIO1; |
| 1245 | break; |
| 1246 | case 3: |
| 1247 | spec->init_amp = ALC_INIT_GPIO2; |
| 1248 | break; |
| 1249 | case 7: |
| 1250 | spec->init_amp = ALC_INIT_GPIO3; |
| 1251 | break; |
| 1252 | case 5: |
Takashi Iwai | 5a8cfb4 | 2010-11-26 17:11:18 +0100 | [diff] [blame] | 1253 | default: |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1254 | spec->init_amp = ALC_INIT_DEFAULT; |
| 1255 | break; |
| 1256 | } |
| 1257 | |
| 1258 | /* is laptop or Desktop and enable the function "Mute internal speaker |
| 1259 | * when the external headphone out jack is plugged" |
| 1260 | */ |
| 1261 | if (!(ass & 0x8000)) |
| 1262 | return 1; |
| 1263 | /* |
| 1264 | * 10~8 : Jack location |
| 1265 | * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered |
| 1266 | * 14~13: Resvered |
| 1267 | * 15 : 1 --> enable the function "Mute internal speaker |
| 1268 | * when the external headphone out jack is plugged" |
| 1269 | */ |
Takashi Iwai | 5fe6e01 | 2011-09-26 10:41:21 +0200 | [diff] [blame] | 1270 | if (!spec->autocfg.hp_pins[0] && |
| 1271 | !(spec->autocfg.line_out_pins[0] && |
| 1272 | spec->autocfg.line_out_type == AUTO_PIN_HP_OUT)) { |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1273 | hda_nid_t nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1274 | tmp = (ass >> 11) & 0x3; /* HP to chassis */ |
| 1275 | if (tmp == 0) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1276 | nid = porta; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1277 | else if (tmp == 1) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1278 | nid = porte; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1279 | else if (tmp == 2) |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1280 | nid = portd; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 1281 | else if (tmp == 3) |
| 1282 | nid = porti; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1283 | else |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1284 | return 1; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 1285 | if (found_in_nid_list(nid, spec->autocfg.line_out_pins, |
| 1286 | spec->autocfg.line_outs)) |
| 1287 | return 1; |
Takashi Iwai | 01d4825 | 2009-10-06 13:21:54 +0200 | [diff] [blame] | 1288 | spec->autocfg.hp_pins[0] = nid; |
Kailang Yang | c9b5800 | 2007-10-16 14:30:01 +0200 | [diff] [blame] | 1289 | } |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1290 | return 1; |
| 1291 | } |
Kailang Yang | ea1fb29 | 2008-08-26 12:58:38 +0200 | [diff] [blame] | 1292 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1293 | /* Check the validity of ALC subsystem-id |
| 1294 | * ports contains an array of 4 pin NIDs for port-A, E, D and I */ |
| 1295 | 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] | 1296 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 1297 | 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] | 1298 | struct alc_spec *spec = codec->spec; |
| 1299 | snd_printd("realtek: " |
| 1300 | "Enable default setup for auto mode as fallback\n"); |
| 1301 | spec->init_amp = ALC_INIT_DEFAULT; |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1302 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1303 | } |
Takashi Iwai | 1a1455d | 2011-04-28 17:36:18 +0200 | [diff] [blame] | 1304 | |
Takashi Iwai | 41e41f1 | 2005-06-08 14:48:49 +0200 | [diff] [blame] | 1305 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1306 | * COEF access helper functions |
| 1307 | */ |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1308 | static int alc_read_coef_idx(struct hda_codec *codec, |
| 1309 | unsigned int coef_idx) |
| 1310 | { |
| 1311 | unsigned int val; |
| 1312 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1313 | coef_idx); |
| 1314 | val = snd_hda_codec_read(codec, 0x20, 0, |
| 1315 | AC_VERB_GET_PROC_COEF, 0); |
| 1316 | return val; |
| 1317 | } |
| 1318 | |
Kailang Yang | 977ddd6 | 2010-09-15 10:02:29 +0200 | [diff] [blame] | 1319 | static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx, |
| 1320 | unsigned int coef_val) |
| 1321 | { |
| 1322 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, |
| 1323 | coef_idx); |
| 1324 | snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, |
| 1325 | coef_val); |
| 1326 | } |
| 1327 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 1328 | /* a special bypass for COEF 0; read the cached value at the second time */ |
| 1329 | static unsigned int alc_get_coef0(struct hda_codec *codec) |
| 1330 | { |
| 1331 | struct alc_spec *spec = codec->spec; |
| 1332 | if (!spec->coef0) |
| 1333 | spec->coef0 = alc_read_coef_idx(codec, 0); |
| 1334 | return spec->coef0; |
| 1335 | } |
| 1336 | |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1337 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 1338 | hda_nid_t pin, int pin_type, |
| 1339 | hda_nid_t dac); |
| 1340 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 1341 | bool is_digital); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1342 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 1343 | hda_nid_t to_nid, int with_aa_mix, |
| 1344 | struct nid_path *path); |
| 1345 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 1346 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 1347 | int with_aa_mix); |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1348 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1349 | /* |
| 1350 | * Digital I/O handling |
| 1351 | */ |
| 1352 | |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1353 | /* set right pin controls for digital I/O */ |
| 1354 | static void alc_auto_init_digital(struct hda_codec *codec) |
| 1355 | { |
| 1356 | struct alc_spec *spec = codec->spec; |
| 1357 | int i; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1358 | hda_nid_t pin; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1359 | |
| 1360 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
| 1361 | pin = spec->autocfg.dig_out_pins[i]; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 1362 | if (!pin) |
| 1363 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1364 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1365 | } |
| 1366 | pin = spec->autocfg.dig_in_pin; |
| 1367 | if (pin) |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 1368 | snd_hda_set_pin_ctl(codec, pin, PIN_IN); |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1369 | } |
| 1370 | |
| 1371 | /* parse digital I/Os and set up NIDs in BIOS auto-parse mode */ |
| 1372 | static void alc_auto_parse_digital(struct hda_codec *codec) |
| 1373 | { |
| 1374 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1375 | int i, nums; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1376 | hda_nid_t dig_nid; |
| 1377 | |
| 1378 | /* support multiple SPDIFs; the secondary is set up as a slave */ |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1379 | nums = 0; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1380 | for (i = 0; i < spec->autocfg.dig_outs; i++) { |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 1381 | hda_nid_t pin = spec->autocfg.dig_out_pins[i]; |
| 1382 | dig_nid = alc_auto_look_for_dac(codec, pin, true); |
| 1383 | if (!dig_nid) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1384 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 1385 | if (!add_new_nid_path(codec, dig_nid, pin, 2)) |
| 1386 | continue; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1387 | if (!nums) { |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1388 | spec->multiout.dig_out_nid = dig_nid; |
| 1389 | spec->dig_out_type = spec->autocfg.dig_out_type[0]; |
| 1390 | } else { |
| 1391 | spec->multiout.slave_dig_outs = spec->slave_dig_outs; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1392 | if (nums >= ARRAY_SIZE(spec->slave_dig_outs) - 1) |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1393 | break; |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1394 | spec->slave_dig_outs[nums - 1] = dig_nid; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1395 | } |
Takashi Iwai | 51e4152 | 2011-11-03 16:54:06 +0100 | [diff] [blame] | 1396 | nums++; |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | if (spec->autocfg.dig_in_pin) { |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1400 | dig_nid = codec->start_nid; |
| 1401 | for (i = 0; i < codec->num_nodes; i++, dig_nid++) { |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1402 | struct nid_path *path; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1403 | unsigned int wcaps = get_wcaps(codec, dig_nid); |
| 1404 | if (get_wcaps_type(wcaps) != AC_WID_AUD_IN) |
| 1405 | continue; |
| 1406 | if (!(wcaps & AC_WCAP_DIGITAL)) |
| 1407 | continue; |
Takashi Iwai | df1d1fb | 2012-12-18 11:55:53 +0100 | [diff] [blame] | 1408 | path = add_new_nid_path(codec, spec->autocfg.dig_in_pin, |
| 1409 | dig_nid, 2); |
| 1410 | if (path) { |
| 1411 | path->active = true; |
Takashi Iwai | 01fdf18 | 2010-09-24 09:09:42 +0200 | [diff] [blame] | 1412 | spec->dig_in_nid = dig_nid; |
| 1413 | break; |
| 1414 | } |
| 1415 | } |
Takashi Iwai | 757899a | 2010-07-30 10:48:14 +0200 | [diff] [blame] | 1416 | } |
| 1417 | } |
| 1418 | |
Takashi Iwai | f95474e | 2007-07-10 00:47:43 +0200 | [diff] [blame] | 1419 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 1420 | * capture mixer elements |
Vincent Petry | ef8ef5f | 2008-11-23 11:31:41 +0800 | [diff] [blame] | 1421 | */ |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1422 | #define alc_cap_vol_info snd_hda_mixer_amp_volume_info |
| 1423 | #define alc_cap_vol_get snd_hda_mixer_amp_volume_get |
| 1424 | #define alc_cap_vol_tlv snd_hda_mixer_amp_tlv |
| 1425 | |
| 1426 | typedef int (*put_call_t)(struct snd_kcontrol *kcontrol, |
| 1427 | struct snd_ctl_elem_value *ucontrol); |
| 1428 | |
| 1429 | static int alc_cap_put_caller(struct snd_kcontrol *kcontrol, |
| 1430 | struct snd_ctl_elem_value *ucontrol, |
| 1431 | put_call_t func, int type) |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1432 | { |
| 1433 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1434 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1435 | const struct hda_input_mux *imux; |
| 1436 | struct nid_path *path; |
| 1437 | int i, adc_idx, err = 0; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1438 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1439 | imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1440 | adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1441 | mutex_lock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1442 | codec->cached_write = 1; |
| 1443 | for (i = 0; i < imux->num_items; i++) { |
| 1444 | path = get_nid_path(codec, spec->imux_pins[i], |
| 1445 | get_adc_nid(codec, adc_idx, i)); |
| 1446 | if (!path->ctls[type]) |
| 1447 | continue; |
| 1448 | kcontrol->private_value = path->ctls[type]; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1449 | err = func(kcontrol, ucontrol); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1450 | if (err < 0) |
| 1451 | goto error; |
Takashi Iwai | 9c7a083 | 2011-07-07 09:25:54 +0200 | [diff] [blame] | 1452 | } |
| 1453 | error: |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1454 | codec->cached_write = 0; |
Wu Fengguang | 5a9e02e | 2009-01-09 16:45:24 +0800 | [diff] [blame] | 1455 | mutex_unlock(&codec->control_mutex); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1456 | snd_hda_codec_resume_amp(codec); |
| 1457 | if (err >= 0 && type == NID_PATH_MUTE_CTL && |
| 1458 | spec->inv_dmic_fixup && spec->inv_dmic_muted) |
| 1459 | alc_inv_dmic_sync_adc(codec, adc_idx); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1460 | return err; |
| 1461 | } |
| 1462 | |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1463 | static int alc_cap_vol_put(struct snd_kcontrol *kcontrol, |
| 1464 | struct snd_ctl_elem_value *ucontrol) |
| 1465 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1466 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1467 | snd_hda_mixer_amp_volume_put, |
| 1468 | NID_PATH_VOL_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1469 | } |
| 1470 | |
| 1471 | /* capture mixer elements */ |
| 1472 | #define alc_cap_sw_info snd_ctl_boolean_stereo_info |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1473 | #define alc_cap_sw_get snd_hda_mixer_amp_switch_get |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1474 | |
| 1475 | static int alc_cap_sw_put(struct snd_kcontrol *kcontrol, |
| 1476 | struct snd_ctl_elem_value *ucontrol) |
| 1477 | { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1478 | return alc_cap_put_caller(kcontrol, ucontrol, |
| 1479 | snd_hda_mixer_amp_switch_put, |
| 1480 | NID_PATH_MUTE_CTL); |
Takashi Iwai | f9e336f | 2008-10-31 16:37:07 +0100 | [diff] [blame] | 1481 | } |
| 1482 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1483 | static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx) |
| 1484 | { |
| 1485 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 1486 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1487 | struct nid_path *path; |
| 1488 | hda_nid_t nid; |
| 1489 | int i, dir, parm; |
| 1490 | unsigned int val; |
| 1491 | |
| 1492 | for (i = 0; i < imux->num_items; i++) { |
| 1493 | if (spec->imux_pins[i] == spec->inv_dmic_pin) |
| 1494 | break; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1495 | } |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1496 | if (i >= imux->num_items) |
| 1497 | return; |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1498 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1499 | path = get_nid_path(codec, spec->inv_dmic_pin, |
| 1500 | get_adc_nid(codec, adc_idx, i)); |
| 1501 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 1502 | if (!val) |
| 1503 | return; |
| 1504 | nid = get_amp_nid_(val); |
| 1505 | dir = get_amp_direction_(val); |
| 1506 | parm = AC_AMP_SET_RIGHT | |
| 1507 | (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1508 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1509 | /* we care only right channel */ |
| 1510 | val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0); |
| 1511 | if (val & 0x80) /* if already muted, we don't need to touch */ |
| 1512 | return; |
| 1513 | val |= 0x80; |
| 1514 | snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, |
| 1515 | parm | val); |
Takashi Iwai | a23b688 | 2009-03-23 15:21:36 +0100 | [diff] [blame] | 1516 | } |
| 1517 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1518 | /* |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1519 | * Inverted digital-mic handling |
| 1520 | * |
| 1521 | * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch" |
| 1522 | * gives the additional mute only to the right channel of the digital mic |
| 1523 | * capture stream. This is a workaround for avoiding the almost silence |
| 1524 | * by summing the stereo stream from some (known to be ForteMedia) |
| 1525 | * digital mic unit. |
| 1526 | * |
| 1527 | * The logic is to call alc_inv_dmic_sync() after each action (possibly) |
| 1528 | * modifying ADC amp. When the mute flag is set, it mutes the R-channel |
| 1529 | * without caching so that the cache can still keep the original value. |
| 1530 | * The cached value is then restored when the flag is set off or any other |
| 1531 | * than d-mic is used as the current input source. |
| 1532 | */ |
| 1533 | static void alc_inv_dmic_sync(struct hda_codec *codec, bool force) |
| 1534 | { |
| 1535 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1536 | int src, nums; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1537 | |
| 1538 | if (!spec->inv_dmic_fixup) |
| 1539 | return; |
| 1540 | if (!spec->inv_dmic_muted && !force) |
| 1541 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1542 | nums = spec->dyn_adc_switch ? 1 : spec->num_adc_nids; |
| 1543 | for (src = 0; src < nums; src++) { |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1544 | bool dmic_fixup = false; |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1545 | |
| 1546 | if (spec->inv_dmic_muted && |
| 1547 | spec->imux_pins[spec->cur_mux[src]] == spec->inv_dmic_pin) |
| 1548 | dmic_fixup = true; |
| 1549 | if (!dmic_fixup && !force) |
| 1550 | continue; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1551 | alc_inv_dmic_sync_adc(codec, src); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1552 | } |
| 1553 | } |
| 1554 | |
| 1555 | static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol, |
| 1556 | struct snd_ctl_elem_value *ucontrol) |
| 1557 | { |
| 1558 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1559 | struct alc_spec *spec = codec->spec; |
| 1560 | |
| 1561 | ucontrol->value.integer.value[0] = !spec->inv_dmic_muted; |
| 1562 | return 0; |
| 1563 | } |
| 1564 | |
| 1565 | static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol, |
| 1566 | struct snd_ctl_elem_value *ucontrol) |
| 1567 | { |
| 1568 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 1569 | struct alc_spec *spec = codec->spec; |
| 1570 | unsigned int val = !ucontrol->value.integer.value[0]; |
| 1571 | |
| 1572 | if (val == spec->inv_dmic_muted) |
| 1573 | return 0; |
| 1574 | spec->inv_dmic_muted = val; |
| 1575 | alc_inv_dmic_sync(codec, true); |
| 1576 | return 0; |
| 1577 | } |
| 1578 | |
| 1579 | static const struct snd_kcontrol_new alc_inv_dmic_sw = { |
| 1580 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 1581 | .info = snd_ctl_boolean_mono_info, |
| 1582 | .get = alc_inv_dmic_sw_get, |
| 1583 | .put = alc_inv_dmic_sw_put, |
| 1584 | }; |
| 1585 | |
| 1586 | static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid) |
| 1587 | { |
| 1588 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 1589 | |
| 1590 | if (!alc_kcontrol_new(spec, "Inverted Internal Mic Capture Switch", |
| 1591 | &alc_inv_dmic_sw)) |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1592 | return -ENOMEM; |
| 1593 | spec->inv_dmic_fixup = 1; |
| 1594 | spec->inv_dmic_muted = 0; |
| 1595 | spec->inv_dmic_pin = nid; |
| 1596 | return 0; |
| 1597 | } |
| 1598 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 1599 | /* typically the digital mic is put at node 0x12 */ |
| 1600 | static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec, |
| 1601 | const struct alc_fixup *fix, int action) |
| 1602 | { |
| 1603 | if (action == ALC_FIXUP_ACT_PROBE) |
| 1604 | alc_add_inv_dmic_mixer(codec, 0x12); |
| 1605 | } |
| 1606 | |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 1607 | /* |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1608 | * virtual master controls |
| 1609 | */ |
| 1610 | |
| 1611 | /* |
| 1612 | * slave controls for virtual master |
| 1613 | */ |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1614 | static const char * const alc_slave_pfxs[] = { |
| 1615 | "Front", "Surround", "Center", "LFE", "Side", |
Takashi Iwai | 7c58975 | 2012-03-02 09:00:33 +0100 | [diff] [blame] | 1616 | "Headphone", "Speaker", "Mono", "Line Out", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1617 | "CLFE", "Bass Speaker", "PCM", |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1618 | NULL, |
| 1619 | }; |
| 1620 | |
| 1621 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1622 | * build control elements |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1623 | */ |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1624 | |
Jaroslav Kysela | 5b0cb1d | 2009-12-08 16:13:32 +0100 | [diff] [blame] | 1625 | #define NID_MAPPING (-1) |
| 1626 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 1627 | static void alc_free_kctls(struct hda_codec *codec); |
| 1628 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1629 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1630 | /* additional beep mixers; the actual parameters are overwritten at build */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1631 | static const struct snd_kcontrol_new alc_beep_mixer[] = { |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1632 | HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT), |
Jaroslav Kysela | 123c07a | 2009-10-21 14:48:23 +0200 | [diff] [blame] | 1633 | HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT), |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1634 | { } /* end */ |
| 1635 | }; |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1636 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1637 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1638 | static int __alc_build_controls(struct hda_codec *codec) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1639 | { |
| 1640 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 1641 | int i, err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1642 | |
| 1643 | for (i = 0; i < spec->num_mixers; i++) { |
| 1644 | err = snd_hda_add_new_ctls(codec, spec->mixers[i]); |
| 1645 | if (err < 0) |
| 1646 | return err; |
| 1647 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1648 | if (spec->multiout.dig_out_nid) { |
Takashi Iwai | dcda580 | 2012-10-12 17:24:51 +0200 | [diff] [blame] | 1649 | err = snd_hda_create_dig_out_ctls(codec, |
| 1650 | spec->multiout.dig_out_nid, |
| 1651 | spec->multiout.dig_out_nid, |
| 1652 | spec->pcm_rec[1].pcm_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1653 | if (err < 0) |
| 1654 | return err; |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1655 | if (!spec->no_analog) { |
| 1656 | err = snd_hda_create_spdif_share_sw(codec, |
| 1657 | &spec->multiout); |
| 1658 | if (err < 0) |
| 1659 | return err; |
| 1660 | spec->multiout.share_spdif = 1; |
| 1661 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1662 | } |
| 1663 | if (spec->dig_in_nid) { |
| 1664 | err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid); |
| 1665 | if (err < 0) |
| 1666 | return err; |
| 1667 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1668 | |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1669 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1670 | /* create beep controls if needed */ |
| 1671 | if (spec->beep_amp) { |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 1672 | const struct snd_kcontrol_new *knew; |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1673 | for (knew = alc_beep_mixer; knew->name; knew++) { |
| 1674 | struct snd_kcontrol *kctl; |
| 1675 | kctl = snd_ctl_new1(knew, codec); |
| 1676 | if (!kctl) |
| 1677 | return -ENOMEM; |
| 1678 | kctl->private_value = spec->beep_amp; |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 1679 | err = snd_hda_ctl_add(codec, 0, kctl); |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1680 | if (err < 0) |
| 1681 | return err; |
| 1682 | } |
| 1683 | } |
Takashi Iwai | 67d634c | 2009-11-16 15:35:59 +0100 | [diff] [blame] | 1684 | #endif |
Takashi Iwai | 45bdd1c | 2009-02-06 16:11:25 +0100 | [diff] [blame] | 1685 | |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1686 | /* if we have no master control, let's create it */ |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1687 | if (!spec->no_analog && |
| 1688 | !snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) { |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1689 | unsigned int vmaster_tlv[4]; |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1690 | snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid, |
Takashi Iwai | 1c82ed1 | 2008-02-18 13:05:50 +0100 | [diff] [blame] | 1691 | HDA_OUTPUT, vmaster_tlv); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1692 | err = snd_hda_add_vmaster(codec, "Master Playback Volume", |
Takashi Iwai | 9322ca5 | 2012-02-03 14:28:01 +0100 | [diff] [blame] | 1693 | vmaster_tlv, alc_slave_pfxs, |
| 1694 | "Playback Volume"); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1695 | if (err < 0) |
| 1696 | return err; |
| 1697 | } |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1698 | if (!spec->no_analog && |
| 1699 | !snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) { |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1700 | err = __snd_hda_add_vmaster(codec, "Master Playback Switch", |
| 1701 | NULL, alc_slave_pfxs, |
| 1702 | "Playback Switch", |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 1703 | true, &spec->vmaster_mute.sw_kctl); |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 1704 | if (err < 0) |
| 1705 | return err; |
| 1706 | } |
| 1707 | |
Takashi Iwai | bae84e7 | 2010-03-22 08:30:20 +0100 | [diff] [blame] | 1708 | alc_free_kctls(codec); /* no longer needed */ |
| 1709 | |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1710 | return 0; |
| 1711 | } |
| 1712 | |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1713 | static int alc_build_jacks(struct hda_codec *codec) |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1714 | { |
| 1715 | struct alc_spec *spec = codec->spec; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1716 | |
| 1717 | if (spec->shared_mic_hp) { |
| 1718 | int err; |
| 1719 | int nid = spec->autocfg.inputs[1].pin; |
| 1720 | err = snd_hda_jack_add_kctl(codec, nid, "Headphone Mic", 0); |
| 1721 | if (err < 0) |
| 1722 | return err; |
| 1723 | err = snd_hda_jack_detect_enable(codec, nid, 0); |
| 1724 | if (err < 0) |
| 1725 | return err; |
| 1726 | } |
| 1727 | |
| 1728 | return snd_hda_jack_add_kctls(codec, &spec->autocfg); |
| 1729 | } |
| 1730 | |
| 1731 | static int alc_build_controls(struct hda_codec *codec) |
| 1732 | { |
Takashi Iwai | f21d78e | 2012-01-19 12:10:29 +0100 | [diff] [blame] | 1733 | int err = __alc_build_controls(codec); |
Takashi Iwai | 01a61e1 | 2011-10-28 00:03:22 +0200 | [diff] [blame] | 1734 | if (err < 0) |
| 1735 | return err; |
David Henningsson | 5780b62 | 2012-06-27 18:45:45 +0200 | [diff] [blame] | 1736 | |
| 1737 | err = alc_build_jacks(codec); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 1738 | if (err < 0) |
| 1739 | return err; |
| 1740 | alc_apply_fixup(codec, ALC_FIXUP_ACT_BUILD); |
| 1741 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1742 | } |
| 1743 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1744 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | /* |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1746 | * Common callbacks |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1747 | */ |
Takashi Iwai | 16ded52 | 2005-06-10 19:58:24 +0200 | [diff] [blame] | 1748 | |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1749 | static void alc_auto_init_std(struct hda_codec *codec); |
Takashi Iwai | 584c0c4 | 2011-03-10 12:51:11 +0100 | [diff] [blame] | 1750 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | static int alc_init(struct hda_codec *codec) |
| 1752 | { |
| 1753 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1754 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 1755 | if (spec->init_hook) |
| 1756 | spec->init_hook(codec); |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 1757 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1758 | alc_fix_pll(codec); |
Takashi Iwai | 4a79ba3 | 2009-04-22 16:31:35 +0200 | [diff] [blame] | 1759 | alc_auto_init_amp(codec, spec->init_amp); |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 1760 | |
Takashi Iwai | 2e8b2b2 | 2012-06-13 16:47:32 +0200 | [diff] [blame] | 1761 | snd_hda_gen_apply_verbs(codec); |
Takashi Iwai | 070cff4 | 2012-02-21 12:54:17 +0100 | [diff] [blame] | 1762 | alc_auto_init_std(codec); |
Takashi Iwai | ae6b813 | 2006-03-03 16:47:17 +0100 | [diff] [blame] | 1763 | |
Takashi Iwai | 5870112 | 2011-01-13 15:41:45 +0100 | [diff] [blame] | 1764 | alc_apply_fixup(codec, ALC_FIXUP_ACT_INIT); |
| 1765 | |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 1766 | hda_call_check_power_status(codec, 0x01); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1767 | return 0; |
| 1768 | } |
| 1769 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 1770 | #ifdef CONFIG_PM |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 1771 | static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid) |
| 1772 | { |
| 1773 | struct alc_spec *spec = codec->spec; |
| 1774 | return snd_hda_check_amp_list_power(codec, &spec->loopback, nid); |
| 1775 | } |
| 1776 | #endif |
| 1777 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1778 | /* |
| 1779 | * Analog playback callbacks |
| 1780 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1781 | static int alc_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1783 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1784 | { |
| 1785 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9a08160 | 2008-02-12 18:37:26 +0100 | [diff] [blame] | 1786 | return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream, |
| 1787 | hinfo); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1788 | } |
| 1789 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1790 | static int alc_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1791 | struct hda_codec *codec, |
| 1792 | unsigned int stream_tag, |
| 1793 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1794 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1795 | { |
| 1796 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 9c7f852 | 2006-06-28 15:08:22 +0200 | [diff] [blame] | 1797 | return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, |
| 1798 | stream_tag, format, substream); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1799 | } |
| 1800 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1801 | static int alc_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1802 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1803 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1804 | { |
| 1805 | struct alc_spec *spec = codec->spec; |
| 1806 | return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout); |
| 1807 | } |
| 1808 | |
| 1809 | /* |
| 1810 | * Digital out |
| 1811 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1812 | static int alc_dig_playback_pcm_open(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1813 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1814 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1815 | { |
| 1816 | struct alc_spec *spec = codec->spec; |
| 1817 | return snd_hda_multi_out_dig_open(codec, &spec->multiout); |
| 1818 | } |
| 1819 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1820 | static int alc_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 6b97eb4 | 2007-04-05 14:51:48 +0200 | [diff] [blame] | 1821 | struct hda_codec *codec, |
| 1822 | unsigned int stream_tag, |
| 1823 | unsigned int format, |
| 1824 | struct snd_pcm_substream *substream) |
| 1825 | { |
| 1826 | struct alc_spec *spec = codec->spec; |
| 1827 | return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, |
| 1828 | stream_tag, format, substream); |
| 1829 | } |
| 1830 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1831 | static int alc_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 9b5f12e | 2009-02-13 11:47:37 +0100 | [diff] [blame] | 1832 | struct hda_codec *codec, |
| 1833 | struct snd_pcm_substream *substream) |
| 1834 | { |
| 1835 | struct alc_spec *spec = codec->spec; |
| 1836 | return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout); |
| 1837 | } |
| 1838 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1839 | static int alc_dig_playback_pcm_close(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1840 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1841 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1842 | { |
| 1843 | struct alc_spec *spec = codec->spec; |
| 1844 | return snd_hda_multi_out_dig_close(codec, &spec->multiout); |
| 1845 | } |
| 1846 | |
| 1847 | /* |
| 1848 | * Analog capture |
| 1849 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1850 | static int alc_alt_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1851 | struct hda_codec *codec, |
| 1852 | unsigned int stream_tag, |
| 1853 | unsigned int format, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1854 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1855 | { |
| 1856 | struct alc_spec *spec = codec->spec; |
| 1857 | |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1858 | snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number + 1], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1859 | stream_tag, 0, format); |
| 1860 | return 0; |
| 1861 | } |
| 1862 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1863 | static int alc_alt_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1864 | struct hda_codec *codec, |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 1865 | struct snd_pcm_substream *substream) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1866 | { |
| 1867 | struct alc_spec *spec = codec->spec; |
| 1868 | |
Takashi Iwai | 888afa1 | 2008-03-18 09:57:50 +0100 | [diff] [blame] | 1869 | snd_hda_codec_cleanup_stream(codec, |
| 1870 | spec->adc_nids[substream->number + 1]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1871 | return 0; |
| 1872 | } |
| 1873 | |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1874 | /* analog capture with dynamic dual-adc changes */ |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1875 | static int dyn_adc_capture_pcm_prepare(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1876 | struct hda_codec *codec, |
| 1877 | unsigned int stream_tag, |
| 1878 | unsigned int format, |
| 1879 | struct snd_pcm_substream *substream) |
| 1880 | { |
| 1881 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1882 | 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] | 1883 | spec->cur_adc_stream_tag = stream_tag; |
| 1884 | spec->cur_adc_format = format; |
| 1885 | snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format); |
| 1886 | return 0; |
| 1887 | } |
| 1888 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1889 | static int dyn_adc_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1890 | struct hda_codec *codec, |
| 1891 | struct snd_pcm_substream *substream) |
| 1892 | { |
| 1893 | struct alc_spec *spec = codec->spec; |
| 1894 | snd_hda_codec_cleanup_stream(codec, spec->cur_adc); |
| 1895 | spec->cur_adc = 0; |
| 1896 | return 0; |
| 1897 | } |
| 1898 | |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1899 | static const struct hda_pcm_stream dyn_adc_pcm_analog_capture = { |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1900 | .substreams = 1, |
| 1901 | .channels_min = 2, |
| 1902 | .channels_max = 2, |
| 1903 | .nid = 0, /* fill later */ |
| 1904 | .ops = { |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 1905 | .prepare = dyn_adc_capture_pcm_prepare, |
| 1906 | .cleanup = dyn_adc_capture_pcm_cleanup |
Takashi Iwai | 840b64c | 2010-07-13 22:49:01 +0200 | [diff] [blame] | 1907 | }, |
| 1908 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1909 | |
| 1910 | /* |
| 1911 | */ |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1912 | static const struct hda_pcm_stream alc_pcm_analog_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1913 | .substreams = 1, |
| 1914 | .channels_min = 2, |
| 1915 | .channels_max = 8, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1916 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1917 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1918 | .open = alc_playback_pcm_open, |
| 1919 | .prepare = alc_playback_pcm_prepare, |
| 1920 | .cleanup = alc_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1921 | }, |
| 1922 | }; |
| 1923 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1924 | static const struct hda_pcm_stream alc_pcm_analog_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1925 | .substreams = 1, |
| 1926 | .channels_min = 2, |
| 1927 | .channels_max = 2, |
| 1928 | /* NID is set in alc_build_pcms */ |
| 1929 | }; |
| 1930 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1931 | static const struct hda_pcm_stream alc_pcm_analog_alt_playback = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1932 | .substreams = 1, |
| 1933 | .channels_min = 2, |
| 1934 | .channels_max = 2, |
| 1935 | /* NID is set in alc_build_pcms */ |
| 1936 | }; |
| 1937 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1938 | static const struct hda_pcm_stream alc_pcm_analog_alt_capture = { |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 1939 | .substreams = 2, /* can be overridden */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1940 | .channels_min = 2, |
| 1941 | .channels_max = 2, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 1942 | /* NID is set in alc_build_pcms */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1943 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1944 | .prepare = alc_alt_capture_pcm_prepare, |
| 1945 | .cleanup = alc_alt_capture_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1946 | }, |
| 1947 | }; |
| 1948 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1949 | static const struct hda_pcm_stream alc_pcm_digital_playback = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1950 | .substreams = 1, |
| 1951 | .channels_min = 2, |
| 1952 | .channels_max = 2, |
| 1953 | /* NID is set in alc_build_pcms */ |
| 1954 | .ops = { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1955 | .open = alc_dig_playback_pcm_open, |
| 1956 | .close = alc_dig_playback_pcm_close, |
| 1957 | .prepare = alc_dig_playback_pcm_prepare, |
| 1958 | .cleanup = alc_dig_playback_pcm_cleanup |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1959 | }, |
| 1960 | }; |
| 1961 | |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1962 | static const struct hda_pcm_stream alc_pcm_digital_capture = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1963 | .substreams = 1, |
| 1964 | .channels_min = 2, |
| 1965 | .channels_max = 2, |
| 1966 | /* NID is set in alc_build_pcms */ |
| 1967 | }; |
| 1968 | |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1969 | /* 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] | 1970 | static const struct hda_pcm_stream alc_pcm_null_stream = { |
Jonathan Woithe | 4c5186e | 2006-02-09 11:53:48 +0100 | [diff] [blame] | 1971 | .substreams = 0, |
| 1972 | .channels_min = 0, |
| 1973 | .channels_max = 0, |
| 1974 | }; |
| 1975 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1976 | static int alc_build_pcms(struct hda_codec *codec) |
| 1977 | { |
| 1978 | struct alc_spec *spec = codec->spec; |
| 1979 | struct hda_pcm *info = spec->pcm_rec; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1980 | const struct hda_pcm_stream *p; |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 1981 | bool have_multi_adcs; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | int i; |
| 1983 | |
| 1984 | codec->num_pcms = 1; |
| 1985 | codec->pcm_info = info; |
| 1986 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 1987 | if (spec->no_analog) |
| 1988 | goto skip_analog; |
| 1989 | |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 1990 | snprintf(spec->stream_name_analog, sizeof(spec->stream_name_analog), |
| 1991 | "%s Analog", codec->chip_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1992 | info->name = spec->stream_name_analog; |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 1993 | |
Takashi Iwai | eedec3d | 2012-02-06 10:24:04 +0100 | [diff] [blame] | 1994 | if (spec->multiout.num_dacs > 0) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 1995 | p = spec->stream_analog_playback; |
| 1996 | if (!p) |
| 1997 | p = &alc_pcm_analog_playback; |
| 1998 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 1999 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0]; |
Takashi Iwai | 9c9a517 | 2012-07-31 11:35:35 +0200 | [diff] [blame] | 2000 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = |
| 2001 | spec->multiout.max_channels; |
Takashi Iwai | ee81abb | 2012-11-08 17:12:10 +0100 | [diff] [blame] | 2002 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT && |
| 2003 | spec->autocfg.line_outs == 2) |
| 2004 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].chmap = |
| 2005 | snd_pcm_2_1_chmaps; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2006 | } |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2007 | if (spec->num_adc_nids) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2008 | p = spec->stream_analog_capture; |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2009 | if (!p) { |
| 2010 | if (spec->dyn_adc_switch) |
| 2011 | p = &dyn_adc_pcm_analog_capture; |
| 2012 | else |
| 2013 | p = &alc_pcm_analog_capture; |
| 2014 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2015 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2016 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0]; |
| 2017 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2018 | |
Takashi Iwai | 4a471b7 | 2005-12-07 13:56:29 +0100 | [diff] [blame] | 2019 | if (spec->channel_mode) { |
| 2020 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0; |
| 2021 | for (i = 0; i < spec->num_channel_mode; i++) { |
| 2022 | if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) { |
| 2023 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels; |
| 2024 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2025 | } |
| 2026 | } |
| 2027 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2028 | skip_analog: |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2029 | /* SPDIF for stream index #1 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2030 | if (spec->multiout.dig_out_nid || spec->dig_in_nid) { |
Takashi Iwai | 812a2cc | 2009-05-16 10:00:49 +0200 | [diff] [blame] | 2031 | snprintf(spec->stream_name_digital, |
| 2032 | sizeof(spec->stream_name_digital), |
| 2033 | "%s Digital", codec->chip_name); |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2034 | codec->num_pcms = 2; |
Wu Fengguang | b25c9da | 2009-02-06 15:02:27 +0800 | [diff] [blame] | 2035 | codec->slave_dig_outs = spec->multiout.slave_dig_outs; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2036 | info = spec->pcm_rec + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2037 | info->name = spec->stream_name_digital; |
Takashi Iwai | 8c44198 | 2009-01-20 18:30:20 +0100 | [diff] [blame] | 2038 | if (spec->dig_out_type) |
| 2039 | info->pcm_type = spec->dig_out_type; |
| 2040 | else |
| 2041 | info->pcm_type = HDA_PCM_TYPE_SPDIF; |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2042 | if (spec->multiout.dig_out_nid) { |
| 2043 | p = spec->stream_digital_playback; |
| 2044 | if (!p) |
| 2045 | p = &alc_pcm_digital_playback; |
| 2046 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2047 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid; |
| 2048 | } |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2049 | if (spec->dig_in_nid) { |
| 2050 | p = spec->stream_digital_capture; |
| 2051 | if (!p) |
| 2052 | p = &alc_pcm_digital_capture; |
| 2053 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2054 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid; |
| 2055 | } |
Takashi Iwai | 963f803 | 2008-08-11 10:04:40 +0200 | [diff] [blame] | 2056 | /* FIXME: do we need this for all Realtek codec models? */ |
| 2057 | codec->spdif_status_reset = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2058 | } |
| 2059 | |
Takashi Iwai | e64f14f | 2009-01-20 18:32:55 +0100 | [diff] [blame] | 2060 | if (spec->no_analog) |
| 2061 | return 0; |
| 2062 | |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2063 | /* If the use of more than one ADC is requested for the current |
| 2064 | * model, configure a second analog capture-only PCM. |
| 2065 | */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2066 | have_multi_adcs = (spec->num_adc_nids > 1) && |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2067 | !spec->dyn_adc_switch && !spec->auto_mic; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2068 | /* Additional Analaog capture for index #2 */ |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2069 | if (spec->alt_dac_nid || have_multi_adcs) { |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2070 | codec->num_pcms = 3; |
Takashi Iwai | c06134d | 2006-10-11 18:49:13 +0200 | [diff] [blame] | 2071 | info = spec->pcm_rec + 2; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2072 | info->name = spec->stream_name_analog; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2073 | if (spec->alt_dac_nid) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2074 | p = spec->stream_analog_alt_playback; |
| 2075 | if (!p) |
| 2076 | p = &alc_pcm_analog_alt_playback; |
| 2077 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2078 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = |
| 2079 | spec->alt_dac_nid; |
| 2080 | } else { |
| 2081 | info->stream[SNDRV_PCM_STREAM_PLAYBACK] = |
| 2082 | alc_pcm_null_stream; |
| 2083 | info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0; |
| 2084 | } |
Takashi Iwai | 1fa1757 | 2011-11-02 21:30:51 +0100 | [diff] [blame] | 2085 | if (have_multi_adcs) { |
Takashi Iwai | c2d986b | 2011-07-06 18:30:08 +0200 | [diff] [blame] | 2086 | p = spec->stream_analog_alt_capture; |
| 2087 | if (!p) |
| 2088 | p = &alc_pcm_analog_alt_capture; |
| 2089 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = *p; |
Takashi Iwai | 6330079 | 2008-01-24 15:31:36 +0100 | [diff] [blame] | 2090 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = |
| 2091 | spec->adc_nids[1]; |
| 2092 | info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = |
| 2093 | spec->num_adc_nids - 1; |
| 2094 | } else { |
| 2095 | info->stream[SNDRV_PCM_STREAM_CAPTURE] = |
| 2096 | alc_pcm_null_stream; |
| 2097 | info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = 0; |
Takashi Iwai | e08a007 | 2006-09-07 17:52:14 +0200 | [diff] [blame] | 2098 | } |
| 2099 | } |
| 2100 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2101 | return 0; |
| 2102 | } |
| 2103 | |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2104 | static inline void alc_shutup(struct hda_codec *codec) |
| 2105 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2106 | struct alc_spec *spec = codec->spec; |
| 2107 | |
| 2108 | if (spec && spec->shutup) |
| 2109 | spec->shutup(codec); |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2110 | snd_hda_shutup_pins(codec); |
| 2111 | } |
| 2112 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2113 | static void alc_free_kctls(struct hda_codec *codec) |
| 2114 | { |
| 2115 | struct alc_spec *spec = codec->spec; |
| 2116 | |
| 2117 | if (spec->kctls.list) { |
| 2118 | struct snd_kcontrol_new *kctl = spec->kctls.list; |
| 2119 | int i; |
| 2120 | for (i = 0; i < spec->kctls.used; i++) |
| 2121 | kfree(kctl[i].name); |
| 2122 | } |
| 2123 | snd_array_free(&spec->kctls); |
| 2124 | } |
| 2125 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2126 | static void alc_free_bind_ctls(struct hda_codec *codec) |
| 2127 | { |
| 2128 | struct alc_spec *spec = codec->spec; |
| 2129 | if (spec->bind_ctls.list) { |
| 2130 | struct hda_bind_ctls **ctl = spec->bind_ctls.list; |
| 2131 | int i; |
| 2132 | for (i = 0; i < spec->bind_ctls.used; i++) |
| 2133 | kfree(ctl[i]); |
| 2134 | } |
| 2135 | snd_array_free(&spec->bind_ctls); |
| 2136 | } |
| 2137 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2138 | static void alc_free(struct hda_codec *codec) |
| 2139 | { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2140 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2141 | |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2142 | if (!spec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2143 | return; |
| 2144 | |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2145 | alc_free_kctls(codec); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2146 | alc_free_bind_ctls(codec); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2147 | snd_array_free(&spec->paths); |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 2148 | snd_hda_gen_free(&spec->gen); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2149 | kfree(spec); |
Kusanagi Kouichi | 680cd53 | 2009-02-05 00:00:58 +0900 | [diff] [blame] | 2150 | snd_hda_detach_beep_device(codec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2151 | } |
| 2152 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2153 | #ifdef CONFIG_PM |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2154 | static void alc_power_eapd(struct hda_codec *codec) |
| 2155 | { |
Takashi Iwai | 691f1fc | 2011-04-07 10:31:43 +0200 | [diff] [blame] | 2156 | alc_auto_setup_eapd(codec, false); |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2157 | } |
| 2158 | |
Takashi Iwai | 68cb2b5 | 2012-07-02 15:20:37 +0200 | [diff] [blame] | 2159 | static int alc_suspend(struct hda_codec *codec) |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2160 | { |
| 2161 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | a4e09aa | 2009-12-27 11:22:24 +0100 | [diff] [blame] | 2162 | alc_shutup(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2163 | if (spec && spec->power_hook) |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2164 | spec->power_hook(codec); |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2165 | return 0; |
| 2166 | } |
| 2167 | #endif |
| 2168 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2169 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2170 | static int alc_resume(struct hda_codec *codec) |
| 2171 | { |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 2172 | msleep(150); /* to avoid pop noise */ |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2173 | codec->patch_ops.init(codec); |
| 2174 | snd_hda_codec_resume_amp(codec); |
| 2175 | snd_hda_codec_resume_cache(codec); |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 2176 | alc_inv_dmic_sync(codec, true); |
Takashi Iwai | 9e5341b | 2010-09-21 09:57:06 +0200 | [diff] [blame] | 2177 | hda_call_check_power_status(codec, 0x01); |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2178 | return 0; |
| 2179 | } |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2180 | #endif |
| 2181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2182 | /* |
| 2183 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 2184 | static const struct hda_codec_ops alc_patch_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2185 | .build_controls = alc_build_controls, |
| 2186 | .build_pcms = alc_build_pcms, |
| 2187 | .init = alc_init, |
| 2188 | .free = alc_free, |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2189 | .unsol_event = snd_hda_jack_unsol_event, |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 2190 | #ifdef CONFIG_PM |
Takashi Iwai | e044c39 | 2008-10-27 16:56:24 +0100 | [diff] [blame] | 2191 | .resume = alc_resume, |
| 2192 | #endif |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2193 | #ifdef CONFIG_PM |
Hector Martin | f5de24b | 2009-12-20 22:51:31 +0100 | [diff] [blame] | 2194 | .suspend = alc_suspend, |
Takashi Iwai | cb53c62 | 2007-08-10 17:21:45 +0200 | [diff] [blame] | 2195 | .check_power_status = alc_check_power_status, |
| 2196 | #endif |
Daniel T Chen | c97259d | 2009-12-27 18:52:08 -0500 | [diff] [blame] | 2197 | .reboot_notify = alc_shutup, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | }; |
| 2199 | |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 2200 | |
Kailang Yang | c027ddc | 2010-03-19 11:33:06 +0100 | [diff] [blame] | 2201 | /* replace the codec chip_name with the given string */ |
| 2202 | static int alc_codec_rename(struct hda_codec *codec, const char *name) |
| 2203 | { |
| 2204 | kfree(codec->chip_name); |
| 2205 | codec->chip_name = kstrdup(name, GFP_KERNEL); |
| 2206 | if (!codec->chip_name) { |
| 2207 | alc_free(codec); |
| 2208 | return -ENOMEM; |
| 2209 | } |
| 2210 | return 0; |
| 2211 | } |
| 2212 | |
Takashi Iwai | 2fa522b | 2005-05-12 14:51:12 +0200 | [diff] [blame] | 2213 | /* |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2214 | * Rename codecs appropriately from COEF value |
| 2215 | */ |
| 2216 | struct alc_codec_rename_table { |
| 2217 | unsigned int vendor_id; |
| 2218 | unsigned short coef_mask; |
| 2219 | unsigned short coef_bits; |
| 2220 | const char *name; |
| 2221 | }; |
| 2222 | |
| 2223 | static struct alc_codec_rename_table rename_tbl[] = { |
| 2224 | { 0x10ec0269, 0xfff0, 0x3010, "ALC277" }, |
| 2225 | { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" }, |
| 2226 | { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" }, |
| 2227 | { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" }, |
| 2228 | { 0x10ec0269, 0xffff, 0xa023, "ALC259" }, |
| 2229 | { 0x10ec0269, 0xffff, 0x6023, "ALC281X" }, |
| 2230 | { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" }, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 2231 | { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2232 | { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" }, |
| 2233 | { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" }, |
| 2234 | { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" }, |
| 2235 | { 0x10ec0899, 0x2000, 0x2000, "ALC899" }, |
| 2236 | { 0x10ec0892, 0xffff, 0x8020, "ALC661" }, |
| 2237 | { 0x10ec0892, 0xffff, 0x8011, "ALC661" }, |
| 2238 | { 0x10ec0892, 0xffff, 0x4011, "ALC656" }, |
| 2239 | { } /* terminator */ |
| 2240 | }; |
| 2241 | |
| 2242 | static int alc_codec_rename_from_preset(struct hda_codec *codec) |
| 2243 | { |
| 2244 | const struct alc_codec_rename_table *p; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2245 | |
| 2246 | for (p = rename_tbl; p->vendor_id; p++) { |
| 2247 | if (p->vendor_id != codec->vendor_id) |
| 2248 | continue; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 2249 | if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits) |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 2250 | return alc_codec_rename(codec, p->name); |
| 2251 | } |
| 2252 | return 0; |
| 2253 | } |
| 2254 | |
| 2255 | /* |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2256 | * Automatic parse of I/O pins from the BIOS configuration |
| 2257 | */ |
| 2258 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2259 | enum { |
| 2260 | ALC_CTL_WIDGET_VOL, |
| 2261 | ALC_CTL_WIDGET_MUTE, |
| 2262 | ALC_CTL_BIND_MUTE, |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2263 | ALC_CTL_BIND_VOL, |
| 2264 | ALC_CTL_BIND_SW, |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2265 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 2266 | static const struct snd_kcontrol_new alc_control_templates[] = { |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2267 | HDA_CODEC_VOLUME(NULL, 0, 0, 0), |
| 2268 | HDA_CODEC_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 985be54 | 2005-11-02 18:26:49 +0100 | [diff] [blame] | 2269 | HDA_BIND_MUTE(NULL, 0, 0, 0), |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2270 | HDA_BIND_VOL(NULL, 0), |
| 2271 | HDA_BIND_SW(NULL, 0), |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2272 | }; |
| 2273 | |
| 2274 | /* add dynamic controls */ |
Takashi Iwai | f12ab1e | 2007-04-12 15:51:47 +0200 | [diff] [blame] | 2275 | 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] | 2276 | int cidx, unsigned long val) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2277 | { |
Takashi Iwai | c8b6bf9 | 2005-11-17 14:57:47 +0100 | [diff] [blame] | 2278 | struct snd_kcontrol_new *knew; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2279 | |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 2280 | knew = alc_kcontrol_new(spec, name, &alc_control_templates[type]); |
Takashi Iwai | 603c401 | 2008-07-30 15:01:44 +0200 | [diff] [blame] | 2281 | if (!knew) |
| 2282 | return -ENOMEM; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2283 | knew->index = cidx; |
Jaroslav Kysela | 4d02d1b | 2009-11-12 10:15:48 +0100 | [diff] [blame] | 2284 | if (get_amp_nid_(val)) |
Jaroslav Kysela | 5e26dfd | 2009-12-10 13:57:01 +0100 | [diff] [blame] | 2285 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2286 | knew->private_value = val; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2287 | return 0; |
| 2288 | } |
| 2289 | |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2290 | static int add_control_with_pfx(struct alc_spec *spec, int type, |
| 2291 | const char *pfx, const char *dir, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2292 | const char *sfx, int cidx, unsigned long val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2293 | { |
| 2294 | char name[32]; |
| 2295 | snprintf(name, sizeof(name), "%s %s %s", pfx, dir, sfx); |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2296 | return add_control(spec, type, name, cidx, val); |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2297 | } |
| 2298 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2299 | #define add_pb_vol_ctrl(spec, type, pfx, val) \ |
| 2300 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", 0, val) |
| 2301 | #define add_pb_sw_ctrl(spec, type, pfx, val) \ |
| 2302 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", 0, val) |
| 2303 | #define __add_pb_vol_ctrl(spec, type, pfx, cidx, val) \ |
| 2304 | add_control_with_pfx(spec, type, pfx, "Playback", "Volume", cidx, val) |
| 2305 | #define __add_pb_sw_ctrl(spec, type, pfx, cidx, val) \ |
| 2306 | add_control_with_pfx(spec, type, pfx, "Playback", "Switch", cidx, val) |
Takashi Iwai | 0afe5f8 | 2009-10-02 09:20:00 +0200 | [diff] [blame] | 2307 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2308 | static const char * const channel_name[4] = { |
| 2309 | "Front", "Surround", "CLFE", "Side" |
| 2310 | }; |
| 2311 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2312 | static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch, |
| 2313 | bool can_be_master, int *index) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2314 | { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2315 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2316 | |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2317 | *index = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2318 | if (cfg->line_outs == 1 && !spec->multi_ios && |
| 2319 | !cfg->hp_outs && !cfg->speaker_outs && can_be_master) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2320 | return "Master"; |
| 2321 | |
| 2322 | switch (cfg->line_out_type) { |
| 2323 | case AUTO_PIN_SPEAKER_OUT: |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2324 | if (cfg->line_outs == 1) |
| 2325 | return "Speaker"; |
Takashi Iwai | fbabc24 | 2011-12-07 17:14:20 +0100 | [diff] [blame] | 2326 | if (cfg->line_outs == 2) |
| 2327 | return ch ? "Bass Speaker" : "Speaker"; |
David Henningsson | ebbeb3d | 2011-03-04 14:08:30 +0100 | [diff] [blame] | 2328 | break; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2329 | case AUTO_PIN_HP_OUT: |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 2330 | /* for multi-io case, only the primary out */ |
| 2331 | if (ch && spec->multi_ios) |
| 2332 | break; |
| 2333 | *index = ch; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2334 | return "Headphone"; |
| 2335 | default: |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 2336 | if (cfg->line_outs == 1 && !spec->multi_ios) |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2337 | return "PCM"; |
| 2338 | break; |
| 2339 | } |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2340 | if (ch >= ARRAY_SIZE(channel_name)) { |
| 2341 | snd_BUG(); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2342 | return "PCM"; |
David Henningsson | 71aa5eb | 2012-10-17 12:43:44 +0200 | [diff] [blame] | 2343 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 2344 | |
| 2345 | return channel_name[ch]; |
Takashi Iwai | bcb2f0f | 2011-01-10 15:45:23 +0100 | [diff] [blame] | 2346 | } |
| 2347 | |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 2348 | #ifdef CONFIG_PM |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2349 | /* add the powersave loopback-list entry */ |
| 2350 | static void add_loopback_list(struct alc_spec *spec, hda_nid_t mix, int idx) |
| 2351 | { |
| 2352 | struct hda_amp_list *list; |
| 2353 | |
| 2354 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) |
| 2355 | return; |
| 2356 | list = spec->loopback_list + spec->num_loopbacks; |
| 2357 | list->nid = mix; |
| 2358 | list->dir = HDA_INPUT; |
| 2359 | list->idx = idx; |
| 2360 | spec->num_loopbacks++; |
| 2361 | spec->loopback.amplist = spec->loopback_list; |
| 2362 | } |
| 2363 | #else |
| 2364 | #define add_loopback_list(spec, mix, idx) /* NOP */ |
| 2365 | #endif |
| 2366 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2367 | /* create input playback/capture controls for the given pin */ |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2368 | static int new_analog_input(struct hda_codec *codec, hda_nid_t pin, |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2369 | const char *ctlname, int ctlidx, |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2370 | hda_nid_t mix_nid) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2371 | { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2372 | struct alc_spec *spec = codec->spec; |
| 2373 | struct nid_path *path; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2374 | unsigned int val; |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2375 | int err, idx; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2376 | |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2377 | if (!nid_has_volume(codec, mix_nid, HDA_INPUT) && |
| 2378 | !nid_has_mute(codec, mix_nid, HDA_INPUT)) |
| 2379 | return 0; /* no need for analog loopback */ |
| 2380 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2381 | path = add_new_nid_path(codec, pin, mix_nid, 2); |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2382 | if (!path) |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2383 | return -EINVAL; |
| 2384 | |
| 2385 | idx = path->idx[path->depth - 1]; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2386 | if (nid_has_volume(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2387 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2388 | err = __add_pb_vol_ctrl(spec, ALC_CTL_WIDGET_VOL, ctlname, ctlidx, val); |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2389 | if (err < 0) |
| 2390 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2391 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2392 | } |
| 2393 | |
| 2394 | if (nid_has_mute(codec, mix_nid, HDA_INPUT)) { |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2395 | val = HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT); |
| 2396 | err = __add_pb_sw_ctrl(spec, ALC_CTL_WIDGET_MUTE, ctlname, ctlidx, val); |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2397 | if (err < 0) |
| 2398 | return err; |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2399 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | bd32f78 | 2012-12-12 18:08:52 +0100 | [diff] [blame] | 2400 | } |
| 2401 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2402 | path->active = true; |
Takashi Iwai | 164f73e | 2012-02-21 11:27:09 +0100 | [diff] [blame] | 2403 | add_loopback_list(spec, mix_nid, idx); |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2404 | return 0; |
| 2405 | } |
| 2406 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2407 | 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] | 2408 | { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2409 | unsigned int pincap = snd_hda_query_pin_caps(codec, nid); |
| 2410 | return (pincap & AC_PINCAP_IN) != 0; |
| 2411 | } |
| 2412 | |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2413 | /* check whether the given two widgets can be connected */ |
| 2414 | static bool is_reachable_path(struct hda_codec *codec, |
| 2415 | hda_nid_t from_nid, hda_nid_t to_nid) |
| 2416 | { |
| 2417 | if (!from_nid || !to_nid) |
| 2418 | return false; |
| 2419 | return snd_hda_get_conn_index(codec, to_nid, from_nid, true) >= 0; |
| 2420 | } |
| 2421 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2422 | /* Parse the codec tree and retrieve ADCs */ |
| 2423 | static int alc_auto_fill_adc_nids(struct hda_codec *codec) |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2424 | { |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2425 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2426 | hda_nid_t nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2427 | hda_nid_t *adc_nids = spec->adc_nids; |
| 2428 | int max_nums = ARRAY_SIZE(spec->adc_nids); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2429 | int i, nums = 0; |
| 2430 | |
| 2431 | nid = codec->start_nid; |
| 2432 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2433 | unsigned int caps = get_wcaps(codec, nid); |
| 2434 | int type = get_wcaps_type(caps); |
| 2435 | |
| 2436 | if (type != AC_WID_AUD_IN || (caps & AC_WCAP_DIGITAL)) |
| 2437 | continue; |
| 2438 | adc_nids[nums] = nid; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2439 | if (++nums >= max_nums) |
| 2440 | break; |
| 2441 | } |
Takashi Iwai | d6cc9fab | 2011-07-06 16:38:42 +0200 | [diff] [blame] | 2442 | spec->num_adc_nids = nums; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2443 | return nums; |
| 2444 | } |
| 2445 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2446 | /* filter out invalid adc_nids that don't give all active input pins; |
| 2447 | * if needed, check whether dynamic ADC-switching is available |
| 2448 | */ |
| 2449 | static int check_dyn_adc_switch(struct hda_codec *codec) |
| 2450 | { |
| 2451 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2452 | struct hda_input_mux *imux = &spec->input_mux; |
| 2453 | hda_nid_t adc_nids[ARRAY_SIZE(spec->adc_nids)]; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2454 | int i, n, nums; |
| 2455 | hda_nid_t pin, adc; |
| 2456 | |
| 2457 | again: |
| 2458 | nums = 0; |
| 2459 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2460 | adc = spec->adc_nids[n]; |
| 2461 | for (i = 0; i < imux->num_items; i++) { |
| 2462 | pin = spec->imux_pins[i]; |
| 2463 | if (!is_reachable_path(codec, pin, adc)) |
| 2464 | break; |
| 2465 | } |
| 2466 | if (i >= imux->num_items) |
| 2467 | adc_nids[nums++] = adc; |
| 2468 | } |
| 2469 | |
| 2470 | if (!nums) { |
| 2471 | if (spec->shared_mic_hp) { |
| 2472 | spec->shared_mic_hp = 0; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2473 | imux->num_items = 1; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2474 | goto again; |
| 2475 | } |
| 2476 | |
| 2477 | /* check whether ADC-switch is possible */ |
| 2478 | for (i = 0; i < imux->num_items; i++) { |
| 2479 | pin = spec->imux_pins[i]; |
| 2480 | for (n = 0; n < spec->num_adc_nids; n++) { |
| 2481 | adc = spec->adc_nids[n]; |
| 2482 | if (is_reachable_path(codec, pin, adc)) { |
| 2483 | spec->dyn_adc_idx[i] = n; |
| 2484 | break; |
| 2485 | } |
| 2486 | } |
| 2487 | } |
| 2488 | |
| 2489 | snd_printdd("realtek: enabling ADC switching\n"); |
| 2490 | spec->dyn_adc_switch = 1; |
| 2491 | } else if (nums != spec->num_adc_nids) { |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2492 | memcpy(spec->adc_nids, adc_nids, nums * sizeof(hda_nid_t)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2493 | spec->num_adc_nids = nums; |
| 2494 | } |
| 2495 | |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2496 | if (imux->num_items == 1 || spec->shared_mic_hp) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2497 | snd_printdd("realtek: reducing to a single ADC\n"); |
| 2498 | spec->num_adc_nids = 1; /* reduce to a single ADC */ |
| 2499 | } |
| 2500 | |
| 2501 | return 0; |
| 2502 | } |
| 2503 | |
| 2504 | /* templates for capture controls */ |
| 2505 | static const struct snd_kcontrol_new cap_src_temp = { |
| 2506 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2507 | .name = "Input Source", |
| 2508 | .info = alc_mux_enum_info, |
| 2509 | .get = alc_mux_enum_get, |
| 2510 | .put = alc_mux_enum_put, |
| 2511 | }; |
| 2512 | |
| 2513 | static const struct snd_kcontrol_new cap_vol_temp = { |
| 2514 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2515 | .name = "Capture Volume", |
| 2516 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
| 2517 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | |
| 2518 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK), |
| 2519 | .info = alc_cap_vol_info, |
| 2520 | .get = alc_cap_vol_get, |
| 2521 | .put = alc_cap_vol_put, |
| 2522 | .tlv = { .c = alc_cap_vol_tlv }, |
| 2523 | }; |
| 2524 | |
| 2525 | static const struct snd_kcontrol_new cap_sw_temp = { |
| 2526 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 2527 | .name = "Capture Switch", |
| 2528 | .info = alc_cap_sw_info, |
| 2529 | .get = alc_cap_sw_get, |
| 2530 | .put = alc_cap_sw_put, |
| 2531 | }; |
| 2532 | |
| 2533 | static int parse_capvol_in_path(struct hda_codec *codec, struct nid_path *path) |
| 2534 | { |
| 2535 | hda_nid_t nid; |
| 2536 | int i, depth; |
| 2537 | |
| 2538 | path->ctls[NID_PATH_VOL_CTL] = path->ctls[NID_PATH_MUTE_CTL] = 0; |
| 2539 | for (depth = 0; depth < 3; depth++) { |
| 2540 | if (depth >= path->depth) |
| 2541 | return -EINVAL; |
| 2542 | i = path->depth - depth - 1; |
| 2543 | nid = path->path[i]; |
| 2544 | if (!path->ctls[NID_PATH_VOL_CTL]) { |
| 2545 | if (nid_has_volume(codec, nid, HDA_OUTPUT)) |
| 2546 | path->ctls[NID_PATH_VOL_CTL] = |
| 2547 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2548 | else if (nid_has_volume(codec, nid, HDA_INPUT)) { |
| 2549 | int idx = path->idx[i]; |
| 2550 | if (!depth && codec->single_adc_amp) |
| 2551 | idx = 0; |
| 2552 | path->ctls[NID_PATH_VOL_CTL] = |
| 2553 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2554 | } |
| 2555 | } |
| 2556 | if (!path->ctls[NID_PATH_MUTE_CTL]) { |
| 2557 | if (nid_has_mute(codec, nid, HDA_OUTPUT)) |
| 2558 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2559 | HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 2560 | else if (nid_has_mute(codec, nid, HDA_INPUT)) { |
| 2561 | int idx = path->idx[i]; |
| 2562 | if (!depth && codec->single_adc_amp) |
| 2563 | idx = 0; |
| 2564 | path->ctls[NID_PATH_MUTE_CTL] = |
| 2565 | HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_INPUT); |
| 2566 | } |
| 2567 | } |
| 2568 | } |
| 2569 | return 0; |
| 2570 | } |
| 2571 | |
| 2572 | static int create_capture_mixers(struct hda_codec *codec) |
| 2573 | { |
| 2574 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2575 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2576 | struct snd_kcontrol_new *knew; |
| 2577 | int i, n, nums; |
| 2578 | |
| 2579 | if (spec->dyn_adc_switch) |
| 2580 | nums = 1; |
| 2581 | else |
| 2582 | nums = spec->num_adc_nids; |
| 2583 | |
| 2584 | if (!spec->auto_mic && imux->num_items > 1) { |
| 2585 | knew = alc_kcontrol_new(spec, "Input Source", &cap_src_temp); |
| 2586 | if (!knew) |
| 2587 | return -ENOMEM; |
| 2588 | knew->count = nums; |
| 2589 | } |
| 2590 | |
| 2591 | for (n = 0; n < nums; n++) { |
| 2592 | int vol, sw; |
| 2593 | |
| 2594 | vol = sw = 0; |
| 2595 | for (i = 0; i < imux->num_items; i++) { |
| 2596 | struct nid_path *path; |
| 2597 | path = get_nid_path(codec, spec->imux_pins[i], |
| 2598 | get_adc_nid(codec, n, i)); |
| 2599 | if (!path) |
| 2600 | continue; |
| 2601 | parse_capvol_in_path(codec, path); |
| 2602 | if (!vol) |
| 2603 | vol = path->ctls[NID_PATH_VOL_CTL]; |
| 2604 | if (!sw) |
| 2605 | sw = path->ctls[NID_PATH_MUTE_CTL]; |
| 2606 | } |
| 2607 | |
| 2608 | if (vol) { |
| 2609 | knew = alc_kcontrol_new(spec, "Capture Volume", |
| 2610 | &cap_vol_temp); |
| 2611 | if (!knew) |
| 2612 | return -ENOMEM; |
| 2613 | knew->index = n; |
| 2614 | knew->private_value = vol; |
| 2615 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2616 | } |
| 2617 | if (sw) { |
| 2618 | knew = alc_kcontrol_new(spec, "Capture Switch", |
| 2619 | &cap_sw_temp); |
| 2620 | if (!knew) |
| 2621 | return -ENOMEM; |
| 2622 | knew->index = n; |
| 2623 | knew->private_value = sw; |
| 2624 | knew->subdevice = HDA_SUBDEV_AMP_FLAG; |
| 2625 | } |
| 2626 | } |
| 2627 | |
| 2628 | return 0; |
| 2629 | } |
| 2630 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2631 | /* create playback/capture controls for input pins */ |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2632 | static int alc_auto_create_input_ctls(struct hda_codec *codec) |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2633 | { |
| 2634 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2635 | const struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2636 | hda_nid_t mixer = spec->mixer_nid; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 2637 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2638 | int num_adcs; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2639 | int i, c, err, type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2640 | const char *prev_label = NULL; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2641 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2642 | num_adcs = alc_auto_fill_adc_nids(codec); |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2643 | if (num_adcs < 0) |
| 2644 | return 0; |
| 2645 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2646 | for (i = 0; i < cfg->num_inputs; i++) { |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2647 | hda_nid_t pin; |
Takashi Iwai | 10a20af | 2010-09-09 16:28:02 +0200 | [diff] [blame] | 2648 | const char *label; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2649 | bool imux_added; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2650 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2651 | pin = cfg->inputs[i].pin; |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2652 | if (!alc_is_input_pin(codec, pin)) |
| 2653 | continue; |
| 2654 | |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2655 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2656 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 2657 | label = "Headphone Mic"; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2658 | if (prev_label && !strcmp(label, prev_label)) |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2659 | type_idx++; |
| 2660 | else |
| 2661 | type_idx = 0; |
David Henningsson | 5322bf2 | 2011-01-05 11:03:56 +0100 | [diff] [blame] | 2662 | prev_label = label; |
| 2663 | |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2664 | if (mixer) { |
Takashi Iwai | c2fd19c | 2012-12-12 18:02:41 +0100 | [diff] [blame] | 2665 | if (is_reachable_path(codec, pin, mixer)) { |
| 2666 | err = new_analog_input(codec, pin, |
| 2667 | label, type_idx, mixer); |
Takashi Iwai | 05f5f47 | 2009-08-25 13:10:18 +0200 | [diff] [blame] | 2668 | if (err < 0) |
| 2669 | return err; |
| 2670 | } |
| 2671 | } |
| 2672 | |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2673 | imux_added = false; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2674 | for (c = 0; c < num_adcs; c++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2675 | struct nid_path *path; |
| 2676 | hda_nid_t adc = spec->adc_nids[c]; |
| 2677 | |
| 2678 | if (!is_reachable_path(codec, pin, adc)) |
| 2679 | continue; |
| 2680 | path = snd_array_new(&spec->paths); |
| 2681 | if (!path) |
| 2682 | return -ENOMEM; |
| 2683 | memset(path, 0, sizeof(*path)); |
| 2684 | if (!parse_nid_path(codec, pin, adc, 2, path)) { |
| 2685 | snd_printd(KERN_ERR |
| 2686 | "invalid input path 0x%x -> 0x%x\n", |
| 2687 | pin, adc); |
| 2688 | spec->paths.used--; |
| 2689 | continue; |
| 2690 | } |
| 2691 | |
| 2692 | if (!imux_added) { |
| 2693 | spec->imux_pins[imux->num_items] = pin; |
| 2694 | snd_hda_add_imux_item(imux, label, |
| 2695 | imux->num_items, NULL); |
| 2696 | imux_added = true; |
Takashi Iwai | b782170 | 2011-07-06 15:12:46 +0200 | [diff] [blame] | 2697 | } |
| 2698 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2699 | } |
Takashi Iwai | 2126896 | 2011-07-07 15:01:13 +0200 | [diff] [blame] | 2700 | |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2701 | return 0; |
| 2702 | } |
| 2703 | |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 2704 | /* create a shared input with the headphone out */ |
| 2705 | static int alc_auto_create_shared_input(struct hda_codec *codec) |
| 2706 | { |
| 2707 | struct alc_spec *spec = codec->spec; |
| 2708 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 2709 | unsigned int defcfg; |
| 2710 | hda_nid_t nid; |
| 2711 | |
| 2712 | /* only one internal input pin? */ |
| 2713 | if (cfg->num_inputs != 1) |
| 2714 | return 0; |
| 2715 | defcfg = snd_hda_codec_get_pincfg(codec, cfg->inputs[0].pin); |
| 2716 | if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT) |
| 2717 | return 0; |
| 2718 | |
| 2719 | if (cfg->hp_outs == 1 && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 2720 | nid = cfg->hp_pins[0]; /* OK, we have a single HP-out */ |
| 2721 | else if (cfg->line_outs == 1 && cfg->line_out_type == AUTO_PIN_HP_OUT) |
| 2722 | nid = cfg->line_out_pins[0]; /* OK, we have a single line-out */ |
| 2723 | else |
| 2724 | return 0; /* both not available */ |
| 2725 | |
| 2726 | if (!(snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_IN)) |
| 2727 | return 0; /* no input */ |
| 2728 | |
| 2729 | cfg->inputs[1].pin = nid; |
| 2730 | cfg->inputs[1].type = AUTO_PIN_MIC; |
| 2731 | cfg->num_inputs = 2; |
| 2732 | spec->shared_mic_hp = 1; |
| 2733 | snd_printdd("realtek: Enable shared I/O jack on NID 0x%x\n", nid); |
| 2734 | return 0; |
| 2735 | } |
| 2736 | |
Takashi Iwai | baba8ee | 2007-04-23 17:17:48 +0200 | [diff] [blame] | 2737 | static int get_pin_type(int line_out_type) |
| 2738 | { |
| 2739 | if (line_out_type == AUTO_PIN_HP_OUT) |
| 2740 | return PIN_HP; |
| 2741 | else |
| 2742 | return PIN_OUT; |
| 2743 | } |
| 2744 | |
Takashi Iwai | 0a7f532 | 2011-07-06 15:15:12 +0200 | [diff] [blame] | 2745 | static void alc_auto_init_analog_input(struct hda_codec *codec) |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2746 | { |
| 2747 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2748 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2749 | int i; |
| 2750 | |
Takashi Iwai | 66ceeb6 | 2010-08-30 13:05:52 +0200 | [diff] [blame] | 2751 | for (i = 0; i < cfg->num_inputs; i++) { |
| 2752 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 6234399 | 2012-12-18 09:06:01 +0100 | [diff] [blame] | 2753 | if (alc_is_input_pin(codec, nid)) |
Takashi Iwai | 30ea098 | 2010-09-16 18:47:56 +0200 | [diff] [blame] | 2754 | alc_set_input_pin(codec, nid, cfg->inputs[i].type); |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2755 | |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2756 | /* mute loopback inputs */ |
| 2757 | if (spec->mixer_nid) { |
| 2758 | struct nid_path *path; |
| 2759 | path = get_nid_path(codec, nid, spec->mixer_nid); |
| 2760 | if (path) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 2761 | activate_path(codec, path, path->active, false); |
Takashi Iwai | 829f69e | 2012-12-14 18:26:02 +0100 | [diff] [blame] | 2762 | } |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 2763 | } |
Takashi Iwai | e9edcee | 2005-06-13 14:16:38 +0200 | [diff] [blame] | 2764 | } |
| 2765 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2766 | static bool alc_is_dac_already_used(struct hda_codec *codec, hda_nid_t nid) |
| 2767 | { |
| 2768 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2769 | int i; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2770 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2771 | for (i = 0; i < spec->paths.used; i++) { |
| 2772 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2773 | if (path->path[0] == nid) |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2774 | return true; |
| 2775 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2776 | return false; |
| 2777 | } |
| 2778 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2779 | /* look for an empty DAC slot */ |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2780 | static hda_nid_t alc_auto_look_for_dac(struct hda_codec *codec, hda_nid_t pin, |
| 2781 | bool is_digital) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2782 | { |
| 2783 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2784 | bool cap_digital; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2785 | int i; |
| 2786 | |
| 2787 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2788 | hda_nid_t nid = spec->all_dacs[i]; |
| 2789 | if (!nid || alc_is_dac_already_used(codec, nid)) |
| 2790 | continue; |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 2791 | cap_digital = !!(get_wcaps(codec, nid) & AC_WCAP_DIGITAL); |
| 2792 | if (is_digital != cap_digital) |
| 2793 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 2794 | if (is_reachable_path(codec, nid, pin)) |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2795 | return nid; |
| 2796 | } |
| 2797 | return 0; |
| 2798 | } |
| 2799 | |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2800 | /* called recursively */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2801 | static bool __parse_nid_path(struct hda_codec *codec, |
| 2802 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 2803 | int with_aa_mix, struct nid_path *path, int depth) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2804 | { |
| 2805 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2806 | hda_nid_t conn[16]; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2807 | int i, nums; |
| 2808 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2809 | if (to_nid == spec->mixer_nid) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2810 | if (!with_aa_mix) |
| 2811 | return false; |
| 2812 | with_aa_mix = 2; /* mark aa-mix is included */ |
| 2813 | } |
| 2814 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2815 | nums = snd_hda_get_connections(codec, to_nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2816 | for (i = 0; i < nums; i++) { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2817 | if (conn[i] != from_nid) { |
| 2818 | /* special case: when from_nid is 0, |
| 2819 | * try to find an empty DAC |
| 2820 | */ |
| 2821 | if (from_nid || |
| 2822 | get_wcaps_type(get_wcaps(codec, conn[i])) != AC_WID_AUD_OUT || |
| 2823 | alc_is_dac_already_used(codec, conn[i])) |
| 2824 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2825 | } |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2826 | /* aa-mix is requested but not included? */ |
| 2827 | if (!(spec->mixer_nid && with_aa_mix == 1)) |
| 2828 | goto found; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2829 | } |
| 2830 | if (depth >= MAX_NID_PATH_DEPTH) |
| 2831 | return false; |
| 2832 | for (i = 0; i < nums; i++) { |
| 2833 | unsigned int type; |
| 2834 | type = get_wcaps_type(get_wcaps(codec, conn[i])); |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2835 | if (type == AC_WID_AUD_OUT || type == AC_WID_AUD_IN || |
| 2836 | type == AC_WID_PIN) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2837 | continue; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2838 | if (__parse_nid_path(codec, from_nid, conn[i], |
| 2839 | with_aa_mix, path, depth + 1)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2840 | goto found; |
| 2841 | } |
| 2842 | return false; |
| 2843 | |
| 2844 | found: |
| 2845 | path->path[path->depth] = conn[i]; |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2846 | path->idx[path->depth + 1] = i; |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2847 | if (nums > 1 && get_wcaps_type(get_wcaps(codec, to_nid)) != AC_WID_AUD_MIX) |
Takashi Iwai | 95e960c | 2012-12-10 17:27:57 +0100 | [diff] [blame] | 2848 | path->multi[path->depth + 1] = 1; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2849 | path->depth++; |
| 2850 | return true; |
| 2851 | } |
| 2852 | |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2853 | /* parse the widget path from the given nid to the target nid; |
| 2854 | * when @from_nid is 0, try to find an empty DAC; |
| 2855 | * when @with_aa_mix is 0, paths with spec->mixer_nid are excluded. |
| 2856 | * when @with_aa_mix is 1, paths without spec->mixer_nid are excluded. |
| 2857 | * when @with_aa_mix is 2, no special handling about spec->mixer_nid. |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2858 | */ |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2859 | static bool parse_nid_path(struct hda_codec *codec, hda_nid_t from_nid, |
| 2860 | hda_nid_t to_nid, int with_aa_mix, |
| 2861 | struct nid_path *path) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2862 | { |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2863 | if (__parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path, 1)) { |
| 2864 | path->path[path->depth] = to_nid; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2865 | path->depth++; |
| 2866 | #if 0 |
Takashi Iwai | 36f0fd5 | 2012-12-12 17:25:00 +0100 | [diff] [blame] | 2867 | snd_printdd("path: depth=%d, %02x/%02x/%02x/%02x/%02x\n", |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2868 | path->depth, path->path[0], path->path[1], |
| 2869 | path->path[2], path->path[3], path->path[4]); |
| 2870 | #endif |
| 2871 | return true; |
| 2872 | } |
| 2873 | return false; |
| 2874 | } |
| 2875 | |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2876 | static hda_nid_t get_dac_if_single(struct hda_codec *codec, hda_nid_t pin) |
| 2877 | { |
Takashi Iwai | 140547e | 2012-02-16 17:23:46 +0100 | [diff] [blame] | 2878 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 2879 | int i; |
| 2880 | hda_nid_t nid_found = 0; |
| 2881 | |
| 2882 | for (i = 0; i < spec->num_all_dacs; i++) { |
| 2883 | hda_nid_t nid = spec->all_dacs[i]; |
| 2884 | if (!nid || alc_is_dac_already_used(codec, nid)) |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2885 | continue; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 2886 | if (is_reachable_path(codec, nid, pin)) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 2887 | if (nid_found) |
| 2888 | return 0; |
| 2889 | nid_found = nid; |
| 2890 | } |
| 2891 | } |
| 2892 | return nid_found; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 2893 | } |
| 2894 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2895 | static bool is_ctl_used(struct hda_codec *codec, unsigned int val, int type) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2896 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2897 | struct alc_spec *spec = codec->spec; |
| 2898 | int i; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2899 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2900 | for (i = 0; i < spec->paths.used; i++) { |
| 2901 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2902 | if (path->ctls[type] == val) |
| 2903 | return true; |
| 2904 | } |
| 2905 | return false; |
| 2906 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2907 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2908 | /* badness definition */ |
| 2909 | enum { |
| 2910 | /* No primary DAC is found for the main output */ |
| 2911 | BAD_NO_PRIMARY_DAC = 0x10000, |
| 2912 | /* No DAC is found for the extra output */ |
| 2913 | BAD_NO_DAC = 0x4000, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2914 | /* No possible multi-ios */ |
| 2915 | BAD_MULTI_IO = 0x103, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2916 | /* No individual DAC for extra output */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2917 | BAD_NO_EXTRA_DAC = 0x102, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2918 | /* No individual DAC for extra surrounds */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2919 | BAD_NO_EXTRA_SURR_DAC = 0x101, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2920 | /* Primary DAC shared with main surrounds */ |
| 2921 | BAD_SHARED_SURROUND = 0x100, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2922 | /* Primary DAC shared with main CLFE */ |
| 2923 | BAD_SHARED_CLFE = 0x10, |
| 2924 | /* Primary DAC shared with extra surrounds */ |
| 2925 | BAD_SHARED_EXTRA_SURROUND = 0x10, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 2926 | /* Volume widget is shared */ |
| 2927 | BAD_SHARED_VOL = 0x10, |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2928 | }; |
| 2929 | |
| 2930 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2931 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2932 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2933 | struct nid_path *path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2934 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2935 | static struct nid_path *add_new_nid_path(struct hda_codec *codec, |
| 2936 | hda_nid_t from_nid, hda_nid_t to_nid, |
| 2937 | int with_aa_mix) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2938 | { |
| 2939 | struct alc_spec *spec = codec->spec; |
| 2940 | struct nid_path *path; |
| 2941 | |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2942 | if (from_nid && to_nid && !is_reachable_path(codec, from_nid, to_nid)) |
| 2943 | return NULL; |
| 2944 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2945 | path = snd_array_new(&spec->paths); |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2946 | if (!path) |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2947 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2948 | memset(path, 0, sizeof(*path)); |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2949 | if (parse_nid_path(codec, from_nid, to_nid, with_aa_mix, path)) |
| 2950 | return path; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2951 | /* push back */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2952 | spec->paths.used--; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 2953 | return NULL; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 2954 | } |
| 2955 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 2956 | /* get the path between the given NIDs; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2957 | * passing 0 to either @pin or @dac behaves as a wildcard |
| 2958 | */ |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 2959 | static struct nid_path * |
| 2960 | get_nid_path(struct hda_codec *codec, hda_nid_t from_nid, hda_nid_t to_nid) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2961 | { |
| 2962 | struct alc_spec *spec = codec->spec; |
| 2963 | int i; |
| 2964 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 2965 | for (i = 0; i < spec->paths.used; i++) { |
| 2966 | struct nid_path *path = snd_array_elem(&spec->paths, i); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2967 | if (path->depth <= 0) |
| 2968 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 2969 | if ((!from_nid || path->path[0] == from_nid) && |
| 2970 | (!to_nid || path->path[path->depth - 1] == to_nid)) |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2971 | return path; |
| 2972 | } |
| 2973 | return NULL; |
| 2974 | } |
| 2975 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 2976 | /* look for widgets in the path between the given NIDs appropriate for |
| 2977 | * volume and mute controls, and assign the values to ctls[]. |
| 2978 | * |
| 2979 | * When no appropriate widget is found in the path, the badness value |
| 2980 | * is incremented depending on the situation. The function returns the |
| 2981 | * total badness for both volume and mute controls. |
| 2982 | */ |
| 2983 | static int assign_out_path_ctls(struct hda_codec *codec, hda_nid_t pin, |
| 2984 | hda_nid_t dac) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2985 | { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 2986 | struct nid_path *path = get_nid_path(codec, dac, pin); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2987 | hda_nid_t nid; |
| 2988 | unsigned int val; |
| 2989 | int badness = 0; |
| 2990 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2991 | if (!path) |
| 2992 | return BAD_SHARED_VOL * 2; |
| 2993 | nid = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2994 | if (nid) { |
| 2995 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2996 | if (is_ctl_used(codec, val, NID_PATH_VOL_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 2997 | badness += BAD_SHARED_VOL; |
| 2998 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 2999 | path->ctls[NID_PATH_VOL_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3000 | } else |
| 3001 | badness += BAD_SHARED_VOL; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3002 | nid = alc_look_for_out_mute_nid(codec, path); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3003 | if (nid) { |
| 3004 | unsigned int wid_type = get_wcaps_type(get_wcaps(codec, nid)); |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3005 | if (wid_type == AC_WID_PIN || wid_type == AC_WID_AUD_OUT || |
| 3006 | nid_has_mute(codec, nid, HDA_OUTPUT)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3007 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT); |
| 3008 | else |
| 3009 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3010 | if (is_ctl_used(codec, val, NID_PATH_MUTE_CTL)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3011 | badness += BAD_SHARED_VOL; |
| 3012 | else |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3013 | path->ctls[NID_PATH_MUTE_CTL] = val; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3014 | } else |
| 3015 | badness += BAD_SHARED_VOL; |
| 3016 | return badness; |
| 3017 | } |
| 3018 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3019 | struct badness_table { |
| 3020 | int no_primary_dac; /* no primary DAC */ |
| 3021 | int no_dac; /* no secondary DACs */ |
| 3022 | int shared_primary; /* primary DAC is shared with main output */ |
| 3023 | int shared_surr; /* secondary DAC shared with main or primary */ |
| 3024 | int shared_clfe; /* third DAC shared with main or primary */ |
| 3025 | int shared_surr_main; /* secondary DAC sahred with main/DAC0 */ |
| 3026 | }; |
| 3027 | |
| 3028 | static struct badness_table main_out_badness = { |
| 3029 | .no_primary_dac = BAD_NO_PRIMARY_DAC, |
| 3030 | .no_dac = BAD_NO_DAC, |
| 3031 | .shared_primary = BAD_NO_PRIMARY_DAC, |
| 3032 | .shared_surr = BAD_SHARED_SURROUND, |
| 3033 | .shared_clfe = BAD_SHARED_CLFE, |
| 3034 | .shared_surr_main = BAD_SHARED_SURROUND, |
| 3035 | }; |
| 3036 | |
| 3037 | static struct badness_table extra_out_badness = { |
| 3038 | .no_primary_dac = BAD_NO_DAC, |
| 3039 | .no_dac = BAD_NO_DAC, |
| 3040 | .shared_primary = BAD_NO_EXTRA_DAC, |
| 3041 | .shared_surr = BAD_SHARED_EXTRA_SURROUND, |
| 3042 | .shared_clfe = BAD_SHARED_EXTRA_SURROUND, |
| 3043 | .shared_surr_main = BAD_NO_EXTRA_SURR_DAC, |
| 3044 | }; |
| 3045 | |
| 3046 | /* try to assign DACs to pins and return the resultant badness */ |
| 3047 | static int alc_auto_fill_dacs(struct hda_codec *codec, int num_outs, |
| 3048 | const hda_nid_t *pins, hda_nid_t *dacs, |
| 3049 | const struct badness_table *bad) |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3050 | { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3051 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3052 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3053 | int i, j; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3054 | int badness = 0; |
| 3055 | hda_nid_t dac; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3056 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3057 | if (!num_outs) |
| 3058 | return 0; |
| 3059 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3060 | for (i = 0; i < num_outs; i++) { |
| 3061 | hda_nid_t pin = pins[i]; |
| 3062 | if (!dacs[i]) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 3063 | dacs[i] = alc_auto_look_for_dac(codec, pin, false); |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3064 | if (!dacs[i] && !i) { |
| 3065 | for (j = 1; j < num_outs; j++) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3066 | if (is_reachable_path(codec, dacs[j], pin)) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3067 | dacs[0] = dacs[j]; |
| 3068 | dacs[j] = 0; |
| 3069 | break; |
| 3070 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3071 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3072 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3073 | dac = dacs[i]; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3074 | if (!dac) { |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3075 | if (is_reachable_path(codec, dacs[0], pin)) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3076 | dac = dacs[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3077 | else if (cfg->line_outs > i && |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3078 | is_reachable_path(codec, spec->private_dac_nids[i], pin)) |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3079 | dac = spec->private_dac_nids[i]; |
| 3080 | if (dac) { |
| 3081 | if (!i) |
| 3082 | badness += bad->shared_primary; |
| 3083 | else if (i == 1) |
| 3084 | badness += bad->shared_surr; |
| 3085 | else |
| 3086 | badness += bad->shared_clfe; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 3087 | } else if (is_reachable_path(codec, spec->private_dac_nids[0], pin)) { |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3088 | dac = spec->private_dac_nids[0]; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3089 | badness += bad->shared_surr_main; |
| 3090 | } else if (!i) |
| 3091 | badness += bad->no_primary_dac; |
| 3092 | else |
| 3093 | badness += bad->no_dac; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3094 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3095 | if (!add_new_nid_path(codec, dac, pin, 0)) |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3096 | dac = dacs[i] = 0; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3097 | if (dac) |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3098 | badness += assign_out_path_ctls(codec, pin, dac); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3099 | } |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3100 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3101 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3102 | } |
| 3103 | |
| 3104 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3105 | hda_nid_t reference_pin, |
| 3106 | bool hardwired, int offset); |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3107 | |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3108 | static bool alc_map_singles(struct hda_codec *codec, int outs, |
| 3109 | const hda_nid_t *pins, hda_nid_t *dacs) |
| 3110 | { |
| 3111 | int i; |
| 3112 | bool found = false; |
| 3113 | for (i = 0; i < outs; i++) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3114 | hda_nid_t dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3115 | if (dacs[i]) |
| 3116 | continue; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3117 | dac = get_dac_if_single(codec, pins[i]); |
| 3118 | if (!dac) |
| 3119 | continue; |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 3120 | if (add_new_nid_path(codec, dac, pins[i], 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3121 | dacs[i] = dac; |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3122 | found = true; |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 3123 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3124 | } |
| 3125 | return found; |
| 3126 | } |
| 3127 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3128 | /* fill in the dac_nids table from the parsed pin configuration */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3129 | static int fill_and_eval_dacs(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3130 | bool fill_hardwired, |
| 3131 | bool fill_mio_first) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3132 | { |
| 3133 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3134 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3135 | int i, err, badness; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3136 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3137 | /* set num_dacs once to full for alc_auto_look_for_dac() */ |
| 3138 | spec->multiout.num_dacs = cfg->line_outs; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3139 | spec->multiout.dac_nids = spec->private_dac_nids; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3140 | memset(spec->private_dac_nids, 0, sizeof(spec->private_dac_nids)); |
| 3141 | memset(spec->multiout.hp_out_nid, 0, sizeof(spec->multiout.hp_out_nid)); |
| 3142 | 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] | 3143 | spec->multi_ios = 0; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3144 | snd_array_free(&spec->paths); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3145 | badness = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3146 | |
| 3147 | /* fill hard-wired DACs first */ |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3148 | if (fill_hardwired) { |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3149 | bool mapped; |
| 3150 | do { |
| 3151 | mapped = alc_map_singles(codec, cfg->line_outs, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3152 | cfg->line_out_pins, |
| 3153 | spec->private_dac_nids); |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3154 | mapped |= alc_map_singles(codec, cfg->hp_outs, |
| 3155 | cfg->hp_pins, |
| 3156 | spec->multiout.hp_out_nid); |
| 3157 | mapped |= alc_map_singles(codec, cfg->speaker_outs, |
| 3158 | cfg->speaker_pins, |
| 3159 | spec->multiout.extra_out_nid); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3160 | if (fill_mio_first && cfg->line_outs == 1 && |
| 3161 | cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3162 | err = alc_auto_fill_multi_ios(codec, cfg->line_out_pins[0], true, 0); |
| 3163 | if (!err) |
| 3164 | mapped = true; |
| 3165 | } |
Takashi Iwai | 185d99f | 2012-02-16 18:39:45 +0100 | [diff] [blame] | 3166 | } while (mapped); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3167 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3168 | |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3169 | badness += alc_auto_fill_dacs(codec, cfg->line_outs, cfg->line_out_pins, |
| 3170 | spec->private_dac_nids, |
| 3171 | &main_out_badness); |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3172 | |
Takashi Iwai | 8f398ae | 2011-07-23 18:57:11 +0200 | [diff] [blame] | 3173 | /* re-count num_dacs and squash invalid entries */ |
| 3174 | spec->multiout.num_dacs = 0; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3175 | for (i = 0; i < cfg->line_outs; i++) { |
| 3176 | if (spec->private_dac_nids[i]) |
| 3177 | spec->multiout.num_dacs++; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3178 | else { |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3179 | memmove(spec->private_dac_nids + i, |
| 3180 | spec->private_dac_nids + i + 1, |
| 3181 | sizeof(hda_nid_t) * (cfg->line_outs - i - 1)); |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3182 | spec->private_dac_nids[cfg->line_outs - 1] = 0; |
| 3183 | } |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3184 | } |
| 3185 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3186 | if (fill_mio_first && |
| 3187 | cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3188 | /* try to fill multi-io first */ |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3189 | 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] | 3190 | if (err < 0) |
| 3191 | return err; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3192 | /* we don't count badness at this stage yet */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3193 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3194 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3195 | if (cfg->line_out_type != AUTO_PIN_HP_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3196 | err = alc_auto_fill_dacs(codec, cfg->hp_outs, cfg->hp_pins, |
| 3197 | spec->multiout.hp_out_nid, |
| 3198 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3199 | if (err < 0) |
| 3200 | return err; |
| 3201 | badness += err; |
| 3202 | } |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3203 | if (cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
Takashi Iwai | dc31b58 | 2012-02-17 17:27:53 +0100 | [diff] [blame] | 3204 | err = alc_auto_fill_dacs(codec, cfg->speaker_outs, |
| 3205 | cfg->speaker_pins, |
| 3206 | spec->multiout.extra_out_nid, |
| 3207 | &extra_out_badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3208 | if (err < 0) |
| 3209 | return err; |
| 3210 | badness += err; |
| 3211 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3212 | if (cfg->line_outs == 1 && cfg->line_out_type != AUTO_PIN_SPEAKER_OUT) { |
| 3213 | 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] | 3214 | if (err < 0) |
| 3215 | return err; |
| 3216 | badness += err; |
| 3217 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3218 | if (cfg->hp_outs && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3219 | /* try multi-ios with HP + inputs */ |
Takashi Iwai | f568291 | 2012-02-21 12:37:00 +0100 | [diff] [blame] | 3220 | int offset = 0; |
| 3221 | if (cfg->line_outs >= 3) |
| 3222 | offset = 1; |
| 3223 | err = alc_auto_fill_multi_ios(codec, cfg->hp_pins[0], false, |
| 3224 | offset); |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3225 | if (err < 0) |
| 3226 | return err; |
| 3227 | badness += err; |
| 3228 | } |
| 3229 | |
| 3230 | if (spec->multi_ios == 2) { |
| 3231 | for (i = 0; i < 2; i++) |
| 3232 | spec->private_dac_nids[spec->multiout.num_dacs++] = |
| 3233 | spec->multi_io[i].dac; |
| 3234 | spec->ext_channel_count = 2; |
| 3235 | } else if (spec->multi_ios) { |
| 3236 | spec->multi_ios = 0; |
| 3237 | badness += BAD_MULTI_IO; |
| 3238 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3239 | |
| 3240 | return badness; |
| 3241 | } |
| 3242 | |
| 3243 | #define DEBUG_BADNESS |
| 3244 | |
| 3245 | #ifdef DEBUG_BADNESS |
| 3246 | #define debug_badness snd_printdd |
| 3247 | #else |
| 3248 | #define debug_badness(...) |
| 3249 | #endif |
| 3250 | |
| 3251 | static void debug_show_configs(struct alc_spec *spec, struct auto_pin_cfg *cfg) |
| 3252 | { |
| 3253 | debug_badness("multi_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3254 | cfg->line_out_pins[0], cfg->line_out_pins[1], |
| 3255 | cfg->line_out_pins[2], cfg->line_out_pins[2], |
| 3256 | spec->multiout.dac_nids[0], |
| 3257 | spec->multiout.dac_nids[1], |
| 3258 | spec->multiout.dac_nids[2], |
| 3259 | spec->multiout.dac_nids[3]); |
Takashi Iwai | 6f45304 | 2012-02-17 14:09:20 +0100 | [diff] [blame] | 3260 | if (spec->multi_ios > 0) |
| 3261 | debug_badness("multi_ios(%d) = %x/%x : %x/%x\n", |
| 3262 | spec->multi_ios, |
| 3263 | spec->multi_io[0].pin, spec->multi_io[1].pin, |
| 3264 | spec->multi_io[0].dac, spec->multi_io[1].dac); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3265 | debug_badness("hp_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3266 | cfg->hp_pins[0], cfg->hp_pins[1], |
| 3267 | cfg->hp_pins[2], cfg->hp_pins[2], |
| 3268 | spec->multiout.hp_out_nid[0], |
| 3269 | spec->multiout.hp_out_nid[1], |
| 3270 | spec->multiout.hp_out_nid[2], |
| 3271 | spec->multiout.hp_out_nid[3]); |
| 3272 | debug_badness("spk_outs = %x/%x/%x/%x : %x/%x/%x/%x\n", |
| 3273 | cfg->speaker_pins[0], cfg->speaker_pins[1], |
| 3274 | cfg->speaker_pins[2], cfg->speaker_pins[3], |
| 3275 | spec->multiout.extra_out_nid[0], |
| 3276 | spec->multiout.extra_out_nid[1], |
| 3277 | spec->multiout.extra_out_nid[2], |
| 3278 | spec->multiout.extra_out_nid[3]); |
| 3279 | } |
| 3280 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3281 | /* find all available DACs of the codec */ |
| 3282 | static void alc_fill_all_nids(struct hda_codec *codec) |
| 3283 | { |
| 3284 | struct alc_spec *spec = codec->spec; |
| 3285 | int i; |
| 3286 | hda_nid_t nid = codec->start_nid; |
| 3287 | |
| 3288 | spec->num_all_dacs = 0; |
| 3289 | memset(spec->all_dacs, 0, sizeof(spec->all_dacs)); |
| 3290 | for (i = 0; i < codec->num_nodes; i++, nid++) { |
| 3291 | if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_AUD_OUT) |
| 3292 | continue; |
| 3293 | if (spec->num_all_dacs >= ARRAY_SIZE(spec->all_dacs)) { |
| 3294 | snd_printk(KERN_ERR "hda: Too many DACs!\n"); |
| 3295 | break; |
| 3296 | } |
| 3297 | spec->all_dacs[spec->num_all_dacs++] = nid; |
| 3298 | } |
| 3299 | } |
| 3300 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3301 | static int alc_auto_fill_dac_nids(struct hda_codec *codec) |
| 3302 | { |
| 3303 | struct alc_spec *spec = codec->spec; |
| 3304 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 3305 | struct auto_pin_cfg *best_cfg; |
| 3306 | int best_badness = INT_MAX; |
| 3307 | int badness; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3308 | bool fill_hardwired = true, fill_mio_first = true; |
| 3309 | bool best_wired = true, best_mio = true; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3310 | bool hp_spk_swapped = false; |
| 3311 | |
Takashi Iwai | 463419d | 2012-12-05 14:17:37 +0100 | [diff] [blame] | 3312 | alc_fill_all_nids(codec); |
| 3313 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3314 | best_cfg = kmalloc(sizeof(*best_cfg), GFP_KERNEL); |
| 3315 | if (!best_cfg) |
| 3316 | return -ENOMEM; |
| 3317 | *best_cfg = *cfg; |
| 3318 | |
| 3319 | for (;;) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3320 | badness = fill_and_eval_dacs(codec, fill_hardwired, |
| 3321 | fill_mio_first); |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3322 | if (badness < 0) { |
| 3323 | kfree(best_cfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3324 | return badness; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3325 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3326 | debug_badness("==> lo_type=%d, wired=%d, mio=%d, badness=0x%x\n", |
| 3327 | cfg->line_out_type, fill_hardwired, fill_mio_first, |
| 3328 | badness); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3329 | debug_show_configs(spec, cfg); |
| 3330 | if (badness < best_badness) { |
| 3331 | best_badness = badness; |
| 3332 | *best_cfg = *cfg; |
| 3333 | best_wired = fill_hardwired; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3334 | best_mio = fill_mio_first; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3335 | } |
| 3336 | if (!badness) |
| 3337 | break; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3338 | fill_mio_first = !fill_mio_first; |
| 3339 | if (!fill_mio_first) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3340 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3341 | fill_hardwired = !fill_hardwired; |
| 3342 | if (!fill_hardwired) |
| 3343 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3344 | if (hp_spk_swapped) |
| 3345 | break; |
| 3346 | hp_spk_swapped = true; |
| 3347 | if (cfg->speaker_outs > 0 && |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3348 | cfg->line_out_type == AUTO_PIN_HP_OUT) { |
| 3349 | cfg->hp_outs = cfg->line_outs; |
| 3350 | memcpy(cfg->hp_pins, cfg->line_out_pins, |
| 3351 | sizeof(cfg->hp_pins)); |
| 3352 | cfg->line_outs = cfg->speaker_outs; |
| 3353 | memcpy(cfg->line_out_pins, cfg->speaker_pins, |
| 3354 | sizeof(cfg->speaker_pins)); |
| 3355 | cfg->speaker_outs = 0; |
| 3356 | memset(cfg->speaker_pins, 0, sizeof(cfg->speaker_pins)); |
| 3357 | cfg->line_out_type = AUTO_PIN_SPEAKER_OUT; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3358 | fill_hardwired = true; |
| 3359 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3360 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3361 | if (cfg->hp_outs > 0 && |
| 3362 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { |
| 3363 | cfg->speaker_outs = cfg->line_outs; |
| 3364 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 3365 | sizeof(cfg->speaker_pins)); |
| 3366 | cfg->line_outs = cfg->hp_outs; |
| 3367 | memcpy(cfg->line_out_pins, cfg->hp_pins, |
| 3368 | sizeof(cfg->hp_pins)); |
| 3369 | cfg->hp_outs = 0; |
| 3370 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 3371 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 3372 | fill_hardwired = true; |
| 3373 | continue; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 3374 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3375 | break; |
Takashi Iwai | 0a34b42 | 2011-12-07 17:20:30 +0100 | [diff] [blame] | 3376 | } |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 3377 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3378 | if (badness) { |
| 3379 | *cfg = *best_cfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3380 | fill_and_eval_dacs(codec, best_wired, best_mio); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3381 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3382 | debug_badness("==> Best config: lo_type=%d, wired=%d, mio=%d\n", |
| 3383 | cfg->line_out_type, best_wired, best_mio); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3384 | debug_show_configs(spec, cfg); |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3385 | |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3386 | if (cfg->line_out_pins[0]) { |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3387 | struct nid_path *path = get_nid_path(codec, |
| 3388 | spec->multiout.dac_nids[0], |
| 3389 | cfg->line_out_pins[0]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3390 | if (path) |
| 3391 | spec->vmaster_nid = alc_look_for_out_vol_nid(codec, path); |
| 3392 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3393 | |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3394 | kfree(best_cfg); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3395 | return 0; |
| 3396 | } |
| 3397 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3398 | /* replace the channels in the composed amp value with the given number */ |
| 3399 | static unsigned int amp_val_replace_channels(unsigned int val, unsigned int chs) |
| 3400 | { |
| 3401 | val &= ~(0x3U << 16); |
| 3402 | val |= chs << 16; |
| 3403 | return val; |
| 3404 | } |
| 3405 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3406 | static int alc_auto_add_vol_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3407 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3408 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3409 | struct nid_path *path) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3410 | { |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3411 | unsigned int val; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3412 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3413 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3414 | val = path->ctls[NID_PATH_VOL_CTL]; |
| 3415 | if (!val) |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3416 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3417 | val = amp_val_replace_channels(val, chs); |
| 3418 | return __add_pb_vol_ctrl(codec->spec, ALC_CTL_WIDGET_VOL, pfx, cidx, val); |
| 3419 | } |
| 3420 | |
| 3421 | /* return the channel bits suitable for the given path->ctls[] */ |
| 3422 | static int get_default_ch_nums(struct hda_codec *codec, struct nid_path *path, |
| 3423 | int type) |
| 3424 | { |
| 3425 | int chs = 1; /* mono (left only) */ |
| 3426 | if (path) { |
| 3427 | hda_nid_t nid = get_amp_nid_(path->ctls[type]); |
| 3428 | if (nid && (get_wcaps(codec, nid) & AC_WCAP_STEREO)) |
| 3429 | chs = 3; /* stereo */ |
| 3430 | } |
| 3431 | return chs; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3432 | } |
| 3433 | |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3434 | static int alc_auto_add_stereo_vol(struct hda_codec *codec, |
| 3435 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3436 | struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3437 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3438 | int chs = get_default_ch_nums(codec, path, NID_PATH_VOL_CTL); |
| 3439 | return alc_auto_add_vol_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3440 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3441 | |
| 3442 | /* create a mute-switch for the given mixer widget; |
| 3443 | * if it has multiple sources (e.g. DAC and loopback), create a bind-mute |
| 3444 | */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3445 | static int alc_auto_add_sw_ctl(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3446 | const char *pfx, int cidx, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3447 | unsigned int chs, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3448 | struct nid_path *path) |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3449 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3450 | unsigned int val; |
| 3451 | int type = ALC_CTL_WIDGET_MUTE; |
| 3452 | |
| 3453 | if (!path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3454 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3455 | val = path->ctls[NID_PATH_MUTE_CTL]; |
| 3456 | if (!val) |
| 3457 | return 0; |
| 3458 | val = amp_val_replace_channels(val, chs); |
| 3459 | if (get_amp_direction_(val) == HDA_INPUT) { |
| 3460 | hda_nid_t nid = get_amp_nid_(val); |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3461 | int nums = snd_hda_get_num_conns(codec, nid); |
| 3462 | if (nums > 1) { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3463 | type = ALC_CTL_BIND_MUTE; |
Takashi Iwai | 9366ede | 2012-12-13 16:43:52 +0100 | [diff] [blame] | 3464 | val |= nums << 19; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3465 | } |
Takashi Iwai | 97aaab7 | 2011-07-06 14:02:55 +0200 | [diff] [blame] | 3466 | } |
| 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, |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3471 | int cidx, struct nid_path *path) |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3472 | { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3473 | int chs = get_default_ch_nums(codec, path, NID_PATH_MUTE_CTL); |
| 3474 | return alc_auto_add_sw_ctl(codec, pfx, cidx, chs, path); |
Takashi Iwai | e29d377 | 2011-11-14 17:13:23 +0100 | [diff] [blame] | 3475 | } |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3476 | |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3477 | static hda_nid_t alc_look_for_out_mute_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3478 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3479 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3480 | int i; |
| 3481 | |
| 3482 | for (i = path->depth - 1; i >= 0; i--) { |
| 3483 | if (nid_has_mute(codec, path->path[i], HDA_OUTPUT)) |
| 3484 | return path->path[i]; |
| 3485 | if (i != path->depth - 1 && i != 0 && |
| 3486 | nid_has_mute(codec, path->path[i], HDA_INPUT)) |
| 3487 | return path->path[i]; |
| 3488 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3489 | return 0; |
| 3490 | } |
| 3491 | |
| 3492 | static hda_nid_t alc_look_for_out_vol_nid(struct hda_codec *codec, |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3493 | struct nid_path *path) |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3494 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3495 | int i; |
| 3496 | |
| 3497 | for (i = path->depth - 1; i >= 0; i--) { |
| 3498 | if (nid_has_volume(codec, path->path[i], HDA_OUTPUT)) |
| 3499 | return path->path[i]; |
| 3500 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3501 | return 0; |
| 3502 | } |
| 3503 | |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3504 | /* add playback controls from the parsed DAC table */ |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3505 | static int alc_auto_create_multi_out_ctls(struct hda_codec *codec, |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3506 | const struct auto_pin_cfg *cfg) |
| 3507 | { |
| 3508 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3509 | int i, err, noutputs; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3510 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3511 | noutputs = cfg->line_outs; |
Takashi Iwai | b90bf1d | 2012-01-19 11:42:55 +0100 | [diff] [blame] | 3512 | if (spec->multi_ios > 0 && cfg->line_outs < 3) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3513 | noutputs += spec->multi_ios; |
| 3514 | |
| 3515 | for (i = 0; i < noutputs; i++) { |
Takashi Iwai | 6843ca1 | 2011-06-24 11:03:58 +0200 | [diff] [blame] | 3516 | const char *name; |
| 3517 | int index; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3518 | hda_nid_t dac, pin; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3519 | struct nid_path *path; |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3520 | |
| 3521 | dac = spec->multiout.dac_nids[i]; |
| 3522 | if (!dac) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3523 | continue; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3524 | if (i >= cfg->line_outs) { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3525 | pin = spec->multi_io[i - 1].pin; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3526 | index = 0; |
| 3527 | name = channel_name[i]; |
| 3528 | } else { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3529 | pin = cfg->line_out_pins[i]; |
Takashi Iwai | 689cabf | 2012-02-21 12:35:27 +0100 | [diff] [blame] | 3530 | name = alc_get_line_out_pfx(spec, i, true, &index); |
| 3531 | } |
Takashi Iwai | afcd551 | 2011-07-08 11:07:59 +0200 | [diff] [blame] | 3532 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3533 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3534 | if (!path) |
| 3535 | continue; |
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 | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3538 | err = alc_auto_add_vol_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3539 | if (err < 0) |
| 3540 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3541 | err = alc_auto_add_vol_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3542 | if (err < 0) |
| 3543 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3544 | err = alc_auto_add_sw_ctl(codec, "Center", 0, 1, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3545 | if (err < 0) |
| 3546 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3547 | err = alc_auto_add_sw_ctl(codec, "LFE", 0, 2, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3548 | if (err < 0) |
| 3549 | return err; |
| 3550 | } else { |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3551 | err = alc_auto_add_stereo_vol(codec, name, index, path); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3552 | if (err < 0) |
| 3553 | return err; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3554 | err = alc_auto_add_stereo_sw(codec, name, index, path); |
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 | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3566 | struct nid_path *path; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3567 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3568 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3569 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3570 | if (!path) |
| 3571 | return 0; |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3572 | /* bind volume control will be created in the case of dac = 0 */ |
| 3573 | if (dac) { |
| 3574 | err = alc_auto_add_stereo_vol(codec, pfx, cidx, path); |
| 3575 | if (err < 0) |
| 3576 | return err; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3577 | } |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 3578 | err = alc_auto_add_stereo_sw(codec, pfx, cidx, path); |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3579 | if (err < 0) |
| 3580 | return err; |
Takashi Iwai | 3af9ee6 | 2011-06-27 12:34:01 +0200 | [diff] [blame] | 3581 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3582 | } |
| 3583 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3584 | static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, |
| 3585 | unsigned int nums, |
| 3586 | struct hda_ctl_ops *ops) |
| 3587 | { |
| 3588 | struct alc_spec *spec = codec->spec; |
| 3589 | struct hda_bind_ctls **ctlp, *ctl; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3590 | ctlp = snd_array_new(&spec->bind_ctls); |
| 3591 | if (!ctlp) |
| 3592 | return NULL; |
| 3593 | ctl = kzalloc(sizeof(*ctl) + sizeof(long) * (nums + 1), GFP_KERNEL); |
| 3594 | *ctlp = ctl; |
| 3595 | if (ctl) |
| 3596 | ctl->ops = ops; |
| 3597 | return ctl; |
| 3598 | } |
| 3599 | |
| 3600 | /* add playback controls for speaker and HP outputs */ |
| 3601 | static int alc_auto_create_extra_outs(struct hda_codec *codec, int num_pins, |
| 3602 | const hda_nid_t *pins, |
| 3603 | const hda_nid_t *dacs, |
| 3604 | const char *pfx) |
| 3605 | { |
| 3606 | struct alc_spec *spec = codec->spec; |
| 3607 | struct hda_bind_ctls *ctl; |
| 3608 | char name[32]; |
| 3609 | int i, n, err; |
| 3610 | |
| 3611 | if (!num_pins || !pins[0]) |
| 3612 | return 0; |
| 3613 | |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3614 | if (num_pins == 1) { |
| 3615 | hda_nid_t dac = *dacs; |
| 3616 | if (!dac) |
| 3617 | dac = spec->multiout.dac_nids[0]; |
Takashi Iwai | 766ddee | 2011-12-07 16:55:19 +0100 | [diff] [blame] | 3618 | return alc_auto_create_extra_out(codec, *pins, dac, pfx, 0); |
Takashi Iwai | 527e4d7 | 2011-10-27 16:33:27 +0200 | [diff] [blame] | 3619 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3620 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3621 | for (i = 0; i < num_pins; i++) { |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3622 | hda_nid_t dac; |
| 3623 | if (dacs[num_pins - 1]) |
| 3624 | dac = dacs[i]; /* with individual volumes */ |
| 3625 | else |
| 3626 | dac = 0; |
| 3627 | if (num_pins == 2 && i == 1 && !strcmp(pfx, "Speaker")) { |
| 3628 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3629 | "Bass Speaker", 0); |
| 3630 | } else if (num_pins >= 3) { |
| 3631 | snprintf(name, sizeof(name), "%s %s", |
| 3632 | pfx, channel_name[i]); |
| 3633 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3634 | name, 0); |
| 3635 | } else { |
| 3636 | err = alc_auto_create_extra_out(codec, pins[i], dac, |
| 3637 | pfx, i); |
| 3638 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3639 | if (err < 0) |
| 3640 | return err; |
| 3641 | } |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3642 | if (dacs[num_pins - 1]) |
| 3643 | return 0; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3644 | |
Takashi Iwai | c96f0bf | 2012-02-21 12:12:57 +0100 | [diff] [blame] | 3645 | /* Let's create a bind-controls for volumes */ |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3646 | ctl = new_bind_ctl(codec, num_pins, &snd_hda_bind_vol); |
| 3647 | if (!ctl) |
| 3648 | return -ENOMEM; |
| 3649 | n = 0; |
| 3650 | for (i = 0; i < num_pins; i++) { |
| 3651 | hda_nid_t vol; |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3652 | struct nid_path *path; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3653 | if (!pins[i] || !dacs[i]) |
| 3654 | continue; |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3655 | path = get_nid_path(codec, dacs[i], pins[i]); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3656 | if (!path) |
| 3657 | continue; |
| 3658 | vol = alc_look_for_out_vol_nid(codec, path); |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3659 | if (vol) |
| 3660 | ctl->values[n++] = |
| 3661 | HDA_COMPOSE_AMP_VAL(vol, 3, 0, HDA_OUTPUT); |
| 3662 | } |
| 3663 | if (n) { |
| 3664 | snprintf(name, sizeof(name), "%s Playback Volume", pfx); |
| 3665 | err = add_control(spec, ALC_CTL_BIND_VOL, name, 0, (long)ctl); |
| 3666 | if (err < 0) |
| 3667 | return err; |
| 3668 | } |
| 3669 | return 0; |
| 3670 | } |
| 3671 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3672 | static int alc_auto_create_hp_out(struct hda_codec *codec) |
| 3673 | { |
| 3674 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3675 | return alc_auto_create_extra_outs(codec, spec->autocfg.hp_outs, |
| 3676 | spec->autocfg.hp_pins, |
| 3677 | spec->multiout.hp_out_nid, |
| 3678 | "Headphone"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3679 | } |
| 3680 | |
| 3681 | static int alc_auto_create_speaker_out(struct hda_codec *codec) |
| 3682 | { |
| 3683 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 3684 | return alc_auto_create_extra_outs(codec, spec->autocfg.speaker_outs, |
| 3685 | spec->autocfg.speaker_pins, |
| 3686 | spec->multiout.extra_out_nid, |
| 3687 | "Speaker"); |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3688 | } |
| 3689 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3690 | /* check whether a control with the given (nid, dir, idx) was assigned */ |
| 3691 | static bool is_ctl_associated(struct hda_codec *codec, hda_nid_t nid, |
| 3692 | int dir, int idx) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3693 | { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3694 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3695 | int i, type; |
| 3696 | |
| 3697 | for (i = 0; i < spec->paths.used; i++) { |
| 3698 | struct nid_path *p = snd_array_elem(&spec->paths, i); |
| 3699 | if (p->depth <= 0) |
| 3700 | continue; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 3701 | for (type = 0; type < NID_PATH_NUM_CTLS; type++) { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3702 | unsigned int val = p->ctls[type]; |
| 3703 | if (get_amp_nid_(val) == nid && |
| 3704 | get_amp_direction_(val) == dir && |
| 3705 | get_amp_index_(val) == idx) |
| 3706 | return true; |
| 3707 | } |
| 3708 | } |
| 3709 | return false; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3710 | } |
| 3711 | |
| 3712 | /* can have the amp-in capability? */ |
| 3713 | static bool has_amp_in(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3714 | { |
| 3715 | hda_nid_t nid = path->path[idx]; |
| 3716 | unsigned int caps = get_wcaps(codec, nid); |
| 3717 | unsigned int type = get_wcaps_type(caps); |
| 3718 | |
| 3719 | if (!(caps & AC_WCAP_IN_AMP)) |
| 3720 | return false; |
| 3721 | if (type == AC_WID_PIN && idx > 0) /* only for input pins */ |
| 3722 | return false; |
| 3723 | return true; |
| 3724 | } |
| 3725 | |
| 3726 | /* can have the amp-out capability? */ |
| 3727 | static bool has_amp_out(struct hda_codec *codec, struct nid_path *path, int idx) |
| 3728 | { |
| 3729 | hda_nid_t nid = path->path[idx]; |
| 3730 | unsigned int caps = get_wcaps(codec, nid); |
| 3731 | unsigned int type = get_wcaps_type(caps); |
| 3732 | |
| 3733 | if (!(caps & AC_WCAP_OUT_AMP)) |
| 3734 | return false; |
| 3735 | if (type == AC_WID_PIN && !idx) /* only for output pins */ |
| 3736 | return false; |
| 3737 | return true; |
| 3738 | } |
| 3739 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3740 | /* check whether the given (nid,dir,idx) is active */ |
| 3741 | static bool is_active_nid(struct hda_codec *codec, hda_nid_t nid, |
| 3742 | unsigned int idx, unsigned int dir) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3743 | { |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3744 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3745 | int i, n; |
| 3746 | |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 3747 | for (n = 0; n < spec->paths.used; n++) { |
| 3748 | struct nid_path *path = snd_array_elem(&spec->paths, n); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3749 | if (!path->active) |
| 3750 | continue; |
| 3751 | for (i = 0; i < path->depth; i++) { |
| 3752 | if (path->path[i] == nid) { |
| 3753 | if (dir == HDA_OUTPUT || path->idx[i] == idx) |
| 3754 | return true; |
| 3755 | break; |
| 3756 | } |
| 3757 | } |
| 3758 | } |
| 3759 | return false; |
| 3760 | } |
| 3761 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3762 | /* get the default amp value for the target state */ |
| 3763 | static int get_amp_val_to_activate(struct hda_codec *codec, hda_nid_t nid, |
| 3764 | int dir, bool enable) |
| 3765 | { |
| 3766 | unsigned int caps; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3767 | unsigned int val = 0; |
| 3768 | |
| 3769 | caps = query_amp_caps(codec, nid, dir); |
| 3770 | if (caps & AC_AMPCAP_NUM_STEPS) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3771 | /* set to 0dB */ |
| 3772 | if (enable) |
| 3773 | val = (caps & AC_AMPCAP_OFFSET) >> AC_AMPCAP_OFFSET_SHIFT; |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3774 | } |
| 3775 | if (caps & AC_AMPCAP_MUTE) { |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3776 | if (!enable) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3777 | val |= HDA_AMP_MUTE; |
| 3778 | } |
| 3779 | return val; |
| 3780 | } |
| 3781 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3782 | /* initialize the amp value (only at the first time) */ |
| 3783 | static void init_amp(struct hda_codec *codec, hda_nid_t nid, int dir, int idx) |
| 3784 | { |
| 3785 | int val = get_amp_val_to_activate(codec, nid, dir, false); |
| 3786 | snd_hda_codec_amp_init_stereo(codec, nid, dir, idx, 0xff, val); |
| 3787 | } |
| 3788 | |
| 3789 | static void activate_amp(struct hda_codec *codec, hda_nid_t nid, int dir, |
| 3790 | int idx, bool enable) |
| 3791 | { |
| 3792 | int val; |
| 3793 | if (is_ctl_associated(codec, nid, dir, idx) || |
| 3794 | is_active_nid(codec, nid, dir, idx)) |
| 3795 | return; |
| 3796 | val = get_amp_val_to_activate(codec, nid, dir, enable); |
| 3797 | snd_hda_codec_amp_stereo(codec, nid, dir, idx, 0xff, val); |
| 3798 | } |
| 3799 | |
| 3800 | static void activate_amp_out(struct hda_codec *codec, struct nid_path *path, |
| 3801 | int i, bool enable) |
| 3802 | { |
| 3803 | hda_nid_t nid = path->path[i]; |
| 3804 | init_amp(codec, nid, HDA_OUTPUT, 0); |
| 3805 | activate_amp(codec, nid, HDA_OUTPUT, 0, enable); |
| 3806 | } |
| 3807 | |
| 3808 | static void activate_amp_in(struct hda_codec *codec, struct nid_path *path, |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3809 | int i, bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3810 | { |
| 3811 | struct alc_spec *spec = codec->spec; |
| 3812 | hda_nid_t conn[16]; |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3813 | int n, nums, idx; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3814 | int type; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3815 | hda_nid_t nid = path->path[i]; |
| 3816 | |
| 3817 | nums = snd_hda_get_connections(codec, nid, conn, ARRAY_SIZE(conn)); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3818 | type = get_wcaps_type(get_wcaps(codec, nid)); |
| 3819 | if (type == AC_WID_PIN || |
| 3820 | (type == AC_WID_AUD_IN && codec->single_adc_amp)) { |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3821 | nums = 1; |
| 3822 | idx = 0; |
| 3823 | } else |
| 3824 | idx = path->idx[i]; |
| 3825 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3826 | for (n = 0; n < nums; n++) |
| 3827 | init_amp(codec, nid, HDA_INPUT, n); |
| 3828 | |
Takashi Iwai | 0250f7c | 2012-12-14 17:53:29 +0100 | [diff] [blame] | 3829 | if (is_ctl_associated(codec, nid, HDA_INPUT, idx)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3830 | return; |
| 3831 | |
| 3832 | /* here is a little bit tricky in comparison with activate_amp_out(); |
| 3833 | * when aa-mixer is available, we need to enable the path as well |
| 3834 | */ |
| 3835 | for (n = 0; n < nums; n++) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3836 | if (n != idx && (!add_aamix || conn[n] != spec->mixer_nid)) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3837 | continue; |
| 3838 | activate_amp(codec, nid, HDA_INPUT, n, enable); |
| 3839 | } |
| 3840 | } |
| 3841 | |
| 3842 | static void activate_path(struct hda_codec *codec, struct nid_path *path, |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3843 | bool enable, bool add_aamix) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3844 | { |
| 3845 | int i; |
| 3846 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3847 | if (!enable) |
| 3848 | path->active = false; |
| 3849 | |
| 3850 | for (i = path->depth - 1; i >= 0; i--) { |
Takashi Iwai | 183a444 | 2012-12-17 18:00:02 +0100 | [diff] [blame] | 3851 | if (enable && path->multi[i]) |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3852 | snd_hda_codec_write_cache(codec, path->path[i], 0, |
| 3853 | AC_VERB_SET_CONNECT_SEL, |
| 3854 | path->idx[i]); |
| 3855 | if (has_amp_in(codec, path, i)) |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3856 | activate_amp_in(codec, path, i, enable, add_aamix); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3857 | if (has_amp_out(codec, path, i)) |
| 3858 | activate_amp_out(codec, path, i, enable); |
| 3859 | } |
| 3860 | |
| 3861 | if (enable) |
| 3862 | path->active = true; |
| 3863 | } |
| 3864 | |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3865 | /* configure the path from the given dac to the pin as the proper output */ |
| 3866 | static void alc_auto_set_output_and_unmute(struct hda_codec *codec, |
| 3867 | hda_nid_t pin, int pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3868 | hda_nid_t dac) |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3869 | { |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3870 | struct nid_path *path; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3871 | |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3872 | snd_hda_set_pin_ctl_cache(codec, pin, pin_type); |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 3873 | path = get_nid_path(codec, dac, pin); |
Takashi Iwai | ba811127 | 2012-12-06 18:06:23 +0100 | [diff] [blame] | 3874 | if (!path) |
| 3875 | return; |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 3876 | if (path->active) |
| 3877 | return; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 3878 | activate_path(codec, path, true, true); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3879 | } |
| 3880 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3881 | static void alc_auto_init_multi_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3882 | { |
| 3883 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 7085ec1 | 2009-10-02 09:03:58 +0200 | [diff] [blame] | 3884 | int pin_type = get_pin_type(spec->autocfg.line_out_type); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3885 | int i; |
| 3886 | |
| 3887 | for (i = 0; i <= HDA_SIDE; i++) { |
| 3888 | hda_nid_t nid = spec->autocfg.line_out_pins[i]; |
| 3889 | if (nid) |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3890 | alc_auto_set_output_and_unmute(codec, nid, pin_type, |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3891 | spec->multiout.dac_nids[i]); |
Takashi Iwai | 78e635c | 2012-12-10 17:07:16 +0100 | [diff] [blame] | 3892 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3893 | } |
| 3894 | } |
| 3895 | |
Takashi Iwai | 343a04b | 2011-07-06 14:28:39 +0200 | [diff] [blame] | 3896 | static void alc_auto_init_extra_out(struct hda_codec *codec) |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3897 | { |
| 3898 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3899 | int i; |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3900 | hda_nid_t pin, dac; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3901 | |
David Henningsson | 636030e | 2011-10-12 19:26:03 +0200 | [diff] [blame] | 3902 | for (i = 0; i < spec->autocfg.hp_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3903 | if (spec->autocfg.line_out_type == AUTO_PIN_HP_OUT) |
| 3904 | break; |
Takashi Iwai | e23832a | 2011-08-23 18:16:56 +0200 | [diff] [blame] | 3905 | pin = spec->autocfg.hp_pins[i]; |
| 3906 | if (!pin) |
| 3907 | break; |
| 3908 | dac = spec->multiout.hp_out_nid[i]; |
| 3909 | if (!dac) { |
| 3910 | if (i > 0 && spec->multiout.hp_out_nid[0]) |
| 3911 | dac = spec->multiout.hp_out_nid[0]; |
| 3912 | else |
| 3913 | dac = spec->multiout.dac_nids[0]; |
| 3914 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3915 | alc_auto_set_output_and_unmute(codec, pin, PIN_HP, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3916 | } |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3917 | for (i = 0; i < spec->autocfg.speaker_outs; i++) { |
Takashi Iwai | 716eef0 | 2011-10-21 15:07:42 +0200 | [diff] [blame] | 3918 | if (spec->autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 3919 | break; |
Takashi Iwai | 8cd0775 | 2011-08-23 15:16:22 +0200 | [diff] [blame] | 3920 | pin = spec->autocfg.speaker_pins[i]; |
| 3921 | if (!pin) |
| 3922 | break; |
| 3923 | dac = spec->multiout.extra_out_nid[i]; |
| 3924 | if (!dac) { |
| 3925 | if (i > 0 && spec->multiout.extra_out_nid[0]) |
| 3926 | dac = spec->multiout.extra_out_nid[0]; |
| 3927 | else |
| 3928 | dac = spec->multiout.dac_nids[0]; |
| 3929 | } |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 3930 | alc_auto_set_output_and_unmute(codec, pin, PIN_OUT, dac); |
Takashi Iwai | 675c1aa | 2011-08-23 12:36:28 +0200 | [diff] [blame] | 3931 | } |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 3932 | } |
| 3933 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3934 | /* check whether the given pin can be a multi-io pin */ |
| 3935 | static bool can_be_multiio_pin(struct hda_codec *codec, |
| 3936 | unsigned int location, hda_nid_t nid) |
| 3937 | { |
| 3938 | unsigned int defcfg, caps; |
| 3939 | |
| 3940 | defcfg = snd_hda_codec_get_pincfg(codec, nid); |
| 3941 | if (get_defcfg_connect(defcfg) != AC_JACK_PORT_COMPLEX) |
| 3942 | return false; |
| 3943 | if (location && get_defcfg_location(defcfg) != location) |
| 3944 | return false; |
| 3945 | caps = snd_hda_query_pin_caps(codec, nid); |
| 3946 | if (!(caps & AC_PINCAP_OUT)) |
| 3947 | return false; |
| 3948 | return true; |
| 3949 | } |
| 3950 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3951 | /* |
| 3952 | * multi-io helper |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3953 | * |
| 3954 | * When hardwired is set, try to fill ony hardwired pins, and returns |
| 3955 | * zero if any pins are filled, non-zero if nothing found. |
| 3956 | * When hardwired is off, try to fill possible input pins, and returns |
| 3957 | * the badness value. |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3958 | */ |
| 3959 | static int alc_auto_fill_multi_ios(struct hda_codec *codec, |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3960 | hda_nid_t reference_pin, |
| 3961 | bool hardwired, int offset) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3962 | { |
| 3963 | struct alc_spec *spec = codec->spec; |
| 3964 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3965 | int type, i, j, dacs, num_pins, old_pins; |
| 3966 | unsigned int defcfg = snd_hda_codec_get_pincfg(codec, reference_pin); |
| 3967 | unsigned int location = get_defcfg_location(defcfg); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 3968 | int badness = 0; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3969 | |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3970 | old_pins = spec->multi_ios; |
| 3971 | if (old_pins >= 2) |
| 3972 | goto end_fill; |
| 3973 | |
| 3974 | num_pins = 0; |
| 3975 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3976 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3977 | if (cfg->inputs[i].type != type) |
| 3978 | continue; |
| 3979 | if (can_be_multiio_pin(codec, location, |
| 3980 | cfg->inputs[i].pin)) |
| 3981 | num_pins++; |
| 3982 | } |
| 3983 | } |
| 3984 | if (num_pins < 2) |
| 3985 | goto end_fill; |
| 3986 | |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3987 | dacs = spec->multiout.num_dacs; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3988 | for (type = AUTO_PIN_LINE_IN; type >= AUTO_PIN_MIC; type--) { |
| 3989 | for (i = 0; i < cfg->num_inputs; i++) { |
| 3990 | hda_nid_t nid = cfg->inputs[i].pin; |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 3991 | hda_nid_t dac = 0; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3992 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3993 | if (cfg->inputs[i].type != type) |
| 3994 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3995 | if (!can_be_multiio_pin(codec, location, nid)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 3996 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 3997 | for (j = 0; j < spec->multi_ios; j++) { |
| 3998 | if (nid == spec->multi_io[j].pin) |
| 3999 | break; |
| 4000 | } |
| 4001 | if (j < spec->multi_ios) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4002 | continue; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4003 | |
| 4004 | if (offset && offset + spec->multi_ios < dacs) { |
| 4005 | dac = spec->private_dac_nids[offset + spec->multi_ios]; |
Takashi Iwai | 9c64076 | 2012-12-14 16:15:56 +0100 | [diff] [blame] | 4006 | if (!is_reachable_path(codec, dac, nid)) |
Takashi Iwai | 07b18f6 | 2011-11-10 15:42:54 +0100 | [diff] [blame] | 4007 | dac = 0; |
| 4008 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4009 | if (hardwired) |
| 4010 | dac = get_dac_if_single(codec, nid); |
| 4011 | else if (!dac) |
Takashi Iwai | fef7fbb | 2012-12-14 16:54:44 +0100 | [diff] [blame] | 4012 | dac = alc_auto_look_for_dac(codec, nid, false); |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4013 | if (!dac) { |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4014 | badness++; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4015 | continue; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4016 | } |
Takashi Iwai | 965cceb | 2012-12-18 11:46:37 +0100 | [diff] [blame] | 4017 | if (!add_new_nid_path(codec, dac, nid, 0)) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4018 | badness++; |
| 4019 | continue; |
| 4020 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4021 | spec->multi_io[spec->multi_ios].pin = nid; |
| 4022 | spec->multi_io[spec->multi_ios].dac = dac; |
| 4023 | spec->multi_ios++; |
| 4024 | if (spec->multi_ios >= 2) |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4025 | break; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4026 | } |
| 4027 | } |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4028 | end_fill: |
| 4029 | if (badness) |
| 4030 | badness = BAD_MULTI_IO; |
| 4031 | if (old_pins == spec->multi_ios) { |
| 4032 | if (hardwired) |
| 4033 | return 1; /* nothing found */ |
| 4034 | else |
| 4035 | return badness; /* no badness if nothing found */ |
| 4036 | } |
| 4037 | if (!hardwired && spec->multi_ios < 2) { |
Takashi Iwai | 30dcd3b | 2012-12-06 15:45:38 +0100 | [diff] [blame] | 4038 | /* cancel newly assigned paths */ |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4039 | spec->paths.used -= spec->multi_ios - old_pins; |
Takashi Iwai | 276dd70 | 2012-02-17 16:17:03 +0100 | [diff] [blame] | 4040 | spec->multi_ios = old_pins; |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4041 | return badness; |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4042 | } |
Takashi Iwai | 1c4a54b | 2012-02-16 16:45:59 +0100 | [diff] [blame] | 4043 | |
Takashi Iwai | 792cf2f | 2012-12-10 16:04:30 +0100 | [diff] [blame] | 4044 | /* assign volume and mute controls */ |
| 4045 | for (i = old_pins; i < spec->multi_ios; i++) |
| 4046 | badness += assign_out_path_ctls(codec, spec->multi_io[i].pin, |
| 4047 | spec->multi_io[i].dac); |
| 4048 | |
| 4049 | return badness; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4050 | } |
| 4051 | |
| 4052 | static int alc_auto_ch_mode_info(struct snd_kcontrol *kcontrol, |
| 4053 | struct snd_ctl_elem_info *uinfo) |
| 4054 | { |
| 4055 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4056 | struct alc_spec *spec = codec->spec; |
| 4057 | |
| 4058 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
| 4059 | uinfo->count = 1; |
| 4060 | uinfo->value.enumerated.items = spec->multi_ios + 1; |
| 4061 | if (uinfo->value.enumerated.item > spec->multi_ios) |
| 4062 | uinfo->value.enumerated.item = spec->multi_ios; |
| 4063 | sprintf(uinfo->value.enumerated.name, "%dch", |
| 4064 | (uinfo->value.enumerated.item + 1) * 2); |
| 4065 | return 0; |
| 4066 | } |
| 4067 | |
| 4068 | static int alc_auto_ch_mode_get(struct snd_kcontrol *kcontrol, |
| 4069 | struct snd_ctl_elem_value *ucontrol) |
| 4070 | { |
| 4071 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4072 | struct alc_spec *spec = codec->spec; |
| 4073 | ucontrol->value.enumerated.item[0] = (spec->ext_channel_count - 1) / 2; |
| 4074 | return 0; |
| 4075 | } |
| 4076 | |
| 4077 | static int alc_set_multi_io(struct hda_codec *codec, int idx, bool output) |
| 4078 | { |
| 4079 | struct alc_spec *spec = codec->spec; |
| 4080 | hda_nid_t nid = spec->multi_io[idx].pin; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4081 | struct nid_path *path; |
| 4082 | |
Takashi Iwai | 6518f7a | 2012-12-14 17:34:51 +0100 | [diff] [blame] | 4083 | path = get_nid_path(codec, spec->multi_io[idx].dac, nid); |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4084 | if (!path) |
| 4085 | return -EINVAL; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4086 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4087 | if (path->active == output) |
| 4088 | return 0; |
Takashi Iwai | 130e5f0 | 2012-12-14 16:09:29 +0100 | [diff] [blame] | 4089 | |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4090 | if (output) { |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4091 | snd_hda_set_pin_ctl_cache(codec, nid, PIN_OUT); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4092 | activate_path(codec, path, true, true); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4093 | } else { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4094 | activate_path(codec, path, false, true); |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 4095 | snd_hda_set_pin_ctl_cache(codec, nid, |
| 4096 | spec->multi_io[idx].ctl_in); |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4097 | } |
| 4098 | return 0; |
| 4099 | } |
| 4100 | |
| 4101 | static int alc_auto_ch_mode_put(struct snd_kcontrol *kcontrol, |
| 4102 | struct snd_ctl_elem_value *ucontrol) |
| 4103 | { |
| 4104 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); |
| 4105 | struct alc_spec *spec = codec->spec; |
| 4106 | int i, ch; |
| 4107 | |
| 4108 | ch = ucontrol->value.enumerated.item[0]; |
| 4109 | if (ch < 0 || ch > spec->multi_ios) |
| 4110 | return -EINVAL; |
| 4111 | if (ch == (spec->ext_channel_count - 1) / 2) |
| 4112 | return 0; |
| 4113 | spec->ext_channel_count = (ch + 1) * 2; |
| 4114 | for (i = 0; i < spec->multi_ios; i++) |
| 4115 | alc_set_multi_io(codec, i, i < ch); |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4116 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4117 | spec->const_channel_count); |
| 4118 | if (spec->need_dac_fix) |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4119 | spec->multiout.num_dacs = spec->multiout.max_channels / 2; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4120 | return 1; |
| 4121 | } |
| 4122 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 4123 | static const struct snd_kcontrol_new alc_auto_channel_mode_enum = { |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4124 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 4125 | .name = "Channel Mode", |
| 4126 | .info = alc_auto_ch_mode_info, |
| 4127 | .get = alc_auto_ch_mode_get, |
| 4128 | .put = alc_auto_ch_mode_put, |
| 4129 | }; |
| 4130 | |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4131 | static int alc_auto_add_multi_channel_mode(struct hda_codec *codec) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4132 | { |
| 4133 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4134 | |
Takashi Iwai | c267468 | 2011-08-24 17:57:44 +0200 | [diff] [blame] | 4135 | if (spec->multi_ios > 0) { |
Takashi Iwai | 668d1e9 | 2012-11-29 14:10:17 +0100 | [diff] [blame] | 4136 | if (!alc_kcontrol_new(spec, "Channel Mode", |
| 4137 | &alc_auto_channel_mode_enum)) |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4138 | return -ENOMEM; |
Takashi Iwai | ce764ab | 2011-04-27 16:35:23 +0200 | [diff] [blame] | 4139 | } |
| 4140 | return 0; |
| 4141 | } |
| 4142 | |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4143 | static void alc_auto_init_multi_io(struct hda_codec *codec) |
| 4144 | { |
| 4145 | struct alc_spec *spec = codec->spec; |
| 4146 | int i; |
| 4147 | |
| 4148 | for (i = 0; i < spec->multi_ios; i++) { |
| 4149 | hda_nid_t pin = spec->multi_io[i].pin; |
| 4150 | struct nid_path *path; |
| 4151 | path = get_nid_path(codec, spec->multi_io[i].dac, pin); |
| 4152 | if (!path) |
| 4153 | continue; |
| 4154 | if (!spec->multi_io[i].ctl_in) |
| 4155 | spec->multi_io[i].ctl_in = |
| 4156 | snd_hda_codec_update_cache(codec, pin, 0, |
| 4157 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4158 | activate_path(codec, path, path->active, true); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4159 | } |
| 4160 | } |
| 4161 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4162 | /* |
| 4163 | * initialize ADC paths |
| 4164 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4165 | static void alc_auto_init_input_src(struct hda_codec *codec) |
| 4166 | { |
| 4167 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 27d3153 | 2012-12-18 08:57:05 +0100 | [diff] [blame] | 4168 | struct hda_input_mux *imux = &spec->input_mux; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4169 | struct nid_path *path; |
| 4170 | int i, c, nums; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4171 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4172 | if (spec->dyn_adc_switch) |
| 4173 | nums = 1; |
| 4174 | else |
| 4175 | nums = spec->num_adc_nids; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4176 | |
| 4177 | for (c = 0; c < nums; c++) { |
| 4178 | for (i = 0; i < imux->num_items; i++) { |
| 4179 | path = get_nid_path(codec, spec->imux_pins[i], |
| 4180 | get_adc_nid(codec, c, i)); |
| 4181 | if (path) { |
| 4182 | bool active = path->active; |
| 4183 | if (i == spec->cur_mux[c]) |
| 4184 | active = true; |
| 4185 | activate_path(codec, path, active, false); |
| 4186 | } |
| 4187 | } |
| 4188 | } |
| 4189 | |
| 4190 | alc_inv_dmic_sync(codec, true); |
| 4191 | if (spec->shared_mic_hp) |
| 4192 | update_shared_mic_hp(codec, spec->cur_mux[0]); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4193 | } |
| 4194 | |
| 4195 | /* add mic boosts if needed */ |
| 4196 | static int alc_auto_add_mic_boost(struct hda_codec *codec) |
| 4197 | { |
| 4198 | struct alc_spec *spec = codec->spec; |
| 4199 | struct auto_pin_cfg *cfg = &spec->autocfg; |
| 4200 | int i, err; |
| 4201 | int type_idx = 0; |
| 4202 | hda_nid_t nid; |
| 4203 | const char *prev_label = NULL; |
| 4204 | |
| 4205 | for (i = 0; i < cfg->num_inputs; i++) { |
| 4206 | if (cfg->inputs[i].type > AUTO_PIN_MIC) |
| 4207 | break; |
| 4208 | nid = cfg->inputs[i].pin; |
| 4209 | if (get_wcaps(codec, nid) & AC_WCAP_IN_AMP) { |
| 4210 | const char *label; |
| 4211 | char boost_label[32]; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4212 | struct nid_path *path; |
| 4213 | unsigned int val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4214 | |
| 4215 | label = hda_get_autocfg_input_label(codec, cfg, i); |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4216 | if (spec->shared_mic_hp && !strcmp(label, "Misc")) |
| 4217 | label = "Headphone Mic"; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4218 | if (prev_label && !strcmp(label, prev_label)) |
| 4219 | type_idx++; |
| 4220 | else |
| 4221 | type_idx = 0; |
| 4222 | prev_label = label; |
| 4223 | |
| 4224 | snprintf(boost_label, sizeof(boost_label), |
| 4225 | "%s Boost Volume", label); |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4226 | val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4227 | err = add_control(spec, ALC_CTL_WIDGET_VOL, |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4228 | boost_label, type_idx, val); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4229 | if (err < 0) |
| 4230 | return err; |
Takashi Iwai | 8dd4867 | 2012-12-14 18:19:04 +0100 | [diff] [blame] | 4231 | |
| 4232 | path = get_nid_path(codec, nid, 0); |
| 4233 | if (path) |
| 4234 | path->ctls[NID_PATH_BOOST_CTL] = val; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4235 | } |
| 4236 | } |
| 4237 | return 0; |
| 4238 | } |
| 4239 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4240 | /* |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4241 | * standard auto-parser initializations |
| 4242 | */ |
| 4243 | static void alc_auto_init_std(struct hda_codec *codec) |
| 4244 | { |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4245 | alc_auto_init_multi_out(codec); |
| 4246 | alc_auto_init_extra_out(codec); |
Takashi Iwai | 3ebf1e9 | 2012-12-14 18:04:37 +0100 | [diff] [blame] | 4247 | alc_auto_init_multi_io(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4248 | alc_auto_init_analog_input(codec); |
| 4249 | alc_auto_init_input_src(codec); |
| 4250 | alc_auto_init_digital(codec); |
David Henningsson | a7a0a64 | 2012-07-05 12:00:12 +0200 | [diff] [blame] | 4251 | alc_inithook(codec); |
Takashi Iwai | e477062 | 2011-07-08 11:11:35 +0200 | [diff] [blame] | 4252 | } |
| 4253 | |
| 4254 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4255 | * Digital-beep handlers |
| 4256 | */ |
| 4257 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 4258 | #define set_beep_amp(spec, nid, idx, dir) \ |
| 4259 | ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir)) |
| 4260 | |
| 4261 | static const struct snd_pci_quirk beep_white_list[] = { |
Duncan Roe | 7110005 | 2012-10-10 14:19:50 +0200 | [diff] [blame] | 4262 | SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4263 | SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1), |
| 4264 | SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1), |
| 4265 | SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1), |
| 4266 | SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1), |
Takashi Iwai | 78f8baf | 2012-03-06 14:02:32 +0100 | [diff] [blame] | 4267 | SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4268 | SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1), |
| 4269 | {} |
| 4270 | }; |
| 4271 | |
| 4272 | static inline int has_cdefine_beep(struct hda_codec *codec) |
| 4273 | { |
| 4274 | struct alc_spec *spec = codec->spec; |
| 4275 | const struct snd_pci_quirk *q; |
| 4276 | q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list); |
| 4277 | if (q) |
| 4278 | return q->value; |
| 4279 | return spec->cdefine.enable_pcbeep; |
| 4280 | } |
| 4281 | #else |
| 4282 | #define set_beep_amp(spec, nid, idx, dir) /* NOP */ |
| 4283 | #define has_cdefine_beep(codec) 0 |
| 4284 | #endif |
| 4285 | |
| 4286 | /* parse the BIOS configuration and set up the alc_spec */ |
| 4287 | /* return 1 if successful, 0 if the proper config is not found, |
| 4288 | * or a negative error code |
| 4289 | */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4290 | static int alc_parse_auto_config(struct hda_codec *codec, |
| 4291 | const hda_nid_t *ignore_nids, |
| 4292 | const hda_nid_t *ssid_nids) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4293 | { |
| 4294 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4295 | struct auto_pin_cfg *cfg = &spec->autocfg; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4296 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4297 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 4298 | err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids, |
| 4299 | spec->parse_flags); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4300 | if (err < 0) |
| 4301 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4302 | if (!cfg->line_outs) { |
| 4303 | if (cfg->dig_outs || cfg->dig_in_pin) { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4304 | spec->multiout.max_channels = 2; |
| 4305 | spec->no_analog = 1; |
| 4306 | goto dig_only; |
| 4307 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4308 | return 0; /* can't find valid BIOS pin config */ |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4309 | } |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4310 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 4311 | if (!spec->no_primary_hp && |
| 4312 | cfg->line_out_type == AUTO_PIN_SPEAKER_OUT && |
Takashi Iwai | 0650367 | 2011-10-06 08:27:19 +0200 | [diff] [blame] | 4313 | cfg->line_outs <= cfg->hp_outs) { |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4314 | /* use HP as primary out */ |
| 4315 | cfg->speaker_outs = cfg->line_outs; |
| 4316 | memcpy(cfg->speaker_pins, cfg->line_out_pins, |
| 4317 | sizeof(cfg->speaker_pins)); |
| 4318 | cfg->line_outs = cfg->hp_outs; |
| 4319 | memcpy(cfg->line_out_pins, cfg->hp_pins, sizeof(cfg->hp_pins)); |
| 4320 | cfg->hp_outs = 0; |
| 4321 | memset(cfg->hp_pins, 0, sizeof(cfg->hp_pins)); |
| 4322 | cfg->line_out_type = AUTO_PIN_HP_OUT; |
| 4323 | } |
| 4324 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4325 | err = alc_auto_fill_dac_nids(codec); |
| 4326 | if (err < 0) |
| 4327 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4328 | err = alc_auto_add_multi_channel_mode(codec); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4329 | if (err < 0) |
| 4330 | return err; |
Takashi Iwai | 23c09b0 | 2011-08-19 09:05:35 +0200 | [diff] [blame] | 4331 | err = alc_auto_create_multi_out_ctls(codec, cfg); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4332 | if (err < 0) |
| 4333 | return err; |
| 4334 | err = alc_auto_create_hp_out(codec); |
| 4335 | if (err < 0) |
| 4336 | return err; |
| 4337 | err = alc_auto_create_speaker_out(codec); |
| 4338 | if (err < 0) |
| 4339 | return err; |
Takashi Iwai | 24de183 | 2011-11-07 17:13:39 +0100 | [diff] [blame] | 4340 | err = alc_auto_create_shared_input(codec); |
| 4341 | if (err < 0) |
| 4342 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4343 | err = alc_auto_create_input_ctls(codec); |
| 4344 | if (err < 0) |
| 4345 | return err; |
| 4346 | |
Takashi Iwai | b6adb57 | 2012-12-03 10:30:58 +0100 | [diff] [blame] | 4347 | /* check the multiple speaker pins */ |
| 4348 | if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) |
| 4349 | spec->const_channel_count = cfg->line_outs * 2; |
| 4350 | else |
| 4351 | spec->const_channel_count = cfg->speaker_outs * 2; |
| 4352 | |
| 4353 | if (spec->multi_ios > 0) |
| 4354 | spec->multiout.max_channels = max(spec->ext_channel_count, |
| 4355 | spec->const_channel_count); |
| 4356 | else |
| 4357 | spec->multiout.max_channels = spec->multiout.num_dacs * 2; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4358 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4359 | dig_only: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4360 | alc_auto_parse_digital(codec); |
| 4361 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4362 | if (ssid_nids) |
| 4363 | alc_ssid_check(codec, ssid_nids); |
| 4364 | |
| 4365 | if (!spec->no_analog) { |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4366 | err = alc_init_automute(codec); |
Takashi Iwai | 475c3d2 | 2012-11-30 08:31:30 +0100 | [diff] [blame] | 4367 | if (err < 0) |
| 4368 | return err; |
Takashi Iwai | 666a70d | 2012-12-17 20:29:29 +0100 | [diff] [blame] | 4369 | |
| 4370 | err = check_dyn_adc_switch(codec); |
| 4371 | if (err < 0) |
| 4372 | return err; |
| 4373 | |
| 4374 | if (!spec->shared_mic_hp) { |
| 4375 | err = alc_init_auto_mic(codec); |
| 4376 | if (err < 0) |
| 4377 | return err; |
| 4378 | } |
| 4379 | |
| 4380 | err = create_capture_mixers(codec); |
| 4381 | if (err < 0) |
| 4382 | return err; |
| 4383 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4384 | err = alc_auto_add_mic_boost(codec); |
| 4385 | if (err < 0) |
| 4386 | return err; |
| 4387 | } |
| 4388 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4389 | if (spec->kctls.list) |
| 4390 | add_mixer(spec, spec->kctls.list); |
| 4391 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4392 | return 1; |
| 4393 | } |
| 4394 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4395 | /* common preparation job for alc_spec */ |
| 4396 | static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) |
| 4397 | { |
| 4398 | struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
| 4399 | int err; |
| 4400 | |
| 4401 | if (!spec) |
| 4402 | return -ENOMEM; |
| 4403 | codec->spec = spec; |
Takashi Iwai | 1098b7c | 2012-12-17 20:03:15 +0100 | [diff] [blame] | 4404 | codec->single_adc_amp = 1; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4405 | spec->mixer_nid = mixer_nid; |
Takashi Iwai | ee48df5 | 2012-06-26 14:54:32 +0200 | [diff] [blame] | 4406 | snd_hda_gen_init(&spec->gen); |
Takashi Iwai | 361dab3 | 2012-05-09 14:35:27 +0200 | [diff] [blame] | 4407 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
| 4408 | snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); |
Takashi Iwai | c9967f1 | 2012-12-14 16:39:22 +0100 | [diff] [blame] | 4409 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4410 | |
| 4411 | err = alc_codec_rename_from_preset(codec); |
| 4412 | if (err < 0) { |
| 4413 | kfree(spec); |
| 4414 | return err; |
| 4415 | } |
| 4416 | return 0; |
| 4417 | } |
| 4418 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4419 | static int alc880_parse_auto_config(struct hda_codec *codec) |
| 4420 | { |
| 4421 | static const hda_nid_t alc880_ignore[] = { 0x1d, 0 }; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 4422 | static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4423 | return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids); |
| 4424 | } |
| 4425 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4426 | /* |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4427 | * ALC880 fix-ups |
| 4428 | */ |
| 4429 | enum { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4430 | ALC880_FIXUP_GPIO1, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4431 | ALC880_FIXUP_GPIO2, |
| 4432 | ALC880_FIXUP_MEDION_RIM, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4433 | ALC880_FIXUP_LG, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4434 | ALC880_FIXUP_W810, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4435 | ALC880_FIXUP_EAPD_COEF, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4436 | ALC880_FIXUP_TCL_S700, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4437 | ALC880_FIXUP_VOL_KNOB, |
| 4438 | ALC880_FIXUP_FUJITSU, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4439 | ALC880_FIXUP_F1734, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4440 | ALC880_FIXUP_UNIWILL, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4441 | ALC880_FIXUP_UNIWILL_DIG, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4442 | ALC880_FIXUP_Z71V, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4443 | ALC880_FIXUP_3ST_BASE, |
| 4444 | ALC880_FIXUP_3ST, |
| 4445 | ALC880_FIXUP_3ST_DIG, |
| 4446 | ALC880_FIXUP_5ST_BASE, |
| 4447 | ALC880_FIXUP_5ST, |
| 4448 | ALC880_FIXUP_5ST_DIG, |
| 4449 | ALC880_FIXUP_6ST_BASE, |
| 4450 | ALC880_FIXUP_6ST, |
| 4451 | ALC880_FIXUP_6ST_DIG, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4452 | }; |
| 4453 | |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4454 | /* enable the volume-knob widget support on NID 0x21 */ |
| 4455 | static void alc880_fixup_vol_knob(struct hda_codec *codec, |
| 4456 | const struct alc_fixup *fix, int action) |
| 4457 | { |
| 4458 | if (action == ALC_FIXUP_ACT_PROBE) |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4459 | 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] | 4460 | } |
| 4461 | |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4462 | static const struct alc_fixup alc880_fixups[] = { |
Takashi Iwai | 411225a | 2012-02-20 17:48:19 +0100 | [diff] [blame] | 4463 | [ALC880_FIXUP_GPIO1] = { |
| 4464 | .type = ALC_FIXUP_VERBS, |
| 4465 | .v.verbs = alc_gpio1_init_verbs, |
| 4466 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4467 | [ALC880_FIXUP_GPIO2] = { |
| 4468 | .type = ALC_FIXUP_VERBS, |
| 4469 | .v.verbs = alc_gpio2_init_verbs, |
| 4470 | }, |
| 4471 | [ALC880_FIXUP_MEDION_RIM] = { |
| 4472 | .type = ALC_FIXUP_VERBS, |
| 4473 | .v.verbs = (const struct hda_verb[]) { |
| 4474 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4475 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4476 | { } |
| 4477 | }, |
| 4478 | .chained = true, |
| 4479 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4480 | }, |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4481 | [ALC880_FIXUP_LG] = { |
| 4482 | .type = ALC_FIXUP_PINS, |
| 4483 | .v.pins = (const struct alc_pincfg[]) { |
| 4484 | /* disable bogus unused pins */ |
| 4485 | { 0x16, 0x411111f0 }, |
| 4486 | { 0x18, 0x411111f0 }, |
| 4487 | { 0x1a, 0x411111f0 }, |
| 4488 | { } |
| 4489 | } |
| 4490 | }, |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4491 | [ALC880_FIXUP_W810] = { |
| 4492 | .type = ALC_FIXUP_PINS, |
| 4493 | .v.pins = (const struct alc_pincfg[]) { |
| 4494 | /* disable bogus unused pins */ |
| 4495 | { 0x17, 0x411111f0 }, |
| 4496 | { } |
| 4497 | }, |
| 4498 | .chained = true, |
| 4499 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4500 | }, |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4501 | [ALC880_FIXUP_EAPD_COEF] = { |
| 4502 | .type = ALC_FIXUP_VERBS, |
| 4503 | .v.verbs = (const struct hda_verb[]) { |
| 4504 | /* change to EAPD mode */ |
| 4505 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4506 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 4507 | {} |
| 4508 | }, |
| 4509 | }, |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4510 | [ALC880_FIXUP_TCL_S700] = { |
| 4511 | .type = ALC_FIXUP_VERBS, |
| 4512 | .v.verbs = (const struct hda_verb[]) { |
| 4513 | /* change to EAPD mode */ |
| 4514 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4515 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 4516 | {} |
| 4517 | }, |
| 4518 | .chained = true, |
| 4519 | .chain_id = ALC880_FIXUP_GPIO2, |
| 4520 | }, |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4521 | [ALC880_FIXUP_VOL_KNOB] = { |
| 4522 | .type = ALC_FIXUP_FUNC, |
| 4523 | .v.func = alc880_fixup_vol_knob, |
| 4524 | }, |
| 4525 | [ALC880_FIXUP_FUJITSU] = { |
| 4526 | /* override all pins as BIOS on old Amilo is broken */ |
| 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 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4533 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4534 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4535 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4536 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4537 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4538 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4539 | { 0x1e, 0x01454140 }, /* SPDIF out */ |
| 4540 | { } |
| 4541 | }, |
| 4542 | .chained = true, |
| 4543 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4544 | }, |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4545 | [ALC880_FIXUP_F1734] = { |
| 4546 | /* almost compatible with FUJITSU, but no bass and SPDIF */ |
| 4547 | .type = ALC_FIXUP_PINS, |
| 4548 | .v.pins = (const struct alc_pincfg[]) { |
| 4549 | { 0x14, 0x0121411f }, /* HP */ |
| 4550 | { 0x15, 0x99030120 }, /* speaker */ |
| 4551 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4552 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4553 | { 0x18, 0x411111f0 }, /* N/A */ |
| 4554 | { 0x19, 0x01a19950 }, /* mic-in */ |
| 4555 | { 0x1a, 0x411111f0 }, /* N/A */ |
| 4556 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4557 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4558 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4559 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4560 | { } |
| 4561 | }, |
| 4562 | .chained = true, |
| 4563 | .chain_id = ALC880_FIXUP_VOL_KNOB, |
| 4564 | }, |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4565 | [ALC880_FIXUP_UNIWILL] = { |
| 4566 | /* need to fix HP and speaker pins to be parsed correctly */ |
| 4567 | .type = ALC_FIXUP_PINS, |
| 4568 | .v.pins = (const struct alc_pincfg[]) { |
| 4569 | { 0x14, 0x0121411f }, /* HP */ |
| 4570 | { 0x15, 0x99030120 }, /* speaker */ |
| 4571 | { 0x16, 0x99030130 }, /* bass speaker */ |
| 4572 | { } |
| 4573 | }, |
| 4574 | }, |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4575 | [ALC880_FIXUP_UNIWILL_DIG] = { |
| 4576 | .type = ALC_FIXUP_PINS, |
| 4577 | .v.pins = (const struct alc_pincfg[]) { |
| 4578 | /* disable bogus unused pins */ |
| 4579 | { 0x17, 0x411111f0 }, |
| 4580 | { 0x19, 0x411111f0 }, |
| 4581 | { 0x1b, 0x411111f0 }, |
| 4582 | { 0x1f, 0x411111f0 }, |
| 4583 | { } |
| 4584 | } |
| 4585 | }, |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4586 | [ALC880_FIXUP_Z71V] = { |
| 4587 | .type = ALC_FIXUP_PINS, |
| 4588 | .v.pins = (const struct alc_pincfg[]) { |
| 4589 | /* set up the whole pins as BIOS is utterly broken */ |
| 4590 | { 0x14, 0x99030120 }, /* speaker */ |
| 4591 | { 0x15, 0x0121411f }, /* HP */ |
| 4592 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4593 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4594 | { 0x18, 0x01a19950 }, /* mic-in */ |
| 4595 | { 0x19, 0x411111f0 }, /* N/A */ |
| 4596 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4597 | { 0x1b, 0x411111f0 }, /* N/A */ |
| 4598 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4599 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4600 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4601 | { } |
| 4602 | } |
| 4603 | }, |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4604 | [ALC880_FIXUP_3ST_BASE] = { |
| 4605 | .type = ALC_FIXUP_PINS, |
| 4606 | .v.pins = (const struct alc_pincfg[]) { |
| 4607 | { 0x14, 0x01014010 }, /* line-out */ |
| 4608 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4609 | { 0x16, 0x411111f0 }, /* N/A */ |
| 4610 | { 0x17, 0x411111f0 }, /* N/A */ |
| 4611 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4612 | { 0x19, 0x0121411f }, /* HP */ |
| 4613 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4614 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4615 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4616 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4617 | /* 0x1e is filled in below */ |
| 4618 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4619 | { } |
| 4620 | } |
| 4621 | }, |
| 4622 | [ALC880_FIXUP_3ST] = { |
| 4623 | .type = ALC_FIXUP_PINS, |
| 4624 | .v.pins = (const struct alc_pincfg[]) { |
| 4625 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4626 | { } |
| 4627 | }, |
| 4628 | .chained = true, |
| 4629 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4630 | }, |
| 4631 | [ALC880_FIXUP_3ST_DIG] = { |
| 4632 | .type = ALC_FIXUP_PINS, |
| 4633 | .v.pins = (const struct alc_pincfg[]) { |
| 4634 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4635 | { } |
| 4636 | }, |
| 4637 | .chained = true, |
| 4638 | .chain_id = ALC880_FIXUP_3ST_BASE, |
| 4639 | }, |
| 4640 | [ALC880_FIXUP_5ST_BASE] = { |
| 4641 | .type = ALC_FIXUP_PINS, |
| 4642 | .v.pins = (const struct alc_pincfg[]) { |
| 4643 | { 0x14, 0x01014010 }, /* front */ |
| 4644 | { 0x15, 0x411111f0 }, /* N/A */ |
| 4645 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4646 | { 0x17, 0x01016412 }, /* surr */ |
| 4647 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4648 | { 0x19, 0x0121411f }, /* HP */ |
| 4649 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4650 | { 0x1b, 0x02a19c40 }, /* front-mic */ |
| 4651 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4652 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4653 | /* 0x1e is filled in below */ |
| 4654 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4655 | { } |
| 4656 | } |
| 4657 | }, |
| 4658 | [ALC880_FIXUP_5ST] = { |
| 4659 | .type = ALC_FIXUP_PINS, |
| 4660 | .v.pins = (const struct alc_pincfg[]) { |
| 4661 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4662 | { } |
| 4663 | }, |
| 4664 | .chained = true, |
| 4665 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4666 | }, |
| 4667 | [ALC880_FIXUP_5ST_DIG] = { |
| 4668 | .type = ALC_FIXUP_PINS, |
| 4669 | .v.pins = (const struct alc_pincfg[]) { |
| 4670 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4671 | { } |
| 4672 | }, |
| 4673 | .chained = true, |
| 4674 | .chain_id = ALC880_FIXUP_5ST_BASE, |
| 4675 | }, |
| 4676 | [ALC880_FIXUP_6ST_BASE] = { |
| 4677 | .type = ALC_FIXUP_PINS, |
| 4678 | .v.pins = (const struct alc_pincfg[]) { |
| 4679 | { 0x14, 0x01014010 }, /* front */ |
| 4680 | { 0x15, 0x01016412 }, /* surr */ |
| 4681 | { 0x16, 0x01011411 }, /* CLFE */ |
| 4682 | { 0x17, 0x01012414 }, /* side */ |
| 4683 | { 0x18, 0x01a19c30 }, /* mic-in */ |
| 4684 | { 0x19, 0x02a19c40 }, /* front-mic */ |
| 4685 | { 0x1a, 0x01813031 }, /* line-in */ |
| 4686 | { 0x1b, 0x0121411f }, /* HP */ |
| 4687 | { 0x1c, 0x411111f0 }, /* N/A */ |
| 4688 | { 0x1d, 0x411111f0 }, /* N/A */ |
| 4689 | /* 0x1e is filled in below */ |
| 4690 | { 0x1f, 0x411111f0 }, /* N/A */ |
| 4691 | { } |
| 4692 | } |
| 4693 | }, |
| 4694 | [ALC880_FIXUP_6ST] = { |
| 4695 | .type = ALC_FIXUP_PINS, |
| 4696 | .v.pins = (const struct alc_pincfg[]) { |
| 4697 | { 0x1e, 0x411111f0 }, /* N/A */ |
| 4698 | { } |
| 4699 | }, |
| 4700 | .chained = true, |
| 4701 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4702 | }, |
| 4703 | [ALC880_FIXUP_6ST_DIG] = { |
| 4704 | .type = ALC_FIXUP_PINS, |
| 4705 | .v.pins = (const struct alc_pincfg[]) { |
| 4706 | { 0x1e, 0x0144111e }, /* SPDIF */ |
| 4707 | { } |
| 4708 | }, |
| 4709 | .chained = true, |
| 4710 | .chain_id = ALC880_FIXUP_6ST_BASE, |
| 4711 | }, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4712 | }; |
| 4713 | |
| 4714 | static const struct snd_pci_quirk alc880_fixup_tbl[] = { |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4715 | SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810), |
Takashi Iwai | 96e225f | 2012-02-20 17:41:51 +0100 | [diff] [blame] | 4716 | SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V), |
Takashi Iwai | 29e3fdc | 2012-02-20 17:56:57 +0100 | [diff] [blame] | 4717 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1), |
| 4718 | SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2), |
Takashi Iwai | 27e917f | 2012-02-17 17:49:54 +0100 | [diff] [blame] | 4719 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF), |
Takashi Iwai | 967b88c | 2012-02-20 17:31:02 +0100 | [diff] [blame] | 4720 | SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4721 | SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734), |
Takashi Iwai | 817de92 | 2012-02-20 17:20:48 +0100 | [diff] [blame] | 4722 | SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL), |
Takashi Iwai | 7833c7e | 2012-02-20 17:11:38 +0100 | [diff] [blame] | 4723 | SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB), |
Takashi Iwai | f02aab5 | 2012-02-17 16:33:56 +0100 | [diff] [blame] | 4724 | SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810), |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4725 | SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4726 | SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4727 | SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | ba53381 | 2012-02-20 16:36:52 +0100 | [diff] [blame] | 4728 | SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734), |
Takashi Iwai | cf5a227 | 2012-02-20 16:31:07 +0100 | [diff] [blame] | 4729 | SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU), |
Takashi Iwai | dc6af52 | 2012-02-17 16:18:59 +0100 | [diff] [blame] | 4730 | SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG), |
| 4731 | SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG), |
| 4732 | SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG), |
Takashi Iwai | b9368f5 | 2012-02-17 17:54:44 +0100 | [diff] [blame] | 4733 | SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700), |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4734 | |
| 4735 | /* Below is the copied entries from alc880_quirks.c. |
| 4736 | * It's not quite sure whether BIOS sets the correct pin-config table |
| 4737 | * on these machines, thus they are kept to be compatible with |
| 4738 | * the old static quirks. Once when it's confirmed to work without |
| 4739 | * these overrides, it'd be better to remove. |
| 4740 | */ |
| 4741 | SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG), |
| 4742 | SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST), |
| 4743 | SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4744 | SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4745 | SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4746 | SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG), |
| 4747 | SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG), |
| 4748 | SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST), |
| 4749 | SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG), |
| 4750 | SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST), |
| 4751 | SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST), |
| 4752 | SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST), |
| 4753 | SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST), |
| 4754 | SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST), |
| 4755 | SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG), |
| 4756 | SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG), |
| 4757 | SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG), |
| 4758 | SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG), |
| 4759 | SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG), |
| 4760 | SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG), |
| 4761 | SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG), |
| 4762 | SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */ |
| 4763 | SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG), |
| 4764 | SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4765 | SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4766 | SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4767 | SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4768 | SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4769 | SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4770 | SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG), |
| 4771 | SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4772 | SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4773 | SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG), |
| 4774 | /* default Intel */ |
| 4775 | SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST), |
| 4776 | SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG), |
| 4777 | SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG), |
| 4778 | {} |
| 4779 | }; |
| 4780 | |
| 4781 | static const struct alc_model_fixup alc880_fixup_models[] = { |
| 4782 | {.id = ALC880_FIXUP_3ST, .name = "3stack"}, |
| 4783 | {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"}, |
| 4784 | {.id = ALC880_FIXUP_5ST, .name = "5stack"}, |
| 4785 | {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"}, |
| 4786 | {.id = ALC880_FIXUP_6ST, .name = "6stack"}, |
| 4787 | {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"}, |
Takashi Iwai | ee3b296 | 2011-11-15 14:26:54 +0100 | [diff] [blame] | 4788 | {} |
| 4789 | }; |
| 4790 | |
| 4791 | |
| 4792 | /* |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4793 | * OK, here we have finally the patch for ALC880 |
| 4794 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4795 | static int patch_alc880(struct hda_codec *codec) |
| 4796 | { |
| 4797 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4798 | int err; |
| 4799 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4800 | err = alc_alloc_spec(codec, 0x0b); |
| 4801 | if (err < 0) |
| 4802 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4803 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4804 | spec = codec->spec; |
Takashi Iwai | 7b1655f | 2011-07-14 15:31:21 +0200 | [diff] [blame] | 4805 | spec->need_dac_fix = 1; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4806 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4807 | alc_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl, |
| 4808 | alc880_fixups); |
| 4809 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4810 | |
Takashi Iwai | 67b6ec3 | 2012-02-20 18:20:42 +0100 | [diff] [blame] | 4811 | /* automatic parse from the BIOS config */ |
| 4812 | err = alc880_parse_auto_config(codec); |
| 4813 | if (err < 0) |
| 4814 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4815 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4816 | if (!spec->no_analog) { |
| 4817 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4818 | if (err < 0) |
| 4819 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4820 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 4821 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4822 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4823 | codec->patch_ops = alc_patch_ops; |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4824 | codec->patch_ops.unsol_event = alc880_unsol_event; |
| 4825 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4826 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 4827 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 4828 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4829 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 4830 | |
| 4831 | error: |
| 4832 | alc_free(codec); |
| 4833 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4834 | } |
| 4835 | |
| 4836 | |
| 4837 | /* |
| 4838 | * ALC260 support |
| 4839 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4840 | static int alc260_parse_auto_config(struct hda_codec *codec) |
| 4841 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4842 | static const hda_nid_t alc260_ignore[] = { 0x17, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 4843 | static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 }; |
| 4844 | return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4845 | } |
| 4846 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4847 | /* |
| 4848 | * Pin config fixes |
| 4849 | */ |
| 4850 | enum { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4851 | ALC260_FIXUP_HP_DC5750, |
| 4852 | ALC260_FIXUP_HP_PIN_0F, |
| 4853 | ALC260_FIXUP_COEF, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4854 | ALC260_FIXUP_GPIO1, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4855 | ALC260_FIXUP_GPIO1_TOGGLE, |
| 4856 | ALC260_FIXUP_REPLACER, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4857 | ALC260_FIXUP_HP_B1900, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4858 | ALC260_FIXUP_KN1, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4859 | }; |
| 4860 | |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4861 | static void alc260_gpio1_automute(struct hda_codec *codec) |
| 4862 | { |
| 4863 | struct alc_spec *spec = codec->spec; |
| 4864 | snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, |
| 4865 | spec->hp_jack_present); |
| 4866 | } |
| 4867 | |
| 4868 | static void alc260_fixup_gpio1_toggle(struct hda_codec *codec, |
| 4869 | const struct alc_fixup *fix, int action) |
| 4870 | { |
| 4871 | struct alc_spec *spec = codec->spec; |
| 4872 | if (action == ALC_FIXUP_ACT_PROBE) { |
| 4873 | /* although the machine has only one output pin, we need to |
| 4874 | * toggle GPIO1 according to the jack state |
| 4875 | */ |
| 4876 | spec->automute_hook = alc260_gpio1_automute; |
| 4877 | spec->detect_hp = 1; |
| 4878 | spec->automute_speaker = 1; |
| 4879 | spec->autocfg.hp_pins[0] = 0x0f; /* copy it for automute */ |
David Henningsson | 29adc4b | 2012-09-25 11:31:00 +0200 | [diff] [blame] | 4880 | snd_hda_jack_detect_enable_callback(codec, 0x0f, ALC_HP_EVENT, |
| 4881 | alc_hp_automute); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 4882 | snd_hda_gen_add_verbs(&spec->gen, alc_gpio1_init_verbs); |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4883 | } |
| 4884 | } |
| 4885 | |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4886 | static void alc260_fixup_kn1(struct hda_codec *codec, |
| 4887 | const struct alc_fixup *fix, int action) |
| 4888 | { |
| 4889 | struct alc_spec *spec = codec->spec; |
| 4890 | static const struct alc_pincfg pincfgs[] = { |
| 4891 | { 0x0f, 0x02214000 }, /* HP/speaker */ |
| 4892 | { 0x12, 0x90a60160 }, /* int mic */ |
| 4893 | { 0x13, 0x02a19000 }, /* ext mic */ |
| 4894 | { 0x18, 0x01446000 }, /* SPDIF out */ |
| 4895 | /* disable bogus I/O pins */ |
| 4896 | { 0x10, 0x411111f0 }, |
| 4897 | { 0x11, 0x411111f0 }, |
| 4898 | { 0x14, 0x411111f0 }, |
| 4899 | { 0x15, 0x411111f0 }, |
| 4900 | { 0x16, 0x411111f0 }, |
| 4901 | { 0x17, 0x411111f0 }, |
| 4902 | { 0x19, 0x411111f0 }, |
| 4903 | { } |
| 4904 | }; |
| 4905 | |
| 4906 | switch (action) { |
| 4907 | case ALC_FIXUP_ACT_PRE_PROBE: |
| 4908 | alc_apply_pincfgs(codec, pincfgs); |
| 4909 | break; |
| 4910 | case ALC_FIXUP_ACT_PROBE: |
| 4911 | spec->init_amp = ALC_INIT_NONE; |
| 4912 | break; |
| 4913 | } |
| 4914 | } |
| 4915 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4916 | static const struct alc_fixup alc260_fixups[] = { |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4917 | [ALC260_FIXUP_HP_DC5750] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4918 | .type = ALC_FIXUP_PINS, |
| 4919 | .v.pins = (const struct alc_pincfg[]) { |
| 4920 | { 0x11, 0x90130110 }, /* speaker */ |
| 4921 | { } |
| 4922 | } |
| 4923 | }, |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4924 | [ALC260_FIXUP_HP_PIN_0F] = { |
| 4925 | .type = ALC_FIXUP_PINS, |
| 4926 | .v.pins = (const struct alc_pincfg[]) { |
| 4927 | { 0x0f, 0x01214000 }, /* HP */ |
| 4928 | { } |
| 4929 | } |
| 4930 | }, |
| 4931 | [ALC260_FIXUP_COEF] = { |
| 4932 | .type = ALC_FIXUP_VERBS, |
| 4933 | .v.verbs = (const struct hda_verb[]) { |
| 4934 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4935 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 }, |
| 4936 | { } |
| 4937 | }, |
| 4938 | .chained = true, |
| 4939 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4940 | }, |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4941 | [ALC260_FIXUP_GPIO1] = { |
| 4942 | .type = ALC_FIXUP_VERBS, |
| 4943 | .v.verbs = alc_gpio1_init_verbs, |
| 4944 | }, |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4945 | [ALC260_FIXUP_GPIO1_TOGGLE] = { |
| 4946 | .type = ALC_FIXUP_FUNC, |
| 4947 | .v.func = alc260_fixup_gpio1_toggle, |
| 4948 | .chained = true, |
| 4949 | .chain_id = ALC260_FIXUP_HP_PIN_0F, |
| 4950 | }, |
| 4951 | [ALC260_FIXUP_REPLACER] = { |
| 4952 | .type = ALC_FIXUP_VERBS, |
| 4953 | .v.verbs = (const struct hda_verb[]) { |
| 4954 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 4955 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 4956 | { } |
| 4957 | }, |
| 4958 | .chained = true, |
| 4959 | .chain_id = ALC260_FIXUP_GPIO1_TOGGLE, |
| 4960 | }, |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4961 | [ALC260_FIXUP_HP_B1900] = { |
| 4962 | .type = ALC_FIXUP_FUNC, |
| 4963 | .v.func = alc260_fixup_gpio1_toggle, |
| 4964 | .chained = true, |
| 4965 | .chain_id = ALC260_FIXUP_COEF, |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4966 | }, |
| 4967 | [ALC260_FIXUP_KN1] = { |
| 4968 | .type = ALC_FIXUP_FUNC, |
| 4969 | .v.func = alc260_fixup_kn1, |
| 4970 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4971 | }; |
| 4972 | |
| 4973 | static const struct snd_pci_quirk alc260_fixup_tbl[] = { |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4974 | SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4975 | SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF), |
Takashi Iwai | 15317ab | 2012-02-16 12:02:53 +0100 | [diff] [blame] | 4976 | SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4977 | SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750), |
Takashi Iwai | 0a1c4fa | 2012-02-16 12:42:30 +0100 | [diff] [blame] | 4978 | SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900), |
Takashi Iwai | b1f5808 | 2012-02-16 12:45:03 +0100 | [diff] [blame] | 4979 | SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1), |
Takashi Iwai | 118cb4a | 2012-04-19 07:33:27 +0200 | [diff] [blame] | 4980 | SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1), |
Takashi Iwai | 20f7d92 | 2012-02-16 12:35:16 +0100 | [diff] [blame] | 4981 | SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER), |
Takashi Iwai | ca8f042 | 2012-02-16 11:51:19 +0100 | [diff] [blame] | 4982 | SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4983 | {} |
| 4984 | }; |
| 4985 | |
| 4986 | /* |
| 4987 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4988 | static int patch_alc260(struct hda_codec *codec) |
| 4989 | { |
| 4990 | struct alc_spec *spec; |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4991 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4992 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4993 | err = alc_alloc_spec(codec, 0x07); |
| 4994 | if (err < 0) |
| 4995 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4996 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 4997 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 4998 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 4999 | alc_pick_fixup(codec, NULL, alc260_fixup_tbl, alc260_fixups); |
| 5000 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5001 | |
Takashi Iwai | c3c2c9e | 2012-02-16 12:59:55 +0100 | [diff] [blame] | 5002 | /* automatic parse from the BIOS config */ |
| 5003 | err = alc260_parse_auto_config(codec); |
| 5004 | if (err < 0) |
| 5005 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5006 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5007 | if (!spec->no_analog) { |
| 5008 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5009 | if (err < 0) |
| 5010 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5011 | set_beep_amp(spec, 0x07, 0x05, HDA_INPUT); |
| 5012 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5013 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5014 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5015 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5016 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5017 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5018 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5019 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5020 | |
| 5021 | error: |
| 5022 | alc_free(codec); |
| 5023 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5024 | } |
| 5025 | |
| 5026 | |
| 5027 | /* |
| 5028 | * ALC882/883/885/888/889 support |
| 5029 | * |
| 5030 | * ALC882 is almost identical with ALC880 but has cleaner and more flexible |
| 5031 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 5032 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 5033 | * 6-channel independent captures. |
| 5034 | * |
| 5035 | * In addition, an independent DAC for the multi-playback (not used in this |
| 5036 | * driver yet). |
| 5037 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5038 | |
| 5039 | /* |
| 5040 | * Pin config fixes |
| 5041 | */ |
| 5042 | enum { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5043 | ALC882_FIXUP_ABIT_AW9D_MAX, |
| 5044 | ALC882_FIXUP_LENOVO_Y530, |
| 5045 | ALC882_FIXUP_PB_M5210, |
| 5046 | ALC882_FIXUP_ACER_ASPIRE_7736, |
| 5047 | ALC882_FIXUP_ASUS_W90V, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5048 | ALC889_FIXUP_CD, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5049 | ALC889_FIXUP_VAIO_TT, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5050 | ALC888_FIXUP_EEE1601, |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5051 | ALC882_FIXUP_EAPD, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5052 | ALC883_FIXUP_EAPD, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5053 | ALC883_FIXUP_ACER_EAPD, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5054 | ALC882_FIXUP_GPIO1, |
| 5055 | ALC882_FIXUP_GPIO2, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5056 | ALC882_FIXUP_GPIO3, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5057 | ALC889_FIXUP_COEF, |
| 5058 | ALC882_FIXUP_ASUS_W2JC, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5059 | ALC882_FIXUP_ACER_ASPIRE_4930G, |
| 5060 | ALC882_FIXUP_ACER_ASPIRE_8930G, |
| 5061 | ALC882_FIXUP_ASPIRE_8930G_VERBS, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5062 | ALC885_FIXUP_MACPRO_GPIO, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5063 | ALC889_FIXUP_DAC_ROUTE, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5064 | ALC889_FIXUP_MBP_VREF, |
| 5065 | ALC889_FIXUP_IMAC91_VREF, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5066 | ALC882_FIXUP_INV_DMIC, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5067 | ALC882_FIXUP_NO_PRIMARY_HP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5068 | }; |
| 5069 | |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5070 | static void alc889_fixup_coef(struct hda_codec *codec, |
| 5071 | const struct alc_fixup *fix, int action) |
| 5072 | { |
| 5073 | if (action != ALC_FIXUP_ACT_INIT) |
| 5074 | return; |
| 5075 | alc889_coef_init(codec); |
| 5076 | } |
| 5077 | |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5078 | /* toggle speaker-output according to the hp-jack state */ |
| 5079 | static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted) |
| 5080 | { |
| 5081 | unsigned int gpiostate, gpiomask, gpiodir; |
| 5082 | |
| 5083 | gpiostate = snd_hda_codec_read(codec, codec->afg, 0, |
| 5084 | AC_VERB_GET_GPIO_DATA, 0); |
| 5085 | |
| 5086 | if (!muted) |
| 5087 | gpiostate |= (1 << pin); |
| 5088 | else |
| 5089 | gpiostate &= ~(1 << pin); |
| 5090 | |
| 5091 | gpiomask = snd_hda_codec_read(codec, codec->afg, 0, |
| 5092 | AC_VERB_GET_GPIO_MASK, 0); |
| 5093 | gpiomask |= (1 << pin); |
| 5094 | |
| 5095 | gpiodir = snd_hda_codec_read(codec, codec->afg, 0, |
| 5096 | AC_VERB_GET_GPIO_DIRECTION, 0); |
| 5097 | gpiodir |= (1 << pin); |
| 5098 | |
| 5099 | |
| 5100 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5101 | AC_VERB_SET_GPIO_MASK, gpiomask); |
| 5102 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5103 | AC_VERB_SET_GPIO_DIRECTION, gpiodir); |
| 5104 | |
| 5105 | msleep(1); |
| 5106 | |
| 5107 | snd_hda_codec_write(codec, codec->afg, 0, |
| 5108 | AC_VERB_SET_GPIO_DATA, gpiostate); |
| 5109 | } |
| 5110 | |
| 5111 | /* set up GPIO at initialization */ |
| 5112 | static void alc885_fixup_macpro_gpio(struct hda_codec *codec, |
| 5113 | const struct alc_fixup *fix, int action) |
| 5114 | { |
| 5115 | if (action != ALC_FIXUP_ACT_INIT) |
| 5116 | return; |
| 5117 | alc882_gpio_mute(codec, 0, 0); |
| 5118 | alc882_gpio_mute(codec, 1, 0); |
| 5119 | } |
| 5120 | |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5121 | /* Fix the connection of some pins for ALC889: |
| 5122 | * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't |
| 5123 | * work correctly (bko#42740) |
| 5124 | */ |
| 5125 | static void alc889_fixup_dac_route(struct hda_codec *codec, |
| 5126 | const struct alc_fixup *fix, int action) |
| 5127 | { |
| 5128 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5129 | /* fake the connections during parsing the tree */ |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5130 | hda_nid_t conn1[2] = { 0x0c, 0x0d }; |
| 5131 | hda_nid_t conn2[2] = { 0x0e, 0x0f }; |
| 5132 | snd_hda_override_conn_list(codec, 0x14, 2, conn1); |
| 5133 | snd_hda_override_conn_list(codec, 0x15, 2, conn1); |
| 5134 | snd_hda_override_conn_list(codec, 0x18, 2, conn2); |
| 5135 | snd_hda_override_conn_list(codec, 0x1a, 2, conn2); |
Takashi Iwai | ef8d60f | 2012-02-17 10:12:38 +0100 | [diff] [blame] | 5136 | } else if (action == ALC_FIXUP_ACT_PROBE) { |
| 5137 | /* restore the connections */ |
| 5138 | hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 }; |
| 5139 | snd_hda_override_conn_list(codec, 0x14, 5, conn); |
| 5140 | snd_hda_override_conn_list(codec, 0x15, 5, conn); |
| 5141 | snd_hda_override_conn_list(codec, 0x18, 5, conn); |
| 5142 | snd_hda_override_conn_list(codec, 0x1a, 5, conn); |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5143 | } |
| 5144 | } |
| 5145 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5146 | /* Set VREF on HP pin */ |
| 5147 | static void alc889_fixup_mbp_vref(struct hda_codec *codec, |
| 5148 | const struct alc_fixup *fix, int action) |
| 5149 | { |
| 5150 | struct alc_spec *spec = codec->spec; |
| 5151 | static hda_nid_t nids[2] = { 0x14, 0x15 }; |
| 5152 | int i; |
| 5153 | |
| 5154 | if (action != ALC_FIXUP_ACT_INIT) |
| 5155 | return; |
| 5156 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5157 | unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]); |
| 5158 | if (get_defcfg_device(val) != AC_JACK_HP_OUT) |
| 5159 | continue; |
| 5160 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5161 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5162 | val |= AC_PINCTL_VREF_80; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5163 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5164 | spec->keep_vref_in_automute = 1; |
| 5165 | break; |
| 5166 | } |
| 5167 | } |
| 5168 | |
| 5169 | /* Set VREF on speaker pins on imac91 */ |
| 5170 | static void alc889_fixup_imac91_vref(struct hda_codec *codec, |
| 5171 | const struct alc_fixup *fix, int action) |
| 5172 | { |
| 5173 | struct alc_spec *spec = codec->spec; |
| 5174 | static hda_nid_t nids[2] = { 0x18, 0x1a }; |
| 5175 | int i; |
| 5176 | |
| 5177 | if (action != ALC_FIXUP_ACT_INIT) |
| 5178 | return; |
| 5179 | for (i = 0; i < ARRAY_SIZE(nids); i++) { |
| 5180 | unsigned int val; |
| 5181 | val = snd_hda_codec_read(codec, nids[i], 0, |
| 5182 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 5183 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 5184 | snd_hda_set_pin_ctl(codec, nids[i], val); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5185 | } |
| 5186 | spec->keep_vref_in_automute = 1; |
| 5187 | } |
| 5188 | |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5189 | /* Don't take HP output as primary |
| 5190 | * strangely, the speaker output doesn't work on VAIO Z through DAC 0x05 |
| 5191 | */ |
| 5192 | static void alc882_fixup_no_primary_hp(struct hda_codec *codec, |
| 5193 | const struct alc_fixup *fix, int action) |
| 5194 | { |
| 5195 | struct alc_spec *spec = codec->spec; |
| 5196 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5197 | spec->no_primary_hp = 1; |
| 5198 | } |
| 5199 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5200 | static const struct alc_fixup alc882_fixups[] = { |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5201 | [ALC882_FIXUP_ABIT_AW9D_MAX] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5202 | .type = ALC_FIXUP_PINS, |
| 5203 | .v.pins = (const struct alc_pincfg[]) { |
| 5204 | { 0x15, 0x01080104 }, /* side */ |
| 5205 | { 0x16, 0x01011012 }, /* rear */ |
| 5206 | { 0x17, 0x01016011 }, /* clfe */ |
| 5207 | { } |
| 5208 | } |
| 5209 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5210 | [ALC882_FIXUP_LENOVO_Y530] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5211 | .type = ALC_FIXUP_PINS, |
| 5212 | .v.pins = (const struct alc_pincfg[]) { |
| 5213 | { 0x15, 0x99130112 }, /* rear int speakers */ |
| 5214 | { 0x16, 0x99130111 }, /* subwoofer */ |
| 5215 | { } |
| 5216 | } |
| 5217 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5218 | [ALC882_FIXUP_PB_M5210] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5219 | .type = ALC_FIXUP_VERBS, |
| 5220 | .v.verbs = (const struct hda_verb[]) { |
| 5221 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
| 5222 | {} |
| 5223 | } |
| 5224 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5225 | [ALC882_FIXUP_ACER_ASPIRE_7736] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5226 | .type = ALC_FIXUP_FUNC, |
| 5227 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5228 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5229 | [ALC882_FIXUP_ASUS_W90V] = { |
Takashi Iwai | 5cdf745 | 2011-10-26 23:04:08 +0200 | [diff] [blame] | 5230 | .type = ALC_FIXUP_PINS, |
| 5231 | .v.pins = (const struct alc_pincfg[]) { |
| 5232 | { 0x16, 0x99130110 }, /* fix sequence for CLFE */ |
| 5233 | { } |
| 5234 | } |
| 5235 | }, |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5236 | [ALC889_FIXUP_CD] = { |
| 5237 | .type = ALC_FIXUP_PINS, |
| 5238 | .v.pins = (const struct alc_pincfg[]) { |
| 5239 | { 0x1c, 0x993301f0 }, /* CD */ |
| 5240 | { } |
| 5241 | } |
| 5242 | }, |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5243 | [ALC889_FIXUP_VAIO_TT] = { |
| 5244 | .type = ALC_FIXUP_PINS, |
| 5245 | .v.pins = (const struct alc_pincfg[]) { |
| 5246 | { 0x17, 0x90170111 }, /* hidden surround speaker */ |
| 5247 | { } |
| 5248 | } |
| 5249 | }, |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5250 | [ALC888_FIXUP_EEE1601] = { |
| 5251 | .type = ALC_FIXUP_VERBS, |
| 5252 | .v.verbs = (const struct hda_verb[]) { |
| 5253 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5254 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 }, |
| 5255 | { } |
| 5256 | } |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5257 | }, |
| 5258 | [ALC882_FIXUP_EAPD] = { |
| 5259 | .type = ALC_FIXUP_VERBS, |
| 5260 | .v.verbs = (const struct hda_verb[]) { |
| 5261 | /* change to EAPD mode */ |
| 5262 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5263 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 }, |
| 5264 | { } |
| 5265 | } |
| 5266 | }, |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5267 | [ALC883_FIXUP_EAPD] = { |
| 5268 | .type = ALC_FIXUP_VERBS, |
| 5269 | .v.verbs = (const struct hda_verb[]) { |
| 5270 | /* change to EAPD mode */ |
| 5271 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5272 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5273 | { } |
| 5274 | } |
| 5275 | }, |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5276 | [ALC883_FIXUP_ACER_EAPD] = { |
| 5277 | .type = ALC_FIXUP_VERBS, |
| 5278 | .v.verbs = (const struct hda_verb[]) { |
| 5279 | /* eanable EAPD on Acer laptops */ |
| 5280 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5281 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5282 | { } |
| 5283 | } |
| 5284 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5285 | [ALC882_FIXUP_GPIO1] = { |
| 5286 | .type = ALC_FIXUP_VERBS, |
| 5287 | .v.verbs = alc_gpio1_init_verbs, |
| 5288 | }, |
| 5289 | [ALC882_FIXUP_GPIO2] = { |
| 5290 | .type = ALC_FIXUP_VERBS, |
| 5291 | .v.verbs = alc_gpio2_init_verbs, |
| 5292 | }, |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5293 | [ALC882_FIXUP_GPIO3] = { |
| 5294 | .type = ALC_FIXUP_VERBS, |
| 5295 | .v.verbs = alc_gpio3_init_verbs, |
| 5296 | }, |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5297 | [ALC882_FIXUP_ASUS_W2JC] = { |
| 5298 | .type = ALC_FIXUP_VERBS, |
| 5299 | .v.verbs = alc_gpio1_init_verbs, |
| 5300 | .chained = true, |
| 5301 | .chain_id = ALC882_FIXUP_EAPD, |
| 5302 | }, |
| 5303 | [ALC889_FIXUP_COEF] = { |
| 5304 | .type = ALC_FIXUP_FUNC, |
| 5305 | .v.func = alc889_fixup_coef, |
| 5306 | }, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5307 | [ALC882_FIXUP_ACER_ASPIRE_4930G] = { |
| 5308 | .type = ALC_FIXUP_PINS, |
| 5309 | .v.pins = (const struct alc_pincfg[]) { |
| 5310 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5311 | { 0x17, 0x99130112 }, /* surround speaker */ |
| 5312 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5313 | }, |
| 5314 | .chained = true, |
| 5315 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5316 | }, |
| 5317 | [ALC882_FIXUP_ACER_ASPIRE_8930G] = { |
| 5318 | .type = ALC_FIXUP_PINS, |
| 5319 | .v.pins = (const struct alc_pincfg[]) { |
| 5320 | { 0x16, 0x99130111 }, /* CLFE speaker */ |
| 5321 | { 0x1b, 0x99130112 }, /* surround speaker */ |
| 5322 | { } |
| 5323 | }, |
| 5324 | .chained = true, |
| 5325 | .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS, |
| 5326 | }, |
| 5327 | [ALC882_FIXUP_ASPIRE_8930G_VERBS] = { |
| 5328 | /* additional init verbs for Acer Aspire 8930G */ |
| 5329 | .type = ALC_FIXUP_VERBS, |
| 5330 | .v.verbs = (const struct hda_verb[]) { |
| 5331 | /* Enable all DACs */ |
| 5332 | /* DAC DISABLE/MUTE 1? */ |
| 5333 | /* setting bits 1-5 disables DAC nids 0x02-0x06 |
| 5334 | * apparently. Init=0x38 */ |
| 5335 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 }, |
| 5336 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5337 | /* DAC DISABLE/MUTE 2? */ |
| 5338 | /* some bit here disables the other DACs. |
| 5339 | * Init=0x4900 */ |
| 5340 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 }, |
| 5341 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 }, |
| 5342 | /* DMIC fix |
| 5343 | * This laptop has a stereo digital microphone. |
| 5344 | * The mics are only 1cm apart which makes the stereo |
| 5345 | * useless. However, either the mic or the ALC889 |
| 5346 | * makes the signal become a difference/sum signal |
| 5347 | * instead of standard stereo, which is annoying. |
| 5348 | * So instead we flip this bit which makes the |
| 5349 | * codec replicate the sum signal to both channels, |
| 5350 | * turning it into a normal mono mic. |
| 5351 | */ |
| 5352 | /* DMIC_CONTROL? Init value = 0x0001 */ |
| 5353 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b }, |
| 5354 | { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 }, |
| 5355 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5356 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5357 | { } |
Takashi Iwai | 038d4fe | 2012-04-11 17:18:12 +0200 | [diff] [blame] | 5358 | }, |
| 5359 | .chained = true, |
| 5360 | .chain_id = ALC882_FIXUP_GPIO1, |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5361 | }, |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5362 | [ALC885_FIXUP_MACPRO_GPIO] = { |
| 5363 | .type = ALC_FIXUP_FUNC, |
| 5364 | .v.func = alc885_fixup_macpro_gpio, |
| 5365 | }, |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5366 | [ALC889_FIXUP_DAC_ROUTE] = { |
| 5367 | .type = ALC_FIXUP_FUNC, |
| 5368 | .v.func = alc889_fixup_dac_route, |
| 5369 | }, |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5370 | [ALC889_FIXUP_MBP_VREF] = { |
| 5371 | .type = ALC_FIXUP_FUNC, |
| 5372 | .v.func = alc889_fixup_mbp_vref, |
| 5373 | .chained = true, |
| 5374 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5375 | }, |
| 5376 | [ALC889_FIXUP_IMAC91_VREF] = { |
| 5377 | .type = ALC_FIXUP_FUNC, |
| 5378 | .v.func = alc889_fixup_imac91_vref, |
| 5379 | .chained = true, |
| 5380 | .chain_id = ALC882_FIXUP_GPIO1, |
| 5381 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5382 | [ALC882_FIXUP_INV_DMIC] = { |
| 5383 | .type = ALC_FIXUP_FUNC, |
| 5384 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5385 | }, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5386 | [ALC882_FIXUP_NO_PRIMARY_HP] = { |
| 5387 | .type = ALC_FIXUP_FUNC, |
| 5388 | .v.func = alc882_fixup_no_primary_hp, |
| 5389 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5390 | }; |
| 5391 | |
| 5392 | static const struct snd_pci_quirk alc882_fixup_tbl[] = { |
Takashi Iwai | 8812c4f | 2011-11-09 17:39:15 +0100 | [diff] [blame] | 5393 | SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD), |
| 5394 | SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5395 | SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD), |
| 5396 | SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD), |
| 5397 | SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD), |
| 5398 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD), |
Takashi Iwai | c3e837b | 2011-11-10 16:01:47 +0100 | [diff] [blame] | 5399 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
| 5400 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5401 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", |
| 5402 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5403 | SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G", |
| 5404 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5405 | SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G", |
| 5406 | ALC882_FIXUP_ACER_ASPIRE_8930G), |
| 5407 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", |
| 5408 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5409 | SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G", |
| 5410 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
| 5411 | SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G", |
| 5412 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5413 | SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210), |
Takashi Iwai | f5c53d8 | 2012-05-07 10:07:33 +0200 | [diff] [blame] | 5414 | SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G", |
| 5415 | ALC882_FIXUP_ACER_ASPIRE_4930G), |
Takashi Iwai | 02a237b | 2012-02-13 15:25:07 +0100 | [diff] [blame] | 5416 | SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE), |
Takashi Iwai | fe97da1 | 2012-04-12 08:00:19 +0200 | [diff] [blame] | 5417 | 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] | 5418 | SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736), |
Takashi Iwai | 177943a | 2011-11-09 12:55:18 +0100 | [diff] [blame] | 5419 | SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5420 | SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5421 | SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC), |
Takashi Iwai | 0e7cc2e | 2011-11-09 12:42:48 +0100 | [diff] [blame] | 5422 | SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5423 | SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT), |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5424 | 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] | 5425 | |
| 5426 | /* All Apple entries are in codec SSIDs */ |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5427 | SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF), |
| 5428 | SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF), |
| 5429 | SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5430 | SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO), |
| 5431 | SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO), |
| 5432 | SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5433 | SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF), |
| 5434 | SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5435 | SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5436 | SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF), |
| 5437 | SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF), |
| 5438 | SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF), |
| 5439 | SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5440 | SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5441 | SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5442 | SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), |
| 5443 | SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), |
Josh Boyer | 29ebe40 | 2012-04-12 13:55:36 -0400 | [diff] [blame] | 5444 | SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), |
Takashi Iwai | 0519363 | 2012-11-12 10:07:36 +0100 | [diff] [blame] | 5445 | SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5446 | SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), |
| 5447 | SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), |
| 5448 | SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), |
Takashi Iwai | 5671087 | 2011-11-14 17:42:11 +0100 | [diff] [blame] | 5449 | |
Takashi Iwai | 7a6069b | 2011-11-09 15:22:01 +0100 | [diff] [blame] | 5450 | SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), |
Takashi Iwai | bca4013 | 2012-05-07 11:13:14 +0200 | [diff] [blame] | 5451 | SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), |
Takashi Iwai | eb844d5 | 2011-11-09 18:03:07 +0100 | [diff] [blame] | 5452 | SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), |
Marton Balint | 8f23921 | 2012-03-05 21:33:23 +0100 | [diff] [blame] | 5453 | SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD), |
Takashi Iwai | 5c0ebfb | 2011-11-07 17:59:13 +0100 | [diff] [blame] | 5454 | 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] | 5455 | SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD), |
| 5456 | SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD), |
Takashi Iwai | ac9b1cd | 2011-11-09 17:45:55 +0100 | [diff] [blame] | 5457 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530), |
Takashi Iwai | 68ef056 | 2011-11-09 18:24:44 +0100 | [diff] [blame] | 5458 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5459 | {} |
| 5460 | }; |
| 5461 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5462 | static const struct alc_model_fixup alc882_fixup_models[] = { |
| 5463 | {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"}, |
| 5464 | {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"}, |
| 5465 | {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5466 | {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | e427c23 | 2012-07-29 10:04:08 +0200 | [diff] [blame] | 5467 | {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"}, |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5468 | {} |
| 5469 | }; |
| 5470 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5471 | /* |
| 5472 | * BIOS auto configuration |
| 5473 | */ |
| 5474 | /* almost identical with ALC880 parser... */ |
| 5475 | static int alc882_parse_auto_config(struct hda_codec *codec) |
| 5476 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5477 | static const hda_nid_t alc882_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5478 | static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5479 | return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5480 | } |
| 5481 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5482 | /* |
| 5483 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5484 | static int patch_alc882(struct hda_codec *codec) |
| 5485 | { |
| 5486 | struct alc_spec *spec; |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5487 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5488 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5489 | err = alc_alloc_spec(codec, 0x0b); |
| 5490 | if (err < 0) |
| 5491 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5492 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5493 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5494 | |
| 5495 | switch (codec->vendor_id) { |
| 5496 | case 0x10ec0882: |
| 5497 | case 0x10ec0885: |
| 5498 | break; |
| 5499 | default: |
| 5500 | /* ALC883 and variants */ |
| 5501 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5502 | break; |
| 5503 | } |
| 5504 | |
Takashi Iwai | 912093b | 2012-04-11 14:03:41 +0200 | [diff] [blame] | 5505 | alc_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl, |
| 5506 | alc882_fixups); |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5507 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5508 | |
| 5509 | alc_auto_parse_customize_define(codec); |
| 5510 | |
Takashi Iwai | 1a97b7f | 2012-02-21 11:11:48 +0100 | [diff] [blame] | 5511 | /* automatic parse from the BIOS config */ |
| 5512 | err = alc882_parse_auto_config(codec); |
| 5513 | if (err < 0) |
| 5514 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5515 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5516 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5517 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5518 | if (err < 0) |
| 5519 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5520 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5521 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5522 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5523 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5524 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5525 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5526 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5527 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5528 | |
| 5529 | error: |
| 5530 | alc_free(codec); |
| 5531 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5532 | } |
| 5533 | |
| 5534 | |
| 5535 | /* |
| 5536 | * ALC262 support |
| 5537 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5538 | static int alc262_parse_auto_config(struct hda_codec *codec) |
| 5539 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5540 | static const hda_nid_t alc262_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5541 | static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5542 | return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5543 | } |
| 5544 | |
| 5545 | /* |
| 5546 | * Pin config fixes |
| 5547 | */ |
| 5548 | enum { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5549 | ALC262_FIXUP_FSC_H270, |
| 5550 | ALC262_FIXUP_HP_Z200, |
| 5551 | ALC262_FIXUP_TYAN, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5552 | ALC262_FIXUP_LENOVO_3000, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5553 | ALC262_FIXUP_BENQ, |
| 5554 | ALC262_FIXUP_BENQ_T31, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5555 | ALC262_FIXUP_INV_DMIC, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5556 | }; |
| 5557 | |
| 5558 | static const struct alc_fixup alc262_fixups[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5559 | [ALC262_FIXUP_FSC_H270] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5560 | .type = ALC_FIXUP_PINS, |
| 5561 | .v.pins = (const struct alc_pincfg[]) { |
| 5562 | { 0x14, 0x99130110 }, /* speaker */ |
| 5563 | { 0x15, 0x0221142f }, /* front HP */ |
| 5564 | { 0x1b, 0x0121141f }, /* rear HP */ |
| 5565 | { } |
| 5566 | } |
| 5567 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5568 | [ALC262_FIXUP_HP_Z200] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5569 | .type = ALC_FIXUP_PINS, |
| 5570 | .v.pins = (const struct alc_pincfg[]) { |
| 5571 | { 0x16, 0x99130120 }, /* internal speaker */ |
| 5572 | { } |
| 5573 | } |
| 5574 | }, |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5575 | [ALC262_FIXUP_TYAN] = { |
| 5576 | .type = ALC_FIXUP_PINS, |
| 5577 | .v.pins = (const struct alc_pincfg[]) { |
| 5578 | { 0x14, 0x1993e1f0 }, /* int AUX */ |
| 5579 | { } |
| 5580 | } |
| 5581 | }, |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5582 | [ALC262_FIXUP_LENOVO_3000] = { |
| 5583 | .type = ALC_FIXUP_VERBS, |
| 5584 | .v.verbs = (const struct hda_verb[]) { |
| 5585 | { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50 }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5586 | {} |
| 5587 | }, |
| 5588 | .chained = true, |
| 5589 | .chain_id = ALC262_FIXUP_BENQ, |
| 5590 | }, |
| 5591 | [ALC262_FIXUP_BENQ] = { |
| 5592 | .type = ALC_FIXUP_VERBS, |
| 5593 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5594 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5595 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 }, |
| 5596 | {} |
| 5597 | } |
| 5598 | }, |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5599 | [ALC262_FIXUP_BENQ_T31] = { |
| 5600 | .type = ALC_FIXUP_VERBS, |
| 5601 | .v.verbs = (const struct hda_verb[]) { |
| 5602 | { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, |
| 5603 | { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 }, |
| 5604 | {} |
| 5605 | } |
| 5606 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5607 | [ALC262_FIXUP_INV_DMIC] = { |
| 5608 | .type = ALC_FIXUP_FUNC, |
| 5609 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5610 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5611 | }; |
| 5612 | |
| 5613 | static const struct snd_pci_quirk alc262_fixup_tbl[] = { |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5614 | SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200), |
Takashi Iwai | 3dcd3be | 2011-11-07 14:59:40 +0100 | [diff] [blame] | 5615 | SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FIXUP_BENQ), |
| 5616 | SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ), |
Takashi Iwai | ea4e7af | 2011-11-07 12:23:55 +0100 | [diff] [blame] | 5617 | SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN), |
| 5618 | SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270), |
Takashi Iwai | c470150 | 2011-11-07 14:20:07 +0100 | [diff] [blame] | 5619 | SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000), |
Takashi Iwai | b42590b | 2011-11-07 14:41:01 +0100 | [diff] [blame] | 5620 | SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ), |
| 5621 | SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5622 | {} |
| 5623 | }; |
| 5624 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5625 | static const struct alc_model_fixup alc262_fixup_models[] = { |
| 5626 | {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
| 5627 | {} |
| 5628 | }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5629 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5630 | /* |
| 5631 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5632 | static int patch_alc262(struct hda_codec *codec) |
| 5633 | { |
| 5634 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5635 | int err; |
| 5636 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5637 | err = alc_alloc_spec(codec, 0x0b); |
| 5638 | if (err < 0) |
| 5639 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5640 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5641 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame^] | 5642 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5643 | |
| 5644 | #if 0 |
| 5645 | /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is |
| 5646 | * under-run |
| 5647 | */ |
| 5648 | { |
| 5649 | int tmp; |
| 5650 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5651 | tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0); |
| 5652 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7); |
| 5653 | snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80); |
| 5654 | } |
| 5655 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5656 | alc_fix_pll_init(codec, 0x20, 0x0a, 10); |
| 5657 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5658 | alc_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl, |
| 5659 | alc262_fixups); |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5660 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5661 | |
Takashi Iwai | af741c1 | 2012-05-07 18:09:48 +0200 | [diff] [blame] | 5662 | alc_auto_parse_customize_define(codec); |
| 5663 | |
Takashi Iwai | 42399f7 | 2011-11-07 17:18:44 +0100 | [diff] [blame] | 5664 | /* automatic parse from the BIOS config */ |
| 5665 | err = alc262_parse_auto_config(codec); |
| 5666 | if (err < 0) |
| 5667 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5668 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5669 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 5670 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5671 | if (err < 0) |
| 5672 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5673 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5674 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5675 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5676 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5677 | spec->shutup = alc_eapd_shutup; |
| 5678 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 5679 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5680 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5681 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5682 | |
| 5683 | error: |
| 5684 | alc_free(codec); |
| 5685 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5686 | } |
| 5687 | |
| 5688 | /* |
| 5689 | * ALC268 |
| 5690 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5691 | /* bind Beep switches of both NID 0x0f and 0x10 */ |
| 5692 | static const struct hda_bind_ctls alc268_bind_beep_sw = { |
| 5693 | .ops = &snd_hda_bind_sw, |
| 5694 | .values = { |
| 5695 | HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT), |
| 5696 | HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT), |
| 5697 | 0 |
| 5698 | }, |
| 5699 | }; |
| 5700 | |
| 5701 | static const struct snd_kcontrol_new alc268_beep_mixer[] = { |
| 5702 | HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT), |
| 5703 | HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw), |
| 5704 | { } |
| 5705 | }; |
| 5706 | |
| 5707 | /* set PCBEEP vol = 0, mute connections */ |
| 5708 | static const struct hda_verb alc268_beep_init_verbs[] = { |
| 5709 | {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
| 5710 | {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5711 | {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, |
| 5712 | { } |
| 5713 | }; |
| 5714 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5715 | enum { |
| 5716 | ALC268_FIXUP_INV_DMIC, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5717 | ALC268_FIXUP_HP_EAPD, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5718 | }; |
| 5719 | |
| 5720 | static const struct alc_fixup alc268_fixups[] = { |
| 5721 | [ALC268_FIXUP_INV_DMIC] = { |
| 5722 | .type = ALC_FIXUP_FUNC, |
| 5723 | .v.func = alc_fixup_inv_dmic_0x12, |
| 5724 | }, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5725 | [ALC268_FIXUP_HP_EAPD] = { |
| 5726 | .type = ALC_FIXUP_VERBS, |
| 5727 | .v.verbs = (const struct hda_verb[]) { |
| 5728 | {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 5729 | {} |
| 5730 | } |
| 5731 | }, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5732 | }; |
| 5733 | |
| 5734 | static const struct alc_model_fixup alc268_fixup_models[] = { |
| 5735 | {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5736 | {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"}, |
| 5737 | {} |
| 5738 | }; |
| 5739 | |
| 5740 | static const struct snd_pci_quirk alc268_fixup_tbl[] = { |
| 5741 | /* below is codec SSID since multiple Toshiba laptops have the |
| 5742 | * same PCI SSID 1179:ff00 |
| 5743 | */ |
| 5744 | SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD), |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5745 | {} |
| 5746 | }; |
| 5747 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5748 | /* |
| 5749 | * BIOS auto configuration |
| 5750 | */ |
| 5751 | static int alc268_parse_auto_config(struct hda_codec *codec) |
| 5752 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5753 | static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5754 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5755 | int err = alc_parse_auto_config(codec, NULL, alc268_ssids); |
| 5756 | if (err > 0) { |
| 5757 | if (!spec->no_analog && spec->autocfg.speaker_pins[0] != 0x1d) { |
| 5758 | add_mixer(spec, alc268_beep_mixer); |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 5759 | snd_hda_gen_add_verbs(&spec->gen, alc268_beep_init_verbs); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5760 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5761 | } |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5762 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5763 | } |
| 5764 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5765 | /* |
| 5766 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5767 | static int patch_alc268(struct hda_codec *codec) |
| 5768 | { |
| 5769 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5770 | int i, has_beep, err; |
| 5771 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5772 | /* ALC268 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 5773 | err = alc_alloc_spec(codec, 0); |
| 5774 | if (err < 0) |
| 5775 | return err; |
| 5776 | |
| 5777 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5778 | |
Takashi Iwai | cb76640 | 2012-10-20 10:55:21 +0200 | [diff] [blame] | 5779 | alc_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups); |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5780 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 5781 | |
Takashi Iwai | 6ebb805 | 2011-08-16 15:15:40 +0200 | [diff] [blame] | 5782 | /* automatic parse from the BIOS config */ |
| 5783 | err = alc268_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5784 | if (err < 0) |
| 5785 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5786 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5787 | has_beep = 0; |
| 5788 | for (i = 0; i < spec->num_mixers; i++) { |
| 5789 | if (spec->mixers[i] == alc268_beep_mixer) { |
| 5790 | has_beep = 1; |
| 5791 | break; |
| 5792 | } |
| 5793 | } |
| 5794 | |
| 5795 | if (has_beep) { |
| 5796 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5797 | if (err < 0) |
| 5798 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5799 | if (!query_amp_caps(codec, 0x1d, HDA_INPUT)) |
| 5800 | /* override the amp caps for beep generator */ |
| 5801 | snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT, |
| 5802 | (0x0c << AC_AMPCAP_OFFSET_SHIFT) | |
| 5803 | (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 5804 | (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 5805 | (0 << AC_AMPCAP_MUTE_SHIFT)); |
| 5806 | } |
| 5807 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5808 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5809 | spec->shutup = alc_eapd_shutup; |
| 5810 | |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 5811 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 5812 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5813 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 5814 | |
| 5815 | error: |
| 5816 | alc_free(codec); |
| 5817 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5818 | } |
| 5819 | |
| 5820 | /* |
| 5821 | * ALC269 |
| 5822 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5823 | static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = { |
| 5824 | .substreams = 1, |
| 5825 | .channels_min = 2, |
| 5826 | .channels_max = 8, |
| 5827 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5828 | /* NID is set in alc_build_pcms */ |
| 5829 | .ops = { |
| 5830 | .open = alc_playback_pcm_open, |
| 5831 | .prepare = alc_playback_pcm_prepare, |
| 5832 | .cleanup = alc_playback_pcm_cleanup |
| 5833 | }, |
| 5834 | }; |
| 5835 | |
| 5836 | static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = { |
| 5837 | .substreams = 1, |
| 5838 | .channels_min = 2, |
| 5839 | .channels_max = 2, |
| 5840 | .rates = SNDRV_PCM_RATE_44100, /* fixed rate */ |
| 5841 | /* NID is set in alc_build_pcms */ |
| 5842 | }; |
| 5843 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5844 | /* different alc269-variants */ |
| 5845 | enum { |
| 5846 | ALC269_TYPE_ALC269VA, |
| 5847 | ALC269_TYPE_ALC269VB, |
| 5848 | ALC269_TYPE_ALC269VC, |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5849 | ALC269_TYPE_ALC269VD, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5850 | ALC269_TYPE_ALC280, |
| 5851 | ALC269_TYPE_ALC282, |
| 5852 | ALC269_TYPE_ALC284, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5853 | }; |
| 5854 | |
| 5855 | /* |
| 5856 | * BIOS auto configuration |
| 5857 | */ |
| 5858 | static int alc269_parse_auto_config(struct hda_codec *codec) |
| 5859 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5860 | static const hda_nid_t alc269_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5861 | static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 }; |
| 5862 | static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 5863 | struct alc_spec *spec = codec->spec; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5864 | const hda_nid_t *ssids; |
| 5865 | |
| 5866 | switch (spec->codec_variant) { |
| 5867 | case ALC269_TYPE_ALC269VA: |
| 5868 | case ALC269_TYPE_ALC269VC: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5869 | case ALC269_TYPE_ALC280: |
| 5870 | case ALC269_TYPE_ALC284: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5871 | ssids = alc269va_ssids; |
| 5872 | break; |
| 5873 | case ALC269_TYPE_ALC269VB: |
| 5874 | case ALC269_TYPE_ALC269VD: |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 5875 | case ALC269_TYPE_ALC282: |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5876 | ssids = alc269_ssids; |
| 5877 | break; |
| 5878 | default: |
| 5879 | ssids = alc269_ssids; |
| 5880 | break; |
| 5881 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5882 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 5883 | return alc_parse_auto_config(codec, alc269_ignore, ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5884 | } |
| 5885 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 5886 | static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5887 | { |
| 5888 | int val = alc_read_coef_idx(codec, 0x04); |
| 5889 | if (power_up) |
| 5890 | val |= 1 << 11; |
| 5891 | else |
| 5892 | val &= ~(1 << 11); |
| 5893 | alc_write_coef_idx(codec, 0x04, val); |
| 5894 | } |
| 5895 | |
| 5896 | static void alc269_shutup(struct hda_codec *codec) |
| 5897 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5898 | struct alc_spec *spec = codec->spec; |
| 5899 | |
| 5900 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
| 5901 | return; |
| 5902 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 5903 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 5904 | alc269vb_toggle_power_output(codec, 0); |
| 5905 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
| 5906 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5907 | msleep(150); |
| 5908 | } |
| 5909 | } |
| 5910 | |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5911 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5912 | static int alc269_resume(struct hda_codec *codec) |
| 5913 | { |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5914 | struct alc_spec *spec = codec->spec; |
| 5915 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 5916 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 5917 | alc269vb_toggle_power_output(codec, 0); |
| 5918 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5919 | (alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5920 | msleep(150); |
| 5921 | } |
| 5922 | |
| 5923 | codec->patch_ops.init(codec); |
| 5924 | |
Kailang Yang | 1387e2d | 2012-11-08 10:23:18 +0100 | [diff] [blame] | 5925 | if (spec->codec_variant == ALC269_TYPE_ALC269VB) |
| 5926 | alc269vb_toggle_power_output(codec, 1); |
| 5927 | if (spec->codec_variant == ALC269_TYPE_ALC269VB && |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 5928 | (alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5929 | msleep(200); |
| 5930 | } |
| 5931 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5932 | snd_hda_codec_resume_amp(codec); |
| 5933 | snd_hda_codec_resume_cache(codec); |
| 5934 | hda_call_check_power_status(codec, 0x01); |
| 5935 | return 0; |
| 5936 | } |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 5937 | #endif /* CONFIG_PM */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5938 | |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 5939 | static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec, |
| 5940 | const struct alc_fixup *fix, int action) |
| 5941 | { |
| 5942 | struct alc_spec *spec = codec->spec; |
| 5943 | |
| 5944 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 5945 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 5946 | } |
| 5947 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 5948 | static void alc269_fixup_hweq(struct hda_codec *codec, |
| 5949 | const struct alc_fixup *fix, int action) |
| 5950 | { |
| 5951 | int coef; |
| 5952 | |
| 5953 | if (action != ALC_FIXUP_ACT_INIT) |
| 5954 | return; |
| 5955 | coef = alc_read_coef_idx(codec, 0x1e); |
| 5956 | alc_write_coef_idx(codec, 0x1e, coef | 0x80); |
| 5957 | } |
| 5958 | |
| 5959 | static void alc271_fixup_dmic(struct hda_codec *codec, |
| 5960 | const struct alc_fixup *fix, int action) |
| 5961 | { |
| 5962 | static const struct hda_verb verbs[] = { |
| 5963 | {0x20, AC_VERB_SET_COEF_INDEX, 0x0d}, |
| 5964 | {0x20, AC_VERB_SET_PROC_COEF, 0x4000}, |
| 5965 | {} |
| 5966 | }; |
| 5967 | unsigned int cfg; |
| 5968 | |
| 5969 | if (strcmp(codec->chip_name, "ALC271X")) |
| 5970 | return; |
| 5971 | cfg = snd_hda_codec_get_pincfg(codec, 0x12); |
| 5972 | if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED) |
| 5973 | snd_hda_sequence_write(codec, verbs); |
| 5974 | } |
| 5975 | |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 5976 | static void alc269_fixup_pcm_44k(struct hda_codec *codec, |
| 5977 | const struct alc_fixup *fix, int action) |
| 5978 | { |
| 5979 | struct alc_spec *spec = codec->spec; |
| 5980 | |
| 5981 | if (action != ALC_FIXUP_ACT_PROBE) |
| 5982 | return; |
| 5983 | |
| 5984 | /* Due to a hardware problem on Lenovo Ideadpad, we need to |
| 5985 | * fix the sample rate of analog I/O to 44.1kHz |
| 5986 | */ |
| 5987 | spec->stream_analog_playback = &alc269_44k_pcm_analog_playback; |
| 5988 | spec->stream_analog_capture = &alc269_44k_pcm_analog_capture; |
| 5989 | } |
| 5990 | |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 5991 | static void alc269_fixup_stereo_dmic(struct hda_codec *codec, |
| 5992 | const struct alc_fixup *fix, int action) |
| 5993 | { |
| 5994 | int coef; |
| 5995 | |
| 5996 | if (action != ALC_FIXUP_ACT_INIT) |
| 5997 | return; |
| 5998 | /* The digital-mic unit sends PDM (differential signal) instead of |
| 5999 | * the standard PCM, thus you can't record a valid mono stream as is. |
| 6000 | * Below is a workaround specific to ALC269 to control the dmic |
| 6001 | * signal source as mono. |
| 6002 | */ |
| 6003 | coef = alc_read_coef_idx(codec, 0x07); |
| 6004 | alc_write_coef_idx(codec, 0x07, coef | 0x80); |
| 6005 | } |
| 6006 | |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6007 | static void alc269_quanta_automute(struct hda_codec *codec) |
| 6008 | { |
David Henningsson | 42cf0d0 | 2011-09-20 12:04:56 +0200 | [diff] [blame] | 6009 | update_outputs(codec); |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6010 | |
| 6011 | snd_hda_codec_write(codec, 0x20, 0, |
| 6012 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6013 | snd_hda_codec_write(codec, 0x20, 0, |
| 6014 | AC_VERB_SET_PROC_COEF, 0x680); |
| 6015 | |
| 6016 | snd_hda_codec_write(codec, 0x20, 0, |
| 6017 | AC_VERB_SET_COEF_INDEX, 0x0c); |
| 6018 | snd_hda_codec_write(codec, 0x20, 0, |
| 6019 | AC_VERB_SET_PROC_COEF, 0x480); |
| 6020 | } |
| 6021 | |
| 6022 | static void alc269_fixup_quanta_mute(struct hda_codec *codec, |
| 6023 | const struct alc_fixup *fix, int action) |
| 6024 | { |
| 6025 | struct alc_spec *spec = codec->spec; |
| 6026 | if (action != ALC_FIXUP_ACT_PROBE) |
| 6027 | return; |
| 6028 | spec->automute_hook = alc269_quanta_automute; |
| 6029 | } |
| 6030 | |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6031 | /* update mute-LED according to the speaker mute state via mic1 VREF pin */ |
| 6032 | static void alc269_fixup_mic1_mute_hook(void *private_data, int enabled) |
| 6033 | { |
| 6034 | struct hda_codec *codec = private_data; |
| 6035 | unsigned int pinval = AC_PINCTL_IN_EN + (enabled ? |
| 6036 | AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80); |
| 6037 | snd_hda_set_pin_ctl_cache(codec, 0x18, pinval); |
| 6038 | } |
| 6039 | |
| 6040 | static void alc269_fixup_mic1_mute(struct hda_codec *codec, |
| 6041 | const struct alc_fixup *fix, int action) |
| 6042 | { |
| 6043 | struct alc_spec *spec = codec->spec; |
| 6044 | switch (action) { |
| 6045 | case ALC_FIXUP_ACT_BUILD: |
| 6046 | spec->vmaster_mute.hook = alc269_fixup_mic1_mute_hook; |
| 6047 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
| 6048 | /* fallthru */ |
| 6049 | case ALC_FIXUP_ACT_INIT: |
| 6050 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
| 6051 | break; |
| 6052 | } |
| 6053 | } |
| 6054 | |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6055 | /* update mute-LED according to the speaker mute state via mic2 VREF pin */ |
| 6056 | static void alc269_fixup_mic2_mute_hook(void *private_data, int enabled) |
| 6057 | { |
| 6058 | struct hda_codec *codec = private_data; |
| 6059 | unsigned int pinval = enabled ? 0x20 : 0x24; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6060 | snd_hda_set_pin_ctl_cache(codec, 0x19, pinval); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6061 | } |
| 6062 | |
| 6063 | static void alc269_fixup_mic2_mute(struct hda_codec *codec, |
| 6064 | const struct alc_fixup *fix, int action) |
| 6065 | { |
| 6066 | struct alc_spec *spec = codec->spec; |
| 6067 | switch (action) { |
| 6068 | case ALC_FIXUP_ACT_BUILD: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6069 | spec->vmaster_mute.hook = alc269_fixup_mic2_mute_hook; |
Takashi Iwai | f29735c | 2012-03-13 07:55:10 +0100 | [diff] [blame] | 6070 | snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6071 | /* fallthru */ |
| 6072 | case ALC_FIXUP_ACT_INIT: |
Takashi Iwai | d2f344b | 2012-03-12 16:59:58 +0100 | [diff] [blame] | 6073 | snd_hda_sync_vmaster_hook(&spec->vmaster_mute); |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6074 | break; |
| 6075 | } |
| 6076 | } |
| 6077 | |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6078 | static void alc271_hp_gate_mic_jack(struct hda_codec *codec, |
| 6079 | const struct alc_fixup *fix, |
| 6080 | int action) |
| 6081 | { |
| 6082 | struct alc_spec *spec = codec->spec; |
| 6083 | |
| 6084 | if (action == ALC_FIXUP_ACT_PROBE) |
| 6085 | snd_hda_jack_set_gating_jack(codec, spec->ext_mic_pin, |
| 6086 | spec->autocfg.hp_pins[0]); |
| 6087 | } |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6088 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6089 | enum { |
| 6090 | ALC269_FIXUP_SONY_VAIO, |
| 6091 | ALC275_FIXUP_SONY_VAIO_GPIO2, |
| 6092 | ALC269_FIXUP_DELL_M101Z, |
| 6093 | ALC269_FIXUP_SKU_IGNORE, |
| 6094 | ALC269_FIXUP_ASUS_G73JW, |
| 6095 | ALC269_FIXUP_LENOVO_EAPD, |
| 6096 | ALC275_FIXUP_SONY_HWEQ, |
| 6097 | ALC271_FIXUP_DMIC, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6098 | ALC269_FIXUP_PCM_44K, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6099 | ALC269_FIXUP_STEREO_DMIC, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6100 | ALC269_FIXUP_QUANTA_MUTE, |
| 6101 | ALC269_FIXUP_LIFEBOOK, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6102 | ALC269_FIXUP_AMIC, |
| 6103 | ALC269_FIXUP_DMIC, |
| 6104 | ALC269VB_FIXUP_AMIC, |
| 6105 | ALC269VB_FIXUP_DMIC, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6106 | ALC269_FIXUP_MIC1_MUTE_LED, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6107 | ALC269_FIXUP_MIC2_MUTE_LED, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6108 | ALC269_FIXUP_INV_DMIC, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6109 | ALC269_FIXUP_LENOVO_DOCK, |
| 6110 | ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6111 | ALC271_FIXUP_AMIC_MIC2, |
| 6112 | ALC271_FIXUP_HP_GATE_MIC_JACK, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6113 | }; |
| 6114 | |
| 6115 | static const struct alc_fixup alc269_fixups[] = { |
| 6116 | [ALC269_FIXUP_SONY_VAIO] = { |
| 6117 | .type = ALC_FIXUP_VERBS, |
| 6118 | .v.verbs = (const struct hda_verb[]) { |
| 6119 | {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREFGRD}, |
| 6120 | {} |
| 6121 | } |
| 6122 | }, |
| 6123 | [ALC275_FIXUP_SONY_VAIO_GPIO2] = { |
| 6124 | .type = ALC_FIXUP_VERBS, |
| 6125 | .v.verbs = (const struct hda_verb[]) { |
| 6126 | {0x01, AC_VERB_SET_GPIO_MASK, 0x04}, |
| 6127 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04}, |
| 6128 | {0x01, AC_VERB_SET_GPIO_DATA, 0x00}, |
| 6129 | { } |
| 6130 | }, |
| 6131 | .chained = true, |
| 6132 | .chain_id = ALC269_FIXUP_SONY_VAIO |
| 6133 | }, |
| 6134 | [ALC269_FIXUP_DELL_M101Z] = { |
| 6135 | .type = ALC_FIXUP_VERBS, |
| 6136 | .v.verbs = (const struct hda_verb[]) { |
| 6137 | /* Enables internal speaker */ |
| 6138 | {0x20, AC_VERB_SET_COEF_INDEX, 13}, |
| 6139 | {0x20, AC_VERB_SET_PROC_COEF, 0x4040}, |
| 6140 | {} |
| 6141 | } |
| 6142 | }, |
| 6143 | [ALC269_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6144 | .type = ALC_FIXUP_FUNC, |
| 6145 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6146 | }, |
| 6147 | [ALC269_FIXUP_ASUS_G73JW] = { |
| 6148 | .type = ALC_FIXUP_PINS, |
| 6149 | .v.pins = (const struct alc_pincfg[]) { |
| 6150 | { 0x17, 0x99130111 }, /* subwoofer */ |
| 6151 | { } |
| 6152 | } |
| 6153 | }, |
| 6154 | [ALC269_FIXUP_LENOVO_EAPD] = { |
| 6155 | .type = ALC_FIXUP_VERBS, |
| 6156 | .v.verbs = (const struct hda_verb[]) { |
| 6157 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6158 | {} |
| 6159 | } |
| 6160 | }, |
| 6161 | [ALC275_FIXUP_SONY_HWEQ] = { |
| 6162 | .type = ALC_FIXUP_FUNC, |
| 6163 | .v.func = alc269_fixup_hweq, |
| 6164 | .chained = true, |
| 6165 | .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2 |
| 6166 | }, |
| 6167 | [ALC271_FIXUP_DMIC] = { |
| 6168 | .type = ALC_FIXUP_FUNC, |
| 6169 | .v.func = alc271_fixup_dmic, |
| 6170 | }, |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6171 | [ALC269_FIXUP_PCM_44K] = { |
| 6172 | .type = ALC_FIXUP_FUNC, |
| 6173 | .v.func = alc269_fixup_pcm_44k, |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6174 | .chained = true, |
| 6175 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6176 | }, |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6177 | [ALC269_FIXUP_STEREO_DMIC] = { |
| 6178 | .type = ALC_FIXUP_FUNC, |
| 6179 | .v.func = alc269_fixup_stereo_dmic, |
| 6180 | }, |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6181 | [ALC269_FIXUP_QUANTA_MUTE] = { |
| 6182 | .type = ALC_FIXUP_FUNC, |
| 6183 | .v.func = alc269_fixup_quanta_mute, |
| 6184 | }, |
| 6185 | [ALC269_FIXUP_LIFEBOOK] = { |
| 6186 | .type = ALC_FIXUP_PINS, |
| 6187 | .v.pins = (const struct alc_pincfg[]) { |
| 6188 | { 0x1a, 0x2101103f }, /* dock line-out */ |
| 6189 | { 0x1b, 0x23a11040 }, /* dock mic-in */ |
| 6190 | { } |
| 6191 | }, |
| 6192 | .chained = true, |
| 6193 | .chain_id = ALC269_FIXUP_QUANTA_MUTE |
| 6194 | }, |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6195 | [ALC269_FIXUP_AMIC] = { |
| 6196 | .type = ALC_FIXUP_PINS, |
| 6197 | .v.pins = (const struct alc_pincfg[]) { |
| 6198 | { 0x14, 0x99130110 }, /* speaker */ |
| 6199 | { 0x15, 0x0121401f }, /* HP out */ |
| 6200 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6201 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6202 | { } |
| 6203 | }, |
| 6204 | }, |
| 6205 | [ALC269_FIXUP_DMIC] = { |
| 6206 | .type = ALC_FIXUP_PINS, |
| 6207 | .v.pins = (const struct alc_pincfg[]) { |
| 6208 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6209 | { 0x14, 0x99130110 }, /* speaker */ |
| 6210 | { 0x15, 0x0121401f }, /* HP out */ |
| 6211 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6212 | { } |
| 6213 | }, |
| 6214 | }, |
| 6215 | [ALC269VB_FIXUP_AMIC] = { |
| 6216 | .type = ALC_FIXUP_PINS, |
| 6217 | .v.pins = (const struct alc_pincfg[]) { |
| 6218 | { 0x14, 0x99130110 }, /* speaker */ |
| 6219 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6220 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6221 | { 0x21, 0x0121401f }, /* HP out */ |
| 6222 | { } |
| 6223 | }, |
| 6224 | }, |
David Henningsson | 2267ea9 | 2012-01-03 08:45:56 +0100 | [diff] [blame] | 6225 | [ALC269VB_FIXUP_DMIC] = { |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6226 | .type = ALC_FIXUP_PINS, |
| 6227 | .v.pins = (const struct alc_pincfg[]) { |
| 6228 | { 0x12, 0x99a3092f }, /* int-mic */ |
| 6229 | { 0x14, 0x99130110 }, /* speaker */ |
| 6230 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6231 | { 0x21, 0x0121401f }, /* HP out */ |
| 6232 | { } |
| 6233 | }, |
| 6234 | }, |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6235 | [ALC269_FIXUP_MIC1_MUTE_LED] = { |
| 6236 | .type = ALC_FIXUP_FUNC, |
| 6237 | .v.func = alc269_fixup_mic1_mute, |
| 6238 | }, |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6239 | [ALC269_FIXUP_MIC2_MUTE_LED] = { |
| 6240 | .type = ALC_FIXUP_FUNC, |
| 6241 | .v.func = alc269_fixup_mic2_mute, |
| 6242 | }, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6243 | [ALC269_FIXUP_INV_DMIC] = { |
| 6244 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6245 | .v.func = alc_fixup_inv_dmic_0x12, |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6246 | }, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6247 | [ALC269_FIXUP_LENOVO_DOCK] = { |
| 6248 | .type = ALC_FIXUP_PINS, |
| 6249 | .v.pins = (const struct alc_pincfg[]) { |
| 6250 | { 0x19, 0x23a11040 }, /* dock mic */ |
| 6251 | { 0x1b, 0x2121103f }, /* dock headphone */ |
| 6252 | { } |
| 6253 | }, |
| 6254 | .chained = true, |
| 6255 | .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT |
| 6256 | }, |
| 6257 | [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = { |
| 6258 | .type = ALC_FIXUP_FUNC, |
| 6259 | .v.func = alc269_fixup_pincfg_no_hp_to_lineout, |
| 6260 | }, |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6261 | [ALC271_FIXUP_AMIC_MIC2] = { |
| 6262 | .type = ALC_FIXUP_PINS, |
| 6263 | .v.pins = (const struct alc_pincfg[]) { |
| 6264 | { 0x14, 0x99130110 }, /* speaker */ |
| 6265 | { 0x19, 0x01a19c20 }, /* mic */ |
| 6266 | { 0x1b, 0x99a7012f }, /* int-mic */ |
| 6267 | { 0x21, 0x0121401f }, /* HP out */ |
| 6268 | { } |
| 6269 | }, |
| 6270 | }, |
| 6271 | [ALC271_FIXUP_HP_GATE_MIC_JACK] = { |
| 6272 | .type = ALC_FIXUP_FUNC, |
| 6273 | .v.func = alc271_hp_gate_mic_jack, |
| 6274 | .chained = true, |
| 6275 | .chain_id = ALC271_FIXUP_AMIC_MIC2, |
| 6276 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6277 | }; |
| 6278 | |
| 6279 | static const struct snd_pci_quirk alc269_fixup_tbl[] = { |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6280 | SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC), |
| 6281 | SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | 420b0fe | 2012-03-12 12:35:27 +0100 | [diff] [blame] | 6282 | SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_MIC2_MUTE_LED), |
David Henningsson | 6d3cd5d | 2013-01-07 12:03:47 +0100 | [diff] [blame] | 6283 | SND_PCI_QUIRK(0x103c, 0x1972, "HP Pavilion 17", ALC269_FIXUP_MIC1_MUTE_LED), |
David Henningsson | 5ac5755 | 2012-04-20 10:01:46 +0200 | [diff] [blame] | 6284 | SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC), |
Oleksij Rempel | 148728f | 2012-09-21 17:44:58 +0200 | [diff] [blame] | 6285 | SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC), |
Takashi Iwai | 017f2a1 | 2011-07-09 14:42:25 +0200 | [diff] [blame] | 6286 | SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW), |
David Henningsson | 693b613 | 2012-06-22 19:12:10 +0200 | [diff] [blame] | 6287 | SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC), |
Takashi Iwai | adabb3e | 2011-08-03 07:48:37 +0200 | [diff] [blame] | 6288 | SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC), |
| 6289 | SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), |
| 6290 | SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), |
| 6291 | SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
| 6292 | SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6293 | SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2), |
| 6294 | SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6295 | SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ), |
| 6296 | SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO), |
| 6297 | SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), |
Dylan Reid | 08a978d | 2012-11-18 22:56:40 -0800 | [diff] [blame] | 6298 | SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6299 | SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), |
Takashi Iwai | 2451991 | 2011-08-16 15:08:49 +0200 | [diff] [blame] | 6300 | SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6301 | SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE), |
| 6302 | SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE), |
| 6303 | SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE), |
| 6304 | SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE), |
| 6305 | SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), |
Takashi Iwai | 707fba3 | 2012-08-02 09:04:39 +0200 | [diff] [blame] | 6306 | SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), |
Felix Kaechele | c8415a4 | 2012-08-06 23:02:01 +0200 | [diff] [blame] | 6307 | SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), |
Stefán Freyr | 84f98fd | 2012-10-19 22:46:00 +0200 | [diff] [blame] | 6308 | SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK), |
Philipp A. Mohrenweiser | 4407be6 | 2012-08-06 13:14:18 +0200 | [diff] [blame] | 6309 | SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6310 | SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), |
David Henningsson | 012e7eb | 2012-08-08 08:43:37 +0200 | [diff] [blame] | 6311 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6312 | SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6313 | |
Takashi Iwai | a7f3eed | 2012-02-16 13:03:18 +0100 | [diff] [blame] | 6314 | #if 0 |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6315 | /* Below is a quirk table taken from the old code. |
| 6316 | * Basically the device should work as is without the fixup table. |
| 6317 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6318 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6319 | */ |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6320 | SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A", |
| 6321 | ALC269_FIXUP_AMIC), |
| 6322 | SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC), |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6323 | SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC), |
| 6324 | SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC), |
| 6325 | SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC), |
| 6326 | SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC), |
| 6327 | SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC), |
| 6328 | SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC), |
| 6329 | SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC), |
| 6330 | SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC), |
| 6331 | SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC), |
| 6332 | SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC), |
| 6333 | SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC), |
| 6334 | SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC), |
| 6335 | SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC), |
| 6336 | SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC), |
| 6337 | SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC), |
| 6338 | SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC), |
| 6339 | SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC), |
| 6340 | SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC), |
| 6341 | SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC), |
| 6342 | SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC), |
| 6343 | SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC), |
| 6344 | SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC), |
| 6345 | SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC), |
| 6346 | SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC), |
| 6347 | SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC), |
| 6348 | SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC), |
| 6349 | SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC), |
| 6350 | SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC), |
| 6351 | SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC), |
| 6352 | SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC), |
| 6353 | SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC), |
| 6354 | SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC), |
| 6355 | SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC), |
| 6356 | SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC), |
| 6357 | SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC), |
| 6358 | SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC), |
| 6359 | SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC), |
| 6360 | SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC), |
| 6361 | #endif |
| 6362 | {} |
| 6363 | }; |
| 6364 | |
| 6365 | static const struct alc_model_fixup alc269_fixup_models[] = { |
| 6366 | {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"}, |
| 6367 | {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6368 | {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"}, |
| 6369 | {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"}, |
| 6370 | {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
David Henningsson | 108cc10 | 2012-07-20 10:37:25 +0200 | [diff] [blame] | 6371 | {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"}, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6372 | {} |
| 6373 | }; |
| 6374 | |
| 6375 | |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6376 | static void alc269_fill_coef(struct hda_codec *codec) |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6377 | { |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6378 | struct alc_spec *spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6379 | int val; |
| 6380 | |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6381 | if (spec->codec_variant != ALC269_TYPE_ALC269VB) |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6382 | return; |
Kailang Yang | 526af6e | 2012-03-07 08:25:20 +0100 | [diff] [blame] | 6383 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6384 | if ((alc_get_coef0(codec) & 0x00ff) < 0x015) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6385 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6386 | alc_write_coef_idx(codec, 0xe, 0x8817); |
| 6387 | } |
| 6388 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6389 | if ((alc_get_coef0(codec) & 0x00ff) == 0x016) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6390 | alc_write_coef_idx(codec, 0xf, 0x960b); |
| 6391 | alc_write_coef_idx(codec, 0xe, 0x8814); |
| 6392 | } |
| 6393 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6394 | if ((alc_get_coef0(codec) & 0x00ff) == 0x017) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6395 | val = alc_read_coef_idx(codec, 0x04); |
| 6396 | /* Power up output pin */ |
| 6397 | alc_write_coef_idx(codec, 0x04, val | (1<<11)); |
| 6398 | } |
| 6399 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6400 | if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6401 | val = alc_read_coef_idx(codec, 0xd); |
| 6402 | if ((val & 0x0c00) >> 10 != 0x1) { |
| 6403 | /* Capless ramp up clock control */ |
| 6404 | alc_write_coef_idx(codec, 0xd, val | (1<<10)); |
| 6405 | } |
| 6406 | val = alc_read_coef_idx(codec, 0x17); |
| 6407 | if ((val & 0x01c0) >> 6 != 0x4) { |
| 6408 | /* Class D power on reset */ |
| 6409 | alc_write_coef_idx(codec, 0x17, val | (1<<7)); |
| 6410 | } |
| 6411 | } |
| 6412 | |
| 6413 | val = alc_read_coef_idx(codec, 0xd); /* Class D */ |
| 6414 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 6415 | |
| 6416 | val = alc_read_coef_idx(codec, 0x4); /* HP */ |
| 6417 | alc_write_coef_idx(codec, 0x4, val | (1<<11)); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6418 | } |
| 6419 | |
| 6420 | /* |
| 6421 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6422 | static int patch_alc269(struct hda_codec *codec) |
| 6423 | { |
| 6424 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6425 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6426 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6427 | err = alc_alloc_spec(codec, 0x0b); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6428 | if (err < 0) |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6429 | return err; |
| 6430 | |
| 6431 | spec = codec->spec; |
Takashi Iwai | 37c0420 | 2012-12-18 14:22:45 +0100 | [diff] [blame^] | 6432 | spec->shared_mic_vref_pin = 0x18; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6433 | |
Herton Ronaldo Krzesinski | 9f720bb9 | 2012-09-27 10:38:14 -0300 | [diff] [blame] | 6434 | alc_pick_fixup(codec, alc269_fixup_models, |
| 6435 | alc269_fixup_tbl, alc269_fixups); |
| 6436 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 6437 | |
| 6438 | alc_auto_parse_customize_define(codec); |
| 6439 | |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6440 | switch (codec->vendor_id) { |
| 6441 | case 0x10ec0269: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6442 | spec->codec_variant = ALC269_TYPE_ALC269VA; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6443 | switch (alc_get_coef0(codec) & 0x00f0) { |
| 6444 | case 0x0010: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6445 | if (codec->bus->pci->subsystem_vendor == 0x1025 && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6446 | spec->cdefine.platform_type == 1) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6447 | err = alc_codec_rename(codec, "ALC271X"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6448 | spec->codec_variant = ALC269_TYPE_ALC269VB; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6449 | break; |
| 6450 | case 0x0020: |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6451 | if (codec->bus->pci->subsystem_vendor == 0x17aa && |
| 6452 | codec->bus->pci->subsystem_device == 0x21f3) |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 6453 | err = alc_codec_rename(codec, "ALC3202"); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6454 | spec->codec_variant = ALC269_TYPE_ALC269VC; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6455 | break; |
Kailang Yang | adcc70b | 2012-05-25 08:08:38 +0200 | [diff] [blame] | 6456 | case 0x0030: |
| 6457 | spec->codec_variant = ALC269_TYPE_ALC269VD; |
| 6458 | break; |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6459 | default: |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6460 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 6461 | } |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6462 | if (err < 0) |
| 6463 | goto error; |
Takashi Iwai | 546bb67 | 2012-03-07 08:37:19 +0100 | [diff] [blame] | 6464 | spec->init_hook = alc269_fill_coef; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6465 | alc269_fill_coef(codec); |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 6466 | break; |
| 6467 | |
| 6468 | case 0x10ec0280: |
| 6469 | case 0x10ec0290: |
| 6470 | spec->codec_variant = ALC269_TYPE_ALC280; |
| 6471 | break; |
| 6472 | case 0x10ec0282: |
| 6473 | case 0x10ec0283: |
| 6474 | spec->codec_variant = ALC269_TYPE_ALC282; |
| 6475 | break; |
| 6476 | case 0x10ec0284: |
| 6477 | case 0x10ec0292: |
| 6478 | spec->codec_variant = ALC269_TYPE_ALC284; |
| 6479 | break; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6480 | } |
| 6481 | |
Takashi Iwai | a4297b5 | 2011-08-23 18:40:12 +0200 | [diff] [blame] | 6482 | /* automatic parse from the BIOS config */ |
| 6483 | err = alc269_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6484 | if (err < 0) |
| 6485 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6486 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6487 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 6488 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6489 | if (err < 0) |
| 6490 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6491 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6492 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6493 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6494 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 2a43952 | 2011-07-26 09:52:50 +0200 | [diff] [blame] | 6495 | #ifdef CONFIG_PM |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6496 | codec->patch_ops.resume = alc269_resume; |
| 6497 | #endif |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6498 | spec->shutup = alc269_shutup; |
| 6499 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6500 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6501 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6502 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6503 | |
| 6504 | error: |
| 6505 | alc_free(codec); |
| 6506 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6507 | } |
| 6508 | |
| 6509 | /* |
| 6510 | * ALC861 |
| 6511 | */ |
| 6512 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6513 | static int alc861_parse_auto_config(struct hda_codec *codec) |
| 6514 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6515 | static const hda_nid_t alc861_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6516 | static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 }; |
| 6517 | return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6518 | } |
| 6519 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6520 | /* Pin config fixes */ |
| 6521 | enum { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6522 | ALC861_FIXUP_FSC_AMILO_PI1505, |
| 6523 | ALC861_FIXUP_AMP_VREF_0F, |
| 6524 | ALC861_FIXUP_NO_JACK_DETECT, |
| 6525 | ALC861_FIXUP_ASUS_A6RP, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6526 | }; |
| 6527 | |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6528 | /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */ |
| 6529 | static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec, |
| 6530 | const struct alc_fixup *fix, int action) |
| 6531 | { |
| 6532 | struct alc_spec *spec = codec->spec; |
| 6533 | unsigned int val; |
| 6534 | |
| 6535 | if (action != ALC_FIXUP_ACT_INIT) |
| 6536 | return; |
| 6537 | val = snd_hda_codec_read(codec, 0x0f, 0, |
| 6538 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
| 6539 | if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))) |
| 6540 | val |= AC_PINCTL_IN_EN; |
| 6541 | val |= AC_PINCTL_VREF_50; |
Takashi Iwai | cdd03ce | 2012-04-20 12:34:50 +0200 | [diff] [blame] | 6542 | snd_hda_set_pin_ctl(codec, 0x0f, val); |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6543 | spec->keep_vref_in_automute = 1; |
| 6544 | } |
| 6545 | |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6546 | /* suppress the jack-detection */ |
| 6547 | static void alc_fixup_no_jack_detect(struct hda_codec *codec, |
| 6548 | const struct alc_fixup *fix, int action) |
| 6549 | { |
| 6550 | if (action == ALC_FIXUP_ACT_PRE_PROBE) |
| 6551 | codec->no_jack_detect = 1; |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6552 | } |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6553 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6554 | static const struct alc_fixup alc861_fixups[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6555 | [ALC861_FIXUP_FSC_AMILO_PI1505] = { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6556 | .type = ALC_FIXUP_PINS, |
| 6557 | .v.pins = (const struct alc_pincfg[]) { |
| 6558 | { 0x0b, 0x0221101f }, /* HP */ |
| 6559 | { 0x0f, 0x90170310 }, /* speaker */ |
| 6560 | { } |
| 6561 | } |
| 6562 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6563 | [ALC861_FIXUP_AMP_VREF_0F] = { |
Takashi Iwai | 31150f2 | 2012-01-30 10:54:08 +0100 | [diff] [blame] | 6564 | .type = ALC_FIXUP_FUNC, |
| 6565 | .v.func = alc861_fixup_asus_amp_vref_0f, |
Takashi Iwai | 3b25eb6 | 2012-01-25 09:55:46 +0100 | [diff] [blame] | 6566 | }, |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6567 | [ALC861_FIXUP_NO_JACK_DETECT] = { |
| 6568 | .type = ALC_FIXUP_FUNC, |
| 6569 | .v.func = alc_fixup_no_jack_detect, |
| 6570 | }, |
| 6571 | [ALC861_FIXUP_ASUS_A6RP] = { |
| 6572 | .type = ALC_FIXUP_FUNC, |
| 6573 | .v.func = alc861_fixup_asus_amp_vref_0f, |
| 6574 | .chained = true, |
| 6575 | .chain_id = ALC861_FIXUP_NO_JACK_DETECT, |
| 6576 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6577 | }; |
| 6578 | |
| 6579 | static const struct snd_pci_quirk alc861_fixup_tbl[] = { |
Takashi Iwai | e652f4c | 2012-02-13 11:56:25 +0100 | [diff] [blame] | 6580 | SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP), |
| 6581 | SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F), |
| 6582 | SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT), |
| 6583 | SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F), |
| 6584 | SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F), |
| 6585 | 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] | 6586 | {} |
| 6587 | }; |
| 6588 | |
| 6589 | /* |
| 6590 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6591 | static int patch_alc861(struct hda_codec *codec) |
| 6592 | { |
| 6593 | struct alc_spec *spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6594 | int err; |
| 6595 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6596 | err = alc_alloc_spec(codec, 0x15); |
| 6597 | if (err < 0) |
| 6598 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6599 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6600 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6601 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6602 | alc_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups); |
| 6603 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6604 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6605 | /* automatic parse from the BIOS config */ |
| 6606 | err = alc861_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6607 | if (err < 0) |
| 6608 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6609 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6610 | if (!spec->no_analog) { |
| 6611 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6612 | if (err < 0) |
| 6613 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6614 | set_beep_amp(spec, 0x23, 0, HDA_OUTPUT); |
| 6615 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6616 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6617 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 83012a7 | 2012-08-24 18:38:08 +0200 | [diff] [blame] | 6618 | #ifdef CONFIG_PM |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6619 | spec->power_hook = alc_power_eapd; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6620 | #endif |
| 6621 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6622 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6623 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6624 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6625 | |
| 6626 | error: |
| 6627 | alc_free(codec); |
| 6628 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6629 | } |
| 6630 | |
| 6631 | /* |
| 6632 | * ALC861-VD support |
| 6633 | * |
| 6634 | * Based on ALC882 |
| 6635 | * |
| 6636 | * In addition, an independent DAC |
| 6637 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6638 | static int alc861vd_parse_auto_config(struct hda_codec *codec) |
| 6639 | { |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6640 | static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6641 | static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6642 | return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6643 | } |
| 6644 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6645 | enum { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6646 | ALC660VD_FIX_ASUS_GPIO1, |
| 6647 | ALC861VD_FIX_DALLAS, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6648 | }; |
| 6649 | |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6650 | /* exclude VREF80 */ |
| 6651 | static void alc861vd_fixup_dallas(struct hda_codec *codec, |
| 6652 | const struct alc_fixup *fix, int action) |
| 6653 | { |
| 6654 | if (action == ALC_FIXUP_ACT_PRE_PROBE) { |
Takashi Iwai | b78562b | 2012-12-17 20:06:49 +0100 | [diff] [blame] | 6655 | snd_hda_override_pin_caps(codec, 0x18, 0x00000734); |
| 6656 | snd_hda_override_pin_caps(codec, 0x19, 0x0000073c); |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6657 | } |
| 6658 | } |
| 6659 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6660 | static const struct alc_fixup alc861vd_fixups[] = { |
| 6661 | [ALC660VD_FIX_ASUS_GPIO1] = { |
| 6662 | .type = ALC_FIXUP_VERBS, |
| 6663 | .v.verbs = (const struct hda_verb[]) { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6664 | /* reset GPIO1 */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6665 | {0x01, AC_VERB_SET_GPIO_MASK, 0x03}, |
| 6666 | {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01}, |
| 6667 | {0x01, AC_VERB_SET_GPIO_DATA, 0x01}, |
| 6668 | { } |
| 6669 | } |
| 6670 | }, |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6671 | [ALC861VD_FIX_DALLAS] = { |
| 6672 | .type = ALC_FIXUP_FUNC, |
| 6673 | .v.func = alc861vd_fixup_dallas, |
| 6674 | }, |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6675 | }; |
| 6676 | |
| 6677 | static const struct snd_pci_quirk alc861vd_fixup_tbl[] = { |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6678 | SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6679 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1), |
Takashi Iwai | 8fdcb6f | 2011-08-23 17:28:55 +0200 | [diff] [blame] | 6680 | SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS), |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6681 | {} |
| 6682 | }; |
| 6683 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6684 | /* |
| 6685 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6686 | static int patch_alc861vd(struct hda_codec *codec) |
| 6687 | { |
| 6688 | struct alc_spec *spec; |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6689 | int err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6690 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6691 | err = alc_alloc_spec(codec, 0x0b); |
| 6692 | if (err < 0) |
| 6693 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6694 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 6695 | spec = codec->spec; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6696 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6697 | alc_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups); |
| 6698 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6699 | |
Takashi Iwai | cb4e482 | 2011-08-23 17:34:25 +0200 | [diff] [blame] | 6700 | /* automatic parse from the BIOS config */ |
| 6701 | err = alc861vd_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6702 | if (err < 0) |
| 6703 | goto error; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6704 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6705 | if (!spec->no_analog) { |
| 6706 | err = snd_hda_attach_beep_device(codec, 0x23); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6707 | if (err < 0) |
| 6708 | goto error; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6709 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 6710 | } |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6711 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6712 | codec->patch_ops = alc_patch_ops; |
| 6713 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6714 | spec->shutup = alc_eapd_shutup; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6715 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 6716 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 6717 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6718 | return 0; |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 6719 | |
| 6720 | error: |
| 6721 | alc_free(codec); |
| 6722 | return err; |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6723 | } |
| 6724 | |
| 6725 | /* |
| 6726 | * ALC662 support |
| 6727 | * |
| 6728 | * ALC662 is almost identical with ALC880 but has cleaner and more flexible |
| 6729 | * configuration. Each pin widget can choose any input DACs and a mixer. |
| 6730 | * Each ADC is connected from a mixer of all inputs. This makes possible |
| 6731 | * 6-channel independent captures. |
| 6732 | * |
| 6733 | * In addition, an independent DAC for the multi-playback (not used in this |
| 6734 | * driver yet). |
| 6735 | */ |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 6736 | |
| 6737 | /* |
| 6738 | * BIOS auto configuration |
| 6739 | */ |
| 6740 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6741 | static int alc662_parse_auto_config(struct hda_codec *codec) |
| 6742 | { |
Takashi Iwai | 4c6d72d | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6743 | static const hda_nid_t alc662_ignore[] = { 0x1d, 0 }; |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6744 | static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 }; |
| 6745 | static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 }; |
| 6746 | const hda_nid_t *ssids; |
Takashi Iwai | ee979a14 | 2008-09-02 15:42:20 +0200 | [diff] [blame] | 6747 | |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6748 | if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 || |
| 6749 | codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670) |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6750 | ssids = alc663_ssids; |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 6751 | else |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 6752 | ssids = alc662_ssids; |
| 6753 | return alc_parse_auto_config(codec, alc662_ignore, ssids); |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 6754 | } |
| 6755 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6756 | static void alc272_fixup_mario(struct hda_codec *codec, |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6757 | const struct alc_fixup *fix, int action) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6758 | { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6759 | if (action != ALC_FIXUP_ACT_PROBE) |
Takashi Iwai | 6fc398c | 2011-01-13 14:36:37 +0100 | [diff] [blame] | 6760 | return; |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6761 | if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT, |
| 6762 | (0x3b << AC_AMPCAP_OFFSET_SHIFT) | |
| 6763 | (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) | |
| 6764 | (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) | |
| 6765 | (0 << AC_AMPCAP_MUTE_SHIFT))) |
| 6766 | printk(KERN_WARNING |
| 6767 | "hda_codec: failed to override amp caps for NID 0x2\n"); |
| 6768 | } |
| 6769 | |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6770 | enum { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6771 | ALC662_FIXUP_ASPIRE, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6772 | ALC662_FIXUP_IDEAPAD, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6773 | ALC272_FIXUP_MARIO, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6774 | ALC662_FIXUP_CZC_P10T, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6775 | ALC662_FIXUP_SKU_IGNORE, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6776 | ALC662_FIXUP_HP_RP5800, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6777 | ALC662_FIXUP_ASUS_MODE1, |
| 6778 | ALC662_FIXUP_ASUS_MODE2, |
| 6779 | ALC662_FIXUP_ASUS_MODE3, |
| 6780 | ALC662_FIXUP_ASUS_MODE4, |
| 6781 | ALC662_FIXUP_ASUS_MODE5, |
| 6782 | ALC662_FIXUP_ASUS_MODE6, |
| 6783 | ALC662_FIXUP_ASUS_MODE7, |
| 6784 | ALC662_FIXUP_ASUS_MODE8, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6785 | ALC662_FIXUP_NO_JACK_DETECT, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6786 | ALC662_FIXUP_ZOTAC_Z68, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6787 | ALC662_FIXUP_INV_DMIC, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6788 | }; |
| 6789 | |
| 6790 | static const struct alc_fixup alc662_fixups[] = { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6791 | [ALC662_FIXUP_ASPIRE] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6792 | .type = ALC_FIXUP_PINS, |
| 6793 | .v.pins = (const struct alc_pincfg[]) { |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6794 | { 0x15, 0x99130112 }, /* subwoofer */ |
| 6795 | { } |
| 6796 | } |
| 6797 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6798 | [ALC662_FIXUP_IDEAPAD] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6799 | .type = ALC_FIXUP_PINS, |
| 6800 | .v.pins = (const struct alc_pincfg[]) { |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6801 | { 0x17, 0x99130112 }, /* subwoofer */ |
| 6802 | { } |
| 6803 | } |
| 6804 | }, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 6805 | [ALC272_FIXUP_MARIO] = { |
Takashi Iwai | b5bfbc6 | 2011-01-13 14:22:32 +0100 | [diff] [blame] | 6806 | .type = ALC_FIXUP_FUNC, |
| 6807 | .v.func = alc272_fixup_mario, |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6808 | }, |
| 6809 | [ALC662_FIXUP_CZC_P10T] = { |
| 6810 | .type = ALC_FIXUP_VERBS, |
| 6811 | .v.verbs = (const struct hda_verb[]) { |
| 6812 | {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0}, |
| 6813 | {} |
| 6814 | } |
| 6815 | }, |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6816 | [ALC662_FIXUP_SKU_IGNORE] = { |
Takashi Iwai | 23d30f2 | 2012-05-07 17:17:32 +0200 | [diff] [blame] | 6817 | .type = ALC_FIXUP_FUNC, |
| 6818 | .v.func = alc_fixup_sku_ignore, |
Takashi Iwai | c6b3587 | 2011-03-28 12:05:31 +0200 | [diff] [blame] | 6819 | }, |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6820 | [ALC662_FIXUP_HP_RP5800] = { |
| 6821 | .type = ALC_FIXUP_PINS, |
| 6822 | .v.pins = (const struct alc_pincfg[]) { |
| 6823 | { 0x14, 0x0221201f }, /* HP out */ |
| 6824 | { } |
| 6825 | }, |
| 6826 | .chained = true, |
| 6827 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6828 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6829 | [ALC662_FIXUP_ASUS_MODE1] = { |
| 6830 | .type = ALC_FIXUP_PINS, |
| 6831 | .v.pins = (const struct alc_pincfg[]) { |
| 6832 | { 0x14, 0x99130110 }, /* speaker */ |
| 6833 | { 0x18, 0x01a19c20 }, /* mic */ |
| 6834 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6835 | { 0x21, 0x0121401f }, /* HP out */ |
| 6836 | { } |
| 6837 | }, |
| 6838 | .chained = true, |
| 6839 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6840 | }, |
| 6841 | [ALC662_FIXUP_ASUS_MODE2] = { |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6842 | .type = ALC_FIXUP_PINS, |
| 6843 | .v.pins = (const struct alc_pincfg[]) { |
| 6844 | { 0x14, 0x99130110 }, /* speaker */ |
| 6845 | { 0x18, 0x01a19820 }, /* mic */ |
| 6846 | { 0x19, 0x99a3092f }, /* int-mic */ |
| 6847 | { 0x1b, 0x0121401f }, /* HP out */ |
| 6848 | { } |
| 6849 | }, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6850 | .chained = true, |
| 6851 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6852 | }, |
| 6853 | [ALC662_FIXUP_ASUS_MODE3] = { |
| 6854 | .type = ALC_FIXUP_PINS, |
| 6855 | .v.pins = (const struct alc_pincfg[]) { |
| 6856 | { 0x14, 0x99130110 }, /* speaker */ |
| 6857 | { 0x15, 0x0121441f }, /* HP */ |
| 6858 | { 0x18, 0x01a19840 }, /* mic */ |
| 6859 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6860 | { 0x21, 0x01211420 }, /* HP2 */ |
| 6861 | { } |
| 6862 | }, |
| 6863 | .chained = true, |
| 6864 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6865 | }, |
| 6866 | [ALC662_FIXUP_ASUS_MODE4] = { |
| 6867 | .type = ALC_FIXUP_PINS, |
| 6868 | .v.pins = (const struct alc_pincfg[]) { |
| 6869 | { 0x14, 0x99130110 }, /* speaker */ |
| 6870 | { 0x16, 0x99130111 }, /* speaker */ |
| 6871 | { 0x18, 0x01a19840 }, /* mic */ |
| 6872 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6873 | { 0x21, 0x0121441f }, /* HP */ |
| 6874 | { } |
| 6875 | }, |
| 6876 | .chained = true, |
| 6877 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6878 | }, |
| 6879 | [ALC662_FIXUP_ASUS_MODE5] = { |
| 6880 | .type = ALC_FIXUP_PINS, |
| 6881 | .v.pins = (const struct alc_pincfg[]) { |
| 6882 | { 0x14, 0x99130110 }, /* speaker */ |
| 6883 | { 0x15, 0x0121441f }, /* HP */ |
| 6884 | { 0x16, 0x99130111 }, /* speaker */ |
| 6885 | { 0x18, 0x01a19840 }, /* mic */ |
| 6886 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6887 | { } |
| 6888 | }, |
| 6889 | .chained = true, |
| 6890 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6891 | }, |
| 6892 | [ALC662_FIXUP_ASUS_MODE6] = { |
| 6893 | .type = ALC_FIXUP_PINS, |
| 6894 | .v.pins = (const struct alc_pincfg[]) { |
| 6895 | { 0x14, 0x99130110 }, /* speaker */ |
| 6896 | { 0x15, 0x01211420 }, /* HP2 */ |
| 6897 | { 0x18, 0x01a19840 }, /* mic */ |
| 6898 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6899 | { 0x1b, 0x0121441f }, /* HP */ |
| 6900 | { } |
| 6901 | }, |
| 6902 | .chained = true, |
| 6903 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6904 | }, |
| 6905 | [ALC662_FIXUP_ASUS_MODE7] = { |
| 6906 | .type = ALC_FIXUP_PINS, |
| 6907 | .v.pins = (const struct alc_pincfg[]) { |
| 6908 | { 0x14, 0x99130110 }, /* speaker */ |
| 6909 | { 0x17, 0x99130111 }, /* speaker */ |
| 6910 | { 0x18, 0x01a19840 }, /* mic */ |
| 6911 | { 0x19, 0x99a3094f }, /* int-mic */ |
| 6912 | { 0x1b, 0x01214020 }, /* HP */ |
| 6913 | { 0x21, 0x0121401f }, /* HP */ |
| 6914 | { } |
| 6915 | }, |
| 6916 | .chained = true, |
| 6917 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
| 6918 | }, |
| 6919 | [ALC662_FIXUP_ASUS_MODE8] = { |
| 6920 | .type = ALC_FIXUP_PINS, |
| 6921 | .v.pins = (const struct alc_pincfg[]) { |
| 6922 | { 0x14, 0x99130110 }, /* speaker */ |
| 6923 | { 0x12, 0x99a30970 }, /* int-mic */ |
| 6924 | { 0x15, 0x01214020 }, /* HP */ |
| 6925 | { 0x17, 0x99130111 }, /* speaker */ |
| 6926 | { 0x18, 0x01a19840 }, /* mic */ |
| 6927 | { 0x21, 0x0121401f }, /* HP */ |
| 6928 | { } |
| 6929 | }, |
| 6930 | .chained = true, |
| 6931 | .chain_id = ALC662_FIXUP_SKU_IGNORE |
Takashi Iwai | 2996bdb | 2011-08-18 16:02:24 +0200 | [diff] [blame] | 6932 | }, |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6933 | [ALC662_FIXUP_NO_JACK_DETECT] = { |
| 6934 | .type = ALC_FIXUP_FUNC, |
| 6935 | .v.func = alc_fixup_no_jack_detect, |
| 6936 | }, |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6937 | [ALC662_FIXUP_ZOTAC_Z68] = { |
| 6938 | .type = ALC_FIXUP_PINS, |
| 6939 | .v.pins = (const struct alc_pincfg[]) { |
| 6940 | { 0x1b, 0x02214020 }, /* Front HP */ |
| 6941 | { } |
| 6942 | } |
| 6943 | }, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6944 | [ALC662_FIXUP_INV_DMIC] = { |
| 6945 | .type = ALC_FIXUP_FUNC, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 6946 | .v.func = alc_fixup_inv_dmic_0x12, |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6947 | }, |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6948 | }; |
| 6949 | |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 6950 | static const struct snd_pci_quirk alc662_fixup_tbl[] = { |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6951 | SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2), |
David Henningsson | a6c47a8 | 2011-02-10 15:39:19 +0100 | [diff] [blame] | 6952 | SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE), |
David Henningsson | 94024cd | 2011-04-29 14:10:55 +0200 | [diff] [blame] | 6953 | SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE), |
Takashi Iwai | 125821a | 2012-06-22 14:30:29 +0200 | [diff] [blame] | 6954 | SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC), |
Daniel T Chen | 2df0351 | 2010-10-10 22:39:28 -0400 | [diff] [blame] | 6955 | SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), |
Takashi Iwai | e59ea3e | 2011-06-29 17:21:00 +0200 | [diff] [blame] | 6956 | SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), |
Takashi Iwai | 1565cc3 | 2012-02-13 12:03:25 +0100 | [diff] [blame] | 6957 | SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6958 | SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2), |
Daniel T Chen | a0e90ac | 2010-11-20 10:20:35 -0500 | [diff] [blame] | 6959 | SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD), |
Valentine Sinitsyn | d411858 | 2010-10-01 22:24:08 +0600 | [diff] [blame] | 6960 | SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD), |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 6961 | SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD), |
David Henningsson | edfe3bf | 2012-06-12 13:15:12 +0200 | [diff] [blame] | 6962 | SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68), |
Anisse Astier | d2ebd47 | 2011-01-20 12:36:21 +0100 | [diff] [blame] | 6963 | SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T), |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6964 | |
| 6965 | #if 0 |
| 6966 | /* Below is a quirk table taken from the old code. |
| 6967 | * Basically the device should work as is without the fixup table. |
| 6968 | * If BIOS doesn't give a proper info, enable the corresponding |
| 6969 | * fixup entry. |
Jesper Juhl | 7d7eb9e | 2012-04-12 22:11:25 +0200 | [diff] [blame] | 6970 | */ |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 6971 | SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1), |
| 6972 | SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3), |
| 6973 | SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1), |
| 6974 | SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3), |
| 6975 | SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6976 | SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6977 | SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 6978 | SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1), |
| 6979 | SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1), |
| 6980 | SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6981 | SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7), |
| 6982 | SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7), |
| 6983 | SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8), |
| 6984 | SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3), |
| 6985 | SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1), |
| 6986 | SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6987 | SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2), |
| 6988 | SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1), |
| 6989 | SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6990 | SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6991 | SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6992 | SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6993 | SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1), |
| 6994 | SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3), |
| 6995 | SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2), |
| 6996 | SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 6997 | SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5), |
| 6998 | SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6), |
| 6999 | SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7000 | SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1), |
| 7001 | SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7002 | SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7003 | SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3), |
| 7004 | SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3), |
| 7005 | SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1), |
| 7006 | SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1), |
| 7007 | SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1), |
| 7008 | SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1), |
| 7009 | SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1), |
| 7010 | SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2), |
| 7011 | SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2), |
| 7012 | SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1), |
| 7013 | SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7014 | SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3), |
| 7015 | SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1), |
| 7016 | SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1), |
| 7017 | SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1), |
| 7018 | SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2), |
| 7019 | SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1), |
| 7020 | SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4), |
| 7021 | #endif |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7022 | {} |
| 7023 | }; |
| 7024 | |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7025 | static const struct alc_model_fixup alc662_fixup_models[] = { |
| 7026 | {.id = ALC272_FIXUP_MARIO, .name = "mario"}, |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7027 | {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"}, |
| 7028 | {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"}, |
| 7029 | {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"}, |
| 7030 | {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"}, |
| 7031 | {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"}, |
| 7032 | {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"}, |
| 7033 | {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"}, |
| 7034 | {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"}, |
Takashi Iwai | 6e72aa5 | 2012-06-25 10:52:25 +0200 | [diff] [blame] | 7035 | {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"}, |
Todd Broch | 6be7948 | 2010-12-07 16:51:05 -0800 | [diff] [blame] | 7036 | {} |
| 7037 | }; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7038 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7039 | static void alc662_fill_coef(struct hda_codec *codec) |
| 7040 | { |
| 7041 | int val, coef; |
| 7042 | |
| 7043 | coef = alc_get_coef0(codec); |
| 7044 | |
| 7045 | switch (codec->vendor_id) { |
| 7046 | case 0x10ec0662: |
| 7047 | if ((coef & 0x00f0) == 0x0030) { |
| 7048 | val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */ |
| 7049 | alc_write_coef_idx(codec, 0x4, val & ~(1<<10)); |
| 7050 | } |
| 7051 | break; |
| 7052 | case 0x10ec0272: |
| 7053 | case 0x10ec0273: |
| 7054 | case 0x10ec0663: |
| 7055 | case 0x10ec0665: |
| 7056 | case 0x10ec0670: |
| 7057 | case 0x10ec0671: |
| 7058 | case 0x10ec0672: |
| 7059 | val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */ |
| 7060 | alc_write_coef_idx(codec, 0xd, val | (1<<14)); |
| 7061 | break; |
| 7062 | } |
| 7063 | } |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7064 | |
Takashi Iwai | 1d045db | 2011-07-07 18:23:21 +0200 | [diff] [blame] | 7065 | /* |
| 7066 | */ |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7067 | static int patch_alc662(struct hda_codec *codec) |
| 7068 | { |
| 7069 | struct alc_spec *spec; |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7070 | int err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7071 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7072 | err = alc_alloc_spec(codec, 0x0b); |
| 7073 | if (err < 0) |
| 7074 | return err; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7075 | |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7076 | spec = codec->spec; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7077 | |
Takashi Iwai | 53c334a | 2011-08-23 18:27:14 +0200 | [diff] [blame] | 7078 | /* handle multiple HPs as is */ |
| 7079 | spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP; |
| 7080 | |
Takashi Iwai | 2c3bf9a | 2008-06-04 12:39:38 +0200 | [diff] [blame] | 7081 | alc_fix_pll_init(codec, 0x20, 0x04, 15); |
| 7082 | |
Kailang Yang | 8663ff7 | 2012-06-29 09:35:52 +0200 | [diff] [blame] | 7083 | spec->init_hook = alc662_fill_coef; |
| 7084 | alc662_fill_coef(codec); |
| 7085 | |
Takashi Iwai | 8e5a050 | 2012-06-21 15:49:33 +0200 | [diff] [blame] | 7086 | alc_pick_fixup(codec, alc662_fixup_models, |
| 7087 | alc662_fixup_tbl, alc662_fixups); |
| 7088 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); |
| 7089 | |
| 7090 | alc_auto_parse_customize_define(codec); |
| 7091 | |
Takashi Iwai | 1bb7e43 | 2011-10-17 16:50:59 +0200 | [diff] [blame] | 7092 | if ((alc_get_coef0(codec) & (1 << 14)) && |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7093 | codec->bus->pci->subsystem_vendor == 0x1025 && |
| 7094 | spec->cdefine.platform_type == 1) { |
| 7095 | if (alc_codec_rename(codec, "ALC272X") < 0) |
| 7096 | goto error; |
Takashi Iwai | 20ca0c3 | 2011-10-17 16:00:35 +0200 | [diff] [blame] | 7097 | } |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7098 | |
Takashi Iwai | b9c5106 | 2011-08-24 18:08:07 +0200 | [diff] [blame] | 7099 | /* automatic parse from the BIOS config */ |
| 7100 | err = alc662_parse_auto_config(codec); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7101 | if (err < 0) |
| 7102 | goto error; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7103 | |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7104 | if (!spec->no_analog && has_cdefine_beep(codec)) { |
| 7105 | err = snd_hda_attach_beep_device(codec, 0x1); |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7106 | if (err < 0) |
| 7107 | goto error; |
Kailang Yang | da00c24 | 2010-03-19 11:23:45 +0100 | [diff] [blame] | 7108 | switch (codec->vendor_id) { |
| 7109 | case 0x10ec0662: |
| 7110 | set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); |
| 7111 | break; |
| 7112 | case 0x10ec0272: |
| 7113 | case 0x10ec0663: |
| 7114 | case 0x10ec0665: |
| 7115 | set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); |
| 7116 | break; |
| 7117 | case 0x10ec0273: |
| 7118 | set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT); |
| 7119 | break; |
| 7120 | } |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7121 | } |
Takashi Iwai | 2134ea4 | 2008-01-10 16:53:55 +0100 | [diff] [blame] | 7122 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7123 | codec->patch_ops = alc_patch_ops; |
Takashi Iwai | 1c716153 | 2011-04-07 10:37:16 +0200 | [diff] [blame] | 7124 | spec->shutup = alc_eapd_shutup; |
David Henningsson | 6cb3b70 | 2010-09-09 08:51:44 +0200 | [diff] [blame] | 7125 | |
Takashi Iwai | 589876e | 2012-02-20 15:47:55 +0100 | [diff] [blame] | 7126 | alc_apply_fixup(codec, ALC_FIXUP_ACT_PROBE); |
| 7127 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7128 | return 0; |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7129 | |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7130 | error: |
| 7131 | alc_free(codec); |
| 7132 | return err; |
Kailang Yang | b478b99 | 2011-05-18 11:51:15 +0200 | [diff] [blame] | 7133 | } |
| 7134 | |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7135 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7136 | * ALC680 support |
| 7137 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7138 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7139 | static int alc680_parse_auto_config(struct hda_codec *codec) |
| 7140 | { |
Takashi Iwai | 3e6179b | 2011-07-08 16:55:13 +0200 | [diff] [blame] | 7141 | return alc_parse_auto_config(codec, NULL, NULL); |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7142 | } |
| 7143 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7144 | /* |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7145 | */ |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7146 | static int patch_alc680(struct hda_codec *codec) |
| 7147 | { |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7148 | int err; |
| 7149 | |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7150 | /* ALC680 has no aa-loopback mixer */ |
Takashi Iwai | 3de9517 | 2012-05-07 18:03:15 +0200 | [diff] [blame] | 7151 | err = alc_alloc_spec(codec, 0); |
| 7152 | if (err < 0) |
| 7153 | return err; |
Takashi Iwai | 1f0f4b8 | 2011-06-27 10:52:59 +0200 | [diff] [blame] | 7154 | |
Takashi Iwai | 1ebec5f | 2011-08-15 13:21:48 +0200 | [diff] [blame] | 7155 | /* automatic parse from the BIOS config */ |
| 7156 | err = alc680_parse_auto_config(codec); |
| 7157 | if (err < 0) { |
| 7158 | alc_free(codec); |
| 7159 | return err; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7160 | } |
| 7161 | |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7162 | codec->patch_ops = alc_patch_ops; |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7163 | |
| 7164 | return 0; |
| 7165 | } |
| 7166 | |
| 7167 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7168 | * patch entries |
| 7169 | */ |
Takashi Iwai | a911132 | 2011-05-02 11:30:18 +0200 | [diff] [blame] | 7170 | static const struct hda_codec_preset snd_hda_preset_realtek[] = { |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7171 | { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7172 | { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7173 | { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7174 | { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 }, |
Kailang Yang | a361d84 | 2007-06-05 12:30:55 +0200 | [diff] [blame] | 7175 | { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 }, |
Kailang Yang | f6a9224 | 2007-12-13 16:52:54 +0100 | [diff] [blame] | 7176 | { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7177 | { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 }, |
Kailang Yang | 01afd41 | 2008-10-15 11:22:09 +0200 | [diff] [blame] | 7178 | { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 }, |
Kailang Yang | ebb83ee | 2009-12-17 12:23:00 +0100 | [diff] [blame] | 7179 | { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 }, |
Kailang Yang | 296f033 | 2011-05-18 11:52:36 +0200 | [diff] [blame] | 7180 | { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 }, |
David Henningsson | befae82 | 2012-06-25 19:49:28 +0200 | [diff] [blame] | 7181 | { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 }, |
David Henningsson | 4e01ec6 | 2012-07-18 07:38:46 +0200 | [diff] [blame] | 7182 | { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7183 | { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, |
Kailang Yang | 065380f | 2013-01-10 10:25:48 +0100 | [diff] [blame] | 7184 | { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 }, |
Kailang Yang | 7ff34ad | 2012-10-06 17:02:30 +0200 | [diff] [blame] | 7185 | { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, |
David Henningsson | af02dde | 2012-11-21 08:57:58 +0100 | [diff] [blame] | 7186 | { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7187 | { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7188 | .patch = patch_alc861 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7189 | { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, |
| 7190 | { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 }, |
| 7191 | { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7192 | { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7193 | .patch = patch_alc882 }, |
Kailang Yang | bc9f98a | 2007-04-12 13:06:07 +0200 | [diff] [blame] | 7194 | { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1", |
| 7195 | .patch = patch_alc662 }, |
David Henningsson | cc667a7 | 2011-10-18 14:07:51 +0200 | [diff] [blame] | 7196 | { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3", |
| 7197 | .patch = patch_alc662 }, |
Kailang Yang | 6dda9f4 | 2008-05-27 12:05:31 +0200 | [diff] [blame] | 7198 | { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, |
Kailang Yang | cec27c8 | 2010-02-04 14:18:18 +0100 | [diff] [blame] | 7199 | { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7200 | { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 }, |
Kailang Yang | 6227cdc | 2010-02-25 08:36:52 +0100 | [diff] [blame] | 7201 | { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, |
Kailang Yang | d1eb57f | 2010-06-23 16:25:26 +0200 | [diff] [blame] | 7202 | { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, |
Jakub Schmidtke | f32610e | 2007-02-02 18:17:27 +0100 | [diff] [blame] | 7203 | { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7204 | { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7205 | { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 }, |
Clive Messer | 669faba | 2008-09-30 15:49:13 +0200 | [diff] [blame] | 7206 | { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7207 | .patch = patch_alc882 }, |
Takashi Iwai | cb308f9 | 2008-04-16 14:13:29 +0200 | [diff] [blame] | 7208 | { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7209 | .patch = patch_alc882 }, |
Kailang Yang | df694da | 2005-12-05 19:42:22 +0100 | [diff] [blame] | 7210 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7211 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 }, |
Kailang Yang | 4442608 | 2008-10-15 11:18:05 +0200 | [diff] [blame] | 7212 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7213 | .patch = patch_alc882 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7214 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 }, |
Takashi Iwai | 4953550a | 2009-06-30 15:28:30 +0200 | [diff] [blame] | 7215 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, |
Kailang Yang | 274693f | 2009-12-03 10:07:50 +0100 | [diff] [blame] | 7216 | { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, |
Takashi Iwai | e16fb6d | 2011-10-17 16:39:09 +0200 | [diff] [blame] | 7217 | { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, |
Kailang Yang | 19a6282 | 2012-11-08 10:25:37 +0100 | [diff] [blame] | 7218 | { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7219 | {} /* terminator */ |
| 7220 | }; |
Takashi Iwai | 1289e9e | 2008-11-27 15:47:11 +0100 | [diff] [blame] | 7221 | |
| 7222 | MODULE_ALIAS("snd-hda-codec-id:10ec*"); |
| 7223 | |
| 7224 | MODULE_LICENSE("GPL"); |
| 7225 | MODULE_DESCRIPTION("Realtek HD-audio codec"); |
| 7226 | |
| 7227 | static struct hda_codec_preset_list realtek_list = { |
| 7228 | .preset = snd_hda_preset_realtek, |
| 7229 | .owner = THIS_MODULE, |
| 7230 | }; |
| 7231 | |
| 7232 | static int __init patch_realtek_init(void) |
| 7233 | { |
| 7234 | return snd_hda_add_codec_preset(&realtek_list); |
| 7235 | } |
| 7236 | |
| 7237 | static void __exit patch_realtek_exit(void) |
| 7238 | { |
| 7239 | snd_hda_delete_codec_preset(&realtek_list); |
| 7240 | } |
| 7241 | |
| 7242 | module_init(patch_realtek_init) |
| 7243 | module_exit(patch_realtek_exit) |